Documentation of CSL
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
csl::TensorElement Class Reference

Specialization of Abstract for Indicial tensor. Building block carrying indices, and respecting Einstein's summation convention. More...

#include <indicial.h>

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

Public Member Functions

 TensorElement (const Index &t_index, const Parent &t_parent)
 Constructor called by an TensorParent, for a tensor with one index. More...
 
 TensorElement (const std::vector< Index > &indices, const Parent &t_parent)
 Constructor called by an TensorParent, for a tensor with several indices. More...
 
 TensorElement (const IndexStructure &indices, const Parent &t_parent)
 Constructor called by an TensorParent, for a tensor with several indices. More...
 
 TensorElement (const Abstract *&expression)
 Copy constructor from an Abstract*. Works only if the pointer points to another TensorElement. More...
 
 TensorElement (const Expr &expression)
 Copy constructor from an Expr. Works only if the pointer points to another TensorElement. More...
 
csl::PrimaryType getPrimaryType () const override
 Gives the primary type of Abstract. More...
 
size_t memoryOverhead () const override
 
bool isIndexed () const override
 
int getNIndices () const override
 
void resetIndexStructure () override
 
IndexStructure getIndexStructure () const override
 
const IndexStructuregetIndexStructureView () const override
 
IndexStructuregetIndexStructureView () override
 
bool compareWithDummy (Expr_info expr, std::map< Index, Index > &constraints, bool keepAllCosntraints=false) const override
 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...
 
csl::Type getType () const override
 Gives the type of Abstract. More...
 
std::optional< ExprgetComplexConjugate () const override
 Calculates and returns the complex conjugate of the expression. More...
 
std::optional< ExprgetHermitianConjugate (const Space *space) const override
 
std::optional< ExprgetHermitianConjugate (const std::vector< const Space *> &spaces) const override
 
std::optional< ExprgetTransposed (const Space *space, bool applyProp=true) const override
 
std::optional< ExprgetTransposed (const std::vector< const Space *> &t_spaces, bool applyProp=true) const override
 
Index getIndex (int i) const override
 
bool askTerm (Expr_info expr, bool exact=false) const override
 Determines if the term expr can be factorized out from the TensorElement, i.e. if expr is equal to the tensor to (may be) a renaming of index. More...
 
bool dependsOn (Expr_info expr) const override
 Check recursively if the expression depends on expr. More...
 
bool dependsOn (Parent_info t_parent) const override
 
bool dependsExplicitlyOn (Expr_info expr) const override
 Check recursively if expr is present in the expression. More...
 
const std::vector< Equation * > & getProperties () const override
 
void addProperty (Equation *property) override
 Adds a property to the object. More...
 
void removeProperty (Equation *property) override
 Removes a property to the object. More...
 
bool checkIndexStructure (const std::vector< Index > &t_index) const override
 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...
 
void selfCheckIndexStructure ()
 
std::optional< ExprreplaceIndex (const Index &indexToReplace, const Index &newIndex, bool refresh=true) const override
 For indicial expressions, this function searches indexToContract and replaces it with newIndex. More...
 
std::optional< ExprreplaceIndices (std::vector< Index > const &indexToReplace, std::vector< Index > const &newIndex, bool refresh=true, bool flipped=false) const override
 
void replaceIndexInPlace (Index const &oldIndex, Index const &newIndex) override
 
csl::vector_expr breakSpace (const Space *brokenSpace, const std::vector< const Space *> &newSpaces, const std::vector< std::string > &indexNames) const override
 
void setIndexStructure (const IndexStructure &t_index) override
 Replaces the index structure of the object, that must be an Indicial expression. More...
 
bool hasContractionProperty (Expr_info B) const override
 Tells (for an Indicial type) if there is a special contraction property with B. More...
 
std::vector< ContractionChaingetContractionProperties () const override
 
Expr contraction (Expr_info B) const override
 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...
 
bool hasChainContractionProperty () const override
 
Expr applyPermutation (const Permutation &permutations) const
 Applies a permutation of the indices on a copy of the TensorElement, and returns it. More...
 
csl::vector_expr getPermutations (bool optimize=true) const override
 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...
 
csl::vector_expr getAlternateForms () const override
 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...
 
Expr getCanonicalPermutation () const override
 
void print (int mode=0, std::ostream &out=std::cout, bool lib=false) const override
 Displays the abstract in standard output. More...
 
void printCode (int mode=0, std::ostream &out=std::cout) const override
 
