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>>,java.io.Serializable,java.lang.Comparable<GenMatrix<C>>
public class GenMatrix<C extends RingElem<C>> extends java.lang.Object implements AlgebraElem<GenMatrix<C>,C>
GenMatrix implements a generic matrix algebra over RingElem entries. Matrix has n columns and m rows over C.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description java.util.ArrayList<java.util.ArrayList<C>>matrixGenMatrixRing<C>ring
-
Constructor Summary
Constructors Constructor Description GenMatrix(GenMatrixRing<C> r)Constructor for zero GenMatrix.GenMatrix(GenMatrixRing<C> r, C[][] m)Constructor for GenMatrix.GenMatrix(GenMatrixRing<C> r, java.util.ArrayList<java.util.ArrayList<C>> m)Constructor for GenMatrix.GenMatrix(GenMatrixRing<C> r, java.util.List<java.util.List<C>> m)Constructor for GenMatrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GenMatrix<C>abs()Absolute value of this matrix.intcompareTo(GenMatrix<C> b)compareTo, lexicogaphical comparison.GenMatrix<C>concat(GenMatrixRing<C> cc, GenMatrix<C> b)Concat method.GenMatrix<C>copy()Copy method.GenMatrix<C>divide(GenMatrix<C> S)Divide this by S.GenMatrix<C>divideLeft(GenMatrix<C> S)Divide left this by S.GenMatrix<C>[]egcd(GenMatrix<C> b)Extended greatest common divisor.booleanequals(java.lang.Object other)Comparison with any other object.GenMatrixRing<C>factory()Get the corresponding element factory.GenMatrix<C>gcd(GenMatrix<C> b)Greatest common divisor.Cget(int i, int j)Get element at row i, column j.GenVector<C>getColumn(int i)Get column i.GenVector<C>getDiagonal()Get diagonal.GenMatrix<C>getLower()Get lower triangular L matrix.GenVector<C>getRow(int i)Get row i.GenMatrix<C>getUpper()Get upper triangular U matrix.GenMatrix<C>getUpperScaled()Get upper triangular U matrix with diagonale 1.inthashCode()Hash code for this GenMatrix.GenMatrix<C>inverse()Inverse of this.booleanisONE()Test if this is one.booleanisUnit()Test if this is a unit.booleanisZERO()Test if this is equal to a zero matrix.GenMatrix<C>leftLinearCombination(C s, C t, GenMatrix<C> b)left linear compination of this matrix with scalar multiple of other matrix.GenMatrix<C>leftScalarMultiply(C s)Left product of this matrix with scalar.GenMatrix<C>linearCombination(C t, GenMatrix<C> b)Left linear combination of this matrix with scalar multiple of other matrix.GenMatrix<C>linearCombination(C s, GenMatrix<C> b, C t)Linear compination of this matrix with scalar multiple of other matrix.GenMatrix<C>linearCombination(GenMatrix<C> b, C t)Linear combination of this matrix with scalar multiple of other matrix.GenMatrix<C>multiply(C s)Product of this matrix with scalar.GenMatrix<C>multiply(GenMatrix<C> S)Multiply this with S.GenMatrix<C>multiplySimple(GenMatrix<C> S)Multiply this with S.GenMatrix<C>negate()Negative of this matrix.GenMatrix<C>[]quotientRemainder(GenMatrix<C> S)Quotient and remainder by division of this by S.GenMatrix<C>remainder(GenMatrix<C> S)Remainder after division of this by S.GenMatrix<C>scalarMultiply(C s)Product of this matrix with scalar.GenMatrix<C>set(int i, int j, C el)Set element at row i, column j.voidsetMutate(int i, int j, C el)Set element at row i, column j.intsignum()sign of matrix.GenMatrix<C>stack(GenMatrixRing<C> st, GenMatrix<C> b)Stack method.GenMatrix<C>subtract(GenMatrix<C> b)Difference of matrices.GenMatrix<C>sum(GenMatrix<C> b)Sum of matrices.java.lang.StringtoScript()Get a scripting compatible string representation.java.lang.StringtoScriptFactory()Get a scripting compatible string representation of the factory.java.lang.StringtoString()Get the String representation as RingElem.GenMatrix<C>transpose()Transposed matrix.GenMatrix<C>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
-
-
-
-
Constructor Detail
-
GenMatrix
public GenMatrix(GenMatrixRing<C> r)
Constructor for zero GenMatrix.- Parameters:
r- matrix ring
-
GenMatrix
public GenMatrix(GenMatrixRing<C> r, java.util.List<java.util.List<C>> m)
Constructor for GenMatrix.- Parameters:
r- matrix ringm- matrix
-
GenMatrix
public GenMatrix(GenMatrixRing<C> r, java.util.ArrayList<java.util.ArrayList<C>> m)
Constructor for GenMatrix.- Parameters:
r- matrix ringm- matrix
-
GenMatrix
public GenMatrix(GenMatrixRing<C> r, C[][] m)
Constructor for GenMatrix.- Parameters:
r- matrix ringm- matrix
-
-
Method Detail
-
get
public C get(int i, int j)
Get element at row i, column j.- Parameters:
i- row index.j- column index.- Returns:
- this(i,j).
-
setMutate
public void setMutate(int i, int j, C el)
Set element at row i, column j. Mutates this matrix.- Parameters:
i- row index.j- column index.el- element to set.
-
set
public GenMatrix<C> set(int i, int j, C el)
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
public GenVector<C> getColumn(int i)
Get column i.- Parameters:
i- column index.- Returns:
- this(*,i) as vector.
-
getRow
public GenVector<C> getRow(int i)
Get row i.- Parameters:
i- row index.- Returns:
- this(i,*) as vector.
-
getDiagonal
public GenVector<C> getDiagonal()
Get diagonal.- Returns:
- diagonal(this) as vector.
-
getUpper
public GenMatrix<C> getUpper()
Get upper triangular U matrix.- Returns:
- U as matrix with equal length rows.
-
getUpperScaled
public GenMatrix<C> getUpperScaled()
Get upper triangular U matrix with diagonale 1.- Returns:
- U as matrix with equal length rows and diagonale 1.
-
getLower
public GenMatrix<C> getLower()
Get lower triangular L matrix.- Returns:
- L as matrix with equal length rows.
-
toString
public java.lang.String toString()
Get the String representation as RingElem.- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.
-
toScriptFactory
public java.lang.String toScriptFactory()
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactoryin interfaceElement<C extends RingElem<C>>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
Element.toScriptFactory()
-
factory
public GenMatrixRing<C> factory()
Get the corresponding element factory.
-
stack
public GenMatrix<C> stack(GenMatrixRing<C> st, GenMatrix<C> b)
Stack method.- Parameters:
st- stacked matrix ring.b- other matrix.- Returns:
- stacked matrix, this on top of other.
-
concat
public GenMatrix<C> concat(GenMatrixRing<C> cc, GenMatrix<C> b)
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:
isZEROin interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- true if this is 0, else false.
-
isONE
public boolean isONE()
Test if this is one.- Specified by:
isONEin interfaceMonoidElem<C extends RingElem<C>>- Returns:
- true if this is 1, else false.
-
equals
public boolean equals(java.lang.Object other)
Comparison with any other object.
-
hashCode
public int hashCode()
Hash code for this GenMatrix.
-
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:
isUnitin interfaceMonoidElem<C extends RingElem<C>>- Returns:
- true if this is a unit, else false.
-
signum
public int signum()
sign of matrix.- Specified by:
signumin interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- 1 if (this < 0), 0 if (this == 0) or -1 if (this > 0).
-
sum
public GenMatrix<C> sum(GenMatrix<C> b)
Sum of matrices.- Specified by:
sumin interfaceAbelianGroupElem<C extends RingElem<C>>- Parameters:
b- other matrix.- Returns:
- this+b
-
subtract
public GenMatrix<C> subtract(GenMatrix<C> b)
Difference of matrices.- Specified by:
subtractin interfaceAbelianGroupElem<C extends RingElem<C>>- Parameters:
b- other matrix.- Returns:
- this-b
-
negate
public GenMatrix<C> negate()
Negative of this matrix.- Specified by:
negatein interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- -this
-
abs
public GenMatrix<C> abs()
Absolute value of this matrix.- Specified by:
absin interfaceAbelianGroupElem<C extends RingElem<C>>- Returns:
- abs(this)
-
multiply
public GenMatrix<C> multiply(C s)
Product of this matrix with scalar.- Parameters:
s- scalar.- Returns:
- this*s
-
scalarMultiply
public GenMatrix<C> scalarMultiply(C s)
Product of this matrix with scalar.- Specified by:
scalarMultiplyin interfaceAlgebraElem<GenMatrix<C extends RingElem<C>>,C extends RingElem<C>>- Parameters:
s- scalar- Returns:
- this*s
-
leftScalarMultiply
public GenMatrix<C> leftScalarMultiply(C s)
Left product of this matrix with scalar.- Parameters:
s- scalar- Returns:
- s*this
-
linearCombination
public GenMatrix<C> linearCombination(C s, GenMatrix<C> b, C t)
Linear compination of this matrix with scalar multiple of other matrix.- Specified by:
linearCombinationin interfaceAlgebraElem<GenMatrix<C extends RingElem<C>>,C extends RingElem<C>>- Parameters:
s- scalart- scalarb- other matrix.- Returns:
- this*s+b*t
-
linearCombination
public GenMatrix<C> linearCombination(GenMatrix<C> b, C t)
Linear combination of this matrix with scalar multiple of other matrix.- Specified by:
linearCombinationin interfaceAlgebraElem<GenMatrix<C extends RingElem<C>>,C extends RingElem<C>>- Parameters:
t- scalarb- other matrix.- Returns:
- this+b*t
-
linearCombination
public GenMatrix<C> linearCombination(C t, GenMatrix<C> b)
Left linear combination of this matrix with scalar multiple of other matrix.- Parameters:
t- scalarb- other matrix.- Returns:
- this+t*b
-
leftLinearCombination
public GenMatrix<C> leftLinearCombination(C s, C t, GenMatrix<C> b)
left linear compination of this matrix with scalar multiple of other matrix.- Parameters:
s- scalart- scalarb- other matrix.- Returns:
- s*this+t*b
-
transpose
public GenMatrix<C> transpose(GenMatrixRing<C> tr)
Transposed matrix.- Parameters:
tr- transposed matrix ring.- Returns:
- transpose(this)
-
multiply
public GenMatrix<C> multiply(GenMatrix<C> S)
Multiply this with S.- Specified by:
multiplyin interfaceMonoidElem<C extends RingElem<C>>- Parameters:
S- other matrix.- Returns:
- this * S.
-
multiplySimple
public GenMatrix<C> multiplySimple(GenMatrix<C> S)
Multiply this with S. Simple unblocked algorithm.- Parameters:
S- other matrix.- Returns:
- this * S.
-
divide
public GenMatrix<C> divide(GenMatrix<C> S)
Divide this by S.- Specified by:
dividein interfaceMonoidElem<C extends RingElem<C>>- Parameters:
S- other matrix.- Returns:
- this * S^{-1}.
-
divideLeft
public GenMatrix<C> divideLeft(GenMatrix<C> S)
Divide left this by S.- Parameters:
S- other matrix.- Returns:
- S^{-1} * this.
-
remainder
public GenMatrix<C> remainder(GenMatrix<C> S)
Remainder after division of this by S.- Specified by:
remainderin interfaceMonoidElem<C extends RingElem<C>>- Parameters:
S- other matrix.- Returns:
- this - (this / S) * S.
-
quotientRemainder
public GenMatrix<C>[] quotientRemainder(GenMatrix<C> S)
Quotient and remainder by division of this by S.- Specified by:
quotientRemainderin interfaceMonoidElem<C extends RingElem<C>>- Parameters:
S- a GenMatrix- Returns:
- [this/S, this - (this/S)*S].
-
inverse
public GenMatrix<C> inverse()
Inverse of this.- Specified by:
inversein interfaceMonoidElem<C extends RingElem<C>>- Returns:
- x with this * x = 1, if it exists.
- See Also:
LinAlg.inverseLU(edu.jas.vector.GenMatrix,java.util.List)
-
-