18#ifndef __ESCRIPT_DATAVECTOR_H__
19#define __ESCRIPT_DATAVECTOR_H__
27#ifdef ESYS_HAVE_BOOST_NUMPY
28#include <boost/python.hpp>
29#include <boost/python/numpy.hpp>
84#ifdef ESYS_HAVE_BOOST_NUMPY
87 pointToNumpyArrayOld(boost::python::numpy::ndarray& dataArray,
const RealVectorType::ElementType* data,
const ShapeType& shape,
long offset,
long numsamples,
long dpps,
long numdata);
91 pointToNumpyArrayOld(boost::python::numpy::ndarray& dataArray,
const CplxVectorType::ElementType* data,
const ShapeType& shape,
long offset,
long numsamples,
long dpps,
long numdata);
176 typename VEC::size_type leftOffset,
179 typename VEC::size_type otherOffset,
185 ESYS_ASSERT(!left.size()==!1,
"left data is empty.");
186 ESYS_ASSERT(!other.size()==!1,
"other data is empty.");
192 "offset incompatible with this vector.");
194 "offset incompatible with other vector.");
197 "slice not same rank as vector to be sliced from.");
200 "slice shape not compatible shape for this vector.");
208 switch (region.size()) {
215 left[leftOffset+numCopy]=other[otherOffset];
219 for (
int i=region[0].first;i<region[0].second;i++) {
220 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i)];
225 for (
int j=region[1].first;j<region[1].second;j++) {
226 for (
int i=region[0].first;i<region[0].second;i++) {
228 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i,j)];
234 for (
int k=region[2].first;k<region[2].second;k++) {
235 for (
int j=region[1].first;j<region[1].second;j++) {
236 for (
int i=region[0].first;i<region[0].second;i++) {
238 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i,j,k)];
245 for (
int l=region[3].first;l<region[3].second;l++) {
246 for (
int k=region[2].first;k<region[2].second;k++) {
247 for (
int j=region[1].first;j<region[1].second;j++) {
248 for (
int i=region[0].first;i<region[0].second;i++) {
250 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i,j,k,l)];
258 std::stringstream mess;
259 mess <<
"Error - (copySlice) Invalid slice region rank: " << region.size();
278 template<
typename VEC>
283 typename VEC::size_type leftOffset,
286 typename VEC::size_type otherOffset,
292 ESYS_ASSERT(left.size()!=0,
"this vector is empty.");
293 ESYS_ASSERT(other.size()!=0,
"other vector is empty.");
300 "offset incompatible with other vector.");
302 "offset incompatible with this vector.");
305 "slice not same rank as this vector.");
308 "slice shape not compatible shape for other vector.");
319 switch (region.size()) {
325 left[leftOffset]=other[otherOffset];
329 for (
int i=region[0].first;i<region[0].second;i++) {
330 left[leftOffset+
getRelIndex(leftShape,i)]=other[otherOffset];
335 for (
int j=region[1].first;j<region[1].second;j++) {
336 for (
int i=region[0].first;i<region[0].second;i++) {
337 left[leftOffset+
getRelIndex(leftShape,i,j)]=other[otherOffset];
343 for (
int k=region[2].first;k<region[2].second;k++) {
344 for (
int j=region[1].first;j<region[1].second;j++) {
345 for (
int i=region[0].first;i<region[0].second;i++) {
346 left[leftOffset+
getRelIndex(leftShape,i,j,k)]=other[otherOffset];
353 for (
int l=region[3].first;l<region[3].second;l++) {
354 for (
int k=region[2].first;k<region[2].second;k++) {
355 for (
int j=region[1].first;j<region[1].second;j++) {
356 for (
int i=region[0].first;i<region[0].second;i++) {
357 left[leftOffset+
getRelIndex(leftShape,i,j,k,l)]=other[otherOffset];
365 std::stringstream mess;
366 mess <<
"Error - (copySliceFrom) Invalid slice region rank: " << region.size();
375 switch (region.size()) {
381 left[leftOffset]=other[otherOffset+numCopy];
385 for (
int i=region[0].first;i<region[0].second;i++) {
386 left[leftOffset+
getRelIndex(leftShape,i)]=other[otherOffset+numCopy];
391 for (
int j=region[1].first;j<region[1].second;j++) {
392 for (
int i=region[0].first;i<region[0].second;i++) {
393 left[leftOffset+
getRelIndex(leftShape,i,j)]=other[otherOffset+numCopy];
399 for (
int k=region[2].first;k<region[2].second;k++) {
400 for (
int j=region[1].first;j<region[1].second;j++) {
401 for (
int i=region[0].first;i<region[0].second;i++) {
402 left[leftOffset+
getRelIndex(leftShape,i,j,k)]=other[otherOffset+numCopy];
409 for (
int l=region[3].first;l<region[3].second;l++) {
410 for (
int k=region[2].first;k<region[2].second;k++) {
411 for (
int j=region[1].first;j<region[1].second;j++) {
412 for (
int i=region[0].first;i<region[0].second;i++) {
413 left[leftOffset+
getRelIndex(leftShape,i,j,k,l)]=other[otherOffset+numCopy];
421 std::stringstream mess;
422 mess <<
"Error - (copySliceFrom) Invalid slice region rank: " << region.size();
#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
T ElementType
Definition DataVectorAlt.h:43
void pointToStream(std::ostream &os, const RealVectorType::ElementType *data, const ShapeType &shape, int offset, bool needsep=true, const std::string &sep=",")
Display a single value (with the specified shape) from the data.
int noValues(const ShapeType &shape)
Calculate the number of values in a datapoint with the given shape.
Definition DataTypes.cpp:91
bool checkOffset(vec_size_type offset, int size, int noval)
Definition DataTypes.h:331
std::string pointToString(const RealVectorType &data, const ShapeType &shape, int offset, const std::string &prefix)
Display a single value (with the specified shape) from the data.
Definition DataVector.cpp:492
int getRank(const DataTypes::ShapeType &shape)
Return the rank (number of dimensions) of the given shape.
Definition DataTypes.h:225
std::vector< std::pair< int, int > > RegionLoopRangeType
Definition DataTypes.h:46
std::vector< int > ShapeType
The shape of a single datapoint.
Definition DataTypes.h:44
void copySlice(VEC &left, const ShapeType &leftShape, typename VEC::size_type leftOffset, const VEC &other, const ShapeType &otherShape, typename VEC::size_type otherOffset, const RegionLoopRangeType ®ion)
Copy a data slice specified by the given region and offset from the "other" vector into the "left" ve...
Definition DataVector.h:174
DataTypes::ShapeType getResultSliceShape(const RegionType ®ion)
Determine the shape of the specified slice region.
Definition DataTypes.cpp:173
void fillComplexFromReal(const RealVectorType &r, CplxVectorType &c)
copy data from a real vector to a complex vector The complex vector will be resized as needed and any...
Definition DataVector.cpp:585
void copySliceFrom(VEC &left, const ShapeType &leftShape, typename VEC::size_type leftOffset, const VEC &other, const ShapeType &otherShape, typename VEC::size_type otherOffset, const RegionLoopRangeType ®ion)
Copy data into a slice specified by the given region and offset in the left vector from the other vec...
Definition DataVector.h:281
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
void copyPoint(RealVectorType &dest, vec_size_type doffset, vec_size_type nvals, const RealVectorType &src, vec_size_type soffset)
Copy a point from one vector to another. Note: This version does not check to see if shapes are the s...
long vec_size_type
Definition DataTypes.h:49
Definition AbstractContinuousDomain.cpp:23