std::string printLaTeX (int mode=0) const override
 Creates a LaTeX output for the Abstract. More...
 
std::vector< ParentgetSubSymbols () const override
 
std::optional< Exprderive (Expr_info expr) const override
 Calculates the derivative of the Abstract wrt another. More...
 
std::optional< Exprevaluate (csl::eval::mode user_mode=csl::eval::base) const override
 Evaluates the Abstract. More...
 
unique_Expr copy_unique () const override
 
Expr refresh () const override
 
Expr deepRefresh () const override
 
bool operator== (Expr_info expr) const override
 Compares the Abstract with another. More...
 
bool operator< (const Abstract *expr) const override
 
- Public Member Functions inherited from csl::AbstractElement
 AbstractElement ()
 
 AbstractElement (const std::shared_ptr< AbstractParent > &t_parent)
 Intializes the parent and no name. More...
 
 ~AbstractElement ()
 Destructor.
 
Parent getParent () const override
 
Parent_info getParent_info () const override
 
std::string const & getName () const override
 Returns the Abstract's name. More...
 
std::string const & getLatexName () const override
 
bool getCommutable () const override
 Allows to know if the object commutes with all the others. More...
 
csl::ComplexProperty getComplexProperty () const override
 
void setParent (const Parent &t_parent) override
 Changes the Parent of the Element, as the name and the commutability property from those of t_parent. More...
 
void setName (const std::string &t_name) override
 Change the name of the abstract. More...
 
void setCommutable (bool t_commutable) override
 Allows the abstract to commute or not. More...
 
void setComplexProperty (csl::ComplexProperty t_prop) override
 
int isPolynomial (Expr_info variable) const override
 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...
 
std::optional< ExprgetPolynomialTerm (Expr_info variable, int order) const override
 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...
 
- Public Member Functions inherited from csl::Complexified
bool isReal () const override
 
bool isPurelyImaginary () const override
 
bool isComplexConjugate () const override
 
std::optional< ExprgetRealPart () const override
 Evaluates the real part of the Abstract and returns it. More...
 
Expr getImaginaryPart () const override
 Evaluates the imaginary part of the Abstract and returns it. More...
 
void setConjugated (bool t_conjugated) override
 
void printProp (std::ostream &fout=std::cout) const override
 
- Public Member Functions inherited from csl::AbstractBuildingBlock
bool isBuildingBlock () const override
 Tells if the expression is a Building Block or not. More...
 
virtual bool commutesWith (Expr_info expr, int sign=-1) const override
 Tells if the object commutes with expr. More...
 
std::optional< Exprexpand (bool full=false, bool inplace=false) const override
 Develops the Abstract. More...
 
std::optional< Exprfactor (bool full=false) const override
 Factors the Abstract. More...
 
std::optional< Exprfactor (Expr_info expr, bool full=false) const override
 Factors the Abstract wrt a particular Abstract. More...
 
std::optional< ExprgetTerm () const override
 This function returns the same expression as *this but amputated of its numerical factor. Example: (4*cos(x) -> cos(x)). More...
 
std::optional< ExprgetComplexModulus () const override
 Evaluates the modulus in the complex plane of the Abstract and returns it. More...
 
std::optional< ExprfindSubExpression (Expr_info subExpression, const Expr &newExpression) const override
 Searches a sub-expression and replaces it. More...
 
- Public Member Functions inherited from csl::Abstract
 Abstract ()
 Default Constructor. More...
 
virtual ~Abstract ()
 Destructor.
 
Expr self ()
 
void printExplicit (int mode=0) const
 Displays explicitely the expression, with types of each component. This function is only used for debug. More...
 
virtual LibDependency getLibDependency () const
 
virtual bool getElementary () const
 
virtual bool getAllDependencies () const
 
virtual int getDim () const
 Gives the dimension of the object. More...
 
virtual int getOrderOf (Expr_info expr) const
 
virtual bool isArbitrary () const
 
virtual bool isHermitianConjugate () const
 
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)
 
IndexStructure getIndexStructure (csl::Space const *space) const
 
virtual IndexStructure getFreeIndexStructure () const
 
virtual Tensor getPoint () const
 
virtual int getNContractedPairs () const
 Returns the number of contracted pairs of indices in an Indicial expression. More...
 
virtual std::set< std::pair< int, int > > getContractedPair () const
 
Expr copy () const
 
virtual Expr deepCopy () const
 
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...
 
std::optional< ExprcontractIndex (const Index &index) const
 
