OASIS
Open Algebra Software
Loading...
Searching...
No Matches
Oasis::Expression Class Referenceabstract

An expression. More...

#include <Oasis/Expression.hpp>

Inheritance diagram for Oasis::Expression:
[legend]

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Expression()

virtual Oasis::Expression::~Expression ( )
virtualdefault

Member Function Documentation

◆ Copy()

◆ Differentiate()

◆ Equals()

virtual auto Oasis::Expression::Equals ( const Expression & other) const -> bool
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.

Parameters
otherThe other expression.
Returns
Whether the two expressions are equal.

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.

◆ FindZeros()

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.

Template Parameters
origonalExpresionThe expression for which all the factors will be found.

◆ Generalize()

◆ GetCategory()

auto Oasis::Expression::GetCategory ( ) const -> uint32_t
virtual

Gets the category of this expression.

Returns
The category of this expression.

◆ GetType()

auto Oasis::Expression::GetType ( ) const -> ExpressionType
virtual

Gets the type of this expression.

Returns
The type of this expression.

◆ Integrate()

◆ IntegrateWithBounds()

auto Oasis::Expression::IntegrateWithBounds ( const Expression & variable,
const Expression & ,
const Expression &  ) -> std::unique_ptr<Expression>
virtual

Attempts to integrate this expression using integration rules.

Returns
A solved definite integral of the expression

◆ Is() [1/3]

template<IExpression T>
bool Oasis::Expression::Is ( ) const
inline

Gets whether this expression is of a specific type.

Template Parameters
TThe type to check against.
Returns
true if this expression is of type T, false otherwise.

◆ Is() [2/3]

template<template< typename > typename T>
bool Oasis::Expression::Is ( ) const
inline

◆ Is() [3/3]

template<template< typename, typename > typename T>
bool Oasis::Expression::Is ( ) const
inline

◆ Serialize()

virtual void Oasis::Expression::Serialize ( SerializationVisitor & visitor) const
pure virtual

◆ Simplify()

◆ StructurallyEquivalent()

virtual auto Oasis::Expression::StructurallyEquivalent ( const Expression & other) const -> bool
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.

Parameters
otherThe other expression.
Returns
Whether the two expressions are structurally equivalent.

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 >.

◆ Substitute()


The documentation for this class was generated from the following files: