edu.jas.vector
Class GenMatrix<C extends RingElem<C>>

java.lang.Object
  extended by 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.Cloneable, 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
 java.util.ArrayList<java.util.ArrayList<C>> matrix
           
 GenMatrixRing<C> ring
           
 
Constructor Summary
GenMatrix(GenMatrixRing<C> r)
          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
 GenMatrix<C> abs()
          Absolute value of this matrix.
 GenMatrix<C> clone()
          clone method.
 int compareTo(GenMatrix<C> b)
          compareTo, lexicogaphical comparison.
 GenMatrix<C> divide(GenMatrix<C> S)
          Divide this by S.
 GenMatrix<C>[] egcd(GenMatrix<C> b)
          Extended greatest common divisor.
 boolean equals(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.
 C get(int i, int j)
          Get element at row i, column j.
 int hashCode()
          Hash code for this GenMatrix.
 GenMatrix<C> inverse()
          Inverse of this.
 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.
 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 compination 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 compination of this matrix with scalar multiple of other matrix.
 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> 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.
 void setMutate(int i, int j, C el)
          Set element at row i, column j.
 int signum()
          sign of matrix.
 GenMatrix<C> subtract(GenMatrix<C> b)
          Difference of matrices.
 GenMatrix<C> sum(GenMatrix<C> b)
          Sum of matrices.
 java.lang.String toScript()
          Get a scripting compatible string representation.
 java.lang.String toScriptFactory()
          Get a scripting compatible string representation of the factory.
 java.lang.String toString()
          Get the String representation as RingElem.
 GenMatrix<C> transpose(GenMatrixRing<C> tr)
          Transposed matrix.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ring

public final GenMatrixRing<C extends RingElem<C>> ring

matrix

public final java.util.ArrayList<java.util.ArrayList<C extends RingElem<C>>> matrix
Constructor Detail

GenMatrix

public GenMatrix(GenMatrixRing<C> r)
Constructor for GenMatrix.


GenMatrix

public GenMatrix(GenMatrixRing<C> r,
                 java.util.List<java.util.List<C>> m)
Constructor for GenMatrix.


GenMatrix

public GenMatrix(GenMatrixRing<C> r,
                 java.util.ArrayList<java.util.ArrayList<C>> m)
Constructor for GenMatrix.

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.

toString

public java.lang.String toString()
Get the String representation as RingElem.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

toScript

public java.lang.String toScript()
Get a scripting compatible string representation.

Specified by:
toScript in interface Element<GenMatrix<C extends RingElem<C>>>
Returns:
script compatible representation for this Element.
See Also:
Element.toScript()

toScriptFactory

public java.lang.String toScriptFactory()
Get a scripting compatible string representation of the factory.

Specified by:
toScriptFactory in interface Element<GenMatrix<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.

Specified by:
factory in interface Element<GenMatrix<C extends RingElem<C>>>
Returns:
factory for this Element.
See Also:
Element.factory()

clone

public GenMatrix<C> clone()
clone method.

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

isZERO

public boolean isZERO()
Test if this is equal to a zero matrix.

Specified by:
isZERO in interface AbelianGroupElem<GenMatrix<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 interface MonoidElem<GenMatrix<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.

Specified by:
equals in interface Element<GenMatrix<C extends RingElem<C>>>
Overrides:
equals in class java.lang.Object
Returns:
true if this is equal to b, else false.
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Hash code for this GenMatrix.

Specified by:
hashCode in interface Element<GenMatrix<C extends RingElem<C>>>
Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode.
See Also:
Object.hashCode()

compareTo

public int compareTo(GenMatrix<C> b)
compareTo, lexicogaphical comparison.

Specified by:
compareTo in interface Element<GenMatrix<C extends RingElem<C>>>
Specified by:
compareTo in interface java.lang.Comparable<GenMatrix<C extends RingElem<C>>>
Parameters:
b - other
Returns:
1 if (this < b), 0 if (this == b) or -1 if (this > b).

isUnit

public boolean isUnit()
Test if this is a unit. I.e. there exists x with this.multiply(x).isONE() == true. Tests if all diagonal elements are units and all other elements are zero.

Specified by:
isUnit in interface MonoidElem<GenMatrix<C extends RingElem<C>>>
Returns:
true if this is a unit, else false.

signum

public int signum()
sign of matrix.

Specified by:
signum in interface AbelianGroupElem<GenMatrix<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:
sum in interface AbelianGroupElem<GenMatrix<C extends RingElem<C>>>
Returns:
this+b

subtract

public GenMatrix<C> subtract(GenMatrix<C> b)
Difference of matrices.

Specified by:
subtract in interface AbelianGroupElem<GenMatrix<C extends RingElem<C>>>
Returns:
this-b

negate

public GenMatrix<C> negate()
Negative of this matrix.

Specified by:
negate in interface AbelianGroupElem<GenMatrix<C extends RingElem<C>>>
Returns:
-this

abs

public GenMatrix<C> abs()
Absolute value of this matrix.

Specified by:
abs in interface AbelianGroupElem<GenMatrix<C extends RingElem<C>>>
Returns:
abs(this)

scalarMultiply

public GenMatrix<C> scalarMultiply(C s)
Product of this matrix with scalar.

Specified by:
scalarMultiply in interface AlgebraElem<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.

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:
linearCombination in interface AlgebraElem<GenMatrix<C extends RingElem<C>>,C extends RingElem<C>>
Parameters:
s - scalar
b - algebra element
t - scalar
Returns:
this*s+b*t

linearCombination

public GenMatrix<C> linearCombination(GenMatrix<C> b,
                                      C t)
Linear compination of this matrix with scalar multiple of other matrix.

Specified by:
linearCombination in interface AlgebraElem<GenMatrix<C extends RingElem<C>>,C extends RingElem<C>>
Parameters:
b - algebra element
t - scalar
Returns:
this+b*t

linearCombination

public GenMatrix<C> linearCombination(C t,
                                      GenMatrix<C> b)
Left linear compination of this matrix with scalar multiple of 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.

Returns:
s*this+t*b

transpose

public GenMatrix<C> transpose(GenMatrixRing<C> tr)
Transposed matrix.

Returns:
transpose(this)

multiply

public GenMatrix<C> multiply(GenMatrix<C> S)
Multiply this with S.

Specified by:
multiply in interface MonoidElem<GenMatrix<C extends RingElem<C>>>
Parameters:
S -
Returns:
this * S.

multiplySimple

public GenMatrix<C> multiplySimple(GenMatrix<C> S)
Multiply this with S. Simple unblocked algorithm.

Parameters:
S -
Returns:
this * S.

divide

public GenMatrix<C> divide(GenMatrix<C> S)
Divide this by S.

Specified by:
divide in interface MonoidElem<GenMatrix<C extends RingElem<C>>>
Parameters:
S -
Returns:
this / S.

remainder

public GenMatrix<C> remainder(GenMatrix<C> S)
Remainder after division of this by S.

Specified by:
remainder in interface MonoidElem<GenMatrix<C extends RingElem<C>>>
Parameters:
S -
Returns:
this - (this / S) * S.

inverse

public GenMatrix<C> inverse()
Inverse of this.

Specified by:
inverse in interface MonoidElem<GenMatrix<C extends RingElem<C>>>
Returns:
x with this * x = 1, if it exists.

gcd

public GenMatrix<C> gcd(GenMatrix<C> b)
Greatest common divisor.

Specified by:
gcd in interface RingElem<GenMatrix<C extends RingElem<C>>>
Parameters:
b - other element.
Returns:
gcd(this,b).

egcd

public GenMatrix<C>[] egcd(GenMatrix<C> b)
Extended greatest common divisor.

Specified by:
egcd in interface RingElem<GenMatrix<C extends RingElem<C>>>
Parameters:
b - other element.
Returns:
[ gcd(this,b), c1, c2 ] with c1*this + c2*b = gcd(this,b).