36 #ifndef VIGRA_NUMPY_ARRAY_HXX 
   37 #define VIGRA_NUMPY_ARRAY_HXX 
   39 #ifndef NPY_NO_DEPRECATED_API 
   40 # define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 
   46 #include <numpy/arrayobject.h> 
   47 #include "multi_array.hxx" 
   48 #include "array_vector.hxx" 
   49 #include "python_utility.hxx" 
   50 #include "numpy_array_traits.hxx" 
   51 #include "numpy_array_taggedshape.hxx" 
   58 static inline void import_vigranumpy()
 
   61     if(_import_array() < 0)
 
   62         pythonToCppException(0);
 
   66     char const * load_vigra =
 
   68         "if 'vigra.vigranumpycore' not in sys.modules:\n" 
   70     pythonToCppException(PyRun_SimpleString(load_vigra) == 0);
 
   80 class MultibandVectorAccessor
 
   91     typedef Multiband<T> value_type;
 
   95     typedef T component_type;
 
   97     typedef VectorElementAccessor<MultibandVectorAccessor<T> > ElementAccessor;
 
  102     template <
class ITERATOR>
 
  103     component_type 
const & getComponent(ITERATOR 
const & i, 
int idx)
 const 
  105         return *(&*i+idx*stride_);
 
  113     template <
class V, 
class ITERATOR>
 
  114     void setComponent(V 
const & value, ITERATOR 
const & i, 
int idx)
 const 
  116         *(&*i+idx*stride_) = detail::RequiresExplicitCast<component_type>::cast(value);
 
  122     template <
class ITERATOR, 
class DIFFERENCE>
 
  123     component_type 
const & getComponent(ITERATOR 
const & i, DIFFERENCE 
const & diff, 
int idx)
 const 
  125         return *(&i[diff]+idx*stride_);
 
  133     template <
class V, 
class ITERATOR, 
class DIFFERENCE>
 
  135     setComponent(V 
const & value, ITERATOR 
const & i, DIFFERENCE 
const & diff, 
int idx)
 const 
  137         *(&i[diff]+idx*stride_) = detail::RequiresExplicitCast<component_type>::cast(value);
 
  149 template <
class TYPECODE> 
 
  152 constructArray(TaggedShape tagged_shape, TYPECODE typeCode, 
bool init,
 
  153                python_ptr arraytype = python_ptr());
 
  157 template <
