Package org.cicirello.math.la
Class MatrixOps
- java.lang.Object
-
- org.cicirello.math.la.MatrixOps
-
public final class MatrixOps extends Object
Utility class of basic linear algebra matrix operations, where matrices are represented as 2-D Java arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double[][]
difference(double[][] A, double[][] B)
Computes C = A - B.static double[][]
difference(double[][] A, double[][] B, double[][] C)
Computes C = A - B.static int[][]
difference(int[][] A, int[][] B)
Computes C = A - B.static int[][]
difference(int[][] A, int[][] B, int[][] C)
Computes C = A - B.static double[][]
product(double[][] A, double[][] B)
Computes C = A * B.static double[][]
product(double[][] A, double[][] B, double[][] C)
Computes C = A * B.static int[][]
product(int[][] A, int[][] B)
Computes C = A * B.static int[][]
product(int[][] A, int[][] B, int[][] C)
Computes C = A * B.static double[][]
sum(double[][] A, double[][] B)
Computes C = A + B.static double[][]
sum(double[][] A, double[][] B, double[][] C)
Computes C = A + B.static int[][]
sum(int[][] A, int[][] B)
Computes C = A + B.static int[][]
sum(int[][] A, int[][] B, int[][] C)
Computes C = A + B.static double[][]
transposeSquareMatrixInline(double[][] matrix)
Transpose a square matrix inline.static int[][]
transposeSquareMatrixInline(int[][] matrix)
Transpose a square matrix inline.
-
-
-
Method Detail
-
transposeSquareMatrixInline
public static int[][] transposeSquareMatrixInline(int[][] matrix)
Transpose a square matrix inline.- Parameters:
matrix
- the matrix to transpose, with result replacing contents of matrix.- Returns:
- The matrix is returned for convenience for passing to other methods requiring a matrix as parameter. It is the same object reference that was passed as a parameter.
-
transposeSquareMatrixInline
public static double[][] transposeSquareMatrixInline(double[][] matrix)
Transpose a square matrix inline.- Parameters:
matrix
- the matrix to transpose, with result replacing contents of matrix.- Returns:
- The matrix is returned for convenience for passing to other methods requiring a matrix as parameter. It is the same object reference that was passed as a parameter.
-
sum
public static int[][] sum(int[][] A, int[][] B, int[][] C)
Computes C = A + B.- Parameters:
A
- matrixB
- matrixC
- if C is null then a new matrix is constructed for result, otherwise C is used for result.- Returns:
- A reference to the C matrix.
-
sum
public static double[][] sum(double[][] A, double[][] B, double[][] C)
Computes C = A + B.- Parameters:
A
- matrixB
- matrixC
- if C is null then a new matrix is constructed for result, otherwise C is used for result.- Returns:
- A reference to the C matrix.
-
sum
public static int[][] sum(int[][] A, int[][] B)
Computes C = A + B.- Parameters:
A
- matrixB
- matrix- Returns:
- A reference to a new matrix C containing the sum.
-
sum
public static double[][] sum(double[][] A, double[][] B)
Computes C = A + B.- Parameters:
A
- matrixB
- matrix- Returns:
- A reference to a new matrix C containing the sum.
-
difference
public static int[][] difference(int[][] A, int[][] B, int[][] C)
Computes C = A - B.- Parameters:
A
- matrixB
- matrixC
- if C is null then a new matrix is constructed for result, otherwise C is used for result.- Returns:
- A reference to the C matrix.
-
difference
public static double[][] difference(double[][] A, double[][] B, double[][] C)
Computes C = A - B.- Parameters:
A
- matrixB
- matrixC
- if C is null then a new matrix is constructed for result, otherwise C is used for result.- Returns:
- A reference to the C matrix.
-
difference
public static int[][] difference(int[][] A, int[][] B)
Computes C = A - B.- Parameters:
A
- matrixB
- matrix- Returns:
- A reference to a new matrix C containing the difference.
-
difference
public static double[][] difference(double[][] A, double[][] B)
Computes C = A - B.- Parameters:
A
- matrixB
- matrix- Returns:
- A reference to a new matrix C containing the difference.
-
product
public static int[][] product(int[][] A, int[][] B, int[][] C)
Computes C = A * B.- Parameters:
A
- matrixB
- matrixC
- if C is null then a new matrix is constructed for result, otherwise C is used for result.- Returns:
- A reference to the C matrix.
-
product
public static double[][] product(double[][] A, double[][] B, double[][] C)
Computes C = A * B.- Parameters:
A
- matrixB
- matrixC
- if C is null then a new matrix is constructed for result, otherwise C is used for result.- Returns:
- A reference to the C matrix.
-
product
public static int[][] product(int[][] A, int[][] B)
Computes C = A * B.- Parameters:
A
- matrixB
- matrix- Returns:
- A reference to a new matrix C containing the product.
-
product
public static double[][] product(double[][] A, double[][] B)
Computes C = A * B.- Parameters:
A
- matrixB
- matrix- Returns:
- A reference to a new matrix C containing the product.
-
-