Factor

com.phasmidsoftware.number.core.inner.Factor
See theFactor companion object
sealed trait Factor

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
Graph
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

Members list

Value members

Abstract methods

def add(x: Value, y: Value, f: Factor, negative: Boolean = ...): Option[ProtoNumber]

Attempts to add two values together (each based on this Factor) and computes an appropriate factor for the result.

Attempts to add two values together (each based on this Factor) and computes an appropriate factor for the result.

Value parameters

f

the factor associated with y

negative

true if the y value has negative sense (this is relevant for some factors such as SquareRoot).

x

the first value

y

the addend

Attributes

Returns

an optional tuple containing the resultant value and its factor

def canMultiply(f: Factor): Boolean

Determines whether the current factor can be multiplied by the given factor. CONSIDER do we need this method now that we have multiply(x, y, this)?

Determines whether the current factor can be multiplied by the given factor. CONSIDER do we need this method now that we have multiply(x, y, this)?

Value parameters

f

the factor to be checked for compatibility with multiplication.

Attributes

Returns

true if the factors can be multiplied; false otherwise.

def canShow(value: Value): Boolean

Determines whether given value with this Factor can be rendered exactly.

Determines whether given value with this Factor can be rendered exactly.

Attributes

Returns

true if this Factor can be rendered exactly; false otherwise.

def convert(v: Value, f: Factor): Option[Value]

Convert a value x from this factor to f if possible, using the simplest possible mechanism. If the factors are incompatible, then None will be returned.

Convert a value x from this factor to f if possible, using the simplest possible mechanism. If the factors are incompatible, then None will be returned.

NOTE: only ScalarScalar, NthRootNthRoot or LogarithmicLogarithmic conversions can be effected.

Value parameters

f

the factor of the result.

v

the value to be converted.

Attributes

Returns

an optional Value which, given factor f, represents the same quantity as v given this.

Raises the value x to the power of the value y.

Raises the value x to the power of the value y.

Value parameters

x

the base value to be raised

y

the exponent value (from a PureNumber)

Attributes

Returns

an optional result of type ProtoNumber, representing the computed value if the operation is valid, or None otherwise

def invert(x: Value): Option[ProtoNumber]

Computes the multiplicative inverse of the given value if it exists.

Computes the multiplicative inverse of the given value if it exists.

Value parameters

x

the value to be inverted

Attributes

Returns

an optional ProtoNumber representing the inverse of x, or None if the inverse cannot be computed

def isA(context: CoreContext): Boolean

Determines if the current factor satisfies certain conditions within the given context.

Determines if the current factor satisfies certain conditions within the given context.

Value parameters

context

the context in which the factor is evaluated.

Attributes

Returns

a Boolean indicating whether the factor satisfies the specified conditions in the given context.

def isAdditive: Boolean

Determines if the current factor operates additively.

Determines if the current factor operates additively.

CONSIDER rewriting in terms of canAdd

Attributes

Returns

true if the factor is additive; false otherwise.

def isExact: Boolean

Determines whether the current scalar can be exactly converted to a PureNumber.

Determines whether the current scalar can be exactly converted to a PureNumber.

Attributes

Returns

true if the scalar represents an exact value; false otherwise.

def modulate(v: Value): Value

Modulates the given value according to the context or rules defined by this factor.

Modulates the given value according to the context or rules defined by this factor.

Value parameters

v

the value to be modulated

Attributes

Returns

the modulated value

def multiply(x: Value, y: Value, f: Factor): Option[ProtoNumber]

Multiplies two values together and computes an appropriate factor for the result.

Multiplies two values together and computes an appropriate factor for the result.

Value parameters

f

the factor associated with y

x

the first value

y

the multiplicand

Attributes

Returns

an optional tuple containing the resultant value and its factor

def negate(x: Value): Option[ProtoNumber]

Computes the negation of the given value x within the context of this factor.

Computes the negation of the given value x within the context of this factor.

Value parameters

x

the value to negate

Attributes

Returns

an optional ProtoNumber representing the negated value, or None if the operation is not valid

def render(v: String): String

Method to render a Value (which has already been converted to a String) in the context of this Factor.

Method to render a Value (which has already been converted to a String) in the context of this Factor.

Value parameters

v

a String representing the Value.

Attributes

Returns

a String.

Concrete methods

def canAdd(f: Factor): Boolean

Determines whether the current factor can be augmented by the given factor. CONSIDER do we need this method now that we have add(x, y, this)?

Determines whether the current factor can be augmented by the given factor. CONSIDER do we need this method now that we have add(x, y, this)?

Value parameters

f

the factor to be checked for compatibility with addition.

Attributes

Returns

true if the factors can be added; false otherwise.

def canRaise(f: Factor, exponent: Field): Boolean

Determines whether this factor can be raised by the given factor f. CONSIDER do we need this method now that we have raise(x, y, this)?

Determines whether this factor can be raised by the given factor f. CONSIDER do we need this method now that we have raise(x, y, this)?

Value parameters

f

the factor to be checked for compatibility with raising to a power.

Attributes

Returns

true if the factors can be powered; false otherwise.

def clean(po: Option[ProtoNumber]): Option[ProtoNumber]

Cleans a given optional ProtoNumber by potentially simplifying its root quantities based on specific conditions and returning the modified result.

Cleans a given optional ProtoNumber by potentially simplifying its root quantities based on specific conditions and returning the modified result.

Value parameters

po

an optional ProtoNumber that may be simplified

Attributes

Returns

an optional ProtoNumber, simplified if applicable, or None if input is None

def raise(x: Value, y: Value, f: Factor): Option[ProtoNumber]

Raises x to the power of y and compute an appropriate factor for the result. NOTE: for now, we only allow raising to a power of a PureNumber. TODO: enable powers of Radian factor.

Raises x to the power of y and compute an appropriate factor for the result. NOTE: for now, we only allow raising to a power of a PureNumber. TODO: enable powers of Radian factor.

Value parameters

f

the factor associated with y

x

the first value

y

the power

Attributes

Returns

an optional tuple containing the resultant value and its factor

def render(x: Value): String

Method to render a Value in the context of this Factor.

Method to render a Value in the context of this Factor.

Value parameters

x

the Value.

Attributes

Returns

a String.

Abstract fields

val value: Double

A value which can be used to convert a value associated with this Factor to a different Factor. CONSIDER redefining this as a Number (which could be exact or fuzzy).

A value which can be used to convert a value associated with this Factor to a different Factor. CONSIDER redefining this as a Number (which could be exact or fuzzy).

Attributes