Module ojalgo

Class PrimitiveScalar

    • Constructor Detail

      • PrimitiveScalar

        public PrimitiveScalar()
      • PrimitiveScalar

        private PrimitiveScalar​(double value)
    • Method Detail

      • isAbsolute

        public static boolean isAbsolute​(double value)
      • isInfinite

        public static boolean isInfinite​(double value)
      • isNaN

        public static boolean isNaN​(double value)
      • isSmall

        public static boolean isSmall​(double comparedTo,
                                      double value)
      • valueOf

        public static PrimitiveScalar valueOf​(java.lang.Comparable<?> number)
      • compareTo

        public int compareTo​(java.lang.Double reference)
        Specified by:
        compareTo in interface java.lang.Comparable<java.lang.Double>
      • conjugate

        public PrimitiveScalar conjugate()
        Description copied from interface: VectorSpace

        This 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:
        conjugate in interface VectorSpace<Scalar<java.lang.Double>,​java.lang.Double>
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • get

        public java.lang.Double get()
        Specified by:
        get in interface AccessScalar<java.lang.Double>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isAbsolute

        public boolean isAbsolute()
        Specified by:
        isAbsolute in interface Scalar<java.lang.Double>
        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:
        Scalar.isAbsolute()
      • isSmall

        public boolean isSmall​(double comparedTo)
        Specified by:
        isSmall in interface NormedVectorSpace<Scalar<java.lang.Double>,​java.lang.Double>
        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: Scalar
        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).

        Specified by:
        isZero in interface Scalar<java.lang.Double>
        Returns:
        true if this scalar represents exactly zero, false otherwise
        See Also:
        NormedVectorSpace.isSmall(double)
      • norm

        public double norm()
        Description copied from interface: NormedVectorSpace
        this == this.signum().multiply(this.norm())
        Specified by:
        norm in interface NormedVectorSpace<Scalar<java.lang.Double>,​java.lang.Double>
        Returns:
        The norm
      • toBigDecimal

        public java.math.BigDecimal toBigDecimal()
        Specified by:
        toBigDecimal in interface Scalar<java.lang.Double>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public java.lang.String toString​(NumberContext context)
        Specified by:
        toString in interface Scalar<java.lang.Double>