tensor-0.1.0
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Tensors

Data Structures

struct  tensor::CTensor
 Complex Tensor with elements of type "cdouble". More...
 
struct  tensor::RTensor
 Real Tensor with elements of type "double". More...
 
class  tensor::Sparse< elt >
 A sparse matrix. More...
 
class  tensor::Tensor< elt >
 An N-dimensional array of numbers. More...
 

Functions

elt_t & tensor::Tensor< elt >::at (index i)
 Return a mutable reference to an element of a 1D Tensor. More...
 
elt_t & tensor::Tensor< elt >::at (index row, index col)
 Return a mutable reference to an element of a 2D Tensor. More...
 
elt_t & tensor::Tensor< elt >::at (index d1, index d2, index d3)
 Return a mutable reference to an element of a 3D Tensor. More...
 
elt_t & tensor::Tensor< elt >::at (index d1, index d2, index d3, index d4)
 Return a mutable reference to an element of a 4D Tensor. More...
 
elt_t & tensor::Tensor< elt >::at (index d1, index d2, index d3, index d4, index d5)
 Return a mutable reference to an element of a 5D Tensor. More...
 
elt_t & tensor::Tensor< elt >::at (index d1, index d2, index d3, index d4, index d5, index d6)
 Return a mutable reference to an element of 6D Tensor. More...
 
mutable_view tensor::Tensor< elt >::at (PRange r)
 Mutable slice from a 1D Tensor. More...
 
mutable_view tensor::Tensor< elt >::at (PRange r1, PRange r2)
 Mutable slice from a 2D Tensor. More...
 
mutable_view tensor::Tensor< elt >::at (PRange r1, PRange r2, PRange r3)
 Mutable slice from a 3D Tensor. More...
 
mutable_view tensor::Tensor< elt >::at (PRange r1, PRange r2, PRange r3, PRange r4)
 Mutable slice from a 4D Tensor. More...
 
mutable_view tensor::Tensor< elt >::at (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5)
 Mutable slice from a 5D Tensor. More...
 
mutable_view tensor::Tensor< elt >::at (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5, PRange r6)
 Mutable slice from a 6D Tensor. More...
 
elt_t & tensor::Tensor< elt >::at_seq (index i)
 Return a mutable reference to the i-th element of a Tensor, in column major order. More...
 
iterator tensor::Tensor< elt >::begin ()
 Iterator at the beginning. More...
 
const_iterator tensor::Tensor< elt >::begin () const
 Iterator at the beginning. More...
 
const_iterator tensor::Tensor< elt >::begin_const () const
 Iterator at the beginning for const objects. More...
 
index tensor::Tensor< elt >::columns () const
 Query the size of 2nd index. More...
 
const RTensor tensor::conj (const RTensor &r)
 Complex conjugate of a real tensor. More...
 
const Tensor< elt_t > tensor::Tensor< elt >::diag (int which=0, int ndx1=0, int ndx2=-1)
 Take a diagonal from a tensor. More...
 
index tensor::Tensor< elt >::dimension (int which) const
 Length of a given Tensor index. More...
 
const Indices & tensor::Tensor< elt >::dimensions () const
 Return Tensor dimensions. More...
 
const_iterator tensor::Tensor< elt >::end () const
 Iterator at the end for const objects. More...
 
iterator tensor::Tensor< elt >::end ()
 Iterator at the end. More...
 
const_iterator tensor::Tensor< elt >::end_const () const
 Iterator at the end for const objects. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::eye (index rows)
 Identity matrix. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::eye (index rows, index cols)
 Rectangular identity matrix. More...
 
void tensor::Tensor< elt >::fill_with (const elt_t &e)
 Fill with an element. More...
 
void tensor::Tensor< elt >::fill_with_zeros ()
 Fill with zeros. More...
 
const Tensor< double > tensor::fold (const Tensor< double > &a, int ndx1, const Tensor< double > &b, int ndx2)
 Contraction of two tensors. More...
 
const Tensor< cdouble > tensor::fold (const Tensor< cdouble > &a, int ndx1, const Tensor< cdouble > &b, int ndx2)
 Contraction of two tensors. More...
 
const Tensor< double > tensor::foldc (const Tensor< double > &a, int ndx1, const Tensor< double > &b, int ndx2)
 Contraction of two tensors. More...
 
const Tensor< cdouble > tensor::foldc (const Tensor< cdouble > &a, int ndx1, const Tensor< cdouble > &b, int ndx2)
 Contraction of two tensors. More...
 
const Tensor< double > tensor::foldin (const Tensor< double > &a, int _ndx1, const Tensor< double > &b, int _ndx2)
 Contraction of two tensors with complex conjugation. More...
 