csl::vector_expr breakSpace (const Space *brokenSpace, const std::vector< const Space *> &newSpace) const
 
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 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::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...
 
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 dependsExplicitlyOn (Parent_info parent) const
 
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 Expr contraction (const csl::vector_expr &chain) const
 
virtual long double evaluateScalar () const
 Evaluates the value of the 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_if (std::function< bool(Expr const &)> const &f, bool full=false, bool inPlace=false) const
 Develops the Abstract. More...
 
virtual std::optional< ExprgetComplexArgument () const
 Evaluates the argument in the complex plane of the Abstract and returns it. 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 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
 
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
 

Protected Member Functions

bool comparePermutations (Expr_info perm1, Expr_info perm2) const
 
void selfCheckAutoIndices ()
 
ExprapplySelfStructureOn (Expr &expr) const override
 
void adjustMetricDeltaParent ()
 
csl::vector_expr applyBrokenIndices (std::vector< Parent > &brokenParents, const Space *broken, const std::vector< const Space *> &newSpaces, const std::vector< Index > &indices) const
 
- Protected Member Functions inherited from csl::Complexified
void applyComplexPropertiesOn (const Expr &expr) const
 
void applyComplexPropertiesOn (unique_Expr &expr) const
 

Protected Attributes

IndexStructure index
 IndexStructure of the tensor.
 
- Protected Attributes inherited from csl::AbstractElement
std::shared_ptr< AbstractParentparent
 Pointer to the parent that gave birth to this element.
 
- Protected Attributes inherited from csl::Complexified
bool conjugated = false
 

Friends

template<typename ... Args>
Expr tensorelement_s (Args &&...args)
 

Additional Inherited Members

- Static Public Member Functions inherited from csl::Abstract
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

Specialization of Abstract for Indicial tensor. Building block carrying indices, and respecting Einstein's summation convention.

Constructor & Destructor Documentation

◆ TensorElement() [1/5]

csl::TensorElement::TensorElement ( const Index t_index,
const Parent t_parent 
)

Constructor called by an TensorParent, for a tensor with one index.

Parameters
t_index(Only) index of the tensor.
t_parentPointer to the TensorParent creating the tensor.

◆ TensorElement() [2/5]

csl::TensorElement::TensorElement ( const std::vector< Index > &  indices,
const Parent t_parent 
)

Constructor called by an TensorParent, for a tensor with several indices.

Parameters
t_indexList of indices for the tensor.
t_parentPointer to the TensorParent creating the tensor.

◆ TensorElement() [3/5]

csl::TensorElement::TensorElement ( const IndexStructure indices,
const Parent t_parent 
)

Constructor called by an TensorParent, for a tensor with several indices.

Parameters
t_indexList of indices for the tensor in the form of an already created IndexStructure.
t_parentPointer to the TensorParent creating the tensor.

◆ TensorElement() [4/5]

csl::TensorElement::TensorElement ( const Abstract *&  expression)
explicit

Copy constructor from an Abstract*. Works only if the pointer points to another TensorElement.

Parameters
expression

◆ TensorElement() [5/5]

csl::TensorElement::TensorElement ( const Expr expression)
explicit

Copy constructor from an Expr. Works only if the pointer points to another TensorElement.

Parameters
expression

Member Function Documentation

◆ addProperty()

void csl::TensorElement::addProperty ( Equation property)
overridevirtual

Adds a property to the object.

Parameters
propertyThe new property to add in props.

Reimplemented from csl::Abstract.

◆ applyPermutation()

Expr csl::TensorElement::applyPermutation ( const Permutation permutations) const

Applies a permutation of the indices on a copy of the TensorElement, and returns it.

Parameters
permutationsPermutation to apply on the new TensorElement.
Returns

◆ askTerm()

bool csl::TensorElement::askTerm ( Expr_info  expr,
bool  exact = false 
) const
overridevirtual

Determines if the term expr can be factorized out from the TensorElement, i.e. if expr is equal to the tensor to (may be) a renaming of index.

If exact is set to true, the function returns true if the IndexStructure matches exactly. Else, the Comparator::freeIndexComparison() function is called.

Parameters
exprTerm to compare.
exactTells if the comparison must be exact regarding indices.
Returns
True if expr can be factorized out.
False else.

Reimplemented from csl::Abstract.

◆ checkIndexStructure()

bool csl::TensorElement::checkIndexStructure ( const std::vector< Index > &  t_index) const
overridevirtual

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 from csl::Abstract.

◆ compareWithDummy()

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

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 from csl::Abstract.

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

◆ contraction()

