Real

com.phasmidsoftware.number.algebra.eager.Real
See theReal companion class
object Real

Represents a fuzzy number, combining a numeric value with a level of fuzziness.

A fuzzy number encapsulates imprecision or uncertainty alongside its value, and supports arithmetic operations and algebraic structure integration. Fuzzy numbers are useful in computational scenarios involving uncertainty, approximate calculations, or tolerances. This object provides factory methods, constants, and implicit type class instances for working with fuzzy numbers.

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Real.type

Members list

Type members

Classlikes

object Infinity extends Real

Represents an immutable instance of positive infinity as a Real.

Represents an immutable instance of positive infinity as a Real.

Infinity is a predefined object within the Real class hierarchy that symbolizes the mathematical concept of positive infinity. It is constructed using Double.PositiveInfinity as the underlying representation and does not associate any fuzziness with its value.

This object can be used in computations requiring an explicit representation of positive infinity.

Attributes

See also
Supertypes
class Real
trait Serializable
trait Product
trait Equals
trait MaybeFuzzy
trait CanPower[Number]
trait Scalable[Real]
trait CanNegate[Real]
trait CanAdd[Real, Real]
trait Can[Real]
trait R
trait Number
trait Ordered[Scalar]
trait Comparable[Scalar]
trait Scalar
trait Structure
trait Eager
trait DyadicOps
trait Approximate
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
Infinity.type

A given instance of the Convertible typeclass for transforming an instance of type Angle into a Real using a conversion operation.

A given instance of the Convertible typeclass for transforming an instance of type Angle into a Real using a conversion operation.

This implementation creates a new Real by extracting the numerical value from the Angle instance and wrapping it within the Real type.

Value parameters

u

the source Angle instance to be converted into a Real

witness

an instance of type Real, representing additional context for the conversion

Attributes

Returns

a new Real instance containing the numerical value derived from the input Angle

Supertypes
class Object
trait Matchable
class Any
Self type

Provides a given instance of the Convertible typeclass to enable conversion from an instance of RationalNumber to an instance of Real.

Provides a given instance of the Convertible typeclass to enable conversion from an instance of RationalNumber to an instance of Real.

This given instance defines a concrete implementation of the convert method that transforms a RationalNumber into a Real by utilizing the toDouble method of the RationalNumber class. The convert method takes a Real witness object (serving as a prototype for the conversion) and a RationalNumber to be converted.

The resulting Real is constructed using the numeric value of the RationalNumber (converted to a Double) and the default fuzziness of the Real.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Given instance of Convertible for converting a value of type Real into another value of type Real.

Given instance of Convertible for converting a value of type Real into another value of type Real.

This implementation of Convertible performs an identity operation, where the given input value is returned as-is without any modifications.

Type parameters

Real

the target and source type for conversion

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

A given instance of the Convertible typeclass that provides a conversion from WholeNumber to Real.

A given instance of the Convertible typeclass that provides a conversion from WholeNumber to Real.

The conversion is performed by taking the WholeNumber value, converting it to a Double, and then constructing a Real instance using the converted value.

This implementation assumes that the Real type represents a numerical value with support for double-precision, and the WholeNumber type represents an integer-like structure.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object realIsRing extends Ring[Real], Ordering[Real]

Provides an implicit implementation of the Ring typeclass for the Real type.

Provides an implicit implementation of the Ring typeclass for the Real type.

This object supports arithmetic operations (addition, multiplication, and negation) and the retrieval of constants (zero and one) for the Real type, thus conforming to the requirements of the Ring algebraic structure.

CONSIDER extending Semiring instead (Claude feels that it would be appropriate for fuzzy numbers), but I don't have a problem with the additive (or multiplicative) inverse.

Attributes

Supertypes
trait Ordering[Real]
trait PartialOrdering[Real]
trait Equiv[Real]
trait Comparator[Real]
trait Ring[Real]
trait Rng[Real]
trait AdditiveCommutativeGroup[Real]
trait AdditiveGroup[Real]
trait Rig[Real]
trait MultiplicativeMonoid[Real]
trait Semiring[Real]
trait MultiplicativeSemigroup[Real]
trait AdditiveCommutativeMonoid[Real]
trait AdditiveCommutativeSemigroup[Real]
trait AdditiveMonoid[Real]
trait AdditiveSemigroup[Real]
trait Serializable
class Object
trait Matchable
class Any
Show all
Self type
realIsRing.type