class Shape>
 
  158 void numpyParseSlicing(Shape 
const & shape, PyObject * idx, Shape & start, Shape & stop)
 
  160     int N = shape.size();
 
  161     for(
int k=0; k<N; ++k)
 
  167     python_ptr index(idx);
 
  168     if(!PySequence_Check(index))
 
  170         index = python_ptr(PyTuple_Pack(1, index.ptr()), python_ptr::new_nonzero_reference);
 
  172     int lindex = PyTuple_Size(index);
 
  174     for(; kindex<lindex; ++kindex)
 
  176         if(PyTuple_GET_ITEM((PyTupleObject *)index.ptr(), kindex) == Py_Ellipsis)
 
  179     if(kindex == lindex && lindex < N)
 
  181         python_ptr ellipsis = python_ptr(PyTuple_Pack(1, Py_Ellipsis), python_ptr::new_nonzero_reference);
 
  182         index = python_ptr(PySequence_Concat(index, ellipsis), python_ptr::new_nonzero_reference);
 
  186     for(
int k=0; k < N; ++k)
 
  188         PyObject * item = PyTuple_GET_ITEM((PyTupleObject *)index.ptr(), kindex);
 
  189 #if PY_MAJOR_VERSION < 3 
  190         if(PyInt_Check(item))
 
  194         if(PyLong_Check(item))
 
  200                 start[k] += shape[k];
 
  204         else if(PySlice_Check(item))
 
  206             Py_ssize_t sstart, sstop, step;
 
  207 #if PY_MAJOR_VERSION < 3 
  208             if(PySlice_GetIndices((PySliceObject *)item, shape[k], &sstart, &sstop, &step) != 0)
 
  210             if(PySlice_GetIndices(item, shape[k], &sstart, &sstop, &step) != 0)
 
  212                 pythonToCppException(0);
 
  213             vigra_precondition(step == 1,
 
  214                 "numpyParseSlicing(): only unit steps are supported.");
 
  219         else if(item == Py_Ellipsis)
 
  228             vigra_precondition(
false,
 
  229                 "numpyParseSlicing(): unsupported index object.");
 
  262     static python_ptr getArrayTypeObject()
 
  264         return detail::getArrayTypeObject();
 
  267     static std::string defaultOrder(std::string defaultValue = 
"C")
 
  269         return detail::defaultOrder(defaultValue);
 
  272     static python_ptr defaultAxistags(
int ndim, std::string order = 
"")
 
  274         return detail::defaultAxistags(ndim, order);
 
  277     static python_ptr emptyAxistags(
int ndim)
 
  279         return detail::emptyAxistags(ndim);
 
  289     explicit NumpyAnyArray(PyObject * obj = 0, 
bool createCopy = 
false, PyTypeObject * type = 0)
 
  293         vigra_precondition(type == 0 || PyType_IsSubtype(type, &PyArray_Type),
 
  294              "NumpyAnyArray(obj, createCopy, type): type must be numpy.ndarray or a subclass thereof.");
 
  298             vigra_precondition(
makeReference(obj, type), 
"NumpyAnyArray(obj): obj isn't a numpy array.");
 
  310         vigra_precondition(type == 0 || PyType_IsSubtype(type, &PyArray_Type),
 
  311              "NumpyAnyArray(obj, createCopy, type): type must be numpy.ndarray or a subclass thereof.");
 
  334             vigra_precondition(other.
hasData(),
 
  335                 "NumpyArray::operator=(): Cannot assign from empty array.");
 
  337             python_ptr arraytype = getArrayTypeObject();
 
  338             python_ptr f(pythonFromData(
"_copyValuesImpl"));
 
  339             if(PyObject_HasAttr(arraytype, f))
 
  341                 python_ptr res(PyObject_CallMethodObjArgs(arraytype, f.get(),
 
  342                                                           pyArray_.get(), other.pyArray_.get(), NULL),
 
  343                                python_ptr::keep_count);
 
  344                 vigra_postcondition(res.get() != 0,
 
  345                        "NumpyArray::operator=(): VigraArray._copyValuesImpl() failed.");
 
  349                 PyArrayObject * sarray = (PyArrayObject *)pyArray_.get();
 
  350                 PyArrayObject * tarray = (PyArrayObject *)other.pyArray_.get();
 
  352                 if(PyArray_CopyInto(tarray, sarray) == -1)
 
  353                     pythonToCppException(0);
 
  358             pyArray_ = other.pyArray_;
 
  370             return PyArray_NDIM(
pyArray());
 
  383         return pythonGetAttr(
pyObject(), 
"spatialDimensions", 
ndim());
 
  386     bool hasChannelAxis()
 const 
  390         return channelIndex() == 
ndim();
 
  397         return pythonGetAttr(
pyObject(), 
"channelIndex", 
ndim());
 
  404         return pythonGetAttr(
pyObject(), 
"innerNonchannelIndex", 
ndim());
 
  436                 if(stride[j] < stride[smallest])
 
  441                 std::swap(stride[k], stride[smallest]);
 
  442                 std::swap(permutation[k], permutation[smallest]);
 
  447             ordering[permutation[k]] = k;
 
  480             return PyArray_DESCR(
pyArray())->type_num;
 
  487     template <
class Shape>
 
  491         unsigned int size = 
