March 2019
Intermediate to advanced
336 pages
9h 9m
English
The inverse method returns the inverse of the matrix, which is passed as a parameter. This is shown in the following snippet:
//inverse methodfunc inverse(matrix [2][2]int) [][]float64 { var det float64 det = determinant(matrix) var invmatrix float64 invmatrix[0][0] = matrix[1][1]/det invmatrix[0][1] = -1*matrix[0][1]/det invmatrix[1][0] = -1*matrix[1][0]/det invmatrix[1][1] = matrix[0][0]/det return invmatrix}
Run the following command to execute the twodmatrix.go file:
go run twodmatrix.go
The output is as follows:

The next section talks about the zig-zag matrix data structure.
Read now
Unlock full access