const Tensor< cdouble > tensor::foldin (const Tensor< cdouble > &a, int _ndx1, const Tensor< cdouble > &b, int _ndx2)
 Contraction of two tensors with complex conjugation. More...
 
void tensor::foldin_into (Tensor< double > &output, const Tensor< double > &a, int _ndx1, const Tensor< double > &b, int _ndx2)
 Similar to foldin(), but the output has been preallocated.
 
void tensor::foldin_into (Tensor< cdouble > &output, const Tensor< cdouble > &a, int _ndx1, const Tensor< cdouble > &b, int _ndx2)
 Similar to foldin(), but the output has been preallocated.
 
void tensor::Tensor< elt >::get_dimensions (index *length) const
 Query dimensions of 1D Tensor. More...
 
void tensor::Tensor< elt >::get_dimensions (index *rows, index *cols) const
 Query dimensions of 2D Tensor. More...
 
void tensor::Tensor< elt >::get_dimensions (index *d0, index *d1, index *d2) const
 Query dimensions of 3D Tensor. More...
 
void tensor::Tensor< elt >::get_dimensions (index *d0, index *d1, index *d2, index *d3) const
 Query dimensions of 4D Tensor. More...
 
void tensor::Tensor< elt >::get_dimensions (index *d0, index *d1, index *d2, index *d3, index *d4) const
 Query dimensions of 5D Tensor. More...
 
void tensor::Tensor< elt >::get_dimensions (index *d0, index *d1, index *d2, index *d3, index *d4, index *d5) const
 Query dimensions of 6D Tensor. More...
 
bool tensor::Tensor< elt >::is_empty () const
 Does the tensor have elements?
 
const RTensor tensor::linspace (double min, double max, index n)
 Vector of 'n' equally spaced numbers in the interval [min, max]. More...
 
const RTensor tensor::linspace (const RTensor &min, const RTensor &max, index n)
 Tensor of 'n' equally spaced vectors in the interval [min, max]. More...
 
const CTensor tensor::linspace (cdouble min, cdouble max, index n)
 Vector of 'n' equally spaced numbers in the interval [min, max]. More...
 
const CTensor tensor::linspace (const CTensor &min, const CTensor &max, index n)
 Tensor of 'n' equally spaced vectors in the interval [min, max]. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::ones (index rows)
 Matrix of ones. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::ones (index rows, index cols)
 Matrix of ones. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::ones (const Indices &dimensions)
 Tensor of ones. More...
 
const elt_t & tensor::Tensor< elt >::operator() (index i) const
 Return an element of a 1D Tensor. More...
 
const elt_t & tensor::Tensor< elt >::operator() (index row, index col) const
 Return an element of a 2D Tensor. More...
 
const elt_t & tensor::Tensor< elt >::operator() (index d0, index d1, index d2) const
 Return an element of a 3D Tensor. More...
 
const elt_t & tensor::Tensor< elt >::operator() (index d0, index d1, index d2, index d3) const
 Return an element of a 4D Tensor. More...
 
const elt_t & tensor::Tensor< elt >::operator() (index d0, index d1, index d2, index d3, index d4) const
 Return an element of a 5D Tensor. More...
 
const elt_t & tensor::Tensor< elt >::operator() (index d0, index d1, index d2, index d3, index d4, index d5w) const
 Return an element of a 6D Tensor. More...
 
const view tensor::Tensor< elt >::operator() (PRange r) const
 Extracts a slice from a 1D Tensor. More...
 
const view tensor::Tensor< elt >::operator() (PRange r1, PRange r2) const
 Extracts a slice from a 2D Tensor. More...
 
const view tensor::Tensor< elt >::operator() (PRange r1, PRange r2, PRange r3) const
 Extracts a slice from a 3D Tensor. More...
 
const view tensor::Tensor< elt >::operator() (PRange r1, PRange r2, PRange r3, PRange r4) const
 Extracts a slice from a 4D Tensor. More...
 
const view tensor::Tensor< elt >::operator() (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5) const
 Extracts a slice from a 5D Tensor. More...
 
const view tensor::Tensor< elt >::operator() (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5, PRange r6) const
 Extracts a slice from a 6D Tensor. More...
 
const Tensor & tensor::Tensor< elt >::operator= (const Tensor< elt_t > &other)
 Assignment operator. More...
 
const elt_t & tensor::Tensor< elt >::operator[] (index i) const
 Return the i-th element, accessed in column major order. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (index length)
 Build a random 1D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (index rows, index cols)
 Build a random 2D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (index d1, index d2, index d3)
 Build a random 3D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (index d1, index d2, index d3, index d4)
 Build a random 4D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (index d1, index d2, index d3, index d4, index d5)
 Build a random 5D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (index d1, index d2, index d3, index d4, index d5, index d6)
 Build a random 6D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::random (const Indices &dimensions)
 Build a random Tensor with arbitrary dimensions. More...
 
