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

Parent of an indicial object, allows to generate them (TensorElement). More...

#include <indicial.h>

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

Public Member Functions

 TensorParent ()
 Default constructor.
 
 TensorParent (const std::string &t_name)
 Constructor that initializes only the name of the parent. More...
 
 TensorParent (const TensorParent &abstract)=default
 Copy constructor = c++ default.
 
 TensorParent (const std::string &t_name, const Space *t_space)
 Constructor of a 1-indexed parent. More...
 
 TensorParent (const std::string &t_name, const std::vector< const Space *> &t_space)
 Constructor of a n-indexed parent. More...
 
 TensorParent (const std::string &t_name, const std::vector< const Space *> &t_space, const Expr &t_tensor)
 Constructor of a n-indexed parent, with explicit tensor tensor. More...
 
 TensorParent (const std::string &t_name, const Space *t_space, const Expr &t_tensor)
 Constructor of a 1-indexed parent, with explicit tensor tensor. More...
 
cslParent::PrimaryType getPrimaryType () const override
 
cslParent::Type getType () const override
 
void printDefinition (std::ostream &out=std::cout, int indentSize=4, bool header=false) const override
 
int getDim (const Space *t_space) const override
 Returns the dimension of the parent relatively to a certain vector space, i.e. the number of indices in this vector space. More...
 
std::vector< const Space * > getSpace () const override
 
Symmetry getSymmetry () const
 
bool getFullySymmetric () const override
 
bool getFullyAntiSymmetric () const override
 
std::vector< PermutationgetPermutation () const override
 For an TensorParent returns all the possible permutations of the tensor with respect to the symmetries or antisymmetries in a vector of Permutation. More...
 
bool isValued () const override
 
Expr getTensor () const override
 For a valued TensorParent returns the corresponding tensor. Valued means that the tensor has been defined by the user. More...
 
Expr getTensor (Expr_info self) const override
 
Expr getTrace () const override
 For an TensorParent of dimension 2 (in a given unique space) returns the trace of it, i.e. the sum of its diagonal elements.
 
bool dependsOn (Expr_info expr) const override
 Tells if the parent depends on another expression or not. More...
 
bool dependsExplicitlyOn (Expr_info expr) const override
 Tells if the parent depends explicitely on another expression or not. More...
 
const std::vector< Equation * > & getProperties () const override
 
void setComplexProperty (csl::ComplexProperty t_prop) override
 
void setKeepBestPermutation (bool keep)
 
void setFullySymmetric () override
 Set the TensorParent fully symmetric.
 
void setFullyAntiSymmetric () override
 Set the TensorParent fully antisymmetric.
 
bool isTraceLessIn (csl::Space const *space) const override
 
void addTraceLessNess (csl::Space const *space) override
 
void removeTraceLessNess (csl::Space const *space) override
 
void addSpace (const Space *space) override
 Adds a dimension to an TensorParent in a specific vector space. More...
 
void addSymmetry (int i1, int i2) override
 Adds a symmetry between indices in position i1 and i2. More...
 
void addAntiSymmetry (int i1, int i2) override
 Adds an antisymmetry between indices in position i1 and i2. More...
 
void setSymmetry (const Symmetry &t_symetry) override
 Sets all the symmetry properties of an TensorParent from an object of type Symmetry. This erase all possible properties of (anti)symmetry the parent had before that. More...
 
void setTensor (const Expr &t_tensor) override
 
void setTrace (const Expr &t_trace) override
 
void setElementary (bool t_elementary)
 Sets all potential variables in the tensor associated with the indicial object elementary. For example, setting a vector as elementary will set all vector elements (if they are variables) as elementary variables, i.e. that depend only on themselves. More...
 
bool hasContractionProperty (const Abstract *self, Expr_info B) const override
 Tells if an TensorParent has contraction properties with another expression. More...
 
std::vector< ContractionChaingetContractionProperties () const override
 
Expr contraction (const Abstract *self, Expr_info B) const override
 Applies a contractoin property if there is one between self and B. More...
 
void addSelfContraction (const Expr &A, const Expr &B, const Expr &res, std::optional< std::function< bool(Expr_info, Expr_info)>> condition=std::nullopt) override
 Adds a contraction property between an Element and another that share the parent (*this). More...
 
void removeSelfContraction (const Expr &A, const Expr &B) override
 
bool hasChainContractionProperty () const override
 
void addContractionProperty (csl::vector_expr const &leftHandSide, const Expr &rightHandSide) override
 
void removeContractionProperty (csl::vector_expr const &leftHandSide, const Expr &rightHandSide) override
 
std::optional< ExprgetComplexProperty (Expr_info self) const override
 
std::optional< ExprgetHermitianProperty (Expr_info self, const Space *t_space) const override
 
