C++ Tensor Template Library (TTL)

Specification

 

1.0 General

This is an attempt to build a library using algebra definitions. This means we need an underlying set (represented as class), several operations defined on this set, which we will denote with arithmetic signs +,-,*,/, as well as zero and unary element on this set and means to compare two elements from the set.

The above rools are fulfilled by standard numeric types and classes and they are easy to implement in user classes. It is also planned to add such useful classes to the library.

The same rools are used to build vector / matrix / tensor algebras in the library. This allows simple and intuitive notation for different linear algebra problems.

Strict compile time type-safe checking should include vector / matrix / tensor dimensions.

2.0 Classes

Two twin classes Ket<C,U,D> and Bra<C,U,D> represent vectors with components of type C and dimension D. Class Ket<C,U,D> corresponds to upper tensor index, or matrix rows, and class Bra<C,U,D> corresponds to lower tensor index or matrix columns.

Class U is the class of tensor elements, which is used as terminal class for template recursions. All standard numerical types can be used, as well as other classes, which fulfill certain requirements.

Minimum requirements for user defined class (to create additive group):

Additional requirements to create vector space:

Additional requirements to create a ring or field:

One dimensional tensor (vector) is represented as Ket<U,U,D>, i.e. class U is used as class C. Tensors of higher dimensions are created using another Ket or Bra class as class C, e.g. matrix is represented as Ket<Bra<U,U,D>,U,D>.

3.0 Operations

Operations are divided into several groups. The compiler will allow operations from the group, if corresponding operations on the class U are defined.

Comparison for Ket<C,U,D> (dual for Bra<C,U,D>).

Additive group for Ket<C,U,D> (dual for Bra<C,U,D>).

Vector space over Ket<C,U,D> (dual over Bra<C,U,D>).

Tensor multiplication.

Tensor division, defines also multiplicative group on Ket<Bra<U,U,D>,U,D> (dual on Bra<Ket<U,U,D>,U,D>).