void tensor::Tensor< elt >::randomize ()
 Fills with random numbers. More...
 
int tensor::Tensor< elt >::rank () const
 Number of Tensor indices. More...
 
void tensor::Tensor< elt >::reshape (const Indices &new_dims)
 Change the dimensions, while keeping the data. More...
 
const RTensor tensor::reshape (const RTensor &t, const Indices &new_dims)
 Return a RTensor with same data and given dimensions. More...
 
const RTensor tensor::reshape (const RTensor &t, index length)
 Return a RTensor with same data and given dimensions. More...
 
const RTensor tensor::reshape (const RTensor &t, index rows, index cols)
 Return a RTensor with same data and given dimensions. More...
 
const RTensor tensor::reshape (const RTensor &t, index d1, index d2, index d3)
 Return a RTensor with same data and given dimensions. More...
 
const RTensor tensor::reshape (const RTensor &t, index d1, index d2, index d3, index d4)
 Return a RTensor with same data and given dimensions. More...
 
const RTensor tensor::reshape (const RTensor &t, index d1, index d2, index d3, index d4, index d5)
 Return a RTensor with same data and given dimensions. More...
 
const RTensor tensor::reshape (const RTensor &t, index d1, index d2, index d3, index d4, index d5, index d6)
 Return a RTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, const Indices &new_dims)
 Return a CTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, index length)
 Return a CTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, index rows, index cols)
 Return a CTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, index d1, index d2, index d3)
 Return a CTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, index d1, index d2, index d3, index d4)
 Return a CTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, index d1, index d2, index d3, index d4, index d5)
 Return a CTensor with same data and given dimensions. More...
 
const CTensor tensor::reshape (const CTensor &t, index d1, index d2, index d3, index d4, index d5, index d6)
 Return a CTensor with same data and given dimensions. More...
 
index tensor::Tensor< elt >::rows () const
 Query then size of 1st index. More...
 
const Tensor< double > tensor::scale (const Tensor< double > &t, int ndx, const Tensor< double > &v)
 Hadamard product of a tensor times a vector. More...
 
const Tensor< cdouble > tensor::scale (const Tensor< cdouble > &t, int ndx, const Tensor< cdouble > &v)
 Hadamard product of a tensor times a vector. More...
 
index tensor::Tensor< elt >::size () const
 Returns total number of elements in Tensor. More...
 
const RTensor tensor::squeeze (const RTensor &t)
 Eliminate all singleton dimensions from a tensor, preserving the data. More...
 
const CTensor tensor::squeeze (const CTensor &t)
 Eliminate all singleton dimensions from a tensor, preserving the data. More...
 
const RTensor tensor::take_diag (const RTensor &a, int which, int ndx1, int ndx2)
 Extract a diagonal from a matrix or tensor. More...
 
const CTensor tensor::take_diag (const CTensor &a, int which, int ndx1, int ndx2)
 Extract a diagonal from a matrix or tensor. More...
 
 tensor::Tensor< elt >::Tensor ()
 Constructs an empty Tensor. More...
 
 tensor::Tensor< elt >::Tensor (const Indices &new_dims)
 Constructs an unitialized N-D Tensor given the dimensions. More...
 
 tensor::Tensor< elt >::Tensor (const Indices &new_dims, const Tensor< elt_t > &data)
 Consturcts an N-D Tensor with given initial data. More...
 
 tensor::Tensor< elt >::Tensor (const Vector< elt_t > &data)
 Constructs a 1-D Tensor from a vector. More...
 
 tensor::Tensor< elt >::Tensor (const std::vector< elt_t > &data)
 Constructs a 1-D Tensor from a vector. More...
 
 tensor::Tensor< elt >::Tensor (const Tensor &other)
 Optimized copy constructor (See Optimal copy). More...
 
template<typename e2 >
 tensor::Tensor< elt >::Tensor (const Tensor< e2 > &other)
 Implicit coercion. More...
 
template<size_t n>
 tensor::Tensor< elt >::Tensor (const StaticVector< elt_t, n > &t)
 Create a one-dimensional tensor from data created with "gen" expressions. More...
 
