Packages

  • package root

    This is the documentation for the Evaluator project (see GitHub).

    This is the documentation for the Evaluator project (see GitHub).

    The main package net.totietje.evaluator. The net.totietje.complex package contains an example usage of this package, which may also be useful.

    Definition Classes
    root
  • package net
    Definition Classes
    root
  • package totietje
    Definition Classes
    net
  • package complex

    This package is centered around the Complex class, with a focus on complex arithmetic.

    This package is centered around the Complex class, with a focus on complex arithmetic.

    The ComplexEvaluator object contains the evaluate(String) method for parsing a mathematical expression as a function of complex numbers.

    Definition Classes
    totietje
    Examples:
    1. val function = ComplexEvaluator.parse("log(i * x) - i * log(y)")

    2. ,
    3. val sine = Complex(3, 4).sin

  • Complex
  • ComplexEvaluator
  • ComplexFunction
  • VariableException
  • package evaluator

    The evaluator package is designed to simplify the process of parsing a string.

    The evaluator package is designed to simplify the process of parsing a string.

    The work of parsing a string is reduced to just tokenizing an expression, that is, breaking it down into its principal parts. The AbstractEvaluator class will handle the rest.

    The AbstractTokenizer makes this even easier, though it is only applicable in some situations.

    Definition Classes
    totietje
    See also

    AbstractTokenizer

    Tokenizer

    AbstractEvaluator

    Evaluator

p

net.totietje

complex

package complex

This package is centered around the Complex class, with a focus on complex arithmetic.

The ComplexEvaluator object contains the evaluate(String) method for parsing a mathematical expression as a function of complex numbers.

Source
package.scala
Examples:
  1. val function = ComplexEvaluator.parse("log(i * x) - i * log(y)")

  2. ,
  3. val sine = Complex(3, 4).sin

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

Type Members

  1. case class Complex (re: Double, im: Double = 0) extends Product with Serializable

    A class which represents a complex number, that is, a number in the form a + bi, where i is one of the two square roots of -1.

    A class which represents a complex number, that is, a number in the form a + bi, where i is one of the two square roots of -1.

    a is called the real part, and b is called the imaginary part.

    re

    The real part

    im

    The imaginary part

  2. abstract class ComplexFunction extends AnyRef

    This represents a function of complex variables.

    This represents a function of complex variables. It can be evaluated using a map of the variables and their values. The function will then be evaluated, substituting in each variable's respective value, returning a complex number as its output.

    See also

    Complex

  3. case class VariableException (message: String = null, cause: Throwable = null) extends Exception with Product with Serializable

    An exception thrown by a ComplexFunction on evaluation if an undefined variable is encountered.

    An exception thrown by a ComplexFunction on evaluation if an undefined variable is encountered.

    message

    The detailed message

    cause

    The cause

Value Members

  1. object Complex extends Serializable

    A companion object for the Complex class.

    A companion object for the Complex class.

    This contains constants and implicit conversions.

  2. object ComplexEvaluator extends AbstractEvaluator[ComplexFunction]

    An Evaluator which parses an expression as a ComplexFunction.

    An Evaluator which parses an expression as a ComplexFunction.

    This allows the basic operators +, -, *, / and ^ and the use of brackets.

    The following strings are treated as constants:

    • i
    • pi or π
    • tau or τ
    • e

    Furthermore, the following functions are recognised:

    • im
    • re
    • arg
    • abs
    • conj
    • sqrt or √
    • log or ln
    • sin
    • asin
    • cos
    • acos
    • tan
    • atan
    • sinh
    • asinh
    • cosh
    • acosh
    • tanh
    • atanh

    There is currently no support for implicit multiplication without the * symbol, such as 2i.

    A string can be parsed like this:

    val complexFunction = ComplexEvaluator.evaluate("2 + i * sin(x)")

    That returned ComplexFunction can then be evaluated for a given input for x with:

    val complexNumber = complexFunction(Map("x" -> xValue))

    For example, replacing xValue with Complex.Pi would produce a complex number roughly equal to 2. It is recommended to then round the result by calling .round to round the number to an appropriate degree of accuracy.

  3. object ComplexFunction

    A companion object for the ComplexFunction trait.

    A companion object for the ComplexFunction trait.

    This contains all the subclasses of the sealed ComplexFunction class, and implicit conversions.

Inherited from AnyRef

Inherited from Any

Ungrouped