18 #ifndef __ESCRIPT_DATAVECTORALT_H__ 19 #define __ESCRIPT_DATAVECTORALT_H__ 91 const value_type val=0.0,
92 const size_type blockSize=1);
114 resize(
const size_type newSize,
115 const value_type newVal=0.0,
116 const size_type newBlockSize=1);
125 copyFromArray(
const WrappedArray& value, size_type copies);
131 copyFromArrayToOffset(
const WrappedArray& value, size_type offset, size_type copies);
176 operator[](
const size_type i);
180 operator[](
const size_type i)
const;
184 const ElementType* data()
const;
224 ESYS_ASSERT(i<size(),
"DataVectorAlt: invalid index specified, " << i <<
" of " << size());
225 return m_array_data[i];
233 ESYS_ASSERT(i<size(),
"DataVectorAlt: invalid index specified. " << i <<
" of " << size());
234 return m_array_data[i];
250 m_size(other.m_size),
255 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
257 #pragma omp parallel for private(i) schedule(static) 258 for (i=0; i<m_size; i++) {
271 resize(size, val, blockSize);
295 if ( newBlockSize < 1) {
296 std::ostringstream oss;
297 oss <<
"DataVectorAlt: invalid blockSize specified (" << newBlockSize <<
')';
302 std::ostringstream oss;
303 oss <<
"DataVectorAlt: invalid new size specified (" << newSize <<
')';
306 if ( (newSize % newBlockSize) != 0) {
307 std::ostringstream oss;
308 oss <<
"DataVectorAlt: newSize is not a multiple of blockSize: (" << newSize <<
", " << newBlockSize<<
')';
313 m_dim = newBlockSize;
314 m_N = newSize / newBlockSize;
320 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
322 #pragma omp parallel for private(i) schedule(static) 323 for (i=0; i<m_size; i++) {
324 m_array_data[i] = newValue;
343 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
345 #pragma omp parallel for private(i) schedule(static) 346 for (i=0; i<m_size; i++) {
359 if (m_size!=other.
m_size) {
362 if (m_dim!=other.
m_dim) {
365 if (m_N!=other.
m_N) {
368 for (
int i=0; i<m_size; i++) {
380 return !(*
this==other);
389 if (offset+len*copies>size())
391 std::ostringstream ss;
392 ss <<
"Error - not enough room for that DataPoint at that offset. (";
393 ss <<
"offset=" << offset <<
" + " <<
" len=" << len <<
" >= " << size();
402 m_array_data[offset+z]=value.
getElt();
408 for (
size_t i=0;i<tempShape[0];++i)
410 m_array_data[offset+i]=value.
getElt(i);
473 std::ostringstream oss;
474 oss <<
"Error - unknown rank. Rank=" << value.
getRank();
489 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*nelements));
493 copyFromArrayToOffset(value,0,copies);
501 #endif // __ESCRIPT_DATAVECTORALT_H__ ElementType * m_array_data
Definition: DataVectorAlt.h:194
const DataTypes::ShapeType & getShape() const
Definition: WrappedArray.h:82
DataVectorAlt()
Default constructor for DataVectorAlt.
Definition: DataVectorAlt.h:240
ElementType & reference
Definition: DataVectorAlt.h:50
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:49
size_type m_dim
Definition: DataVectorAlt.h:191
Definition: AbstractContinuousDomain.cpp:22
DataTypes::real_t getElt() const
Definition: WrappedArray.h:88
vec_size_type getRelIndex(const DataTypes::ShapeType &shape, vec_size_type i)
Compute the offset (in 1D vector) of a given subscript with a shape.
Definition: DataTypes.h:233
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:42
unsigned int getRank() const
Definition: WrappedArray.h:76
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:214
ElementType value_type
Definition: DataVectorAlt.h:48
size_type m_size
Definition: DataVectorAlt.h:190
ElementType * data()
Definition: DataVectorAlt.h:199
Definition: DataVectorAlt.h:36
T ElementType
Definition: DataVectorAlt.h:42
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:90
Definition: DataException.h:26
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
reference operator[](const size_type i)
Return a reference to the element at position i in this DataVectorAlt. Will throw an exception if an ...
Definition: DataVectorAlt.h:222
size_type m_N
Definition: DataVectorAlt.h:192
const ElementType & const_reference
Definition: DataVectorAlt.h:51
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false...
Definition: Assert.h:78
Definition: WrappedArray.h:31
long vec_size_type
Definition: DataTypes.h:47
const ElementType * const_pointer
Definition: DataVectorAlt.h:47