Documentation of CSL
Public Member Functions | Static Public Member Functions
csl::Abstract Class Referenceabstract

Root class of the inheritance tree of abstracts. More...

#include <abstract.h>

Inheritance diagram for csl::Abstract:
Inheritance graph
[legend]

Public Member Functions

 Abstract ()
 Default Constructor. More...
 
virtual ~Abstract ()
 Destructor.
 
Expr self ()
 
virtual void print (int mode=0, std::ostream &out=std::cout, bool lib=false) const =0
 Displays the abstract in standard output. More...
 
virtual void printCode (int mode=0, std::ostream &out=std::cout) const
 
virtual void printProp (std::ostream &fout=std::cout) const
 
void printExplicit (int mode=0) const
 Displays explicitely the expression, with types of each component. This function is only used for debug. More...
 
virtual std::string printLaTeX (int mode=0) const
 Creates a LaTeX output for the Abstract. More...
 
virtual std::vector< ParentgetSubSymbols () const =0
 
virtual LibDependency getLibDependency () const
 
virtual size_t memoryOverhead () const
 
virtual std::string const & getName () const
 Returns the Abstract's name. More...
 
virtual std::string const & getLatexName () const
 
virtual bool getCommutable () const
 Allows to know if the object commutes with all the others. More...
 
virtual bool getElementary () const
 
virtual bool getAllDependencies () const
 
virtual csl::PrimaryType getPrimaryType () const =0
 Gives the primary type of Abstract. More...
 
virtual csl::Type getType () const =0
 Gives the type of Abstract. More...
 
virtual int getDim () const
 Gives the dimension of the object. More...
 
virtual bool isBuildingBlock () const
 Tells if the expression is a Building Block or not. More...
 
virtual int getOrderOf (Expr_info expr) const
 
virtual bool isArbitrary () const
 
virtual bool isIndexed () const
 
virtual const std::vector< Equation * > & getProperties () const
 
virtual bool isReal () const
 
virtual bool isPurelyImaginary () const
 
virtual bool isComplexConjugate () const
 
virtual bool isHermitianConjugate () const
 
virtual csl::ComplexProperty getComplexProperty () const
 
virtual void setComplexProperty (csl::ComplexProperty prop)
 
virtual void setConjugated (bool t_conjugated)
 
virtual bool isInteger () const
 Tells if the expression is an integer. Either an Integer object directly, or a Float that has an integer value. More...
 
virtual bool getValued () const
 Tells if the expression is valued, i.e. is a function of numbers and valued literals (a Variable or Constant is not valued by default). More...
 
virtual long double getValue () const
 Returns the value of the expression, if it has one explicitely. In particular, it will work only on Numbers and valued Literals, not on functions. More...
 
virtual long double getDeltaPlus () const
 
virtual long double getDeltaMinus () const
 
virtual long long int getNum () const
 
virtual long long int getDenom () const
 
virtual int getNArgs (int axis=0) const
 Returns the number of arguments of the expression. If the expression is a building block (AbstractBuildingBlock), this function returns 0. More...
 
virtual size_t size () const
 
virtual bool empty () const
 
virtual csl::vector_expr::iterator begin ()
 
virtual csl::vector_expr::iterator end ()
 
virtual csl::vector_expr::const_iterator begin () const
 
virtual csl::vector_expr::const_iterator end () const
 
virtual Expr const & getArgument (int iArg=0) const
 
virtual ExprgetArgument (int iArg=0)
 
virtual Expr const & getArgument (const std::vector< int > &indices) const
 Allows to get specific arguments of expressions in multiple dimensions, by giving the indices in each dimension. More...
 
virtual ExprgetArgument (const std::vector< int > &indices)
 
virtual const csl::vector_expr & getVectorArgument () const
 Allows to get the entire std::vector of arguments of the expression. More...
 
virtual Expr getVariable () const
 Accessor to the variable that defines certain types of expressions. More...
 
virtual int getOrder () const
 Accessor to the order (integer) that defines certain types of expressions. More...
 
virtual int getSign () const
 
virtual bool isAnOperator () const
 Tells if the expression is an operator (like a derivetive operator). More...
 
virtual bool isEmpty () const
 Tells for a Derivative or an Integral if the argument is empty i.e. if the object must apply on the next argument encountered on the right. More...
 
virtual bool operatorAppliesOn (Expr_info expr) const
 
virtual Expr getOperand () const
 Returns the operand of an Operator. More...
 
virtual std::vector< int > getShape () const
 Accessor to the shape of the tensor in the form of a std::vector of integers. More...
 
virtual Expr getInfBoundary () const
 
virtual Expr getSupBoundary () const
 
virtual void setSupBoundary (Expr const &t_inf)
 
virtual void setInfBoundary (Expr const &t_inf)
 
virtual int getNIndices () const
 
virtual Index getIndex (int i=0) const
 
virtual void resetIndexStructure ()
 
virtual IndexStructure getIndexStructure () const
 
IndexStructure getIndexStructure (csl::Space const *space) const
 
virtual const IndexStructuregetIndexStructureView () const
 
virtual IndexStructuregetIndexStructureView ()
 
virtual IndexStructure getFreeIndexStructure () const
 
virtual Parent getParent () const
 For indicial expressions this function returns a pointer to the parent object of type TensorParent (not an expression). More...
 
virtual Parent_info getParent_info () const
 
virtual Tensor getPoint () const
 
virtual int getNContractedPairs () const
 Returns the number of contracted pairs of indices in an Indicial expression. More...
 
virtual csl::vector_expr getPermutations (bool optimize=true) const
 Returns a std::vector of all possible permutations of an Indicial expression. The possible permutations are determined from the posible symmetries and anti-symmetries of the object. More...
 
virtual std::set< std::pair< int, int > > getContractedPair () const
 
Expr copy () const
 
virtual unique_Expr copy_unique () const =0
 
virtual Expr deepCopy () const
 
virtual Expr refresh () const
 
virtual Expr deepRefresh () const
 
virtual void setName (const std::string &t_name)
 Change the name of the abstract. More...
 
virtual void setCommutable (bool t_commutable)
 Allows the abstract to commute or not. More...
 
virtual void addProperty (Equation *property)
 Adds a property to the object. More...
 
virtual void removeProperty (Equation *property)
 Removes a property to the object. More...
 
virtual void setValue (long double t_value)
 Sets the value if there is one (for Numerical and Literal valued).
 
virtual void setValue (Expr const &t_value)
 
virtual void setElementary (bool t_elementary)
 
virtual void setAllDependencies (bool t_allDependencies)
 
virtual void addDependency (Expr const &expr)
 
virtual void removeDependency (Expr const &expr)
 
virtual void setArgument (const Expr &expr, int iArg=0)
 Sets the argument at position iArg (default=0). More...
 
virtual void setArgument (const Expr &expr, const std::vector< int > &indices)
 Sets the argument at position {i,j,...} for multi-dimensions expressions. More...
 
virtual void setEmpty (bool t_empty)
 
virtual void setOperand (const Expr &operand)
 Sets the operand of an operator. More...
 
virtual void setOperandPrivate (const Expr &operand, bool leaveEmpty)
 Sets the operand of an operator. More...
 
virtual void setVectorArgument (const csl::vector_expr &t_argument)
 Replaced the entire std::vector of argument. More...
 
virtual void setVariable (Expr const &t_variable)
 
virtual void insert (const Expr &expr, bool side=1)
 Inserts an expression in a sum or a product. More...
 
virtual void setParent (const Parent &t_parent)
 
virtual std::optional< ExprreplaceIndex (const Index &indexToReplace, const Index &newIndex, bool refresh=true) const
 For indicial expressions, this function searches indexToContract and replaces it with newIndex. More...
 
virtual std::optional< ExprreplaceIndices (std::vector< Index > const &indexToReplace, std::vector< Index > const &newIndex, bool refresh=true, bool flipped=false) const
 
virtual void replaceIndexInPlace (Index const &oldIndex, Index const &newIndex)
 
std::optional< ExprcontractIndex (const Index &index) const
 
csl::vector_expr breakSpace (const Space *brokenSpace, const std::vector< const Space *> &newSpace) const
 