template<size_t n>
 tensor::Tensor< elt >::Tensor (const StaticVector< elt_t, n > &t, const Indices &d)
 Create a general tensor from data created with "gen" expressions. More...
 
 tensor::Tensor< elt >::Tensor (index length)
 Build a 1D Tensor or vector. More...
 
 tensor::Tensor< elt >::Tensor (index rows, index cols)
 Build a 2D Tensor or matrix. More...
 
 tensor::Tensor< elt >::Tensor (index d1, index d2, index d3)
 Build a 3D Tensor. More...
 
 tensor::Tensor< elt >::Tensor (index d1, index d2, index d3, index d4)
 Build a 4D Tensor. More...
 
 tensor::Tensor< elt >::Tensor (index d1, index d2, index d3, index d4, index d5)
 Build a 5D Tensor. More...
 
 tensor::Tensor< elt >::Tensor (index d1, index d2, index d3, index d4, index d5, index d6)
 Build a 6D Tensor. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (index rows)
 Matrix of zeros. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (index rows, index cols)
 Matrix of zeros. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (index d1, index d2, index d3)
 4D Tensor of zeros. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (index d1, index d2, index d3, index d4)
 4D Tensor of zeros. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (index d1, index d2, index d3, index d4, index d5)
 5D Tensor of zeros. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (index d1, index d2, index d3, index d4, index d5, index d6)
 6D Tensor of zeros. More...
 
static const Tensor< elt_t > tensor::Tensor< elt >::zeros (const Indices &dimensions)
 Tensor of zeros. More...
 

Detailed Description

Function Documentation

template<typename elt>
elt_t& tensor::Tensor< elt >::at ( index  i)

Return a mutable reference to an element of a 1D Tensor.

template<typename elt>
elt_t& tensor::Tensor< elt >::at ( index  row,
index  col 
)

Return a mutable reference to an element of a 2D Tensor.

template<typename elt>
elt_t& tensor::Tensor< elt >::at ( index  d1,
index  d2,
index  d3 
)

Return a mutable reference to an element of a 3D Tensor.

template<typename elt>
elt_t& tensor::Tensor< elt >::at ( index  d1,
index  d2,
index  d3,
index  d4 
)

Return a mutable reference to an element of a 4D Tensor.

template<typename elt>
elt_t& tensor::Tensor< elt >::at ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5 
)

Return a mutable reference to an element of a 5D Tensor.

template<typename elt>
elt_t& tensor::Tensor< elt >::at ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5,
index  d6 
)

Return a mutable reference to an element of 6D Tensor.

template<typename elt>
mutable_view tensor::Tensor< elt >::at ( PRange  r)

Mutable slice from a 1D Tensor.

template<typename elt>
mutable_view tensor::Tensor< elt >::at ( PRange  r1,
PRange  r2 
)

Mutable slice from a 2D Tensor.

template<typename elt>
mutable_view tensor::Tensor< elt >::at ( PRange  r1,
PRange  r2,
PRange  r3 
)

Mutable slice from a 3D Tensor.

template<typename elt>
mutable_view tensor::Tensor< elt >::at ( PRange  r1,
PRange  r2,
PRange  r3,
PRange  r4 
)

Mutable slice from a 4D Tensor.

template<typename elt>
mutable_view tensor::Tensor< elt >::at ( PRange  r1,
PRange  r2,
PRange  r3,
PRange  r4,
PRange  r5 
)

Mutable slice from a 5D Tensor.

template<typename elt>
mutable_view tensor::Tensor< elt >::at ( PRange  r1,
PRange  r2,
PRange  r3,
PRange  r4,
PRange  r5,
PRange  r6 
)

Mutable slice from a 6D Tensor.

template<typename elt>
elt_t& tensor::Tensor< elt >::at_seq ( index  i)

Return a mutable reference to the i-th element of a Tensor, in column major order.

template<typename elt>
iterator tensor::Tensor< elt >::begin ( )
inline

Iterator at the beginning.

Definition at line 256 of file tensor.h.

template<typename elt>
const_iterator tensor::Tensor< elt >::begin ( ) const
inline

Iterator at the beginning.

Definition at line 258 of file tensor.h.

template<typename elt>
const_iterator tensor::Tensor< elt >::begin_const ( ) const
inline

Iterator at the beginning for const objects.

Definition at line 260 of file tensor.h.

template<typename elt>
index tensor::Tensor< elt >::columns ( ) const
inline

Query the size of 2nd index.

Definition at line 137 of file tensor.h.

const RTensor tensor::conj ( const RTensor &  r)
inline

Complex conjugate of a real tensor.

Returns the same tensor.

Definition at line 461 of file tensor.h.

template<typename elt>
const Tensor<elt_t> tensor::Tensor< elt >::diag ( int  which = 0,
int  ndx1 = 0,
int  ndx2 = -1 
)
inline

Take a diagonal from a tensor.

Definition at line 272 of file tensor.h.

template<typename elt>
index tensor::Tensor< elt >::dimension ( int  which) const

