39 virtual inline bool isOK()
const;
40 virtual inline bool isEmpty()
const;
42 virtual T getND(
const int*)
const = 0;
44 virtual void setND(
const int*,T) = 0;
47 {
return getStorage_(); }
51 {
delete s;
return true; }
56 {
return getData_(); }
58 virtual const T* get1D(
const int*)
const;
59 virtual T* get1D(
const int*);
60 virtual int get1DDim()
const;
71 virtual void setAll(T);
72 virtual void getAll(T* ptr)
const;
90 return getStorage()->
arr();
106 virtual void set(int,T) = 0;
107 virtual T
get(int)
const = 0;
108 void setND(
const int* pos,T v) {
set( pos[0], v ); }
110 {
return get(pos[0]); }
120 inline T operator [](
int idx )
const 121 {
return get( idx ); }
134 virtual void set( int, int, T ) = 0;
135 virtual T
get(
int p0,
int p1 )
const = 0;
137 {
set( pos[0], pos[1], v);}
139 {
return get( pos[0], pos[1] ); }
157 virtual void set( int, int, int, T ) = 0;
158 virtual T
get(
int p0,
int p1,
int p2 )
const = 0;
160 {
set( pos[0], pos[1], pos[2], v);}
162 {
return get( pos[0], pos[1], pos[2] ); }
190 template <
class T>
void inline setPos(
const T& idxabl);
191 const int*
getPos()
const {
return position_; }
192 int operator[](
int)
const;
203 #define mArrayNDVSAdapterNrDim 20 219 if ( array_.getData() || array_.getStorage() )
221 pErrMsg(
"Not a good idea to use adapter. " 222 "Use getStorage() instead");
230 pErrMsg(
"Too many dimensions");
243 array_.info().getArrayPos( idx, pos );
244 return array_.getND( pos );
247 const T*
arr()
const {
return array_.getData(); }
258 for (
int idx=
sz_.
getNDim()-1; idx>=0; idx-- )
269 #define mDefArrayNDStdMembers(nd) \ 271 Array##nd##Conv(Array##nd<TT>* arr) \ 273 ~Array##nd##Conv() { delete arr_; } \ 275 const Array##nd##Info& info() const { return arr_->info(); } \ 279 Array##nd<TT>* arr_; \ 283 #define mDefArrayNDConverter(nd) \ 284 template <class T, class TT> \ 285 class Array##nd##Conv : public Array##nd<T> \ 286 { mDefArrayNDStdMembers(nd); 290 template <
class T,
class TT>
294 T
get(
int p0 )
const 295 {
return (T)arr_->get( p0 ); }
296 void set(
int p0, T v )
297 { arr_->set( p0, (TT)v ); }
302 template <
class T,
class TT>
305 T
get(
int p0,
int p1 )
const 306 {
return (T)arr_->get( p0, p1 ); }
307 void set(
int p0,
int p1, T v )
308 { arr_->set( p0, p1, (TT)v ); }
312 template <
class T,
class TT>
316 T
get(
int p0,
int p1,
int p2 )
const 317 {
return (T)arr_->get( p0, p1, p2 ); }
318 void set(
int p0,
int p1,
int p2, T v )
319 { arr_->set( p0, p1, p2, (TT)v ); }
326 template <
class T>
inline 329 return getStorage() ? getStorage()->isOK() :
true;
333 template <
class T>
inline 336 return !isOK() || info().getTotalSz() == 0;
340 template <
class T>
inline 343 const T* ptr = getData();
344 if ( !ptr )
return 0;
346 int ndim = info().getNDim();
349 OD::memCopy(pos,i, (
int)
sizeof(
int)*(ndim-1));
353 return &ptr[info().getOffset( pos )];
357 template <
class T>
inline 359 {
return info().getNDim()-1; }
362 template <
class T>
inline 365 return !isSettable() ? 0
366 :
const_cast<T*
>(((
const ArrayND*)
this)->getData_());
370 template <
class T>
inline 373 return !isSettable() ? 0 :
378 template <
class T>
inline 381 return !isSettable() ? 0 :
const_cast<T*
>(((
const ArrayND*)
this)->get1D(i));
385 template <
class T>
inline 408 setND( iterator.
getPos(), val );
409 }
while ( iterator.
next() );
423 , totalnr_( arr.info().getTotalSz() )
430 , totalnr_( arr.info().getTotalSz() )
431 , vs_( vs.arr() ? 0 : &vs )
437 if ( !arr_.info().getArrayPos( start, pos ) )
441 iterator.
setPos( (
int*) pos );
445 for (
od_int64 idx=start; idx<=stop; idx++ )
448 arr_.getND( iterator.getPos() ) );
452 if ( !iterator.next() )
458 T* res = ptr_ + start;
459 for (
od_int64 idx=start; idx<=stop; idx++, res++ )
461 *res = arr_.getND( iterator.getPos() );
465 if ( !iterator.next() )
485 template <
class T>
inline 489 { getAll( vs.
arr() );
return; }
491 const od_int64 totalsz = info().getTotalSz();
506 template <
class T>
inline 509 const od_int64 totalsz = info().getTotalSz();
513 const T* tdata = getData();
515 OD::memCopy( ptr, tdata, totalsz *
sizeof(T) );
Array1D ( Subclass of ArrayND ) is a one dimensional array.
Definition: arraynd.h:101
#define mExpClass(module)
Definition: commondefs.h:160
virtual int getNDim() const =0
void getValues(ValueSeries< T > &, int64_t nrvals) const
Definition: valseries.h:261
virtual bool canSetStorage() const
Definition: arraynd.h:49
T value(int64_t i) const
Definition: arraynd.h:113
virtual bool setStorage(ValueSeries< T > *s)
Definition: arraynd.h:50
const T * arr() const
Definition: arraynd.h:247
virtual T ** get2DData()
Definition: arraynd.h:141
Sets large amounts of values to a constant using multiple threads.
Definition: odmemory.h:42
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:118
const ValueSeries< T > * getStorage() const
Definition: arraynd.h:46
#define od_int64
Definition: plftypes.h:36
ValueSeries< T > * clone() const
Definition: arraynd.h:237
virtual const T * get1D(const int *) const
Definition: arraynd.h:341
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:23
Contains the information about the size of Array1D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:71
int * position_
Definition: arraynd.h:198
T value(int64_t idx) const
Definition: arraynd.h:240
virtual bool getArrayPos(uint64_t, int *) const
virtual bool isSettable() const
Definition: arraynd.h:43
Definition: arraynd.h:313
ArrayNDValseriesAdapter(const ArrayND< T > &a)
Definition: arraynd.h:216
virtual const T ** get2DData() const
Definition: arraynd.h:142
const ArrayNDInfo & sz_
Definition: arraynd.h:199
virtual int get1DDim() const
Definition: arraynd.h:358
virtual bool isEmpty() const
Definition: arraynd.h:334
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
const ArrayND< T > & array_
Definition: arraynd.h:252
const T * getData() const
Definition: arraynd.h:55
virtual bool canSetInfo() const
Definition: arraynd.h:64
Definition: arraynd.h:291
T * arr()
Definition: arraynd.h:248
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:131
bool writable() const
Definition: arraynd.h:114
virtual void setAll(T t)
Definition: arraynd.h:116
void setPos(const T &idxabl)
Definition: arraynd.h:256
bool execute()
Definition: paralleltask.h:71
Interface to a series of values.
Definition: odmemory.h:17
bool setGlobalPos(int64_t)
Definition: arraynd.h:264
virtual const ValueSeries< T > * getStorage_() const
Definition: arraynd.h:85
virtual const T *** get3DData() const
Definition: arraynd.h:165
T getND(const int *pos) const
Definition: arraynd.h:161
virtual T *** get3DData()
Definition: arraynd.h:164
Contains the information about the size of Array2D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:95
void setND(const int *pos, T v)
Definition: arraynd.h:108
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:54
virtual bool canChangeNrDims() const
Definition: arraynd.h:66
virtual void setAll(T)
Definition: arraynd.h:386
virtual void setAll(T)
Definition: valseries.h:48
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:33
Iterates through all samples in an ArrayND.
Definition: arraynd.h:179
void setND(const int *pos, T v)
Definition: arraynd.h:136
virtual bool setInfo(const ArrayNDInfo &)
Definition: arraynd.h:68
const int * getPos() const
Definition: arraynd.h:191
#define mAllocLargeVarLenArr(type, varnm, __size)
Definition: varlenarray.h:31
virtual const T * getData_() const
Definition: arraynd.h:87
Definition: arraynd.h:303
ValueSeries Copier.
Definition: odmemory.h:89
virtual bool canSetAll() const
Definition: valseries.h:47
T getND(const int *pos) const
Definition: arraynd.h:109
void setND(const int *pos, T v)
Definition: arraynd.h:159
virtual bool isOK() const
Definition: arraynd.h:327
void setValue(int64_t i, T t)
Definition: arraynd.h:115
#define mClass(module)
Definition: commondefs.h:164
bool isEmpty(const NLAModel *mdl)
#define pErrMsg(msg)
Definition: errmsg.h:60
#define mDefArrayNDStdMembers(nd)
Definition: arraynd.h:269
T getND(const int *pos) const
Definition: arraynd.h:138
virtual void getAll(T *ptr) const
Definition: arraynd.h:507
Adapter that makes any ArrayND to a (slow) value series.
Definition: arraynd.h:213
#define mArrayNDVSAdapterNrDim
Definition: arraynd.h:203
Array3D ( Subclass of ArrayND ) is a three dimensional array.
Definition: arraynd.h:153
virtual ~ArrayND()
Definition: arraynd.h:37
virtual T * arr()
Definition: valseries.h:55
bool isOK() const
Definition: arraynd.h:226