virtual csl::vector_expr breakSpace (const Space *brokenSpace, const std::vector< const Space *> &newSpace, const std::vector< std::string > &indexNames) const
 
virtual void setIndexStructure (const IndexStructure &t_index)
 Replaces the index structure of the object, that must be an Indicial expression. More...
 
virtual void setPoint (const Tensor &t_point)
 
virtual void setFullySymmetric ()
 Sets an Indicial object fully symmetric. Allows to set quickly a frequent property of tensors. This function then erases all properties of symmetry / antisymmetry and sets fullySymmetric to True.
 
virtual void setFullyAntiSymmetric ()
 Sets an Indicial object fully anti-symmetric. Allows to set quickly a frequent property of tensors. This function then erases all properties * of symmetry / antisymmetry and sets fullyAntiSymmetric to True.
 
virtual void addSymmetry (int i1, int i2)
 Add a symmetry between the i1^{th} and the i2^{th} indices. If those indices are anti-symmetric, an error is thrown. More...
 
virtual void addAntiSymmetry (int i1, int i2)
 Add an anti-symmetry between the i1^{th} and the i2^{th} indices. If those indices are symmetric, an error is thrown. More...
 
virtual int permut (int i1, int i2)
 Tries to permut indices at place i1 and i2. If those two indices have a symmetry property, indices are swaped and the symmetry is returned. Else the fnuction does nothing and returns 0. More...
 
virtual Expr getNumericalFactor () const
 Returns the numerical factor of the expression, i.e. returns C if the expression if of the form C*x (x having a numerical factor equal to 1), and return 1 else. More...
 
virtual int getNFactor () const
 
virtual csl::vector_expr getFactors () const
 Allows to get a std::vector of all terms than could factor the expression. More...
 
virtual std::optional< ExprgetTerm () const
 This function returns the same expression as *this but amputated of its numerical factor. Example: (4*cos(x) -> cos(x)). More...
 
virtual void getExponents (std::vector< Expr > const &factors, std::vector< Expr > &exponents) const
 Fills in a vector the exponents corresponding to some factors for the expression. More...
 
virtual bool checkIndexStructure (const std::vector< Index > &t_index) const
 Checks the compatibility of the index structure of an Indicial expression with another. In a sum, two terms must have exaclty the same index structure. More...
 
virtual bool checkIndexStructure (const std::initializer_list< Index > &index) const
 Checks the compatibility of the index structure of an Indicial expression with another. In a sum, two terms must have exaclty the same index structure. More...
 
virtual bool compareWithDummy (Expr_info expr, std::map< Index, Index > &constraints, bool keepAllCosntraints=false) const
 Comparison disregarding name of dummy indices, i.e. the two expressions * are equals even if dummy indices have not the same names in *this and * expr. More...
 
bool compareWithDummy (Expr_info expr, bool keepAllCosntraints=false) const
 
virtual int getParity (Expr_info t_variable) const
 Returns the parity property of the expression with respect to t_variable. More...
 
virtual bool askTerm (Expr_info expr, bool exact=false) const
 Check if expr can factor *this. More...
 
virtual bool dependsOn (Expr_info expr) const
 Check recursively if the expression depends on expr. More...
 
virtual bool dependsOn (Parent_info parent) const
 
virtual bool dependsExplicitlyOn (Expr_info expr) const
 Check recursively if expr is present in the expression. More...
 
virtual bool dependsExplicitlyOn (Parent_info parent) const
 
virtual bool commutesWith (Expr_info expr, int sign=-1) const
 Tells if the object commutes with expr. More...
 
virtual std::optional< ExprfindSubExpression (Expr_info subExpression, const Expr &newExpression) const
 Searches a sub-expression and replaces it. More...
 
virtual int isPolynomial (Expr_info expr) const
 Determines if the expression is a mononomial term in expr, i.e. a term of the form C*expr^n with C independent of expr, n integer. More...
 
virtual bool matchShape (Expr_info expr, bool exact=false) const
 In the case of a vectorial-type expression, this function checks if the shape of expr matches itself. More...
 
virtual bool hasContractionProperty (Expr_info B) const
 Tells (for an Indicial type) if there is a special contraction property with B. More...
 
virtual bool hasChainContractionProperty () const
 
virtual std::vector< ContractionChaingetContractionProperties () const
 
virtual Expr contraction (Expr_info B) const
 Applies a special contraction of indices. Before calling this function we must check that there is indeed a contraction by calling the function hasContractionProperty(). More...
 
virtual Expr contraction (const csl::vector_expr &chain) const
 
virtual long double evaluateScalar () const
 Evaluates the value of the Abstract. More...
 
virtual std::optional< Exprevaluate (csl::eval::mode user_mode=csl::eval::base) const =0
 Evaluates the Abstract. More...
 
virtual std::optional< Exprderive (Expr_info expr) const
 Calculates the derivative of the Abstract wrt another. More...
 
virtual std::optional< Exprfactor (bool full=false) const
 Factors the Abstract. More...
 
virtual std::optional< Exprfactor (Expr_info factor, bool full=false) const
 Factors the Abstract wrt a particular Abstract. More...
 
virtual std::optional< Exprcollect (std::vector< Expr > const &factors, bool full=false) const
 Collects terms in sum according to some factors given by the user. More...
 
virtual Expr suppressTerm (Expr_info expr) const
 Remove a factor from an expr, that must have been determined before. More...
 
virtual std::optional< ExprsuppressExponent (Expr const &factor, Expr const &exponent) const
 Returns the expression where the factor factor^exponent has been suppressed. More...
 
virtual std::optional< Exprexpand (bool full=false, bool inPlace=false) const
 Develops the Abstract. More...
 
virtual std::optional< Exprexpand_if (std::function< bool(Expr const &)> const &f, bool full=false, bool inPlace=false) const
 Develops the Abstract. More...
 
virtual std::optional< ExprgetRealPart () const
 Evaluates the real part of the Abstract and returns it. More...
 
virtual Expr getImaginaryPart () const
 Evaluates the imaginary part of the Abstract and returns it. More...
 
virtual std::optional< ExprgetComplexModulus () const
 Evaluates the modulus in the complex plane of the Abstract and returns it. More...
 
virtual std::optional< ExprgetComplexArgument () const
 Evaluates the argument in the complex plane of the Abstract and returns it. More...
 
virtual std::optional< ExprgetComplexConjugate () const
 Calculates and returns the complex conjugate of the expression. More...
 
virtual ExprapplySelfStructureOn (Expr &expr) const
 
virtual std::optional< ExprgetTransposed (const Space *space, bool applyProp=true) const
 
virtual std::optional< ExprgetTransposed (const std::vector< const Space *> &spaces, bool applyProp=true) const
 
virtual std::optional< ExprgetHermitianConjugate (const Space *space) const
 
virtual std::optional< ExprgetHermitianConjugate (const std::vector< const Space *> &spaces) const
 
virtual std::optional< ExprgetPolynomialTerm (Expr_info t_variable, int order) const
 Calculates and returns the polynomial term corresponding to *this with the variable t_variable at order order. In particular, this function assumes that the checks have already been made with the function isPolynomial(). More...
 
virtual csl::vector_expr getAlternateForms () const
 Calculates and returns all possible alternate forms of the expression in terms of simplifications. For example 1-sin^2(x) is one of the alternate forms of cos^2(x). More...
 
virtual Expr applyOperator (const Expr &operand, bool leaveEmpty=false) const
 Apply the operator on an operand, iif the expression is an operator. More...
 
virtual Expr addition_own (const Expr &expr) const
 Contains implementation of special addition for Numerical- and Vectorial-types. More...
 
virtual Expr multiplication_own (const Expr &expr, bool side=1) const
 Contains implementation of special multiplication for Numerical- and Vectorial-types. More...
 
virtual Expr division_own (const Expr &expr) const
 Contains implementation of special division for Numerical- and Polynomial-types. For polynomial, the euclidean division of two polynomials is implemented. More...
 
virtual Expr exponentiation_own (const Expr &expr) const
 Contains implementation of special exponentiation for Numerical- and Vectorial-types. More...
 
virtual Expr getRegularExpression () const
 Returns a regular expression from the polynomial, that is a sum where the different powers of the variable appear explicitely. More...
 
