Module ojalgo
Package org.ojalgo.matrix
Class BasicMatrix<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
- java.lang.Object
-
- org.ojalgo.matrix.BasicMatrix<N,M>
-
- All Implemented Interfaces:
Group,Group.Additive<M>,NormedVectorSpace<M,N>,Operation,Operation.Addition<M>,Operation.Multiplication<M>,Operation.Subtraction<M>,ScalarOperation,ScalarOperation.Addition<M,N>,ScalarOperation.Division<M,N>,ScalarOperation.Multiplication<M,N>,ScalarOperation.Subtraction<M,N>,VectorSpace<M,N>,Matrix2D<N,M>,Provider2D,Provider2D.Condition,Provider2D.Determinant<N>,Provider2D.Eigenpairs,Provider2D.Hermitian,Provider2D.Inverse<M>,Provider2D.Rank,Provider2D.Solution<M>,Provider2D.Symmetric,Provider2D.Trace<N>,Access1D<N>,Access1D.Aggregatable<N>,Access2D<N>,Access2D.Aggregatable<N>,Access2D.Collectable<N,TransformableRegion<N>>,Operate2D<N,M>,Structure1D,Structure2D,Structure2D.Logical<Access2D<N>,M>,Structure2D.ReducibleTo1D<M>,NumberContext.Enforceable<M>
- Direct Known Subclasses:
MatrixC128,MatrixH256,MatrixQ128,MatrixR032,MatrixR064,MatrixR128
public abstract class BasicMatrix<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>> extends java.lang.Object implements Matrix2D<N,M>, Structure2D.ReducibleTo1D<M>, NumberContext.Enforceable<M>, Access2D.Collectable<N,TransformableRegion<N>>, Provider2D.Inverse<M>, Provider2D.Condition, Provider2D.Rank, Provider2D.Symmetric, Provider2D.Hermitian, Provider2D.Trace<N>, Provider2D.Determinant<N>, Provider2D.Solution<M>, Provider2D.Eigenpairs, Structure2D.Logical<Access2D<N>,M>, Operate2D<N,M>
A base class for, easy to use, immutable (thread safe) matrices with a rich feature set. This class handles a lot of complexity, and makes choices, for you. If you want more control, and to be exposed to all the implementation details, then look at the various interfaces/classes in the org.ojalgo.matrix.store and org.ojalgo.matrix.decomposition packages.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Access2D
Access2D.Aggregatable<N extends java.lang.Comparable<N>>, Access2D.Collectable<N extends java.lang.Comparable<N>,R extends Mutate2D>, Access2D.ColumnView<N extends java.lang.Comparable<N>>, Access2D.ElementView<N extends java.lang.Comparable<N>>, Access2D.RowView<N extends java.lang.Comparable<N>>, Access2D.SelectionView<N extends java.lang.Comparable<N>>, Access2D.Sliceable<N extends java.lang.Comparable<N>>, Access2D.Visitable<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.algebra.Group
Group.Additive<T>, Group.Multiplicative<T>
-
Nested classes/interfaces inherited from interface org.ojalgo.algebra.Operation
Operation.Addition<T>, Operation.Division<T>, Operation.Multiplication<T>, Operation.Subtraction<T>
-
Nested classes/interfaces inherited from interface org.ojalgo.matrix.Provider2D
Provider2D.Condition, Provider2D.Determinant<N extends java.lang.Comparable<N>>, Provider2D.Eigenpairs, Provider2D.Hermitian, Provider2D.Inverse<M>, Provider2D.Rank, Provider2D.Solution<M>, Provider2D.Symmetric, Provider2D.Trace<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.algebra.ScalarOperation
ScalarOperation.Addition<T,N extends java.lang.Comparable<N>>, ScalarOperation.Division<T,N extends java.lang.Comparable<N>>, ScalarOperation.Multiplication<T,N extends java.lang.Comparable<N>>, ScalarOperation.Subtraction<T,N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S extends Structure1D,B extends Structure1D.Logical<S,B>>, Structure1D.LongIndex, Structure1D.LoopCallback
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure2D
Structure2D.IntRowColumn, Structure2D.Logical<S extends Structure2D,B extends Structure2D.Logical<S,B>>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R extends Structure1D>, Structure2D.Reshapable, Structure2D.RowColumnKey<R,C>, Structure2D.RowColumnMapper<R,C>
-
-
Field Summary
Fields Modifier and Type Field Description private static NumberContextEQUALSprivate MatrixDecomposition<N>myDecompositionprivate PhysicalStore.Factory<N,?>myFactoryprivate intmyHashCodeprivate java.lang.BooleanmyHermitianprivate java.lang.BooleanmySPDprivate MatrixStore<N>myStoreprivate ElementsSupplier<N>mySupplierprivate java.lang.BooleanmySymmetric
-
Constructor Summary
Constructors Constructor Description BasicMatrix(PhysicalStore.Factory<N,?> factory, ElementsSupplier<N> supplier)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Mabove(long numberOfRows)Mabove(Access2D<N> above)Mabove(Access2D<N>... above)Madd(double scalarAddend)Madd(M addend)Madd(N scalarAddend)NaggregateColumn(long row, long col, Aggregator aggregator)NaggregateDiagonal(long row, long col, Aggregator aggregator)NaggregateRange(long first, long limit, Aggregator aggregator)NaggregateRow(long row, long col, Aggregator aggregator)Mbelow(long numberOfRows)Mbelow(Access2D<N> below)Mbelow(Access2D<N>... below)Mbidiagonal(boolean upper)static <M extends BasicMatrix<?,M>>
doublecalculateFrobeniusNorm(M matrix)The Frobenius norm is the square root of the sum of the squares of each element, or the square root of the sum of the square of the singular values.static <M extends BasicMatrix<?,M>>
doublecalculateInfinityNorm(M matrix)static <M extends BasicMatrix<?,M>>
doublecalculateOneNorm(M matrix)Mcolumn(int column)Mcolumn(long column)Mcolumns(int... columns)A selection (re-ordering) of columns.Mcolumns(long... columns)Mconjugate()This method will (most likely) be moved to some other interface in the future! Just have to figure out where it fits...abstract DenseMutator2D<N,M>copy()The returned instance can have its elements mutated in various ways, while the size/shape is fixed.longcount()count() == countRows() * countColumns()longcountColumns()Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.longcountRows()Only need to implement if the structure may contain more than Integer.MAX_VALUE elements.Mdiagonal()Mdiagonally(Access2D<N>... diagonally)Mdivide(double scalarDivisor)Mdivide(N scalarDivisor)doubledoubleValue(int row, int col)Extracts one element of this matrix as a double.doubledoubleValue(long index)Menforce(NumberContext context)booleanequals(java.lang.Object other)true if "other" is anAccess2Dof the same size/shape and the elements are equal to high precision (12 significant digits).Mget()Deprecated.v50 No need for this!Nget(long index)Nget(long row, long col)intgetColDim()doublegetCondition()Matrix condition (2-norm)private Provider2D.ConditiongetConditionProvider()NgetDeterminant()private Provider2D.Determinant<N>getDeterminantProvider()java.util.List<Eigenvalue.Eigenpair>getEigenpairs()private Provider2D.EigenpairsgetEigenpairsProvider()private Provider2D.Inverse<java.util.Optional<MatrixStore<N>>>getInverseProvider(boolean safe)intgetRank()The rank of a matrix is the (maximum) number of linearly independent rows or columns it contains.private Provider2D.RankgetRankProvider()intgetRowDim()private Provider2D.Solution<java.util.Optional<MatrixStore<N>>>getSolutionProvider(boolean safe, Access2D<?> rhs)NgetTrace()The sum of the diagonal elements.inthashCode()Mhermitian(boolean upper)Similar toStructure2D.Logical.symmetric(boolean)but in addition the mirrored elements are conjugated.Mhessenberg(boolean upper)longindexOfLargest()Minvert()About inverting matrices:booleanisHermitian()booleanisSmall(double comparedTo)booleanisSymmetric()Mleft(long numberOfColumns)Mleft(Access2D<N> left)Mleft(Access2D<N>... left)Mlimits(long rowLimit, long columnLimit)Setting either limit to < 0 is interpreted as "no limit" (useful when you only want to limit either the rows or columns, and don't know the size of the other)Mlogical()Deprecated.v50 No need for this!Mmultiply(double scalarMultiplicand)Mmultiply(M multiplicand)Mmultiply(N scalarMultiplicand)Mnegate()The additive inverse of this.(package private) abstract Cholesky<N>newCholesky(Structure2D typical)(package private) abstract DeterminantTask<N>newDeterminantTask(Structure2D template)(package private) abstract Eigenvalue<N>newEigenvalue(Structure2D typical)(package private) abstract MnewInstance(ElementsSupplier<N> store)(package private) abstract InverterTask<N>newInverterTask(Structure2D template)(package private) abstract LDL<N>newLDL(Structure2D typical)(package private) LDU<N>newLDU(Structure2D typical)(package private) abstract LU<N>newLU(Structure2D typical)(package private) abstract QR<N>newQR(Structure2D typical)(package private) abstract SingularValue<N>newSingularValue(Structure2D typical)(package private) abstract SolverTask<N>newSolverTask(Structure2D templateBody, Structure2D templateRHS)doublenorm()The Frobenius norm is the square root of the sum of the squares of each element, or the square root of the sum of the square of the singular values.Moffsets(long rowOffset, long columnOffset)MonAll(double left, BinaryFunction<N> operator)MonAll(N left, BinaryFunction<N> operator)MonAll(BinaryFunction<N> operator, double right)MonAll(BinaryFunction<N> operator, N right)MonAll(ParameterFunction<N> operator, int parameter)MonAll(UnaryFunction<N> operator)MonAny(Transformation2D<N> operator)MonColumns(BinaryFunction<N> operator, Access1D<N> right)MonColumns(Access1D<N> left, BinaryFunction<N> operator)MonCompatible(BinaryFunction<N> operator, Access2D<N> right)MonCompatible(Access2D<N> left, BinaryFunction<N> operator)MonMatching(BinaryFunction<N> operator, Access2D<N> right)MonMatching(Access2D<N> left, BinaryFunction<N> operator)MonRows(BinaryFunction<N> operator, Access1D<N> right)MonRows(Access1D<N> left, BinaryFunction<N> operator)Mpower(int power)Multiply by itselfpowertimes.MreduceColumns(Aggregator aggregator)MreduceRows(Aggregator aggregator)Mrepeat(int rowsRepetitions, int columnsRepetitions)Will repeat this structure creating a new structure with a multiple of rows and columns.Mright(long numberOfColumns)Mright(Access2D<N> right)Mright(Access2D<N>... right)Mrow(int row)Mrow(long row)Mrows(int... rows)A selection (re-ordering) of rows.Mrows(long... rows)Mselect(int[] rows, int[] columns)Mselect(long[] rows, long[] columns)Creates a view of the underlying data structure of only the selected elements.Msignum()this == this.signum().multiply(this.norm())intsize()size() == getRowDim() * getColDim()Msolve(Access2D<?> rhs)This method solves a system of linear equations: [this][X]=[rhs].(package private) MatrixStore<N>store()Msubtract(double scalarSubtrahend)Msubtract(M subtrahend)Msubtract(N scalarSubtrahend)Msuperimpose(long row, long col, Access2D<N> matrix)(package private) ElementsSupplier<N>supplier()voidsupplyTo(TransformableRegion<N> receiver)Msymmetric(boolean upper)Defines a symmetricStructure2D(matrix) by mirroring one half (diagonally) on the other.Scalar<N>toScalar(int row, int col)Extracts one element of this matrix as a Scalar.java.lang.StringtoString()Mtranspose()Transposes this matrix.Mtriangular(boolean upper, boolean assumeOne)Mtridiagonal()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ojalgo.structure.Access1D
asCollectable1D, asKeyed1D, asList, axpy, dot, select, supplyTo, toList, toRawCopy1D
-
Methods inherited from interface org.ojalgo.structure.Access1D.Aggregatable
aggregateAll
-
Methods inherited from interface org.ojalgo.structure.Access2D
asCollectable2D, asKeyed2D, byteValue, byteValue, byteValue, byteValue, columns, doubleValue, doubleValue, elements, floatValue, floatValue, floatValue, floatValue, intValue, intValue, intValue, intValue, longValue, longValue, longValue, longValue, nonzeros, rows, shortValue, shortValue, shortValue, shortValue, toRawCopy2D
-
Methods inherited from interface org.ojalgo.structure.Access2D.Aggregatable
aggregateColumn, aggregateDiagonal, aggregateRow, reduceColumns, reduceRows
-
Methods inherited from interface org.ojalgo.structure.Access2D.Collectable
collect
-
Methods inherited from interface org.ojalgo.algebra.ScalarOperation.Addition
add
-
Methods inherited from interface org.ojalgo.algebra.ScalarOperation.Division
divide
-
Methods inherited from interface org.ojalgo.algebra.ScalarOperation.Multiplication
multiply
-
Methods inherited from interface org.ojalgo.algebra.ScalarOperation.Subtraction
subtract
-
Methods inherited from interface org.ojalgo.structure.Structure2D
firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow
-
Methods inherited from interface org.ojalgo.structure.Structure2D.Logical
superimpose
-
-
-
-
Field Detail
-
EQUALS
private static final NumberContext EQUALS
-
myDecomposition
private transient MatrixDecomposition<N extends java.lang.Comparable<N>> myDecomposition
-
myFactory
private final PhysicalStore.Factory<N extends java.lang.Comparable<N>,?> myFactory
-
myHashCode
private transient int myHashCode
-
myHermitian
private transient java.lang.Boolean myHermitian
-
mySPD
private transient java.lang.Boolean mySPD
-
myStore
private MatrixStore<N extends java.lang.Comparable<N>> myStore
-
mySupplier
private final ElementsSupplier<N extends java.lang.Comparable<N>> mySupplier
-
mySymmetric
private transient java.lang.Boolean mySymmetric
-
-
Constructor Detail
-
BasicMatrix
BasicMatrix(PhysicalStore.Factory<N,?> factory, ElementsSupplier<N> supplier)
-
-
Method Detail
-
calculateFrobeniusNorm
public static <M extends BasicMatrix<?,M>> double calculateFrobeniusNorm(M matrix)
The Frobenius norm is the square root of the sum of the squares of each element, or the square root of the sum of the square of the singular values.- Returns:
- The matrix' Frobenius norm
-
calculateInfinityNorm
public static <M extends BasicMatrix<?,M>> double calculateInfinityNorm(M matrix)
- Returns:
- The inf-norm or maximum row sum
-
calculateOneNorm
public static <M extends BasicMatrix<?,M>> double calculateOneNorm(M matrix)
- Returns:
- The 1-norm or maximum column sum
-
above
public M above(Access2D<N>... above)
- Specified by:
abovein interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
above
public M above(Access2D<N> above)
- Specified by:
abovein interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
above
public M above(long numberOfRows)
- Specified by:
abovein interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
add
public M add(double scalarAddend)
- Specified by:
addin interfaceScalarOperation.Addition<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this + scalarAddend.
-
add
public M add(M addend)
- Specified by:
addin interfaceOperation.Addition<N extends java.lang.Comparable<N>>- Parameters:
addend- What to add- Returns:
this + addend
-
add
public M add(N scalarAddend)
- Specified by:
addin interfaceScalarOperation.Addition<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this + scalarAddend.
-
aggregateColumn
public N aggregateColumn(long row, long col, Aggregator aggregator)
- Specified by:
aggregateColumnin interfaceAccess2D.Aggregatable<N extends java.lang.Comparable<N>>
-
aggregateDiagonal
public N aggregateDiagonal(long row, long col, Aggregator aggregator)
- Specified by:
aggregateDiagonalin interfaceAccess2D.Aggregatable<N extends java.lang.Comparable<N>>
-
aggregateRange
public N aggregateRange(long first, long limit, Aggregator aggregator)
- Specified by:
aggregateRangein interfaceAccess1D.Aggregatable<N extends java.lang.Comparable<N>>
-
aggregateRow
public N aggregateRow(long row, long col, Aggregator aggregator)
- Specified by:
aggregateRowin interfaceAccess2D.Aggregatable<N extends java.lang.Comparable<N>>
-
below
public M below(Access2D<N>... below)
- Specified by:
belowin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
below
public M below(Access2D<N> below)
- Specified by:
belowin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
below
public M below(long numberOfRows)
- Specified by:
belowin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
bidiagonal
public M bidiagonal(boolean upper)
- Specified by:
bidiagonalin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
column
public M column(int column)
- Specified by:
columnin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- See Also:
Structure2D.Logical.columns(int[])
-
column
public M column(long column)
- Specified by:
columnin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- See Also:
Structure2D.Logical.columns(int[])
-
columns
public M columns(int... columns)
Description copied from interface:Structure2D.LogicalA selection (re-ordering) of columns. Note that it's ok to reference the same base column more than once, and any negative column reference/index will translate to a column of zeros. The number of columns in the resulting matrix is the same as the number of elements in the columns index array.
-
columns
public M columns(long... columns)
- Specified by:
columnsin interfaceAccess2D<N extends java.lang.Comparable<N>>- Specified by:
columnsin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- See Also:
Structure2D.Logical.columns(int[])
-
conjugate
public M conjugate()
Description copied from interface:VectorSpaceThis method will (most likely) be moved to some other interface in the future! Just have to figure out where it fits...
The conjugate transpose of a matrix and/or the conjugate of a scalar/field like ComplexNumber or Quaternion.
The conjugate transpose of a real matrix is simply its transpose.
- Specified by:
conjugatein interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Specified by:
conjugatein interfaceVectorSpace<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
copy
public abstract DenseMutator2D<N,M> copy()
The returned instance can have its elements mutated in various ways, while the size/shape is fixed.- Returns:
- A fully mutable matrix builder with the elements initially set to a copy of this matrix – always creates a full dense copy.
- See Also:
logical()
-
count
public long count()
Description copied from interface:Structure2Dcount() == countRows() * countColumns()- Specified by:
countin interfaceStructure1D- Specified by:
countin interfaceStructure2D
-
countColumns
public long countColumns()
Description copied from interface:Structure2DOnly need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countColumnsin interfaceStructure2D- Returns:
- The number of columns
-
countRows
public long countRows()
Description copied from interface:Structure2DOnly need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countRowsin interfaceStructure2D- Returns:
- The number of rows
-
diagonal
public M diagonal()
- Specified by:
diagonalin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
- A diagonal matrix (main diagonal only)
-
diagonally
public M diagonally(Access2D<N>... diagonally)
- Specified by:
diagonallyin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
divide
public M divide(double scalarDivisor)
- Specified by:
dividein interfaceScalarOperation.Division<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this / scalarDivisor.
-
divide
public M divide(N scalarDivisor)
- Specified by:
dividein interfaceScalarOperation.Division<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this / scalarDivisor.
-
doubleValue
public double doubleValue(int row, int col)Description copied from interface:Access2DExtracts one element of this matrix as a double.- Specified by:
doubleValuein interfaceAccess2D<N extends java.lang.Comparable<N>>- Parameters:
row- A row index.col- A column index.- Returns:
- One matrix element
-
doubleValue
public double doubleValue(long index)
- Specified by:
doubleValuein interfaceAccess1D<N extends java.lang.Comparable<N>>- Specified by:
doubleValuein interfaceAccess2D<N extends java.lang.Comparable<N>>
-
enforce
public M enforce(NumberContext context)
- Specified by:
enforcein interfaceNumberContext.Enforceable<N extends java.lang.Comparable<N>>
-
equals
public boolean equals(java.lang.Object other)
true if "other" is anAccess2Dof the same size/shape and the elements are equal to high precision (12 significant digits).- Overrides:
equalsin classjava.lang.Object
-
get
@Deprecated public M get()
Deprecated.v50 No need for this!
-
get
public N get(long index)
-
get
public N get(long row, long col)
-
getColDim
public int getColDim()
- Specified by:
getColDimin interfaceStructure2D- Returns:
- The number of columns
-
getCondition
public double getCondition()
Matrix condition (2-norm)- Specified by:
getConditionin interfaceProvider2D.Condition- Returns:
- ratio of largest to smallest singular value.
-
getDeterminant
public N getDeterminant()
- Specified by:
getDeterminantin interfaceProvider2D.Determinant<N extends java.lang.Comparable<N>>- Returns:
- The matrix' determinant.
-
getEigenpairs
public java.util.List<Eigenvalue.Eigenpair> getEigenpairs()
- Specified by:
getEigenpairsin interfaceProvider2D.Eigenpairs
-
getRank
public int getRank()
The rank of a matrix is the (maximum) number of linearly independent rows or columns it contains. It is also equal to the number of nonzero singular values of the matrix.- Specified by:
getRankin interfaceProvider2D.Rank- Returns:
- The matrix' rank.
- See Also:
MatrixDecomposition.RankRevealing
-
getRowDim
public int getRowDim()
- Specified by:
getRowDimin interfaceStructure2D- Returns:
- The number of rows
-
getTrace
public N getTrace()
The sum of the diagonal elements.- Specified by:
getTracein interfaceProvider2D.Trace<N extends java.lang.Comparable<N>>- Returns:
- The matrix' trace.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
hermitian
public M hermitian(boolean upper)
Description copied from interface:Structure2D.LogicalSimilar toStructure2D.Logical.symmetric(boolean)but in addition the mirrored elements are conjugated.- Specified by:
hermitianin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
hessenberg
public M hessenberg(boolean upper)
- Specified by:
hessenbergin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
indexOfLargest
public long indexOfLargest()
- Specified by:
indexOfLargestin interfaceAccess1D.Aggregatable<N extends java.lang.Comparable<N>>
-
invert
public M invert()
About inverting matrices:
- "right inverse": [this][right inverse]=[I]. You may calculate it using solve(Access2D).
- "left inverse": [left inverse][this]=[I]. You may calculate it using solve(Access2D) and transposing.
- "generalised inverse": [this][generalised inverse][this]=[this]. Note that if [this] is singular or non-square, then [generalised inverse] is not unique.
- "pseudoinverse": The generalised inverse (there are typically/possibly many) with the smallest frobenius norm is called the (Moore-Penrose) pseudoinverse. You may calculate it using the QR or SingularValue decompositions.
- "inverse":
- If [left inverse]=[right inverse] then it is also [inverse].
- If [this] is square and has full rank then the [generalised inverse] is unique, with the [pseudoinverse] given, and equal to [inverse].
- Specified by:
invertin interfaceProvider2D.Inverse<N extends java.lang.Comparable<N>>- Returns:
- The "best possible" inverse....
-
isHermitian
public boolean isHermitian()
- Specified by:
isHermitianin interfaceProvider2D.Hermitian
-
isSmall
public boolean isSmall(double comparedTo)
- Specified by:
isSmallin interfaceNormedVectorSpace<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Parameters:
comparedTo- What to compare with- Returns:
- true if this is small compared to the magnitude of the input reference value.
-
isSymmetric
public boolean isSymmetric()
- Specified by:
isSymmetricin interfaceProvider2D.Symmetric
-
left
public M left(Access2D<N>... left)
- Specified by:
leftin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
left
public M left(Access2D<N> left)
- Specified by:
leftin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
left
public M left(long numberOfColumns)
- Specified by:
leftin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
limits
public M limits(long rowLimit, long columnLimit)
Description copied from interface:Structure2D.LogicalSetting either limit to < 0 is interpreted as "no limit" (useful when you only want to limit either the rows or columns, and don't know the size of the other)- Specified by:
limitsin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
logical
@Deprecated public final M logical()
Deprecated.v50 No need for this!
-
multiply
public M multiply(double scalarMultiplicand)
- Specified by:
multiplyin interfaceScalarOperation.Multiplication<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this * scalarMultiplicand.
-
multiply
public M multiply(M multiplicand)
- Specified by:
multiplyin interfaceOperation.Multiplication<N extends java.lang.Comparable<N>>- Parameters:
multiplicand- The multiplicand- Returns:
this * multiplicand.
-
multiply
public M multiply(N scalarMultiplicand)
- Specified by:
multiplyin interfaceScalarOperation.Multiplication<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this * multiplicand.
-
negate
public M negate()
Description copied from interface:Group.AdditiveThe additive inverse of this.- Specified by:
negatein interfaceGroup.Additive<N extends java.lang.Comparable<N>>- Returns:
-this.
-
norm
public double norm()
The Frobenius norm is the square root of the sum of the squares of each element, or the square root of the sum of the square of the singular values. This definition fits the requirements of NormedVectorSpace.norm().- Specified by:
normin interfaceNormedVectorSpace<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
- The matrix' Frobenius norm
-
offsets
public M offsets(long rowOffset, long columnOffset)
- Specified by:
offsetsin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
onAll
public M onAll(BinaryFunction<N> operator, double right)
-
onAll
public M onAll(BinaryFunction<N> operator, N right)
-
onAll
public M onAll(double left, BinaryFunction<N> operator)
-
onAll
public M onAll(N left, BinaryFunction<N> operator)
-
onAll
public M onAll(ParameterFunction<N> operator, int parameter)
-
onAll
public M onAll(UnaryFunction<N> operator)
-
onAny
public M onAny(Transformation2D<N> operator)
-
onColumns
public M onColumns(Access1D<N> left, BinaryFunction<N> operator)
-
onColumns
public M onColumns(BinaryFunction<N> operator, Access1D<N> right)
-
onCompatible
public M onCompatible(Access2D<N> left, BinaryFunction<N> operator)
- Specified by:
onCompatiblein interfaceOperate2D<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
onCompatible
public M onCompatible(BinaryFunction<N> operator, Access2D<N> right)
- Specified by:
onCompatiblein interfaceOperate2D<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
onMatching
public M onMatching(Access2D<N> left, BinaryFunction<N> operator)
- Specified by:
onMatchingin interfaceOperate2D<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
onMatching
public M onMatching(BinaryFunction<N> operator, Access2D<N> right)
- Specified by:
onMatchingin interfaceOperate2D<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
onRows
public M onRows(Access1D<N> left, BinaryFunction<N> operator)
-
onRows
public M onRows(BinaryFunction<N> operator, Access1D<N> right)
-
power
public M power(int power)
Description copied from interface:Operation.MultiplicationMultiply by itselfpowertimes.- Specified by:
powerin interfaceOperation.Multiplication<N extends java.lang.Comparable<N>>
-
reduceColumns
public M reduceColumns(Aggregator aggregator)
- Specified by:
reduceColumnsin interfaceStructure2D.ReducibleTo1D<N extends java.lang.Comparable<N>>
-
reduceRows
public M reduceRows(Aggregator aggregator)
- Specified by:
reduceRowsin interfaceStructure2D.ReducibleTo1D<N extends java.lang.Comparable<N>>
-
repeat
public M repeat(int rowsRepetitions, int columnsRepetitions)
Description copied from interface:Structure2D.LogicalWill repeat this structure creating a new structure with a multiple of rows and columns.- Specified by:
repeatin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Parameters:
rowsRepetitions- The number of times to repeat the rowscolumnsRepetitions- The number of times to repeat the columns- Returns:
- The builder
-
right
public M right(Access2D<N>... right)
- Specified by:
rightin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
right
public M right(Access2D<N> right)
- Specified by:
rightin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
right
public M right(long numberOfColumns)
- Specified by:
rightin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
row
public M row(int row)
- Specified by:
rowin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- See Also:
Structure2D.Logical.rows(int[])
-
row
public M row(long row)
- Specified by:
rowin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- See Also:
Structure2D.Logical.rows(int[])
-
rows
public M rows(int... rows)
Description copied from interface:Structure2D.LogicalA selection (re-ordering) of rows. Note that it's ok to reference the same base row more than once, and any negative row reference/index will translate to a row of zeros. The number of rows in the resulting matrix is the same as the number of elements in the rows index array.
-
rows
public M rows(long... rows)
- Specified by:
rowsin interfaceAccess2D<N extends java.lang.Comparable<N>>- Specified by:
rowsin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- See Also:
Structure2D.Logical.rows(int[])
-
select
public M select(int[] rows, int[] columns)
-
select
public M select(long[] rows, long[] columns)
Description copied from interface:Access2DCreates a view of the underlying data structure of only the selected elements. If either the rows or columns input arguments are null or empty arrays, then that transaltes to all rows and/or columns.
-
signum
public M signum()
Description copied from interface:NormedVectorSpacethis == this.signum().multiply(this.norm())- Specified by:
signumin interfaceNormedVectorSpace<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
- A unit "vector"
-
size
public int size()
Description copied from interface:Structure2Dsize() == getRowDim() * getColDim()- Specified by:
sizein interfaceStructure1D- Specified by:
sizein interfaceStructure2D
-
solve
public M solve(Access2D<?> rhs)
This method solves a system of linear equations: [this][X]=[rhs]. A combination of columns in [this] should produce a column(s) in [rhs]. It is ok for [rhs] to have more than 1 column.
- If the problem is over-qualified an approximate solution is returned.
- If the problem is under-qualified one possible solution is returned.
Remember that: [X][this]=[rhs] is equivalent to [this]T[X]T=[rhs]T
- Specified by:
solvein interfaceProvider2D.Solution<N extends java.lang.Comparable<N>>- Parameters:
rhs- The right hand side of the equation.- Returns:
- The solution, [X].
-
subtract
public M subtract(double scalarSubtrahend)
- Specified by:
subtractin interfaceScalarOperation.Subtraction<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this - scalarSubtrahend.
-
subtract
public M subtract(M subtrahend)
- Specified by:
subtractin interfaceOperation.Subtraction<N extends java.lang.Comparable<N>>- Parameters:
subtrahend- The subtrahend- Returns:
this - subtrahend.
-
subtract
public M subtract(N scalarSubtrahend)
- Specified by:
subtractin interfaceScalarOperation.Subtraction<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
this - scalarSubtrahend.
-
superimpose
public M superimpose(long row, long col, Access2D<N> matrix)
- Specified by:
superimposein interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
supplyTo
public void supplyTo(TransformableRegion<N> receiver)
- Specified by:
supplyToin interfaceAccess2D.Collectable<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
symmetric
public M symmetric(boolean upper)
Description copied from interface:Structure2D.LogicalDefines a symmetricStructure2D(matrix) by mirroring one half (diagonally) on the other.- Specified by:
symmetricin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Parameters:
upper- From where are the elements read?
-
toScalar
public Scalar<N> toScalar(int row, int col)
Description copied from interface:Matrix2DExtracts one element of this matrix as a Scalar.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
transpose
public M transpose()
Transposes this matrix. For complex matrices conjugate() and transpose() are NOT EQUAL.- Specified by:
transposein interfaceMatrix2D<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Specified by:
transposein interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>- Returns:
- A matrix that is the transpose of this matrix.
- See Also:
conjugate()
-
triangular
public M triangular(boolean upper, boolean assumeOne)
- Specified by:
triangularin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
tridiagonal
public M tridiagonal()
- Specified by:
tridiagonalin interfaceStructure2D.Logical<N extends java.lang.Comparable<N>,M extends BasicMatrix<N,M>>
-
getConditionProvider
private Provider2D.Condition getConditionProvider()
-
getDeterminantProvider
private Provider2D.Determinant<N> getDeterminantProvider()
-
getEigenpairsProvider
private Provider2D.Eigenpairs getEigenpairsProvider()
-
getInverseProvider
private Provider2D.Inverse<java.util.Optional<MatrixStore<N>>> getInverseProvider(boolean safe)
-
getRankProvider
private Provider2D.Rank getRankProvider()
-
getSolutionProvider
private Provider2D.Solution<java.util.Optional<MatrixStore<N>>> getSolutionProvider(boolean safe, Access2D<?> rhs)
-
newCholesky
abstract Cholesky<N> newCholesky(Structure2D typical)
-
newDeterminantTask
abstract DeterminantTask<N> newDeterminantTask(Structure2D template)
-
newEigenvalue
abstract Eigenvalue<N> newEigenvalue(Structure2D typical)
-
newInstance
abstract M newInstance(ElementsSupplier<N> store)
-
newInverterTask
abstract InverterTask<N> newInverterTask(Structure2D template)
-
newLDL
abstract LDL<N> newLDL(Structure2D typical)
-
newLDU
final LDU<N> newLDU(Structure2D typical)
-
newLU
abstract LU<N> newLU(Structure2D typical)
-
newQR
abstract QR<N> newQR(Structure2D typical)
-
newSingularValue
abstract SingularValue<N> newSingularValue(Structure2D typical)
-
newSolverTask
abstract SolverTask<N> newSolverTask(Structure2D templateBody, Structure2D templateRHS)
-
store
MatrixStore<N> store()
-
supplier
ElementsSupplier<N> supplier()
-
-