Class Matrix
- Direct Known Subclasses:
VandermondeMatrix
Offers matrixContent calculations in different fields.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a matrixContent (x,y) with the specified MathMode.Creates a two dimensional matrixContent (x,y) with the specified MathMode.Creates a two dimensional matrixContent (x,y) with the specified MathMode.Creates a two dimensional matrixContent (x,y) with the specified MathMode.Creates a copy of the current matrix object. -
Method Summary
Modifier and TypeMethodDescriptionvoiddivRow(int row, int scalar) Divides all values of the specified row in the matrixContent by the scalar specified.static booleanenableMatrixCache(boolean enable) Enables or disables the matrixContent cache.booleanvoidflipRow(int row1, int row2) Flips two rows of the current matrixContent.byte[]Get the content of the matrixContent as byte array.intgetField(int x, int y) Extracts the value of a specified matrixContent field.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.intgetX()Get the number of columns.intgetY()Set the number of rows.inthashCode()Multiplies the current matrixContent with the specified matrixContent.static MatrixrandomMatrix(int x, int y, MathMode mode) Returns a matrixContent with the specified dimension initialised with random values.voidremoveRow(int index) Removes the specified row from the matrixContent.intsetField(int x, int y, int value) Sets the value of a specified matrixContent field.intsetModulo(int i) Sets a modulo value of the matrixContent for all operations.toString()voidtransformColumn(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.voidtransformRow(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 MatrixunitMatrix(int size, MathMode mode) Creates a two dimensional unit matrixContent (size,size) with the specified MathMode.
-
Field Details
-
MAX_CACHE
public static final int MAX_CACHE- See Also:
-
-
Constructor Details
-
Matrix
Creates a copy of the current matrix object.
- Parameters:
originalMatrix- the matrix to be copied
-
Matrix
Creates a matrixContent (x,y) with the specified MathMode.
- Parameters:
x- the number of columns of the matrixContenty- the number of rows of the matrixContentmode- the math mode to be applied
-
Matrix
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
- Parameters:
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)
-
Matrix
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
- Parameters:
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)
-
Matrix
Creates a two dimensional matrixContent (x,y) with the specified MathMode.
- Parameters:
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 fields
-
-
Method Details
-
unitMatrix
Creates a two dimensional unit matrixContent (size,size) with the specified MathMode.
- Parameters:
size- the number of columns of the matrixContentmode- the math mode to be applied- Returns:
- the requested matrix
-
getX
public int getX()Get the number of columns.
- Returns:
- the number of columns as int value
-
getY
public int getY()Set the number of rows.
- Returns:
- the number of rows as int value
-
removeRow
public void removeRow(int index) Removes the specified row from the matrixContent.
- Parameters:
index- the index of the row to be removed (starting with 0)
-
randomMatrix
Returns a matrixContent with the specified dimension initialised with random values.
- Parameters:
x- the number of columns of the matrixContenty- the number of rows of the matrixContentmode- the math mode to be applied- Returns:
- the generated matrixContent
-
mul
Multiplies the current matrixContent with the specified matrixContent.
- Parameters:
m- the matrixContent to multiply with- Returns:
- the resulting matrixContent
- Throws:
ArithmeticException- if multiplication may not be carried out
-
equals
-
hashCode
public int hashCode() -
toString
-
setModulo
public int setModulo(int i) Sets a modulo value of the matrixContent for all operations.
- Parameters:
i- the value to be used as modulo- Returns:
- the previously set modulo
-
getRow
public int[] getRow(int i) Get a row of the matrixContent as array.
- Parameters:
i- the index of the row to be extracted as array- Returns:
- the row representation as array
-
getField
public int getField(int x, int y) Extracts the value of a specified matrixContent field.
- Parameters:
x- the column of the fieldy- the row of the field- Returns:
- the value of the field
-
setField
public int setField(int x, int y, int value) Sets the value of a specified matrixContent field.
- Parameters:
x- the column of the fieldy- the row of the fieldvalue- the value to be set- Returns:
- the previously set value of the field
-
getInverse
Calculates the inverse by applying the Gauss-Jordan-algorithm.
- Returns:
- the inverse of the matrixContent
- Throws:
ArithmeticException- if matrixContent is not square in dimensions or the algorithm was unable to compute an inverse
-
getRowAsByteArray
public byte[] getRowAsByteArray(int row) Get the values of a row as byte arrays.
- Parameters:
row- the index of the row to be used (starting with 0)- Returns:
- the array containing the values of the row
-
getAsByteArray
public byte[] getAsByteArray()Get the content of the matrixContent as byte array.
- Returns:
- the byte array representing the matrixContent values (row by row)
-
transformColumn
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.
- Parameters:
col- the column to be recalculated/alteredcol2- the column to be used for recalculationscalar- the scalar to be used for division/multiplication
-
transformRow
public 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.
- Parameters:
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 used
-
divRow
public void divRow(int row, int scalar) Divides all values of the specified row in the matrixContent by the scalar specified.
- Parameters:
row- the index of the row (starting with 0)scalar- the scalar to be used as divisor
-
flipRow
public void flipRow(int row1, int row2) Flips two rows of the current matrixContent.
- Parameters:
row1- index of the first row (starting with 0)row2- index of the second row (starting with 0)
-
enableMatrixCache
public static boolean enableMatrixCache(boolean enable) Enables or disables the matrixContent cache.
- Parameters:
enable- set to true if matrixContent cache should be enabled- Returns:
- the previously set value
-