virtual Expr tensordot (const Expr &expr) const
 Returns the tensordot of two Vectorial expressions. More...
 
virtual Expr dot (const Expr &expr) const
 Returns the dot product of two Vectorial expressions. More...
 
virtual Expr getSum () const
 Calculates and returns the sum of all elements in the Vectorial object. More...
 
virtual Expr getProduct () const
 Calculates and returns the product of all elements in the Vectorial object. More...
 
virtual Expr getVectorialModulus () const
 Returns the Vectorial modulus of the Vectorial object, that is defined here as the squared root of the sum of element squared. Example: {A_{11}^2+A_{12}^2+}. More...
 
virtual Expr getSubVectorial (int iExcept) const
 Allows to pick a part of a Vectorial expression, excluding the iExcept^{th} element. More...
 
virtual Expr getSubVectorial (int iExcept, int jExcept) const
 Allows to pick a part of a Vectorial expression, excluding the [iExcept^{th},jExcept^{th}] element (useful for matrices). More...
 
virtual Expr getSubVectorial (const std::vector< int > &exceptions) const
 Allows to pick a part of a Vectorial expression, excluding the iExcept^{th} element. More...
 
virtual Expr getSubVectorial (const std::vector< std::vector< int >> &keepIndices) const
 
virtual Expr getSubVectorial (std::vector< std::vector< int >>::const_iterator begin, std::vector< std::vector< int >>::const_iterator end) const
 
virtual Expr determinant () const
 Returns the determinant of the object if it corresponds to a square matrix (or a scalar), 0 else. More...
 
virtual Expr trace () const
 
virtual Expr trace (int axis1, int axis2) const
 Calculates the trace over the axis axis1 and axis2 of a tensor. axis1 and axis2 can be the same, in which case the trace just corresponds to the sum over this particular axis. More...
 
virtual Expr transpose () const
 Calculates and returns the transpose of a 2D matrix. More...
 
virtual Expr hermitian () const
 
virtual Expr symmetrise () const
 Calculates and returns the symmetrization of a 2D matrix. More...
 
virtual Expr antisymmetrise () const
 Calculates and returns the anti-symmetrization of a 2D matrix. More...
 
virtual Expr inverseMatrix () const
 Calculates and returns the inverse of a 2D square matrix. The applied method is: A^{-1} = 1/det(A)*Com(A)^T. More...
 
virtual Expr getCanonicalPermutation () const
 
virtual Expr applyDiracDelta (const Expr &, const Expr &) const
 
virtual void operator= (double t_value)
 Equivalent to the setValue() function. More...
 
virtual bool operator== (int t_value) const
 
virtual bool operator== (double t_value) const
 
virtual bool operator!= (int t_value) const
 
virtual bool operator!= (double t_value) const
 
virtual bool operator== (Expr_info expr) const =0
 Compares the Abstract with another. More...
 
int testDummy (Expr_info expr) const
 
bool operator== (const Expr_c &expr) const
 
bool operator== (const Expr &expr) const
 
bool operator== (const Abstract &other) const
 
bool operator!= (Expr_info expr) const
 
bool operator!= (const Expr_c &expr) const
 Compares the Abstract with another. More...
 
bool operator!= (const Expr &expr) const
 
bool operator!= (const Abstract &other) const
 
virtual Expr const & operator[] (int iArg) const
 Access operator for multi-argument expressions, equivalent to the function getArgument(). More...
 
virtual Exproperator[] (int iArg)
 Access operator for multi-argument expressions, returns a reference so this function is not const. More...
 
virtual bool operator< (Expr_info expr) const =0
 Compares the simplicity of the expression to another. More...
 
bool operator< (const Expr_c &expr) const
 Compares the simplicity of the expression to another. More...
 
bool operator> (Expr_info expr) const
 Compares the simplicity of the expression to another. More...
 
bool operator> (const Expr_c &expr) const
 
bool operator<= (Expr_info expr) const
 
bool operator>= (Expr_info expr) const
 Compares the simplicity of the expression to another. More...
 
bool operator<= (const Expr_c &expr) const
 Compares the simplicity of the expression to another. More...
 
bool operator>= (const Expr_c &expr) const
 

Static Public Member Functions

static std::string regularName (std::string const &name)
 
static std::string regularName (std::string_view name)
 
static std::string regularLiteral (std::string const &name)
 
static std::string regularLiteral (std::string_view name)
 

Detailed Description

Root class of the inheritance tree of abstracts.

Contains all functions that derived class needs. In particular all documented functions of the class Abstract are specialized in all the derived classes.

Note
Some functions are not documented here because not every derived class use them.

Constructor & Destructor Documentation

◆ Abstract()

csl::Abstract::Abstract ( )
inline

Default Constructor.

Initializes name empty and commutable to True.

Member Function Documentation

◆ addAntiSymmetry()

void csl::Abstract::addAntiSymmetry ( int  i1,
int  i2 
)
virtual

Add an anti-symmetry between the i1^{th} and the i2^{th} indices. If those indices are symmetric, an error is thrown.

Parameters
i1Position of the first index.
i2Position of the second index.

◆ addition_own()

Expr csl::Abstract::addition_own ( const Expr expr) const
virtual

Contains implementation of special addition for Numerical- and Vectorial-types.

Parameters
exprRight operrand of the addition.
Returns
The sum of the two operands.

Reimplemented in csl::Complex, csl::IntFraction, csl::Polynomial, csl::Float, csl::AbstractVectorial, csl::Integer, and csl::NumericalEval.

◆ addProperty()

void csl::Abstract::addProperty ( Equation property)
virtual

Adds a property to the object.

Parameters
propertyThe new property to add in props.

Reimplemented in csl::TensorElement, and csl::AbstractLiteral.

◆ addSymmetry()

void csl::Abstract::addSymmetry ( int  i1,
int  i2 
)
virtual

Add a symmetry between the i1^{th} and the i2^{th} indices. If those indices are anti-symmetric, an error is thrown.

Parameters
i1Position of the first index.
i2Position of the second index.

◆ antisymmetrise()

Expr csl::Abstract::antisymmetrise ( ) const
virtual

Calculates and returns the anti-symmetrization of a 2D matrix.

Returns
1/2*(A - A^T) for a matrix (2D) A.

Reimplemented in csl::Matrix, and csl::AbstractVectorial.

◆ applyOperator()

Expr csl::Abstract::applyOperator ( const Expr operand,
bool  leaveEmpty = false 
) const
virtual

Apply the operator on an operand, iif the expression is an operator.

Parameters
operandOperand of the operator.
Returns
The operator filled with operand.

◆ askTerm()

bool csl::Abstract::askTerm ( Expr_info  expr,
bool  exact = false 
) const
virtual

Check if expr can factor *this.

In almost every case this corresponds just to the comparison ** *this == expr**. For Prod, Pow, Fraction types (all that are multiplicative) we must check if the factor hides in a product.

Parameters
exprFactor to search in the expression.
Returns
True if expr is a possible factor.
False else.

Reimplemented in csl::TensorElement, csl::Pow, csl::Prod, and csl::Sum.

◆ begin() [1/2]

csl::vector_expr::iterator csl::Abstract::begin ( )
virtual
Returns
A csl::vector_expr::iterator at the beginning of argument for multi-argument expressions.

Reimplemented in csl::AbstractMultiFunc, and csl::AbstractVectorial.

◆ begin() [2/2]

csl::vector_expr::const_iterator csl::Abstract::begin ( ) const
virtual
Returns
A csl::vector_expr::iterator at the beginning of argument for multi-argument expressions.

Reimplemented in csl::AbstractMultiFunc, and csl::AbstractVectorial.

◆ checkIndexStructure() [1/2]

virtual bool csl::Abstract::checkIndexStructure ( const std::vector< Index > &  t_index) const
virtual

Checks the compatibility of the index structure of an Indicial expression with another. In a sum, two terms must have exaclty the same index structure.

Parameters
t_indexA std::vector of Index to compare.
Returns
True if the two structures match.
False else.

Reimplemented in csl::TensorElement.

◆ checkIndexStructure() [2/2]