ndim();
 
  492         vigra_precondition(start.size() == size && stop.size() == size,
 
  493             "NumpyAnyArray::getitem(): shape has wrong dimension.");
 
  497         python_ptr index(PyTuple_New(size), python_ptr::new_nonzero_reference);
 
  498         for(
unsigned int k=0; k<size; ++k)
 
  504             vigra_precondition(0 <= start[k] && start[k] <= stop[k] && stop[k] <= s[k],
 
  505                 "NumpyAnyArray::getitem(): slice out of bounds.");
 
  507             if(start[k] == stop[k])
 
  509                 item = pythonFromData(start[k]);
 
  513                 python_ptr s0(pythonFromData(start[k]));
 
  514                 python_ptr s1(pythonFromData(stop[k]));
 
  515                 item = PySlice_New(s0, s1, 0);
 
  517             pythonToCppException(item);
 
  518             PyTuple_SET_ITEM((PyTupleObject *)index.ptr(), k, item); 
 
  520         python_ptr func(pythonFromData(
"__getitem__"));
 
  521         python_ptr res(PyObject_CallMethodObjArgs(
pyObject(), func.ptr(), index.ptr(), NULL),
 
  522                        python_ptr::new_nonzero_reference);
 
  536             python_ptr key(pythonFromData(
"axistags"));
 
  537             axistags.reset(PyObject_GetAttr(
pyObject(), key), python_ptr::keep_count);
 
  549         return (PyArrayObject *)pyArray_.get();
 
  558         return pyArray_.get();
 
  571         if(obj == 0 || !PyArray_Check(obj))
 
  575             vigra_precondition(PyType_IsSubtype(type, &PyArray_Type) != 0,
 
  576                 "NumpyAnyArray::makeReference(obj, type): type must be numpy.ndarray or a subclass thereof.");
 
  577             obj = PyArray_View((PyArrayObject*)obj, 0, type);
 
  578             pythonToCppException(obj);
 
  590     void makeCopy(PyObject * obj, PyTypeObject * type = 0)
 
  592         vigra_precondition(obj && PyArray_Check(obj),
 
  593              "NumpyAnyArray::makeCopy(obj): obj is not an array.");
 
  594         vigra_precondition(type == 0 || PyType_IsSubtype(type, &PyArray_Type),
 
  595              "NumpyAnyArray::makeCopy(obj, type): type must be numpy.ndarray or a subclass thereof.");
 
  596         python_ptr array(PyArray_NewCopy((PyArrayObject*)obj, NPY_ANYORDER), python_ptr::keep_count);
 
  597         pythonToCppException(array);
 
  606         return pyArray_ != 0;
 
  619 nontrivialPermutation(ArrayVector<npy_intp> 
const & p)
 
  621     for(
unsigned int k=0; k<p.size(); ++k)
 
  629 template <
class TYPECODE> 
 
  632 constructArray(TaggedShape tagged_shape, TYPECODE typeCode, 
bool init, python_ptr arraytype)
 
  634     ArrayVector<npy_intp> shape = finalizeTaggedShape(tagged_shape);
 
  635     PyAxisTags axistags(tagged_shape.axistags);
 
  637     int ndim = (int)shape.size();
 
  638     ArrayVector<npy_intp> inverse_permutation;
 
  644             arraytype = NumpyAnyArray::getArrayTypeObject();
 
  646         inverse_permutation = axistags.permutationFromNormalOrder();
 
  647         vigra_precondition(ndim == (
int)inverse_permutation.size(),
 
  648                      "axistags.permutationFromNormalOrder(): permutation has wrong size.");
 
  652         arraytype = python_ptr((PyObject*)&PyArray_Type);
 
  658     python_ptr array(PyArray_New((PyTypeObject *)arraytype.get(), ndim, shape.begin(),
 
  659                                   typeCode, 0, 0, 0, order, 0),
 
  660                      python_ptr::keep_count);
 
  661     pythonToCppException(array);
 
  663     if(detail::nontrivialPermutation(inverse_permutation))
 
  665         PyArray_Dims permute = { inverse_permutation.begin(), ndim };
 
  666         array = python_ptr(PyArray_Transpose((PyArrayObject*)array.get(), &permute),
 
  667                            python_ptr::keep_count);
 
  668         pythonToCppException(array);
 
  671     if(arraytype != (PyObject*)&PyArray_Type && axistags)
 
  672         pythonToCppException(PyObject_SetAttrString(array, 
"axistags", axistags.axistags) != -1);
 
  675         PyArray_FILLWBYTE((PyArrayObject *)array.get(), 0);
 
  677     return array.release();
 
  681 template <
