Go to the documentation of this file.
19 #ifndef __ESCRIPT_DATAVECTORALT_H__
20 #define __ESCRIPT_DATAVECTORALT_H__
43 typedef T ElementType;
48 typedef const ElementType * const_pointer;
49 typedef ElementType value_type;
51 typedef ElementType & reference;
52 typedef const ElementType & const_reference;
71 DataVectorAlt(
const DataVectorAlt<T>& other);
185 const ElementType* data()
const;
195 ElementType* m_array_data;
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),
256 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*m_size));
258 #pragma omp parallel for private(i) schedule(static)
259 for (i=0; i<m_size; i++) {
272 resize(size, val, blockSize);
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;
336 m_size = other.m_size;
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++) {
348 m_array_data[i] = other.m_array_data[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++) {
370 if (m_array_data[i] != other.m_array_data[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);
419 for (size_type z=0;z<copies;++z)
421 for (size_type i=0;i<si;i++)
423 for (size_type j=0;j<sj;j++)
435 for (size_type z=0;z<copies;++z)
437 for (size_type i=0;i<si;i++)
439 for (size_type j=0;j<sj;j++)
441 for (size_type k=0;k<sk;k++)
455 for (size_type z=0;z<copies;++z)
457 for (size_type i=0;i<si;i++)
459 for (size_type j=0;j<sj;j++)
461 for (size_type k=0;k<sk;k++)
463 for (size_type l=0;l<sl;l++)
474 std::ostringstream oss;
475 oss <<
"Error - unknown rank. Rank=" << value.
getRank();
476 throw DataException(oss.str());
490 m_array_data=
reinterpret_cast<T*
>(malloc(
sizeof(T)*nelements));
494 copyFromArrayToOffset(value,0,copies);
502 #endif // __ESCRIPT_DATAVECTORALT_H__
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:30
DataTypes::cplx_t getEltC() const
Definition: WrappedArray.h:147
T ElementType
Definition: DataVectorAlt.h:85
DataTypes::real_t getElt() const
Definition: WrappedArray.h:89
DataVectorAlt & operator=(const DataVectorAlt< T > &other)
DataVectorAlt assignment operator "=". Assign the given DataVectorAlt object to this.
Definition: DataVectorAlt.h:359
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:251
~DataVectorAlt()
Default destructor for DataVectorAlt.
Definition: DataVectorAlt.h:304
DataVectorAlt()
Default constructor for DataVectorAlt.
Definition: DataVectorAlt.h:269
Definition: WrappedArray.h:32
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:319
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:92
Definition: DataVectorAlt.h:65
void copyFromArrayToOffset(const WrappedArray &value, size_type offset, size_type copies)
Definition: DataVectorAlt.h:414
ElementType * data()
Definition: DataVectorAlt.h:228
long vec_size_type
Definition: DataTypes.h:76
unsigned int getRank() const
Definition: WrappedArray.h:77
bool operator==(const DataVectorAlt< T > &other) const
DataVectorAlt equality comparison operator "==". Return true if the given DataVectorAlt is equal to t...
Definition: DataVectorAlt.h:384
Definition: DataException.h:41
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:71
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:91
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:510
ElementType value_type
Definition: DataVectorAlt.h:91
Definition: AbstractContinuousDomain.cpp:23
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:243
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:262
ElementType & reference
Definition: DataVectorAlt.h:93
ElementType * m_array_data
Definition: DataVectorAlt.h:237
const DataTypes::ShapeType & getShape() const
Definition: WrappedArray.h:83
#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
bool operator!=(const DataVectorAlt< T > &other) const
DataVectorAlt inequality comparison operator "!=". Return true if the given DataVectorAlt is not equa...
Definition: DataVectorAlt.h:407