MatrixUtils - MeAlam1/BlueLib GitHub Wiki
MatrixUtils
Overview
The MatrixUtils
class provides various utility methods for matrix operations, including matrix multiplication, transposition, determinant calculation, and inversion.
Key Methods
-
multiplyMatrices(double[][], double[][])
Multiplies two matrices and returns the result as a new matrix.double[][] matrixA = {{1, 2}, {3, 4}}; double[][] matrixB = {{2, 0}, {1, 2}}; double[][] product = MatrixUtils.multiplyMatrices(matrixA, matrixB);
-
transposeMatrix(double[][])
Computes the transpose of a matrix.double[][] matrix = {{1, 2, 3}, {4, 5, 6}}; double[][] transposed = MatrixUtils.transposeMatrix(matrix);
-
calculate2x2MatrixDeterminant(double[][])
Calculates the determinant of a 2x2 matrix.double[][] matrix = {{1, 2}, {3, 4}}; double determinant = MatrixUtils.calculate2x2MatrixDeterminant(matrix);
-
invert2x2Matrix(double[][])
Calculates the inverse of a 2x2 matrix.double[][] matrix = {{4, 7}, {2, 6}}; double[][] inverse = MatrixUtils.invert2x2Matrix(matrix);
Usage Notes
- Error Handling: If the matrix dimensions are incompatible with the operation (e.g., not 2x2 for determinant calculation or inversion), the method throws an appropriate exception and logs an error message.
- Utility Design: This class cannot be instantiated, as it contains a private constructor and only static methods.