class TINY_VECTOR>
 
  683 python_ptr constructNumpyArrayFromData(
 
  684     TINY_VECTOR 
const & shape, npy_intp *strides,
 
  685     NPY_TYPES typeCode, 
void *data)
 
  687     ArrayVector<npy_intp> pyShape(shape.begin(), shape.end());
 
  689 #ifndef NPY_ARRAY_WRITEABLE 
  690 #  define NPY_ARRAY_WRITEABLE NPY_WRITEABLE    // old API compatibility 
  693     python_ptr array(PyArray_New(&PyArray_Type, shape.size(), pyShape.begin(),
 
  694                                  typeCode, strides, data, 0, NPY_ARRAY_WRITEABLE, 0),
 
  695                      python_ptr::keep_count);
 
  696     pythonToCppException(array);
 
  715 template <
unsigned int N, 
class T, 
class Str
ide = Str
idedArrayTag>
 
  717 : 
public MultiArrayView<N, typename NumpyArrayTraits<N, T, Stride>::value_type, Stride>,
 
  721     typedef NumpyArrayTraits<N, T, Stride> ArrayTraits;
 
  722     typedef typename ArrayTraits::dtype 
dtype;
 
  723     typedef T pseudo_value_type;
 
  725     static NPY_TYPES 
const typeCode = ArrayTraits::typeCode;
 
  731     enum { actual_dimension = view_type::actual_dimension };
 
  792     void setupArrayView();
 
  794     static python_ptr init(
difference_type const & shape, 
bool init = 
true,
 
  795                            std::string 
const & order = 
"")
 
  797         vigra_precondition(order == 
"" || order == 
"C" || order == 
"F" ||
 
  798                            order == 
"V" || order == 
"A",
 
  799             "NumpyArray.init(): order must be in ['C', 'F', 'V', 'A', ''].");
 
  800         return python_ptr(constructArray(ArrayTraits::taggedShape(shape, order), typeCode, init),
 
  801                           python_ptr::keep_count);
 
  821     explicit NumpyArray(PyObject *obj = 0, 
bool createCopy = 
false)
 
  829                   "NumpyArray(obj): Cannot construct from incompatible array.");
 
  854     template <
class U, 
class S>
 
  860                   "NumpyArray(MultiArrayView): Python constructor did not produce a compatible array.");
 
  874                      "NumpyArray(shape): Python constructor did not produce a compatible array.");
 
  886            "NumpyArray(tagged_shape): Python constructor did not produce a compatible array.");
 
  901                    "NumpyArray(NumpyAnyArray): Cannot construct from incompatible or empty array.");
 
  929     template <
class U, 
class S>
 
  935                 "NumpyArray::operator=(): shape mismatch.");
 
  942                 "NumpyArray::operator=(): reshape failed unexpectedly.");
 
  955     template <
class U, 
class S>
 
  961                 "NumpyArray::operator=(): shape mismatch.");
 
  968                 "NumpyArray::operator=(): reshape failed unexpectedly.");
 
  995             vigra_precondition(
false,
 
  996                 "NumpyArray::operator=(): Cannot assign from incompatible array.");
 
 1010             "NumpyArray::permuteLikewise(): array has no data.");
 
 1013         ArrayTraits::permuteLikewise(this->pyArray_, data, res);
 
 1021     template <
class U, 
int K>
 
 1026             "NumpyArray::permuteLikewise(): array has no data.");
 
 1029         ArrayTraits::permuteLikewise(this->pyArray_, data, res);
 
 1042             "NumpyArray::permuteLikewise(): array has no data.");
 
 1046         ArrayTraits::permuteLikewise(this->pyArray_, data, res);
 
 1058 #if VIGRA_CONVERTER_DEBUG 
 1059         std::cerr << 
"class " << 
typeid(
NumpyArray).name() << 
" got " << obj->ob_type->tp_name << 
"\n";
 
 1060         std::cerr << 
"using traits " << 
typeid(ArrayTraits).name() << 
"\n";
 
 1061         std::cerr<<
