Class RealMatrix
- java.lang.Object
-
- dev.nm.algebra.linear.matrix.generic.matrixtype.RealMatrix
-
- All Implemented Interfaces:
GenericMatrix<RealMatrix,Real>,GenericMatrixAccess<Real>,AbelianGroup<RealMatrix>,Monoid<RealMatrix>,Ring<RealMatrix>,VectorSpace<RealMatrix,Real>,Table
public class RealMatrix extends Object implements GenericMatrix<RealMatrix,Real>
This is aRealmatrix. Comparing to thedouble-basedDenseMatrix, this class allows arbitrary precision arithmetic at the cost of (much) slower performance.
-
-
Constructor Summary
Constructors Constructor Description RealMatrix(double[][] data)Construct aRealmatrix.RealMatrix(int nRows, int nCols)Construct aRealmatrix.RealMatrix(Real[][] data)Construct aRealmatrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RealMatrixadd(RealMatrix that)+ : G × G → GDenseMatrixdoubleValue()Construct aDenseMatrixequivalent of this Real matrix (rounded if necessary).booleanequals(Object obj)Realget(int row, int col)Get the matrix entry at [i,j].inthashCode()RealMatrixminus(RealMatrix that)- : G × G → GRealMatrixmultiply(RealMatrix that)× : G × G → GintnCols()Gets the number of columns.intnRows()Gets the number of rows.RealMatrixONE()The multiplicative element 1 in the group such that for any elements a in the group, the equation 1 × a = a × 1 = a holds.RealMatrixopposite()For each a in G, there exists an element b in G such that a + b = b + a = 0.RealMatrixscaled(Real scalar)× : F × V → Vvoidset(int row, int col, Real value)Set the matrix entry at [i,j] to a value.StringtoString()RealMatrixZERO()The additive element 0 in the group, such that for all elements a in the group, the equation 0 + a = a + 0 = a holds.
-
-
-
Constructor Detail
-
RealMatrix
public RealMatrix(int nRows, int nCols)Construct aRealmatrix.- Parameters:
nRows- the number of rowsnCols- the number of columns
-
RealMatrix
public RealMatrix(Real[][] data)
Construct aRealmatrix.- Parameters:
data- a matrix data ofRealnumbers in a 2D array
-
RealMatrix
public RealMatrix(double[][] data)
Construct aRealmatrix.- Parameters:
data- a matrix data ofdoubles in a 2D array
-
-
Method Detail
-
nRows
public int nRows()
Description copied from interface:TableGets the number of rows. Rows count from 1.
-
nCols
public int nCols()
Description copied from interface:TableGets the number of columns. Columns count from 1.
-
set
public void set(int row, int col, Real value)Description copied from interface:GenericMatrixAccessSet the matrix entry at [i,j] to a value. This is the only method that may change a matrix.- Specified by:
setin interfaceGenericMatrixAccess<Real>- Parameters:
row- the row indexcol- the column indexvalue- the value to set A[i,j] to
-
get
public Real get(int row, int col)
Description copied from interface:GenericMatrixAccessGet the matrix entry at [i,j].- Specified by:
getin interfaceGenericMatrixAccess<Real>- Parameters:
row- the row indexcol- the column index- Returns:
- A[i,j]
-
add
public RealMatrix add(RealMatrix that)
Description copied from interface:AbelianGroup+ : G × G → G- Specified by:
addin interfaceAbelianGroup<RealMatrix>- Parameters:
that- the object to be added- Returns:
- this + that
-
minus
public RealMatrix minus(RealMatrix that)
Description copied from interface:AbelianGroup- : G × G → G The operation "-" is not in the definition of of an additive group but can be deduced. This function is provided for convenience purpose. It is equivalent to
.this.add(that.opposite())- Specified by:
minusin interfaceAbelianGroup<RealMatrix>- Parameters:
that- the object to be subtracted (subtrahend)- Returns:
- this - that
-
multiply
public RealMatrix multiply(RealMatrix that)
Description copied from interface:Monoid× : G × G → G- Specified by:
multiplyin interfaceMonoid<RealMatrix>- Parameters:
that- the multiplicand- Returns:
- this × that
-
scaled
public RealMatrix scaled(Real scalar)
Description copied from interface:VectorSpace× : F × V → V The result of applying this function to a scalar, c, in F and v in V is denoted cv.- Specified by:
scaledin interfaceVectorSpace<RealMatrix,Real>- Parameters:
scalar- a multiplier- Returns:
- c * this
- See Also:
- Wikipedia: Scalar multiplication
-
opposite
public RealMatrix opposite()
Description copied from interface:AbelianGroupFor each a in G, there exists an element b in G such that a + b = b + a = 0. That is, it is the object such asthis.add(this.opposite()) == this.ZERO- Specified by:
oppositein interfaceAbelianGroup<RealMatrix>- Returns:
- -this, the additive opposite
- See Also:
- Wikipedia: Additive inverse
-
ZERO
public RealMatrix ZERO()
Description copied from interface:AbelianGroupThe additive element 0 in the group, such that for all elements a in the group, the equation 0 + a = a + 0 = a holds.- Specified by:
ZEROin interfaceAbelianGroup<RealMatrix>- Returns:
- 0, the additive identity
-
ONE
public RealMatrix ONE()
Description copied from interface:MonoidThe multiplicative element 1 in the group such that for any elements a in the group, the equation 1 × a = a × 1 = a holds.- Specified by:
ONEin interfaceMonoid<RealMatrix>- Returns:
- 1
-
doubleValue
public DenseMatrix doubleValue()
Construct aDenseMatrixequivalent of this Real matrix (rounded if necessary).- Returns:
- a
DenseMatrixequivalent
-
-