Package org.deepjava.runtime.util
Class Matrix
- java.lang.Object
-
- org.deepjava.runtime.util.Matrix
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Matrix left, Matrix right)Adds two matrices and stores the result in this instance.Matrixclone()Creates and returns a copy of this object.booleancopy(Matrix M)Copies the content of matrixMinto this matrix.doubleget(int i, int j)Read an entry in a matrix.intgetColumnCount()Reads number of columns in a matrix.intgetRowCount()Reads number of rows in a matrix.booleanisEqual(Matrix M)Compares this object against the specified object.booleanmultiply(Matrix left, Matrix right)Multiplies two matrices and stores the result in this instance.voidprint(PrintStream out)Prints a matrix onto a print stream.static Matrixrot3x(double angle)static booleanrot3x(Matrix A, double angle)booleanset(int i, int j, double value)Writes an entry in a matrix.voidtranspose()booleantranspose(Matrix original)
-
-
-
Constructor Detail
-
Matrix
public Matrix(double[][] data)
Creates a newMatrixfrom array ofdouble. This does not copy the array but simply references the same memory range.- Parameters:
data- Array ofdouble. Rows of the matrix will be set to the first dimension ofdata.
-
Matrix
public Matrix(Matrix M)
Creates a new copy of aMatrixfrom a given matrixM.- Parameters:
M- Matrix to be copied from.
-
Matrix
public Matrix(int n, int m)Creates a newMatrixwithnrows andmcolumns.- Parameters:
n- Number of rows.m- Number of columns.
-
-
Method Detail
-
get
public double get(int i, int j)Read an entry in a matrix. ReturnsDouble.NaNif specified position is not within the matrix.- Parameters:
i- Row (1..n)j- Column (1..m)- Returns:
- Entry at
i,jorDouble.NaNif specified position is not within the matrix
-
set
public boolean set(int i, int j, double value)Writes an entry in a matrix. Returnsfalseif specified position is not within the matrix.- Parameters:
i- Row (1..n)j- Column (1..m)value- Value to write.- Returns:
falseif specified position is not within the matrix.
-
getRowCount
public int getRowCount()
Reads number of rows in a matrix.- Returns:
- Number of rows.
-
getColumnCount
public int getColumnCount()
Reads number of columns in a matrix.- Returns:
- Number of columns.
-
add
public boolean add(Matrix left, Matrix right)
Adds two matrices and stores the result in this instance. Returnsfalseif the dimensions of the involved matrices do not fit.- Parameters:
left- First input matrixright- Second input matrix- Returns:
falseif dimensions of the involved matrices do not fit.
-
multiply
public boolean multiply(Matrix left, Matrix right)
Multiplies two matrices and stores the result in this instance. Returnsfalsedimensions of the involved matrices do not fit.- Parameters:
left- First input matrixright- Second input matrix- Returns:
falseif the number of columns ofleft!= number of rows ofrightor if the number of columns ofright!= number of columns ofthisor if the number of rows ofleft!= number of rows ofthisor.
-
transpose
public boolean transpose(Matrix original)
-
transpose
public void transpose()
-
clone
public Matrix clone()
Creates and returns a copy of this object.- Returns:
- A clone of this instance.
-
copy
public boolean copy(Matrix M)
Copies the content of matrixMinto this matrix.- Parameters:
M- The matrix to be copied from.- Returns:
trueif successful,falseif the two matrices have different dimensions.
-
isEqual
public boolean isEqual(Matrix M)
Compares this object against the specified object.- Parameters:
M- The matrix to compare with.- Returns:
trueif every value of this matrix is the same as the value of the compared matrix.
-
rot3x
public static boolean rot3x(Matrix A, double angle)
-
rot3x
public static Matrix rot3x(double angle)
-
print
public void print(PrintStream out)
Prints a matrix onto a print stream.- Parameters:
out- Print stream
-
-