March 2019
Intermediate to advanced
336 pages
9h 9m
English
The multiply method multiplies the elements of two 2 x 2 matrices. The multiplication of two matrices, matrix1 and matrix2, is shown in the following snippet. The matrix that's generated after the multiplication is returned by the multiply method:
// multiply methodfunc multiply(matrix1 [2][2]int, matrix2 [2][2]int) [2][2]int { var m int var l int var n int var product [2][2]int for l = 0; l < 2; l++ { for m=0; m <2; m++ { var productSum int = 0 for n=0; n< 2; n++ { productSum = productSum + matrix1[l][n]*matrix2[n][m] } product[l][m] = productSum; } } return product}
The product of two matrices is calculated using the multiply method in the following code snippet, which takes the two matrices as parameters:
var product ...Read now
Unlock full access