Expr csl::TensorElement::contraction ( Expr_info  B) const
overridevirtual

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 from csl::Abstract.

◆ dependsExplicitlyOn()

bool csl::TensorElement::dependsExplicitlyOn ( Expr_info  expr) const
overridevirtual

Check recursively if expr is present in the expression.

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

Reimplemented from csl::Abstract.

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

◆ dependsOn()

bool csl::TensorElement::dependsOn ( Expr_info  expr) const
overridevirtual

Check recursively if the expression depends on expr.

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

Reimplemented from csl::Abstract.

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

◆ derive()

optional< Expr > csl::TensorElement::derive ( Expr_info  expr) const
overridevirtual

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 from csl::Abstract.

◆ evaluate()

optional< Expr > csl::TensorElement::evaluate ( csl::eval::mode  user_mode = csl::eval::base) const
overridevirtual

Evaluates the Abstract.

Replaces all variables by their value and evaluating. This function must be used instead of evaluateScalar() when treating not only real scalars.* In particular (x=2, y=3) x+iy evaluates to 3+ 3i whereas evaluateScalar() would return 3.

Returns
The abstract result of the evaluation.

Reimplemented from csl::AbstractElement.

Reimplemented in csl::TensorFieldElement.

◆ getAlternateForms()

csl::vector_expr csl::TensorElement::getAlternateForms ( ) const
overridevirtual

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 from csl::Abstract.

◆ getComplexConjugate()

optional< Expr > csl::TensorElement::getComplexConjugate ( ) const
overridevirtual

Calculates and returns the complex conjugate of the expression.

Returns
{*this}.

Reimplemented from csl::Complexified.

Reimplemented in csl::TDerivativeElement.

◆ getIndex()

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

Reimplemented from csl::Abstract.

◆ getIndexStructure()

IndexStructure csl::TensorElement::getIndexStructure ( ) const
inlineoverridevirtual
Returns
The index structure of the Indicial expression

Reimplemented from csl::Abstract.

Reimplemented in csl::TDerivativeElement.

◆ getNIndices()

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

Reimplemented from csl::Abstract.

◆ getPermutations()

csl::vector_expr csl::TensorElement::getPermutations ( bool  optimize = true) const
overridevirtual

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 from csl::Abstract.

◆ getPrimaryType()

csl::PrimaryType csl::TensorElement::getPrimaryType ( ) const
inlineoverridevirtual

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)

Implements csl::Abstract.

Reimplemented in csl::TensorFieldElement.

◆ getProperties()

const std::vector< Equation * > & csl::TensorElement::getProperties ( ) const
overridevirtual
Returns
The properties of the object.

Reimplemented from csl::Abstract.

◆ getType()

csl::Type csl::TensorElement::getType ( ) const
inlineoverridevirtual

Gives the 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 (cos, product, number, etc) in order to do special treatments or simplifications.

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

Implements csl::Abstract.

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

◆ hasContractionProperty()

bool csl::TensorElement::hasContractionProperty ( Expr_info  B) const
overridevirtual

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 from csl::Abstract.

◆ isIndexed()

bool csl::TensorElement::isIndexed ( ) const
inlineoverridevirtual
Returns
True if the expression is indexed.
False else.

Reimplemented from csl::Abstract.

Reimplemented in csl::TensorFieldElement.

◆ operator==()

bool csl::TensorElement::operator== ( Expr_info  expr) const
overridevirtual

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.

Reimplemented from csl::Complexified.

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

◆ print()

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

Displays the abstract in standard output.

Parameters
modeTells if the Abstract is printed alone (default) or in another expr.

Implements csl::Abstract.

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

◆ printLaTeX()

string csl::TensorElement::printLaTeX ( int  mode = 0) const
overridevirtual

Creates a LaTeX output for the Abstract.

Parameters
modeTells if the Abstract is printed alone (default) or in another expr.
Returns
The string corresponding to the LaTeX output.

Reimplemented from csl::Abstract.

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

◆ removeProperty()

void csl::TensorElement::removeProperty ( Equation property)
overridevirtual

Removes a property to the object.

Parameters
propertyProperty to remove from props.

Reimplemented from csl::Abstract.

◆ replaceIndex()

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

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 from csl::Abstract.

Reimplemented in csl::TDerivativeElement.

◆ setIndexStructure()

void csl::TensorElement::setIndexStructure ( const IndexStructure t_index)
overridevirtual

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 from csl::Abstract.

Reimplemented in csl::TDerivativeElement.


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