virtual bool csl::Abstract::checkIndexStructure ( const std::initializer_list< Index > &  index) const
virtual

Checks the compatibility of the index structure of an Indicial expression with another. In a sum, two terms must have exaclty the same index structure.

Parameters
t_indexA std::initializer_list of Index to compare.
Returns
True if the two structures match.
False else.

◆ collect()

optional< Expr > csl::Abstract::collect ( std::vector< Expr > const &  factors,
bool  full = false 
) const
virtual

Collects terms in sum according to some factors given by the user.

This function allows the factor with some specific scalar variables. For example, $ ax + ay + by $ can be factored in two ways. Either with $ (a, b) $ which gives $ a(x+y) + by $ ; or with $ (x, y) $ which gives $ ax + (a+b)y $. With the collect function it is possible to choose precisely the set of variables that will be factored to express results in a standard way.

Parameters
factorsFactors to search in the expression.
fullBoolean (default = false) that tells if the collection must be recursive (full expression depth).
Returns
The collected expression if modifications have been done.
std::nullopt else.
Note
This function will probably replace the factor() function in the future.
For now, the collect function does not support factorization by indicial tensors, whereas factor() does.

Reimplemented in csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::Sum, and csl::AbstractFunc.

◆ commutesWith()

bool csl::Abstract::commutesWith ( Expr_info  expr,
int  sign = -1 
) const
virtual

Tells if the object commutes with expr.

Parameters
expr
Returns
True if *this commutes with expr.
False else.

Reimplemented in csl::AbstractMultiFunc, csl::AbstractDuoFunc, csl::Variable, csl::TensorFieldElement, csl::AbstractFunc, csl::ScalarField, csl::AbstractVectorial, and csl::AbstractBuildingBlock.

◆ compareWithDummy()

virtual bool csl::Abstract::compareWithDummy ( Expr_info  expr,
std::map< Index, Index > &  constraints,
bool  keepAllCosntraints = false 
) const
virtual

Comparison disregarding name of dummy indices, i.e. the two expressions * are equals even if dummy indices have not the same names in *this and * expr.

Parameters
exprExpression to compare.
constraintsList of existing constraints between indices (it is modified in the function).
Returns
True if expr == *this taking constraints into account.
False else.

Reimplemented in csl::IProd, csl::ISum, csl::TensorElement, csl::TDerivativeElement, csl::VectorIntegral, csl::TensorFieldElement, csl::AbstractFunc, and csl::Scalar.

◆ contraction()

Expr csl::Abstract::contraction ( Expr_info  B) const
virtual

Applies a special contraction of indices. Before calling this function we must check that there is indeed a contraction by calling the function hasContractionProperty().

Parameters
BExpression with which *this contracts.
Returns
The result of the contraction.

Reimplemented in csl::TensorElement.

◆ dependsExplicitlyOn()

bool csl::Abstract::dependsExplicitlyOn ( Expr_info  expr) const
virtual

Check recursively if expr is present in the expression.

Parameters
exprExpression to search.
Returns
True if expr is found.
False else.

Reimplemented in csl::TensorElement, csl::Integral, csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::TensorFieldElement, csl::AbstractFunc, csl::AbstractIntegral, csl::AbstractVectorial, csl::AbstractField, and csl::AbstractNumerical.

◆ dependsOn()

bool csl::Abstract::dependsOn ( Expr_info  expr) const
virtual

Check recursively if the expression depends on expr.

Parameters
exprExpression to search.
Returns
True if a dependency in expr is found.
False else.

Reimplemented in csl::TensorElement, csl::Integral, csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::Variable, csl::TensorFieldElement, csl::AbstractFunc, csl::AbstractIntegral, csl::Constant, csl::AbstractVectorial, csl::AbstractField, and csl::AbstractNumerical.

◆ derive()

optional< Expr > csl::Abstract::derive ( Expr_info  expr) const
virtual

Calculates the derivative of the Abstract wrt another.

It is possible to derive wrt any complicated expr. In this case however, the calculation is not always mathematically correct. The program just searches for equal Abstract or Abstract with the same name. In particular dx/d(exp(x))=0.

Parameters
exprExpression wrt which we derive.
Returns
The derivative.

Reimplemented in csl::DiracDelta, csl::Factorial, csl::ATanh, csl::ASinh, csl::ACosh, csl::Tanh, csl::Sinh, csl::TensorElement, csl::Cosh, csl::Angle, csl::Integral, csl::ATan, csl::Derivative, csl::ASin, csl::ACos, csl::Pow, csl::Tan, csl::Imaginary, csl::Complex, csl::Prod, csl::Sin, csl::IntFactorial, csl::IntFraction, csl::Cos, csl::Variable, csl::Log, csl::Polynomial, csl::Float, csl::Exp, csl::Constant, csl::Integer, csl::AbstractIntegral, csl::Sum, csl::Commutator, csl::NumericalEval, and csl::Abs.

◆ determinant()

Expr csl::Abstract::determinant ( ) const
virtual

Returns the determinant of the object if it corresponds to a square matrix (or a scalar), 0 else.

Returns
det(*this) if *this is a square matrix or scalar.
0 else.

Reimplemented in csl::Matrix.

◆ division_own()

Expr csl::Abstract::division_own ( const Expr expr) const
virtual

Contains implementation of special division for Numerical- and Polynomial-types. For polynomial, the euclidean division of two polynomials is implemented.

Parameters
exprRight operrand of the division.
Returns
The division of the two operands.

Reimplemented in csl::Complex, csl::IntFraction, csl::Polynomial, csl::Float, csl::Integer, and csl::NumericalEval.

◆ dot()

Expr csl::Abstract::dot ( const Expr expr) const
virtual

Returns the dot product of two Vectorial expressions.

Parameters
exprThe right operand of the dot product.
Returns
sum _k (*this)[i,j,...,k]*expr[k,l,m,...].

Reimplemented in csl::AbstractVectorial.

◆ end() [1/2]

csl::vector_expr::iterator csl::Abstract::end ( )
virtual
Returns
A csl::vector_expr::iterator at the end of argument for multi-argument expressions.

Reimplemented in csl::AbstractMultiFunc, and csl::AbstractVectorial.

◆ end() [2/2]

csl::vector_expr::const_iterator csl::Abstract::end ( ) const
virtual
Returns
A csl::vector_expr::iterator at the end of argument for multi-argument expressions.

Reimplemented in csl::AbstractMultiFunc, and csl::AbstractVectorial.

◆ evaluate()

virtual std::optional<Expr> csl::Abstract::evaluate ( csl::eval::mode  user_mode = csl::eval::base) const
pure virtual

◆ evaluateScalar()

long double csl::Abstract::evaluateScalar ( ) const
virtual

Evaluates the value of the Abstract.

Tries to replace all variables by a real value. If it is not possible (for example treating a Vector or an Imaginary) the considered object is replaced by 0. A warning message is displayed in the case of i.

Returns
The value of the Abstract (double).

Reimplemented in csl::Factorial, csl::ATanh, csl::ASinh, csl::ACosh, csl::Tanh, csl::Sinh, csl::Cosh, csl::Angle, csl::ATan, csl::Derivative, csl::ASin, csl::ACos, csl::Pow, csl::Tan, csl::Imaginary, csl::Complex, csl::Sin, csl::Prod, csl::IntFactorial, csl::Cos, csl::IntFraction, csl::Variable, csl::Log, csl::Polynomial, csl::Float, csl::Exp, csl::Constant, csl::Integer, csl::Commutator, csl::Sum, csl::Abs, and csl::NumericalEval.

◆ expand()

optional< Expr > csl::Abstract::expand ( bool  full = false,
bool  inPlace = false 
) const
virtual

Develops the Abstract.

This function concerns only products (and exponents) that will be flatten to give at the end a sum of independant terms.

Parameters
fullIf true the expandment is recursive through all the Abstract.
Returns
The expand Abstract.

Reimplemented in csl::Pow, csl::AbstractMultiFunc, csl::Prod, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::Exp, csl::AbstractVectorial, csl::AbstractFunc, and csl::AbstractBuildingBlock.

◆ expand_if()

optional< Expr > csl::Abstract::expand_if ( std::function< bool(Expr const &)> const &  f,
bool  full = false,
bool  inPlace = false 
) const
virtual

