Eager

com.phasmidsoftware.number.algebra.eager.Eager
See theEager companion trait
object Eager

The Eager object provides factory methods to create instances of Valuable entities that are evaluated eagerly. These entities can represent numerical values parsed from strings, long integers, or specific types of mathematical fields.

Attributes

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

Members list

Type members

Classlikes

implicit class IntToImaginary(x: Int)

Provides an implicit conversion from an Int to an imaginary number representation.

Provides an implicit conversion from an Int to an imaginary number representation.

This class allows integers to be interpreted as imaginary numbers by appending .i to an integer. The imaginary number is constructed using the square of the integer negated, combined with the square root notation.

Value parameters

x

the integer to be converted into an imaginary number

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(str: String): Eager

Parses the given string into a Valuable representation. If the string cannot be parsed into a valid Number, an exception is thrown.

Parses the given string into a Valuable representation. If the string cannot be parsed into a valid Number, an exception is thrown.

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

Value parameters

str

the input string representing a numerical value.

Attributes

Returns

a Valuable representation of the parsed Number.

Note

Throws CoreExceptionWithCause if parsing the string fails.

def apply(x: Double): Eager

Creates an Eager instance representing the given double value.

Creates an Eager instance representing the given double value.

Value parameters

x

the input value of type Double to be wrapped in an Eager representation.

Attributes

Returns

an Eager instance corresponding to the input value.

def apply(x: Long): Eager

Creates a Valuable instance representing the given long value.

Creates a Valuable instance representing the given long value.

Value parameters

x

the input value of type Long to be wrapped in a Valuable representation.

Attributes

Returns

a Valuable object corresponding to the input value.

def apply(field: Field): Eager

Creates a Valuable instance based on the given Field. If the Field is a Real object, it converts it into a Scalar representation. Otherwise, it throws an IllegalArgumentException.

Creates a Valuable instance based on the given Field. If the Field is a Real object, it converts it into a Scalar representation. Otherwise, it throws an IllegalArgumentException.

Value parameters

field

the input field to be converted into a Valuable. It is expected to be of type com.phasmidsoftware.number.core.Real.

Attributes

Returns

a Valuable representation of the input Field as a Scalar.

Note

Throws com.phasmidsoftware.number.algebra.util.AlgebraException if the provided Field is not of type Real.

def eagerToField(eager: Eager): Field

Converts an Eager instance into a Field representation. If the conversion fails, it recovers by throwing a AlgebraException with an appropriate error message indicating the failure.

Converts an Eager instance into a Field representation. If the conversion fails, it recovers by throwing a AlgebraException with an appropriate error message indicating the failure.

CONSIDER making this an instance method of Eager.

Value parameters

eager

the Eager instance to be converted into a Field. This is expected to represent a numerical value.

Attributes

Returns

the Field representation of the input Valuable.

Note

Throws com.phasmidsoftware.number.algebra.util.AlgebraException If conversion is not possible.

Computes the imaginary representation of the given number by squaring it, negating the result, and attempting to convert it into a valid imaginary number. It cannot be used for negative imaginary numbers or any multiple of i𝛑.

Computes the imaginary representation of the given number by squaring it, negating the result, and attempting to convert it into a valid imaginary number. It cannot be used for negative imaginary numbers or any multiple of i𝛑.

The purpose of this method is to provide a convenient way to construct a simple imaginary number.

Value parameters

x

the input value of type Number to be transformed into an imaginary representation. It is expected to be a valid numerical value.

Attributes

Returns

an Eager instance representing the imaginary conversion of the input number.

Throws
AlgebraException

if the conversion fails or the resulting value cannot be represented as an imaginary number.

Concrete fields

lazy val e: Eager

A lazily initialized constant e in an Eager representation.

A lazily initialized constant e in an Eager representation.

The value of e is imported from the NaturalExponential object, which defines the mathematical constant e (approximately 2.71828...) to arbitrary precision.

As a lazy value, the computation or retrieval of e is deferred until it is accessed for the first time.

Attributes

lazy val half: Number

A lazily initialized constant one-half, wrapped as a RationalNumber instance constructed from Rational.half.

A lazily initialized constant one-half, wrapped as a RationalNumber instance constructed from Rational.half.

This value is of type Eager and is calculated lazily, meaning it is initialized only when accessed. The half constant provides a convenient representation of the fractional value 1/2 in the Eager context.

Attributes

lazy val i: InversePower

Represents the imaginary unit i as an Eager instance.

Represents the imaginary unit i as an Eager instance.

This specific value corresponds to the mathematical constant √(-1), which is represented internally as the result of applying the InversePower constructor with a base of 2 and an exponent of -1.

The value is lazily initialized, meaning it is computed only when accessed.

Attributes

lazy val iPi: Eager

Exact value of iPi.

