OASIS
Open Algebra Software
|
An expression. More...
#include <Oasis/Expression.hpp>
Public Member Functions | |
virtual auto | Copy () const -> std::unique_ptr< Expression >=0 |
Copies this expression. | |
virtual auto | Differentiate (const Expression &) const -> std::unique_ptr< Expression > |
Tries to differentiate this function. | |
virtual auto | Equals (const Expression &other) const -> bool=0 |
Compares this expression to another expression for equality. | |
auto | FindZeros () const -> std::vector< std::unique_ptr< Expression > > |
The FindZeros function finds all rational real zeros, and up to 2 irrational/complex zeros of a polynomial. | |
virtual auto | GetCategory () const -> uint32_t |
Gets the category of this expression. | |
virtual auto | GetType () const -> ExpressionType |
Gets the type of this expression. | |
virtual auto | Generalize () const -> std::unique_ptr< Expression > |
Converts this expression to a more general expression. | |
virtual auto | Integrate (const Expression &) const -> std::unique_ptr< Expression > |
Attempts to integrate this expression using integration rules. | |
virtual auto | IntegrateWithBounds (const Expression &, const Expression &, const Expression &) -> std::unique_ptr< Expression > |
Attempts to integrate this expression using integration rules. | |
template<IExpression T> | |
bool | Is () const |
Gets whether this expression is of a specific type. | |
template<template< typename > typename T> | |
bool | Is () const |
template<template< typename, typename > typename T> | |
bool | Is () const |
virtual auto | Simplify () const -> std::unique_ptr< Expression > |
Simplifies this expression. | |
virtual auto | StructurallyEquivalent (const Expression &other) const -> bool=0 |
Checks whether this expression is structurally equivalent to another expression. | |
virtual auto | Substitute (const Expression &var, const Expression &val) -> std::unique_ptr< Expression >=0 |
virtual void | Serialize (SerializationVisitor &visitor) const =0 |
This function serializes the expression object. | |
virtual | ~Expression ()=default |
An expression.
Expressions are a tree-like structure that represent mathematical expressions. They can be evaluated, simplified, and compared for equality. They are immutable, and all operations on them return a new expression.
|
virtualdefault |
|
pure virtual |
Copies this expression.
Implemented in Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::BoundedUnaryExpression< DerivedT, OperandT, LowerBoundT, UpperBoundT >, Oasis::LeafExpression< DerivedT >, Oasis::LeafExpression< EulerNumber >, Oasis::LeafExpression< Imaginary >, Oasis::LeafExpression< Matrix >, Oasis::LeafExpression< Pi >, Oasis::LeafExpression< Real >, Oasis::LeafExpression< Undefined >, Oasis::LeafExpression< Variable >, Oasis::UnaryExpression< DerivedT, OperandT >, Oasis::UnaryExpression< Magnitude, OperandT >, and Oasis::UnaryExpression< Negate, OperandT >.
|
virtual |
Tries to differentiate this function.
Reimplemented in Oasis::Matrix, Oasis::Real, Oasis::Variable, Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::BoundedUnaryExpression< DerivedT, OperandT, LowerBoundT, UpperBoundT >, Oasis::LeafExpression< DerivedT >, Oasis::LeafExpression< EulerNumber >, Oasis::LeafExpression< Imaginary >, Oasis::LeafExpression< Matrix >, Oasis::LeafExpression< Pi >, Oasis::LeafExpression< Real >, Oasis::LeafExpression< Undefined >, Oasis::LeafExpression< Variable >, Oasis::Magnitude< OperandT >, and Oasis::Negate< OperandT >.
|
pure virtual |
Compares this expression to another expression for equality.
Two expressions are equal if they are structurally equivalent and have the same value. While this method considers the associativity and commutativity of expressions, it does not simplify the expressions before comparing them. For example, Add<Real>(Real(1), Real(2))
and Add<Real>(Real(2), Real(1))
are not equal, despite being structurally equivalent.
other | The other expression. |
Implemented in Oasis::Undefined, Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::BoundedUnaryExpression< DerivedT, OperandT, LowerBoundT, UpperBoundT >, Oasis::EulerNumber, Oasis::Imaginary, Oasis::Matrix, Oasis::Pi, Oasis::Real, Oasis::UnaryExpression< DerivedT, OperandT >, Oasis::UnaryExpression< Magnitude, OperandT >, Oasis::UnaryExpression< Negate, OperandT >, and Oasis::Variable.
auto Oasis::Expression::FindZeros | ( | ) | const -> std::vector<std::unique_ptr<Expression>> |
The FindZeros function finds all rational real zeros, and up to 2 irrational/complex zeros of a polynomial.
The FindZeros function finds all rational zeros of a polynomial.
Currently assumes an expression of the form a+bx+cx^2+dx^3+... where a, b, c, d are a integers.
origonalExpresion | The expression for which all the factors will be found. |
|
virtual |
Converts this expression to a more general expression.
Some expressions may explicitly specify the type of their operands. For example, a Divide<Real>
expression may only accept Real
operands. This function converts the expression to a more general expression, such as Divide<Expression>
, which accepts any expression as an operand.
Reimplemented in Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::UnaryExpression< DerivedT, OperandT >, Oasis::UnaryExpression< Magnitude, OperandT >, and Oasis::UnaryExpression< Negate, OperandT >.
|
virtual |
Gets the category of this expression.
|
virtual |
Gets the type of this expression.
|
virtual |
Attempts to integrate this expression using integration rules.
Reimplemented in Oasis::Magnitude< OperandT >, Oasis::Matrix, Oasis::Real, Oasis::Variable, Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::LeafExpression< DerivedT >, Oasis::LeafExpression< EulerNumber >, Oasis::LeafExpression< Imaginary >, Oasis::LeafExpression< Matrix >, Oasis::LeafExpression< Pi >, Oasis::LeafExpression< Real >, Oasis::LeafExpression< Undefined >, and Oasis::LeafExpression< Variable >.
|
virtual |
Attempts to integrate this expression using integration rules.
|
inline |
Gets whether this expression is of a specific type.
T | The type to check against. |
|
inline |
|
inline |
|
pure virtual |
This function serializes the expression object.
visitor | The serializer class object to write the Expression data. |
Implemented in Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::BoundedUnaryExpression< DerivedT, OperandT, LowerBoundT, UpperBoundT >, Oasis::LeafExpression< DerivedT >, Oasis::LeafExpression< EulerNumber >, Oasis::LeafExpression< Imaginary >, Oasis::LeafExpression< Matrix >, Oasis::LeafExpression< Pi >, Oasis::LeafExpression< Real >, Oasis::LeafExpression< Undefined >, Oasis::LeafExpression< Variable >, Oasis::UnaryExpression< DerivedT, OperandT >, Oasis::UnaryExpression< Magnitude, OperandT >, and Oasis::UnaryExpression< Negate, OperandT >.
|
virtual |
Simplifies this expression.
Reimplemented in Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::Magnitude< OperandT >, and Oasis::Negate< OperandT >.
|
pure virtual |
Checks whether this expression is structurally equivalent to another expression.
Two expressions are structurally equivalent if the share the same tree structure. For example, Add<Real>(Real(1), Real(2))
and Add<Real>(Real(2), Real(1))
are structurally equivalent despite having different values.
other | The other expression. |
Implemented in Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::LeafExpression< DerivedT >, Oasis::LeafExpression< EulerNumber >, Oasis::LeafExpression< Imaginary >, Oasis::LeafExpression< Matrix >, Oasis::LeafExpression< Pi >, Oasis::LeafExpression< Real >, Oasis::LeafExpression< Undefined >, Oasis::LeafExpression< Variable >, Oasis::UnaryExpression< DerivedT, OperandT >, Oasis::UnaryExpression< Magnitude, OperandT >, and Oasis::UnaryExpression< Negate, OperandT >.
|
pure virtual |
Implemented in Oasis::LeafExpression< DerivedT >, Oasis::LeafExpression< EulerNumber >, Oasis::LeafExpression< Imaginary >, Oasis::LeafExpression< Matrix >, Oasis::LeafExpression< Pi >, Oasis::LeafExpression< Real >, Oasis::LeafExpression< Undefined >, Oasis::LeafExpression< Variable >, Oasis::BinaryExpression< DerivedT, MostSigOpT, LeastSigOpT >, Oasis::BinaryExpression< Add, Expression, Expression >, Oasis::BinaryExpression< Derivative, Expression, Expression >, Oasis::BinaryExpression< Divide, Expression, Expression >, Oasis::BinaryExpression< Exponent, Expression, Expression >, Oasis::BinaryExpression< Integral, Expression, Expression >, Oasis::BinaryExpression< Log, Expression, Expression >, Oasis::BinaryExpression< Multiply, Expression, Expression >, Oasis::BinaryExpression< Subtract, Expression, Expression >, Oasis::BoundedBinaryExpression< DerivedT, MostSigOpT, LeastSigOpT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< DefiniteIntegral, OperandT, VariableT, LowerBoundT, UpperBoundT >, Oasis::BoundedBinaryExpression< Summation, OperandT, IncrementingVarT, LowerBoundT, UpperBoundT >, Oasis::BoundedUnaryExpression< DerivedT, OperandT, LowerBoundT, UpperBoundT >, Oasis::UnaryExpression< DerivedT, OperandT >, Oasis::UnaryExpression< Magnitude, OperandT >, Oasis::UnaryExpression< Negate, OperandT >, and Oasis::Variable.