Packages

package math

The math package contains classes, traits and objects for common mathematical operations. Its package object defines exponentiation, logarithmic, trigonometric, etc. operators and functions.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. math
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. case class Complex(re: Double, im: Double = 0.0) extends Fractional[Complex] with Ordered[Complex] with Product with Serializable

    The Complex class is used to represent and operate on complex numbers.

    The Complex class is used to represent and operate on complex numbers. Internally, a complex number is represented as two double precision floating point numbers (Double). Externally, two forms are supported:

    a+bi = 2.1+3.2i via: Complex ("2.1+3.2i"), 'toString' (a, b) = (2.1, 3.2) via: create ("(2.1, 3.2)"), 'toString2'

    Note: 'i * i = -1'. -------------------------------------------------------------------------

    re

    the real part (e.g., 2.1)

    im

    the imaginary part (e.g., 3.2)

  2. final class Double_Exp extends AnyVal

    The Double_Exp value class adds an exponentiation operator 'x ~ y' and a 'near_eq' operator 'x =~ y' to Double. The '~' has higher precedence than '*' or '/'.

  3. type FunctionS2S = (Double) => Double

    The type definition for a function of a scalar (f: Double => Double)

    The type definition for a function of a scalar (f: Double => Double)

    See also

    also scalation.linalgebra

  4. type Functions = Array[FunctionS2S]

    The type definition for an array of scalar functions

  5. final class Int_Exp extends AnyVal

    The Int_Exp value class adds an exponentiation operator 'x ~ y' and a 'near_eq' operator 'x =~ y' to Int. The '~' has higher precedence than '*' or '/'.

  6. final class Long_Exp extends AnyVal

    The Long_Exp value class adds an exponentiation operator 'x ~ y' and a 'near_eq' operator 'x =~ y' to Long. The '~' has higher precedence than '*' or '/'.

  7. case class ProbNum(x: Double, p: Double = 1.0) extends Numeric[ProbNum] with Ordered[ProbNum] with Error with Product with Serializable

    The ProbNum class is used to represent probabilistic numbers '(x, p)' where 'x' is a real number and 'p' is its probability of occurrence.

    The ProbNum class is used to represent probabilistic numbers '(x, p)' where 'x' is a real number and 'p' is its probability of occurrence. FIX: Currently this class is half-baked!!!

    x

    the real number (double precision)

    p

    the probability of its occurrence [0, 1]

    See also

    http://okmij.org/ftp/Computation/monads.html#random-var-monad

  8. case class Rational(num: Long, den: Long = 1L) extends Fractional[Rational] with Ordered[Rational] with Product with Serializable

    The Rational class is used to represent and operate on rational numbers.

    The Rational class is used to represent and operate on rational numbers. Internally, a rational number is represented as two long integers. Externally, two forms are supported:

    a/b = 2/3 via: Rational ("2/3"), 'toString' (a, b) = (2, 3) via: create ("(2, 3)") 'toString2'

    Rational number can be created without loss of precision using the constructor, 'apply', 'create' or 'fromBigDecimal' methods. Other methods may lose precision.

    num

    the numerator (e.g., 2)

    den

    the denominator (e.g., 3)

  9. case class Real(hi: Double, lo: Double = 0.0) extends Fractional[Real] with Ordered[Real] with Product with Serializable

    The Real class provides higher precision floating point numbers using the Double Double technique, which supports 106 bits of precision.

    The Real class provides higher precision floating point numbers using the Double Double technique, which supports 106 bits of precision. ----------------------------------------------------------------------------- Code adapted from DoubleDouble.java:

    hi

    the high portion of the real number

    lo

    the low portion of the real number

    See also

    http://tsusiatsoftware.net/dd/main.html

    oai.cwi.nl/oai/asset/9159/9159A.pdf -----------------------------------------------------------------------------

