示例#1
0
func TestEigSymm(t *testing.T) {
	n := 100
	a := randMat(n, n)
	a = mat.Plus(a, mat.T(a))

	// Take eigen decomposition.
	v, d, err := EigSymm(a)
	if err != nil {
		t.Fatal(err)
	}

	got := mat.Mul(mat.Mul(v, mat.NewDiag(d)), mat.T(v))
	testMatEq(t, a, got)
}
示例#2
0
文件: svd_test.go 项目: jvlmdr/lin-go
func TestSVD(t *testing.T) {
	m, n := 150, 100
	want := randMat(m, n)

	// Take singular value decomposition.
	u, s, vt, err := SVD(want)
	if err != nil {
		t.Fatal(err)
	}

	// Check that A = U S V'.
	got := mat.Mul(u, mat.Mul(mat.NewDiag(s), vt))
	testMatEq(t, want, got)
}