The WholeNumber companion object contains utility methods, predefined constants, and typeclass instances for working with WholeNumbers. WholeNumbers are represented using rational numbers and comply with the algebraic structure of a commutative group.
Attributes
- Companion
- class
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
WholeNumber.type
Members list
Type members
Classlikes
Provides an implicit implementation of a commutative group for the WholeNumber type, supporting group operations such as identity, combination, and inversion.
Provides an implicit implementation of a commutative group for the WholeNumber type, supporting group operations such as identity, combination, and inversion.
This allows WholeNumber objects to adhere to the algebraic structure of a commutative group, where the combine operation is associative and commutative, an identity element exists, and each element has an additive inverse.
Attributes
- Companion
- trait
- Supertypes
-
trait CommutativeRing[WholeNumber]trait CommutativeRng[WholeNumber]trait CommutativeRig[WholeNumber]trait MultiplicativeCommutativeMonoid[WholeNumber]trait CommutativeSemiring[WholeNumber]trait MultiplicativeCommutativeSemigroup[WholeNumber]trait Ring[WholeNumber]trait Rng[WholeNumber]trait AdditiveCommutativeGroup[WholeNumber]trait AdditiveGroup[WholeNumber]trait Rig[WholeNumber]trait MultiplicativeMonoid[WholeNumber]trait Semiring[WholeNumber]trait MultiplicativeSemigroup[WholeNumber]trait AdditiveCommutativeMonoid[WholeNumber]trait AdditiveCommutativeSemigroup[WholeNumber]trait AdditiveMonoid[WholeNumber]trait AdditiveSemigroup[WholeNumber]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
Provides an implicit implementation of a commutative group for the WholeNumber type, supporting group operations such as identity, combination, and inversion.
Provides an implicit implementation of a commutative group for the WholeNumber type, supporting group operations such as identity, combination, and inversion.
This allows WholeNumber objects to adhere to the algebraic structure of a commutative group, where the combine operation is associative and commutative, an identity element exists, and each element has an additive inverse.
Attributes
- Companion
- object
- Supertypes
-
trait CommutativeRing[WholeNumber]trait CommutativeRng[WholeNumber]trait CommutativeRig[WholeNumber]trait MultiplicativeCommutativeMonoid[WholeNumber]trait CommutativeSemiring[WholeNumber]trait MultiplicativeCommutativeSemigroup[WholeNumber]trait Ring[WholeNumber]trait Rng[WholeNumber]trait AdditiveCommutativeGroup[WholeNumber]trait AdditiveGroup[WholeNumber]trait Rig[WholeNumber]trait MultiplicativeMonoid[WholeNumber]trait Semiring[WholeNumber]trait MultiplicativeSemigroup[WholeNumber]trait AdditiveCommutativeMonoid[WholeNumber]trait AdditiveCommutativeSemigroup[WholeNumber]trait AdditiveMonoid[WholeNumber]trait AdditiveSemigroup[WholeNumber]trait Serializableclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
object WholeNumberIsCommutativeRing
Represents a given instance of the Convertible typeclass to transform a Real into a WholeNumber, provided the Real value is exact and can be represented as a whole number.
Represents a given instance of the Convertible typeclass to transform a Real into a WholeNumber, provided the Real value is exact and can be represented as a whole number.
The implementation leverages FP.recover to handle failures gracefully and will throw an AlgebraException if the provided Real cannot be converted into a WholeNumber.
The conversion is only possible if the Real value satisfies the following conditions:
- It is marked as exact.
- Its numerical value can be expressed as an integer.
Attributes
- Returns
-
a
WholeNumberinstance representing the converted value. - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the input
Realcannot be converted to aWholeNumber. - Supertypes
- Self type
Provides a Convertible implementation for converting instances of WholeNumber to WholeNumber.
Provides a Convertible implementation for converting instances of WholeNumber to WholeNumber.
This implementation allows a WholeNumber instance to be converted to another WholeNumber without applying any transformation, effectively serving as an identity conversion.
Value parameters
- u
-
the source
WholeNumberto be converted - witness
-
a
WholeNumberinstance that serves as a template or context for the conversion
Attributes
- Returns
-
the same
WholeNumberinstance as passed inu - Note
-
This implementation adheres to the contract of the
Convertibletypeclass. - Supertypes
- Self type
Value members
Concrete methods
Constructs a new WholeNumber instance from a given BigInt value.
Constructs a new WholeNumber instance from a given BigInt value.
Value parameters
- name
-
an optional name associated with the
WholeNumberinstance; defaults toNoneif not provided - x
-
the
BigIntvalue to be wrapped as aWholeNumber
Attributes
- Returns
-
a new instance of
WholeNumbercreated using the providedBigIntvalue and optional name
Concrete fields
Represents the constant whole number value of -1.
Represents the constant whole number value of -1.
This is a lazily computed instance of the WholeNumber type, initialized with the value -1.
Attributes
Represents the whole number value 1 as an instance of WholeNumber.
Represents the whole number value 1 as an instance of WholeNumber.
This is a lazy value, ensuring that the object is not instantiated until it is accessed, and thereafter remains constant for the duration of the application's lifecycle.
Attributes
Represents the whole number two as a lazy value of type WholeNumber.
Represents the whole number two as a lazy value of type WholeNumber.
This is a predefined constant for convenient access to the numeric value 2 in the context of WholeNumber operations and conversions.
Attributes
Represents the WholeNumber constant for the value zero (0).
Represents the WholeNumber constant for the value zero (0).
This is a lazily evaluated instance of WholeNumber initialized with the value 0.
Attributes
Givens
Givens
Represents a given instance of the Convertible typeclass to transform a Real into a WholeNumber, provided the Real value is exact and can be represented as a whole number.
Represents a given instance of the Convertible typeclass to transform a Real into a WholeNumber, provided the Real value is exact and can be represented as a whole number.
The implementation leverages FP.recover to handle failures gracefully and will throw an AlgebraException if the provided Real cannot be converted into a WholeNumber.
The conversion is only possible if the Real value satisfies the following conditions:
- It is marked as exact.
- Its numerical value can be expressed as an integer.
Attributes
- Returns
-
a
WholeNumberinstance representing the converted value. - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the input
Realcannot be converted to aWholeNumber.
Provides a Convertible implementation for converting instances of WholeNumber to WholeNumber.
Provides a Convertible implementation for converting instances of WholeNumber to WholeNumber.
This implementation allows a WholeNumber instance to be converted to another WholeNumber without applying any transformation, effectively serving as an identity conversion.
Value parameters
- u
-
the source
WholeNumberto be converted - witness
-
a
WholeNumberinstance that serves as a template or context for the conversion
Attributes
- Returns
-
the same
WholeNumberinstance as passed inu - Note
-
This implementation adheres to the contract of the
Convertibletypeclass.
Provides an implementation of the DyadicOperator trait for the WholeNumber type.
Provides an implementation of the DyadicOperator trait for the WholeNumber type.
This given instance enables the application of binary operations on WholeNumber instances using a provided function f. The function encapsulates the operation logic and handles the operand types and potential failures via Try.
Attributes
- Returns
-
A
DyadicOperatorinstance for theWholeNumbertype, facilitating binary operations with safety provided byTry.
Provides an implementation of the Eq type class for the WholeNumber type.
Provides an implementation of the Eq type class for the WholeNumber type.
This given instance defines equality for WholeNumber values. It uses the eqv method defined on WholeNumber, falling back to false if the equality operation is not defined.
Attributes
- Returns
-
an
Eqinstance for comparingWholeNumbervalues for equality
Provides an instance of FuzzyEq for the WholeNumber type.
Provides an instance of FuzzyEq for the WholeNumber type.
This instance defines the fuzzy equality behavior for WholeNumber values, where two WholeNumber instances are considered equal if they are exactly the same, regardless of the probability p.
Attributes
- Returns
-
An instance of
FuzzyEqforWholeNumberthat implements strict equality.
Implicits
Implicits
Converts an Int to a WholeNumber implicitly.
Converts an Int to a WholeNumber implicitly.
This implicit conversion allows an Int to be seamlessly treated as a WholeNumber.
Value parameters
- x
-
the integer value to be converted to a
WholeNumber
Attributes
- Returns
-
the converted
WholeNumberinstance
Provides an implicit Show instance for the WholeNumber class, enabling conversion of an WholeNumber instance to a string representation using its render method.
Provides an implicit Show instance for the WholeNumber class, enabling conversion of an WholeNumber instance to a string representation using its render method.
This allows the WholeNumber class to integrate seamlessly with libraries or frameworks requiring a Show typeclass instance for displaying or logging purposes.