19#ifndef __ESCRIPT_DATAVECTORALT_H__
20#define __ESCRIPT_DATAVECTORALT_H__
225 ESYS_ASSERT(i<size(),
"DataVectorAlt: invalid index specified, " << i <<
" of " << size());
226 return m_array_data[i];
234 ESYS_ASSERT(i<size(),
"DataVectorAlt: invalid index specified. " << i <<
" of " << size());
235 return m_array_data[i];
251 m_size(other.m_size),
258 #pragma omp parallel for private(i) schedule(static)
259 for (i=0; i<
m_size; i++) {
296 if ( newBlockSize < 1) {
297 std::ostringstream oss;
298 oss <<
"DataVectorAlt: invalid blockSize specified (" << newBlockSize <<
')';
303 std::ostringstream oss;
304 oss <<
"DataVectorAlt: invalid new size specified (" << newSize <<
')';
307 if ( (newSize % newBlockSize) != 0) {
308 std::ostringstream oss;
309 oss <<
"DataVectorAlt: newSize is not a multiple of blockSize: (" << newSize <<
", " << newBlockSize<<
')';
314 m_dim = newBlockSize;
315 m_N = newSize / newBlockSize;
321 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
323 #pragma omp parallel for private(i) schedule(static)
324 for (i=0; i<m_size; i++) {
325 m_array_data[i] = newValue;
344 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
346 #pragma omp parallel for private(i) schedule(static)
347 for (i=0; i<m_size; i++) {
360 if (m_size!=other.
m_size) {
363 if (m_dim!=other.
m_dim) {
366 if (m_N!=other.
m_N) {
369 for (
int i=0; i<m_size; i++) {
381 return !(*
this==other);
390 if (offset+len*copies>size())
392 std::ostringstream ss;
393 ss <<
"Error - not enough room for that DataPoint at that offset. (";
394 ss <<
"offset=" << offset <<
" + " <<
" len=" << len <<
" >= " << size();
403 m_array_data[offset+z]=value.
getElt();
409 for (
size_t i=0;i<tempShape[0];++i)
411 m_array_data[offset+i]=value.
getElt(i);
474 std::ostringstream oss;
475 oss <<
"Error - unknown rank. Rank=" << value.
getRank();
490 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*nelements));
494 copyFromArrayToOffset(value,0,copies);
#define ESYS_ASSERT(a, b)
EsysAssert is a MACRO that will throw an exception if the boolean condition specified is false.
Definition Assert.h:79
Definition DataException.h:28
Definition DataVectorAlt.h:37
bool operator!=(const DataVectorAlt< T > &other) const
DataVectorAlt inequality comparison operator "!=". Return true if the given DataVectorAlt is not equa...
Definition DataVectorAlt.h:379
ElementType * data()
Definition DataVectorAlt.h:200
bool operator==(const DataVectorAlt< T > &other) const
DataVectorAlt equality comparison operator "==". Return true if the given DataVectorAlt is equal to t...
Definition DataVectorAlt.h:356
T ElementType
Definition DataVectorAlt.h:43
size_type m_N
Definition DataVectorAlt.h:193
void copyFromArrayToOffset(const WrappedArray &value, size_type offset, size_type copies)
Definition DataVectorAlt.h:386
void copyFromArray(const WrappedArray &value, size_type copies)
Populates the vector with the data from value. This method currently throws an exception if the speci...
Definition DataVectorAlt.h:482
ElementType & reference
Definition DataVectorAlt.h:51
ElementType value_type
Definition DataVectorAlt.h:49
DataVectorAlt & operator=(const DataVectorAlt< T > &other)
DataVectorAlt assignment operator "=". Assign the given DataVectorAlt object to this.
Definition DataVectorAlt.h:331
const_reference operator[](const size_type i) const
Definition DataVectorAlt.h:232
DataTypes::vec_size_type size_type
Definition DataVectorAlt.h:50
void resize(const size_type newSize, const value_type newVal=0.0, const size_type newBlockSize=1)
Resize the DataVectorAlt to the given length "newSize". All current data is lost. All elements in the...
Definition DataVectorAlt.h:291
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition DataVectorAlt.h:215
size_type m_dim
Definition DataVectorAlt.h:192
~DataVectorAlt()
Default destructor for DataVectorAlt.
Definition DataVectorAlt.h:276
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:223
const ElementType & const_reference
Definition DataVectorAlt.h:52
DataVectorAlt()
Default constructor for DataVectorAlt.
Definition DataVectorAlt.h:241
DataVectorAlt(const DataVectorAlt< T > &other)
Copy constructor for DataVectorAlt.
DataVectorAlt(const size_type size, const value_type val=0.0, const size_type blockSize=1)
Constructor for DataVectorAlt.
const ElementType * const_pointer
Definition DataVectorAlt.h:48
const ElementType * data() const
Definition DataVectorAlt.h:207
ElementType * m_array_data
Definition DataVectorAlt.h:195
size_type m_size
Definition DataVectorAlt.h:191
Definition WrappedArray.h:33
DataTypes::real_t getElt() const
Definition WrappedArray.h:89
unsigned int getRank() const
Definition WrappedArray.h:77
const DataTypes::ShapeType & getShape() const
Definition WrappedArray.h:83
#define ESCRIPT_INLINE_DLL_API
Definition escriptcore/src/system_dep.h:31
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition DataTypes.cpp:91
std::vector< int > ShapeType
The shape of a single datapoint.
Definition DataTypes.h:44
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:240
long vec_size_type
Definition DataTypes.h:49
Definition AbstractContinuousDomain.cpp:23