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 boolean
add(Matrix left, Matrix right)
Adds two matrices and stores the result in this instance.Matrix
clone()
Creates and returns a copy of this object.boolean
copy(Matrix M)
Copies the content of matrixM
into this matrix.double
get(int i, int j)
Read an entry in a matrix.int
getColumnCount()
Reads number of columns in a matrix.int
getRowCount()
Reads number of rows in a matrix.boolean
isEqual(Matrix M)
Compares this object against the specified object.boolean
multiply(Matrix left, Matrix right)
Multiplies two matrices and stores the result in this instance.void
print(PrintStream out)
Prints a matrix onto a print stream.static Matrix
rot3x(double angle)
static boolean
rot3x(Matrix A, double angle)
boolean
set(int i, int j, double value)
Writes an entry in a matrix.void
transpose()
boolean
transpose(Matrix original)
-
-
-
Constructor Detail
-
Matrix
public Matrix(double[][] data)
Creates a newMatrix
from 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 aMatrix
from a given matrixM
.- Parameters:
M
- Matrix to be copied from.
-
Matrix
public Matrix(int n, int m)
Creates a newMatrix
withn
rows andm
columns.- 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.NaN
if specified position is not within the matrix.- Parameters:
i
- Row (1..n)j
- Column (1..m)- Returns:
- Entry at
i
,j
orDouble.NaN
if specified position is not within the matrix
-
set
public boolean set(int i, int j, double value)
Writes an entry in a matrix. Returnsfalse
if specified position is not within the matrix.- Parameters:
i
- Row (1..n)j
- Column (1..m)value
- Value to write.- Returns:
false
if 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. Returnsfalse
if the dimensions of the involved matrices do not fit.- Parameters:
left
- First input matrixright
- Second input matrix- Returns:
false
if 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. Returnsfalse
dimensions of the involved matrices do not fit.- Parameters:
left
- First input matrixright
- Second input matrix- Returns:
false
if the number of columns ofleft
!= number of rows ofright
or if the number of columns ofright
!= number of columns ofthis
or if the number of rows ofleft
!= number of rows ofthis
or.
-
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 matrixM
into this matrix.- Parameters:
M
- The matrix to be copied from.- Returns:
true
if successful,false
if 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:
true
if 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
-
-