func TestFMath(t *testing.T) { fmt.Printf("Test matrix basic math.\n") A := matrix.ComplexZeros(2, 2) fmt.Printf("A\n%v\n", A) A = Add(A, 1.0) fmt.Printf("A += 1.0\n%v\n", A) A = Scale(A, 9.0) fmt.Printf("A *= 9.0\n%v\n", A) A = Add(A, -1.0) fmt.Printf("A -= 1.0\n%v\n", A) A = Mul(A, A) fmt.Printf("A = A .* A\n%v\n", A) }
// Return Complex(Real, Imag). Return a new matrix. func Complex(Real, Imag *matrix.FloatMatrix) *matrix.ComplexMatrix { if !Real.SizeMatch(Imag.Size()) { return nil } C := matrix.ComplexZeros(Real.Size()) Rr := Real.FloatArray() Ir := Imag.FloatArray() Cr := C.ComplexArray() for i, _ := range Rr { Cr[i] = complex(Rr[i], Ir[i]) } return C }