36 #ifndef MADNESS_TENSOR_BASETENSOR_H__INCLUDED
37 #define MADNESS_TENSOR_BASETENSOR_H__INCLUDED
57 #ifdef TENSOR_INSTANCE_COUNT
87 #ifdef TENSOR_INSTANCE_COUNT
102 if (_ndim < 0) _size=0;
103 for (
long i=_ndim-1; i>=0; --i) {
117 #ifdef TENSOR_INSTANCE_COUNT
123 #ifdef TENSOR_INSTANCE_COUNT
130 #ifdef TENSOR_INSTANCE_COUNT
131 return instance_count;
147 long dim(
int i)
const {
return _dim[i];}
150 long stride(
int i)
const {
return _stride[i];}
160 if (_ndim != t->
_ndim)
return false;
161 for (
long i=0; i<
_ndim; ++i) {
162 if (_dim[i] != t->
_dim[i])
return false;
169 if (_size <= 0)
return true;
171 for (
long i=_ndim-1; i>=0; --i) {
172 if (_stride[i] != sz)
return false;
207 #endif // MADNESS_TENSOR_BASETENSOR_H__INCLUDED
long _size
Number of elements in the tensor.
Definition: basetensor.h:93
std::complex< double > double_complex
Definition: basetensor.h:45
BaseTensor()
Definition: basetensor.h:116
void reshape_inplace(const std::vector< long > &d)
Reshapes the tensor inplace.
Definition: basetensor.cc:76
long ndim() const
Returns the number of dimensions in the tensor.
Definition: basetensor.h:144
Macros for easy and efficient iteration over tensors.
const double L
Definition: 3dharmonic.cc:123
static int get_instance_count()
Returns the count of all current instances of tensors & slice tensors of all types.
Definition: basetensor.h:129
long dim(int i) const
Returns the size of dmension i.
Definition: basetensor.h:147
long id() const
Returns the typeid of the tensor (c.f., TensorTypeData )
Definition: basetensor.h:141
const long * dims() const
Returns the array of tensor dimensions.
Definition: basetensor.h:153
void set_dims_and_size(long nd, const long d[])
Definition: basetensor.h:99
The base class for tensors defines generic capabilities.
Definition: basetensor.h:85
const long * strides() const
Returns the array of tensor strides.
Definition: basetensor.h:156
void mapdim_inplace(const std::vector< long > &map)
General permutation of dimensions.
Definition: basetensor.cc:156
#define max(a, b)
Definition: lda.h:53
Defines and implements TensorTypeData, a type traits class.
bool conforms(const BaseTensor *t) const
Returns true if this and *t are the same shape and size.
Definition: basetensor.h:159
void splitdim_inplace(long i, long dimi0, long dimi1)
Splits dimension i.
Definition: basetensor.cc:88
long _ndim
Number of dimensions (-1=invalid; 0=scalar; >0=tensor)
Definition: basetensor.h:94
Declares and implements factories for short vectors.
void cycledim_inplace(long shift, long start, long end)
Cyclic shift of dimensions.
Definition: basetensor.cc:134
#define TENSOR_MAXDIM
Definition: tensor_macros.h:194
bool iscontiguous() const
Returns true if the tensor refers to contiguous memory locations.
Definition: basetensor.h:168
void flat_inplace()
Reshapes the tensor inplace into 1D.
Definition: basetensor.cc:81
std::complex< float > float_complex
Definition: basetensor.h:44
An integer with atomic set, get, read+inc, read+dec, dec+test operations.
Definition: atomicint.h:73
long stride(int i) const
Returns the stride associated with dimension i.
Definition: basetensor.h:150
long _id
Id from TensorTypeData in type_data.h.
Definition: basetensor.h:95
long _stride[TENSOR_MAXDIM]
Increment between elements in each dimension.
Definition: basetensor.h:97
Declares and implements Slice.
long size() const
Returns the number of elements in the tensor.
Definition: basetensor.h:138
long _dim[TENSOR_MAXDIM]
Size of each dimension.
Definition: basetensor.h:96
virtual ~BaseTensor()
Definition: basetensor.h:122
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
void fusedim_inplace(long i)
Fuses dimensions i and i+1.
Definition: basetensor.cc:107
void swapdim_inplace(long i, long j)
Swaps the dimensions.
Definition: basetensor.cc:124