public class Zn.ZnElement extends java.lang.Object implements RingElement, UniqueByteRepresentable
| Modifier and Type | Field and Description |
|---|---|
protected java.math.BigInteger |
v
The unique integer
v such that 0 <= v < n and v projects
to the represented element in Zn. |
| Modifier | Constructor and Description |
|---|---|
protected |
ZnElement()
Create the zero element.
|
protected |
ZnElement(java.math.BigInteger v)
Construct a new
ZnElement initialized as [v] mod n (must reduce v before calling!). |
| Modifier and Type | Method and Description |
|---|---|
Zn.ZnElement |
add(Element e)
Computes \(\text{this} + e\).
|
ExponentConstantExpr |
asExponentExpression() |
java.math.BigInteger |
asInteger()
Interprets this element as an integer.
|
protected void |
checkSameModulus(Element e) |
boolean |
divides(RingElement e)
Returns true iff there exists an \(x\) in the ring such that \(\text{this} \cdot x = e\).
|
Zn.ZnElement[] |
divideWithRemainder(RingElement e)
Divides this by e with remainder, returning both quotient and remainder.
|
boolean |
equals(java.lang.Object obj) |
java.math.BigInteger |
getInteger()
Returns the unique integer representative for this element in \([0,n)\).
|
java.math.BigInteger |
getRank()
Implements the euclidean function of a euclidean domain.
|
Representation |
getRepresentation()
The representation of this object.
|
Zn |
getStructure()
Returns the
Structure that this Element belongs to. |
int |
hashCode() |
Zn.ZnElement |
inv()
Computes the multiplicative inverse of this element.
|
Zn.ZnElement |
mul(java.math.BigInteger k)
Computes \(\text{this} \cdot k\) (equivalent to \(\text{this} + \text{this} + \cdots\) k-times).
|
Zn.ZnElement |
mul(Element e)
Computes \(\text{this} \cdot e\).
|
Zn.ZnElement |
mul(long k)
Computes \(\text{this} \cdot k\) (equivalent to \(\text{this} + \text{this} + \cdots\) k-times).
|
Zn.ZnElement |
neg()
Computes the additive inverse of this element.
|
Zn.ZnElement |
pow(java.math.BigInteger k)
Calculates \(\text{this}^k\).
|
Zn.ZnElement |
pow(long k)
Calculates \(\text{this}^k\).
|
Zn.ZnElement |
sub(Element e)
Computes \(\text{this} - e\).
|
java.lang.String |
toString() |
ByteAccumulator |
updateAccumulator(ByteAccumulator accumulator)
Updates the ByteAccumulator with the unique byte representation of this object.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitdiv, isOne, isUnit, isZero, square, toAdditiveGroupElement, toUnitGroupElementgetUniqueByteRepresentationprotected final java.math.BigInteger v
v such that 0 <= v < n and v projects
to the represented element in Zn.protected ZnElement(java.math.BigInteger v)
ZnElement initialized as [v] mod n (must reduce v before calling!).protected ZnElement()
public Zn getStructure()
ElementStructure that this Element belongs to.getStructure in interface ElementgetStructure in interface RingElementpublic Zn.ZnElement add(Element e)
RingElementadd in interface RingElemente - the addendpublic Zn.ZnElement neg()
RingElementneg in interface RingElementpublic Zn.ZnElement sub(Element e)
RingElementsub in interface RingElemente - the subtrahendpublic Zn.ZnElement mul(Element e)
RingElementmul in interface RingElemente - the factorpublic Zn.ZnElement mul(java.math.BigInteger k)
RingElementmul in interface RingElementk - the factorpublic Zn.ZnElement mul(long k)
RingElementmul in interface RingElementk - the factorpublic Zn.ZnElement pow(java.math.BigInteger k)
RingElementNote that \(a^0 = 1\) for any \(a\) in the ring, particularly \(0^0 = 1\).
pow in interface RingElementpublic Zn.ZnElement pow(long k)
RingElementNote that \(a^0 = 1\) for any \(a\) in the ring, particularly \(0^0 = 1\).
pow in interface RingElementpublic Zn.ZnElement inv() throws java.lang.UnsupportedOperationException
RingElementinv in interface RingElementjava.lang.UnsupportedOperationException - if this is not a unitpublic boolean divides(RingElement e) throws java.lang.UnsupportedOperationException
RingElementdivides in interface RingElementjava.lang.UnsupportedOperationException - if this cannot be decided (efficiently)public Zn.ZnElement[] divideWithRemainder(RingElement e) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
RingElement
Specifically, returns an array result such that the first entry contains the quotient
and the second entry the remainder.
Furthermore, result[1].getRank() < e.getRank() or result[1] = 0.
This definition implies that the remainder is zero if and only if e divides this element.
divideWithRemainder in interface RingElementjava.lang.UnsupportedOperationException - if the ring is not a euclidean domainjava.lang.IllegalArgumentException - if e is zeropublic java.math.BigInteger getRank()
throws java.lang.UnsupportedOperationException
RingElementThe euclidean function is a function from \(R \setminus \{0\}\) to \(\mathbb{N}_0\) such that
a.getRank() >= 0 for any a in the ring
a.mul(b).getRank() >= a.getRank() for any a, b != 0
divideWithRemainder is less than the divisor's rank
The rank of the zero element is undefined (no guarantee as to what this method returns in that case).
getRank in interface RingElementjava.lang.UnsupportedOperationException - if the ring is not a euclidean domainprotected void checkSameModulus(Element e)
public boolean equals(java.lang.Object obj)
public int hashCode()
public Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic java.math.BigInteger getInteger()
public java.lang.String toString()
toString in class java.lang.Objectpublic ByteAccumulator updateAccumulator(ByteAccumulator accumulator)
UniqueByteRepresentableThe input to the accumulators update function is an injective (with respect to a given domain) byte encoding of this object.
For many use-cases, the AnnotatedUbrUtil can be used to quickly implement this method.
updateAccumulator in interface UniqueByteRepresentablepublic ExponentConstantExpr asExponentExpression()
public java.math.BigInteger asInteger()
throws java.lang.UnsupportedOperationException
RingElement
Formally, this method shall return the inverse of Ring.getElement(BigInteger), i.e.
x.getStructure().getElement(x.asInteger()).equals(x) (if asInteger() doesn't throw an exception).
asInteger in interface RingElementjava.lang.UnsupportedOperationException - if no such element exists or cannot be efficiently computed