Length of a given Tensor index.

template<typename elt>
const Indices& tensor::Tensor< elt >::dimensions ( ) const
inline

Return Tensor dimensions.

Definition at line 121 of file tensor.h.

template<typename elt>
const_iterator tensor::Tensor< elt >::end ( ) const
inline

Iterator at the end for const objects.

Definition at line 264 of file tensor.h.

template<typename elt>
iterator tensor::Tensor< elt >::end ( )
inline

Iterator at the end.

Definition at line 266 of file tensor.h.

template<typename elt>
const_iterator tensor::Tensor< elt >::end_const ( ) const
inline

Iterator at the end for const objects.

Definition at line 262 of file tensor.h.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::eye ( index  rows)
inlinestatic

Identity matrix.

Definition at line 231 of file tensor.h.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::eye ( index  rows,
index  cols 
)
static

Rectangular identity matrix.

template<typename elt>
void tensor::Tensor< elt >::fill_with ( const elt_t &  e)

Fill with an element.

template<typename elt>
void tensor::Tensor< elt >::fill_with_zeros ( )
inline

Fill with zeros.

Definition at line 177 of file tensor.h.

const Tensor<double> tensor::fold ( const Tensor< double > &  a,
int  ndx1,
const Tensor< double > &  b,
int  ndx2 
)

Contraction of two tensors.

A contraction is a generalization of the matrix product that we all know. The code C=fold(A,1,B,0) contracts tensors A and B, according to the second and first index as given by the formula

\[ C_{i_0i_1i_3i_4} = \sum_j A_{i_0ji_1} B_{ji_3i_4} \]

There exist variants for these functions for contracting real with real, complex with complex, and real with complex tensors. Depending on the choice of indices, NDX1 and NDX2, the multiplication will be faster or slower. For instance, at least fast products are achieved via the ATLAS library when NDX=0 or 1.

Definition at line 39 of file tensor_fold_d.cc.

const Tensor<cdouble> tensor::fold ( const Tensor< cdouble > &  a,
int  ndx1,
const Tensor< cdouble > &  b,
int  ndx2 
)

Contraction of two tensors.

A contraction is a generalization of the matrix product that we all know. The code C=fold(A,1,B,0) contracts tensors A and B, according to the second and first index as given by the formula

\[ C_{i_0i_1i_3i_4} = \sum_j A_{i_0ji_1} B_{ji_3i_4} \]

There exist variants for these functions for contracting real with real, complex with complex, and real with complex tensors. Depending on the choice of indices, NDX1 and NDX2, the multiplication will be faster or slower. For instance, at least fast products are achieved via the ATLAS library when NDX=0 or 1.

Definition at line 39 of file tensor_fold_z.cc.

const Tensor<double> tensor::foldc ( const Tensor< double > &  a,
int  ndx1,
const Tensor< double > &  b,
int  ndx2 
)

Contraction of two tensors.

The code C=foldc(A,n,B,m) acting on real tensors does the same as fold(A,n,B,m).

Definition at line 52 of file tensor_fold_d.cc.

const Tensor<cdouble> tensor::foldc ( const Tensor< cdouble > &  a,
int  ndx1,
const Tensor< cdouble > &  b,
int  ndx2 
)

Contraction of two tensors.

A contraction is a generalization of the matrix product that we all know. The code C=foldc(A,1,B,0) contracts tensors A and B, according to the second and first index as given by the formula

\[ C_{i_0i_1i_3i_4} = \sum_j A_{i_0ji_1}^* B_{ji_3i_4} \]

There exist variants for these functions for contracting real with real, complex with complex, and real with complex tensors. Depending on the choice of indices, NDX1 and NDX2, the multiplication will be faster or slower. For instance, at least fast products are achieved via the ATLAS library when NDX=0 or 1.

Definition at line 62 of file tensor_fold_z.cc.

const Tensor<double> tensor::foldin ( const Tensor< double > &  a,
int  _ndx1,
const Tensor< double > &  b,
int  _ndx2 
)

Contraction of two tensors with complex conjugation.

Similar to the fold() routine, but the indices of the first tensor are inserted in the output. In other words the code C=foldc(A,1,B,0) performs

\[ C_{i_3i_0i_1i_4} = \sum_j A_{i_0ji_1}^\star B_{ji_3i_4} \]

Definition at line 35 of file tensor_foldin_d.cc.

const Tensor<cdouble> tensor::foldin ( const Tensor< cdouble > &  a,
int  _ndx1,
const Tensor< cdouble > &  b,
int  _ndx2 
)

Contraction of two tensors with complex conjugation.

Similar to the fold() routine, but the indices of the first tensor are inserted in the output. In other words the code C=foldc(A,1,B,0) performs