Develops the Abstract.

This function concerns only products (and exponents) that will be flatten to give at the end a sum of independant terms.

Parameters
fFunctions that returns a boolean that determines which arguments must be expanded in products.
fullIf true the expandment is recursive through all the Abstract.
Returns
The expand Abstract.

Reimplemented in csl::Pow, csl::AbstractMultiFunc, csl::Prod, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::Exp, csl::AbstractVectorial, and csl::AbstractFunc.

◆ exponentiation_own()

Expr csl::Abstract::exponentiation_own ( const Expr expr) const
virtual

Contains implementation of special exponentiation for Numerical- and Vectorial-types.

Parameters
exprexponent.
Returns
The exponentiation of the two operands.

Reimplemented in csl::Complex, csl::IntFraction, csl::Float, csl::Integer, and csl::NumericalEval.

◆ factor() [1/2]

optional< Expr > csl::Abstract::factor ( bool  full = false) const
virtual

Factors the Abstract.

This function tries to factor the Abstract wrt any factor. This will be more involved in calculation than the other factorizing function that takes the factor as a parameter. So this function must be used only if we don't know the factors we want at the end.

Parameters
fullIf true the factorization is recursive through all the Abstract.

Reimplemented in csl::ISum, csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::Polynomial, csl::AbstractVectorial, csl::Sum, csl::AbstractFunc, and csl::AbstractBuildingBlock.

◆ factor() [2/2]

optional< Expr > csl::Abstract::factor ( Expr_info  factor,
bool  full = false 
) const
virtual

Factors the Abstract wrt a particular Abstract.

Parameters
factorAbstract wrt which we try to factor.
fullIf true the factorization is recursive through all the Abstract.

Reimplemented in csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::AbstractVectorial, csl::Sum, csl::AbstractFunc, and csl::AbstractBuildingBlock.

◆ findSubExpression()

optional< Expr > csl::Abstract::findSubExpression ( Expr_info  subExpression,
const Expr newExpression 
) const
virtual

Searches a sub-expression and replaces it.

Parameters
subExpressionExpression to search.
newExpressionExpression that replaces subExpression if it is found.
Returns
The expression with the replacement done.

Reimplemented in csl::AbstractMultiFunc, csl::Prod, csl::AbstractDuoFunc, csl::AbstractFunc, and csl::AbstractBuildingBlock.

◆ getAlternateForms()

csl::vector_expr csl::Abstract::getAlternateForms ( ) const
virtual

Calculates and returns all possible alternate forms of the expression in terms of simplifications. For example 1-sin^2(x) is one of the alternate forms of cos^2(x).

Those alternate forms are then compared in terms of simplicity, this allows automatic simplification. Alternates are tried to simplify, and the bests are chosed. More details and algorithms in file alternateForms.cpp.

Returns
A std::vector containing the alternate forms of the expression.

Reimplemented in csl::Tanh, csl::Sinh, csl::TensorElement, csl::Cosh, csl::Pow, csl::Tan, csl::Prod, csl::Sin, csl::Cos, and csl::Sum.

◆ getArgument() [1/2]

Expr const & csl::Abstract::getArgument ( int  iArg = 0) const
virtual
Warning
This function must not be called for building blocks, one must check first that the expression has arguments.
Returns
The i^{th} argument of the expression.

Reimplemented in csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::AbstractVectorial, and csl::AbstractFunc.

◆ getArgument() [2/2]

virtual Expr const& csl::Abstract::getArgument ( const std::vector< int > &  indices) const
virtual

Allows to get specific arguments of expressions in multiple dimensions, by giving the indices in each dimension.

Warning
This function must not be called for building blocks, one must check first that the expression has arguments.
Returns
The argument {i,j,...} of the expression.

Reimplemented in csl::AbstractVectorial.

◆ getCommutable()

bool csl::Abstract::getCommutable ( ) const
virtual

Allows to know if the object commutes with all the others.

Returns
commutable

Reimplemented in csl::AbstractMultiFunc, csl::AbstractDuoFunc, csl::Variable, csl::Constant, csl::AbstractElement, and csl::AbstractFunc.

◆ getComplexArgument()

optional< Expr > csl::Abstract::getComplexArgument ( ) const
virtual

Evaluates the argument in the complex plane of the Abstract and returns it.

Returns
The argument part of the Abstract.

Reimplemented in csl::DiracDelta, csl::Tanh, csl::Sinh, csl::Cosh, csl::ASin, csl::ACos, csl::Tan, csl::Complex, csl::Imaginary, csl::AbstractMultiFunc, csl::Sin, csl::Prod, csl::Cos, csl::AbstractDuoFunc, csl::Log, csl::Exp, csl::AbstractFunc, and csl::Sum.

◆ getComplexConjugate()

optional< Expr > csl::Abstract::getComplexConjugate ( ) const
virtual

Calculates and returns the complex conjugate of the expression.

Returns
{*this}.

Reimplemented in csl::TensorElement, csl::Complex, csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::ImaginaryPart, csl::AbstractFunc, csl::AbstractVectorial, csl::Complexified, and csl::RealPart.

◆ getComplexModulus()

optional< Expr > csl::Abstract::getComplexModulus ( ) const
virtual

◆ getContractedPair()

set< pair< int, int > > csl::Abstract::getContractedPair ( ) const
virtual
Returns
All contracted pairs of indices of an Indicial expression.
Warning
This function is not yet well implemented and may not be useful in the future.

◆ getDenom()

long long int csl::Abstract::getDenom ( ) const
virtual
Returns
The denominator for a IntFraction.

Reimplemented in csl::IntFraction.

◆ getDim()

int csl::Abstract::getDim ( ) const
virtual

Gives the dimension of the object.

Allows to know if we are manipulating a pure scalar (i.e. that can have a real value) or something else. There is the particular case of the Imaginary i that is considered as a scalar for simplicity but in reality cannot be evaluated with a real. Example: 1 + i cannot be reduced.

Returns
dim (a non memorized integer corresponding to the dimension of the abstract)

Reimplemented in csl::AbstractVectorial.

◆ getExponents()

void csl::Abstract::getExponents ( std::vector< Expr > const &  factors,
std::vector< Expr > &  exponents 
) const
virtual

Fills in a vector the exponents corresponding to some factors for the expression.

For example, an expression like $ 2ax^2\cos y $ will have exponents $ (1, 2, 0) $ for the set of factors $ (a, x, y). $ factors and exponents must of course be of the same size. Otherwise the behaviour is undefined.

Note
This function assumes that the expression is canonical, in particular that no terms like $ x\cdot x^2 $ can appear.
This function does not take into account factors in sums like $ (1 + x) $ (this will return a factor 0 for $ x $).
Parameters
factorsFactors.
exponentsExponents (out variable, modified during the run).

Reimplemented in csl::Pow, and csl::Prod.

◆ getFactors()

csl::vector_expr csl::Abstract::getFactors ( ) const
virtual

Allows to get a std::vector of all terms than could factor the expression.

Returns
A std::vector containing the possible factors of *this.

Reimplemented in csl::Pow, csl::Prod, and csl::Sum.

◆ getFreeIndexStructure()

IndexStructure csl::Abstract::getFreeIndexStructure ( ) const
virtual
Returns
The free index structure of the Indicial expression

◆ getImaginaryPart()

Expr csl::Abstract::getImaginaryPart ( ) const
virtual

◆ getIndex()

Index csl::Abstract::getIndex ( int  i = 0) const
virtual
Parameters
iSpot of the index to get.
Returns
the i^{th} index of an Indicial expression.

Reimplemented in csl::TensorElement.

◆ getIndexStructure()

IndexStructure csl::Abstract::getIndexStructure ( ) const
virtual

◆ getName()

std::string const & csl::Abstract::getName ( ) const
virtual

Returns the Abstract's name.

Returns
name

Reimplemented in csl::Variable, csl::Constant, csl::AbstractElement, csl::Arbitrary, and csl::AbstractVectorial.

◆ getNArgs()

int csl::Abstract::getNArgs ( int  axis = 0) const
virtual

Returns the number of arguments of the expression. If the expression is a building block (AbstractBuildingBlock), this function returns 0.

