March 2020
Intermediate to advanced
406 pages
8h 39m
English
Matrix addition is the method in which we add two matrices together. Perhaps we want to find the resulting value of the summation of two 2D sets. If we have two matrices of the same size, we can add them together, like so:

We can also represent this in Go code, as shown in the following code block:
package mainimport ( "fmt" "gonum.org/v1/gonum/mat")func main() { a := mat.NewDense(3, 3, []float64{1, 2, 3, 4, 5, 6, 7, 8, 9}) a.Add(a, a) // add a and a together matrixPrint(a)}func matrixPrint(m mat.Matrix) { formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) fmt.Printf("%v\n", formattedMatrix)}
The result of executing ...
Read now
Unlock full access