Matrices
Examples
Filter
package main
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
func main() {
// Initialize two matrices, a and b.
a := mat.NewDense(2, 2, []float64{
4, 0,
0, 4,
})
b := mat.NewDense(2, 3, []float64{
4, 0, 0,
0, 0, 4,
})
// Take the matrix product of a and b and place the result in c.
var c mat.Dense
c.Mul(a, b)
// Print the result using the formatter.
fc := mat.Formatted(&c, mat.Prefix(" "), mat.Squeeze())
fmt.Printf("c = %v", fc)
}
Last Run
:
c = ⎡16 0 0⎤
⎣ 0 0 16⎦