Class Quaternions
- All Implemented Interfaces:
AbelianGroup<Quaternion>, AbelianMonoid<Quaternion>, Group<Quaternion>, Magma<Quaternion>, Monoid<Quaternion>, Field<Quaternion>, Ring<Quaternion>, Semiring<Quaternion>, InfiniteSet<Quaternion>, Set<Quaternion>
This class represents the structure of quaternions.
It implements Field because H forms a skew field (division ring)
under addition and multiplication.
Note: Quaternion multiplication is non-commutative.
* @author Silvere Martin-Michiellot- Since:
- 1.0
- Author:
- Gemini AI (Google DeepMind)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionadd(Quaternion a, Quaternion b) Returns the sum of two elements (additive notation).intReturns the characteristic of this field.booleancontains(Quaternion element) Tests whether this set contains the specified element.Returns a human-readable description of this set.static QuaternionsReturns the singleton instance.inverse(Quaternion element) Returns the multiplicative inverse of a non-zero element.booleanReturnstrueif this set is countable (i.e., its elements can be put in one-to-one correspondence with the natural numbers).booleanisEmpty()Returnstrueif this set contains no elements.booleanFields always have commutative multiplication.multiply(Quaternion a, Quaternion b) Returns the product of two elements.negate(Quaternion element) Returns the additive inverse (negation) of an element.one()Returns the multiplicative identity (one element).operate(Quaternion a, Quaternion b) Performs the binary operation on two elements.toString()zero()Returns the additive identity (zero element).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AbelianGroup
isCommutative, subtractMethods inherited from interface AbelianMonoid
identity, isCommutativeMethods inherited from interface Monoid
isAssociative
-
Field Details
-
INSTANCE
Singleton instance
-
-
Method Details
-
getInstance
Returns the singleton instance.- Returns:
- the Quaternions structure
-
operate
Description copied from interface:MagmaPerforms the binary operation on two elements.This is the fundamental operation of a magma. The result must be an element of this magma (closure property).
Properties: None required (not necessarily associative or commutative)
- Specified by:
operatein interfaceMagma<Quaternion>- Parameters:
a- the first operandb- the second operand- Returns:
- the result of a ∗ b
- See Also:
-
add
Description copied from interface:AbelianMonoidReturns the sum of two elements (additive notation).Delegates to
Magma.operate(Object, Object).- Specified by:
addin interfaceAbelianMonoid<Quaternion>- Parameters:
a- the first addendb- the second addend- Returns:
- a + b
-
characteristic
public int characteristic()Description copied from interface:FieldReturns the characteristic of this field.The characteristic is the smallest positive integer n such that:
1 + 1 + ... + 1 (n times) = 0
If no such n exists, the characteristic is 0.Examples:
- char(ℚ) = char(â„Â) = char(â„‚) = 0
- char(ðÂâ€Â½Ã¢â€šÅ¡) = p (for prime p)
- Specified by:
characteristicin interfaceField<Quaternion>- Returns:
- the characteristic (0 for infinite fields, p for finite fields)
-
zero
Description copied from interface:AbelianMonoidReturns the additive identity (zero element).Delegates to
AbelianMonoid.identity().- Specified by:
zeroin interfaceAbelianMonoid<Quaternion>- Returns:
- the zero element
-
negate
Description copied from interface:AbelianGroupReturns the additive inverse (negation) of an element.Satisfies: a + (-a) = (-a) + a = 0
- Specified by:
negatein interfaceAbelianGroup<Quaternion>- Parameters:
element- the element to negate- Returns:
- -element
- See Also:
-
multiply
Description copied from interface:SemiringReturns the product of two elements.Multiplication must be associative and distribute over addition.
- Specified by:
multiplyin interfaceSemiring<Quaternion>- Parameters:
a- the first factorb- the second factor- Returns:
- a × b
-
one
Description copied from interface:SemiringReturns the multiplicative identity (one element).Satisfies: 1 × a = a × 1 = a for all elements a.
- Specified by:
onein interfaceSemiring<Quaternion>- Returns:
- the multiplicative identity
-
isMultiplicationCommutative
public boolean isMultiplicationCommutative()Description copied from interface:FieldFields always have commutative multiplication.- Specified by:
isMultiplicationCommutativein interfaceField<Quaternion>- Specified by:
isMultiplicationCommutativein interfaceSemiring<Quaternion>- Returns:
- always
true
-
inverse
Description copied from interface:FieldReturns the multiplicative inverse of a non-zero element.For element a ≠0, returns a⻹ such that: a × a⻹ = a⻹ × a = 1
Examples:
- In ℚ: inverse(2/3) = 3/2
- In â„Â: inverse(5.0) = 0.2
- In â„‚: inverse(3+4i) = (3-4i)/25
- Specified by:
inversein interfaceField<Quaternion>- Specified by:
inversein interfaceGroup<Quaternion>- Parameters:
element- the element to invert (must be non-zero)- Returns:
- the multiplicative inverse
- See Also:
-
isCountable
public boolean isCountable()Description copied from interface:InfiniteSetReturnstrueif this set is countable (i.e., its elements can be put in one-to-one correspondence with the natural numbers).Examples:
- Countable: ℕ (Natural numbers), ℤ (Integers), ℚ (Rational numbers)
- Uncountable: â„ (Real numbers), â„‚ (Complex numbers)
- Specified by:
isCountablein interfaceInfiniteSet<Quaternion>- Returns:
trueif this set is countable
-
contains
Description copied from interface:SetTests whether this set contains the specified element.This is the fundamental operation of a set - membership testing.
- Specified by:
containsin interfaceSet<Quaternion>- Parameters:
element- the element to test for membership- Returns:
trueif this set contains the element,falseotherwise- See Also:
-
isEmpty
public boolean isEmpty()Description copied from interface:SetReturnstrueif this set contains no elements.The empty set (∅) is a fundamental concept in set theory. It is the unique set containing no elements.
- Specified by:
isEmptyin interfaceSet<Quaternion>- Returns:
trueif this set is empty
-
description
Description copied from interface:SetReturns a human-readable description of this set.Examples:
- "â„ (Real Numbers)"
- "ℤ/12ℤ (Integers modulo 12)"
- "{1, 2, 3, 4, 5}"
- Specified by:
descriptionin interfaceSet<Quaternion>- Returns:
- a description of this set
-
toString
-