Documentation
¶
Index ¶
- func DisableMemoize[U Uint]() func(*Calculator[U]) error
- func Pretty[U Uint](pretty bool) func(*Calculator[U]) error
- func Size[U Uint](size int) func(*Calculator[U]) error
- type Calculator
- func (t *Calculator) AST() *node[U]
- func (t *Calculator) Add(rule pegRule, begin, end, index U)
- func (c *Calculator[T]) Convert(n *node[T]) Value
- func (c *Calculator[T]) Eval() Value
- func (p *Calculator[U]) Init(options ...func(*Calculator[U]) error) error
- func (p *Calculator[_]) Parse(rule ...int) error
- func (t *Calculator) PrettyPrintSyntaxTree(buffer string)
- func (t *Calculator) Print()
- func (p *Calculator[_]) PrintSyntaxTree()
- func (p *Calculator[_]) Reset()
- func (p *Calculator[_]) SprintSyntaxTree() string
- func (t *Calculator) Tokens() []token[U]
- func (t *Calculator) Trim(length uint32)
- func (p *Calculator[_]) WriteSyntaxTree(w io.Writer)
- type Float
- func (f *Float) Abs(a *Float) *Float
- func (f *Float) Add(a, b *Float) *Float
- func (f *Float) Arg(x *Float) *Float
- func (f *Float) Atan2(x *Float) *Float
- func (f *Float) Conj(a *Float) *Float
- func (f *Float) Cos(x *Float) *Float
- func (f *Float) Div(a, b *Float) *Float
- func (f *Float) Exp(x *Float) *Float
- func (f *Float) Log(x *Float) *Float
- func (f *Float) Mul(a, b *Float) *Float
- func (f *Float) Pow(x *Float, y *Float) *Float
- func (f *Float) Rat(r *Rational)
- func (f *Float) SetRat(r *Rational)
- func (f *Float) Sin(x *Float) *Float
- func (f *Float) Sqrt(a *Float) *Float
- func (f *Float) String() string
- func (f *Float) Sub(a, b *Float) *Float
- func (f *Float) Tan(x *Float) *Float
- type Matrix
- func (m *Matrix) Abs(a *Matrix) *Matrix
- func (m *Matrix) Add(a, b *Matrix) *Matrix
- func (m *Matrix) Arg(a *Matrix) *Matrix
- func (m *Matrix) Atan2(a *Matrix) *Matrix
- func (m *Matrix) Conj(a *Matrix) *Matrix
- func (m *Matrix) Cos(a *Matrix) *Matrix
- func (m *Matrix) Div(a, b *Matrix) *Matrix
- func (m *Matrix) Exp(a *Matrix) *Matrix
- func (m *Matrix) Im(a *Matrix) *Matrix
- func (m *Matrix) Log(a *Matrix) *Matrix
- func (m *Matrix) Mul(a, b *Matrix) *Matrix
- func (m *Matrix) Neg(a *Matrix) *Matrix
- func (m *Matrix) Pow(x *Matrix, y *Rational) *Matrix
- func (m *Matrix) Re(a *Matrix) *Matrix
- func (m *Matrix) Sin(a *Matrix) *Matrix
- func (m *Matrix) Sqrt(a *Matrix) *Matrix
- func (m *Matrix) String() string
- func (m *Matrix) Sub(a, b *Matrix) *Matrix
- func (m *Matrix) Tan(a *Matrix) *Matrix
- type Node
- type Operation
- type Rational
- func (r *Rational) Add(a, b *Rational) *Rational
- func (r *Rational) Conj(a *Rational) *Rational
- func (r *Rational) Div(a, b *Rational) *Rational
- func (r *Rational) Mul(a, b *Rational) *Rational
- func (r *Rational) Neg(a *Rational) *Rational
- func (r *Rational) String() string
- func (r *Rational) Sub(a, b *Rational) *Rational
- type Uint
- type Value
- type ValueType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableMemoize ¶
func DisableMemoize[U Uint]() func(*Calculator[U]) error
Types ¶
type Calculator ¶
type Calculator[U Uint] struct { Buffer string Pretty bool // contains filtered or unexported fields }
func (*Calculator[T]) Convert ¶
func (c *Calculator[T]) Convert(n *node[T]) Value
Convert converts to an expression
func (*Calculator[U]) Init ¶
func (p *Calculator[U]) Init(options ...func(*Calculator[U]) error) error
func (*Calculator[_]) Parse ¶
func (p *Calculator[_]) Parse(rule ...int) error
func (*Calculator) PrettyPrintSyntaxTree ¶
func (t *Calculator) PrettyPrintSyntaxTree(buffer string)
func (*Calculator[_]) PrintSyntaxTree ¶
func (p *Calculator[_]) PrintSyntaxTree()
func (*Calculator[_]) Reset ¶
func (p *Calculator[_]) Reset()
func (*Calculator[_]) SprintSyntaxTree ¶
func (p *Calculator[_]) SprintSyntaxTree() string
func (*Calculator[_]) WriteSyntaxTree ¶
func (p *Calculator[_]) WriteSyntaxTree(w io.Writer)
type Float ¶
Float is an imaginary number
func (*Float) Arg ¶
Arg computes arg(x + yi) using atan2(y, x) in (−π, π]. https://mathworld.wolfram.com/ComplexArgument.html
func (*Float) Atan2 ¶
Atan2 computes atan2(y, x) for the complex value x+yi (same as Arg). https://en.wikipedia.org/wiki/Atan2
func (*Float) Cos ¶
Cos computes cosine of a number https://www.wolframalpha.com/input/?i=cos%28x+%2B+yi%29
func (*Float) Exp ¶
Exp computes e^x for a complex number https://www.wolframalpha.com/input/?i=e%5E%28x+%2B+yi%29
func (*Float) Log ¶
Log computes the natural log of x: log|z| + i·arg(z) https://en.wikipedia.org/wiki/Complex_logarithm
func (*Float) Pow ¶
Pow computes x**y https://mathworld.wolfram.com/ComplexExponentiation.html
func (*Float) Sin ¶
Sin computes sine of a number https://www.wolframalpha.com/input/?i=sin%28x+%2B+yi%29
func (*Float) Sqrt ¶
Sqrt computes the square root of the complex number https://www.johndcook.com/blog/2020/06/09/complex-square-root/
type Matrix ¶
Matrix is a matrix
func (*Matrix) Arg ¶
Arg computes arg(x + yi) = tan-1(y/x) https://mathworld.wolfram.com/ComplexArgument.html
func (*Matrix) Atan2 ¶
Atan2 computes atan2 of x https://en.wikipedia.org/wiki/Atan2
func (*Matrix) Cos ¶
Cos computes cosine of a number https://www.wolframalpha.com/input/?i=cos%28x+%2B+yi%29
func (*Matrix) Exp ¶
Exp computes e^x for a complex number https://www.wolframalpha.com/input/?i=e%5E%28x+%2B+yi%29
func (*Matrix) Log ¶
Log computes the natural log of x https://en.wikipedia.org/wiki/Complex_logarithm
func (*Matrix) Pow ¶
Pow computes x**y https://mathworld.wolfram.com/ComplexExponentiation.html
func (*Matrix) Sin ¶
Sin computes sine of a number https://www.wolframalpha.com/input/?i=sin%28x+%2B+yi%29
type Node ¶
Node is a node in an expression binary tree
func (*Node) Derivative ¶
Derivative takes the derivative of the equation https://www.cs.utexas.edu/users/novak/asg-symdif.html#:~:text=Introduction,numeric%20calculations%20based%20on%20formulas.
func (*Node) Integrate ¶
Integrate integrates the expression symbolically (indefinite integral). The constant of integration is omitted. Assumes a single free variable. Products of non-constants are handled with integration by parts (LIATE), including cyclic cases such as ∫ e^x sin(x) dx.
type Operation ¶
type Operation uint
Operation is a mathematical operation
const ( // OperationNoop is a noop OperationNoop Operation = iota // OperationAdd adds two numbers OperationAdd // OperationSubtract subtracts two numbers OperationSubtract // OperationMultiply multiplies two numbers OperationMultiply // OperationDivide divides two numbers OperationDivide // OperationModulus computes the modulus of two numbers OperationModulus // OperationExponentiation raises a number to a number OperationExponentiation // OperationNegate changes the sign of a number OperationNegate // OperationVariable is a variable OperationVariable // OperationImaginary is an imaginary number OperationImaginary // OperationNumber is a real number OperationNumber // OperationMatrix is a matrix OperationMatrix // OperationNaturalExponentiation raises the natural number to a power OperationNaturalExponentiation // OperationNatural is the constant e OperationNatural // OperationPI is the constant pi OperationPI // OperationSetPrec sets the precision OperationSetPrec // OperationSimplify simplify the expression OperationSimplify // OperationDerivative compute the symbolic derivative OperationDerivative // OperationIntegrate integrates the equation OperationIntegrate // OperationNaturalLogarithm os the natural logarithm OperationNaturalLogarithm // OperationSquareRoot computes the square root of a number OperationSquareRoot // OperationCosine computes the cosine of a number OperationCosine // OperationSine computes the sine of a number OperationSine // OperationTangent computes the tangent of a number OperationTangent // OperationAbs computes the absolute value / modulus OperationAbs // OperationConj computes the complex conjugate OperationConj // OperationRe extracts the real part OperationRe // OperationIm extracts the imaginary part OperationIm // OperationNotation is E notation operation OperationNotation )
type Rational ¶
Rational is an imaginary number
func NewRational ¶
NewRational creates a new imaginary number
func (*Rational) Div ¶
Div divides two imaginary numbers: (a+bi)/(c+di) = ((ac+bd)+(bc-ad)i)/(c²+d²). Copies inputs so callers may pass overlapping or shared rationals safely.