std::optional< ExprgetTransposedProperty (Expr_info self, const Space *t_space) const override
 
std::optional< Exprevaluate (Expr_info self, csl::eval::mode user_mode=csl::eval::base) const override
 
void addComplexProperty (const Expr &init, const Expr &res) override
 
void addHermitianProperty (const Space *space, const Expr &init, const Expr &res) override
 
void addTransposedProperty (const Space *space, const Expr &init, const Expr &res) override
 
std::vector< ParentgetBrokenParts (const Space *broken) const override
 
std::vector< ParentbreakSpace (const Space *broken, const std::vector< const Space *> &newSpace, const std::vector< size_t > &pieces) const override
 
virtual Expr operator() (Index index) override
 Generate the Element for an TensorParent of dimension 1 (a single index). More...
 
virtual Expr operator() (std::vector< Index > indices) override
 Generate the Element for an TensorParent of arbitrary dimension More...
 
virtual Expr operator() (const std::vector< int > &indices) override
 
virtual bool operator== (const TensorParent &other) const
 Compares the parent with another. More...
 
virtual bool operator!= (const TensorParent &other) const
 Compares the parent with another. More...
 
- Public Member Functions inherited from csl::AbstractParent
 AbstractParent ()
 Default constructor, parent with no name.
 
 AbstractParent (const std::string &t_name)
 Intializes the name of the parent. More...
 
 AbstractParent (const AbstractParent &abstract)=default
 Copy constructor, c++ default.
 
virtual ~AbstractParent ()
 Destructor.
 
Parent self ()
 
virtual bool isAnAbbreviation () const
 
std::string const & getName () const
 
std::string const & getLatexName () const
 
virtual std::string const & getBaseName () const
 
bool getCommutable () const
 
csl::ComplexProperty getComplexProp () const
 
virtual void setName (std::string t_name)
 
virtual void setLatexName (const std::string &t_name)
 
void setCommutable (bool t_commutable)
 
void addProperty (Equation *prop)
 Adds a property for the parent. More...
 
void removeProperty (Equation *prop)
 Removes a property. More...
 
virtual int getDim () const
 
void printPropDefinition (std::ostream &out, int indentSize, bool header) const
 
virtual void enableEvaluation ()
 
virtual void disableEvaluation ()
 
virtual void toggleEvaluation ()
 
virtual Expr const & getEncapsulated () const
 
virtual Expr getExactEncapsulated (Expr_info self) const
 
virtual void setEncapsulated (Expr const &)
 
virtual const SpacegetFieldSpace () const
 
virtual void setFieldSpace (const Space *t_space)
 
virtual Expr operator() (const Tensor &point)
 
virtual Expr operator() (Index index, const Tensor &point)
 
virtual Expr operator() (std::vector< Index > indices, const Tensor &point)
 
virtual Expr operator() (const std::vector< int > &indices, const Tensor &point)
 

Protected Member Functions

void applyProperty (Expr_info self, IndexStructure const &structure, Expr &res) const
 
void checkIndexRequest (const Index &index)
 
void checkIndexRequest (const std::vector< Index > &request)
 
void createFixedIndices (Index &index) const
 
void createFixedIndices (std::vector< Index > &indices) const
 

Protected Attributes

std::vector< const Space * > space
 Vector spaces in which the indices live.
 
std::vector< bool > covariant
 
bool keepBestPermutation = true
 
Symmetry symmetry
 Symmetry properties of the tensor.
 
bool fullySymmetric
 Attribute that can be set to True if the tensor must be fully symmetric.
 
bool fullyAntiSymmetric
 Attribute that can be set to True if the tensor must be fully anti-symmetric.
 
std::vector< std::pair< SelfContraction, Expr > > selfContraction
 List of (self) constractions that have special properties.
 
std::vector< std::pair< SelfContraction, Expr > > extContraction
 
std::vector< csl::AbstractParent const * > externalTensors
 
std::vector< csl::Space const * > traceLessNess
 
std::vector< ContractionChainchainContraction
 
std::map< const csl::Space *, std::vector< csl::Parent > > brokenParts
 
bool valued
 Boolean that is True iif an explicit tensor is given.
 
Expr tensor
 Explicit tensor that can be set by the user.
 
Expr trace
 (almost) Unused attribute going to disappear.
 
std::optional< std::pair< IndexStructure, Expr > > conjugateProperty
 
std::map< const Space *, std::pair< IndexStructure, Expr > > hermitianProperty
 
std::map< const Space *, std::pair< IndexStructure, Expr > > transposedProperty
 
- Protected Attributes inherited from csl::AbstractParent
std::string name
 
std::string latexName
 
bool commutable
 
csl::ComplexProperty complexProp = csl::ComplexProperty::Real
 