Exact value of iPi.

Attributes

lazy val infinity: Eager

A lazily initialized constant for infinity: an Eager instance that encapsulates a RationalNumber with an infinite value.

A lazily initialized constant for infinity: an Eager instance that encapsulates a RationalNumber with an infinite value.

This property is provided as a convenient representation of positive infinity in the context of Eager computations. It utilizes the Rational.infinity to initialize the encapsulated value.

Attributes

lazy val minusOne: Eager

A lazily initialized constant -1 as a lazily evaluated Eager instance.

A lazily initialized constant -1 as a lazily evaluated Eager instance.

This value is initialized by accessing a pre-defined minusOne instance from the Number class and is shared across all uses of the containing class.

The value is immutable and can be used wherever an Eager representation of the constant -1 is required.

Attributes

lazy val negInfinity: Eager

Represents the mathematical concept of negative infinity as an Eager instance.

Represents the mathematical concept of negative infinity as an Eager instance.

This value is constructed using the Rational.negInfinity, which signifies negative infinity in the rational number system, wrapped within the RationalNumber representation.

It can be used in computations where negative infinity needs to be explicitly modeled.

Attributes

lazy val negPiBy2: Eager

Represents an eagerly evaluated lazy value corresponding to the negative half of π (-π/2).

Represents an eagerly evaluated lazy value corresponding to the negative half of π (-π/2).

This value is initialized using the Angle.negPiBy2 constant from the Angle object, conveniently making it available within the Eager type system.

Attributes

lazy val one: Eager

A lazily initialized constant value one within the Eager class. This value corresponds to the numerical representation of one.

A lazily initialized constant value one within the Eager class. This value corresponds to the numerical representation of one.

Attributes

Returns

an Eager instance representing the value 1.

lazy val phi: Eager

Represents the golden ratio, commonly denoted as φ (phi), in the Eager context.

Represents the golden ratio, commonly denoted as φ (phi), in the Eager context.

The golden ratio is a mathematical constant approximately equal to 1.6180339887, and is defined as the positive solution to the quadratic equation x^2 - x - 1 = 0.

This lazy value retrieves its definition from the QuadraticSolution.phi.

Attributes

lazy val pi: Eager

A lazily initialized constant π (pi) as an Eager instance.

A lazily initialized constant π (pi) as an Eager instance.

This value is precomputed and corresponds to the mathematical constant π, providing precise representation through the Eager type.

Attributes

lazy val piBy2: Eager

A lazily initialized constant π/2 (pi divided by 2), expressed as an instance of Eager. This value corresponds to half of the constant π, which is commonly used in trigonometry and other mathematical computations involving angles.

A lazily initialized constant π/2 (pi divided by 2), expressed as an instance of Eager. This value corresponds to half of the constant π, which is commonly used in trigonometry and other mathematical computations involving angles.

Attributes

lazy val piBy4: Eager

A lazily initialized constant π/4 (pi divided by 4) as an instance of the Eager type.

A lazily initialized constant π/4 (pi divided by 4) as an instance of the Eager type.

This value is predefined and corresponds to a quarter of π, commonly used in trigonometric calculations and other mathematical contexts.

It is lazily initialized using the Angle.piBy4 definition and provides an efficient representation of this angle.

Attributes

Returns

A constant Eager representation of π/4.

lazy val psi: Eager

A lazily initialized constant of type Eager representing one of the roots of the quadratic equation. The value is initialized based on the definition provided by QuadraticSolution.psi.

A lazily initialized constant of type Eager representing one of the roots of the quadratic equation. The value is initialized based on the definition provided by QuadraticSolution.psi.

This property is part of the Eager class, which represents mathematical expressions and constants.

The lazy initialization ensures that the computation is deferred until the first access, optimizing resource usage and preventing unnecessary calculations during object instantiation.

Attributes

lazy val root2: Eager

Represents the square root of 2 (√2) as an instance of Eager.

Represents the square root of 2 (√2) as an instance of Eager.

root2 is lazily initialized as an InversePower instance with a numerator of 2 and a denominator of 2. It includes an optional descriptive label "√2".

The Eager type supports numerical representations and operations, enabling mathematical expressions and computations involving this constant.

Attributes

lazy val root3: Eager

Represents the square root of 3 as a lazy initialization of an Eager type.

Represents the square root of 3 as a lazy initialization of an Eager type.

Internally implemented as an InversePower instance with base 2 and exponent 3, providing an efficient representation of √3. Optionally tagged with a string descriptor "√3" for identification.

Attributes

lazy val rootHalf: Eager

Represents the square root of 1/2, lazily initialized.

Represents the square root of 1/2, lazily initialized.

This value is an instance of Eager, constructed using the InversePower class with a base of 2 and an exponent of Eager.half. It models the mathematical constant √½ and is labeled with its LaTeX representation for display purposes.