Value members

Concrete methods

def apply(value: Long): Real

Constructs a Real instance using the given long value and no fuzziness.

Constructs a Real instance using the given long value and no fuzziness.

This method converts the specified long value to a double and delegates to the corresponding method apply(value: Double, fuzziness: Option[Fuzziness[Double]]) to construct the Real instance.

Value parameters

value

the long value to be associated with the Real

Attributes

Returns

a Real instance initialized with the given value (converted to double) and default fuzziness

def apply(value: Double): Real

Constructs a Real with the given numeric value and a default fuzziness level.

Constructs a Real with the given numeric value and a default fuzziness level.

This method creates a Real instance using the provided value and a default level of fuzziness based on double-precision.

Value parameters

value

the numeric value to be associated with the Real

Attributes

Returns

a Real instance initialized with the specified value and default fuzziness

def apply(value: Double, fuzz: Double): Real

Constructs a Real instance using the provided value and absolute fuzziness.

Constructs a Real instance using the provided value and absolute fuzziness.

This method creates a Real object with the specified numeric value and an absolute fuzziness level that adjusts the precision of computations involving this instance.

Value parameters

fuzz

the absolute fuzziness level to be applied to the Real

value

the numeric value to be associated with the Real

Attributes

Returns

a Real instance initialized with the specified value and fuzziness

def apply(x: Real): Real

Constructs a Real instance using the numerical value and optional fuzziness of a given numericalReal instance.

Constructs a Real instance using the numerical value and optional fuzziness of a given numericalReal instance.

This method extracts a double-precision value and an optional fuzziness level from the input numericalReal, and creates a new Real instance initialized with those parameters.

Value parameters

x

the input numericalReal instance, providing the value and optional fuzziness for the new Real

Attributes

Returns

a Real instance initialized with the value and fuzziness derived from the input numericalReal

def apply(x: Double, fuzz: Option[Fuzziness[Double]]): Real

Constructs a Real instance with a specified numeric value and optional fuzziness.

Constructs a Real instance with a specified numeric value and optional fuzziness.

This method creates a Real object using the

Attributes

def apply(w: String): Real

Parses a string representation of a number and constructs a Real instance. If the input string cannot be parsed into a valid number, a AlgebraException is thrown.

Parses a string representation of a number and constructs a Real instance. If the input string cannot be parsed into a valid number, a AlgebraException is thrown.

NOTE this deprecation is OK--there is no alternative NumberParser

Value parameters

w

the input string to be parsed and converted into a Real instance

Attributes

Returns

a Real instance constructed from the parsed numeric value of the input string

Constructs a new Real instance based on the values of an existing Real.

Constructs a new Real instance based on the values of an existing Real.

This method takes a Real instance as an input and creates a new Real with the same numerical value but potentially adjusted fuzziness.

Value parameters

real

the input Real used to initialize the new Real instance

Attributes

Returns

a Real instance initialized with the value of the input Real

Concrete fields

val infinity: Real

Represents a mathematical concept of positive infinity as a Real value.

Represents a mathematical concept of positive infinity as a Real value.

The symbol ∞ is predefined as a Real instance, initialized to Double.PositiveInfinity with no associated fuzziness. It serves to denote a value that is unbounded in the positive direction within the context of real numbers.

Attributes

val one: Real

Returns a Real representing the value one with double precision fuzziness.

Returns a Real representing the value one with double precision fuzziness.

Attributes

Returns

a Real instance initialized with the numeric value 1 and a default level of fuzziness.

val pi: Real

Returns a Real representing the mathematical constant π (pi) with a default level of fuzziness.

Returns a Real representing the mathematical constant π (pi) with a default level of fuzziness.

Attributes

Returns

a Real initialized with the value of π and the default fuzziness level

val zero: Real

Creates a Real instance with a value of 0 and a default fuzziness level.

Creates a Real instance with a value of 0 and a default fuzziness level.

Attributes

Returns

