Real

com.phasmidsoftware.number.core.numerical.Real
See theReal companion object
case class Real(x: Number) extends Field

Sub-class of Field: as opposed to Complex.

TODO remove (direct) Number references and replace with Real.

Value parameters

x

a Number which represents the value of this Real.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Field
trait Ordered[Field]
trait Comparable[Field]
trait Numerical
trait NumberLike
class Object
trait Matchable
class Any
Show all
Known subtypes
object NaN

Members list

Value members

Concrete methods

def add(y: Field): Field

Add y to this Real and return the result. See Number.plus for more detail.

Add y to this Real and return the result. See Number.plus for more detail.

Value parameters

y

the addend.

Attributes

Returns

the sum.

def atan(y: Real): Field

Calculate the angle whose opposite length is y and whose adjacent length is this.

Calculate the angle whose opposite length is y and whose adjacent length is this.

Value parameters

y

the opposite length

Attributes

Returns

the angle defined by x = this, y = y

def compare(that: Field): Int

Result of comparing this with operand that.

Result of comparing this with operand that.

Implement this method to determine how instances of A will be sorted.

Returns x where:

  • x < 0 when this < that

  • x == 0 when this == that

  • x > 0 when this > that

Value parameters

that

the instance to compare against

Attributes

Returns

an integer whose sign indicates the ordering relation between this and that

def divide(y: Field): Field

Divide this Real by y and return the result.

Divide this Real by y and return the result.

Value parameters

y

the divisor.

Attributes

Returns

the quotient.

override def equals(obj: Any): Boolean

Compares the current object with the specified object for equality.

Compares the current object with the specified object for equality.

CONSIDER eliminating this method as it is simply the default implementation.

Value parameters

obj

the object to compare with the current object

Attributes

Returns

true if the specified object is of type Real and its value matches the current object's value, false otherwise

Definition Classes
Equals -> Any
override def hashCode(): Int

Computes a hash code value for the object. This method is intended to provide a consistent hash code implementation based on the hashCode of the encapsulated value or component.

Computes a hash code value for the object. This method is intended to provide a consistent hash code implementation based on the hashCode of the encapsulated value or component.

Attributes

Returns

an integer hash code value for the object

Definition Classes
Any
def isProbablyZero(confidence: Double): Boolean

Determines if the current instance is approximately equal to zero with at least the specified confidence level.

Determines if the current instance is approximately equal to zero with at least the specified confidence level.

Value parameters

confidence

the confidence level, typically between 0 and 1. Ignored if the instance is definitively zero.

Attributes

Returns

true if the instance is considered approximately zero with the given confidence, false otherwise.

def isSame(f: Numerical, confidence: Double): Boolean

Method to determine if this Field is equivalent to another Field (x).

Method to determine if this Field is equivalent to another Field (x).

Value parameters

f

the other field.

Attributes

Returns

true if they are the same, otherwise false.

def multiply(y: Field): Field

Multiply this Real by y and return the result.

Multiply this Real by y and return the result.

  • @param y the multiplicand.
  • @return the product.

Attributes

def power(p: Number): Field

Raise this Real to the power p where p is a Number.

Raise this Real to the power p where p is a Number.

If the Number of this Real is exact and if the exponent p is rational, then we convert x to a ComplexPolar first and raise that to power p.

Value parameters

p

a Number.

Attributes

Returns

this Real raised to power p.

def power(p: Field): Field

Raise this Real to the power p.

Raise this Real to the power p.

If the Number of this Real is exact and if the exponent p is rational, then we convert x to a ComplexPolar first and raise that to power p.

Value parameters

p

a Field.

Attributes

Returns

this Real raised to power p.

def unary_-: Field

Change the sign of this Real.

Change the sign of this Real.

Attributes

Inherited methods

infix def *(x: Field): Field

Multiply this Field by the given Field and return the result.

Multiply this Field by the given Field and return the result.

Value parameters

x

the multiplicand, an instance of Field.

Attributes

Returns

the product of this Field and the given Field.

Inherited from:
Field
infix def +(x: Field): Field

Synonym for add.

Synonym for add.

Value parameters

x

the addend.

Attributes

Returns

the result.

Inherited from:
Field
infix def -(x: Field): Field

Synonym for subtract.

Synonym for subtract.

Value parameters

x

the subtrahend.

Attributes

Returns

this - x.

Inherited from:
Field
def <(that: Field): Boolean

Returns true if this is less than that

Returns true if this is less than that

Value parameters

that

