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;
208 ESYS_ASSERT(i<size(),
"DataVectorAlt: invalid index specified, " << i <<
" of " << size());
209 return m_array_data[i];
217 ESYS_ASSERT(i<size(),
"DataVectorAlt: invalid index specified. " << i <<
" of " << size());
218 return m_array_data[i];
234 m_size(other.m_size),
239 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
241 #pragma omp parallel for private(i) schedule(static) 242 for (i=0; i<m_size; i++) {
255 resize(size, val, blockSize);
279 if ( newBlockSize < 1) {
280 std::ostringstream oss;
281 oss <<
"DataVectorAlt: invalid blockSize specified (" << newBlockSize <<
')';
286 std::ostringstream oss;
287 oss <<
"DataVectorAlt: invalid new size specified (" << newSize <<
')';
290 if ( (newSize % newBlockSize) != 0) {
291 std::ostringstream oss;
292 oss <<
"DataVectorAlt: newSize is not a multiple of blockSize: (" << newSize <<
", " << newBlockSize<<
')';
297 m_dim = newBlockSize;
298 m_N = newSize / newBlockSize;
304 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
306 #pragma omp parallel for private(i) schedule(static) 307 for (i=0; i<m_size; i++) {
308 m_array_data[i] = newValue;
327 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
329 #pragma omp parallel for private(i) schedule(static) 330 for (i=0; i<m_size; i++) {
343 if (m_size!=other.
m_size) {
346 if (m_dim!=other.
m_dim) {
349 if (m_N!=other.
m_N) {
352 for (
int i=0; i<m_size; i++) {
364 return !(*
this==other);
373 if (offset+len*copies>size())
375 std::ostringstream ss;
376 ss <<
"Error - not enough room for that DataPoint at that offset. (";
377 ss <<
"offset=" << offset <<
" + " <<
" len=" << len <<
" >= " << size();
386 m_array_data[offset+z]=value.
getElt();
392 for (
size_t i=0;i<tempShape[0];++i)
394 m_array_data[offset+i]=value.
getElt(i);
457 std::ostringstream oss;
458 oss <<
"Error - unknown rank. Rank=" << value.
getRank();
473 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*nelements));
477 copyFromArrayToOffset(value,0,copies);
485 #endif // __ESCRIPT_DATAVECTORALT_H__ ElementType * m_array_data
Definition: DataVectorAlt.h:191
const DataTypes::ShapeType & getShape() const
Definition: WrappedArray.h:82
DataVectorAlt()
Default constructor for DataVectorAlt.
Definition: DataVectorAlt.h:224
ElementType & reference
Definition: DataVectorAlt.h:50
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:49
size_type m_dim
Definition: DataVectorAlt.h:188
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:198
ElementType value_type
Definition: DataVectorAlt.h:48
size_type m_size
Definition: DataVectorAlt.h:187
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:206
size_type m_N
Definition: DataVectorAlt.h:189
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