\[ C_{i_3i_0i_1i_4} = \sum_j A_{i_0ji_1}^\star B_{ji_3i_4} \]

Definition at line 35 of file tensor_foldin_z.cc.

template<typename elt>
void tensor::Tensor< elt >::get_dimensions ( index *  length) const

Query dimensions of 1D Tensor.

template<typename elt>
void tensor::Tensor< elt >::get_dimensions ( index *  rows,
index *  cols 
) const

Query dimensions of 2D Tensor.

template<typename elt>
void tensor::Tensor< elt >::get_dimensions ( index *  d0,
index *  d1,
index *  d2 
) const

Query dimensions of 3D Tensor.

template<typename elt>
void tensor::Tensor< elt >::get_dimensions ( index *  d0,
index *  d1,
index *  d2,
index *  d3 
) const

Query dimensions of 4D Tensor.

template<typename elt>
void tensor::Tensor< elt >::get_dimensions ( index *  d0,
index *  d1,
index *  d2,
index *  d3,
index *  d4 
) const

Query dimensions of 5D Tensor.

template<typename elt>
void tensor::Tensor< elt >::get_dimensions ( index *  d0,
index *  d1,
index *  d2,
index *  d3,
index *  d4,
index *  d5 
) const

Query dimensions of 6D Tensor.

const RTensor tensor::linspace ( double  min,
double  max,
index  n 
)

Vector of 'n' equally spaced numbers in the interval [min, max].

Definition at line 27 of file linspace_d.cc.

const RTensor tensor::linspace ( const RTensor &  min,
const RTensor &  max,
index  n 
)

Tensor of 'n' equally spaced vectors in the interval [min, max].

Definition at line 36 of file linspace_d.cc.

const CTensor tensor::linspace ( cdouble  min,
cdouble  max,
index  n 
)

Vector of 'n' equally spaced numbers in the interval [min, max].

Definition at line 27 of file linspace_z.cc.

const CTensor tensor::linspace ( const CTensor &  min,
const CTensor &  max,
index  n 
)

Tensor of 'n' equally spaced vectors in the interval [min, max].

Definition at line 36 of file linspace_z.cc.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::ones ( index  rows)
inlinestatic

Matrix of ones.

Definition at line 249 of file tensor.h.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::ones ( index  rows,
index  cols 
)
static

Matrix of ones.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::ones ( const Indices dimensions)
static

Tensor of ones.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator() ( index  i) const

Return an element of a 1D Tensor.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator() ( index  row,
index  col 
) const

Return an element of a 2D Tensor.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator() ( index  d0,
index  d1,
index  d2 
) const

Return an element of a 3D Tensor.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator() ( index  d0,
index  d1,
index  d2,
index  d3 
) const

Return an element of a 4D Tensor.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator() ( index  d0,
index  d1,
index  d2,
index  d3,
index  d4 
) const

Return an element of a 5D Tensor.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator() ( index  d0,
index  d1,
index  d2,
index  d3,
index  d4,
index  d5w 
) const

Return an element of a 6D Tensor.

template<typename elt>
const view tensor::Tensor< elt >::operator() ( PRange  r) const

Extracts a slice from a 1D Tensor.

template<typename elt>
const view tensor::Tensor< elt >::operator() ( PRange  r1,
PRange  r2 
) const

Extracts a slice from a 2D Tensor.

template<typename elt>
const view tensor::Tensor< elt >::operator() ( PRange  r1,
PRange  r2,
PRange  r3 
) const

Extracts a slice from a 3D Tensor.

template<typename elt>
const view tensor::Tensor< elt >::operator() ( PRange  r1,
PRange  r2,
PRange  r3,
PRange  r4 
) const

Extracts a slice from a 4D Tensor.

template<typename elt>
const view tensor::Tensor< elt >::operator() ( PRange  r1,
PRange  r2,
PRange  r3,
PRange  r4,
PRange  r5 
) const

Extracts a slice from a 5D Tensor.

template<typename elt>
const view tensor::Tensor< elt >::operator() ( PRange  r1,
PRange  r2,
PRange  r3,
PRange  r4,
PRange  r5,
PRange  r6 
) const

Extracts a slice from a 6D Tensor.

template<typename elt>
const Tensor& tensor::Tensor< elt >::operator= ( const Tensor< elt_t > &  other)

Assignment operator.

template<typename elt>
const elt_t& tensor::Tensor< elt >::operator[] ( index  i) const

Return the i-th element, accessed in column major order.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( index  length)
static

Build a random 1D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( index  rows,
index  cols 
)
static

Build a random 2D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( index  d1,
index  d2,
index  d3 
)
static

