示例#1
0
文件: complex.go 项目: Gwill/go-R
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)
	}
}
示例#2
0
文件: complex.go 项目: Gwill/go-R
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)
}