Example #1
0
func BenchmarkMulGomatrix___32(bench *testing.B) {
	bench.StopTimer()
	rand.Seed(time.Now().Unix())
	n := 32
	a := randomMatrix(n, n)
	A := gomatrix.MakeDenseMatrix(a.data, a.height, a.width)
	b := randomMatrix(n, n)
	B := gomatrix.MakeDenseMatrix(b.data, b.height, b.width)
	bench.StartTimer()

	for i := 0; i < bench.N; i++ {
		A.TimesDense(B)
	}
}
Example #2
0
func TestGomatrix(t *testing.T) {
	n := 200
	a := randomMatrix(n, n)
	A := gomatrix.MakeDenseMatrix(a.data, a.height, a.width)
	b := randomMatrix(n, n)
	B := gomatrix.MakeDenseMatrix(b.data, b.height, b.width)
	C := MulNaive(a, b)
	D, _ := A.TimesDense(B)

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if math.Abs(C.At(i, j)-D.Get(i, j)) > ε {
				t.Fatalf("Wrong result: C(%d, %d) = %v \t D(%d, %d) = %v \n", i, j, C.At(i, j), i, j, D.Get(i, j))
			}
		}
	}
}