org.encog.mathutil.matrices
Class MatrixMath
- java.lang.Object
-
- org.encog.mathutil.matrices.MatrixMath
-
public final class MatrixMath extends java.lang.ObjectThis class can perform many different mathematical operations on matrixes. The matrixes passed in will not be modified, rather a new matrix, with the operation performed, will be returned.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static Matrixadd(Matrix a, Matrix b)Add two matrixes.static voidcopy(Matrix source, Matrix target)Copy from one matrix to another.static MatrixdeleteCol(Matrix matrix, int deleted)Delete one column from the matrix.static MatrixdeleteRow(Matrix matrix, int deleted)Delete a row from the matrix.static doubledeterminant(Matrix m)static Matrixdivide(Matrix a, double b)Return a matrix with each cell divided by the specified value.static doubledotProduct(Matrix a, Matrix b)Compute the dot product for the two matrixes.static Matrixidentity(int size)Return an identity matrix of the specified size.static Matrixmultiply(Matrix a, double b)Return the result of multiplying every cell in the matrix by the specified value.static double[]multiply(Matrix a, double[] d)static Matrixmultiply(Matrix a, Matrix b)Return the product of the first and second matrix.static Matrixsubtract(Matrix a, Matrix b)Return the results of subtracting one matrix from another.static Matrixtranspose(Matrix input)Return the transposition of a matrix.static doublevectorLength(Matrix input)Calculate the length of a vector.
-
-
-
Method Detail
-
add
public static Matrix add(Matrix a, Matrix b)
Add two matrixes.- Parameters:
a- The first matrix to add.b- The second matrix to add.- Returns:
- A new matrix of the two added.
-
copy
public static void copy(Matrix source, Matrix target)
Copy from one matrix to another.- Parameters:
source- The source matrix for the copy.target- The target matrix for the copy.
-
deleteCol
public static Matrix deleteCol(Matrix matrix, int deleted)
Delete one column from the matrix. Does not actually touch the source matrix, rather a new matrix with the column deleted is returned.- Parameters:
matrix- The matrix.deleted- The column to delete.- Returns:
- A matrix with the column deleted.
-
deleteRow
public static Matrix deleteRow(Matrix matrix, int deleted)
Delete a row from the matrix. Does not actually touch the matrix, rather returns a new matrix.- Parameters:
matrix- The matrix.deleted- Which row to delete.- Returns:
- A new matrix with the specified row deleted.
-
divide
public static Matrix divide(Matrix a, double b)
Return a matrix with each cell divided by the specified value.- Parameters:
a- The matrix to divide.b- The value to divide by.- Returns:
- A new matrix with the division performed.
-
dotProduct
public static double dotProduct(Matrix a, Matrix b)
Compute the dot product for the two matrixes. To compute the dot product, both- Parameters:
a- The first matrix.b- The second matrix.- Returns:
- The dot product.
-
identity
public static Matrix identity(int size)
Return an identity matrix of the specified size.- Parameters:
size- The number of rows and columns to create. An identity matrix is always square.- Returns:
- An identity matrix.
-
multiply
public static Matrix multiply(Matrix a, double b)
Return the result of multiplying every cell in the matrix by the specified value.- Parameters:
a- The first matrix.b- The second matrix.- Returns:
- The result of the multiplication.
-
multiply
public static Matrix multiply(Matrix a, Matrix b)
Return the product of the first and second matrix.- Parameters:
a- The first matrix.b- The second matrix.- Returns:
- The result of the multiplication.
-
subtract
public static Matrix subtract(Matrix a, Matrix b)
Return the results of subtracting one matrix from another.- Parameters:
a- The first matrix.b- The second matrix.- Returns:
- The results of the subtraction.
-
transpose
public static Matrix transpose(Matrix input)
Return the transposition of a matrix.- Parameters:
input- The matrix to transpose.- Returns:
- The matrix transposed.
-
vectorLength
public static double vectorLength(Matrix input)
Calculate the length of a vector.- Parameters:
input- The matrix to calculate the length of.- Returns:
- Vector length.
-
determinant
public static double determinant(Matrix m)
-
multiply
public static double[] multiply(Matrix a, double[] d)
-
-
DMelt 3.0 © DataMelt by jWork.ORG