28 #define SPARSE_MAP std::map
37 #define MAX_SPARSE_ARRAY_DIMS 6
44 typedef SPARSE_MAP<int, T, std::less<int> >
SmapType;
46 SparseArray(
int n0=0,
int n1=1,
int n2=1,
int n3=1,
int n4=1,
int n5=1);
50 const T &
operator()(
int i0,
int i1=0,
int i2=0,
int i3=0,
int i4=0,
int i5=0)
const;
62 T &
get(
int i0=0,
int i1=0,
int i2=0,
int i3=0,
int i4=0,
int i5=0 );
65 void redim(
int n0,
int n1=1,
int n2=1,
int n3=1,
int n4=1,
int n5=1);
68 void set(
const T & value,
int i0,
int i1=0,
int i2=0,
int i3=0,
int i4=0,
int i5=0 );
74 int size(
int d )
const;
91 int boundsCheck(
int i0,
int i1,
int i2,
int i3,
int i4,
int i5 )
const;
93 SPARSE_MAP<int, T, std::less<int> >
smap;
100 #define SPARSE_INDEX(i0,i1,i2,i3,i4,i5) ((i0)+dims[0]*((i1)+dims[1]*((i2)+dims[2]*((i3)+dims[3]*((i4)+dims[4]*((i5)))))))
132 if( iv[d]<0 || iv[d]>=dims[d] )
135 printf(
"SparseArray::boundsCheck: index i%i=%i is out of bounds : [%i,%i]\n",d,iv[d],0,dims[d]-1);
166 get(
int i0,
int i1,
int i2,
int i3,
int i4,
int i5)
173 boundsCheck(i0,i1,i2,i3,i4,i5);
176 typename SmapType::iterator sait = smap.find(i);
178 if( sait != smap.end() )
180 return (*sait).second;
185 smap[i]=defaultValue;
192 redim(
int n0 ,
int n1 ,
int n2 ,
int n3 ,
int n4 ,
int n5 )
216 boundsCheck(i0,i1,
i2,i3,i4,i5);
219 typename SmapType::const_iterator sait= smap.find(i);
222 if( sait != smap.end() )
223 return (*sait).second;
229 set(
const T & value,
int i0,
int i1,
int i2,
int i3,
int i4,
int i5 )
239 boundsCheck(i0,i1,i2,i3,i4,i5);
242 typename SmapType::iterator sait = smap.find(i);
244 if( sait != smap.end() )
246 if( value!=defaultValue )
247 (*sait).second=value;
255 else if( value!=defaultValue )
301 printf(
"SparseArray:ERROR:size: invalid array dimension d=%i\n",d);
342 #undef MAX_SPARSE_ARRAY_DIMS