Tensors

Header file tensor.h

General tensor class

Name
Tensor
Purpose
Representation of tensors, i.e. arrays of objects of the same type, with rules for arithmetic operations.
Inheritance
Arithmetic_matrix of objects (template class).

Constituents

(As for Arithmetic_matrix, plus index_type. )

Methods

(Extending Arithmetic_matrix)
Creation
Input and output
 The << and >> operators can be used.

The class also provides Read_elements and Write_elements methods to read and write the elements only, without the number of rows and columns.) e.g.
Tensor x; cin >> x; cout << x << endl; x.Write_elements(cout);
Assignment
=

e.g. Tensor x,y; cin >> x; y = x;
Inner and outer products
 Where a contraction is performed over a pair of indices, the tensors must have the same number of entries in those indices.
e.g.
  •    Tensor x,y; cin >> x >> y;

  •  

    General tensor class (fixed dimension)

    Name
    Tensor_fixed_dimension
    Inheritance
    tensor
    A Tensor_fixed is exactly the same as a Tensor, except that the Read and Write methods are redefined to omit the number of elements. (This means that the number of elements must be set before a Tensor_fixed_dimension is read.)

    This class is the base for tensors of a specific dimension.