示例#1
0
文件: math.go 项目: sguzwf/algorithm
// 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
}
示例#2
0
文件: math.go 项目: sguzwf/algorithm
// Compute matrix product C = A * B where A is m*p and B is p*n.
// Returns a new m*n matrix.
func Times(A, B *matrix.ComplexMatrix) *matrix.ComplexMatrix {
	if A.Cols() != B.Rows() {
		return nil
	}
	return A.Times(B)
}