Package com.actelion.research.calc
Class Matrix
- java.lang.Object
-
- com.actelion.research.calc.Matrix
-
public class Matrix extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringOUT_SEPARATOR_COLstatic java.lang.StringOUT_SEPARATOR_ROWstatic doubleTINYstatic doubleTINY04static doubleTINY08static doubleTINY16
-
Constructor Summary
Constructors Constructor Description Matrix()Matrix(boolean row, double[] arr)Matrix(boolean row, int[] dArray)Matrix(boolean bRow, java.util.List<java.lang.Double> liDoubles)Matrix(byte[][] arrArr)Matrix(double[][] arrArr)Deep copyMatrix(double[][] arrArr, boolean flat)Matrix(float[][] arrArr)Matrix(int[][] arrArr)Matrix(int rows, int cols)Matrix(Matrix ma)Matrix(java.util.List<DoubleVec> vecDoubleVec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Matrixadd(double v)Matrixadd2CompleteCol(Matrix maRow)The value in the col from the input matrix is added to all values in the corresponding col in the matrix.voidadd2Row(int row, Matrix ma2, int row2)voidaddRow(double[] arr)voidaddRow(int[] arr)voidaddToElement(int i, int j, double value)booleanareRowsEqual(int row1, int row2)voidassignCol(int iCol, Matrix ma)voidassignCol(int iCol, Matrix ma, int iColMa)voidassignRow(int iRow, double[] arr)voidassignRow(int iRow, int[] arr)voidassignRow(int iRow, DoubleVec dv)voidassignRow(int iRow, java.util.Vector<java.lang.Double> vecRow)intcols()booleancontainsRow(DoubleVec dv)voidcopy(Matrix maSource)Copies a matrix ma into this, the pointer to ma1 is not changed.voidcopyColumn(Matrix maSource, int colSource, int colDestination)Matrixcorrelation()Generate a correlation matrix, each column contains values of a pulling.Matrixcovariance()Generate a covariance matrix, each column contains values of a pulling.doubledet()Matrix determinantMatrixdevide(double dDivisor)Matrixdevide(Matrix maDivisor)MatrixdevideCols(Matrix maDivisor)MatrixdevideDivisorBigger(Matrix maDivisor)voiddevideRow(int row, double denominator)Matrixdiagonalize()booleanequal(Matrix ma)booleanequal(Matrix ma, double dLimit)booleanequalDimension(Matrix ma)Checks two matrices for equal dimensions.static java.lang.Stringformat(double val, java.text.DecimalFormat nf, int totalWidth)static java.text.DecimalFormatformat(int digits)doubleget(int row, int col)MatrixgetAbs()double[][]getArray()int[][]getArrayAsInt()double[][]getArrayCopy()MatrixgetCenteredMatrix()MatrixgetCenteredMatrix(Matrix maMean)doublegetCoefficientVariation()Coefficient of variation (CV) is a normalized measure of dispersion of a probability distribution.MatrixgetCol(int col)double[]getColAsDouble(int col)float[]getColAsFloat(int iCol)int[]getColAsInt(int iCol)java.util.List<java.lang.Double>getColAsList(int col)intgetColDim()intgetColIndexContainingMaxVal(int row)ScorePointgetColIndexContainingMaxVal(int rowEnd, int colEnd)MatrixgetColumns(java.util.List<java.lang.Integer> liIndex)MatrixgetColumns(java.util.Vector<java.lang.Integer> vecIndices)Deprecated.use getColumns(ListvecIndices) instead MatrixgetDeleteColsZeroVar(java.util.List<java.lang.Integer> vecIndices)Deletes columns with zero variance.MatrixgetDiagonal()Matrix diagonal extraction.static voidgetEigenvector(Matrix A, int n, Matrix D, Matrix E)Householder reduction according num rec 11.2.doublegetEuclideanDistanceFastRows(int row1, int row2)Skipping the sqrt.doublegetEuclideanDistanceFastRows(int iRow, Matrix A, int iRowA)Skipping the sqrt.MatrixgetFlipped()Opposite direction to transpose.intgetID()MatrixgetLinedCol()java.util.List<java.lang.Double>getList()MatrixgetMatrix(int[] r, int[] c)Get a submatrix.MatrixgetMatrix(int[] r, int j0, int j1)Get a submatrix.MatrixgetMatrix(int i0, int i1, int[] c)Get a submatrix.MatrixgetMatrix(int i0, int i1, int j0, int j1)doublegetMax()doublegetMax(int col)get max value for that col.doublegetMaximumValue()java.awt.PointgetMaxIndex()MatrixgetMaxMin()max and min vals for all colsdoublegetMaxRow(int row)intgetMaxRowIndex(int col)intgetMaxRowIndexRND(int row)Shuffles the indices before searching the minimum.doublegetMean()doublegetMeanCol(int col)doublegetMeanCol(int iColIndex, int[] rowIndex)MatrixgetMeanCols()MatrixgetMeanCols(int[] rowIndex)doublegetMeanRow(int row)MatrixgetMeanRows()doublegetMedian()doublegetMedian(int row)MatrixgetMedianCols()MatrixgetMergeRows(Matrix ma)doublegetMin()doublegetMin(int col)intgetMinColIndex(int row)ScorePointgetMinPos()doublegetMinRow(int row)intgetMinRowIndex(int row)intgetMinRowIndexRND(int row)03.10.04 MvK Shuffles the indices before searching the minimum.MatrixgetMinRows()MatrixgetMinRowsPosCol()double[]getNext4NeighboursTorus(int row, int col)double[]getNext8NeighboursTorus(int row, int col)MatrixgetNormalizedMatrix()MatrixgetNormalizedMatrix(Matrix maStandardDeviation)intgetNumElements()intgetNumElementsEqual(double val2Compare)intgetNumElementsLarger(double val2Compare)static MatrixgetParsed(java.util.Vector<java.lang.String> vecStringMatrix)Parses an vector with Strings and converts it to a Matrix.static doublegetPythag(double a, double b)pythag computes sqrt(a^2 + b^2) without destructive underflow or overflow.static doublegetPythag2(double a, double b)static MatrixgetRND(int rows, int cols)double[]getRow(int row)Flat copy.float[]getRowAsFloat(int row)java.util.List<java.lang.Double>getRowAsList(int row)double[]getRowCopy(int row)intgetRowDim()MatrixgetSorted()Sorts the row of the matrix according the compareTo(...) function in DoubleVecMatrixgetSQRT()doublegetStandardDeviation()MatrixgetStandardDeviationCols()MatrixgetStandardized()Get the standard scores, also known as z-scores.MatrixgetSubMatrix(int indexRowStart, int indexRowEnd, int indexColStart, int indexColEnd)MatrixgetSubMatrix(java.util.List<java.lang.Integer> liIndexRow)doublegetSum()doublegetSumCol(int col)MatrixgetSumCols()doublegetSumRow(int row)MatrixgetSumRows()doublegetSumSquared()doublegetSumUpperTriangle()Matrix has to be quadratic.doublegetTorus(int row, int col)doublegetTrace()Matrix trace.MatrixgetTranspose()double[]getUpperTriangle()For a quadratic matrix only.doublegetVariance()doublegetVarianceCentered()doublegetVarianceCol(int col)MatrixgetVarianceCols()booleanhasOnlyFinite()voidincrease(int row, int col, double v)Matrixlog()Log function from the class Math .MatrixmultCols(Matrix maMuiltiplicant)Matrixmultiply(boolean transA, boolean transB, Matrix ma)Multiplication of two matrices.Matrixmultiply(double dScalar)doublemultiply(int row1, Matrix ma2, int row2)Matrixmultiply(Matrix ma)MatrixmultiplyValByVal(Matrix ma)Value by value multiplication Matrices must have the same dimensions.Matrixplus(Matrix ma)Matrixpow(double exp)static MatrixreadSerialized(java.io.File fiIn)MatrixremoveCol(int col2Remove)voidresize(int rowsNew, int colsNew)Resizes the matrix, the old data are written to the new matrix, if possible.Matrixrow2Matrix(int row, int len)introws()voidset(double v)voidset(double[][] arr)voidset(int row, int col, double v)voidset(Matrix ma)voidsetCol(int col, double v)voidsetCol(int col, double[] arr)voidsetFlat(double[][] arr)voidsetID(int id)voidsetRow(int iRow, double v)voidsetRow(int iRow, double[] arr)Deep copyvoidsetRow(int iRow, int[] arr)static voidsetSeparatorCol(java.lang.String s)static voidsetSeparatorRow(java.lang.String s)voidshuffleRows()static doubleSign(double a, double b)voidsortRows(int col)Matrixsubtract(double val)Matrixsubtract(Matrix ma)MatrixsubtractFromCols(Matrix maDivisor)voidswapRows(int a, int b)double[]toArray()MatrixtoRow()java.lang.StringtoString()java.lang.StringtoString(int digits)java.lang.StringtoString(int rowEnd, int colEnd, int digits)java.lang.StringtoStringBinary()java.lang.StringtoStringRow(int row, int iDigits)java.lang.StringtoStringRowNumber(int iDigits, java.lang.String sSeparatorCol)java.lang.StringtoStringWithColTags(java.util.List<java.lang.String> liColTags, java.text.DecimalFormat nf, java.lang.String separator)java.lang.StringtoStringWithRowTags(java.util.List<java.lang.String> liRowTags, java.text.DecimalFormat nf, java.lang.String separator)voidwrite(java.io.File fiMa)voidwrite(java.io.File fiMa, boolean apppend, int digits)voidwrite(java.io.File fiMa, java.text.DecimalFormat nf, boolean apppend)voidwrite(java.io.OutputStream os)voidwrite(java.io.OutputStream os, java.text.NumberFormat nf)voidwrite(java.lang.String sFile)voidwrite(java.lang.String sFile, boolean apppend)voidwrite(java.lang.String sFiMa, boolean apppend, int digits)voidwrite(java.lang.String sFile, boolean bApppend, int digits, int totalWidth)java.lang.StringwriteAsLineBase64Encoded()voidwriteSerialized(java.io.File fiOut)
-
-
-
Field Detail
-
TINY04
public static final double TINY04
- See Also:
- Constant Field Values
-
TINY08
public static final double TINY08
- See Also:
- Constant Field Values
-
TINY16
public static final double TINY16
-
OUT_SEPARATOR_COL
public static java.lang.String OUT_SEPARATOR_COL
-
OUT_SEPARATOR_ROW
public static java.lang.String OUT_SEPARATOR_ROW
-
TINY
public static final double TINY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Matrix
public Matrix()
-
Matrix
public Matrix(int rows, int cols)
-
Matrix
public Matrix(Matrix ma)
-
Matrix
public Matrix(boolean row, double[] arr)- Parameters:
row- if true the matrix has one row. If false the matrix has one column.arr-
-
Matrix
public Matrix(boolean row, int[] dArray)
-
Matrix
public Matrix(double[][] arrArr)
Deep copy- Parameters:
arrArr-
-
Matrix
public Matrix(double[][] arrArr, boolean flat)
-
Matrix
public Matrix(float[][] arrArr)
-
Matrix
public Matrix(int[][] arrArr)
-
Matrix
public Matrix(byte[][] arrArr)
-
Matrix
public Matrix(java.util.List<DoubleVec> vecDoubleVec)
- Parameters:
vecDoubleVec- Vector with DoubleVec
-
Matrix
public Matrix(boolean bRow, java.util.List<java.lang.Double> liDoubles)
-
-
Method Detail
-
add
public Matrix add(double v)
-
addRow
public void addRow(double[] arr)
- Parameters:
arr- adds a row at the end of the matrix.
-
addRow
public void addRow(int[] arr)
-
add2Row
public void add2Row(int row, Matrix ma2, int row2)- Parameters:
row- where the data are added onma2- matrix from where the data are takenrow2- data row
-
addToElement
public void addToElement(int i, int j, double value)
-
add2CompleteCol
public Matrix add2CompleteCol(Matrix maRow)
The value in the col from the input matrix is added to all values in the corresponding col in the matrix.- Parameters:
maRow- matrix with one row.
-
assignCol
public void assignCol(int iCol, Matrix ma)
-
assignCol
public void assignCol(int iCol, Matrix ma, int iColMa)
-
assignRow
public void assignRow(int iRow, java.util.Vector<java.lang.Double> vecRow)
-
assignRow
public void assignRow(int iRow, double[] arr)
-
assignRow
public void assignRow(int iRow, int[] arr)
-
assignRow
public void assignRow(int iRow, DoubleVec dv)
-
containsRow
public boolean containsRow(DoubleVec dv)
-
copy
public void copy(Matrix maSource)
Copies a matrix ma into this, the pointer to ma1 is not changed.- Parameters:
maSource-
-
copyColumn
public void copyColumn(Matrix maSource, int colSource, int colDestination)
-
get
public final double get(int row, int col)
-
getAbs
public Matrix getAbs()
-
getArray
public final double[][] getArray()
-
getArrayAsInt
public int[][] getArrayAsInt() throws java.lang.NumberFormatException- Throws:
java.lang.NumberFormatException
-
getArrayCopy
public double[][] getArrayCopy()
-
getCenteredMatrix
public Matrix getCenteredMatrix()
- Returns:
- column wise centered matrix.
-
getCol
public Matrix getCol(int col)
-
removeCol
public Matrix removeCol(int col2Remove)
-
getColAsDouble
public double[] getColAsDouble(int col)
-
getColAsList
public java.util.List<java.lang.Double> getColAsList(int col)
-
getColAsFloat
public float[] getColAsFloat(int iCol)
-
getColAsInt
public int[] getColAsInt(int iCol)
-
getColumns
public Matrix getColumns(java.util.Vector<java.lang.Integer> vecIndices)
Deprecated.use getColumns(ListvecIndices) instead - Parameters:
vecIndices-- Returns:
-
getColumns
public Matrix getColumns(java.util.List<java.lang.Integer> liIndex)
-
getColDim
public int getColDim()
-
cols
public int cols()
-
getDeleteColsZeroVar
public Matrix getDeleteColsZeroVar(java.util.List<java.lang.Integer> vecIndices)
Deletes columns with zero variance.- Parameters:
vecIndices- the integer vector is filled with the indices from the input matrix which are taken for the new matrix.- Returns:
- input matrix reduced by all cols with zero variance.
-
covariance
public Matrix covariance()
Generate a covariance matrix, each column contains values of a pulling.- Returns:
- An n-by-n matrix.
-
correlation
public Matrix correlation()
Generate a correlation matrix, each column contains values of a pulling.- Returns:
- An n-by-n matrix.
-
getDiagonal
public Matrix getDiagonal()
Matrix diagonal extraction.- Returns:
- An d*1 Matrix of diagonal elements, d = min(m,n).
-
getLinedCol
public Matrix getLinedCol()
-
getList
public java.util.List<java.lang.Double> getList()
-
getMatrix
public Matrix getMatrix(int i0, int i1, int j0, int j1)
-
getMatrix
public Matrix getMatrix(int[] r, int[] c)
Get a submatrix.- Parameters:
r- Array of row indices.c- Array of column indices.- Returns:
- A(r(:),c(:))
- Throws:
java.lang.ArrayIndexOutOfBoundsException- Submatrix indices
-
getMatrix
public Matrix getMatrix(int i0, int i1, int[] c)
Get a submatrix.- Parameters:
i0- Initial row indexi1- Final row indexc- Array of column indices.- Returns:
- A(i0:i1,c(:))
- Throws:
java.lang.ArrayIndexOutOfBoundsException- Submatrix indices
-
getMatrix
public Matrix getMatrix(int[] r, int j0, int j1)
Get a submatrix.- Parameters:
r- Array of row indices.j0- Initial column indexj1- Final column index- Returns:
- A(r(:),j0:j1)
- Throws:
java.lang.ArrayIndexOutOfBoundsException- Submatrix indices
-
getNumElements
public int getNumElements()
-
getNumElementsLarger
public int getNumElementsLarger(double val2Compare)
-
getNumElementsEqual
public int getNumElementsEqual(double val2Compare)
-
log
public Matrix log()
Log function from the class Math .- Returns:
- matrix with the natural logarithm (base e) of a double value.
-
diagonalize
public Matrix diagonalize()
-
devide
public Matrix devide(double dDivisor)
-
devideRow
public void devideRow(int row, double denominator)
-
getEigenvector
public static final void getEigenvector(Matrix A, int n, Matrix D, Matrix E)
Householder reduction according num rec 11.2. Followed from an Eigen value decomposition with the calculation of the Eigen vectors according num rec 11.3.- Parameters:
A- intercept input matrixn- number of considered eigen valuesD-E-
-
getMinRow
public double getMinRow(int row)
- Parameters:
row- row- Returns:
- smallest value in specified row.
-
getMinRowIndex
public int getMinRowIndex(int row)
- Parameters:
row- row- Returns:
- the column index of the smallest value in the row.
-
getMinRowIndexRND
public int getMinRowIndexRND(int row)
03.10.04 MvK Shuffles the indices before searching the minimum. This randomizes the search order.- Parameters:
row- row- Returns:
- the column index of the smallest value in the row.
-
getID
public int getID()
-
getEuclideanDistanceFastRows
public double getEuclideanDistanceFastRows(int iRow, Matrix A, int iRowA)Skipping the sqrt.- Parameters:
iRow-A-iRowA-- Returns:
-
getEuclideanDistanceFastRows
public double getEuclideanDistanceFastRows(int row1, int row2)Skipping the sqrt.- Parameters:
row1-row2-- Returns:
-
getMaximumValue
public double getMaximumValue()
-
getMean
public double getMean()
-
getMeanCols
public Matrix getMeanCols()
-
getMeanCols
public Matrix getMeanCols(int[] rowIndex)
-
getMeanCol
public double getMeanCol(int col)
-
getMeanRow
public double getMeanRow(int row)
-
getMeanRows
public Matrix getMeanRows()
-
getMeanCol
public double getMeanCol(int iColIndex, int[] rowIndex)
-
getMedian
public double getMedian(int row)
-
getMedian
public double getMedian()
-
getMedianCols
public Matrix getMedianCols()
-
getMaxMin
public Matrix getMaxMin()
max and min vals for all cols- Returns:
- matrix with two rows.
-
getMax
public double getMax()
- Returns:
-
getMax
public double getMax(int col)
get max value for that col.- Parameters:
col-- Returns:
-
getMaxIndex
public java.awt.Point getMaxIndex()
- Returns:
- Point(row,col) for the largest value.
-
getMaxRow
public double getMaxRow(int row)
-
getMaxRowIndexRND
public int getMaxRowIndexRND(int row)
Shuffles the indices before searching the minimum.- Parameters:
row- row- Returns:
- the column index of the largest value in the row.
-
getMaxRowIndex
public int getMaxRowIndex(int col)
- Parameters:
col-- Returns:
- the row index of the largest value in the col.
-
getMin
public double getMin()
-
getMinPos
public ScorePoint getMinPos()
- Returns:
- ValPos
-
getMinRows
public Matrix getMinRows()
- Returns:
- matrix with minimum value from each row.
-
getMinRowsPosCol
public Matrix getMinRowsPosCol()
- Returns:
- matrix dimension n,2. First row contains column position of min val, second col the min value.
-
getMin
public double getMin(int col)
-
getMinColIndex
public int getMinColIndex(int row)
- Parameters:
row-- Returns:
- column index for the field with the lowest value for the given row.
-
getColIndexContainingMaxVal
public int getColIndexContainingMaxVal(int row)
- Parameters:
row-- Returns:
- column index for the field with the largest value for the given row.
-
getColIndexContainingMaxVal
public ScorePoint getColIndexContainingMaxVal(int rowEnd, int colEnd)
- Parameters:
rowEnd- the values in the matrix will be considered until this row (exclusively).colEnd- the values in the matrix will be considered until this col (exclusively).- Returns:
-
getNormalizedMatrix
public Matrix getNormalizedMatrix()
-
getUpperTriangle
public double[] getUpperTriangle()
For a quadratic matrix only.- Returns:
-
getPythag
public static double getPythag(double a, double b)pythag computes sqrt(a^2 + b^2) without destructive underflow or overflow.- Parameters:
a- length ab- length b- Returns:
- double
-
getPythag2
public static double getPythag2(double a, double b)
-
areRowsEqual
public boolean areRowsEqual(int row1, int row2)
-
equal
public boolean equal(Matrix ma)
-
equal
public boolean equal(Matrix ma, double dLimit)
-
equalDimension
public boolean equalDimension(Matrix ma)
Checks two matrices for equal dimensions.- Parameters:
ma- matrix to compare with.- Returns:
- true if the number of getColDim and the number of getRowDim are corresponding.
-
hasOnlyFinite
public boolean hasOnlyFinite()
-
multiplyValByVal
public Matrix multiplyValByVal(Matrix ma)
Value by value multiplication Matrices must have the same dimensions.- Parameters:
ma-- Returns:
-
multiply
public Matrix multiply(double dScalar)
-
multiply
public double multiply(int row1, Matrix ma2, int row2)
-
multiply
public final Matrix multiply(boolean transA, boolean transB, Matrix ma)
Multiplication of two matrices. The algorithm checks for the correct dimensions of the matrices. If the dimensions are not corresponding a runtime exception is thrown. The left matrix is the instantiated object. Algorithm taken from Sedgewick.- Parameters:
transA- if true the left matrix is transposed before the multiplicationtransB- if true the right matrix is transposed before the multiplicationma- right matrix- Returns:
- matrix with dimension getRowDim(), ma.getColDim().
-
getParsed
public static Matrix getParsed(java.util.Vector<java.lang.String> vecStringMatrix) throws java.lang.Exception
Parses an vector with Strings and converts it to a Matrix.- Parameters:
vecStringMatrix- vector with strings.- Returns:
- Matrix
- Throws:
java.lang.Exception
-
pow
public Matrix pow(double exp)
-
det
public double det()
Matrix determinant- Returns:
- determinant
-
resize
public void resize(int rowsNew, int colsNew)Resizes the matrix, the old data are written to the new matrix, if possible.- Parameters:
rowsNew- new number of getRowDim.colsNew- new number of getColDim.
-
getRow
public double[] getRow(int row)
Flat copy.- Parameters:
row-- Returns:
-
getRowCopy
public double[] getRowCopy(int row)
-
getRowAsList
public java.util.List<java.lang.Double> getRowAsList(int row)
-
getRowAsFloat
public float[] getRowAsFloat(int row)
-
getRowDim
public int getRowDim()
-
rows
public int rows()
-
getSorted
public Matrix getSorted()
Sorts the row of the matrix according the compareTo(...) function in DoubleVec- Returns:
- sorted matrix
-
getSQRT
public Matrix getSQRT()
-
getStandardDeviationCols
public Matrix getStandardDeviationCols()
-
getStandardDeviation
public double getStandardDeviation()
-
getVariance
public double getVariance()
-
getCoefficientVariation
public double getCoefficientVariation()
Coefficient of variation (CV) is a normalized measure of dispersion of a probability distribution. It is defined as the ratio of the standard deviation sigma to the mean mu.- Returns:
-
getVarianceCol
public double getVarianceCol(int col)
-
getVarianceCentered
public double getVarianceCentered()
-
getVarianceCols
public Matrix getVarianceCols()
- Returns:
- row with variance
-
increase
public void increase(int row, int col, double v)
-
set
public final void set(int row, int col, double v)
-
set
public void set(Matrix ma)
-
set
public void set(double[][] arr)
-
setFlat
public void setFlat(double[][] arr)
-
set
public void set(double v)
-
setID
public void setID(int id)
-
setCol
public void setCol(int col, double v)
-
setCol
public void setCol(int col, double[] arr)
-
setRow
public void setRow(int iRow, double v)
-
setRow
public void setRow(int iRow, double[] arr)Deep copy- Parameters:
iRow-arr-
-
setRow
public void setRow(int iRow, int[] arr)
-
setSeparatorCol
public static void setSeparatorCol(java.lang.String s)
-
setSeparatorRow
public static void setSeparatorRow(java.lang.String s)
-
shuffleRows
public void shuffleRows()
-
swapRows
public void swapRows(int a, int b)
-
sortRows
public void sortRows(int col)
-
getStandardized
public Matrix getStandardized()
Get the standard scores, also known as z-scores.- Returns:
- matrux with standardized values.
-
getSubMatrix
public Matrix getSubMatrix(int indexRowStart, int indexRowEnd, int indexColStart, int indexColEnd)
- Parameters:
indexRowStart- start row includedindexRowEnd- end row includedindexColStart- start col includedindexColEnd- end col included- Returns:
- matrix
-
getSubMatrix
public Matrix getSubMatrix(java.util.List<java.lang.Integer> liIndexRow)
-
getSum
public double getSum()
-
getSumUpperTriangle
public double getSumUpperTriangle()
Matrix has to be quadratic.- Returns:
-
getSumCols
public Matrix getSumCols()
-
getSumRows
public Matrix getSumRows()
-
getSumCol
public double getSumCol(int col)
-
getSumRow
public double getSumRow(int row)
-
getSumSquared
public double getSumSquared()
-
getNext4NeighboursTorus
public double[] getNext4NeighboursTorus(int row, int col)
-
getNext8NeighboursTorus
public double[] getNext8NeighboursTorus(int row, int col)
-
row2Matrix
public Matrix row2Matrix(int row, int len)
-
getTorus
public double getTorus(int row, int col)
-
getTrace
public double getTrace()
Matrix trace.- Returns:
- sum of the diagonal elements.
-
getTranspose
public Matrix getTranspose()
-
getFlipped
public Matrix getFlipped()
Opposite direction to transpose.
-
toRow
public Matrix toRow()
-
toArray
public double[] toArray()
- Returns:
- deep copy.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringBinary
public java.lang.String toStringBinary()
-
toString
public java.lang.String toString(int digits)
-
toString
public java.lang.String toString(int rowEnd, int colEnd, int digits)- Parameters:
rowEnd- exclusivecolEnd- exclusivedigits-- Returns:
-
toStringRow
public java.lang.String toStringRow(int row, int iDigits)
-
toStringRowNumber
public java.lang.String toStringRowNumber(int iDigits, java.lang.String sSeparatorCol)
-
subtract
public Matrix subtract(double val)
-
Sign
public static double Sign(double a, double b)
-
getRND
public static Matrix getRND(int rows, int cols)
-
write
public void write(java.lang.String sFile, boolean apppend)
-
write
public void write(java.lang.String sFile)
-
write
public void write(java.io.File fiMa)
-
write
public void write(java.io.File fiMa, boolean apppend, int digits) throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(java.lang.String sFiMa, boolean apppend, int digits) throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(java.io.File fiMa, java.text.DecimalFormat nf, boolean apppend)
-
write
public void write(java.io.OutputStream os)
-
writeAsLineBase64Encoded
public java.lang.String writeAsLineBase64Encoded()
-
write
public void write(java.io.OutputStream os, java.text.NumberFormat nf)
-
toStringWithColTags
public java.lang.String toStringWithColTags(java.util.List<java.lang.String> liColTags, java.text.DecimalFormat nf, java.lang.String separator)
-
toStringWithRowTags
public java.lang.String toStringWithRowTags(java.util.List<java.lang.String> liRowTags, java.text.DecimalFormat nf, java.lang.String separator)
-
writeSerialized
public void writeSerialized(java.io.File fiOut) throws java.io.IOException- Throws:
java.io.IOException
-
readSerialized
public static Matrix readSerialized(java.io.File fiIn) throws java.io.FileNotFoundException, java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.FileNotFoundExceptionjava.io.IOExceptionjava.lang.ClassNotFoundException
-
format
public static java.text.DecimalFormat format(int digits)
-
write
public void write(java.lang.String sFile, boolean bApppend, int digits, int totalWidth)
-
format
public static java.lang.String format(double val, java.text.DecimalFormat nf, int totalWidth)
-
-