Package edu.jas.application
Class Residue<C extends GcdRingElem<C>>
- java.lang.Object
-
- edu.jas.application.Residue<C>
-
- All Implemented Interfaces:
AbelianGroupElem<Residue<C>>,Element<Residue<C>>,GcdRingElem<Residue<C>>,MonoidElem<Residue<C>>,RingElem<Residue<C>>,java.io.Serializable,java.lang.Comparable<Residue<C>>
public class Residue<C extends GcdRingElem<C>> extends java.lang.Object implements GcdRingElem<Residue<C>>
Residue ring element based on GenPolynomial with RingElem interface. Objects of this class are (nearly) immutable.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intisunitFlag to remember if this residue element is a unit. -1 is unknown, 1 is unit, 0 not a unit.ResidueRing<C>ringResidue class factory data structure.GenPolynomial<C>valValue part of the element data structure.
-
Constructor Summary
Constructors Constructor Description Residue(ResidueRing<C> r)The constructor creates a Residue object from a ring factory.Residue(ResidueRing<C> r, GenPolynomial<C> a)The constructor creates a Residue object from a ring factory and a polynomial.Residue(ResidueRing<C> r, GenPolynomial<C> a, int u)The constructor creates a Residue object from a ring factory, a polynomial and an indicator if a is a unit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Residue<C>abs()Residue absolute value.intcompareTo(Residue<C> b)Residue comparison.Residue<C>copy()Clone this.Residue<C>divide(Residue<C> S)Residue division.Residue<C>[]egcd(Residue<C> b)Extended greatest common divisor.booleanequals(java.lang.Object b)Comparison with any other object.ResidueRing<C>factory()Get the corresponding element factory.Residue<C>gcd(Residue<C> b)Greatest common divisor.inthashCode()Hash code for this residue.Residue<C>inverse()Residue inverse.booleanisConstant()Is Residue a constant.booleanisONE()Is Residue one.booleanisUnit()Is Residue unit.booleanisZERO()Is Residue zero.Residue<C>monic()Residue monic.Residue<C>multiply(Residue<C> S)Residue multiplication.Residue<C>negate()Residue negate.Residue<C>remainder(Residue<C> S)Residue remainder.intsignum()Residue signum.Residue<C>subtract(Residue<C> S)Residue subtraction.Residue<C>sum(Residue<C> S)Residue summation.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.-
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, quotientRemainder, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
-
-
-
Field Detail
-
ring
public final ResidueRing<C extends GcdRingElem<C>> ring
Residue class factory data structure.
-
val
public final GenPolynomial<C extends GcdRingElem<C>> val
Value part of the element data structure.
-
isunit
protected int isunit
Flag to remember if this residue element is a unit. -1 is unknown, 1 is unit, 0 not a unit.
-
-
Constructor Detail
-
Residue
public Residue(ResidueRing<C> r)
The constructor creates a Residue object from a ring factory.- Parameters:
r- residue ring factory.
-
Residue
public Residue(ResidueRing<C> r, GenPolynomial<C> a)
The constructor creates a Residue object from a ring factory and a polynomial.- Parameters:
r- residue ring factory.a- polynomial.
-
Residue
public Residue(ResidueRing<C> r, GenPolynomial<C> a, int u)
The constructor creates a Residue object from a ring factory, a polynomial and an indicator if a is a unit.- Parameters:
r- residue ring factory.a- polynomial.u- isunit indicator, -1, 0, 1.
-
-
Method Detail
-
factory
public ResidueRing<C> factory()
Get the corresponding element factory.- Specified by:
factoryin interfaceElement<C extends GcdRingElem<C>>- Returns:
- factory for this Element.
- See Also:
Element.factory()
-
copy
public Residue<C> copy()
Clone this.- Specified by:
copyin interfaceElement<C extends GcdRingElem<C>>- Returns:
- Creates and returns a copy of this Element.
- See Also:
Object.clone()
-
isZERO
public boolean isZERO()
Is Residue zero.- Specified by:
isZEROin interfaceAbelianGroupElem<C extends GcdRingElem<C>>- Returns:
- If this is 0 then true is returned, else false.
- See Also:
AbelianGroupElem.isZERO()
-
isONE
public boolean isONE()
Is Residue one.- Specified by:
isONEin interfaceMonoidElem<C extends GcdRingElem<C>>- Returns:
- If this is 1 then true is returned, else false.
- See Also:
MonoidElem.isONE()
-
isUnit
public boolean isUnit()
Is Residue unit.- Specified by:
isUnitin interfaceMonoidElem<C extends GcdRingElem<C>>- Returns:
- If this is a unit then true is returned, else false.
- See Also:
MonoidElem.isUnit()
-
isConstant
public boolean isConstant()
Is Residue a constant.- Returns:
- true if this.val is a constant polynomial, else false.
-
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.- Specified by:
toScriptin interfaceElement<C extends GcdRingElem<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:
toScriptFactoryin interfaceElement<C extends GcdRingElem<C>>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
Element.toScriptFactory()
-
compareTo
public int compareTo(Residue<C> b)
Residue comparison.- Specified by:
compareToin interfacejava.lang.Comparable<C extends GcdRingElem<C>>- Specified by:
compareToin interfaceElement<C extends GcdRingElem<C>>- Parameters:
b- Residue.- Returns:
- sign(this-b), 0 means that this and b are equivalent in this residue class ring.
-
equals
public boolean equals(java.lang.Object b)
Comparison with any other object.- Specified by:
equalsin interfaceElement<C extends GcdRingElem<C>>- Overrides:
equalsin classjava.lang.Object- Returns:
- true means that this and b are equivalent in this residue class ring.
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Hash code for this residue.- Specified by:
hashCodein interfaceElement<C extends GcdRingElem<C>>- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashCode.
- See Also:
Object.hashCode()
-
abs
public Residue<C> abs()
Residue absolute value.- Specified by:
absin interfaceAbelianGroupElem<C extends GcdRingElem<C>>- Returns:
- the absolute value of this.
- See Also:
AbelianGroupElem.abs()
-
sum
public Residue<C> sum(Residue<C> S)
Residue summation.- Specified by:
sumin interfaceAbelianGroupElem<C extends GcdRingElem<C>>- Parameters:
S- Residue.- Returns:
- this+S.
-
negate
public Residue<C> negate()
Residue negate.- Specified by:
negatein interfaceAbelianGroupElem<C extends GcdRingElem<C>>- Returns:
- -this.
- See Also:
AbelianGroupElem.negate()
-
signum
public int signum()
Residue signum.- Specified by:
signumin interfaceAbelianGroupElem<C extends GcdRingElem<C>>- Returns:
- signum(this).
- See Also:
AbelianGroupElem.signum()
-
subtract
public Residue<C> subtract(Residue<C> S)
Residue subtraction.- Specified by:
subtractin interfaceAbelianGroupElem<C extends GcdRingElem<C>>- Parameters:
S- Residue.- Returns:
- this-S.
-
divide
public Residue<C> divide(Residue<C> S)
Residue division.- Specified by:
dividein interfaceMonoidElem<C extends GcdRingElem<C>>- Parameters:
S- Residue.- Returns:
- this/S.
-
inverse
public Residue<C> inverse()
Residue inverse.- Specified by:
inversein interfaceMonoidElem<C extends GcdRingElem<C>>- Returns:
- S with S = 1/this if defined.
- See Also:
MonoidElem.inverse()
-
remainder
public Residue<C> remainder(Residue<C> S)
Residue remainder.- Specified by:
remainderin interfaceMonoidElem<C extends GcdRingElem<C>>- Parameters:
S- Residue.- Returns:
- this - (this/S)*S.
-
multiply
public Residue<C> multiply(Residue<C> S)
Residue multiplication.- Specified by:
multiplyin interfaceMonoidElem<C extends GcdRingElem<C>>- Parameters:
S- Residue.- Returns:
- this*S.
-
gcd
public Residue<C> gcd(Residue<C> b)
Greatest common divisor.- Specified by:
gcdin interfaceRingElem<C extends GcdRingElem<C>>- Parameters:
b- other element.- Returns:
- gcd(this,b).
-
egcd
public Residue<C>[] egcd(Residue<C> b)
Extended greatest common divisor. Note: Not implemented, throws UnsupportedOperationException.- Specified by:
egcdin interfaceRingElem<C extends GcdRingElem<C>>- Parameters:
b- other element.- Returns:
- [ gcd(this,b), c1, c2 ] with c1*this + c2*b = gcd(this,b).
-
-