MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestDefaultMatrix

Function TestDefaultMatrix

math/matrix/determinant_test.go:99–114  ·  view source on GitHub ↗

Test matrix returned from matrix.New

(t *testing.T)

Source from the content-addressed store, hash-verified

97
98// Test matrix returned from matrix.New
99func TestDefaultMatrix(t *testing.T) {
100 initialValue := 0
101 initialRows := 3
102 initialCols := 3
103 defaultMatrix := matrix.New(initialRows, initialCols, initialValue)
104
105 determinant, err := defaultMatrix.Determinant()
106
107 if err != nil {
108 t.Fatalf("Error finding the determinant of 3 by 3 default matrix: %v.", err)
109 }
110 expectedValue := 0
111 if determinant != expectedValue {
112 t.Errorf("Determinant of the default matrix with an initial value 0 was %d; wanted %d.", initialValue, expectedValue)
113 }
114}
115
116// Benchmark a 3 by 3 matrix for computational throughput
117func BenchmarkSmallMatrixDeterminant(b *testing.B) {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
DeterminantMethod · 0.80

Tested by

no test coverage detected