Example #1
0
func (this *ComplexVector) CopyFrom(src []complex128) {
	C.Rf_protect(this.expr)
	defer C.Rf_unprotect(1)
	for i := 0; i < this.length; i++ {
		var c C.Rcomplex
		c.r = C.double(real(src[i]))
		c.i = C.double(imag(src[i]))
		C.SetComplexVectorElt(this.expr, C.int(i), c)
	}
}
Example #2
0
func (this *ComplexVector) Set(i int, val complex128) {
	this.boundsCheck(i)
	C.Rf_protect(this.expr)
	defer C.Rf_unprotect(1)

	var c C.Rcomplex
	c.r = C.double(real(val))
	c.i = C.double(imag(val))
	C.SetComplexVectorElt(this.expr, C.int(i), c)
}