"isArray: "<< ArrayTraits::isArray(obj)<<std::endl;
 
 1062         std::cerr<<
"isShapeCompatible: "<< ArrayTraits::isShapeCompatible((PyArrayObject *)obj)<<std::endl;
 
 1065         return ArrayTraits::isArray(obj) &&
 
 1066                ArrayTraits::isShapeCompatible((PyArrayObject *)obj);
 
 1077         return ArrayTraits::isArray(obj) &&
 
 1078                ArrayTraits::isPropertyCompatible((PyArrayObject *)obj);
 
 1097         for(
unsigned int k=0; k<N; ++k)
 
 1098             strideOrdering[k] = k;
 
 1151         vigra_precondition(!
hasData(),
 
 1152             "makeUnsafeReference(): cannot replace existing view with given buffer");
 
 1155         python_ptr array(ArrayTraits::unsafeConstructorFromData(multiArrayView.
shape(),
 
 1156                                   multiArrayView.
data(), multiArrayView.
stride()));
 
 1170 #if VIGRA_CONVERTER_DEBUG 
 1171         int ndim = PyArray_NDIM((PyArrayObject *)obj);
 
 1172         npy_intp * s = PyArray_DIMS((PyArrayObject *)obj);
 
 1175         std::cerr << 
"for " << 
typeid(*this).name() << 
"\n";
 
 1178                      "NumpyArray::makeCopy(obj): Cannot copy an incompatible array.");
 
 1196                 "NumpyArray.reshape(shape): Python constructor did not produce a compatible array.");
 
 1218         ArrayTraits::finalizeTaggedShape(tagged_shape);
 
 1222             vigra_precondition(tagged_shape.compatible(taggedShape()), message.c_str());
 
 1226             python_ptr array(constructArray(tagged_shape, typeCode, 
true),
 
 1227                              python_ptr::keep_count);
 
 1229                   "NumpyArray.reshapeIfEmpty(): Python constructor did not produce a compatible array.");
 
 1233     TaggedShape taggedShape()
 const 
 1235         return ArrayTraits::taggedShape(this->
shape(), PyAxisTags(this->
axistags(), 
true));
 
 1240 template <
unsigned int N, 
class T, 
class Str
ide>
 
 1241 void NumpyArray<N, T, Stride>::setupArrayView()
 
 1245         permutation_type permute;
 
 1246         ArrayTraits::permutationToSetupOrder(this->pyArray_, permute);
 
 1248         vigra_precondition(
abs((
int)permute.size() - actual_dimension) <= 1,
 
 1249             "NumpyArray::setupArrayView(): got array of incompatible shape (should never happen).");
 
 1252                          PyArray_DIMS(pyArray()), this->m_shape.begin());
 
 1254                          PyArray_STRIDES(pyArray()), this->m_stride.begin());
 
 1256         if((
int)permute.size() == actual_dimension - 1)
 
 1258             this->m_shape[actual_dimension-1] = 1;
 
 1259             this->m_stride[actual_dimension-1] = 
sizeof(value_type);
 
 1262         this->m_stride /= 
sizeof(value_type);
 
 1264         for(
int k=0; k<actual_dimension; ++k)
 
 1266             if(this->m_stride[k] == 0)
 
 1268                 vigra_precondition(this->m_shape[k] == 1,
 
 1269                     "NumpyArray::setupArrayView(): only singleton axes may have zero stride.");
 
 1270                 this->m_stride[k] = 1;
 
 1274         this->m_ptr = 