Build a random 3D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( index  d1,
index  d2,
index  d3,
index  d4 
)
static

Build a random 4D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5 
)
static

Build a random 5D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5,
index  d6 
)
static

Build a random 6D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::random ( const Indices dimensions)
static

Build a random Tensor with arbitrary dimensions.

template<typename elt>
void tensor::Tensor< elt >::randomize ( )

Fills with random numbers.

template<typename elt>
int tensor::Tensor< elt >::rank ( ) const
inline

Number of Tensor indices.

Definition at line 119 of file tensor.h.

template<typename elt>
void tensor::Tensor< elt >::reshape ( const Indices new_dims)

Change the dimensions, while keeping the data.

const RTensor tensor::reshape ( const RTensor &  t,
const Indices &  new_dims 
)

Return a RTensor with same data and given dimensions.

Definition at line 25 of file tensor_reshape_d.cc.

const RTensor tensor::reshape ( const RTensor &  t,
index  length 
)

Return a RTensor with same data and given dimensions.

Definition at line 31 of file tensor_reshape_d.cc.

const RTensor tensor::reshape ( const RTensor &  t,
index  rows,
index  cols 
)

Return a RTensor with same data and given dimensions.

Definition at line 39 of file tensor_reshape_d.cc.

const RTensor tensor::reshape ( const RTensor &  t,
index  d1,
index  d2,
index  d3 
)

Return a RTensor with same data and given dimensions.

Definition at line 48 of file tensor_reshape_d.cc.

const RTensor tensor::reshape ( const RTensor &  t,
index  d1,
index  d2,
index  d3,
index  d4 
)

Return a RTensor with same data and given dimensions.

Definition at line 58 of file tensor_reshape_d.cc.

const RTensor tensor::reshape ( const RTensor &  t,
index  d1,
index  d2,
index  d3,
index  d4,
index  d5 
)

Return a RTensor with same data and given dimensions.

Definition at line 70 of file tensor_reshape_d.cc.

const RTensor tensor::reshape ( const RTensor &  t,
index  d1,
index  d2,
index  d3,
index  d4,
index  d5,
index  d6 
)

Return a RTensor with same data and given dimensions.

Definition at line 83 of file tensor_reshape_d.cc.

const CTensor tensor::reshape ( const CTensor &  t,
const Indices &  new_dims 
)

Return a CTensor with same data and given dimensions.

Definition at line 25 of file tensor_reshape_z.cc.

const CTensor tensor::reshape ( const CTensor &  t,
index  length 
)

Return a CTensor with same data and given dimensions.

Definition at line 31 of file tensor_reshape_z.cc.

const CTensor tensor::reshape ( const CTensor &  t,
index  rows,
index  cols 
)

Return a CTensor with same data and given dimensions.

Definition at line 39 of file tensor_reshape_z.cc.

const CTensor tensor::reshape ( const CTensor &  t,
index  d1,
index  d2,
index  d3 
)

Return a CTensor with same data and given dimensions.

Definition at line 48 of file tensor_reshape_z.cc.

const CTensor tensor::reshape ( const CTensor &  t,
index  d1,
index  d2,
index  d3,
index  d4 
)

Return a CTensor with same data and given dimensions.

Definition at line 58 of file tensor_reshape_z.cc.

const CTensor tensor::reshape ( const CTensor &  t,
index  d1,
index  d2,
index  d3,
index  d4,
index  d5 
)

Return a CTensor with same data and given dimensions.

Definition at line 70 of file tensor_reshape_z.cc.

const CTensor tensor::reshape ( const CTensor &  t,
index  d1,
index  d2,
index  d3,
index  d4,
index  d5,
index  d6 
)

Return a CTensor with same data and given dimensions.

Definition at line 83 of file tensor_reshape_z.cc.

template<typename elt>
index tensor::Tensor< elt >::rows ( ) const
inline

Query then size of 1st index.

Definition at line 139 of file tensor.h.

const Tensor<double> tensor::scale ( const Tensor< double > &  t,
int  ndx,
const Tensor< double > &  v 
)

Hadamard product of a tensor times a vector.

A Hadamard product consists on multiplying the element that have equal indices. For instance, if the tensor T has three indices, the call {scale(t, 1, v)} would be equivalent to $t_{i,j,k}v_j$.

Definition at line 31 of file tensor_scale_d.cc.

const Tensor<cdouble> tensor::scale ( const Tensor< cdouble > &  t,
int  ndx,
const Tensor< cdouble > &  v 
)

Hadamard product of a tensor times a vector.

A Hadamard product consists on multiplying the element that have equal indices. For instance, if the tensor T has three indices, the call {scale(t, 1, v)} would be equivalent to $t_{i,j,k}v_j$.

