Module ojalgo

Interface Scalar<N extends java.lang.Comparable<N>>

    • Method Detail

      • booleanValue

        static boolean booleanValue​(java.lang.Comparable<?> number)
      • byteValue

        static byte byteValue​(java.lang.Comparable<?> number)
      • doubleValue

        static double doubleValue​(java.lang.Comparable<?> number)
      • floatValue

        static float floatValue​(java.lang.Comparable<?> number)
      • intValue

        static int intValue​(java.lang.Comparable<?> number)
      • longValue

        static long longValue​(java.lang.Comparable<?> number)
      • shortValue

        static short shortValue​(java.lang.Comparable<?> number)
      • add

        default Scalar<N> add​(Scalar<N> addend)
        Specified by:
        add in interface Operation.Addition<N extends java.lang.Comparable<N>>
        Parameters:
        addend - What to add
        Returns:
        this + addend
      • dimensions

        default int dimensions()
        Description copied from interface: Tensor
        The range of the indices that identify the scalar components. Each index of a tensor ranges over the number of dimensions.
        Specified by:
        dimensions in interface Tensor<N extends java.lang.Comparable<N>,​Scalar<N extends java.lang.Comparable<N>>>
      • divide

        default Scalar<N> divide​(Scalar<N> divisor)
        Specified by:
        divide in interface Operation.Division<N extends java.lang.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:
        isAbsolute()
      • 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:
        NormedVectorSpace.isSmall(double)
      • rank

        default int rank()
        Description copied from interface: Tensor
        The total number of indices required to uniquely identify each scalar component is called the order, degree or rank of the tensor.
        Specified by:
        rank in interface Tensor<N extends java.lang.Comparable<N>,​Scalar<N extends java.lang.Comparable<N>>>
      • subtract

        default Scalar<N> subtract​(Scalar<N> subtrahend)
        Specified by:
        subtract in interface Operation.Subtraction<N extends java.lang.Comparable<N>>
        Parameters:
        subtrahend - The subtrahend
        Returns:
        this - subtrahend.
      • toBigDecimal

        java.math.BigDecimal toBigDecimal()
      • toPlainString

        default java.lang.String toPlainString​(NumberContext context)