Example #1
0
func TestMatrixCopy(t *testing.T) {
	M := MakeDenseMatrix([]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, 4, 4)
	C := M.Copy()

	utils.Expect(t, "7", C.Get(1, 2))

	C.Set(1, 2, 77)
	utils.Expect(t, "7", M.Get(1, 2))
}
Example #2
0
func TestGetSet(t *testing.T) {
	M := MakeDenseMatrix([]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, 4, 4)

	M.Set(1, 2, 33)
	fmt.Println(M.String())
	utils.Expect(t, "33", M.Get(1, 2))
}
Example #3
0
func TestRowVector(t *testing.T) {
	fmt.Println("TestColVector")
	M := MakeDenseMatrix([]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, 4, 4)
	fmt.Println(M)

	row_vec := M.RowVector(0)
	fmt.Println(row_vec)

	row_vec.Set(0, 1, 200)
	utils.Expect(t, "2", M.Get(0, 1))
}
Example #4
0
func TestColVector(t *testing.T) {
	fmt.Println("TestColVector")
	M := MakeDenseMatrix([]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, 4, 4)
	fmt.Println(M)

	col_vec := M.ColVector(0)
	fmt.Println(col_vec)

	col_vec.Set(1, 0, 100)
	utils.Expect(t, "5", M.Get(1, 0))
}
Example #5
0
func TestArrays(t *testing.T) {
	M := MakeDenseMatrix([]float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, 4, 4)
	fmt.Println(String(M))

	arrays := M.Arrays()
	arrays[1][1] = 111
	utils.Expect(t, "111", M.Get(1, 1))

	array := M.Array()
	array[2] = 100
	utils.Expect(t, "100", M.Get(0, 2))

	fmt.Println(M.Arrays())
	fmt.Println(M.Array())

	row_slice := M.RowSlice(1)
	row_slice[1] = 99
	utils.Expect(t, "99", M.Get(1, 1))
	fmt.Println(M.String())

}
Example #6
0
func TestCopy(t *testing.T) {
	va := NewVector(3)
	va.SetValues([]float64{1, 2, 3})
	utils.Expect(t, "1", va.Get(0))
}