com.phasmidsoftware.number.core.inner

Members list

Type members

Classlikes

case object AnyContext extends CoreContext

The AnyContext object represents a special Context that qualifies all factors without exception.

The AnyContext object represents a special Context that qualifies all factors without exception.

This context essentially overrides all filtering or conditional logic by always returning true for any given factor. It is useful as a catch-all context where no restrictions are applied.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait CoreContext
class Object
trait Matchable
class Any
Show all
Self type
AnyContext.type
case class AnyRoot(inversePower: Rational) extends InversePower

This object represents a general inverse power factor.

This object represents a general inverse power factor.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait InversePower
trait Factor
class Object
trait Matchable
class Any
Show all
trait BoundaryBehavior[X]

Typeclass that defines boundary behavior for a type when normalizing to a range. This captures the intrinsic properties of how a type handles range boundaries.

Typeclass that defines boundary behavior for a type when normalizing to a range. This captures the intrinsic properties of how a type handles range boundaries.

Type parameters

X

the numeric type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case object Composite extends Factor

The Composite object represents a composite factor which cannot be reduced to a unique factor. It is used essentially as a placeholder for Eager values such as Algebraics.

The Composite object represents a composite factor which cannot be reduced to a unique factor. It is used essentially as a placeholder for Eager values such as Algebraics.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Composite.type
trait CoreContext

Represents a trait for specifying in which evaluation-contexts a particular expression may be evaluated.

Represents a trait for specifying in which evaluation-contexts a particular expression may be evaluated.

The Context trait provides an abstraction for determining whether a particular factor or field qualifies within the scope of a specific context. It supports logical operations (or, and, not) to compose complex contexts from simpler ones.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CoreContext

Companion object for the Context class.

Companion object for the Context class.

Provides predefined contexts for evaluating and qualifying factors or fields under specific mathematical or functional conditions. This includes contexts for scalars, logarithms, and roots, along with utility functions for determining qualification.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case object CubeRoot extends NthRoot

This object represents the cube root factor.

This object represents the cube root factor.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class NthRoot
trait InversePower
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
CubeRoot.type
case object Degree extends Scalar

Case object representing the Degree unit, which is a scalar factor for angle measurements. It provides functionality to convert, manipulate, and perform mathematical operations associated with the degree unit.

Case object representing the Degree unit, which is a scalar factor for angle measurements. It provides functionality to convert, manipulate, and perform mathematical operations associated with the degree unit.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Scalar
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Degree.type
sealed trait DyadicOperation extends Operation

Trait to define a dyadic operation.

Trait to define a dyadic operation.

Attributes

Supertypes
trait Operation
class Object
trait Matchable
class Any
Known subtypes
case object DyadicOperationPlus extends DyadicOperation

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type

Represents a dyadic operation that performs power computations.

Represents a dyadic operation that performs power computations.

This operation supports the power function for various numerical types including integers, rational numbers, and double-precision floating-point numbers.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type

Represents the dyadic multiplication operation, where the operation is performed for various numeric types (Int, Rational, Double) using predefined functions.

Represents the dyadic multiplication operation, where the operation is performed for various numeric types (Int, Rational, Double) using predefined functions.

This object provides the implementation of the multiplication operation specific to each numeric type, with safeguards to handle exceptions and ensure safety through Try.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type
case object Euler extends Logarithmic

This factor allows the representation of quantities of the form e power ix.

This factor allows the representation of quantities of the form e power ix.

NOTE: A number in factor Euler will evaluate as e raised to (i times that power). So, the value is the natural log of the evaluation.

We call this Euler because it is used in Euler's formula https://en.wikipedia.org/wiki/Euler's_formula. However, let the record state that Roger Cotes, an English mathematician, used this quantity before Euler https://en.wikipedia.org/wiki/Euler's_formula#History.

Thus the range of such values is subject to the same modulation as Radian.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Logarithmic
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Euler.type
sealed trait Factor

Represents a factor type used for evaluations, conversions, and rendering in a specific context.

Represents a factor type used for evaluations, conversions, and rendering in a specific context.

CONSIDER defining an imaginary (or Complex) subclass of Factor. CONSIDER renaming this trait as Domain.

This trait serves as a foundation for different kinds of factors and provides functionality such as:

  • Determining whether the factor is additive.
  • Checking if the factor meets certain conditions within a specific context.
  • Performing conversions of values between compatible factors.
  • Rendering values in the context of the factor.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Composite
