Documentation of CSL
Public Member Functions | Data Fields | Static Public Attributes | Protected Attributes
csl::Space Class Reference

Vector space that has a name, a dimension, a delta tensor and possibly a non-trivial metric. If a metric is given, the indices in this space are signed, i.e. their up- or down- position matter in expressions. More...

#include <space.h>

Public Member Functions

 Space (const std::string &t_name, int t_dim, std::vector< std::string > const &indexNames={"i", "j", "k", "l"})
 Initializes the name and the dimension of the space, no metric so only the kronecker delta is relevant, and indices are not signed. More...
 
 Space (const std::string &t_name, int t_dim, const std::string &name_metric, const Expr &t_metric, std::vector< std::string > const &indexNames={"i", "j", "k", "l"})
 Initializes name, dimension of the space. Here the metrix is given by the user (also its explicit tensor, like diag (-1,1,1,1) for the Minkowski Space). This constructor constructs then a Space with signed indices and a non-trivial metric. More...
 
virtual ~Space ()
 Destructor.
 
virtual void printCode (std::ostream &out, int indentSize) const
 
virtual void printDefinition (std::ostream &out, int indentSize, bool header=false) const
 
virtual std::string getName () const
 
std::string getNextIndexName () const
 
std::string getIndexName (char spec) const
 
std::string_view getIndexNameView (char spec) const
 
char getSpecFromIndexName (std::string const &t_name) const
 
int getDim () const
 
bool getSignedIndex () const
 
virtual bool hasSpecialTraceProperty (const csl::vector_expr &tensors) const
 
csl::vector_expr getSignature () const
 
Tensor getMetric () const
 
Tensor getInverseMetric () const
 
Tensor getDelta () const
 
Tensor getEpsilon () const
 
Expr applyMetricOnTensor (Expr const &tensor, size_t axis, bool covariant) const
 
Index generateIndex (const std::string &name) const
 Generates and returns an index in the right Space (itself) of name name. More...
 
Index generateIndex () const
 Generates and returns an index in the right Space (itself) of name defined by the program. For now the index is name i_{number}, but in the future one should be able to defined a set of names for a given space, for example {"mu", "nu", "rhi", "sigma"}... More...
 
std::vector< IndexgenerateIndices (size_t N) const
 
std::vector< IndexgenerateIndices (size_t N, const std::string &name) const
 
Index generateSimilar (const Index &model) const
 
void resetIndexNumber () const
 
void refreshIndexName (Index &index) const
 
Expr generateVector (const std::string &t_name) const
 Generates and returns a Vector in the right Space (itself) of name name, filled with Variable objects as components (X_0, X_1, ...) for a name "X". More...
 
std::string generateVectorName (const std::string &t_name) const
 
void addIndexNames (const std::string &name) const
 
void addVectorNames (const std::string &name) const
 
void addIndexNames (const std::vector< std::string > &names) const
 
void addVectorNames (const std::vector< std::string > &names) const
 
virtual Expr calculateTrace (csl::vector_expr tensors) const
 

Data Fields

bool keepCycles = false
 

Static Public Attributes

static bool applyMetric = true
 

Protected Attributes

std::string name
 Name of the vector space.
 
int dim
 Dimension of the space.
 
bool signedIndex
 Property of indices: if true, it means that the metric is non trivial (given by the user at initialization) and that up- or down- position of indices matter in expressions.
 
std::map< char, std::string > nameIndices
 
std::map< std::string, char > specIndices
 
std::vector< std::pair< std::string, Index::ID_type > > availableIndices
 
std::vector< std::pair< std::string, unsigned short > > availableVectors
 
std::vector< std::string >::const_iterator defaultName
 
std::vector< std::string > defaultIndexNames
 
Tensor delta
 Kronecker delta, public attribute for readability in usage. Element i,j of the tensor is then accessible by space.delta({i,j}) with i,j indices in this space. More...
 
Tensor metric
 Public attribute for readability in usage. Element i,j of the tensor is then accessible by space.metric({i,j}) with i,j indices in this space. It corresponds to the metric of the space if it is non trivial, or is redirected to the kronecker delta else. More...
 
Tensor inverseMetric
 
Tensor epsilon
 

Detailed Description

Vector space that has a name, a dimension, a delta tensor and possibly a non-trivial metric. If a metric is given, the indices in this space are signed, i.e. their up- or down- position matter in expressions.

Constructor & Destructor Documentation

◆ Space() [1/2]

csl::Space::Space ( const std::string &  t_name,
int  t_dim,
std::vector< std::string > const &  indexNames = {"i", "j", "k", "l"} 
)

Initializes the name and the dimension of the space, no metric so only the kronecker delta is relevant, and indices are not signed.

Parameters
t_nameName of the Space.
t_dimDimension of the Space.

◆ Space() [2/2]

csl::Space::Space ( const std::string &  t_name,
int  t_dim,
const std::string &  name_metric,
const Expr t_metric,
std::vector< std::string > const &  indexNames = {"i", "j", "k", "l"} 
)

Initializes name, dimension of the space. Here the metrix is given by the user (also its explicit tensor, like diag (-1,1,1,1) for the Minkowski Space). This constructor constructs then a Space with signed indices and a non-trivial metric.

Parameters
t_nameName of the Space.
t_dimDimension of the Space.
name_metricName of the metric. Can be set to CSL_UNDEF. In this case the tensor metric will not be defined (but the indexed object g_ab will).
t_metricExplicit TensorElement for the metric (should be a 2D square matrix, symmetric).

Member Function Documentation

◆ generateIndex() [1/2]

Index csl::Space::generateIndex ( const std::string &  name) const
inline

Generates and returns an index in the right Space (itself) of name name.

Parameters
nameName of the Index.
Returns
An Index of name name living in the Space *this.

◆ generateIndex() [2/2]

Index csl::Space::generateIndex ( ) const
inline

Generates and returns an index in the right Space (itself) of name defined by the program. For now the index is name i_{number}, but in the future one should be able to defined a set of names for a given space, for example {"mu", "nu", "rhi", "sigma"}...

Returns
An Index of name i_{number} living in the Space *this.

◆ generateVector()

Expr csl::Space::generateVector ( const std::string &  t_name) const

Generates and returns a Vector in the right Space (itself) of name name, filled with Variable objects as components (X_0, X_1, ...) for a name "X".

Parameters
nameName of the Vector.
Returns
A Vector of Variables living in the Space *this.

◆ getDim()

int csl::Space::getDim ( ) const
inline
Returns
The dimension of the Space.

◆ getName()

std::string csl::Space::getName ( ) const
virtual
Returns
The name of the Space.

◆ getSignedIndex()

bool csl::Space::getSignedIndex ( ) const
inline
Returns
True if the indices in this Space are signed.
False else.

Field Documentation

◆ delta

Tensor csl::Space::delta
mutableprotected

Kronecker delta, public attribute for readability in usage. Element i,j of the tensor is then accessible by space.delta({i,j}) with i,j indices in this space.

This attribute is mutable because access functions for parents (operator() to get TensorElement) is not const, and all many Space objects are declared const. So we declare this attribute mutable so that the compiler allows it to be changed, event for Space objets declared const.

◆ metric

Tensor csl::Space::metric
mutableprotected

Public attribute for readability in usage. Element i,j of the tensor is then accessible by space.metric({i,j}) with i,j indices in this space. It corresponds to the metric of the space if it is non trivial, or is redirected to the kronecker delta else.

This attribute is mutable because access functions for parents (operator() to get TensorElement) is not const, and all many Space objects are declared const. So we declare this attribute mutable so that the compiler allows it to be changed, event for Space objets declared const.


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