Returns
The number of arguments of the expression.

Reimplemented in csl::AbstractMultiFunc, csl::AbstractDuoFunc, csl::AbstractFunc, and csl::AbstractVectorial.

◆ getNContractedPairs()

int csl::Abstract::getNContractedPairs ( ) const
virtual

Returns the number of contracted pairs of indices in an Indicial expression.

Returns
The number of contracted pairs of indices.

◆ getNFactor()

int csl::Abstract::getNFactor ( ) const
virtual
Returns
The number of possible factors for the expression

Reimplemented in csl::Pow, and csl::Prod.

◆ getNIndices()

int csl::Abstract::getNIndices ( ) const
virtual
Returns
The number of indices of an Indicial expression.

Reimplemented in csl::TensorElement.

◆ getNum()

long long int csl::Abstract::getNum ( ) const
virtual
Returns
The numerator for a IntFraction.

Reimplemented in csl::IntFraction, and csl::Arbitrary.

◆ getNumericalFactor()

Expr csl::Abstract::getNumericalFactor ( ) const
virtual

Returns the numerical factor of the expression, i.e. returns C if the expression if of the form C*x (x having a numerical factor equal to 1), and return 1 else.

Note
This function returns the factor in an Expression (then of Numerical type).
Returns
The numerical factor in front of the expression.

Reimplemented in csl::Pow, csl::Prod, csl::Sum, and csl::AbstractNumerical.

◆ getOperand()

Expr csl::Abstract::getOperand ( ) const
virtual

Returns the operand of an Operator.

Returns
operand of an Operator.

Reimplemented in csl::Integral, csl::Derivative, csl::TDerivativeElement, csl::AbstractIntegral, csl::ImaginaryPart, and csl::RealPart.

◆ getOrder()

int csl::Abstract::getOrder ( ) const
virtual

Accessor to the order (integer) that defines certain types of expressions.

Returns
order.

Reimplemented in csl::Derivative, and csl::Polynomial.

◆ getParent()

Parent csl::Abstract::getParent ( ) const
virtual

For indicial expressions this function returns a pointer to the parent object of type TensorParent (not an expression).

Returns
parent for TensorElement-type expression.

Reimplemented in csl::VectorIntegral, csl::Variable, csl::Constant, and csl::AbstractElement.

◆ getParity()

int csl::Abstract::getParity ( Expr_info  t_variable) const
virtual

Returns the parity property of the expression with respect to t_variable.

Parameters
t_variable.
Returns
1 if the expression is even in t_variable.
-1 if the expression is odd in t_variable.
0 else.

Reimplemented in csl::DiracDelta, csl::Factorial, csl::ATanh, csl::ASinh, csl::ACosh, csl::Tanh, csl::Sinh, csl::Cosh, csl::Angle, csl::Integral, csl::ATan, csl::Derivative, csl::ASin, csl::Pow, csl::ACos, csl::Tan, csl::Prod, csl::Sin, csl::Cos, csl::Variable, csl::Log, csl::Polynomial, csl::Exp, csl::Constant, csl::Sum, csl::Commutator, and csl::Abs.

◆ getPermutations()

csl::vector_expr csl::Abstract::getPermutations ( bool  optimize = true) const
virtual

Returns a std::vector of all possible permutations of an Indicial expression. The possible permutations are determined from the posible symmetries and anti-symmetries of the object.

Returns
A std::vector containing all possible permutations of the tensor.

Reimplemented in csl::TensorElement.

◆ getPolynomialTerm()

optional< Expr > csl::Abstract::getPolynomialTerm ( Expr_info  t_variable,
int  order 
) const
virtual

Calculates and returns the polynomial term corresponding to *this with the variable t_variable at order order. In particular, this function assumes that the checks have already been made with the function isPolynomial().

Parameters
t_variableVariable of the polynomial. Order of *this in t_variable.
Returns
The same expression as (*this) with the term t_variable^order removed.

Reimplemented in csl::Pow, csl::Prod, csl::AbstractElement, and csl::AbstractBuildingBlock.

◆ getPrimaryType()

virtual csl::PrimaryType csl::Abstract::getPrimaryType ( ) const
pure virtual

Gives the primary type of Abstract.

In the program this function is very often called. It allows different functions to know what type of expr they are manipulating (single number, scalar function with one argument, with multiple argumments, a Vector, etc) in order to do special treatments or simplifications.

Returns
type (a non memorized integer corresponding to the type of abstract)

Implemented in csl::TensorElement, csl::Imaginary, csl::AbstractMultiFunc, csl::IntFactorial, csl::AbstractDuoFunc, csl::Variable, csl::TensorFieldElement, csl::Constant, csl::AbstractField, csl::AbstractVectorial, csl::Arbitrary, csl::AbstractFunc, csl::AbstractLiteral, and csl::AbstractNumerical.

◆ getProduct()

Expr csl::Abstract::getProduct ( ) const
virtual

Calculates and returns the product of all elements in the Vectorial object.

Returns
The product of all elements.

Reimplemented in csl::AbstractVectorial.

◆ getProperties()

const vector< Equation * > & csl::Abstract::getProperties ( ) const
virtual
Returns
The properties of the object.

Reimplemented in csl::TensorElement, and csl::AbstractLiteral.

◆ getRealPart()

optional< Expr > csl::Abstract::getRealPart ( ) const
virtual

◆ getRegularExpression()

Expr csl::Abstract::getRegularExpression ( ) const
virtual

Returns a regular expression from the polynomial, that is a sum where the different powers of the variable appear explicitely.

Returns
a Sum expression equal to the polynomial.

Reimplemented in csl::Polynomial.

◆ getShape()

vector< int > csl::Abstract::getShape ( ) const
virtual

Accessor to the shape of the tensor in the form of a std::vector of integers.

Returns
shape.

Reimplemented in csl::AbstractVectorial.

◆ getSign()

int csl::Abstract::getSign ( ) const
virtual
Returns
The sign for a Commutator type expression.

Reimplemented in csl::Commutator.

◆ getSubVectorial() [1/3]

Expr csl::Abstract::getSubVectorial ( int  iExcept) const
virtual

Allows to pick a part of a Vectorial expression, excluding the iExcept^{th} element.

Parameters
iExceptElement to ignore.
Returns
The part of *this excluding iExcept.

Reimplemented in csl::Vector.

◆ getSubVectorial() [2/3]

Expr csl::Abstract::getSubVectorial ( int  iExcept,
int  jExcept 
) const
virtual

Allows to pick a part of a Vectorial expression, excluding the [iExcept^{th},jExcept^{th}] element (useful for matrices).

Parameters
iExceptElement of the first axis to ignore.
jExceptElement of the second axis to ignore.
Returns
The part of *this excluding iExcept.

Reimplemented in csl::Matrix.

◆ getSubVectorial() [3/3]

virtual Expr csl::Abstract::getSubVectorial ( const std::vector< int > &  exceptions) const
virtual

Allows to pick a part of a Vectorial expression, excluding the iExcept^{th} element.

Parameters
iExceptElement to ignore.
Returns
The part of *this excluding iExcept.

Reimplemented in csl::AbstractVectorial.

◆ getSum()

Expr csl::Abstract::getSum ( ) const
virtual

Calculates and returns the sum of all elements in the Vectorial object.

Returns
The sum of all elements.

Reimplemented in csl::AbstractVectorial.

◆ getTerm()

std::optional< Expr > csl::Abstract::getTerm ( ) const
virtual

This function returns the same expression as *this but amputated of its numerical factor. Example: (4*cos(x) -> cos(x)).

Returns
The term without numerical factor corresponding to *this.

Reimplemented in csl::Pow, csl::Prod, csl::Sum, csl::AbstractNumerical, and csl::AbstractBuildingBlock.

◆ getType()

virtual csl::Type csl::Abstract::getType ( ) const
pure virtual

◆ getValue()

long double csl::Abstract::getValue ( ) const
virtual

Returns the value of the expression, if it has one explicitely. In particular, it will work only on Numbers and valued Literals, not on functions.

Returns
The value of the expression.

Reimplemented in csl::IntFactorial, csl::Variable, csl::Constant, and csl::NumericalEval.

