36#ifndef MADNESS_TENSOR_BASETENSOR_H__INCLUDED
37#define MADNESS_TENSOR_BASETENSOR_H__INCLUDED
57#ifdef TENSOR_INSTANCE_COUNT
87#ifdef TENSOR_INSTANCE_COUNT
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;
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;
std::complex< double > double_complex
Definition basetensor.h:45
std::complex< float > float_complex
Definition basetensor.h:44
An integer with atomic set, get, read+increment, read+decrement, and decrement+test operations.
Definition atomicint.h:126
The base class for tensors defines generic capabilities.
Definition basetensor.h:85
bool conforms(const BaseTensor *t) const
Returns true if this and *t are the same shape and size.
Definition basetensor.h:159
void flat_inplace()
Reshapes the tensor inplace into 1D.
Definition basetensor.cc:81
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
bool iscontiguous() const
Returns true if the tensor refers to contiguous memory locations.
Definition basetensor.h:168
static int get_instance_count()
Returns the count of all current instances of tensors & slice tensors of all types.
Definition basetensor.h:129
void mapdim_inplace(const std::vector< long > &map)
General permutation of dimensions.
Definition basetensor.cc:156
const long * dims() const
Returns the array of tensor dimensions.
Definition basetensor.h:153
long _stride[TENSOR_MAXDIM]
Increment between elements in each dimension.
Definition basetensor.h:97
const long * strides() const
Returns the array of tensor strides.
Definition basetensor.h:156
long stride(int i) const
Returns the stride associated with dimension i.
Definition basetensor.h:150
long _size
Number of elements in the tensor.
Definition basetensor.h:93
long id() const
Returns the typeid of the tensor (c.f., TensorTypeData<T> )
Definition basetensor.h:141
void set_dims_and_size(long nd, const long d[])
Definition basetensor.h:99
long _id
Id from TensorTypeData<T> in type_data.h.
Definition basetensor.h:95
void splitdim_inplace(long i, long dimi0, long dimi1)
Splits dimension i.
Definition basetensor.cc:88
void swapdim_inplace(long i, long j)
Swaps the dimensions.
Definition basetensor.cc:124
virtual ~BaseTensor()
Definition basetensor.h:122
BaseTensor()
Definition basetensor.h:116
void fusedim_inplace(long i)
Fuses dimensions i and i+1.
Definition basetensor.cc:107
long _dim[TENSOR_MAXDIM]
Size of each dimension.
Definition basetensor.h:96
long ndim() const
Returns the number of dimensions in the tensor.
Definition basetensor.h:144
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
void cycledim_inplace(long shift, long start, long end)
Cyclic shift of dimensions.
Definition basetensor.cc:134
long _ndim
Number of dimensions (-1=invalid; 0=no supported; >0=tensor)
Definition basetensor.h:94
void reshape_inplace(const std::vector< long > &d)
Reshapes the tensor inplace.
Definition basetensor.cc:76
static double shift
Definition dirac-hatom.cc:19
Macros and tools pertaining to the configuration of MADNESS.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
static const double d
Definition nonlinschro.cc:121
static const double L
Definition rk.cc:46
Declares and implements Slice.
Macros for easy and efficient iteration over tensors.
#define TENSOR_MAXDIM
Definition tensor_macros.h:194
Defines and implements TensorTypeData, a type traits class.
Declares and implements factories for short vectors.