Package edu.jas.vector
Class GenMatrix<C extends RingElem<C>>
java.lang.Object
edu.jas.vector.GenMatrix<C>
- All Implemented Interfaces:
AbelianGroupElem<GenMatrix<C>>
,AlgebraElem<GenMatrix<C>,
,C> Element<GenMatrix<C>>
,MonoidElem<GenMatrix<C>>
,RingElem<GenMatrix<C>>
,Serializable
,Comparable<GenMatrix<C>>
GenMatrix implements a generic matrix algebra over RingElem entries. Matrix
has n columns and m rows over C.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGenMatrix
(GenMatrixRing<C> r) Constructor for zero GenMatrix.GenMatrix
(GenMatrixRing<C> r, C[][] m) Constructor for GenMatrix.Constructor for GenMatrix.Constructor for GenMatrix. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Absolute value of this matrix.int
compareTo, lexicogaphical comparison.concat
(GenMatrixRing<C> cc, GenMatrix<C> b) Concat method.copy()
Copy method.Divide this by S.divideLeft
(GenMatrix<C> S) Divide left this by S.Extended greatest common divisor.boolean
Comparison with any other object.factory()
Get the corresponding element factory.Greatest common divisor.get
(int i, int j) Get element at row i, column j.getColumn
(int i) Get column i.Get diagonal.getLower()
Get lower triangular L matrix.getRow
(int i) Get row i.getUpper()
Get upper triangular U matrix.Get upper triangular U matrix with diagonal 1.int
hashCode()
Hash code for this GenMatrix.inverse()
Inverse of this.boolean
Test if this is a non-zero diagonal matrix.boolean
isONE()
Test if this is one.boolean
isUnit()
Test if this is a unit.boolean
isZERO()
Test if this is equal to a zero matrix.leftLinearCombination
(C s, C t, GenMatrix<C> b) left linear compination of this matrix with scalar multiple of other matrix.Left product of this matrix with scalar.linearCombination
(C t, GenMatrix<C> b) Left linear combination of this matrix with scalar multiple of other matrix.linearCombination
(C s, GenMatrix<C> b, C t) Linear compination of this matrix with scalar multiple of other matrix.linearCombination
(GenMatrix<C> b, C t) Linear combination of this matrix with scalar multiple of other matrix.Product of this matrix with scalar.Multiply this with S.multiplySimple
(GenMatrix<C> S) Multiply this with S.negate()
Negative of this matrix.Quotient and remainder by division of this by S.Remainder after division of this by S.scalarMultiply
(C s) Product of this matrix with scalar.Set element at row i, column j.void
Set element at row i, column j.int
signum()
sign of matrix.stack
(GenMatrixRing<C> st, GenMatrix<C> b) Stack method.Difference of matrices.Sum of matrices.toScript()
Get a scripting compatible string representation.Get a scripting compatible string representation of the factory.toString()
Get the String representation as RingElem.trace()
Trace.Transposed matrix.transpose
(GenMatrixRing<C> tr) Transposed matrix.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.jas.structure.MonoidElem
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
ring
-
matrix
-
hashValue
private int hashValue
-
-
Constructor Details
-
GenMatrix
Constructor for zero GenMatrix.- Parameters:
r
- matrix ring
-
GenMatrix
Constructor for GenMatrix.- Parameters:
r
- matrix ringm
- matrix
-
GenMatrix
Constructor for GenMatrix.- Parameters:
r
- matrix ringm
- matrix
-
GenMatrix
Constructor for GenMatrix.- Parameters:
r
- matrix ringm
- matrix
-
-
Method Details
-
get
Get element at row i, column j.- Parameters:
i
- row index.j
- column index.- Returns:
- this(i,j).
-
setMutate
Set element at row i, column j. Mutates this matrix.- Parameters:
i
- row index.j
- column index.el
- element to set.
-
set
Set element at row i, column j.- Parameters:
i
- row index.j
- column index.el
- element to set.- Returns:
- new matrix m, with m(i,j) == el.
-
getColumn
Get column i.- Parameters:
i
- column index.- Returns:
- this(*,i) as vector.
-
getRow
Get row i.- Parameters:
i
- row index.- Returns:
- this(i,*) as vector.
-
getDiagonal
Get diagonal.- Returns:
- diagonal(this) as vector.
-
trace
Trace.- Returns:
- sum of diagonal elements.
-
getUpper
Get upper triangular U matrix.- Returns:
- U as matrix with equal length rows.
-
getUpperScaled
Get upper triangular U matrix with diagonal 1.- Returns:
- U as matrix with equal length rows and diagonal 1.
-
getLower
Get lower triangular L matrix.- Returns:
- L as matrix with equal length rows.
-
toString
Get the String representation as RingElem. -
toScript
Get a scripting compatible string representation. -
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactory
in interfaceElement<C extends RingElem<C>>
- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
factory
Get the corresponding element factory. -
copy
Copy method. -
stack
Stack method.- Parameters:
st
- stacked matrix ring.b
- other matrix.- Returns:
- stacked matrix, this on top of other.
-
concat
Concat method.- Parameters:
cc
- concated matrix ring.b
- other matrix.- Returns:
- concated matrix, this before of other.
-
isZERO
public boolean isZERO()Test if this is equal to a zero matrix.- Specified by:
isZERO
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- true if this is 0, else false.
-
isONE
public boolean isONE()Test if this is one.- Specified by:
isONE
in interfaceMonoidElem<C extends RingElem<C>>
- Returns:
- true if this is 1, else false.
-
isDiagonal
public boolean isDiagonal()Test if this is a non-zero diagonal matrix.- Returns:
- true if this is non-zero diagonal, else false.
-
equals
Comparison with any other object. -
hashCode
public int hashCode()Hash code for this GenMatrix. -
compareTo
compareTo, lexicogaphical comparison. -
isUnit
public boolean isUnit()Test if this is a unit. I.e. there exists x with this.multiply(x).isONE() == true. Tests if matrix is not singular. Was previously a test if all diagonal elements are units and all other elements are zero.- Specified by:
isUnit
in interfaceMonoidElem<C extends RingElem<C>>
- Returns:
- true if this is a unit, else false.
-
signum
public int signum()sign of matrix.- Specified by:
signum
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- 1 if (this < 0), 0 if (this == 0) or -1 if (this > 0).
-
sum
Sum of matrices.- Specified by:
sum
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Parameters:
b
- other matrix.- Returns:
- this+b
-
subtract
Difference of matrices.- Specified by:
subtract
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Parameters:
b
- other matrix.- Returns:
- this-b
-
negate
Negative of this matrix.- Specified by:
negate
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- -this
-
abs
Absolute value of this matrix.- Specified by:
abs
in interfaceAbelianGroupElem<C extends RingElem<C>>
- Returns:
- abs(this)
-
multiply
Product of this matrix with scalar.- Parameters:
s
- scalar.- Returns:
- this*s
-
scalarMultiply
Product of this matrix with scalar.- Specified by:
scalarMultiply
in interfaceAlgebraElem<GenMatrix<C extends RingElem<C>>,
C extends RingElem<C>> - Parameters:
s
- scalar- Returns:
- this*s
-
leftScalarMultiply
Left product of this matrix with scalar.- Parameters:
s
- scalar- Returns:
- s*this
-
linearCombination
Linear compination of this matrix with scalar multiple of other matrix.- Specified by:
linearCombination
in interfaceAlgebraElem<GenMatrix<C extends RingElem<C>>,
C extends RingElem<C>> - Parameters:
s
- scalarb
- other matrix.t
- scalar- Returns:
- this*s+b*t
-
linearCombination
Linear combination of this matrix with scalar multiple of other matrix.- Specified by:
linearCombination
in interfaceAlgebraElem<GenMatrix<C extends RingElem<C>>,
C extends RingElem<C>> - Parameters:
b
- other matrix.t
- scalar- Returns:
- this+b*t
-
linearCombination
Left linear combination of this matrix with scalar multiple of other matrix.- Parameters:
t
- scalarb
- other matrix.- Returns:
- this+t*b
-
leftLinearCombination
left linear compination of this matrix with scalar multiple of other matrix.- Parameters:
s
- scalart
- scalarb
- other matrix.- Returns:
- s*this+t*b
-
transpose
Transposed matrix.- Parameters:
tr
- transposed matrix ring.- Returns:
- transpose(this)
-
transpose
Transposed matrix.- Returns:
- transpose(this)
-
multiply
Multiply this with S.- Specified by:
multiply
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
S
- other matrix.- Returns:
- this * S.
-
multiplySimple
Multiply this with S. Simple unblocked algorithm.- Parameters:
S
- other matrix.- Returns:
- this * S.
-
divide
Divide this by S.- Specified by:
divide
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
S
- other matrix.- Returns:
- this * S^{-1}.
-
divideLeft
Divide left this by S.- Parameters:
S
- other matrix.- Returns:
- S^{-1} * this.
-
remainder
Remainder after division of this by S.- Specified by:
remainder
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
S
- other matrix.- Returns:
- this - (this / S) * S.
-
quotientRemainder
Quotient and remainder by division of this by S.- Specified by:
quotientRemainder
in interfaceMonoidElem<C extends RingElem<C>>
- Parameters:
S
- a GenMatrix- Returns:
- [this/S, this - (this/S)*S].
-
inverse
Inverse of this.- Specified by:
inverse
in interfaceMonoidElem<C extends RingElem<C>>
- Returns:
- x with this * x = 1, if it exists.
- See Also:
-
gcd
Greatest common divisor. -
egcd
Extended greatest common divisor.
-