std::vector< Equation * > props
 

Friends

template<class ... Args>
std::shared_ptr< TensorParenttensor_s (Args &&...args)
 
template<class ... Args>
std::shared_ptr< TensorParenttensor_s (std::string const &name, std::vector< const Space *> const &indices, Args &&...args)
 
std::ostream & operator<< (std::ostream &fout, const TensorParent &)
 Displays an TensorParent p. More...
 

Detailed Description

Parent of an indicial object, allows to generate them (TensorElement).

Constructor & Destructor Documentation

◆ TensorParent() [1/5]

csl::TensorParent::TensorParent ( const std::string &  t_name)
explicit

Constructor that initializes only the name of the parent.

Parameters
t_nameName of the parent.

◆ TensorParent() [2/5]

csl::TensorParent::TensorParent ( const std::string &  t_name,
const Space t_space 
)

Constructor of a 1-indexed parent.

Parameters
t_nameName of the parent.
t_spaceVector space in which the Index lives.

◆ TensorParent() [3/5]

csl::TensorParent::TensorParent ( const std::string &  t_name,
const std::vector< const Space *> &  t_space 
)

Constructor of a n-indexed parent.

Parameters
t_nameName of the parent.
t_spaceList of the n spaces in which each index lives.

◆ TensorParent() [4/5]

csl::TensorParent::TensorParent ( const std::string &  t_name,
const std::vector< const Space *> &  t_space,
const Expr t_tensor 
)

Constructor of a n-indexed parent, with explicit tensor tensor.

Parameters
t_nameName of the parent.
t_spaceList of the n spaces in which each index lives.
t_tensorExplicit tensor. Must match exactly the shape given by the IndexStructure.

◆ TensorParent() [5/5]

csl::TensorParent::TensorParent ( const std::string &  t_name,
const Space t_space,
const Expr t_tensor 
)

Constructor of a 1-indexed parent, with explicit tensor tensor.

Parameters
t_nameName of the parent.
t_spaceVector space in which the index lives.
t_tensorExplicit tensor. Must match exactly the shape given by the IndexStructure.

Member Function Documentation

◆ addAntiSymmetry()

void csl::TensorParent::addAntiSymmetry ( int  i1,
int  i2 
)
overridevirtual

Adds an antisymmetry between indices in position i1 and i2.

Parameters
i1Index of the first index in the symmetry.
i2Index of the second index in the symmetry.

Reimplemented from csl::AbstractParent.

◆ addSelfContraction()

void csl::TensorParent::addSelfContraction ( const Expr A,
const Expr B,
const Expr res,
std::optional< std::function< bool(Expr_info, Expr_info)>>  condition = std::nullopt 
)
overridevirtual

Adds a contraction property between an Element and another that share the parent (*this).

Parameters
AFirst Element in the contraction.
BSecond Element in the contraction.
Returns
res The result of the contraction.

Reimplemented from csl::AbstractParent.

◆ addSpace()

void csl::TensorParent::addSpace ( const Space t_space)
overridevirtual

Adds a dimension to an TensorParent in a specific vector space.

Parameters
t_spaceSpace in which we add an index.

Reimplemented from csl::AbstractParent.

◆ addSymmetry()

void csl::TensorParent::addSymmetry ( int  i1,
int  i2 
)
overridevirtual

Adds a symmetry between indices in position i1 and i2.

Parameters
i1Index of the first index in the symmetry.
i2Index of the second index in the symmetry.

Reimplemented from csl::AbstractParent.

◆ contraction()

Expr csl::TensorParent::contraction ( const Abstract self,
Expr_info  B 
) const
overridevirtual

Applies a contractoin property if there is one between self and B.

Parameters
selfA pointer to the element corresponding to the parent.
BThe other expression.
Returns
The contracted object.

Reimplemented from csl::AbstractParent.

Reimplemented in csl::MetricParent, csl::DeltaParent, and csl::EpsilonParent.

◆ dependsExplicitlyOn()

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

Tells if the parent depends explicitely on another expression or not.

Parameters
exprfrom which we test the dependency.
Returns
True if the parent depends onexpr.
False else.

Reimplemented from csl::AbstractParent.

◆ dependsOn()

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

Tells if the parent depends on another expression or not.

Parameters
exprfrom which we test the dependency.
Returns
True if the parent depends onexpr.
False else.

Reimplemented from csl::AbstractParent.

◆ getDim()

int csl::TensorParent::getDim ( const Space t_space) const
overridevirtual

Returns the dimension of the parent relatively to a certain vector space, i.e. the number of indices in this vector space.

Parameters
t_spaceVector space to investigate.
Returns
The dimansion in t_space.

Reimplemented from csl::AbstractParent.

◆ getFullyAntiSymmetric()

