MADNESS 0.10.1
madness::TensorIterator< T, Q, R > Class Template Reference

#include <tensoriter.h>

Public Member Functions

 TensorIterator (const Tensor< T > *t0, const Tensor< Q > *t1=0, const Tensor< R > *t2=0, long iterlevel=0, bool optimize=true, bool fusedim=true, long jdim=default_jdim)
 Constructor for general iterator to compose operations over up to three tensors.
bool operator!= (const TensorIterator< T, Q, R > &a) const
T & operator* () const
TensorIterator< T, Q, R > & operator++ ()
TensorIterator< T, Q, R > * operator-> ()
bool operator== (const TensorIterator< T, Q, R > &a) const
void reset ()
 Reset the iterator back to the start ...
void reuse (const Tensor< T > *t0, const Tensor< Q > *t1=0, const Tensor< R > *t2=0)
 Reuse this iterator to iterate over other Tensors.

Public Attributes

T * _p0
Q * _p1
R * _p2
long _s0
long _s1
long _s2
long dim [TENSOR_MAXDIM]
long dimj
long ind [TENSOR_MAXDIM]
long ndim
long stride0 [TENSOR_MAXDIM]
long stride1 [TENSOR_MAXDIM]
long stride2 [TENSOR_MAXDIM]

Private Attributes

T * _p0_save
Q * _p1_save
R * _p2_save

Detailed Description

template<class T, class Q = T, class R = T>
class madness::TensorIterator< T, Q, R >

Optimized iterator for tensors supporting unary, binary and ternary operations.

Member Function Documentation

◆ operator!=()

template<class T, class Q = T, class R = T>
bool madness::TensorIterator< T, Q, R >::operator!= ( const TensorIterator< T, Q, R > & a) const
inline

References TensorIterator(), _p0, and a.

◆ operator*()

template<class T, class Q = T, class R = T>
T & madness::TensorIterator< T, Q, R >::operator* ( ) const
inline

References _p0.

◆ operator++()

template<class T, class Q, class R>
TensorIterator< T, Q, R > & madness::TensorIterator< T, Q, R >::operator++ ( )

References TensorIterator(), _p0, _p1, _p2, d, dim, ind, ndim, stride0, stride1, and stride2.

◆ operator->()

template<class T, class Q = T, class R = T>
TensorIterator< T, Q, R > * madness::TensorIterator< T, Q, R >::operator-> ( )
inline

References TensorIterator().

◆ operator==()

template<class T, class Q = T, class R = T>
bool madness::TensorIterator< T, Q, R >::operator== ( const TensorIterator< T, Q, R > & a) const
inline

References TensorIterator(), _p0, and a.

◆ reset()

template<class T, class Q, class R>
void madness::TensorIterator< T, Q, R >::reset ( )

Reset the iterator back to the start ...

References _p0, _p0_save, _p1, _p1_save, _p2, _p2_save, ind, and TENSOR_MAXDIM.

Referenced by madness::inner_result(), and madness::outer_result().

◆ reuse()

template<class T, class Q, class R>
void madness::TensorIterator< T, Q, R >::reuse ( const Tensor< T > * t0,
const Tensor< Q > * t1 = 0,
const Tensor< R > * t2 = 0 )

Reuse this iterator to iterate over other Tensors.

The point of this method is to optimize away the construction of a TensorIterator when applying the same operation repeatedly to multiple tensors with identical shapes & strides. We trust the caller to ensure all shapes & strides match between the new tensors and the ones used in the original constructor.

References _p0, _p0_save, _p1, _p1_save, _p2, _p2_save, ind, madness::Tensor< T >::ptr(), and TENSOR_MAXDIM.

Member Data Documentation

◆ _p0

◆ _p0_save

template<class T, class Q = T, class R = T>
T* madness::TensorIterator< T, Q, R >::_p0_save
private

Referenced by TensorIterator(), reset(), and reuse().

◆ _p1

template<class T, class Q = T, class R = T>
Q* madness::TensorIterator< T, Q, R >::_p1

◆ _p1_save

template<class T, class Q = T, class R = T>
Q* madness::TensorIterator< T, Q, R >::_p1_save
private

Referenced by TensorIterator(), reset(), and reuse().

◆ _p2

template<class T, class Q = T, class R = T>
R* madness::TensorIterator< T, Q, R >::_p2

◆ _p2_save

template<class T, class Q = T, class R = T>
R* madness::TensorIterator< T, Q, R >::_p2_save
private

Referenced by TensorIterator(), reset(), and reuse().

◆ _s0

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::_s0

◆ _s1

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::_s1

Referenced by TensorIterator().

◆ _s2

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::_s2

Referenced by TensorIterator().

◆ dim

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::dim[TENSOR_MAXDIM]

Referenced by TensorIterator(), and operator++().

◆ dimj

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::dimj

◆ ind

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::ind[TENSOR_MAXDIM]

◆ ndim

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::ndim

Referenced by TensorIterator(), and operator++().

◆ stride0

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::stride0[TENSOR_MAXDIM]

Referenced by TensorIterator(), and operator++().

◆ stride1

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::stride1[TENSOR_MAXDIM]

Referenced by TensorIterator(), and operator++().

◆ stride2

template<class T, class Q = T, class R = T>
long madness::TensorIterator< T, Q, R >::stride2[TENSOR_MAXDIM]

Referenced by TensorIterator(), and operator++().


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