reinterpret_cast<pointer
>(PyArray_DATA(pyArray()));
 
 1275         vigra_precondition(this->checkInnerStride(Stride()),
 
 1276             "NumpyArray<..., UnstridedArrayTag>::setupArrayView(): First dimension of given array is not unstrided (should never happen).");
 
 1286 typedef NumpyArray<2, float >  NumpyFArray2;
 
 1287 typedef NumpyArray<3, float >  NumpyFArray3;
 
 1288 typedef NumpyArray<4, float >  NumpyFArray4;
 
 1289 typedef NumpyArray<2, Singleband<float> >  NumpyFImage;
 
 1290 typedef NumpyArray<3, Singleband<float> >  NumpyFVolume;
 
 1291 typedef NumpyArray<2, RGBValue<float> >  NumpyFRGBImage;
 
 1292 typedef NumpyArray<3, RGBValue<float> >  NumpyFRGBVolume;
 
 1293 typedef NumpyArray<3, Multiband<float> >  NumpyFMultibandImage;
 
 1294 typedef NumpyArray<4, Multiband<float> >  NumpyFMultibandVolume;
 
 1302 template <
class PixelType, 
class Str
ide>
 
 1303 inline triple<ConstStridedImageIterator<PixelType>,
 
 1304               ConstStridedImageIterator<PixelType>,
 
 1305               MultibandVectorAccessor<PixelType> >
 
 1306 srcImageRange(NumpyArray<3, Multiband<PixelType>, Stride> 
const & img)
 
 1308     ConstStridedImageIterator<PixelType>
 
 1309         ul(img.data(), 1, img.stride(0), img.stride(1));
 
 1310     return triple<ConstStridedImageIterator<PixelType>,
 
 1311                   ConstStridedImageIterator<PixelType>,
 
 1312                   MultibandVectorAccessor<PixelType> >
 
 1313         (ul, ul + Size2D(img.shape(0), img.shape(1)), MultibandVectorAccessor<PixelType>(img.shape(2), img.stride(2)));
 
 1316 template <
class PixelType, 
class Str
ide>
 
 1317 inline pair< ConstStridedImageIterator<PixelType>,
 
 1318              MultibandVectorAccessor<PixelType> >
 
 1319 srcImage(NumpyArray<3, Multiband<PixelType>, Stride> 
const & img)
 
 1321     ConstStridedImageIterator<PixelType>
 
 1322         ul(img.data(), 1, img.stride(0), img.stride(1));
 
 1323     return pair<ConstStridedImageIterator<PixelType>, MultibandVectorAccessor<PixelType> >
 
 1324         (ul, MultibandVectorAccessor<PixelType>(img.shape(2), img.stride(2)));
 
 1327 template <
class PixelType, 
class Str
ide>
 
 1328 inline triple< StridedImageIterator<PixelType>,
 
 1329                StridedImageIterator<PixelType>,
 
 1330                MultibandVectorAccessor<PixelType> >
 
 1331 destImageRange(NumpyArray<3, Multiband<PixelType>, Stride> & img)
 
 1333     StridedImageIterator<PixelType>
 
 1334         ul(img.data(), 1, img.stride(0), img.stride(1));
 
 1335     return triple<StridedImageIterator<PixelType>,
 
 1336                   StridedImageIterator<PixelType>,
 
 1337                   MultibandVectorAccessor<PixelType> >
 
 1338         (ul, ul + Size2D(img.shape(0), img.shape(1)),
 
 1339         MultibandVectorAccessor<PixelType>(img.shape(2), img.stride(2)));
 
 1342 template <
class PixelType, 
class Str
ide>
 
 1343 inline pair< StridedImageIterator<PixelType>,
 
 1344              MultibandVectorAccessor<PixelType> >
 
 1345 destImage(NumpyArray<3, Multiband<PixelType>, Stride> & img)
 
 1347     StridedImageIterator<PixelType>
 
 1348         ul(img.data(), 1, img.stride(0), img.stride(1));
 
 1349     return pair<StridedImageIterator<PixelType>, MultibandVectorAccessor<PixelType> >
 
 1350         (ul, MultibandVectorAccessor<PixelType>(img.shape(2), img.stride(2)));
 
 1353 template <
class PixelType, 
class Str
ide>
 
 1354 inline pair< ConstStridedImageIterator<PixelType>,
 
 1355              MultibandVectorAccessor<PixelType> >
 
 1356 maskImage(NumpyArray<3, Multiband<PixelType>, Stride> 
const & img)
 
 1358     ConstStridedImageIterator<PixelType>
 
 1359         ul(img.data(), 1, img.stride(0), img.stride(1));
 
 1360     return pair<ConstStridedImageIterator<PixelType>, MultibandVectorAccessor<PixelType> >
 
 1361         (ul, MultibandVectorAccessor<PixelType>(img.shape(2), img.stride(2)));
 
 1366 #endif // VIGRA_NUMPY_ARRAY_HXX 