trait InversePower
class AnyRoot
class NthRoot
object CubeRoot
object SquareRoot
trait Logarithmic
object Euler
object Log10
object Log2
object NatLog
trait Scalar
object Degree
object Percent
object PureNumber
object Radian
Show all
object Factor

An object that provides a mechanism to map input strings to specific factors such as Radian, NatLog, or PureNumber. It acts as a factory for creating instances of the Factor sealed trait.

An object that provides a mechanism to map input strings to specific factors such as Radian, NatLog, or PureNumber. It acts as a factory for creating instances of the Factor sealed trait.

The object includes predefined constants representing symbols or keywords associated with certain factors. These constants include mathematical symbols like 'ℯ' and 'π', as well as their textual alternatives.

The apply method takes a string input and matches it to one of the predefined constants to return an appropriate Factor instance.

Matching logic:

  • Strings representing π (like "π", "pi", "Radian", "PI") will return the Radian factor.
  • The symbol 'ℯ' will return the NatLog factor.
  • All other strings default to the PureNumber factor.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Factor.type
case object ImpossibleContext extends CoreContext

A Context that rejects all Factor instances without exception.

A Context that rejects all Factor instances without exception.

ImpossibleContext is a specific instance of the Context trait that always returns false for any factor, indicating that no factor qualifies within this context.

This context acts as the logical negation of all other possible contexts, prohibiting any factor from being considered qualifying.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait CoreContext
class Object
trait Matchable
class Any
Show all
Self type
object IntRational

An object providing an extractor method for converting a Rational number into a pair of integers representing its numerator and denominator.

An object providing an extractor method for converting a Rational number into a pair of integers representing its numerator and denominator.

The IntRational object simplifies working with Rational numbers when you need to decompose them into integers for further processing or pattern matching.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Inverse

Provides functionality to determine if a given Rational represents the inverse of an integer. This object serves as an extractor for such instances of Rational.

Provides functionality to determine if a given Rational represents the inverse of an integer. This object serves as an extractor for such instances of Rational.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Inverse.type
sealed trait InversePower extends Factor

A sealed trait extending the Factor trait, representing a mathematical root-based factorization.

A sealed trait extending the Factor trait, representing a mathematical root-based factorization.

This trait provides mechanisms to convert values associated with one root-based factor to another, when such conversions are mathematically possible.

Attributes

Companion
object
Supertypes
trait Factor
class Object
trait Matchable
class Any
Known subtypes
class AnyRoot
class NthRoot
object CubeRoot
object SquareRoot
object InversePower

Companion object for the NthRoot trait, providing utility methods for working with NthRoot instances.

Companion object for the NthRoot trait, providing utility methods for working with NthRoot instances.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case object Log10 extends Logarithmic

Represents the logarithm with base 10.

Represents the logarithm with base 10.

This object extends the Logarithmic trait and provides functionality for representing and rendering logarithms of base 10.

Attributes

Constructor

Creates an instance of Log10.

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Logarithmic
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Log10.type
case object Log2 extends Logarithmic

Object representing the logarithm to base 2.

Object representing the logarithm to base 2.

This object extends the Logarithmic trait and provides specific functionality for dealing with logarithms to the base 2. It defines the base as "2" and computes the logarithmic value (math.log(2)).

Methods include:

  • toString: Returns "log2" as the string representation.
  • render(x: Value): Converts the input value to a string representation based on the power notation specific to the base 2.

Attributes

See also

Logarithmic

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Logarithmic
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Log2.type
sealed trait Logarithmic extends Factor

Trait to define a Factor which indicates that the true value of a Number with this Factor is the base raised to the power of the (nominal) Value.

Trait to define a Factor which indicates that the true value of a Number with this Factor is the base raised to the power of the (nominal) Value.

Attributes

Companion
object
Supertypes
trait Factor
class Object
trait Matchable
class Any
Known subtypes
object Euler
object Log10
object Log2
object NatLog
object Logarithmic

Companion object for the Logarithmic class.

Companion object for the Logarithmic class.

This object provides utilities associated with the Logarithmic class, including operations for pattern matching and internal functionality for string manipulation.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
trait Modulo[X]

Typeclass for types that support modular arithmetic. This provides operations needed to normalize values into a range using modulo.

Typeclass for types that support modular arithmetic. This provides operations needed to normalize values into a range using modulo.

Type parameters

X

the numeric type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Modulo

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Modulo.type
sealed trait MonadicOperation extends Operation