◆ getValued()

bool csl::Abstract::getValued ( ) const
virtual

Tells if the expression is valued, i.e. is a function of numbers and valued literals (a Variable or Constant is not valued by default).

Returns
True if the expression is valued.
False else.

Reimplemented in csl::Variable, and csl::Constant.

◆ getVariable()

Expr csl::Abstract::getVariable ( ) const
virtual

Accessor to the variable that defines certain types of expressions.

Returns
variable.

Reimplemented in csl::Integral, csl::Derivative, csl::VectorIntegral, csl::Polynomial, and csl::ScalarIntegral.

◆ getVectorArgument()

const csl::vector_expr & csl::Abstract::getVectorArgument ( ) const
virtual

Allows to get the entire std::vector of arguments of the expression.

Warning
This function must not be called for building blocks, one must check first that the expression has arguments.
Returns
The std::vector of argument.

Reimplemented in csl::AbstractMultiFunc, and csl::AbstractVectorial.

◆ getVectorialModulus()

Expr csl::Abstract::getVectorialModulus ( ) const
virtual

Returns the Vectorial modulus of the Vectorial object, that is defined here as the squared root of the sum of element squared. Example: {A_{11}^2+A_{12}^2+}.

Returns
The vectorial modulus of the expression.

Reimplemented in csl::AbstractVectorial.

◆ hasContractionProperty()

bool csl::Abstract::hasContractionProperty ( Expr_info  B) const
virtual

Tells (for an Indicial type) if there is a special contraction property with B.

Parameters
BExpression with which we test if there is a special contraction.
Returns
True if there is a contraction.
False else.

Reimplemented in csl::TensorElement.

◆ insert()

void csl::Abstract::insert ( const Expr expr,
bool  side = 1 
)
virtual

Inserts an expression in a sum or a product.