const value_type & const_reference
Definition: multi_array.hxx:727
Definition: numpy_array.hxx:252
Sequential iterator for MultiArrayView. 
Definition: multi_fwd.hxx:161
void applyPermutation(IndexIterator index_first, IndexIterator index_last, InIterator in, OutIterator out)
Sort an array according to the given index permutation. 
Definition: algorithm.hxx:456
bool makeReference(PyObject *obj, PyTypeObject *type=0)
Definition: numpy_array.hxx:569
MultiArrayShape< actual_dimension >::type difference_type
Definition: multi_array.hxx:739
NumpyAnyArray::difference_type permutation_type
Definition: numpy_array.hxx:767
NumpyArray(const NumpyAnyArray &other, bool createCopy=false)
Definition: numpy_array.hxx:893
void makeUnsafeReference(const view_type &multiArrayView)
Definition: numpy_array.hxx:1149
NumpyAnyArray(PyObject *obj=0, bool createCopy=false, PyTypeObject *type=0)
Definition: numpy_array.hxx:289
void reshapeIfEmpty(TaggedShape tagged_shape, std::string message="")
Definition: numpy_array.hxx:1216
PyObject * pyObject() const 
Definition: numpy_array.hxx:556
NumpyArray(const MultiArrayView< N, U, S > &other)
Definition: numpy_array.hxx:855
static bool isReferenceCompatible(PyObject *obj)
Definition: numpy_array.hxx:1075
const difference_type & shape() const 
Definition: multi_array.hxx:1648
MultiArrayIndex spatialDimensions() const 
Definition: numpy_array.hxx:379
view_type::difference_type_1 difference_type_1
Definition: numpy_array.hxx:763
difference_type shape() const 
Definition: numpy_array.hxx:411
void linearSequence(Iterator first, Iterator last, Value start, Value step)
Fill an array with a sequence of numbers. 
Definition: algorithm.hxx:208
view_type::const_traverser const_traverser
Definition: numpy_array.hxx:775
view_type::size_type size_type
Definition: numpy_array.hxx:755
difference_type size_type
Definition: multi_array.hxx:747
pointer data() const
Definition: multi_array.hxx:1898
NumpyArray(difference_type const &shape, std::string const &order="")
Definition: numpy_array.hxx:871
iterator end()
Definition: tinyvector.hxx:864
static bool isStrictlyCompatible(PyObject *obj)
Definition: numpy_array.hxx:1084
view_type::pointer pointer
Definition: numpy_array.hxx:739
std::ptrdiff_t MultiArrayIndex
Definition: multi_fwd.hxx:60
view_type::const_iterator const_iterator
Definition: numpy_array.hxx:783
view_type::traverser traverser
Definition: numpy_array.hxx:771
NumpyArray(PyObject *obj=0, bool createCopy=false)
Definition: numpy_array.hxx:821
vigra::detail::MultiIteratorChooser< StrideTag >::template Traverser< actual_dimension, T, T const &, T const * >::type const_traverser
Definition: multi_array.hxx:769
PyArrayObject * pyArray() const 
Definition: numpy_array.hxx:547
ArrayVector< npy_intp > difference_type
difference type 
Definition: numpy_array.hxx:260
NumpyAnyArray & operator=(NumpyAnyArray const &other)
Definition: numpy_array.hxx:330
TinyVector< U, K > permuteLikewise(TinyVector< U, K > const &data) const 
Definition: numpy_array.hxx:1023
TinyVector< npy_intp, K > permuteLikewise() const 
Definition: numpy_array.hxx:1039
difference_type strideOrdering() const 
Definition: numpy_array.hxx:422
NumpyArray & operator=(const MultiArrayView< N, U, S > &other)
Definition: numpy_array.hxx:956
vigra::detail::MultiIteratorChooser< StrideTag >::template Traverser< actual_dimension, T, T &, T * >::type traverser
Definition: multi_array.hxx:764
bool hasData() const 
Definition: numpy_array.hxx:604
view_type::value_type value_type
Definition: numpy_array.hxx:735
MultiArrayView< N, typename ArrayTraits::value_type, Stride > view_type
Definition: numpy_array.hxx:729
MultiArrayIndex difference_type_1
Definition: multi_array.hxx:751
static difference_type standardStrideOrdering()
Definition: numpy_array.hxx:1094
const difference_type & stride() const 
Definition: multi_array.hxx:1684
value_type & reference
Definition: multi_array.hxx:723
view_type::difference_type difference_type
Definition: numpy_array.hxx:759
int dtype() const 
Definition: numpy_array.hxx:477
iterator begin()
Definition: tinyvector.hxx:861
NumpyAnyArray getitem(Shape start, Shape stop) const 
Definition: numpy_array.hxx:489
view_type::iterator iterator
Definition: numpy_array.hxx:779
view_type::const_reference const_reference
Definition: numpy_array.hxx:751
NumpyArray(TaggedShape const &tagged_shape)
Definition: numpy_array.hxx:883
void copy(const MultiArrayView &rhs)
Definition: multi_array.hxx:1216
bool makeReference(const NumpyAnyArray &array, bool strict=false)
Definition: numpy_array.hxx:1134
Class for fixed size vectors.This class contains an array of size SIZE of the specified VALUETYPE...
Definition: accessor.hxx:940
T value_type
Definition: multi_array.hxx:719
void reshape(difference_type const &shape)
Definition: numpy_array.hxx:1193
MultiArrayIndex ndim() const 
Definition: numpy_array.hxx:367
static bool isCopyCompatible(PyObject *obj)
Definition: numpy_array.hxx:1056
bool makeReference(PyObject *obj, bool=false)
Definition: numpy_array.hxx:1120
bool hasData() const 
Definition: multi_array.hxx:1913
view_type::reference reference
Definition: numpy_array.hxx:747
FFTWComplex< R >::NormType abs(const FFTWComplex< R > &a)
absolute value (= magnitude) 
Definition: fftw3.hxx:1002
Base class for, and view to, vigra::MultiArray. 
Definition: multi_array.hxx:704
NumpyArray & operator=(const NumpyAnyArray &other)
Definition: numpy_array.hxx:983
MultiArrayView & init(const U &init)
Definition: multi_array.hxx:1206
value_type * pointer
Definition: multi_array.hxx:731
size_type size() const 
Definition: array_vector.hxx:358
NumpyAnyArray(NumpyAnyArray const &other, bool createCopy=false, PyTypeObject *type=0)
Definition: numpy_array.hxx:306
NumpyArray & operator=(const NumpyArray< N, U, S > &other)
Definition: numpy_array.hxx:930
python_ptr axistags() const 
Definition: numpy_array.hxx:531
Definition: numpy_array.hxx:716
void makeReferenceUnchecked(PyObject *obj)
Definition: numpy_array.hxx:1107
void makeCopy(PyObject *obj, bool strict=false)
Definition: numpy_array.hxx:1168
MultiArrayView & operator=(MultiArrayView const &rhs)
Definition: multi_array.hxx:907
void reshapeIfEmpty(difference_type const &shape, std::string message="")
Definition: numpy_array.hxx:1204
const value_type * const_pointer
Definition: multi_array.hxx:735
NumpyArray & operator=(const NumpyArray &other)
Definition: numpy_array.hxx:912
view_type::const_pointer const_pointer
Definition: numpy_array.hxx:743
ArrayVector< U > permuteLikewise(ArrayVector< U > const &data) const 
Definition: numpy_array.hxx:1007
NumpyArray(const NumpyArray &other, bool createCopy=false)
Definition: numpy_array.hxx:839
difference_type strideOrdering() const 
Definition: multi_array.hxx:1617
void makeCopy(PyObject *obj, PyTypeObject *type=0)
Definition: numpy_array.hxx:590