xerus
a general purpose tensor library
xerus::Index Class Reference

Class used to represent indices that can be used to write tensor calculations in index notation. More...

#include <index.h>

Collaboration diagram for xerus::Index:

Public Types

enum  Flag {
  FIXED, INVERSE_SPAN, FRACTIONAL_SPAN, ASSINGED,
  OPEN, NUM_FLAGS
}
 Enum defining the possible flags an Index my possess. More...
 

Public Member Functions

 Index ()
 Empty constructor that creates a new Index with new ID. Use this to create indices. More...
 
 Index (const Index &_other) noexcept=default
 Indices are default copy constructable. More...
 
 Index (const int32 _i)
 Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B. More...
 
 Index (const uint32 _i) noexcept
 Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B. More...
 
 Index (const int64 _i)
 Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B. More...
 
 Index (const uint64 _i) noexcept
 Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B. More...
 
 Index (const uint64 _valueId, const size_t _span) noexcept
 Internal constructor, do not use this unless you know what you are doing. More...
 
 Index (const uint64 _valueId, const size_t _span, const Flag _flag1) noexcept
 Internal constructor, do not use this unless you know what you are doing. More...
 
size_t actual_span (const size_t _degree) const
 Returns the span this index actually represents in a tensor of given order. More...
 
size_t dimension () const
 Returns the (mult)Dimension assinged to this index. More...
 
bool fixed () const
 Checks whether the Index represents a fixed number. More...
 
size_t fixed_position () const
 : Returns the fixed position of a fixed index. More...
 
bool open () const
 Checks whether the index is open. More...
 
void open (const bool _open)
 : Sets whether the index is open. More...
 
Index operator & (const size_t _span) const
 : Allow the creation of Indices covering all but x dimensions using the and operator. E.g. A() = B(i&0) * C(i&0), defines A as the full contraction between B and C, indifferent of the actual degree of B and C. More...
 
Index operator/ (const size_t _span) const
 : Allow the creation of Indices covering an x-th fraction of the indices. E.g. A(i&0) = B(i/2, j/2) * C(j&0), defines A as the contraction between the symmetric matrification of B and the vectorisation of C, indifferent of the actual degree of B and C. More...
 
Indexoperator= (const Index &)=default
 Indices are default assignable. More...
 
Index operator^ (const size_t _span) const
 : Allow the creation of Indices covering more than one dimension using the power operator. E.g. A(i^2) = B(i^2) + C(i^2), defines A as the entriewise sum of the matrices B and C. More...
 
void set_span (const size_t _degree)
 Returns the span this index actually represents in a tensor of given order. More...
 

Static Public Member Functions

static bool all_open (const std::vector< Index > &_indices)
 : Checks whether all indices in _indices are open. This is naturally only usefull for assinged indices, i.e. indices returned by IndexedTensorReadOnly::get_assigned_indices(). More...
 

Public Attributes

size_t assingedDimension = 0
 The product of the external dimensions this index correstponds to. Only set for assinged indices. More...
 
std::bitset< NUM_FLAGSflags
 Bitset of all possible flags the index may possess. More...
 
size_t span = 1
 The span states how many dimensions are covered by the index. More...
 
uint64 valueId
 Unqiue ID of the index. In case the fixed flag is set, this is the fixed position. More...
 

Detailed Description

Class used to represent indices that can be used to write tensor calculations in index notation.

The xerus::Index class is used to write indexed tensor expressen, e.g. A(i,j)*B(j,k). Here i,j,k are of type xerus::Index. The Index class provides numerous information used internally. As an enduser only the basic constructors and the ^, &, and / operators should of interest.

Definition at line 43 of file index.h.

Member Enumeration Documentation

◆ Flag

Enum defining the possible flags an Index my possess.

Enumerator
FIXED 
INVERSE_SPAN 
FRACTIONAL_SPAN 
ASSINGED 
OPEN 
NUM_FLAGS 

Definition at line 47 of file index.h.

Constructor & Destructor Documentation

◆ Index() [1/8]

xerus::Index::Index ( )

Empty constructor that creates a new Index with new ID. Use this to create indices.

Definition at line 37 of file index.cpp.

◆ Index() [2/8]

xerus::Index::Index ( const Index _other)
defaultnoexcept

Indices are default copy constructable.

◆ Index() [3/8]

xerus::Index::Index ( const int32  _i)

Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B.

Definition at line 40 of file index.cpp.

◆ Index() [4/8]

xerus::Index::Index ( const uint32  _i)
noexcept

Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B.