Allows to insert an element in a sum or product without comparing all existing terms. This saves time when inserting element by element. The side parameter allows to insert to the left (side = 0) or to the right (side = 1) in products (useful when considering non commutating expressions.

Parameters
exprExpression to insert.
sideSide of insertion for Prod expressions.

Reimplemented in csl::Prod, and csl::Sum.

◆ inverseMatrix()

Expr csl::Abstract::inverseMatrix ( ) const
virtual

Calculates and returns the inverse of a 2D square matrix. The applied method is: A^{-1} = 1/det(A)*Com(A)^T.

Returns
A^{-1} for a matrix (2D) A if det(A) != 0.
0 else

Reimplemented in csl::Matrix.

◆ isAnOperator()

bool csl::Abstract::isAnOperator ( ) const
virtual

Tells if the expression is an operator (like a derivetive operator).

Returns
True if the expression is an Operator.
False else.

◆ isBuildingBlock()

bool csl::Abstract::isBuildingBlock ( ) const
virtual

Tells if the expression is a Building Block or not.

Building blocks are derived classes that cannot contain further expressions, i.e. expressions that are the leafs of the recursive tree reprensent mathematical expressions: numerical or pure literal objects (variable, constant etc).

Returns
True if *this is a Building Block.
False else.

Reimplemented in csl::AbstractBuildingBlock.

◆ isEmpty()

bool csl::Abstract::isEmpty ( ) const
virtual

Tells for a Derivative or an Integral if the argument is empty i.e. if the object must apply on the next argument encountered on the right.

Returns
True if the Derivative or Integral awaits an argument.
False else.

◆ isIndexed()

bool csl::Abstract::isIndexed ( ) const
virtual

◆ isInteger()

bool csl::Abstract::isInteger ( ) const
virtual

Tells if the expression is an integer. Either an Integer object directly, or a Float that has an integer value.

Returns
True if *this is an Integer or a Float with integer value.
False else.

Reimplemented in csl::Float, and csl::Integer.

◆ isPolynomial()

int csl::Abstract::isPolynomial ( Expr_info  expr) const
virtual

Determines if the expression is a mononomial term in expr, i.e. a term of the form C*expr^n with C independent of expr, n integer.

Parameters
exprVariable of the supposed mononomial.
Returns
The order of the exponent if there is one (n in the example).
-1 else.

Reimplemented in csl::Pow, csl::AbstractMultiFunc, csl::Prod, csl::AbstractDuoFunc, csl::AbstractFunc, and csl::AbstractElement.

◆ matchShape()

bool csl::Abstract::matchShape ( Expr_info  expr,
bool  exact = false 
) const
virtual

In the case of a vectorial-type expression, this function checks if the shape of expr matches itself.

If exact is true, the function search an exact match i.e. either the two shapes are exactly equal or one of the two objects is a scalar. If exact is false, this function only search for a possible dot product between the two expressions, and see if the last axis of *this matches the first of expr (or if one of the two objects is scalar also). Then, a product _k (*this)[i,j,...,k]*expr[k,l,m,...] is possible.

Parameters
exprExpression of which we compare the shape.
exactBoolean than specifies if we need an exact match or not.
Returns
True if the two shapes correspond.
False else.

Reimplemented in csl::AbstractVectorial.

◆ multiplication_own()

Expr csl::Abstract::multiplication_own ( const Expr expr,
bool  side = 1 
) const
virtual

Contains implementation of special multiplication for Numerical- and Vectorial-types.

Parameters
exprRight operrand of the product.
Returns
The product of the two operands.

Reimplemented in csl::Complex, csl::IntFraction, csl::Polynomial, csl::Float, csl::AbstractVectorial, csl::Integer, and csl::NumericalEval.

◆ operator!=() [1/3]

bool csl::Abstract::operator!= ( int  t_value) const
virtual
Returns
False if the expression is valued and is equal to t_value.
True else.

◆ operator!=() [2/3]

bool csl::Abstract::operator!= ( double  t_value) const
virtual
Returns
False if the expression is valued and is equal to t_value.
True else.

◆ operator!=() [3/3]

bool csl::Abstract::operator!= ( const Expr_c expr) const
inline

Compares the Abstract with another.

Parameters
exprAbstract to compare.
Returns
False if the two Abstracts are the same (or have the same name).
True else.

◆ operator<() [1/2]

virtual bool csl::Abstract::operator< ( Expr_info  expr) const
pure virtual

Compares the simplicity of the expression to another.

Parameters
exprExpression to compare.
Returns
False if expr is simpler or equivalent.
True else.

Implemented in csl::AbstractMultiFunc, csl::AbstractDuoFunc, and csl::Scalar.

◆ operator<() [2/2]

bool csl::Abstract::operator< ( const Expr_c expr) const
inline

Compares the simplicity of the expression to another.

Parameters
exprExpression to compare.
Returns
False if expr is simpler or equivalent.
True else.

◆ operator<=()

bool csl::Abstract::operator<= ( const Expr_c expr) const
inline

Compares the simplicity of the expression to another.

Parameters
exprExpression to compare.
Returns
False if expr is simpler.
True else.

◆ operator=()

void csl::Abstract::operator= ( double  t_value)
virtual

Equivalent to the setValue() function.

Parameters
t_valueThe new value of the expression.

Reimplemented in csl::IntFraction, csl::Variable, csl::Float, and csl::Constant.

◆ operator==() [1/3]

bool csl::Abstract::operator== ( int  t_value) const
virtual
Returns
True if the expression is valued and is equal to t_value.
False else.

◆ operator==() [2/3]

bool csl::Abstract::operator== ( double  t_value) const
virtual
Returns
True if the expression is valued and is equal to t_value.
False else.

◆ operator==() [3/3]

virtual bool csl::Abstract::operator== ( Expr_info  expr) const
pure virtual

Compares the Abstract with another.

Here if two Abstracts have the same name, the function will return true even if they are not mathematically equal. So beware not to name different things the same way.

Parameters
exprAbstract to compare.
Returns
True if the two Abstracts are the same (or have the same name).
False else.

Implemented in csl::DiracDelta, csl::IProd, csl::ISum, csl::TensorElement, csl::Angle, csl::Integral, csl::Derivative, csl::Pow, csl::Imaginary, csl::Complex, csl::Prod, csl::IntFactorial, csl::TDerivativeElement, csl::IntFraction, csl::Variable, csl::VectorIntegral, csl::Polynomial, csl::Float, csl::TensorFieldElement, csl::ScalarIntegral, csl::AbstractVectorial, csl::AbstractFunc, csl::Constant, csl::Sum, csl::Integer, csl::ScalarField, csl::Commutator, csl::ImaginaryPart, csl::NumericalEval, csl::Complexified, csl::Arbitrary, csl::RealPart, and csl::Scalar.

◆ operator>()

bool csl::Abstract::operator> ( Expr_info  expr) const
inline

Compares the simplicity of the expression to another.

Parameters
exprExpression to compare.
Returns
True if expr is simpler.
False else.

◆ operator>=()

bool csl::Abstract::operator>= ( Expr_info  expr) const
inline

Compares the simplicity of the expression to another.

Parameters
exprExpression to compare.
Returns
True if expr is simpler or equivalent.
False else.

◆ operator[]() [1/2]

Expr const & csl::Abstract::operator[] ( int  iArg) const
virtual

Access operator for multi-argument expressions, equivalent to the function getArgument().

Parameters
iArgIndex of the argument to get.
Returns
argument[iArg].

Reimplemented in csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::AbstractVectorial, and csl::AbstractFunc.

◆ operator[]() [2/2]

Expr & csl::Abstract::operator[] ( int  iArg)
virtual

Access operator for multi-argument expressions, returns a reference so this function is not const.

Parameters
iArgIndex of the argument to get.
Returns
A reference to argument[iArg].

Reimplemented in csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::AbstractVectorial, and csl::AbstractFunc.

◆ permut()

int csl::Abstract::permut ( int  i1,
int  i2 
)
virtual

Tries to permut indices at place i1 and i2. If those two indices have a symmetry property, indices are swaped and the symmetry is returned. Else the fnuction does nothing and returns 0.

Parameters
i1Position of the first index.
i2Position of the second index.
Returns
1 if the permutation **(i1,i2) is symmetric**.
-1 if the permutation **(i1,i2) is anti-symmetric**.
0 else (and do not permut the two indices).

◆ print()

virtual void csl::Abstract::print ( int  mode = 0,
std::ostream &  out = std::cout,
bool  lib = false 
) const
pure virtual

◆ printExplicit()

void csl::Abstract::printExplicit ( int  mode = 0) const

Displays explicitely the expression, with types of each component. This function is only used for debug.

Parameters
modeMode of printing.

◆ printLaTeX()

string csl::Abstract::printLaTeX ( int  mode = 0) const
virtual

◆ removeProperty()

void csl::Abstract::removeProperty ( Equation property)
virtual

Removes a property to the object.

Parameters
propertyProperty to remove from props.

Reimplemented in csl::TensorElement, and csl::AbstractLiteral.

◆ replaceIndex()

optional< Expr > csl::Abstract::replaceIndex ( const Index indexToReplace,
const Index newIndex,
bool  refresh = true 
) const
virtual

For indicial expressions, this function searches indexToContract and replaces it with newIndex.

Parameters
indexToContractIndex that is newly contracted.
newIndexDummy new index that replaces indexToContract in the expression.
Returns
True if the index has been found.
False else.

Reimplemented in csl::IProd, csl::ISum, csl::TensorElement, csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, and csl::AbstractFunc.

◆ setArgument() [1/2]

void csl::Abstract::setArgument ( const Expr expr,
int  iArg = 0 
)
virtual

Sets the argument at position iArg (default=0).

Parameters
exprExpression that replaces the argument.
iArgthe position of the argument to change.

Reimplemented in csl::IProd, csl::AbstractMultiFunc, csl::TDerivativeElement, csl::AbstractDuoFunc, csl::AbstractVectorial, and csl::AbstractFunc.

◆ setArgument() [2/2]

virtual void csl::Abstract::setArgument ( const Expr expr,
const std::vector< int > &  indices 
)
virtual

Sets the argument at position {i,j,...} for multi-dimensions expressions.

Parameters
exprExpression that replaces the argument.
indicesAn std::vector containing the series of indices corresponding to the argument to replace.

Reimplemented in csl::AbstractVectorial.

◆ setCommutable()

void csl::Abstract::setCommutable ( bool  t_commutable)
virtual

Allows the abstract to commute or not.

Parameters
t_commutableMust be true if the abstract can commute.

Reimplemented in csl::Variable, csl::Constant, and csl::AbstractElement.

◆ setIndexStructure()

void csl::Abstract::setIndexStructure ( const IndexStructure t_index)
virtual

Replaces the index structure of the object, that must be an Indicial expression.

Parameters
t_indexA std::vector of Index which takes the place of the structure index.

Reimplemented in csl::TensorElement, and csl::TDerivativeElement.

◆ setName()

void csl::Abstract::setName ( const std::string &  t_name)
virtual

Change the name of the abstract.

Parameters
t_nameReplaces name.

Reimplemented in csl::Variable, csl::Constant, and csl::AbstractElement.

◆ setOperand()

void csl::Abstract::setOperand ( const Expr operand)
virtual

Sets the operand of an operator.

Parameters
operandNew operand.

Reimplemented in csl::Integral, csl::Derivative, csl::TDerivativeElement, csl::AbstractIntegral, csl::ImaginaryPart, and csl::RealPart.

◆ setOperandPrivate()

void csl::Abstract::setOperandPrivate ( const Expr operand,
bool  leaveEmpty 
)
virtual

Sets the operand of an operator.

Parameters
operandNew operand.
leaveEmptyBoolean that tells if the operator must stay empty (if true, then it will again apply later) or not (if false).

◆ setVectorArgument()

void csl::Abstract::setVectorArgument ( const csl::vector_expr &  t_argument)
virtual

Replaced the entire std::vector of argument.

Parameters
t_argumentstd::vector of expressions to copy.

Reimplemented in csl::AbstractMultiFunc, and csl::AbstractVectorial.

◆ suppressExponent()

std::optional< Expr > csl::Abstract::suppressExponent ( Expr const &  factor,
Expr const &  exponent 
) const
virtual

Returns the expression where the factor factor^exponent has been suppressed.

This function works the same manner as getExponents().

Parameters
factorFactor to suppress.
exponentExponent of the factor to suppress.
Returns
The modified expression if the factor has been found.
std::nullopt else.
Note
This function may replace in the future the functions askTerm() and suppressTerm().

Reimplemented in csl::Pow, and csl::Prod.

◆ suppressTerm()

Expr csl::Abstract::suppressTerm ( Expr_info  expr) const
virtual

Remove a factor from an expr, that must have been determined before.

Parameters
factorExpression to remove
Returns
The expr in which factor has been removed

Reimplemented in csl::IProd, csl::Integral, csl::Pow, csl::Prod, csl::Sum, and csl::AbstractIntegral.

◆ symmetrise()

Expr csl::Abstract::symmetrise ( ) const
virtual

Calculates and returns the symmetrization of a 2D matrix.

Returns
1/2*(A + A^T) for a matrix (2D) A.

Reimplemented in csl::Matrix, and csl::AbstractVectorial.

◆ tensordot()

Expr csl::Abstract::tensordot ( const Expr expr) const
virtual

Returns the tensordot of two Vectorial expressions.

Parameters
exprThe right operand of the tensordot
Returns
The tensor dot of *this and expr.

Reimplemented in csl::AbstractVectorial.

◆ trace() [1/2]

Expr csl::Abstract::trace ( ) const
virtual
Returns
i A{ii} for a square matrix A.
A for a scalar A.
0 else.

Reimplemented in csl::Matrix.

◆ trace() [2/2]

Expr csl::Abstract::trace ( int  axis1,
int  axis2 
) const
virtual

Calculates the trace over the axis axis1 and axis2 of a tensor. axis1 and axis2 can be the same, in which case the trace just corresponds to the sum over this particular axis.

Parameters
axis1First axis to contract.
axis2Second axis to contract.
Returns
the trace over axis axis1 and axis2.

Reimplemented in csl::AbstractVectorial.

◆ transpose()

Expr csl::Abstract::transpose ( ) const
virtual

Calculates and returns the transpose of a 2D matrix.

Returns
A^T for a matrix (2D) A.

Reimplemented in csl::Matrix.


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