the instance to compare against

Attributes

Inherited from:
Ordered
def <=(that: Field): Boolean

Returns true if this is less than or equal to that.

Returns true if this is less than or equal to that.

Attributes

Inherited from:
Ordered
def >(that: Field): Boolean

Returns true if this is greater than that.

Returns true if this is greater than that.

Value parameters

that

the instance to compare against

Attributes

Inherited from:
Ordered
def >=(that: Field): Boolean

Returns true if this is greater than or equal to that.

Returns true if this is greater than or equal to that.

Attributes

Inherited from:
Ordered
def approximation: Option[Real]

Computes an approximation of the field as a real number, if possible. This method attempts to map the underlying numerical representation to a real value.

Computes an approximation of the field as a real number, if possible. This method attempts to map the underlying numerical representation to a real value.

Attributes

Returns

an Option containing the Real representation of this field if it can be approximated, or None if the approximation is not possible.

Inherited from:
Field
def asJavaNumber: Option[Number]

Converts this NumberLike object into an optional java.lang.Number provided that the conversion can be performed without loss of precision.

Converts this NumberLike object into an optional java.lang.Number provided that the conversion can be performed without loss of precision.

The method determines whether the current NumberLike object can be represented as a java.lang.Number by leveraging the asNumber method and further evaluating certain conditions:

  • If the NumberLike object is an ExactNumber and its factor is PureNumber, the result is converted using Value.asJavaNumber.
  • If the NumberLike object is a FuzzyNumber with a wiggle value below a specified tolerance, the result is also converted using Value.asJavaNumber.
  • In all other cases, None is returned.

Attributes

Returns

an optional java.lang.Number representation of this object. The result is Some(java.lang.Number) if the conversion is successful under the stated conditions; otherwise, None.

Inherited from:
NumberLike
def compareTo(that: Field): Int

Result of comparing this with operand that.

Result of comparing this with operand that.

Value parameters

that

the instance to compare against

Attributes

Inherited from:
Ordered
def memberOf(set: NumberSet): Boolean

Method to determine if this NumberLike object is a member of the given set.

Method to determine if this NumberLike object is a member of the given set.

Value parameters

set

the candidate NumberSet.

Attributes

Returns

true if this is exact and belongs to set.

Inherited from:
NumberLike
def memberOf: Option[NumberSet]

Method to determine the NumberSet, if any, to which this NumberLike object belongs. NOTE that we don't yet support H, the quaternions.

Method to determine the NumberSet, if any, to which this NumberLike object belongs. NOTE that we don't yet support H, the quaternions.

Attributes

Returns

Some(numberSet) or None if it doesn't belong to any (for example, it is fuzzy).

Inherited from:
NumberLike
infix def power(p: Int): Field

Raise this Field to the power p.

Raise this Field to the power p.

Value parameters

p

an Int.

Attributes

Returns

this Field raised to power p.

Inherited from:
Field
def productElementNames: Iterator[String]

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
def productIterator: Iterator[Any]

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
infix def subtract(x: Field): Field

Subtract x from this Field and return the result.

Subtract x from this Field and return the result.

Value parameters

x

the subtrahend.

Attributes

Returns

the difference of this - x.

Inherited from:
Field
def toRational: Option[Rational]

Converts this Field instance to its equivalent rational representation if it is real-valued.

Converts this Field instance to its equivalent rational representation if it is real-valued.

Attributes

Returns

an Option containing the rational representation of this Field if it is real-valued; otherwise, None.

Inherited from:
Field

Concrete fields

lazy val abs: Real

Returns the absolute value of this Real.

Returns the absolute value of this Real.

Attributes

Returns

a Real representing the absolute value of this.

lazy val asComplex: Complex

Method to return this Real as a Complex. If this is a Real number x, return ComplexPolar(x) otherwise, return this.

Method to return this Real as a Complex. If this is a Real number x, return ComplexPolar(x) otherwise, return this.

Attributes

Returns

a Complex.

lazy val asNumber: Option[Number]

Method to return the x of this Real.

Method to return the x of this Real.

Attributes

Returns

Some(x).

lazy val asReal: Option[Real]

Method to return this Real as an Option[Real]..

Method to return this Real as an Option[Real]..

Attributes

Returns

Some(this).

lazy val cos: Field

Method to determine the cosine of this Real. The result will be a Real with PureNumber factor.

Method to determine the cosine of this Real. The result will be a Real with PureNumber factor.

Attributes

Returns

the cosine.