bool csl::TensorParent::getFullyAntiSymmetric ( ) const
overridevirtual
Returns
True if the parent is indicial and fully antisymmetric in its indices.
False else.

Reimplemented from csl::AbstractParent.

◆ getFullySymmetric()

bool csl::TensorParent::getFullySymmetric ( ) const
overridevirtual
Returns
True if the parent is indicial and fully symmetric in its indices.
False else.

Reimplemented from csl::AbstractParent.

◆ getPermutation()

vector< Permutation > csl::TensorParent::getPermutation ( ) const
overridevirtual

For an TensorParent returns all the possible permutations of the tensor with respect to the symmetries or antisymmetries in a vector of Permutation.

Returns
A std::vector<Permutation> with all possible permutations of the tensor.

Reimplemented from csl::AbstractParent.

◆ getPrimaryType()

cslParent::PrimaryType csl::TensorParent::getPrimaryType ( ) const
overridevirtual
Returns
The primary type of the parent.

Implements csl::AbstractParent.

Reimplemented in csl::TensorFieldParent.

◆ getProperties()

const vector< Equation * > & csl::TensorParent::getProperties ( ) const
overridevirtual
Returns
props.

Reimplemented from csl::AbstractParent.

◆ getSpace()

vector< const Space * > csl::TensorParent::getSpace ( ) const
overridevirtual
Returns
The list of vector-spaces in which live the indices.

Reimplemented from csl::AbstractParent.

◆ getSymmetry()

Symmetry csl::TensorParent::getSymmetry ( ) const
Returns
The Symmetry object describing the parent's properties.

◆ getTensor()

Expr csl::TensorParent::getTensor ( ) const
overridevirtual

For a valued TensorParent returns the corresponding tensor. Valued means that the tensor has been defined by the user.

Returns
tensor.

Reimplemented from csl::AbstractParent.

◆ getType()

cslParent::Type csl::TensorParent::getType ( ) const
overridevirtual
Returns
The type of the parent.

Implements csl::AbstractParent.

Reimplemented in csl::MetricParent, csl::DeltaParent, csl::EpsilonParent, and csl::TensorFieldParent.

◆ hasContractionProperty()

bool csl::TensorParent::hasContractionProperty ( const Abstract self,
Expr_info  B 
) const
overridevirtual

Tells if an TensorParent has contraction properties with another expression.

Parameters
selfA pointer to the element corresponding to the parent.
BThe other expression.
Returns
True if there is one particular contraction property.
False else.

Reimplemented from csl::AbstractParent.

Reimplemented in csl::MetricParent, csl::DeltaParent, and csl::EpsilonParent.

◆ operator!=()

bool csl::TensorParent::operator!= ( const TensorParent other) const
virtual

Compares the parent with another.

Returns
False if the parents are equivalent.
True else.

◆ operator()() [1/2]

Expr csl::TensorParent::operator() ( Index  index)
overridevirtual

Generate the Element for an TensorParent of dimension 1 (a single index).

Parameters
indexThe Index of the Element.
Returns
The corresponding TensorElement.

Reimplemented from csl::AbstractParent.

◆ operator()() [2/2]

virtual Expr csl::TensorParent::operator() ( std::vector< Index indices)
overridevirtual

Generate the Element for an TensorParent of arbitrary dimension

Parameters
indicesList of indices to generate the TensorElement.
Returns
The corresponding TensorElement.

Reimplemented from csl::AbstractParent.

Reimplemented in csl::MetricParent, csl::DeltaParent, and csl::EpsilonParent.

◆ operator==()

bool csl::TensorParent::operator== ( const TensorParent other) const
virtual

Compares the parent with another.

Returns
True if the parents are equivalent.
False else.

◆ setElementary()

void csl::TensorParent::setElementary ( bool  t_elementary)

Sets all potential variables in the tensor associated with the indicial object elementary. For example, setting a vector as elementary will set all vector elements (if they are variables) as elementary variables, i.e. that depend only on themselves.

Parameters
t_elementaryBoolean property of elementary-ness.

◆ setSymmetry()

void csl::TensorParent::setSymmetry ( const Symmetry t_symmetry)
overridevirtual

Sets all the symmetry properties of an TensorParent from an object of type Symmetry. This erase all possible properties of (anti)symmetry the parent had before that.

Parameters
t_symmetryNew symmetry of the parent.

Reimplemented from csl::AbstractParent.

◆ setTensor()

void csl::TensorParent::setTensor ( const Expr t_tensor)
overridevirtual
Parameters
Newtensor corresponding to the TensorParent. Must match the index structure of course.

Reimplemented from csl::AbstractParent.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  fout,
const TensorParent i 
)
friend

Displays an TensorParent p.

std::ostream& operator<<(std::ostream& fout, const TensorParent& p)


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