Package edu.jas.arith
Class BigQuaternion
java.lang.Object
edu.jas.arith.BigQuaternion
- All Implemented Interfaces:
AbelianGroupElem<BigQuaternion>
,Element<BigQuaternion>
,GcdRingElem<BigQuaternion>
,MonoidElem<BigQuaternion>
,RingElem<BigQuaternion>
,StarRingElem<BigQuaternion>
,Serializable
,Comparable<BigQuaternion>
- Direct Known Subclasses:
BigQuaternionInteger
public class BigQuaternion
extends Object
implements StarRingElem<BigQuaternion>, GcdRingElem<BigQuaternion>
BigQuaternion class based on BigRational implementing the RingElem interface
and with the familiar MAS static method names. Objects of this class are
immutable. The integer quaternion methods are implemented after
https://de.wikipedia.org/wiki/Hurwitzquaternion see also
https://en.wikipedia.org/wiki/Hurwitz_quaternion
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
final BigRational
Imaginary part i of the data structure.final BigRational
Imaginary part j of the data structure.final BigRational
Imaginary part k of the data structure.private static final org.apache.logging.log4j.Logger
protected static final Random
final BigRational
Real part of the data structure.final BigQuaternionRing
Corresponding BigQuaternion ring. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for a BigQuaternion with no arguments.BigQuaternion
(BigQuaternionRing fac, long r) Constructor for a BigQuaternion from long.BigQuaternion
(BigQuaternionRing fac, BigComplex r) Constructor for a BigQuaternion from BigComplex.Constructor for a BigQuaternion from BigRationals.BigQuaternion
(BigQuaternionRing fac, BigRational r, BigRational i) Constructor for a BigQuaternion from BigRationals.BigQuaternion
(BigQuaternionRing fac, BigRational r, BigRational i, BigRational j) Constructor for a BigQuaternion from BigRationals.BigQuaternion
(BigQuaternionRing fac, BigRational r, BigRational i, BigRational j, BigRational k) Constructor for a BigQuaternion from BigRationals.BigQuaternion
(BigQuaternionRing fac, String s) The BigQuaternion string constructor accepts the following formats: empty string, "rational", or "rat i rat j rat k rat" with no blanks around i, j or k if used as polynoial coefficient. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Quaternion number absolute value.long
Returns the number of bits in the representation of this BigQuaternion, including a sign bit.ceil()
BigQuaternion ceiling, component wise.int
Since quaternion numbers are unordered, we use lexicographical order of re, im, jm and km.BigQuaternion conjugate.copy()
Clone this.BigQuaternion right divide.BigQuaternion divide.BigQuaternion extended greatest common divisor.boolean
Comparison with any other object.factory()
Get the corresponding element factory.floor()
BigQuaternion floor, component wise.gcd
(BigQuaternion S) Quaternion number greatest common divisor.getIm()
Get the imaginary part im.getJm()
Get the imaginary part jm.getKm()
Get the imaginary part km.getRe()
Get the real part.int
hashCode()
Hash code for this BigQuaternion.inverse()
BigQuaternion inverse.boolean
isEntier()
Is BigQuaternion entier element.boolean
isIMAG()
Is BigQuaternion imaginary one.boolean
isONE()
Is BigQuaternion number one.static boolean
Is BigQuaternion number one.static boolean
Is Quaternion number zero.boolean
isUnit()
Is BigQuaternion unit element.boolean
isZERO()
Is BigQuaternion number zero.BigQuaternion left divide.Quaternion number greatest common divisor.BigQuaternion left remainder.BigQuaternion multiply.BigQuaternion multiply with BigRational.BigQuaternion multiply left.negate()
BigQuaternion number negative.norm()
Quaternion number norm.static BigRational
Quaternion number absolute value.static BigQuaternion
Quaternion number conjugate.static BigQuaternion
QDIF
(BigQuaternion A, BigQuaternion B) Quaternion number difference.static BigQuaternion
Quaternion number inverse.static BigQuaternion
Quaternion number negative.static BigQuaternion
QPROD
(BigQuaternion A, BigQuaternion B) Quaternion number product.static BigQuaternion
QQ
(BigQuaternion A, BigQuaternion B) Quaternion number quotient.static BigQuaternion
QSUM
(BigQuaternion A, BigQuaternion B) Quaternion number sum.Quotient and remainder by division of this by S.BigQuaternion (right) remainder.BigQuaternion right divide.Quaternion number greatest common divisor.BigQuaternion right remainder.BigQuaternion round to next Hurwitz integer.BigQuaternion round to next Lipschitz integer.int
signum()
Since quaternion numbers are unordered, we use lexicographical order of re, im, jm and km.BigQuaternion subtraction.sum
(BigQuaternion B) BigQuaternion summation.toScript()
Get a scripting compatible string representation.Get a scripting compatible string representation of the factory.toString()
Get the string representation.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.jas.structure.MonoidElem
power, twosidedDivide, twosidedRemainder
-
Field Details
-
re
Real part of the data structure. -
im
Imaginary part i of the data structure. -
jm
Imaginary part j of the data structure. -
km
Imaginary part k of the data structure. -
ring
Corresponding BigQuaternion ring. -
random
-
logger
private static final org.apache.logging.log4j.Logger logger -
debug
private static final boolean debug
-
-
Constructor Details
-
BigQuaternion
public BigQuaternion(BigQuaternionRing fac, BigRational r, BigRational i, BigRational j, BigRational k) Constructor for a BigQuaternion from BigRationals.- Parameters:
fac
- BigQuaternionRing.r
- BigRational.i
- BigRational.j
- BigRational.k
- BigRational.
-
BigQuaternion
Constructor for a BigQuaternion from BigRationals.- Parameters:
fac
- BigQuaternionRing.r
- BigRational.i
- BigRational.j
- BigRational.
-
BigQuaternion
Constructor for a BigQuaternion from BigRationals.- Parameters:
fac
- BigQuaternionRing.r
- BigRational.i
- BigRational.
-
BigQuaternion
Constructor for a BigQuaternion from BigRationals.- Parameters:
fac
- BigQuaternionRing.r
- BigRational.
-
BigQuaternion
Constructor for a BigQuaternion from BigComplex.- Parameters:
fac
- BigQuaternionRing.r
- BigComplex.
-
BigQuaternion
Constructor for a BigQuaternion from long.- Parameters:
fac
- BigQuaternionRing.r
- long.
-
BigQuaternion
Constructor for a BigQuaternion with no arguments.- Parameters:
fac
- BigQuaternionRing.
-
BigQuaternion
The BigQuaternion string constructor accepts the following formats: empty string, "rational", or "rat i rat j rat k rat" with no blanks around i, j or k if used as polynoial coefficient.- Parameters:
fac
- BigQuaternionRing.s
- String.- Throws:
NumberFormatException
-
-
Method Details
-
factory
Get the corresponding element factory.- Specified by:
factory
in interfaceElement<BigQuaternion>
- Returns:
- factory for this Element.
- See Also:
-
copy
Clone this.- Specified by:
copy
in interfaceElement<BigQuaternion>
- Returns:
- Creates and returns a copy of this Element.
- See Also:
-
getRe
Get the real part.- Returns:
- re.
-
getIm
Get the imaginary part im.- Returns:
- im.
-
getJm
Get the imaginary part jm.- Returns:
- jm.
-
getKm
Get the imaginary part km.- Returns:
- km.
-
toString
Get the string representation. Is compatible with the string constructor. -
toScript
Get a scripting compatible string representation.- Specified by:
toScript
in interfaceElement<BigQuaternion>
- Returns:
- script compatible representation for this Element.
- See Also:
-
toScriptFactory
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactory
in interfaceElement<BigQuaternion>
- Returns:
- script compatible representation for this ElemFactory.
- See Also:
-
isQZERO
Is Quaternion number zero.- Parameters:
A
- BigQuaternion.- Returns:
- true if A is 0, else false.
-
isZERO
public boolean isZERO()Is BigQuaternion number zero.- Specified by:
isZERO
in interfaceAbelianGroupElem<BigQuaternion>
- Returns:
- true if this is 0, else false.
- See Also:
-
isQONE
Is BigQuaternion number one.- Parameters:
A
- is a quaternion number.- Returns:
- true if A is 1, else false.
-
isONE
public boolean isONE()Is BigQuaternion number one.- Specified by:
isONE
in interfaceMonoidElem<BigQuaternion>
- Returns:
- true if this is 1, else false.
- See Also:
-
isIMAG
public boolean isIMAG()Is BigQuaternion imaginary one.- Returns:
- true if this is i, else false.
-
isUnit
public boolean isUnit()Is BigQuaternion unit element.- Specified by:
isUnit
in interfaceMonoidElem<BigQuaternion>
- Returns:
- If this is a unit then true is returned, else false.
- See Also:
-
isEntier
public boolean isEntier()Is BigQuaternion entier element.- Returns:
- If this is an integer Hurwitz element then true is returned, else false.
-
equals
Comparison with any other object.- Specified by:
equals
in interfaceElement<BigQuaternion>
- Overrides:
equals
in classObject
- Parameters:
b
-- Returns:
- true if this is equal to b, else false.
- See Also:
-
hashCode
public int hashCode()Hash code for this BigQuaternion.- Specified by:
hashCode
in interfaceElement<BigQuaternion>
- Overrides:
hashCode
in classObject
- Returns:
- the hashCode.
- See Also:
-
compareTo
Since quaternion numbers are unordered, we use lexicographical order of re, im, jm and km.- Specified by:
compareTo
in interfaceComparable<BigQuaternion>
- Specified by:
compareTo
in interfaceElement<BigQuaternion>
- Parameters:
b
- BigQuaternion.- Returns:
- 0 if b is equal to this, 1 if this is greater b and -1 else.
-
signum
public int signum()Since quaternion numbers are unordered, we use lexicographical order of re, im, jm and km.- Specified by:
signum
in interfaceAbelianGroupElem<BigQuaternion>
- Returns:
- 0 if this is equal to 0; 1 if re > 0, or re == 0 and im > 0, or ...; -1 if re < 0, or re == 0 and im < 0, or ...
- See Also:
-
sum
BigQuaternion summation.- Specified by:
sum
in interfaceAbelianGroupElem<BigQuaternion>
- Parameters:
B
- BigQuaternion.- Returns:
- this+B.
-
QSUM
Quaternion number sum.- Parameters:
A
- BigQuaternion.B
- BigQuaternion.- Returns:
- A+B.
-
QDIF
Quaternion number difference.- Parameters:
A
- BigQuaternion.B
- BigQuaternion.- Returns:
- A-B.
-
subtract
BigQuaternion subtraction.- Specified by:
subtract
in interfaceAbelianGroupElem<BigQuaternion>
- Parameters:
B
- BigQuaternion.- Returns:
- this-B.
-
QNEG
Quaternion number negative.- Parameters:
A
- is a quaternion number- Returns:
- -A.
-
negate
BigQuaternion number negative.- Specified by:
negate
in interfaceAbelianGroupElem<BigQuaternion>
- Returns:
- -this.
- See Also:
-
QCON
Quaternion number conjugate.- Parameters:
A
- is a quaternion number.- Returns:
- the quaternion conjugate of A.
-
conjugate
BigQuaternion conjugate.- Specified by:
conjugate
in interfaceStarRingElem<BigQuaternion>
- Returns:
- conjugate(this).
-
norm
Quaternion number norm.- Specified by:
norm
in interfaceStarRingElem<BigQuaternion>
- Returns:
- ||this||.
- See Also:
-
abs
Quaternion number absolute value.- Specified by:
abs
in interfaceAbelianGroupElem<BigQuaternion>
- Returns:
- |this|.
- See Also:
-
QABS
Quaternion number absolute value.- Parameters:
A
- is a quaternion number.- Returns:
- the absolute value of A, a rational number. Note: The square root is not jet implemented.
-
QPROD
Quaternion number product.- Parameters:
A
- BigQuaternion.B
- BigQuaternion.- Returns:
- A*B.
-
multiply
BigQuaternion multiply with BigRational.- Parameters:
b
- BigRational.- Returns:
- this*b.
-
multiply
BigQuaternion multiply.- Specified by:
multiply
in interfaceMonoidElem<BigQuaternion>
- Parameters:
B
- BigQuaternion.- Returns:
- this*B.
-
multiplyLeft
BigQuaternion multiply left.- Parameters:
B
- BigQuaternion.- Returns:
- B*this.
-
QINV
Quaternion number inverse.- Parameters:
A
- is a non-zero quaternion number.- Returns:
- S with S * A = A * S = 1.
-
inverse
BigQuaternion inverse.- Specified by:
inverse
in interfaceMonoidElem<BigQuaternion>
- Returns:
- S with S * this = this * S = 1.
- See Also:
-
rightRemainder
BigQuaternion right remainder.- Specified by:
rightRemainder
in interfaceMonoidElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- 0.
-
remainder
BigQuaternion (right) remainder.- Specified by:
remainder
in interfaceMonoidElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- 0.
-
leftRemainder
BigQuaternion left remainder.- Specified by:
leftRemainder
in interfaceMonoidElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- 0.
-
QQ
Quaternion number quotient.- Parameters:
A
- BigQuaternion.B
- BigQuaternion.- Returns:
- R/S.
-
divide
BigQuaternion right divide.- Specified by:
divide
in interfaceMonoidElem<BigQuaternion>
- Parameters:
b
- BigQuaternion.- Returns:
- this * b**(-1).
-
rightDivide
BigQuaternion right divide.- Specified by:
rightDivide
in interfaceMonoidElem<BigQuaternion>
- Parameters:
b
- BigQuaternion.- Returns:
- q = this * b**(-1), such that q * b = this.
-
leftDivide
BigQuaternion left divide.- Specified by:
leftDivide
in interfaceMonoidElem<BigQuaternion>
- Parameters:
b
- BigQuaternion.- Returns:
- q = b**(-1) * this, such that b * q = this.
-
divide
BigQuaternion divide.- Parameters:
b
- BigRational.- Returns:
- this/b.
-
quotientRemainder
Quotient and remainder by division of this by S.- Specified by:
quotientRemainder
in interfaceMonoidElem<BigQuaternion>
- Parameters:
S
- a quaternion number- Returns:
- [this*S**(-1), this - (this*S**(-1))*S].
-
gcd
Quaternion number greatest common divisor.- Specified by:
gcd
in interfaceRingElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- gcd(this,S).
-
leftGcd
Quaternion number greatest common divisor.- Specified by:
leftGcd
in interfaceRingElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- leftCcd(this,S).
-
rightGcd
Quaternion number greatest common divisor.- Specified by:
rightGcd
in interfaceRingElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- rightCcd(this,S).
-
egcd
BigQuaternion extended greatest common divisor.- Specified by:
egcd
in interfaceRingElem<BigQuaternion>
- Parameters:
S
- BigQuaternion.- Returns:
- [ gcd(this,S), a, b ] with a*this + b*S = gcd(this,S).
-
bitLength
public long bitLength()Returns the number of bits in the representation of this BigQuaternion, including a sign bit. It is equivalent tore.bitLength()+im.bitLength()+jm.bitLength()+km.bitLength()
.)- Returns:
- number of bits in the representation of this BigQuaternion, including a sign bit.
-
ceil
BigQuaternion ceiling, component wise.- Returns:
- ceiling of this.
-
floor
BigQuaternion floor, component wise.- Returns:
- floor of this.
-
roundToLipschitzian
BigQuaternion round to next Lipschitz integer. BigQuaternion with all integer components.- Returns:
- Lipschitz integer of this.
-
roundToHurwitzian
BigQuaternion round to next Hurwitz integer. BigQuaternion with all integer or all 1/2 times integer components.- Returns:
- Hurwitz integer near this.
-