MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / MakeRandomMatrix

Function MakeRandomMatrix

math/matrix/strassenmatrixmultiply_test.go:105–118  ·  view source on GitHub ↗
(rows, columns int)

Source from the content-addressed store, hash-verified

103}
104
105func MakeRandomMatrix[T constraints.Integer](rows, columns int) matrix.Matrix[T] {
106 rand.New(rand.NewSource(time.Now().UnixNano()))
107
108 matrixData := make([][]T, rows)
109 for i := 0; i < rows; i++ {
110 matrixData[i] = make([]T, columns)
111 for j := 0; j < columns; j++ {
112 matrixData[i][j] = T(rand.Intn(1000)) // Generate random integers between 0 and 1000
113 }
114 }
115
116 randomMatrix, _ := matrix.NewFromElements(matrixData)
117 return randomMatrix
118}
119
120// BenchmarkStrassenMatrixMultiply benchmarks the StrassenMatrixMultiply function.
121func BenchmarkStrassenMatrixMultiply(b *testing.B) {

Callers

nothing calls this directly

Calls 1

NewFromElementsFunction · 0.92

Tested by

no test coverage detected