lazy val cosh: Field
lazy val exp: Field

Method to raise e to the power of this Real. The result will be a Real with NatLog factor.

Method to raise e to the power of this Real. The result will be a Real with NatLog factor.

Attributes

Returns

the e to the power of this.

lazy val invert: Field

Yields the inverse of this Real. This Number is first normalized so that its factor is PureNumber, since we cannot directly invert Numbers with other factors.

Yields the inverse of this Real. This Number is first normalized so that its factor is PureNumber, since we cannot directly invert Numbers with other factors.

Attributes

lazy val isAlgebraic: Boolean

Attributes

Returns

false.

lazy val isComplex: Boolean

Attributes

Returns

false.

lazy val isExact: Boolean

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.

lazy val isImaginary: Boolean

Method to determine if this Field is imaginary-valued (i.e. the point lies on the imaginary axis).

Method to determine if this Field is imaginary-valued (i.e. the point lies on the imaginary axis).

Attributes

Returns

true if this is a root of a negative number.

lazy val isInfinite: Boolean

Method to determine if this Real has infinite magnitude.

Method to determine if this Real has infinite magnitude.

Attributes

Returns

true if the magnitude of this Field is infinite.

lazy val isReal: Boolean

Method to determine if this Complex is real-valued.

Method to determine if this Complex is real-valued.

Attributes

Returns

true if this is not imaginary.

lazy val isUnity: Boolean

Method to determine if this Real has unity magnitude. Unity is the multiplicative identity.

Method to determine if this Real has unity magnitude. Unity is the multiplicative identity.

Attributes

Returns

true if the magnitude of this Field is one.

lazy val isZero: Boolean

Method to determine if this Real has zero magnitude. Zero is the additive identity.

Method to determine if this Real has zero magnitude. Zero is the additive identity.

Attributes

Returns

true if the magnitude of this Field is zero.

lazy val ln: Field

Method to determine the natural log of this Real. The result will be a Real with PureNumber factor.

Method to determine the natural log of this Real. The result will be a Real with PureNumber factor.

Attributes

Returns

the natural log of this.

lazy val maybeDouble: Option[Double]

Converts the true value of this Real to a Double. If the conversion is unsuccessful, it throws a CoreException.

Converts the true value of this Real to a Double. If the conversion is unsuccessful, it throws a CoreException.

Attributes

Returns

the Double representation of this Real, wrapped in Option.

lazy val maybeFactor: Option[Factor]

Method to determine what Factor, if there is such, this NumberLike object is based on.

Method to determine what Factor, if there is such, this NumberLike object is based on.

Attributes

Returns

an optional Factor.

lazy val normalize: Field

Method to "normalize" a field.

Method to "normalize" a field.

Attributes

Returns

a Real which is in canonical form.

lazy val render: String

Method to render this Field in a presentable manner.

Method to render this Field in a presentable manner.

Attributes

Returns

a String

lazy override val show: String

Show this Real in a human-friendly manner, delegating to the underlying Number.

Show this Real in a human-friendly manner, delegating to the underlying Number.

Attributes

Returns

a String

lazy val signum: Int

Method to determine the sense of this Real: negative, zero, or positive.

Method to determine the sense of this Real: negative, zero, or positive.

Attributes

Returns

an Int which is negative, zero, or positive according to the magnitude of this.

lazy val sin: Field

Method to determine the sine of this Real. The result will be a Real with PureNumber factor.

Method to determine the sine of this Real. The result will be a Real with PureNumber factor.

Attributes

Returns

the sine of this.

lazy val sinh: Field
lazy val sqrt: Field

Computes the square root of this Real number. This is equivalent to raising the number to the power of 1/2.

Computes the square root of this Real number. This is equivalent to raising the number to the power of 1/2.

Attributes

Returns

the square root as a Field.

lazy val square: Field

Squares this Field instance by multiplying it with itself.

Squares this Field instance by multiplying it with itself.

Attributes

Returns

the result of squaring this Field.

lazy val tan: Field

Method to determine the tangent of this Real. The result will be a Real with PureNumber factor.

Method to determine the tangent of this Real. The result will be a Real with PureNumber factor.

Attributes

Returns

the tangent

lazy val tanh: Field
lazy val toDouble: Double

Converts the true value of this Real to a Double. If the conversion is unsuccessful, it throws a CoreException.

Converts the true value of this Real to a Double. If the conversion is unsuccessful, it throws a CoreException.

Attributes

Returns

the Double representation of this Real.

lazy override val toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.