17 #ifndef __ESCRIPT_DATAVECTOR_H__
18 #define __ESCRIPT_DATAVECTOR_H__
26 #ifdef ESYS_HAVE_BOOST_NUMPY
27 #include <boost/python.hpp>
28 #include <boost/python/numpy.hpp>
83 #ifdef ESYS_HAVE_BOOST_NUMPY
86 pointToNumpyArrayOld(boost::python::numpy::ndarray& dataArray,
const RealVectorType::ElementType* data,
const ShapeType& shape,
long offset,
long numsamples,
long dpps,
long numdata);
90 pointToNumpyArrayOld(boost::python::numpy::ndarray& dataArray,
const CplxVectorType::ElementType* data,
const ShapeType& shape,
long offset,
long numsamples,
long dpps,
long numdata);
175 typename VEC::size_type leftOffset,
178 typename VEC::size_type otherOffset,
184 ESYS_ASSERT(!left.size()==!1,
"left data is empty.");
185 ESYS_ASSERT(!other.size()==!1,
"other data is empty.");
191 "offset incompatible with this vector.");
193 "offset incompatible with other vector.");
196 "slice not same rank as vector to be sliced from.");
199 "slice shape not compatible shape for this vector.");
207 switch (region.size()) {
214 left[leftOffset+numCopy]=other[otherOffset];
218 for (
int i=region[0].first;i<region[0].second;i++) {
219 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i)];
224 for (
int j=region[1].first;j<region[1].second;j++) {
225 for (
int i=region[0].first;i<region[0].second;i++) {
227 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i,j)];
233 for (
int k=region[2].first;k<region[2].second;k++) {
234 for (
int j=region[1].first;j<region[1].second;j++) {
235 for (
int i=region[0].first;i<region[0].second;i++) {
237 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i,j,k)];
244 for (
int l=region[3].first;l<region[3].second;l++) {
245 for (
int k=region[2].first;k<region[2].second;k++) {
246 for (
int j=region[1].first;j<region[1].second;j++) {
247 for (
int i=region[0].first;i<region[0].second;i++) {
249 left[leftOffset+numCopy]=other[otherOffset+
getRelIndex(otherShape,i,j,k,l)];
257 std::stringstream mess;
258 mess <<
"Error - (copySlice) Invalid slice region rank: " << region.size();
277 template<
typename VEC>
282 typename VEC::size_type leftOffset,
285 typename VEC::size_type otherOffset,
291 ESYS_ASSERT(left.size()!=0,
"this vector is empty.");
292 ESYS_ASSERT(other.size()!=0,
"other vector is empty.");
299 "offset incompatible with other vector.");
301 "offset incompatible with this vector.");
304 "slice not same rank as this vector.");
307 "slice shape not compatible shape for other vector.");
318 switch (region.size()) {
324 left[leftOffset]=other[otherOffset];
328 for (
int i=region[0].first;i<region[0].second;i++) {
329 left[leftOffset+
getRelIndex(leftShape,i)]=other[otherOffset];
334 for (
int j=region[1].first;j<region[1].second;j++) {
335 for (
int i=region[0].first;i<region[0].second;i++) {
336 left[leftOffset+
getRelIndex(leftShape,i,j)]=other[otherOffset];
342 for (
int k=region[2].first;k<region[2].second;k++) {
343 for (
int j=region[1].first;j<region[1].second;j++) {
344 for (
int i=region[0].first;i<region[0].second;i++) {
345 left[leftOffset+
getRelIndex(leftShape,i,j,k)]=other[otherOffset];
352 for (
int l=region[3].first;l<region[3].second;l++) {
353 for (
int k=region[2].first;k<region[2].second;k++) {
354 for (
int j=region[1].first;j<region[1].second;j++) {
355 for (
int i=region[0].first;i<region[0].second;i++) {
356 left[leftOffset+
getRelIndex(leftShape,i,j,k,l)]=other[otherOffset];
364 std::stringstream mess;
365 mess <<
"Error - (copySliceFrom) Invalid slice region rank: " << region.size();
374 switch (region.size()) {
380 left[leftOffset]=other[otherOffset+numCopy];
384 for (
int i=region[0].first;i<region[0].second;i++) {
385 left[leftOffset+
getRelIndex(leftShape,i)]=other[otherOffset+numCopy];
390 for (
int j=region[1].first;j<region[1].second;j++) {
391 for (
int i=region[0].first;i<region[0].second;i++) {
392 left[leftOffset+
getRelIndex(leftShape,i,j)]=other[otherOffset+numCopy];
398 for (
int k=region[2].first;k<region[2].second;k++) {
399 for (
int j=region[1].first;j<region[1].second;j++) {
400 for (
int i=region[0].first;i<region[0].second;i++) {
401 left[leftOffset+
getRelIndex(leftShape,i,j,k)]=other[otherOffset+numCopy];
408 for (
int l=region[3].first;l<region[3].second;l++) {
409 for (
int k=region[2].first;k<region[2].second;k++) {
410 for (
int j=region[1].first;j<region[1].second;j++) {
411 for (
int i=region[0].first;i<region[0].second;i++) {
412 left[leftOffset+
getRelIndex(leftShape,i,j,k,l)]=other[otherOffset+numCopy];
420 std::stringstream mess;
421 mess <<
"Error - (copySliceFrom) Invalid slice region rank: " << region.size();
432 #endif // __ESCRIPT_DATAVECTOR_H__