Definitions of MonadicOperations. This module relates primarily to operations on Value.

Definitions of MonadicOperations. This module relates primarily to operations on Value.

Attributes

Supertypes
trait Operation
class Object
trait Matchable
class Any
Known subtypes
case class MonadicOperationAtan(xSign: Int, ySign: Int) extends MonadicOperation

MonadicOperation to yield the arctangent of a Number.

MonadicOperation to yield the arctangent of a Number.

Value parameters

sign

an Int which will distinguish between results in the four quadrants.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all

MonadicOperation to raise e (Euler's number) to the power of a Number.

MonadicOperation to raise e (Euler's number) to the power of a Number.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type
case class MonadicOperationFunc(f: Double => Double, dfByDx: Double => Double) extends MonadicOperation

MonadicOperation to apply a generic function to a Number.

MonadicOperation to apply a generic function to a Number.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all

MonadicOperation to invert a Number.

MonadicOperation to invert a Number.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type

MonadicOperation to yield the natural logarithm of a Number. CONSIDER Renaming as MonadicOperationLn

MonadicOperation to yield the natural logarithm of a Number. CONSIDER Renaming as MonadicOperationLn

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type
case class MonadicOperationModulate(min: Int, max: Int, inclusive: Boolean, angularBoundaryBehavior: Boolean) extends MonadicOperation

This class represents a monadic operation that modulates a numeric input into a specified range using modular arithmetic. It allows defining a flexible boundary behavior, which can either model standard numeric ranges or angular (circular) ranges, with the ability to make the range inclusive.

This class represents a monadic operation that modulates a numeric input into a specified range using modular arithmetic. It allows defining a flexible boundary behavior, which can either model standard numeric ranges or angular (circular) ranges, with the ability to make the range inclusive.

Value parameters

angularBoundaryBehavior

when true, treats the boundary as circular (e.g., for angles), otherwise treats it as standard numeric behavior

inclusive

if true, both min and max are valid; if false, max is excluded, unless boundaryBehavior specifies otherwise.

max

the upper bound of the modulation range

min

the lower bound of the modulation range

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all

MonadicOperation to negate a Number.

MonadicOperation to negate a Number.

NOTE: not valid on NatLog-scaled values.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type

This monadic operation is used to scale a Value by a Rational. CONSIDER eliminating this unused operation.

This monadic operation is used to scale a Value by a Rational. CONSIDER eliminating this unused operation.

Value parameters

r

the scale factor (a Rational).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all

MonadicOperation to calculate the sine of a Number. The number is a factor of pi, i.e. it is in radians.

MonadicOperation to calculate the sine of a Number. The number is a factor of pi, i.e. it is in radians.

NOTE that this evaluator for sine is not as useful as the evaluator in the Number class. That's because this type of operation does not change the factor.

CONSIDER allow Monadic operations to change factor.

See https://en.wikipedia.org/wiki/List_of_trigonometric_identities

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type

MonadicOperation to yield the square root of a Number.

MonadicOperation to yield the square root of a Number.

CONSIDER eliminating this and using power only.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Operation
class Object
trait Matchable
class Any
Show all
Self type
case object NatLog extends Logarithmic

This factor essentially provides log/exponent arithmetic.

This factor essentially provides log/exponent arithmetic.

NOTE: A number in factor NatLog will evaluate as e raised to that power. So, the value is the natural log of the evaluation.

Thus the range of such values is any positive number.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Logarithmic
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
NatLog.type
abstract class NthRoot(val n: Int) extends InversePower

Represents an abstract base class for mathematical root operations by extending InversePower.

Represents an abstract base class for mathematical root operations by extending InversePower.

A number with value x and factor InversePower(n) represents the nth root of x where n is a Rational. For example, ExactNumber(5, SquareRoot) is the square root of 5, where SquareRoot is an alias for NthRoot(2).

The NthRoot class encapsulates the concept of a mathematical nth root and provides methods to retrieve the degree of the root. It is intended to be extended by concrete implementations that define specific behaviors for inverse power computation.

Value parameters

n

the integer value representing the nth root degree.

Attributes

Constructor

Creates a new instance of the NthRoot class with the specified root degree.

Companion
object
Supertypes
trait InversePower
trait Factor
class Object
trait Matchable
class Any
Known subtypes
object CubeRoot
object SquareRoot
object NthRoot

Represents the companion object for the NthRoot class.

Represents the companion object for the NthRoot class.

Provides utility functionality related to NthRoot, including methods for matching and extracting values from instances of the NthRoot type.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
NthRoot.type
sealed trait Operation

Represents an operation in a system. This trait serves as a base for different types of operations that can be implemented. Being sealed, all implementations must be defined in the same file, ensuring exhaustive pattern matching.

Represents an operation in a system. This trait serves as a base for different types of operations that can be implemented. Being sealed, all implementations must be defined in the same file, ensuring exhaustive pattern matching.

Use this trait to model behaviors or actions that can be carried out, ensuring type safety and enabling pattern matching on specific operations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Operations

Object providing operations to evaluate dyadic and monadic functions on values, as well as query transformations.

Object providing operations to evaluate dyadic and monadic functions on values, as well as query transformations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Operations.type
case class OperationsException(msg: String) extends Exception

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
case object Percent extends Scalar

The Percent object represents the percentage scalar. It serves as a factor for scaling values, interpreting them as percentages.

The Percent object represents the percentage scalar. It serves as a factor for scaling values, interpreting them as percentages.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Scalar
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Percent.type
case object PureNumber extends Scalar

A case object representing the pure number 1. PureNumber extends the Scalar trait and behaves as a unit scalar factor.

A case object representing the pure number 1. PureNumber extends the Scalar trait and behaves as a unit scalar factor.

CONSIDER expanding to include a DecimalNumber as well as a PureNumber (which logically should be represented in binary). Just because we can represent something exactly in binary doesn't mean we can represent it in decimal (and vice versa).

This object encapsulates the value of 1, providing a representation of a pure scalar. It includes functionality to render a string representation of a value.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Scalar
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
PureNumber.type
trait QueryFunctions[T]

Trait for the query functions: three functions, corresponding to the functions for Int, Rational and Double representations.

Trait for the query functions: three functions, corresponding to the functions for Int, Rational and Double representations.

Attributes

Supertypes
class Object
trait Matchable
class Any
sealed trait QueryOperation[T]

Definitions of QueryOperations.

Definitions of QueryOperations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case object QueryOperationIsInfinite extends QueryOperation[Boolean]

A query operation that determines whether a given value is infinite. This object extends QueryOperation[Boolean] and provides a set of query functions, implemented in BooleanQueryFunctions, to handle Int, Rational, and Double input types.

A query operation that determines whether a given value is infinite. This object extends QueryOperation[Boolean] and provides a set of query functions, implemented in BooleanQueryFunctions, to handle Int, Rational, and Double input types.

Specifically:

  • For Int inputs, this operation always returns false since integers cannot be infinite.
  • For Rational inputs, it checks whether the rational number represents infinity.
  • For Double inputs, it checks for positive or negative infinity.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait QueryOperation[Boolean]
class Object
trait Matchable
class Any
Show all
Self type
case object QueryOperationIsZero extends QueryOperation[Boolean]

QueryOperationIsZero is a specific implementation of the QueryOperation trait for operations that check whether a given numeric value is equal to zero.

QueryOperationIsZero is a specific implementation of the QueryOperation trait for operations that check whether a given numeric value is equal to zero.

This case object provides functions for Int, Rational, and Double inputs, determining if the numeric value is zero. The results of these functions are encapsulated in a Try to capture potential exceptions during the operation.

The behavior of the functions is defined as follows:

  • For Int, it checks if the value is equal to 0.
  • For Rational, it checks if the signum of the value is 0.
  • For Double, it checks if the sign is 0 or -0, accounting for floating-point representation.

This implementation ensures consistent behavior across different numeric types while providing failure handling through the Try wrapper.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait QueryOperation[Boolean]
class Object
trait Matchable
class Any
Show all
Self type
case object QueryOperationSignum extends QueryOperation[Int]

QueryOperationSignum is a concrete implementation of QueryOperation for integer results. It provides functionality to compute the signum of a numeric value (positive, negative, or zero) for various numeric types: Int, Rational, and Double.

QueryOperationSignum is a concrete implementation of QueryOperation for integer results. It provides functionality to compute the signum of a numeric value (positive, negative, or zero) for various numeric types: Int, Rational, and Double.

The class defines a set of query functions encapsulated in an IntQueryFunctions instance. These functions leverage the math.signum operation for Int and Double, and the .signum method for Rational, with error handling provided through Try.

Specifically:

  • For Int inputs, it uses math.signum directly.
  • For Rational inputs, it computes the signum using the signum method of Rational.
  • For Double inputs, it uses math.signum and converts the result to an integer.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait QueryOperation[Int]
class Object
trait Matchable
class Any
Show all
Self type
case object Radian extends Scalar

This factor is primarily used for rotation by an angle.

This factor is primarily used for rotation by an angle.

A number x with factor Radian (theoretically) evaluates to e raised to the power ix. So, you could think of it as essentially a shorthand for writing both cosine and sine. NOTE however that, unlike, with the factor NatLog, we currently do not treat Radian values in quite this way in the code.

CONSIDER implementing the Radian factor conversions in a manner similar to that of NatLog. This would entail conversion from a single number to a pair of Doubles when going from Radian to PureNumber. We could do that using a Complex number but I'd rather do it as a 2-tuple of Doubles. Perhaps the whole idea of our Complex implementation is misguided (although it does allow us to represent complex numbers in Polar form since, in that case, the real part is a PureNumber number, and the imaginary part is coded in with factor Radian).

The range of these values is 0 thru 2, which represents the radian values of 0 thru 2pi.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Scalar
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
Radian.type
object Rational

Companion object to Rational. Represents a Rational number, with various methods for conversion, approximation, and utility. Provides a rich set of operations and utilities to handle rational numbers, convert data types, and manage normalization. Rational numbers are represented as fractions with BigInt numerator and denominator.

Companion object to Rational. Represents a Rational number, with various methods for conversion, approximation, and utility. Provides a rich set of operations and utilities to handle rational numbers, convert data types, and manage normalization. Rational numbers are represented as fractions with BigInt numerator and denominator.

Fields:

  • bigZero: Commonly used representation for Rational zero.
  • bigOne: Commonly used representation for Rational one.
  • bigTwo: Commonly used representation for Rational two.
  • bigThree: Commonly used representation for Rational three.
  • bigFour: Commonly used representation for Rational four.
  • bigFive: Commonly used representation for Rational five.
  • bigSeven: Commonly used representation for Rational seven.
  • bigNegOne: Commonly used representation for Rational negative one.
  • bigTen: Commonly used representation for Rational ten.
  • zero: Rational representation for zero.
  • infinity: Positive infinity in Rational form.
  • negInfinity: Negative infinity in Rational form.
  • one: Rational representation for one.
  • ten: Rational representation for ten.
  • two: Rational representation for two.
  • half: Rational representation for one-half.
  • NaN: Represents "Not a Number" in Rational form.
  • negZero: Represents negative zero in Rational form.
  • negZeroDouble: Represents negative zero as a Double in Rational form.
  • pi_5000: Predefined Rational representation of π/5000.
  • squareRoots: A collection of predefined square root values in Rational form.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Rational.type
case class Rational extends NumberLike

Rational: a case class that represents rational numbers by a BigInt numerator and a BigInt denominator. The numerator (n) and the denominator (d) may not share a common factor: if you try to construct a Rational with new where there is a common factor, then an exception will be thrown. However, all the apply methods ensure valid Rational instances by factoring out any common factors. Similarly, the denominator may not be negative: again, the apply methods will take care of this situation. This is the reason that the constructor of Rational is marked package-private.

Rational: a case class that represents rational numbers by a BigInt numerator and a BigInt denominator. The numerator (n) and the denominator (d) may not share a common factor: if you try to construct a Rational with new where there is a common factor, then an exception will be thrown. However, all the apply methods ensure valid Rational instances by factoring out any common factors. Similarly, the denominator may not be negative: again, the apply methods will take care of this situation. This is the reason that the constructor of Rational is marked package-private.

The domain of Rational includes values with a zero value in the denominator and any numerator (either -ve or +ve infinity) as well as the value with 0 as both the numerator and denominator (NaN).

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait NumberLike
class Object
trait Matchable
class Any
Show all
case class RationalException(s: String) extends Exception

Exception class for Rationals.

Exception class for Rationals.

Value parameters

s

the cause as a String.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
object RationalFloor

Extension methods for Rational to support floor and ceiling operations.

Extension methods for Rational to support floor and ceiling operations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Render

The Render object provides functionality to render various value types as a formatted string, along with a flag indicating whether the value could be rendered exactly or approximately.

The Render object provides functionality to render various value types as a formatted string, along with a flag indicating whether the value could be rendered exactly or approximately.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Render.type
case class RestrictedContext(context: Factor) extends CoreContext

A case class that represents a restricted evaluation context for a specific Factor.

A case class that represents a restricted evaluation context for a specific Factor.

The RestrictedContext is a specialized Context implementation that confines its qualifications to a single Factor. It determines whether a given factor matches the specific factor (context) it was instantiated with. This ensures that only evaluations respecting this restricted context are allowed.

Value parameters

context

the specific factor that defines the restrictive context. Only factors matching this will qualify.

Attributes

Constructor

Creates a RestrictedContext with a predefined Factor to enforce context-based restrictions.

Supertypes
trait Serializable
trait Product
trait Equals
trait CoreContext
class Object
trait Matchable
class Any
Show all
sealed trait Scalar extends Factor

Trait to define a Factor which is a scalar (something that can be scaled by a pure number).

Trait to define a Factor which is a scalar (something that can be scaled by a pure number).

Attributes

Companion
object
Supertypes
trait Factor
class Object
trait Matchable
class Any
Known subtypes
object Degree
object Percent
object PureNumber
object Radian
object Scalar

Companion object for the Scalar trait, providing utility methods.

Companion object for the Scalar trait, providing utility methods.

The unapply method allows pattern matching on an instance of Scalar to extract its underlying Double value.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Scalar.type
case object SquareRoot extends NthRoot

This object represents the square root factor.

This object represents the square root factor.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class NthRoot
trait InversePower
trait Factor
class Object
trait Matchable
class Any
Show all
Self type
SquareRoot.type
object Tolerance

Companion object to Tolerance.

Companion object to Tolerance.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Tolerance.type
case class Tolerance(x: Double, maxDenom: BigInt)

Value class to define Tolerance.

Value class to define Tolerance.

Value parameters

maxDenom

used in the approximation of an irrational number -- whereby the denominator is limited to approximately this value.

x

the tolerance (epsilon) value.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Value

This object provides methods related to the type Value.

This object provides methods related to the type Value.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Value.type

The VulgarFraction object provides a mapping of common fractional values to their corresponding Unicode vulgar fraction characters. It also includes functionality to extract a Unicode representation of a vulgar fraction from a given Rational number.

The VulgarFraction object provides a mapping of common fractional values to their corresponding Unicode vulgar fraction characters. It also includes functionality to extract a Unicode representation of a vulgar fraction from a given Rational number.

This object uses a predefined Map of numerator and denominator pairs to their Unicode character equivalents.

The primary use case for this object is working with Rational numbers and converting them to their Unicode vulgar fraction representation when applicable.

Functionality:

  • Provides the mapping of common fractions to Unicode vulgar fraction characters.
  • Extracts a Unicode vulgar fraction character from a Rational number when possible.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Types

Type alias for the Boolean query functions.

Type alias for the Boolean query functions.

Attributes

type DyadicFunctions = ((Int, Int) => Try[Int], (Rational, Rational) => Try[Rational], (Double, Double) => Try[Double])

Type alias for the dyadic functions, a tuple of three functions, corresponding to the functions for Int, Rational and Double representations.

Type alias for the dyadic functions, a tuple of three functions, corresponding to the functions for Int, Rational and Double representations.

Attributes

Type alias for the Int query functions.

Type alias for the Int query functions.

Attributes

type MonadicFunctions = (Int => Try[Int], Rational => Try[Rational], Double => Try[Double])

Type alias for the monadic functions, a tuple of three functions, corresponding to the functions for Int, Rational and Double representations.

Type alias for the monadic functions, a tuple of three functions, corresponding to the functions for Int, Rational and Double representations.

Attributes

type ProtoNumber = (Value, Factor, Option[Fuzziness[Double]])

Represents an intermediate numerical form, consisting of:

Represents an intermediate numerical form, consisting of:

  • A Value, representing the numerical component.
  • A Factor, providing the contextual framework for interpretation (e.g., units, dimensions, basis of representation).
  • An optional Fuzziness[Double], describing any associated uncertainty or imprecision.

This type is used throughout various computations and transformations to encapsulate numeric quantities, their interpretive factors, and any associated tolerance or fuzziness.

Attributes

type Value = Either[Either[Option[Double], Rational], Int]

This is the type of the nominalValue parameter of a GeneralNumber. CONSIDER redefining this as a class rather than as a type alias.

This is the type of the nominalValue parameter of a GeneralNumber. CONSIDER redefining this as a class rather than as a type alias.

There is a companion object to this type in module Value.scala.

Attributes