Definition at line 31 of file tensor_scale_z.cc.

template<typename elt>
index tensor::Tensor< elt >::size ( ) const
inline

Returns total number of elements in Tensor.

Definition at line 114 of file tensor.h.

const RTensor tensor::squeeze ( const RTensor &  t)

Eliminate all singleton dimensions from a tensor, preserving the data.

Definition at line 27 of file tensor_squeeze_d.cc.

const CTensor tensor::squeeze ( const CTensor &  t)

Eliminate all singleton dimensions from a tensor, preserving the data.

Definition at line 27 of file tensor_squeeze_z.cc.

const RTensor tensor::take_diag ( const RTensor &  a,
int  which,
int  ndx1,
int  ndx2 
)

Extract a diagonal from a matrix or tensor.

For a matrix, it extracts a vector of matrix elements that follow the formula $A(i,i+which)$. For a tensor, we do a similar operation but acting on the indices 'ndx1' and 'ndx2'.

Definition at line 30 of file tensor_take_diag_d.cc.

const CTensor tensor::take_diag ( const CTensor &  a,
int  which,
int  ndx1,
int  ndx2 
)

Extract a diagonal from a matrix or tensor.

For a matrix, it extracts a vector of matrix elements that follow the formula $A(i,i+which)$. For a tensor, we do a similar operation but acting on the indices 'ndx1' and 'ndx2'.

Definition at line 30 of file tensor_take_diag_z.cc.

template<typename elt>
tensor::Tensor< elt >::Tensor ( )

Constructs an empty Tensor.

template<typename elt>
tensor::Tensor< elt >::Tensor ( const Indices new_dims)
explicit

Constructs an unitialized N-D Tensor given the dimensions.

template<typename elt>
tensor::Tensor< elt >::Tensor ( const Indices new_dims,
const Tensor< elt_t > &  data 
)

Consturcts an N-D Tensor with given initial data.

template<typename elt>
tensor::Tensor< elt >::Tensor ( const Vector< elt_t > &  data)

Constructs a 1-D Tensor from a vector.

template<typename elt>
tensor::Tensor< elt >::Tensor ( const std::vector< elt_t > &  data)
inline

Constructs a 1-D Tensor from a vector.

Definition at line 66 of file tensor.h.

template<typename elt>
tensor::Tensor< elt >::Tensor ( const Tensor< elt > &  other)

Optimized copy constructor (See Optimal copy).

template<typename elt>
template<typename e2 >
tensor::Tensor< elt >::Tensor ( const Tensor< e2 > &  other)
inline

Implicit coercion.

Definition at line 77 of file tensor.h.

template<typename elt>
template<size_t n>
tensor::Tensor< elt >::Tensor ( const StaticVector< elt_t, n > &  t)
inline

Create a one-dimensional tensor from data created with "gen" expressions.

Definition at line 84 of file tensor.h.

template<typename elt>
template<size_t n>
tensor::Tensor< elt >::Tensor ( const StaticVector< elt_t, n > &  t,
const Indices d 
)
inline

Create a general tensor from data created with "gen" expressions.

Definition at line 89 of file tensor.h.

template<typename elt>
tensor::Tensor< elt >::Tensor ( index  length)
explicit

Build a 1D Tensor or vector.

template<typename elt>
tensor::Tensor< elt >::Tensor ( index  rows,
index  cols 
)

Build a 2D Tensor or matrix.

template<typename elt>
tensor::Tensor< elt >::Tensor ( index  d1,
index  d2,
index  d3 
)

Build a 3D Tensor.

template<typename elt>
tensor::Tensor< elt >::Tensor ( index  d1,
index  d2,
index  d3,
index  d4 
)

Build a 4D Tensor.

template<typename elt>
tensor::Tensor< elt >::Tensor ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5 
)

Build a 5D Tensor.

template<typename elt>
tensor::Tensor< elt >::Tensor ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5,
index  d6 
)

Build a 6D Tensor.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( index  rows)
inlinestatic

Matrix of zeros.

Definition at line 235 of file tensor.h.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( index  rows,
index  cols 
)
static

Matrix of zeros.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( index  d1,
index  d2,
index  d3 
)
static

4D Tensor of zeros.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( index  d1,
index  d2,
index  d3,
index  d4 
)
static

4D Tensor of zeros.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5 
)
static

5D Tensor of zeros.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( index  d1,
index  d2,
index  d3,
index  d4,
index  d5,
index  d6 
)
static

6D Tensor of zeros.

template<typename elt>
static const Tensor<elt_t> tensor::Tensor< elt >::zeros ( const Indices dimensions)
static

Tensor of zeros.