Class BigScalar
- All Implemented Interfaces:
Comparable<BigDecimal>, Field<Scalar<BigDecimal>>, Group, Group.Additive<Scalar<BigDecimal>>, Group.Multiplicative<Scalar<BigDecimal>>, NormedVectorSpace<Scalar<BigDecimal>, BigDecimal>, Operation, Operation.Addition<Scalar<BigDecimal>>, Operation.Division<Scalar<BigDecimal>>, Operation.Multiplication<Scalar<BigDecimal>>, Operation.Subtraction<Scalar<BigDecimal>>, Ring<Scalar<BigDecimal>>, ScalarOperation, ScalarOperation.Addition<Scalar<BigDecimal>, BigDecimal>, ScalarOperation.Division<Scalar<BigDecimal>, BigDecimal>, ScalarOperation.Multiplication<Scalar<BigDecimal>, BigDecimal>, ScalarOperation.Subtraction<Scalar<BigDecimal>, BigDecimal>, VectorSpace<Scalar<BigDecimal>, BigDecimal>, Scalar<BigDecimal>, AccessScalar<BigDecimal>, Tensor<BigDecimal, Scalar<BigDecimal>>, NumberContext.Enforceable<BigScalar>, NumberDefinition
BigDecimal based implementation of the Scalar interface. Most/all other implementations
are based on primitive components. This implementation exists for historical reasons, and is now primarily
used for tests.-
Nested Class Summary
Nested classes/interfaces inherited from interface Group
Group.Additive<T>, Group.Multiplicative<T>Nested classes/interfaces inherited from interface Operation
Operation.Addition<T>, Operation.Division<T>, Operation.Multiplication<T>, Operation.Subtraction<T>Nested classes/interfaces inherited from interface Scalar
Scalar.Factory<N>Nested classes/interfaces inherited from interface ScalarOperation
ScalarOperation.Addition<T,N>, ScalarOperation.Division<T, N>, ScalarOperation.Multiplication<T, N>, ScalarOperation.Subtraction<T, N> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final NumberContextstatic final Scalar.Factory<BigDecimal> private final BigDecimalstatic final BigScalarstatic final BigScalarstatic final BigScalarstatic final BigScalar -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double arg) add(float scalarAddend) add(BigDecimal arg) intcompareTo(BigDecimal reference) This method will (most likely) be moved to some other interface in the future! Just have to figure out where it fits...divide(double arg) divide(float scalarDivisor) divide(BigDecimal arg) doubleenforce(NumberContext context) booleanfloatget()inthashCode()intintValue()invert()The multiplicative inverse.booleanstatic booleanisAbsolute(BigDecimal value) booleanisSmall(double comparedTo) static booleanisSmall(double comparedTo, BigDecimal value) booleanisZero()Tests if this scalar value is exactly zero.longmultiply(double arg) multiply(float scalarMultiplicand) multiply(BigDecimal arg) negate()The additive inverse of this.doublenorm()this == this.signum().multiply(this.norm())static BigScalarof(BigDecimal value) power(int power) Multiply by itselfpowertimes.signum()this == this.signum().multiply(this.norm())subtract(double arg) subtract(float scalarSubtrahend) subtract(BigDecimal arg) toString()toString(NumberContext context) static BigScalarvalueOf(double value) static BigScalarvalueOf(Comparable<?> number) Methods inherited from interface NumberDefinition
booleanValue, byteValue, shortValueMethods inherited from interface Scalar
add, dimensions, divide, multiply, rank, subtract, toPlainStringMethods inherited from interface Tensor
components, isSameShape
-
Field Details
-
FACTORY
-
NEG
-
ONE
-
TWO
-
ZERO
-
CONTEXT
-
myNumber
-
-
Constructor Details
-
BigScalar
public BigScalar() -
BigScalar
-
-
Method Details
-
isAbsolute
-
isSmall
-
of
-
valueOf
-
valueOf
-
add
- Specified by:
addin interfaceScalarOperation.Addition<Scalar<BigDecimal>, BigDecimal>- Returns:
this + scalarAddend.
-
add
- Specified by:
addin interfaceScalarOperation.Addition<Scalar<BigDecimal>, BigDecimal>- Returns:
this + scalarAddend.
-
add
- Specified by:
addin interfaceScalarOperation.Addition<Scalar<BigDecimal>, BigDecimal>- Returns:
this + scalarAddend.
-
compareTo
- Specified by:
compareToin interfaceComparable<BigDecimal>
-
conjugate
Description copied from interface:VectorSpaceThis method will (most likely) be moved to some other interface in the future! Just have to figure out where it fits...
The conjugate transpose of a matrix and/or the conjugate of a scalar/field like ComplexNumber or Quaternion.
The conjugate transpose of a real matrix is simply its transpose.
- Specified by:
conjugatein interfaceVectorSpace<Scalar<BigDecimal>, BigDecimal>
-
divide
- Specified by:
dividein interfaceScalarOperation.Division<Scalar<BigDecimal>, BigDecimal>- Returns:
this / scalarDivisor.
-
divide
- Specified by:
dividein interfaceScalarOperation.Division<Scalar<BigDecimal>, BigDecimal>- Returns:
this / scalarDivisor.
-
divide
- Specified by:
dividein interfaceScalarOperation.Division<Scalar<BigDecimal>, BigDecimal>- Returns:
this / scalarDivisor.
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein interfaceNumberDefinition
-
enforce
- Specified by:
enforcein interfaceNumberContext.Enforceable<BigScalar>
-
equals
-
floatValue
public float floatValue()- Specified by:
floatValuein interfaceNumberDefinition
-
get
- Specified by:
getin interfaceAccessScalar<BigDecimal>
-
hashCode
-
intValue
public int intValue()- Specified by:
intValuein interfaceNumberDefinition
-
invert
Description copied from interface:Group.MultiplicativeThe multiplicative inverse.- Specified by:
invertin interfaceGroup.Multiplicative<Scalar<BigDecimal>>- Returns:
IDENTITY / this.
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfaceScalar<BigDecimal>- Returns:
- true if this is equal to its own norm, modulus or absolute value (non-negative real part and no imaginary part); otherwise false.
- See Also:
-
isSmall
public boolean isSmall(double comparedTo) - Specified by:
isSmallin interfaceNormedVectorSpace<Scalar<BigDecimal>, BigDecimal>- Parameters:
comparedTo- What to compare with- Returns:
- true if this is small compared to the magnitude of the input reference value.
-
isZero
public boolean isZero()Description copied from interface:ScalarTests if this scalar value is exactly zero.Each implementation should test for zero as exactly as possible based on what's achievable with that specific scalar type. The purpose is NOT to have similar behavior between different implementations, but rather to leverage the full precision and capabilities of each type.
For example:
- Primitive types (like
double) should use exact equality comparison - High-precision types (like
Quadruple) should check both base and remainder components - Arbitrary-precision types (like
BigDecimal) should use their built-in zero detection - Complex types should check both real and imaginary parts
This method should NOT use tolerance-based comparisons or approximate zero detection, as those are better handled by context-aware methods like
NormedVectorSpace.isSmall(double).- Specified by:
isZeroin interfaceScalar<BigDecimal>- Returns:
- true if this scalar represents exactly zero, false otherwise
- See Also:
- Primitive types (like
-
longValue
public long longValue()- Specified by:
longValuein interfaceNumberDefinition
-
multiply
- Specified by:
multiplyin interfaceScalarOperation.Multiplication<Scalar<BigDecimal>, BigDecimal>- Returns:
this * multiplicand.
-
multiply
- Specified by:
multiplyin interfaceScalarOperation.Multiplication<Scalar<BigDecimal>, BigDecimal>- Returns:
this * scalarMultiplicand.
-
multiply
- Specified by:
multiplyin interfaceScalarOperation.Multiplication<Scalar<BigDecimal>, BigDecimal>- Returns:
this * scalarMultiplicand.
-
negate
Description copied from interface:Group.AdditiveThe additive inverse of this.- Specified by:
negatein interfaceGroup.Additive<Scalar<BigDecimal>>- Returns:
-this.
-
norm
public double norm()Description copied from interface:NormedVectorSpacethis == this.signum().multiply(this.norm())- Specified by:
normin interfaceNormedVectorSpace<Scalar<BigDecimal>, BigDecimal>- Returns:
- The norm
-
power
Description copied from interface:Operation.MultiplicationMultiply by itselfpowertimes.- Specified by:
powerin interfaceOperation.Multiplication<Scalar<BigDecimal>>
-
signum
Description copied from interface:NormedVectorSpacethis == this.signum().multiply(this.norm())- Specified by:
signumin interfaceNormedVectorSpace<Scalar<BigDecimal>, BigDecimal>- Returns:
- A unit "vector"
-
subtract
- Specified by:
subtractin interfaceScalarOperation.Subtraction<Scalar<BigDecimal>, BigDecimal>- Returns:
this - scalarSubtrahend.
-
subtract
- Specified by:
subtractin interfaceScalarOperation.Subtraction<Scalar<BigDecimal>, BigDecimal>- Returns:
this - scalarSubtrahend.
-
subtract
- Specified by:
subtractin interfaceScalarOperation.Subtraction<Scalar<BigDecimal>, BigDecimal>- Returns:
this - scalarSubtrahend.
-
toBigDecimal
- Specified by:
toBigDecimalin interfaceScalar<BigDecimal>
-
toString
-
toString
- Specified by:
toStringin interfaceScalar<BigDecimal>
-