Represents a linear solution characterized by a single value. Implements the Algebraic trait where the base is equal to the value, the offset is Value.zero, and the factor is PureNumber. CONSIDER we should not have to deal with offset, factor, negative attributes here.
Value parameters
- value
-
the base value of the solution
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Algebraictrait Solutiontrait Eagertrait DyadicOpstrait Approximatetrait Valuabletrait TypeSafetrait Normalizable[Valuable]trait Exactitudetrait Unitarytrait Zeroabletrait Numerictrait Renderableclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Multiplies this Algebraic by another Algebraic and returns the result.
Multiplies this Algebraic by another Algebraic and returns the result.
Value parameters
- other
-
the other
Algebraicto be multiplied with this
Attributes
- Returns
-
a new
Algebraicresulting from the multiplication
Multiplies this LinearSolution with another Solution instance. Supports multiplication only with another LinearSolution. Throws an exception if the provided Solution type is not supported or if the operation fails.
Multiplies this LinearSolution with another Solution instance. Supports multiplication only with another LinearSolution. Throws an exception if the provided Solution type is not supported or if the operation fails.
Value parameters
- other
-
the Solution instance to multiply with
Attributes
- Returns
-
a new Solution resulting from the multiplication
Scales the given rational value using the current value to produce an optional solution.
Scales the given rational value using the current value to produce an optional solution.
Value parameters
- r
-
the rational value used as a multiplier during scaling
Attributes
- Returns
-
an optional
Algebraicas the result of scaling, orNoneif the operation is not valid - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the operation is not valid for the given
Solution
Adds the specified Solution to the current LinearSolution and returns a new Solution representing the result of the addition. The operation is only supported for instances of LinearSolution. If the addition is unsupported for the given Solution, an exception may be thrown.
Adds the specified Solution to the current LinearSolution and returns a new Solution representing the result of the addition. The operation is only supported for instances of LinearSolution. If the addition is unsupported for the given Solution, an exception may be thrown.
Value parameters
- other
-
the
Solutionto add to the currentLinearSolution
Attributes
- Returns
-
the resulting
Solutionof the addition if supported - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the operation is not valid for the given
Solution
Adds the specified solution to the current solution and returns a new solution that represents the result of the addition.
Adds the specified solution to the current solution and returns a new solution that represents the result of the addition.
TODO implement me
Value parameters
- addend
-
the Eager to be added to the current solution
Attributes
- Returns
-
an optional solution representing the sum of the current solution and the given solution, or None if the operation is not valid
- Definition Classes
Adds a Rational value to the current solution and returns a new Algebraic as the result.
Adds a Rational value to the current solution and returns a new Algebraic as the result.
Value parameters
- addend
-
the
Rationalvalue to be added to the current solution
Attributes
- Returns
-
a new
Algebraicinstance representing the sum of the current solution and the givenaddend
Attempts to compute an approximate representation of the current value.
Attempts to compute an approximate representation of the current value.
This method provides an optional approximation of the value represented by the implementing class. The approximation may account for uncertainties or computational limitations. By default, this method does not force computation of the approximation unless explicitly requested.
Value parameters
- force
-
a boolean flag indicating whether to force computation of the approximation. If
true, the method will attempt to generate an approximation even if such computation is resource-intensive or not strictly necessary.
Attributes
- Returns
-
an
Optioncontaining the approximate value as aRealif available, orNoneif no approximation can be computed.
Retrieves the base value of the solution.
Retrieves the base value of the solution.
Attributes
- Returns
-
the base value of type Value
Returns the number of branches in this.
Returns the number of branches in this.
Attributes
- Returns
-
Determines if the offset is negative. A negative value may not be expressible with just Value and Factor, for example, if factor is SquareRoot.
Determines if the offset is negative. A negative value may not be expressible with just Value and Factor, for example, if factor is SquareRoot.
Attributes
- Returns
-
true if the offset is negative, false otherwise
Computes and returns the conjugate of the current Solution instance.
Computes and returns the conjugate of the current Solution instance.
The conjugate represents a value or transformation that is mathematically paired oppositely with the current instance based on the structure and properties of the Solution implementation.
Normally, the coefficient of the conjugate, added to the current coefficient should equal branches.
Attributes
- Returns
-
a new
Solutioninstance representing the conjugate of the current instance
Determines if the current instance of LinearSolution is equivalent to another Eager instance. The equivalence check is specific to the type of the Eager instance.
Determines if the current instance of LinearSolution is equivalent to another Eager instance. The equivalence check is specific to the type of the Eager instance.
Value parameters
- that
-
the
Eagerinstance to compare for equivalence
Attributes
- Returns
-
a
Try[Boolean]indicating the result of the equivalence check -Success(true)if the instances are considered equivalent -Success(false)if the instances are not equivalent -Failureif the operation is not supported or if an error occurs during the comparison - Definition Classes
Determines whether the solution is a pure number. A pure number is defined as one without any associated factors or offsets.
Determines whether the solution is a pure number. A pure number is defined as one without any associated factors or offsets.
Attributes
- Returns
-
true if the solution is a pure number, false otherwise
Determines whether the solution represents unity.
Determines whether the solution represents unity.
Attributes
- Returns
-
true if the solution represents unity, false otherwise
- Definition Classes
Determines whether the solution is zero.
Determines whether the solution is zero.
Attributes
- Returns
-
true if the solution is zero, false otherwise.
Retrieves the offset value of the solution.
Retrieves the offset value of the solution.
Attributes
- Returns
-
the offset value of type Value
Scales the current Solution instance by a given Rational factor. CONSIDER this could be merged with the method whose name is the asterisk.
Scales the current Solution instance by a given Rational factor. CONSIDER this could be merged with the method whose name is the asterisk.
The scaling operation adjusts the Solution based on the value of the provided Rational parameter, resulting in a new Solution instance that reflects the modification.
Value parameters
- r
-
the
Rationalvalue by which to scale the currentSolution
Attributes
- Returns
-
a new
Solutioninstance representing the result of the scaling operation - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the scaling operation is not supported for the current
Solutionimplementation.
Determines the sign of the solution.
Determines the sign of the solution.
Attributes
- Returns
-
an integer representing the sign of the solution: 0 if the solution is zero, a positive value if the solution is positive, or a negative value if the solution is negative.
If this Solution can be represented as a Structure, return it wrapped in Some, otherwise return None.
If this Solution can be represented as a Structure, return it wrapped in Some, otherwise return None.
Attributes
- Returns
-
an
Option[Structure].
Inherited methods
Multiplies the current instance by the specified integer factor.
Multiplies the current instance by the specified integer factor.
Value parameters
- factor
-
the integer value to multiply with the current instance
Attributes
- Returns
-
a new instance of type
Trepresenting the result of the multiplication - Inherited from:
- Scalable
Computes an approximate representation of the current value.
Computes an approximate representation of the current value.
This method utilizes the approximation mechanism to derive the most likely value in the form of a Real. Should the approximation fail, an AlgebraException will be raised to indicate the error.
Attributes
- Returns
-
the approximate value as a
Realif successful; throws anAlgebraExceptionotherwise. - Inherited from:
- Approximate
Attempts to compute an approximate complex representation of the current value.
Attempts to compute an approximate complex representation of the current value.
This method provides an optional approximation in the form of an Eager type. By default, it does not perform the computation unless explicitly requested through the force flag. The method may return None if no approximation can be computed or if the operation fails.
Value parameters
- force
-
a boolean flag indicating whether to force computation of the approximation. If
true, the method will attempt to perform a complex approximation even if it is resource-intensive or otherwise unwarranted.
Attributes
- Returns
-
an
Optioncontaining the approximate value as anEagerif successful, orNoneif no approximation is available. - Inherited from:
- Approximate
Returns the category of this value in the Valuable type hierarchy.
Returns the category of this value in the Valuable type hierarchy.
Attributes
- Returns
-
a string indicating the high-level category (e.g., "Expression", "Structure", "Nat", "Complex")
- Inherited from:
- TypeSafe
Compares two instances of Eager and determines their relative ordering. This method is not yet implemented and will raise an com.phasmidsoftware.number.algebra.util.AlgebraException if called.
Compares two instances of Eager and determines their relative ordering. This method is not yet implemented and will raise an com.phasmidsoftware.number.algebra.util.AlgebraException if called.
Value parameters
- x
-
the first
Eagerinstance to compare - y
-
the second
Eagerinstance to compare
Attributes
- Returns
-
a
Try[Int]that contains the comparison result: -0ifxandyare equal, - a negative result ifxis less thany, - and a positive result ifxis greater thany. As the method is unimplemented, it will always return a failure with anAlgebraException. - Inherited from:
- Eager
Returns a descriptive string combining category and type name. Useful for debugging to understand both the hierarchy level and concrete type.
Returns a descriptive string combining category and type name. Useful for debugging to understand both the hierarchy level and concrete type.
Attributes
- Returns
-
a string in the format "Category.TypeName" (e.g., "Structure.WholeNumber")
- Inherited from:
- TypeSafe
Performs division of the current Eager instance by another Eager instance. This operation is implemented using the DyadicOperator mechanism, delegating the actual division logic to the divideEagers function.
Performs division of the current Eager instance by another Eager instance. This operation is implemented using the DyadicOperator mechanism, delegating the actual division logic to the divideEagers function.
Value parameters
- y
-
the
Eagerinstance to divide the current instance by
Attributes
- Returns
-
a
Try[Eager]containing the result of the division if successful, or a failure if the operation cannot be performed - Inherited from:
- Eager
Attempts to convert the current object to an instance of Eager using an approximation method. If the conversion fails, it recovers by throwing an AlgebraException with a descriptive error message.
Attempts to convert the current object to an instance of Eager using an approximation method. If the conversion fails, it recovers by throwing an AlgebraException with a descriptive error message.
Attributes
- Returns
-
An instance of
Eagerif the approximation is successful. - Inherited from:
- Eager
Performs a fuzzy comparison between two Eager instances. The comparison is based on a specified tolerance and determines their relative ordering. If the comparison cannot be performed, an AlgebraException is returned as a failure.
Performs a fuzzy comparison between two Eager instances. The comparison is based on a specified tolerance and determines their relative ordering. If the comparison cannot be performed, an AlgebraException is returned as a failure.
Value parameters
- p
-
the tolerance (as a
Double) to be used for the comparison - x
-
the first
Eagerinstance to be compared - y
-
the second
Eagerinstance to be compared
Attributes
- Returns
-
a
Try[Int]representing the result of the comparison: - A negative integer ifxis less thany- Zero ifxis approximately equal toywithin the tolerancep- A positive integer ifxis greater thany- AFailure(AlgebraException)if the comparison cannot be performed - Inherited from:
- Eager
Performs a fuzzy equivalence comparison between the current solution and another solution. The comparison allows for a degree of tolerance specified by the parameter p.
Performs a fuzzy equivalence comparison between the current solution and another solution. The comparison allows for a degree of tolerance specified by the parameter p.
Value parameters
- confidence
-
the tolerance level for the fuzzy equivalence comparison; smaller values impose stricter equality conditions
- that
-
the other solution to compare against, which must be of type
Eager
Attributes
- Returns
-
a
Try[Boolean]indicating whether the two solutions are approximately equivalent within the specified tolerance, or an error if the comparison cannot be performed - Definition Classes
- Inherited from:
- Algebraic
Method to determine if this NumberLike object is exact. For instance, Number.pi is exact, although if you converted it into a PureNumber, it would no longer be exact.
Method to determine if this NumberLike object is exact. For instance, Number.pi is exact, although if you converted it into a PureNumber, it would no longer be exact.
Attributes
- Returns
-
true if this NumberLike object is exact in the context of No factor, else false.
- Inherited from:
- Algebraic
If this Valuable is exact, it returns the exact value as a Double. Otherwise, it returns None. NOTE: do NOT implement this method to return a Double for a fuzzy Real--only for exact numbers.
If this Valuable is exact, it returns the exact value as a Double. Otherwise, it returns None. NOTE: do NOT implement this method to return a Double for a fuzzy Real--only for exact numbers.
Attributes
- Returns
-
Some(x) where x is a Double if this is exact, else None.
- Inherited from:
- Eager
Determines the factor associated with this solution based on certain conditions. If the solution is a pure number, it returns Some(PureNumber). If the base value of the solution is zero, it returns Some(factor). Otherwise, it returns None.
Determines the factor associated with this solution based on certain conditions. If the solution is a pure number, it returns Some(PureNumber). If the base value of the solution is zero, it returns Some(factor). Otherwise, it returns None.
CONSIDER invoke normalize and then apply maybeFactor to the result.
Attributes
- Returns
-
an
Optionof typeFactor, whereSomemay contain the factor depending on the conditions, orNoneif no factor is applicable - Inherited from:
- Algebraic
Multiplies the current Eager instance with another Eager instance. The multiplication operation is carried out using the DyadicOperator mechanism, which delegates to the multiplyEagers function for specific behavior. This ensures proper handling of various subtypes of Eager.
Multiplies the current Eager instance with another Eager instance. The multiplication operation is carried out using the DyadicOperator mechanism, which delegates to the multiplyEagers function for specific behavior. This ensures proper handling of various subtypes of Eager.
Value parameters
- y
-
the
Eagerinstance to multiply with thisEagerinstance
Attributes
- Returns
-
a
Try[Eager]containing the result of the multiplication if successful, or a failure if the operation cannot be performed - Inherited from:
- Eager
Obtains the product of this Valuable instance and another Valuable instance. The behavior of the method is determined by whether the instances are of type Lazy or Eager. If the provided instances do not conform to the expected types, an AlgebraException is thrown. CONSIDER supporting sum also.
Obtains the product of this Valuable instance and another Valuable instance. The behavior of the method is determined by whether the instances are of type Lazy or Eager. If the provided instances do not conform to the expected types, an AlgebraException is thrown. CONSIDER supporting sum also.
CONSIDER using lazify
Value parameters
- other
-
the other
Valuableinstance to compute the product with
Attributes
- Returns
-
a
Valuableinstance representing the product of this and the other instance - Note
-
throws AlgebraException if the computation involves unsupported
Valuabletypes - Inherited from:
- Valuable
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
Renders and returns a string representation of the object. By default, this is the same as render but it can be overridden in subclasses.
Renders and returns a string representation of the object. By default, this is the same as render but it can be overridden in subclasses.
Attributes
- Returns
-
a string representing the object
- Inherited from:
- Valuable
Subtracts the given Eager instance y from the current Eager instance. This operation is performed using the DyadicOperator mechanism, which delegates to the subtractEagers function to handle the specific subtraction behavior.
Subtracts the given Eager instance y from the current Eager instance. This operation is performed using the DyadicOperator mechanism, which delegates to the subtractEagers function to handle the specific subtraction behavior.
Value parameters
- y
-
the
Eagerinstance to be subtracted from thisEagerinstance
Attributes
- Returns
-
a
Try[Eager]containing the result of the subtraction if successful, or a failure if the operation fails - Inherited from:
- Eager
Returns a simple string representation of the runtime type. Useful for debugging and logging.
Returns a simple string representation of the runtime type. Useful for debugging and logging.
Attributes
- Returns
-
the simple class name (e.g., "WholeNumber", "RationalNumber")
- Inherited from:
- TypeSafe
Concrete fields
Retrieves an optional name associated with this instance.
Retrieves an optional name associated with this instance.
Attributes
- Returns
-
an
Option[String]containing the name if present, otherwiseNone
Negates the current instance of the solution by inverting its base and offset values.
Negates the current instance of the solution by inverting its base and offset values.
Attributes
- Returns
-
a new instance of
QuadraticSolutionrepresenting the negated version of the current solution
Normalizes the current instance of LinearSolution to its simplest equivalent form. The normalization process reduces the representation while maintaining the same value.
Normalizes the current instance of LinearSolution to its simplest equivalent form. The normalization process reduces the representation while maintaining the same value.
This may simplify complex expressions or adjust the type to a more precise representation.
Attributes
- Returns
-
the simplest
Valuablerepresentation of this value.
Renders the solution as a string representation. It attempts to use a rational representation of the value if available; otherwise, it falls back to the default string representation of the solution.
Renders the solution as a string representation. It attempts to use a rational representation of the value if available; otherwise, it falls back to the default string representation of the solution.
Attributes
- Returns
-
a string representation of the solution
Inherited fields
Casts this Valuable instance into a Structure type if it already is a Structure. If the instance is not a Structure, an AlgebraException is thrown. CONSIDER returning Option[Structure] instead.
Casts this Valuable instance into a Structure type if it already is a Structure. If the instance is not a Structure, an AlgebraException is thrown. CONSIDER returning Option[Structure] instead.
Attributes
- Returns
-
the current instance as a
Structure - Note
-
Throws com.phasmidsoftware.number.algebra.util.AlgebraException if the instance is not of type
Structure - Inherited from:
- Valuable
Attempts to cast this instance to a Number. If the instance is of type Number, it is wrapped in an Option and returned. Otherwise, returns None.
Attempts to cast this instance to a Number. If the instance is of type Number, it is wrapped in an Option and returned. Otherwise, returns None.
Attributes
- Returns
-
an
Optioncontaining the instance as aNumberif applicable, orNoneif not. - Inherited from:
- Valuable
Converts the current Lazy instance into an Eager instance by forcing the resolution or evaluation of its underlying value.
Converts the current Lazy instance into an Eager instance by forcing the resolution or evaluation of its underlying value.
The materialize method ensures that the computation of the value represented by this Lazy instance is completed and encapsulated within an appropriate Eager representation. This is particularly useful in scenarios where deferred computation needs to be explicitly resolved prior to further processing.
Attributes
- Returns
-
the materialized
Eagerinstance representing the resolved value - Inherited from:
- Eager
Converts the approximate representation of this number into a Double.
Converts the approximate representation of this number into a Double.
This method attempts to approximate the value of this number by invoking the approximation method with force = true. If the approximation exists, it is converted to a Double. If no approximation can be obtained, an AlgebraException is thrown to indicate a logic error.
Attributes
- Returns
-
the approximate value as a
Double. - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if no approximation can be obtained.
- Inherited from:
- Approximate