Definition at line 44 of file index.cpp.

◆ Index() [5/8]

xerus::Index::Index ( const int64  _i)

Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B.

Definition at line 48 of file index.cpp.

◆ Index() [6/8]

xerus::Index::Index ( const uint64  _i)
noexcept

Integers are implicitly allowed to be casted to Index, to allow expression as A(i) = B(3,i), i.e. A is the third row of B.

Definition at line 52 of file index.cpp.

◆ Index() [7/8]

xerus::Index::Index ( const uint64  _valueId,
const size_t  _span 
)
explicitnoexcept

Internal constructor, do not use this unless you know what you are doing.

Definition at line 56 of file index.cpp.

◆ Index() [8/8]

xerus::Index::Index ( const uint64  _valueId,
const size_t  _span,
const Flag  _flag1 
)
explicitnoexcept

Internal constructor, do not use this unless you know what you are doing.

Definition at line 59 of file index.cpp.

Member Function Documentation

◆ actual_span()

size_t xerus::Index::actual_span ( const size_t  _degree) const

Returns the span this index actually represents in a tensor of given order.

Definition at line 80 of file index.cpp.

◆ all_open()

bool xerus::Index::all_open ( const std::vector< Index > &  _indices)
static

: Checks whether all indices in _indices are open. This is naturally only usefull for assinged indices, i.e. indices returned by IndexedTensorReadOnly::get_assigned_indices().

Parameters
_indicesstd::vector of indices to check. Every contained index is required to be assinged.

Definition at line 153 of file index.cpp.

◆ dimension()

size_t xerus::Index::dimension ( ) const

Returns the (mult)Dimension assinged to this index.

Definition at line 123 of file index.cpp.

◆ fixed()

bool xerus::Index::fixed ( ) const

Checks whether the Index represents a fixed number.

Definition at line 96 of file index.cpp.

◆ fixed_position()

size_t xerus::Index::fixed_position ( ) const

: Returns the fixed position of a fixed index.

Definition at line 129 of file index.cpp.

◆ open() [1/2]

bool xerus::Index::open ( ) const

Checks whether the index is open.

Definition at line 111 of file index.cpp.

◆ open() [2/2]

void xerus::Index::open ( const bool  _open)

: Sets whether the index is open.

Parameters
_opennew openness status of the index.

Definition at line 117 of file index.cpp.

◆ operator &()

Index xerus::Index::operator& ( const size_t  _span) const

: Allow the creation of Indices covering all but x dimensions using the and operator. E.g. A() = B(i&0) * C(i&0), defines A as the full contraction between B and C, indifferent of the actual degree of B and C.

Parameters
_spanNumber of dimensions NOT to be covered by this index.

◆ operator/()

Index xerus::Index::operator/ ( const size_t  _span) const

: Allow the creation of Indices covering an x-th fraction of the indices. E.g. A(i&0) = B(i/2, j/2) * C(j&0), defines A as the contraction between the symmetric matrification of B and the vectorisation of C, indifferent of the actual degree of B and C.

Parameters
_spanthe fraction of the dimensions to be covered by this index.

Definition at line 147 of file index.cpp.

◆ operator=()

Index& xerus::Index::operator= ( const Index )
default

Indices are default assignable.

◆ operator^()

Index xerus::Index::operator^ ( const size_t  _span) const

: Allow the creation of Indices covering more than one dimension using the power operator. E.g. A(i^2) = B(i^2) + C(i^2), defines A as the entriewise sum of the matrices B and C.

Parameters
_spanThe number of dimensions the index is supposed to cover.

Definition at line 135 of file index.cpp.

◆ set_span()

void xerus::Index::set_span ( const size_t  _degree)

Returns the span this index actually represents in a tensor of given order.

Definition at line 64 of file index.cpp.

Member Data Documentation

◆ assingedDimension

size_t xerus::Index::assingedDimension = 0

The product of the external dimensions this index correstponds to. Only set for assinged indices.

Definition at line 68 of file index.h.

◆ flags

std::bitset<NUM_FLAGS> xerus::Index::flags

Bitset of all possible flags the index may possess.

Definition at line 71 of file index.h.

◆ span

size_t xerus::Index::span = 1

The span states how many dimensions are covered by the index.

Definition at line 65 of file index.h.

◆ valueId

uint64 xerus::Index::valueId

Unqiue ID of the index. In case the fixed flag is set, this is the fixed position.

Definition at line 62 of file index.h.


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