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();
433 #endif // __ESCRIPT_DATAVECTOR_H__