March 2020
Intermediate to advanced
406 pages
8h 39m
English
Transposing a matrix flips a matrix diagonally, swapping rows and column indices. The following image shows an example transposition of a matrix:

We can represent a matrix transposition in Go using the following code:
package mainimport ( "fmt" "gonum.org/v1/gonum/mat")func main() { a := mat.NewDense(3, 3, []float64{5, 3, 10, 1, 6, 4, 8, 7, 2}) matrixPrint(a) matrixPrint(a.T())}func matrixPrint(m mat.Matrix) { formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) fmt.Printf("%v\n", formattedMatrix)}
The result of this matrix transposition can be seen in the following image:
In the preceding output, we can ...
Read now
Unlock full access