public class IntMatrix extends Object implements EuclidConstants
Read the signature of each member function carefully as some MODIFY the object and some CREATE A NEW ONE. Among the reasons for this is that subclassing (e.g to IntSquareMatrix) is easier with one of these forms in certain cases. Note that if you modify an object, then all references to it will refer to the changed object
| Modifier and Type | Field and Description |
|---|---|
protected int |
cols
number of columns
|
protected int[][] |
flmat
the matrix
|
protected int |
rows
number of rows
|
C_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
IntMatrix()
construct default matrix.
|
IntMatrix(int[][] m)
create from a java matrix.
|
IntMatrix(int r,
int c)
Create matrix with given rows and columns.
|
IntMatrix(int r,
int c,
int f)
creates matrix with initialised values.
|
IntMatrix(int rows,
int cols,
int[] array)
Create from 1-D array.
|
IntMatrix(IntMatrix m)
copy constructor.
|
IntMatrix(IntMatrix m,
int lowrow,
int hirow,
int lowcol,
int hicol)
create from submatrix of another matrix.
|
IntMatrix(RealMatrix realMatrix)
casts doubles to int.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendColumnData(IntArray f)
append data to matrix columnwise.
|
void |
appendColumnData(IntMatrix m)
append data to matrix columnwise.
|
void |
appendRowData(IntArray f)
append data to matrix rowwise.
|
void |
appendRowData(IntMatrix m)
append data to matrix rowwise.
|
protected boolean |
checkNonEmptyMatrix() |
void |
clearMatrix()
clear matrix.
|
void |
columnwiseDivide(IntArray f)
divide each column of a matrix by a vector of scalars (that is mat[i][j] =
mat[i][j] / vect[i] - MODIFIES matrix
|
static IntMatrix |
createByRows(List<List<Integer>> intListList)
create from list of rowvalues
|
void |
deleteColumn(int col)
delete column from matrix and close up.
|
void |
deleteColumns(int low,
int high)
delete 2 or more adjacent columns (inclusive) from matrix and close up.
|
void |
deleteRow(int row)
delete row from matrix and close up.
|
void |
deleteRows(int low,
int high)
delete 2 or more adjacent rows (inclusive) from matrix and close up.
|
int |
elementAt(Int2 rowcol)
extracts a given element.
|
int |
elementAt(int row,
int col)
extracts a given element.
|
IntMatrix |
elementsInRange(IntRange r)
produce a mask of those elements which fall in a range.
|
IntArray |
extractColumnData(int col)
get column data from matrix.
|
org.xmlcml.euclid.Int2Array |
extractColumns(int col1,
int col2)
make an Int2_Array from columns.
|
IntArray |
extractRowData(int row)
get row data from matrix.
|
org.xmlcml.euclid.Int2Array |
extractRows(int row1,
int row2)
make an Int2_Array from rows.
|
IntMatrix |
extractSubMatrixData(int low_row,
int high_row,
int low_col,
int high_col)
extract a IntMatrix submatrix from a IntMatrix
|
static List<Integer> |
findLargestUniqueElementsInRowColumn(IntMatrix intMatrix)
should really be in IntMatrix
|
int |
getCols()
get number of columns.
|
DecimalFormat |
getFormat()
get output format.
|
IntMatrix |
getIntMatrix()
constructs an IntMatrix.
|
int[][] |
getMatrix()
get matrix as java matrix.
|
int[] |
getMatrixAsArray()
get matrix as array.
|
int |
getRows()
get number of rows.
|
IntMatrix |
getTranspose()
transpose matrix - creates new Matrix
|
Int2 |
indexOfLargestElement()
get index of largest element.
|
int |
indexOfLargestElementInColumn(int jcol)
get index of largest element in column.
|
int |
indexOfLargestElementInRow(int irow)
get index of largest element in row.
|
Int2 |
indexOfSmallestElement()
get index of smallest element.
|
int |
indexOfSmallestElementInColumn(int jcol)
get index of smallest element in column.
|
int |
indexOfSmallestElementInRow(int irow)
get index of smallest element in row.
|
void |
insertColumnData(int after_col,
IntArray f)
add data as column or column block into matrix and expand.
|
void |
insertColumnData(int afterCol,
IntMatrix m)
add data as column or column block into matrix and expand.
|
void |
insertRowData(int after_row,
IntArray f)
insert row of data into matrix and expand.
|
void |
insertRowData(int afterRow,
IntMatrix m)
insert 2 or more adjacent rows of data into matrix and expand
|
void |
insertRows(int after_row,
int delta_rows)
make space for new rows in matrix and expand.
|
boolean |
isEqualTo(IntMatrix m)
tests matrices for equality.
|
boolean |
isOrthogonal()
is matrix Orthogonal row-wise.
|
boolean |
isSquare()
is the matrix square
|
int |
largestElement()
get value of largest element.
|
int |
largestElementInColumn(int jcol)
get value of largest element in a column
|
int |
largestElementInRow(int irow)
get value of largest element in a row.
|
void |
makeSpaceForNewColumns(int after_col,
int delta_cols)
insert a hole into the matrix and expand.
|
IntArray |
multiply(IntArray f)
matrix multiplication of a COLUMN vector.
|
IntMatrix |
multiply(IntMatrix m)
matrix multiplication.
|
void |
multiplyBy(int f)
matrix multiplication by a scalar.
|
void |
multiplyEquals(IntMatrix m)
matrix multiplication.
|
void |
negative()
unary minus.
|
IntMatrix |
plus(IntMatrix m2)
matrix addition.
|
IntMatrix |
reorderColumnsBy(IntSet is)
reorder the columns of a matrix.
|
IntMatrix |
reorderRowsBy(IntSet is)
reorder the rows of a matrix Deleting rows is allowed
|
void |
replaceColumnData(int starting_col,
int[] f)
replace data in a single column.
|
void |
replaceColumnData(int column,
IntArray f)
replace data in a single column.
|
void |
replaceColumnData(int start_column,
IntMatrix m)
replace data in a block of columns.
|
void |
replaceRowData(int row,
int[] f)
overwrite existing row of data.
|
void |
replaceRowData(int row,
IntArray f)
overwrite existing row of data.
|
void |
replaceRowData(int afterRow,
IntMatrix m)
overwrite existing block of rows; if too big, copying is truncated
|
void |
replaceSubMatrixData(int low_row,
int low_col,
IntMatrix m)
replaces the data in a submatrix.
|
void |
setAllElements(int f)
initialise matrix to given int.
|
void |
setElementAt(int row,
int col,
int f)
sets a given element MODIFIES matrix
|
void |
setFormat(DecimalFormat f)
set output format.
|
void |
shallowCopy(IntMatrix m)
shallow copy constructor.
|
int |
smallestElement()
get value of smallest element.
|
int |
smallestElementInColumn(int jcol)
get smallest element in a column.
|
int |
smallestElementInRow(int irow)
get smallest element in a row.
|
IntMatrix |
subtract(IntMatrix m2)
matrix subtraction.
|
String |
toString()
output matrix - very crude
|
void |
translateByColumn(int[] d)
subtract value from each colum.
|
void |
writeXML(Writer w)
output xml as a CML matrix.
|
protected int rows
protected int cols
protected int[][] flmat
public IntMatrix()
public IntMatrix(int r,
int c)
r - number of rowsc - number of columnspublic IntMatrix(int rows,
int cols,
int[] array)
throws EuclidRuntimeException
rows - cols - array - EuclidRuntimeException - size of array is not rows*colspublic IntMatrix(int r,
int c,
int f)
r - rowsc - columnsf - value to initialize withpublic IntMatrix(IntMatrix m, int lowrow, int hirow, int lowcol, int hicol) throws EuclidRuntimeException
mm - the matrix to slicelowcol - lowest column indexhicol - highest column indexlowrow - lowest row indexhirow - highest row indexEuclidRuntimeException - impossible value of hirow, hicol, lowrow, lowcolpublic IntMatrix(IntMatrix m)
m - matrix to copypublic IntMatrix(int[][] m)
throws EuclidRuntimeException
m - natrix to copy fromEuclidRuntimeException - m has rows of different lengthspublic IntMatrix(RealMatrix realMatrix)
realMatrix - public static IntMatrix createByRows(List<List<Integer>> intListList)
intListList - public void shallowCopy(IntMatrix m)
m - matrix to copypublic IntMatrix getIntMatrix()
public void setFormat(DecimalFormat f)
f - the formatpublic DecimalFormat getFormat()
public int getRows()
public int getCols()
public int[][] getMatrix()
public int[] getMatrixAsArray()
public boolean isEqualTo(IntMatrix m)
m - public IntMatrix plus(IntMatrix m2) throws EuclidRuntimeException
m2 - matrixEuclidRuntimeException - m and this are different sizespublic IntMatrix subtract(IntMatrix m2) throws EuclidRuntimeException
m2 - EuclidRuntimeException - m and this are different sizespublic void negative()
public IntMatrix multiply(IntMatrix m) throws EuclidRuntimeException
m - EuclidRuntimeException - m and this are different sizespublic void multiplyBy(int f)
f - scalarpublic void multiplyEquals(IntMatrix m) throws EuclidRuntimeException
m - matrix to multiply byEuclidRuntimeException - m and this are different sizespublic void translateByColumn(int[] d)
throws EuclidRuntimeException
d - array of ints to subtractEuclidRuntimeExceptionpublic IntArray multiply(IntArray f) throws EuclidRuntimeException
f - vector to multiplyEuclidRuntimeException - f.size() differs from colspublic void columnwiseDivide(IntArray f) throws EuclidRuntimeException
f - array to divide byEuclidRuntimeException - f.size() and rows differpublic int elementAt(int row,
int col)
throws EuclidRuntimeException
row - col - EuclidRuntimeException - bad value of row or columnpublic int elementAt(Int2 rowcol) throws EuclidRuntimeException
rowcol - represents row,colEuclidRuntimeExceptionpublic void setElementAt(int row,
int col,
int f)
throws EuclidRuntimeException
row - col - f - EuclidRuntimeExceptionpublic int largestElement()
public Int2 indexOfLargestElement()
public int largestElementInColumn(int jcol)
throws EuclidRuntimeException
jcol - EuclidRuntimeExceptionpublic int indexOfLargestElementInColumn(int jcol)
throws EuclidRuntimeException
jcol - indexEuclidRuntimeException - bad value of jcolpublic int indexOfLargestElementInRow(int irow)
throws EuclidRuntimeException
irow - indexEuclidRuntimeException - bad value of irowpublic int indexOfSmallestElementInColumn(int jcol)
throws EuclidRuntimeException
jcol - indexEuclidRuntimeException - bad value of jcolprotected boolean checkNonEmptyMatrix()
public int largestElementInRow(int irow)
throws EuclidRuntimeException
irow - EuclidRuntimeExceptionpublic int indexOfSmallestElementInRow(int irow)
throws EuclidRuntimeException
irow - indexEuclidRuntimeException - bad value of irowpublic int smallestElement()
throws EuclidRuntimeException
EuclidRuntimeExceptionpublic Int2 indexOfSmallestElement()
public int smallestElementInColumn(int jcol)
throws EuclidRuntimeException
jcol - EuclidRuntimeException - bad value of jcolpublic int smallestElementInRow(int irow)
throws EuclidRuntimeException
irow - EuclidRuntimeException - bad value of irowpublic boolean isOrthogonal()
public IntArray extractColumnData(int col) throws EuclidRuntimeException
col - the columnEuclidRuntimeExceptionpublic IntArray extractRowData(int row)
row - the columnpublic void clearMatrix()
public void setAllElements(int f)
f - public IntMatrix getTranspose()
public boolean isSquare()
public void deleteColumn(int col)
col - the columnpublic void deleteColumns(int low,
int high)
low - start columnhigh - end columnpublic void deleteRow(int row)
row - public void deleteRows(int low,
int high)
low - start rowhigh - end rowpublic void replaceColumnData(int column,
IntArray f)
throws EuclidRuntimeException
column - f - data must be of length rowsEuclidRuntimeExceptionpublic void replaceColumnData(int starting_col,
int[] f)
throws EuclidRuntimeException
starting_col - f - data must be of length rowsEuclidRuntimeExceptionpublic void replaceColumnData(int start_column,
IntMatrix m)
throws EuclidRuntimeException
start_column - (gets overwritten)m - must have same row count and fit into gapEuclidRuntimeExceptionpublic void makeSpaceForNewColumns(int after_col,
int delta_cols)
after_col - delta_cols - public void insertColumnData(int after_col,
IntArray f)
throws EuclidRuntimeException
after_col - -1 to cols-1f - EuclidRuntimeExceptionpublic void insertColumnData(int afterCol,
IntMatrix m)
throws EuclidRuntimeException
afterCol - -1 to cols-1m - EuclidRuntimeExceptionpublic void insertRows(int after_row,
int delta_rows)
after_row - -1 to rows-1delta_rows - size of spacepublic void replaceRowData(int row,
IntArray f)
throws EuclidRuntimeException
row - to replacef - row to useEuclidRuntimeException - f.size() and cols differpublic void replaceRowData(int row,
int[] f)
throws EuclidRuntimeException
row - to replacef - row to useEuclidRuntimeException - f.length and cols differpublic void replaceRowData(int afterRow,
IntMatrix m)
throws EuclidRuntimeException
afterRow - from -1 to rows-1m - data to replace withEuclidRuntimeException - m.rows and this.rows differpublic void insertRowData(int afterRow,
IntMatrix m)
throws EuclidRuntimeException
afterRow - from -1 to rows-1m - data to insertEuclidRuntimeException - m.cols and this.colsdifferpublic void insertRowData(int after_row,
IntArray f)
throws EuclidRuntimeException
after_row - from -1 to rows-1f - data to insertEuclidRuntimeException - f.size() and this.cols differpublic void appendColumnData(IntArray f) throws EuclidRuntimeException
f - data to appendEuclidRuntimeException - f.size() and this.rows differpublic void appendColumnData(IntMatrix m) throws EuclidRuntimeException
m - data to appendEuclidRuntimeException - m.rows and this.rows differpublic void appendRowData(IntArray f) throws EuclidRuntimeException
f - data to appendEuclidRuntimeException - m.cols and this.cols differpublic void appendRowData(IntMatrix m) throws EuclidRuntimeException
m - data to appendEuclidRuntimeException - m.cols and this.cols differpublic void replaceSubMatrixData(int low_row,
int low_col,
IntMatrix m)
low_row - starting rowlow_col - starting colm - data to appendpublic IntMatrix reorderColumnsBy(IntSet is) throws EuclidRuntimeException
is - indexes to reorder byEuclidRuntimeException - is.size() and this.cols differpublic IntMatrix reorderRowsBy(IntSet is) throws EuclidRuntimeException
is - indexes to reprder byEuclidRuntimeException - is.size() and this.rows differpublic IntMatrix extractSubMatrixData(int low_row, int high_row, int low_col, int high_col) throws EuclidRuntimeException
low_row - starting rowhigh_row - end rowlow_col - starting colhigh_col - end colEuclidRuntimeException - low/high_row/col are outside range of thispublic org.xmlcml.euclid.Int2Array extractColumns(int col1,
int col2)
throws EuclidRuntimeException
col1 - col2 - EuclidRuntimeException - bad values of columnspublic org.xmlcml.euclid.Int2Array extractRows(int row1,
int row2)
throws EuclidRuntimeException
row1 - row2 - EuclidRuntimeException - bad values of rowspublic IntMatrix elementsInRange(IntRange r) throws EuclidRuntimeException
r - the rangeEuclidRuntimeException - bad values of rowspublic String toString()
public void writeXML(Writer w) throws IOException
w - the writerIOExceptionCopyright © 1994–2024 Peter Murray-Rust. All rights reserved.