a Real representing the value zero with default fuzziness

val ∞: Real

Represents the mathematical concept of infinity within the Real class.

Represents the mathematical concept of infinity within the Real class.

This value is an alias for the predefined infinity constant in the Real class, which signifies a positive infinite quantity. It is typically used in calculations or scenarios where an infinitely large value is required or represented.

Attributes

val 𝛾: Real

Represents the Euler-Mascheroni constant, denoted as 𝛾.

Represents the Euler-Mascheroni constant, denoted as 𝛾.

This value is instantiated as a Real and corresponds to the mathematical constant that characterizes the difference between the harmonic series and the natural logarithm. It is widely used in various branches of mathematics including number theory, analysis, and special functions.

Attributes

Givens

Givens

A given instance of the Convertible typeclass for transforming an instance of type Angle into a Real using a conversion operation.

A given instance of the Convertible typeclass for transforming an instance of type Angle into a Real using a conversion operation.

This implementation creates a new Real by extracting the numerical value from the Angle instance and wrapping it within the Real type.

Value parameters

u

the source Angle instance to be converted into a Real

witness

an instance of type Real, representing additional context for the conversion

Attributes

Returns

a new Real instance containing the numerical value derived from the input Angle

Provides a given instance of the Convertible typeclass to enable conversion from an instance of RationalNumber to an instance of Real.

Provides a given instance of the Convertible typeclass to enable conversion from an instance of RationalNumber to an instance of Real.

This given instance defines a concrete implementation of the convert method that transforms a RationalNumber into a Real by utilizing the toDouble method of the RationalNumber class. The convert method takes a Real witness object (serving as a prototype for the conversion) and a RationalNumber to be converted.

The resulting Real is constructed using the numeric value of the RationalNumber (converted to a Double) and the default fuzziness of the Real.

Attributes

Given instance of Convertible for converting a value of type Real into another value of type Real.

Given instance of Convertible for converting a value of type Real into another value of type Real.

This implementation of Convertible performs an identity operation, where the given input value is returned as-is without any modifications.

Type parameters

Real

the target and source type for conversion

Attributes

A given instance of the Convertible typeclass that provides a conversion from WholeNumber to Real.

A given instance of the Convertible typeclass that provides a conversion from WholeNumber to Real.

The conversion is performed by taking the WholeNumber value, converting it to a Double, and then constructing a Real instance using the converted value.

This implementation assumes that the Real type represents a numerical value with support for double-precision, and the WholeNumber type represents an integer-like structure.

Attributes

Implicit implementation of the DyadicOperator trait for the Real type. This operator allows performing dyadic operations on instances of Real and its subtypes using a provided function f that specifies the operation.

Implicit implementation of the DyadicOperator trait for the Real type. This operator allows performing dyadic operations on instances of Real and its subtypes using a provided function f that specifies the operation.

Attributes

Returns

A DyadicOperator[Real] that applies the given operation f to two operands of Real and its subtypes, encapsulating the result in a Try.

given given_Eq_Real: Eq[Real]

Provides an instance of Eq for the Real type, enabling equality comparison between Real instances.

Provides an instance of Eq for the Real type, enabling equality comparison between Real instances.

This instance defines the equality operation for Real values by using their eqv method, which checks for equivalence. If the equivalence check returns None, it defaults to false.

Attributes

Returns

an instance of Eq[Real] for comparing Real instances

Defines a given instance of the FuzzyEq type class for the Real type.

Defines a given instance of the FuzzyEq type class for the Real type.

This instance provides a fuzzy equality implementation for Real numbers. Two Real instances are considered fuzzily equal if they are strictly equal or if their fuzzy equality (with respect to a specified probability p) evaluates to true.

Attributes

Returns

A FuzzyEq[Real] instance enabling fuzzy equality comparisons for Real.

Implicits

Implicits

implicit val showFuzzyNumber: Show[Real]

Provides an implicit instance of Show for the Real type.

Provides an implicit instance of Show for the Real type.

This implementation defines how instances of Real are converted to a human-readable string representation by invoking their render method.

It enables seamless integration with type classes requiring a Show instance, allowing Real objects to be printed or logged in a human-readable format.

Attributes