Value Members

  1. val THRES: Double

    The threshold used for near equality

  2. def cot(x: Double): Double

    Return the cotangent of 'x'

  3. def csc(x: Double): Double

    Return the cosecant of 'x'

  4. implicit def double_exp(x: Double): Double_Exp

    Implicit conversion from 'Double' to 'Double_Exp', which supports exponentiation and nearly equals.

    Implicit conversion from 'Double' to 'Double_Exp', which supports exponentiation and nearly equals.

    x

    the base parameter

  5. implicit def int_exp(x: Int): Int_Exp

    Implicit conversion from 'Int' to 'Int_Exp', which supports exponentiation and nearly equals.

    Implicit conversion from 'Int' to 'Int_Exp', which supports exponentiation and nearly equals.

    x

    the base parameter

  6. def log2(x: Double): Double

    Compute the log of 'x' base 2.

    Compute the log of 'x' base 2.

    x

    the value whose log is sought

  7. val log_10: Double

    The natural log of 10

  8. val log_2: Double

    The natural log of 2

  9. def logb(b: Double, x: Double): Double

    Compute the log of 'x' base 'b'.

    Compute the log of 'x' base 'b'.

    b

    the base of the logarithm

    x

    the value whose log is sought

  10. implicit def long_exp(x: Long): Long_Exp

    Implicit conversion from 'Long' to 'Long_Exp', which supports exponentiation and nearly equals.

    Implicit conversion from 'Long' to 'Long_Exp', which supports exponentiation and nearly equals.

    x

    the base parameter

  11. def near_eq(x: Double, y: Double): Boolean

    Determine whether two double precision floating point numbers 'x' and 'y' are nearly equal.

    Determine whether two double precision floating point numbers 'x' and 'y' are nearly equal. Two numbers are considered to be nearly equal, if within '2 EPSILON'. A number is considered to be nearly zero, if within '2 MIN_NORMAL'. To accommodate round-off errors, may use 'TOL' instead of 'EPSILON'. --------------------------------------------------------------------------

    x

    the first double precision floating point number

    y

    the second double precision floating point number

    See also

    BasicTest

    stackoverflow.com/questions/4915462/how-should-i-do-floating-point-comparison -------------------------------------------------------------------------- If both 'x' and 'y' are NaN (Not-a-Number), the IEEE standard indicates that should be considered always not equal. For 'near_eq', they are considered nearly equal. Comment out the first line below to conform more closely to the IEEE standard.

    http://stackoverflow.com/questions/10034149/why-is-nan-not-equal-to-nan --------------------------------------------------------------------------

  12. def nexp(x: Double): Double

    Negative exponential function (e to the minus 'x').

    Negative exponential function (e to the minus 'x').

    x

    the argument of the function

  13. val noComplex: Complex

    Missing value representation (use null if available, otherwise most negative value)

  14. val noDouble: Double
  15. val noInt: Int
  16. val noLong: Long
  17. val noRational: Rational
  18. val noReal: Real
  19. val noStrNum: StrNum
  20. val noTimeNum: TimeNum
  21. def oneIf(cond: Boolean): Int

    Return 1 if condition 'cond' is true, else 0.

    Return 1 if condition 'cond' is true, else 0.

    cond

    the condition to evaluate

  22. def pow(x: Long, y: Long): Long

    Power function for scala Longs 'x ~^ y'. Compute: 'math.pow (x, y).toLong' without using floating point, so as to not lose precision.

    Power function for scala Longs 'x ~^ y'. Compute: 'math.pow (x, y).toLong' without using floating point, so as to not lose precision.

    x

    the Long base parameter

    y

    the Long exponent parameter

  23. def recip(x: Double): Double

    Compute the reciprocal/inverse of 'x'.

    Compute the reciprocal/inverse of 'x'.

    x

    the number to invert

  24. def root(x: Long, y: Long): Long

    Find the 'y'-th root of 'x', i.e., 'x ~ 1/y' for scala Longs. 'r = x ~ 1/y' is largest long integer 'r' such that 'r ~^ y <= x'.

    Find the 'y'-th root of 'x', i.e., 'x ~ 1/y' for scala Longs. 'r = x ~ 1/y' is largest long integer 'r' such that 'r ~^ y <= x'.

    x

    the Long base parameter

    y

    the Long root level (reciprocal exponent) parameter

    See also

    http://en.wikipedia.org/wiki/Shifting_nth_root_algorithm

    http://stackoverflow.com/questions/8826822/calculate-nth-root-with-integer-arithmetic

  25. def roundTo(x: Double, places: Int = 4): Double

    Round the given double to the desired number of decimal places.

    Round the given double to the desired number of decimal places.

    x

    the double number which needs to be rounded off

    places

    the desired number of decimal places

  26. def sec(x: Double): Double

    Return the secant of 'x'

  27. def sign(x: Double, y: Double): Double

    Return the absolute value of 'x' with the sign of 'y'.

    Return the absolute value of 'x' with the sign of 'y'.

    x

    the value contributor

    y

    the sign contributor

  28. def sq(x: Double): Double

    Compute the square of 'x'.

    Compute the square of 'x'.

    x

    the number to sqaure

  29. object Combinatorics extends Error

    The Combinatorics object provides several common combinatorics functions, such as factorial permutations, combinations, gamma and beta functions.

  30. object CombinatoricsTest extends App

    The CombinatoricsTest object tests the methods in the Combinatorics object.

  31. object CombinatoricsTest2 extends App

    The CombinatoricsTest2 object tests the Gamma and factorial methods in the Combinatorics object.

  32. object Complex extends Serializable

    The Complex companion object defines the origin (zero) and the fourth roots of unity as well as some utility functions.

  33. object ComplexTest extends App

    The ComplexTest object is used to test the Complex class.

    The ComplexTest object is used to test the Complex class. > runMain scalation.math.ComplexTest

  34. object ExtensionTest extends App

    The ExtensionTest object is used to test the Int_Exp, Long_Exp and Double_Exp classes.

    The ExtensionTest object is used to test the Int_Exp, Long_Exp and Double_Exp classes. > runMain scalation.math.ExtensionTest

  35. object ExtremeD

    The ExtremeD object contains constants representing extreme values for Double (IEEE 754 double precision floating point numbers).

    The ExtremeD object contains constants representing extreme values for Double (IEEE 754 double precision floating point numbers).

    See also

    http://docs.oracle.com/javase/8/docs/api/java/lang/Double.html

    en.wikipedia.org/wiki/Double-precision_floating-point_format ------------------------------------------------------------------------------ 64 bits: 1 sign-bit, 11 exponent-bits, 52 mantissa-bits + 1 implicit

  36. object ExtremeDTest extends App

    The ExtremeDTest object is used to test the ExtremeD class.

    The ExtremeDTest object is used to test the ExtremeD class. > runMain scalation.math.ExtremeDTest

  37. object MathTest extends App

    The MathTest object is used to test the supplemental power, root, exponential, sign, indicator, logarithmic and trigonmetric functions defined in the 'scalation.math' package object.

    The MathTest object is used to test the supplemental power, root, exponential, sign, indicator, logarithmic and trigonmetric functions defined in the 'scalation.math' package object. > runMain scalation.math.MathTest

  38. object Primes

    The Primes object provides an array of 1000 prime numbers as well as methods to generate prime numbers within a given range.

  39. object PrimesTest extends App

    The PrimesTest object is use to perform timing test on the Primes object.

  40. object PrimitiveType

    The PrimitiveType object provides comparison operators for Vec elements.

    The PrimitiveType object provides comparison operators for Vec elements.

    See also

    Vec_Elem

  41. object ProbNumTest extends App

    The ProbNumTest object is used to test the ProbNum class.

    The ProbNumTest object is used to test the ProbNum class. > runMain scalation.math.ProbNumTest

  42. object Rational extends Serializable

    The Rational companion object defines the origin (zero), one and minus one as well as some utility functions.

  43. object RationalTest extends App

    The RationalTest object is used to test the Rational class.

  44. object Real extends Serializable

    The Real companion object defines the origin (zero), one half and one as well as some utility functions.

  45. object RealTest extends App

    The RealTest object is used to test the Real class.

    The RealTest object is used to test the Real class. > runMain scalation.math.RealTest

  46. object StrNumTest extends App

    The StrNumTest object is used to test the StrNum class.

    The StrNumTest object is used to test the StrNum class. > runMain scalation.math.StrNumTest

  47. object StrO extends Error

    The StrO object is used to represent and operate on string numbers.

    The StrO object is used to represent and operate on string numbers. It contains an implicit class definition for StrNum, which extends strings with Numeric operations, it it can be used in VectorS. The semantics of StrNum operators are similar those in Pike.

    See also

    http://docs.roxen.com/pike/7.0/tutorial/strings/operators.xml

  48. object TimeNumTest extends App

    The TimeNumTest object is used to test the TimeNum class.

    The TimeNumTest object is used to test the TimeNum class. > runMain scalation.math.TimeNumTest

  49. object TimeNumTest2 extends App

    The TimeNumTest2 object is used to test the TimeNum class regarding approximately equal date-times.

    The TimeNumTest2 object is used to test the TimeNum class regarding approximately equal date-times. > runMain scalation.math.TimeNumTest2

  50. object TimeNumTest3 extends App

    The TimeNumTest3 object is used to test the TimeNum class regarding its getChrono method.

    The TimeNumTest3 object is used to test the TimeNum class regarding its getChrono method. FIX - crashes - format exception > runMain scalation.math.TimeNumTest3

  51. object TimeO

    The TimeO object is used to represent and operate on date-time values.

    The TimeO object is used to represent and operate on date-time values. It contains an implicit class definition for TimeNum, which extends Instant with Numeric operations that can be used in VectorT. The java.time.Instant class stores nano-seconds since the UNIX Epoch using a long for seconds and int for nano-seconds (12 bytes or 96 bits). The java.time.ZonedDateTime class is used with it to handle various date-time formats.

Inherited from AnyRef

Inherited from Any

Ungrouped