Interface Scalar<N extends Comparable<N>>
- All Superinterfaces:
AccessScalar<N>, Comparable<N>, Field<Scalar<N>>, Group, Group.Additive<Scalar<N>>, Group.Multiplicative<Scalar<N>>, NormedVectorSpace<Scalar<N>, N>, NumberDefinition, Operation, Operation.Addition<Scalar<N>>, Operation.Division<Scalar<N>>, Operation.Multiplication<Scalar<N>>, Operation.Subtraction<Scalar<N>>, Ring<Scalar<N>>, ScalarOperation, ScalarOperation.Addition<Scalar<N>, N>, ScalarOperation.Division<Scalar<N>, N>, ScalarOperation.Multiplication<Scalar<N>, N>, ScalarOperation.Subtraction<Scalar<N>, N>, Tensor<N, Scalar<N>>, VectorSpace<Scalar<N>, N>
- All Known Subinterfaces:
SelfDeclaringScalar<S>
- All Known Implementing Classes:
Amount, BigScalar, ComplexNumber, ExactDecimal, Money, Price, PrimitiveScalar, Quadruple, Quantity, Quaternion, RationalNumber
public interface Scalar<N extends Comparable<N>>
extends AccessScalar<N>, Field<Scalar<N>>, ScalarOperation.Addition<Scalar<N>, N>, ScalarOperation.Division<Scalar<N>, N>, ScalarOperation.Subtraction<Scalar<N>, N>, Comparable<N>, Tensor<N, Scalar<N>>
A Scalar is:
- An abstraction of a vector/matrix element.
- A Comparable decorator, increasing the number of things you can do with them.
Theoretically it is a Field or at least a Division ring.
The intention is that implementors should be final immutable subclasses of Comparable and that they
should be inline with the requirements for ValueBased classes.
-
Nested Class Summary
Nested ClassesNested 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 ScalarOperation
ScalarOperation.Addition<T,N>, ScalarOperation.Division<T, N>, ScalarOperation.Multiplication<T, N>, ScalarOperation.Subtraction<T, N> -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbooleanValue(Comparable<?> number) static bytebyteValue(Comparable<?> number) default intThe range of the indices that identify the scalar components.static doubledoubleValue(Comparable<?> number) static floatfloatValue(Comparable<?> number) static intintValue(Comparable<?> number) booleanbooleanisZero()Tests if this scalar value is exactly zero.static longlongValue(Comparable<?> number) default intrank()The total number of indices required to uniquely identify each scalar component is called the order, degree or rank of the tensor.static shortshortValue(Comparable<?> number) default StringtoPlainString(NumberContext context) toString(NumberContext context) Methods inherited from interface AccessScalar
getMethods inherited from interface Comparable
compareToMethods inherited from interface Group.Additive
negateMethods inherited from interface Group.Multiplicative
invertMethods inherited from interface NormedVectorSpace
isSmall, norm, signumMethods inherited from interface NumberDefinition
booleanValue, byteValue, doubleValue, floatValue, intValue, longValue, shortValueMethods inherited from interface Operation.Multiplication
powerMethods inherited from interface ScalarOperation.Addition
add, add, addMethods inherited from interface ScalarOperation.Division
divide, divide, divideMethods inherited from interface ScalarOperation.Multiplication
multiply, multiply, multiplyMethods inherited from interface ScalarOperation.Subtraction
subtract, subtract, subtractMethods inherited from interface Tensor
components, isSameShapeMethods inherited from interface VectorSpace
conjugate
-
Method Details
-
booleanValue
-
byteValue
-
doubleValue
-
floatValue
-
intValue
-
longValue
-
shortValue
-
add
- Specified by:
addin interfaceOperation.Addition<N extends Comparable<N>>- Parameters:
addend- What to add- Returns:
this + addend
-
dimensions
default int dimensions()Description copied from interface:TensorThe range of the indices that identify the scalar components. Each index of a tensor ranges over the number of dimensions.- Specified by:
dimensionsin interfaceTensor<N extends Comparable<N>, Scalar<N extends Comparable<N>>>
-
divide
- Specified by:
dividein interfaceOperation.Division<N extends Comparable<N>>- Parameters:
divisor- The divisor- Returns:
this / divisor.
-
isAbsolute
boolean isAbsolute()- 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:
-
isZero
boolean isZero()Tests 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).- Returns:
- true if this scalar represents exactly zero, false otherwise
- See Also:
- Primitive types (like
-
multiply
- Specified by:
multiplyin interfaceOperation.Multiplication<N extends Comparable<N>>- Parameters:
multiplicand- The multiplicand- Returns:
this * multiplicand.
-
rank
default int rank()Description copied from interface:TensorThe total number of indices required to uniquely identify each scalar component is called the order, degree or rank of the tensor.- Specified by:
rankin interfaceTensor<N extends Comparable<N>, Scalar<N extends Comparable<N>>>
-
subtract
- Specified by:
subtractin interfaceOperation.Subtraction<N extends Comparable<N>>- Parameters:
subtrahend- The subtrahend- Returns:
this - subtrahend.
-
toBigDecimal
BigDecimal toBigDecimal() -
toPlainString
-
toString
-