Documentation of CSL
Public Member Functions | Protected Attributes | Friends
csl::AbstractParent Class Referenceabstract

Base class for all parents (indicial, fields etc). All parents derive from this class. More...

#include <parent.h>

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

Public Member Functions

 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)
 
virtual void setComplexProperty (csl::ComplexProperty t_prop)
 
void addProperty (Equation *prop)
 Adds a property for the parent. More...
 
void removeProperty (Equation *prop)
 Removes a property. More...
 
virtual cslParent::PrimaryType getPrimaryType () const =0
 
virtual cslParent::Type getType () const =0
 
virtual int getDim () const
 
virtual void printDefinition (std::ostream &out=std::cout, int indentSize=4, bool header=false) const =0
 
void printPropDefinition (std::ostream &out, int indentSize, bool header) const
 
virtual void enableEvaluation ()
 
virtual void disableEvaluation ()
 
virtual void toggleEvaluation ()
 
virtual std::optional< Exprevaluate (Expr_info self, csl::eval::mode user_mode=csl::eval::base) const
 
virtual Expr const & getEncapsulated () const
 
virtual Expr getExactEncapsulated (Expr_info self) const
 
virtual void setEncapsulated (Expr const &)
 
virtual int getDim (const Space *t_space) const
 Returns the dimension of the parent relatively to a certain vector space, i.e. the number of indices in this vector space. More...
 
virtual std::vector< const Space * > getSpace () const
 
virtual const SpacegetFieldSpace () const
 
virtual void setFieldSpace (const Space *t_space)
 
virtual bool getFullySymmetric () const
 
virtual bool getFullyAntiSymmetric () const
 
virtual std::vector< PermutationgetPermutation () const
 For an TensorParent returns all the possible permutations of the tensor with respect to the symmetries or antisymmetries in a vector of Permutation. More...
 
virtual bool isValued () const
 
virtual Expr getTensor () const
 For a valued TensorParent returns the corresponding tensor. Valued means that the tensor has been defined by the user. More...
 
virtual Expr getTensor (Expr_info expr) const
 
virtual Expr getTrace () const
 For an TensorParent of dimension 2 (in a given unique space) returns the trace of it, i.e. the sum of its diagonal elements.
 
virtual bool dependsOn (Expr_info expr) const
 Tells if the parent depends on another expression or not. More...
 
virtual bool dependsExplicitlyOn (Expr_info expr) const
 Tells if the parent depends explicitely on another expression or not. More...
 
virtual const std::vector< Equation * > & getProperties () const
 
virtual void addSpace (const Space *t_space)
 Adds a dimension to an TensorParent in a specific vector space. More...
 
virtual void setFullySymmetric ()
 Set the TensorParent fully symmetric.
 
virtual void setFullyAntiSymmetric ()
 Set the TensorParent fully antisymmetric.
 
virtual bool isTraceLessIn (csl::Space const *space) const
 
virtual void addTraceLessNess (csl::Space const *space)
 
virtual void removeTraceLessNess (csl::Space const *space)
 
virtual void addSymmetry (int i1, int i2)
 Adds a symmetry between indices in position i1 and i2. More...
 
virtual void addAntiSymmetry (int i1, int i2)
 Adds an antisymmetry between indices in position i1 and i2. More...
 
virtual void setSymmetry (const Symmetry &t_symmetry)
 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...
 
virtual void setTensor (const Expr &t_tensor)
 
virtual void setTrace (const Expr &t_trace)
 
virtual bool hasContractionProperty (const Abstract *self, Expr_info B) const
 Tells if an TensorParent has contraction properties with another expression. More...
 
virtual Expr contraction (const Abstract *self, Expr_info B) const
 Applies a contractoin property if there is one between self and B. More...
 
virtual bool hasChainContractionProperty () const
 
virtual std::vector< ContractionChaingetContractionProperties () const
 
virtual void addContractionProperty (csl::vector_expr const &leftHandSide, const Expr &rightHandSide)
 
virtual void removeContractionProperty (csl::vector_expr const &leftHandSide, const Expr &rightHandSide)
 
virtual void addSelfContraction (const Expr &A, const Expr &B, const Expr &res, std::optional< std::function< bool(Expr_info, Expr_info)>> condition=std::nullopt)
 Adds a contraction property between an Element and another that share the parent (*this). More...
 
virtual void removeSelfContraction (const Expr &A, const Expr &B)
 
virtual std::optional< ExprgetComplexProperty (Expr_info self) const
 
virtual std::optional< ExprgetHermitianProperty (Expr_info self, const Space *space) const
 
virtual std::optional< ExprgetTransposedProperty (Expr_info self, const Space *space) const
 
virtual void addComplexProperty (const Expr &init, const Expr &res)
 
virtual void addHermitianProperty (const Space *space, const Expr &init, const Expr &res)
 
virtual void addTransposedProperty (const Space *space, const Expr &init, const Expr &res)
 
virtual std::vector< ParentgetBrokenParts (const Space *broken) const
 
virtual std::vector< ParentbreakSpace (const Space *broken, const std::vector< const Space *> &newSpace, const std::vector< size_t > &pieces) const
 
virtual Expr operator() (Index index)
 Generate the Element for an TensorParent of dimension 1 (a single index). More...
 
virtual Expr operator() (const Tensor &point)
 
virtual Expr operator() (std::vector< Index > indices)
 Generate the Element for an TensorParent of arbitrary dimension More...
 
virtual Expr operator() (const std::vector< int > &indices)
 
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 Attributes