The creation of this value demonstrates the use of lazy initialization to defer computation until it is first accessed.

Attributes

lazy val ten: Eager

A lazily initialized constant value of 10 within the Eager context.

A lazily initialized constant value of 10 within the Eager context.

This value is encapsulated as an instance of the Scalar type in the Eager framework. The ten lazy value is pre-computed and serves as a reusable numeric constant within operations or evaluations involving the Eager type.

The lazy evaluation ensures that the value is computed only when accessed, thus optimizing performance and memory usage in contexts where ten is unused.

Attributes

lazy val two: Eager

A lazily initialized constant value of 2 within the Eager type system.

A lazily initialized constant value of 2 within the Eager type system.

This value is instantiated as a Scalar(2), which is a specific subtype of Eager. It signifies the literal value 2 and can be used in computations or comparisons involving Eager instances.

Attributes

lazy val zero: Eager

A lazily initialized constant representing the number zero, encapsulated in an Eager object. This value is pre-defined and serves as the canonical representation of zero within the Eager type.

A lazily initialized constant representing the number zero, encapsulated in an Eager object. This value is pre-defined and serves as the canonical representation of zero within the Eager type.

Delegates its value to Number.zero, a predefined numerical constant.

Attributes

lazy val zeroAngle: Eager

Represents the zero value for an angle, lazily evaluated.

Represents the zero value for an angle, lazily evaluated.

This lazy value provides an Eager instance corresponding to the Angle.zero constant. It is part of the predefined constants within the Eager type for convenient mathematical operations.

Attributes

Givens

Givens

Provides an implementation of the DyadicOperator trait for the Eager type, enabling dyadic operations to be performed on Eager operands or their subtypes.

Provides an implementation of the DyadicOperator trait for the Eager type, enabling dyadic operations to be performed on Eager operands or their subtypes.

The implementation supports both same-type and cross-type operations. It delegates processing to specialized DyadicOperator instances where applicable, or falls back to a more generic operation using the given function f.

NOTE currently, this is not used because the Eq and FuzzyEq instances go directly to the instance methods of Eager.

Attributes

Returns

An instance of DyadicOperator[Eager] that defines the behavior for performing dyadic operations on Eager values.

given given_Eq_Eager: Eq[Eager]

Provides an instance of Eq for the Eager type, which defines equality comparison behavior for Eager values. The comparison is performed using the eqv method of Eager. If the eqv method returns Some(true), the values are considered equal. Otherwise, they are considered not equal, defaulting to false if no result is specified.

Provides an instance of Eq for the Eager type, which defines equality comparison behavior for Eager values. The comparison is performed using the eqv method of Eager. If the eqv method returns Some(true), the values are considered equal. Otherwise, they are considered not equal, defaulting to false if no result is specified.

Attributes

Returns

An instance of Eq[Eager] for equality comparison.

Provides an instance of the FuzzyEq type class for the Eager type.

Provides an instance of the FuzzyEq type class for the Eager type.

This implementation determines whether two Eager instances are approximately equal based on one of the following conditions:

  1. The two instances are strictly equal (===).
  2. They are approximately equal according to the fuzzy equality comparison defined by the fuzzyEqv method of the Eager type, using the specified probability p.

Attributes

Returns

An instance of FuzzyEq[Eager] that evaluates fuzzy equality between two Eager values.

Implicits

Implicits

final implicit def IntToImaginary(x: Int): IntToImaginary

Provides an implicit conversion from an Int to an imaginary number representation.

Provides an implicit conversion from an Int to an imaginary number representation.

This class allows integers to be interpreted as imaginary numbers by appending .i to an integer. The imaginary number is constructed using the square of the integer negated, combined with the square root notation.

Value parameters

x

the integer to be converted into an imaginary number

Attributes

implicit def convIntEager(x: Int): Eager

Implicitly converts an integer value into an Eager representation. This conversion wraps the integer as a WholeNumber within the Eager type.

Implicitly converts an integer value into an Eager representation. This conversion wraps the integer as a WholeNumber within the Eager type.

Value parameters

x

the integer value to be converted into an Eager instance.

Attributes

Returns

an Eager instance representing the input integer as a WholeNumber.

implicit def convRationalEager(x: Rational): Eager

Implicitly converts a Rational value into an Eager representation. This conversion wraps the Rational as a RationalNumber within the Eager type.

Implicitly converts a Rational value into an Eager representation. This conversion wraps the Rational as a RationalNumber within the Eager type.

Value parameters

x

the Rational value to be converted into an Eager instance.

Attributes

Returns

an Eager instance representing the input Rational as a RationalNumber.

LatexRenderer for Eager (general case).

LatexRenderer for Eager (general case).

Attempts to render based on the concrete type.

Attributes