public class Matrix extends Object
Offers matrixContent calculations in different fields.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CACHE |
Constructor and Description |
---|
Matrix(int x,
int y,
MathMode mode)
Creates a matrixContent (x,y) with the specified MathMode.
|
Matrix(int x,
int y,
MathMode mode,
byte[] content)
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
|
Matrix(int x,
int y,
MathMode mode,
int content)
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
|
Matrix(int x,
int y,
MathMode mode,
int[] content)
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
|
Matrix(Matrix originalMatrix)
Creates a copy of the current matrix object.
|
Modifier and Type | Method and Description |
---|---|
void |
divRow(int row,
int scalar)
Divides all values of the specified row in the matrixContent by the scalar specified.
|
static boolean |
enableMatrixCache(boolean enable)
Enables or disables the matrixContent cache.
|
boolean |
equals(Object o) |
void |
flipRow(int row1,
int row2)
Flips two rows of the current matrixContent.
|
byte[] |
getAsByteArray()
Get the content of the matrixContent as byte array.
|
int |
getField(int x,
int y)
Extracts the value of a specified matrixContent field.
|
Matrix |
getInverse()
Calculates the inverse by applying the Gauss-Jordan-algorithm.
|
int[] |
getRow(int i)
Get a row of the matrixContent as array.
|
byte[] |
getRowAsByteArray(int row)
Get the values of a row as byte arrays.
|
int |
getX()
Get the number of columns.
|
int |
getY()
Set the number of rows.
|
int |
hashCode() |
Matrix |
mul(Matrix m)
Multiplies the current matrixContent with the specified matrixContent.
|
static Matrix |
randomMatrix(int x,
int y,
MathMode mode)
Returns a matrixContent with the specified dimension initialised with random values.
|
void |
removeRow(int index)
Removes the specified row from the matrixContent.
|
int |
setField(int x,
int y,
int value)
Sets the value of a specified matrixContent field.
|
int |
setModulo(int i)
Sets a modulo value of the matrixContent for all operations.
|
String |
toString() |
void |
transformColumn(int col,
int col2,
int scalar)
Multiplies element by element the values of the second column by the specified scalar
and subtracts the resulting value from the first element.
|
void |
transformRow(int row,
int row2,
int scalar,
boolean doDiv)
Divides or multiplies element by element the values of the second row by the specified
scalar and subtracts the resulting value from the first element.
|
static Matrix |
unitMatrix(int size,
MathMode mode)
Creates a two dimensional unit matrixContent (size,size) with the specified MathMode.
|
public static final int MAX_CACHE
public Matrix(Matrix originalMatrix)
Creates a copy of the current matrix object.
originalMatrix
- the matrix to be copiedpublic Matrix(int x, int y, MathMode mode)
Creates a matrixContent (x,y) with the specified MathMode.
x
- the number of columns of the matrixContenty
- the number of rows of the matrixContentmode
- the math mode to be appliedpublic Matrix(int x, int y, MathMode mode, int[] content)
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
x
- the number of columns of the matrixContenty
- the number of rows of the matrixContentmode
- the math mode to be appliedcontent
- the content as one dimensional array (sequence of rows)public Matrix(int x, int y, MathMode mode, byte[] content)
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
x
- the number of columns of the matrixContenty
- the number of rows of the matrixContentmode
- the math mode to be appliedcontent
- the content as one dimensional array (sequence of rows)public Matrix(int x, int y, MathMode mode, int content)
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
x
- the number of columns of the matrixContenty
- the number of rows of the matrixContentmode
- the math mode to be appliedcontent
- the value to be set in all fieldspublic static Matrix unitMatrix(int size, MathMode mode)
Creates a two dimensional unit matrixContent (size,size) with the specified MathMode.
size
- the number of columns of the matrixContentmode
- the math mode to be appliedpublic int getX()
Get the number of columns.
public int getY()
Set the number of rows.
public void removeRow(int index)
Removes the specified row from the matrixContent.
index
- the index of the row to be removed (starting with 0)public static Matrix randomMatrix(int x, int y, MathMode mode)
Returns a matrixContent with the specified dimension initialised with random values.
x
- the number of columns of the matrixContenty
- the number of rows of the matrixContentmode
- the math mode to be appliedpublic Matrix mul(Matrix m)
Multiplies the current matrixContent with the specified matrixContent.
m
- the matrixContent to multiply withArithmeticException
- if multiplication may not be carried outpublic int setModulo(int i)
Sets a modulo value of the matrixContent for all operations.
i
- the value to be used as modulopublic int[] getRow(int i)
Get a row of the matrixContent as array.
i
- the index of the row to be extracted as arraypublic int getField(int x, int y)
Extracts the value of a specified matrixContent field.
x
- the column of the fieldy
- the row of the fieldpublic int setField(int x, int y, int value)
Sets the value of a specified matrixContent field.
x
- the column of the fieldy
- the row of the fieldvalue
- the value to be setpublic Matrix getInverse()
Calculates the inverse by applying the Gauss-Jordan-algorithm.
ArithmeticException
- if matrixContent is not square in dimensions or the algorithm
was unable to compute an inversepublic byte[] getRowAsByteArray(int row)
Get the values of a row as byte arrays.
row
- the index of the row to be used (starting with 0)public byte[] getAsByteArray()
Get the content of the matrixContent as byte array.
public void transformColumn(int col, int col2, int scalar)
Multiplies element by element the values of the second column by the specified scalar and subtracts the resulting value from the first element.
col
- the column to be recalculated/alteredcol2
- the column to be used for recalculationscalar
- the scalar to be used for division/multiplicationpublic void transformRow(int row, int row2, int scalar, boolean doDiv)
Divides or multiplies element by element the values of the second row by the specified scalar and subtracts the resulting value from the first element.
row
- the row o be recalculated/alteredrow2
- the row to be used for recalculationscalar
- the scalar to be used for division/multiplicationdoDiv
- flag to specify whether division (true) or multiplication (false) should be usedpublic void divRow(int row, int scalar)
Divides all values of the specified row in the matrixContent by the scalar specified.
row
- the index of the row (starting with 0)scalar
- the scalar to be used as divisorpublic void flipRow(int row1, int row2)
Flips two rows of the current matrixContent.
row1
- index of the first row (starting with 0)row2
- index of the second row (starting with 0)public static boolean enableMatrixCache(boolean enable)
Enables or disables the matrixContent cache.
enable
- set to true if matrixContent cache should be enabledCopyright © 2023. All rights reserved.