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;
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;
331 DataVectorAlt<T>::operator=(
const DataVectorAlt& other)
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++) {
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();
397 size_type si=0,sj=0,sk=0,sl=0;
401 for (size_type z=0;z<copies;++z)
403 m_array_data[offset+z]=value.
getElt();
407 for (size_type z=0;z<copies;++z)
409 for (
size_t i=0;i<tempShape[0];++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());
482 DataVectorAlt<T>::copyFromArray(
const WrappedArray& value, size_type copies)
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:29
DataTypes::cplx_t getEltC() const
Definition: WrappedArray.h:146
T ElementType
Definition: DataVectorAlt.h:81
DataTypes::real_t getElt() const
Definition: WrappedArray.h:88
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:248
DataVectorAlt()
Default constructor for DataVectorAlt.
Definition: DataVectorAlt.h:266
Definition: WrappedArray.h:31
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:88
Definition: DataVectorAlt.h:62
ElementType * data()
Definition: DataVectorAlt.h:225
size_type m_dim
Definition: DataVectorAlt.h:230
void copyFromArrayToOffset(const WrappedArray &value, size_type offset, size_type copies)
Definition: DataVectorAlt.h:411
size_type m_N
Definition: DataVectorAlt.h:231
long vec_size_type
Definition: DataTypes.h:73
unsigned int getRank() const
Definition: WrappedArray.h:76
Definition: DataException.h:39
std::vector< int > ShapeType
The shape of a single datapoint.
Definition: DataTypes.h:68
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition: DataTypes.cpp:90
ElementType value_type
Definition: DataVectorAlt.h:87
size_type m_size
Definition: DataVectorAlt.h:229
Definition: AbstractContinuousDomain.cpp:23
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition: DataVectorAlt.h:240
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:259
ElementType & reference
Definition: DataVectorAlt.h:89
ElementType * m_array_data
Definition: DataVectorAlt.h:233
const DataTypes::ShapeType & getShape() const
Definition: WrappedArray.h:82
#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