Пример #1
0
// Return Imag(A).
func Imag(A *matrix.ComplexMatrix) *matrix.FloatMatrix {
	C := matrix.FloatZeros(A.Size())
	Ar := A.ComplexArray()
	Cr := C.FloatArray()
	for i, v := range Ar {
		Cr[i] = imag(v)
	}
	return C
}
Пример #2
0
// Compute Abs(A), Returns a new float valued matrix.
func Abs(A *matrix.ComplexMatrix) *matrix.FloatMatrix {
	C := matrix.FloatZeros(A.Rows(), A.Cols())
	Cr := C.FloatArray()
	Ar := A.ComplexArray()
	for k, v := range Ar {
		Cr[k] = cmplx.Abs(v)
	}
	return C
}
Пример #3
0
// See function Asum.
func AsumComplex(X *matrix.ComplexMatrix, opts ...linalg.Option) (v float64, err error) {
	v = 0.0
	ind := linalg.GetIndexOpts(opts...)
	err = check_level1_func(ind, fasum, X, nil)
	if err != nil {
		return
	}
	if ind.Nx == 0 {
		return
	}
	Xa := X.ComplexArray()
	v = dzasum(ind.Nx, Xa[ind.OffsetX:], ind.IncX)
	return
}
Пример #4
0
// See function Dotc.
func DotcComplex(X, Y *matrix.ComplexMatrix, opts ...linalg.Option) (v complex128, err error) {
	v = 0.0
	ind := linalg.GetIndexOpts(opts...)
	err = check_level1_func(ind, fdot, X, Y)
	if err != nil {
		return
	}
	if ind.Nx == 0 {
		return
	}
	Xa := X.ComplexArray()
	Ya := Y.ComplexArray()
	v = zdotc(ind.Nx, Xa[ind.OffsetX:], ind.IncX, Ya[ind.OffsetY:], ind.IncY)
	return
}