std::string name
 
std::string latexName
 
bool commutable
 
csl::ComplexProperty complexProp = csl::ComplexProperty::Real
 
std::vector< Equation * > props
 

Friends

std::ostream & operator<< (std::ostream &fout, const AbstractParent &)
 Display name and commutability of the parent in standard output. More...
 

Detailed Description

Base class for all parents (indicial, fields etc). All parents derive from this class.

The principle of a parent is to contain properties of a variety of objects that share the same abstract concept, like indicial objects. Every specialization (Element) of a tensor for example, is an object with indices like $ g_{\mu\nu} $. But the Element can appear many times in different forms in an expression, we want its properties to appear only at one place in the program, and we want an object that can generate the Element. This is the Parent. The parent then has three important features:
1. It is the only one to contain the properties of the object, if an element wants to access its own properties it has to ask its parent.
2. It is the only object able to generate properly an Element of its type.
2. It cannot appear in an expression (since it is not derived from Abstract). And it is normal because in a expression we want a $ g_{\mu\nu} $ with given $ \mu $ and $ \nu $, not a simple $ g $.

Constructor & Destructor Documentation

◆ AbstractParent()

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

Intializes the name of the parent.

Parameters
t_nameName of the parent.

Member Function Documentation

◆ addAntiSymmetry()

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

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 in csl::TensorParent.

◆ addProperty()

void csl::AbstractParent::addProperty ( Equation prop)

Adds a property for the parent.

Parameters
propEquation defining the new property.

◆ addSelfContraction()

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

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 in csl::TensorParent.

◆ addSpace()

void csl::AbstractParent::addSpace ( const Space t_space)
virtual

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

Parameters
t_spaceSpace in which we add an index.

Reimplemented in csl::TensorParent.

◆ addSymmetry()

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

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 in csl::TensorParent.

◆ contraction()

Expr csl::AbstractParent::contraction ( const Abstract self,
Expr_info  B 
) const
virtual

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 in csl::MetricParent, csl::DeltaParent, csl::EpsilonParent, and csl::TensorParent.

◆ dependsExplicitlyOn()

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

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 in csl::TensorParent.

◆ dependsOn()

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

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 in csl::TensorParent, and csl::VariableParent.

◆ getCommutable()

bool csl::AbstractParent::getCommutable ( ) const
Returns
commutable

◆ getDim() [1/2]

int csl::AbstractParent::getDim ( ) const
virtual
Returns
The dimension of a parent, i.e. the number of indices.

◆ getDim() [2/2]

int csl::AbstractParent::getDim ( const Space t_space) const
virtual

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 in csl::TensorParent.

◆ getFullyAntiSymmetric()

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

Reimplemented in csl::TensorParent.

◆ getFullySymmetric()

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

Reimplemented in csl::TensorParent.

◆ getName()

std::string const & csl::AbstractParent::getName ( ) const
Returns
name

◆ getPermutation()

vector< Permutation > csl::AbstractParent::getPermutation ( ) const
virtual

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 in csl::TensorParent.

◆ getPrimaryType()

virtual cslParent::PrimaryType csl::AbstractParent::getPrimaryType ( ) const
pure virtual
Returns
The primary type of the parent.

Implemented in csl::TensorParent, csl::TensorFieldParent, csl::LiteralParent, and csl::FieldParent.

◆ getProperties()

const std::vector< Equation * > & csl::AbstractParent::getProperties ( ) const
virtual
Returns
props.

Reimplemented in csl::TensorParent.

◆ getTensor()

Expr csl::AbstractParent::getTensor ( ) const
virtual

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

Returns
tensor.

Reimplemented in csl::TensorParent.

◆ getType()

virtual cslParent::Type csl::AbstractParent::getType ( ) const
pure virtual

◆ hasContractionProperty()

bool csl::AbstractParent::hasContractionProperty ( const Abstract self,
Expr_info  B 
) const
virtual

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 in csl::MetricParent, csl::DeltaParent, csl::EpsilonParent, and csl::TensorParent.

◆ operator()() [1/2]

Expr csl::AbstractParent::operator() ( Index  index)
virtual

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

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

Reimplemented in csl::TensorParent.

◆ operator()() [2/2]

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

Generate the Element for an TensorParent of arbitrary dimension

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

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

◆ removeProperty()

void csl::AbstractParent::removeProperty ( Equation prop)

Removes a property.

Parameters
propProperty to remove.

◆ setCommutable()

void csl::AbstractParent::setCommutable ( bool  t_commutable)
Parameters
t_commutableNew commutability property of the parent.

◆ setName()

void csl::AbstractParent::setName ( std::string  t_name)
virtual
Parameters
t_nameNew name of the parent.

◆ setSymmetry()

void csl::AbstractParent::setSymmetry ( const Symmetry t_symmetry)
virtual

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 in csl::TensorParent.

◆ setTensor()

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

Reimplemented in csl::TensorParent.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  fout,
const AbstractParent parent 
)
friend

Display name and commutability of the parent in standard output.

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

Field Documentation

◆ commutable

bool csl::AbstractParent::commutable
protected

Commutability property of the parent (will be given to the elements when created).

◆ latexName

std::string csl::AbstractParent::latexName
protected

Latex name of the parent.

◆ name

std::string csl::AbstractParent::name
protected

Name of the parent (will be given to the elements when created).

◆ props

std::vector<Equation*> csl::AbstractParent::props
protected

Properties of the parent in a form of a list (std::vector) of equations.


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