37#ifndef VIGRA_MULTI_ARRAY_HXX
38#define VIGRA_MULTI_ARRAY_HXX
42#include "accessor.hxx"
43#include "tinyvector.hxx"
44#include "rgbvalue.hxx"
45#include "basicimage.hxx"
46#include "imageiterator.hxx"
47#include "numerictraits.hxx"
48#include "multi_iterator.hxx"
49#include "multi_pointoperators.hxx"
50#include "metaprogramming.hxx"
51#include "mathutil.hxx"
52#include "algorithm.hxx"
55#ifdef VIGRA_CHECK_BOUNDS
56#define VIGRA_ASSERT_INSIDE(diff) \
57 vigra_precondition(this->isInside(diff), "Index out of bounds")
59#define VIGRA_ASSERT_INSIDE(diff)
81template <
class Str
ideTag,
unsigned int N>
84 typedef StrideTag type;
87template <
class Str
ideTag>
88struct MaybeStrided <StrideTag, 0>
90 typedef StridedArrayTag type;
106struct MultiIteratorChooser;
120struct MultiIteratorChooser <StridedArrayTag>
122 template <
unsigned int N,
class T,
class REFERENCE,
class POINTER>
125 typedef StridedMultiIterator <N, T, REFERENCE, POINTER> type;
128 template <
unsigned int N,
class T,
class REFERENCE,
class POINTER>
131 typedef StridedScanOrderIterator <N, T, REFERENCE, POINTER> type;
134 template <
class Iter,
class View>
135 static Iter constructIterator(View * v)
153struct MultiIteratorChooser <UnstridedArrayTag>
155 template <
unsigned int N,
class T,
class REFERENCE,
class POINTER>
158 typedef MultiIterator <N, T, REFERENCE, POINTER> type;
161 template <
unsigned int N,
class T,
class REFERENCE,
class POINTER>
164 typedef POINTER type;
167 template <
class Iter,
class View>
168 static Iter constructIterator(View * v)
180template <
class DestIterator,
class Shape,
class T>
182initMultiArrayData(DestIterator d, Shape
const & shape, T
const & init, MetaInt<0>)
184 DestIterator dend = d + shape[0];
191template <
class DestIterator,
class Shape,
class T,
int N>
193initMultiArrayData(DestIterator d, Shape
const & shape, T
const & init, MetaInt<N>)
195 DestIterator dend = d + shape[N];
198 initMultiArrayData(d.begin(), shape, init, MetaInt<N-1>());
203#define VIGRA_COPY_MULTI_ARRAY_DATA(name, op) \
204template <class SrcIterator, class Shape, class DestIterator> \
206name##MultiArrayData(SrcIterator s, Shape const & shape, DestIterator d, MetaInt<0>) \
208 for(MultiArrayIndex i=0; i < shape[0]; ++i, ++s, ++d) \
210 *d op detail::RequiresExplicitCast<typename DestIterator::value_type>::cast(*s); \
214template <class Ref, class Ptr, class Shape, class DestIterator> \
216name##MultiArrayData(MultiIterator<1, UInt8, Ref, Ptr> si, Shape const & shape, DestIterator d, MetaInt<0>) \
219 for(MultiArrayIndex i=0; i < shape[0]; ++i, ++s, ++d) \
221 *d op detail::RequiresExplicitCast<typename DestIterator::value_type>::cast(*s); \
225template <class SrcIterator, class Shape, class DestIterator, int N> \
227name##MultiArrayData(SrcIterator s, Shape const & shape, DestIterator d, MetaInt<N>) \
229 for(MultiArrayIndex i=0; i < shape[N]; ++i, ++s, ++d) \
231 name##MultiArrayData(s.begin(), shape, d.begin(), MetaInt<N-1>()); \
235template <class DestIterator, class Shape, class T> \
237name##ScalarMultiArrayData(DestIterator d, Shape const & shape, T const & init, MetaInt<0>) \
239 for(MultiArrayIndex i=0; i < shape[0]; ++i, ++d) \
241 *d op detail::RequiresExplicitCast<typename DestIterator::value_type>::cast(init); \
245template <class DestIterator, class Shape, class T, int N> \
247name##ScalarMultiArrayData(DestIterator d, Shape const & shape, T const & init, MetaInt<N>) \
249 for(MultiArrayIndex i=0; i < shape[N]; ++i, ++d) \
251 name##ScalarMultiArrayData(d.begin(), shape, init, MetaInt<N-1>()); \
255VIGRA_COPY_MULTI_ARRAY_DATA(copy, =)
256VIGRA_COPY_MULTI_ARRAY_DATA(copyAdd, +=)
257VIGRA_COPY_MULTI_ARRAY_DATA(copySub, -=)
258VIGRA_COPY_MULTI_ARRAY_DATA(copyMul, *=)
259VIGRA_COPY_MULTI_ARRAY_DATA(copyDiv, /=)
261#undef VIGRA_COPY_MULTI_ARRAY_DATA
263template <
class SrcIterator,
class Shape,
class T,
class ALLOC>
265uninitializedCopyMultiArrayData(SrcIterator s, Shape
const & shape, T * & d, ALLOC & a, MetaInt<0>)
267 SrcIterator send = s + shape[0];
268 for(; s < send; ++s, ++d)
270 std::allocator_traits<ALLOC>::construct(a, d,
static_cast<T
const &
>(*s));
275template <
class Ref,
class Ptr,
class Shape,
class T,
class ALLOC>
277uninitializedCopyMultiArrayData(MultiIterator<1, UInt8, Ref, Ptr> si, Shape
const & shape, T * & d, ALLOC & a, MetaInt<0>)
279 Ptr s = &(*si), send = s + shape[0];
280 for(; s < send; ++s, ++d)
282 std::allocator_traits<ALLOC>::construct(a, d,
static_cast<T
const &
>(*s));
286template <
class SrcIterator,
class Shape,
class T,
class ALLOC,
int N>
288uninitializedCopyMultiArrayData(SrcIterator s, Shape
const & shape, T * & d, ALLOC & a, MetaInt<N>)
290 SrcIterator send = s + shape[N];
293 uninitializedCopyMultiArrayData(s.begin(), shape, d, a, MetaInt<N-1>());
297template <
class SrcIterator,
class Shape,
class T,
class Functor>
299reduceOverMultiArray(SrcIterator s, Shape
const & shape, T & result, Functor
const & f, MetaInt<0>)
301 SrcIterator send = s + shape[0];
308template <
class SrcIterator,
class Shape,
class T,
class Functor,
int N>
310reduceOverMultiArray(SrcIterator s, Shape
const & shape, T & result, Functor
const & f, MetaInt<N>)
312 SrcIterator send = s + shape[N];
315 reduceOverMultiArray(s.begin(), shape, result, f, MetaInt<N-1>());
319struct MaxNormReduceFunctor
321 template <
class T,
class U>
322 void operator()(T & result, U
const & u)
const
330struct L1NormReduceFunctor
332 template <
class T,
class U>
333 void operator()(T & result, U
const & u)
const
339struct SquaredL2NormReduceFunctor
341 template <
class T,
class U>
342 void operator()(T & result, U
const & u)
const
349struct WeightedL2NormReduceFunctor
353 WeightedL2NormReduceFunctor(T s)
358 void operator()(T & result, U
const & u)
const
364struct SumReduceFunctor
366 template <
class T,
class U>
367 void operator()(T & result, U
const & u)
const
373struct ProdReduceFunctor
375 template <
class T,
class U>
376 void operator()(T & result, U
const & u)
const
382struct MinmaxReduceFunctor
384 template <
class T,
class U>
385 void operator()(T & result, U
const & u)
const
389 if(result.second < u)
394struct MeanVarianceReduceFunctor
396 template <
class T,
class U>
397 void operator()(T & result, U
const & u)
const
400 typename T::second_type t1 = u - result.second;
401 typename T::second_type t2 = t1 / result.first;
403 result.third += (result.first-1.0)*t1*t2;
407struct AllTrueReduceFunctor
409 template <
class T,
class U>
410 void operator()(T & result, U
const & u)
const
412 result = result && (u != NumericTraits<U>::zero());
416struct AnyTrueReduceFunctor
418 template <
class T,
class U>
419 void operator()(T & result, U
const & u)
const
421 result = result || (u != NumericTraits<U>::zero());
425template <
class SrcIterator,
class Shape,
class DestIterator>
427equalityOfMultiArrays(SrcIterator s, Shape
const & shape, DestIterator d, MetaInt<0>)
429 SrcIterator send = s + shape[0];
430 for(; s < send; ++s, ++d)
438template <
class SrcIterator,
class Shape,
class DestIterator,
int N>
440equalityOfMultiArrays(SrcIterator s, Shape
const & shape, DestIterator d, MetaInt<N>)
442 SrcIterator send = s + shape[N];
443 for(; s < send; ++s, ++d)
445 if(!equalityOfMultiArrays(s.begin(), shape, d.begin(), MetaInt<N-1>()))
452template <
class SrcIterator,
class Shape,
class DestIterator>
454swapDataImpl(SrcIterator s, Shape
const & shape, DestIterator d, MetaInt<0>)
456 SrcIterator send = s + shape[0];
457 for(; s < send; ++s, ++d)
461template <
class SrcIterator,
class Shape,
class DestIterator,
int N>
463swapDataImpl(SrcIterator s, Shape
const & shape, DestIterator d, MetaInt<N>)
465 SrcIterator send = s + shape[N];
466 for(; s < send; ++s, ++d)
467 swapDataImpl(s.begin(), shape, d.begin(), MetaInt<N-1>());
531struct MultiMathOperand;
533namespace math_detail {
535template <
unsigned int N,
class T,
class C,
class E>
536void assign(MultiArrayView<N, T, C>, MultiMathOperand<E>
const &);
538template <
unsigned int N,
class T,
class C,
class E>
539void plusAssign(MultiArrayView<N, T, C>, MultiMathOperand<E>
const &);
541template <
unsigned int N,
class T,
class C,
class E>
542void minusAssign(MultiArrayView<N, T, C>, MultiMathOperand<E>
const &);
544template <
unsigned int N,
class T,
class C,
class E>
545void multiplyAssign(MultiArrayView<N, T, C>, MultiMathOperand<E>
const &);
547template <
unsigned int N,
class T,
class C,
class E>
548void divideAssign(MultiArrayView<N, T, C>, MultiMathOperand<E>
const &);
550template <
unsigned int N,
class T,
class A,
class E>
551void assignOrResize(MultiArray<N, T, A> &, MultiMathOperand<E>
const &);
553template <
unsigned int N,
class T,
class A,
class E>
554void plusAssignOrResize(MultiArray<N, T, A> &, MultiMathOperand<E>
const &);
556template <
unsigned int N,
class T,
class A,
class E>
557void minusAssignOrResize(MultiArray<N, T, A> &, MultiMathOperand<E>
const &);
559template <
unsigned int N,
class T,
class A,
class E>
560void multiplyAssignOrResize(MultiArray<N, T, A> &, MultiMathOperand<E>
const &);
562template <
unsigned int N,
class T,
class A,
class E>
563void divideAssignOrResize(MultiArray<N, T, A> &, MultiMathOperand<E>
const &);
569template <
class T>
class FindSum;
571struct UnsuitableTypeForExpandElements {};
574struct ExpandElementResult
576 typedef UnsuitableTypeForExpandElements type;
580struct ExpandElementResult<std::complex<T> >
596template <
class T,
int SIZE>
597struct ExpandElementResult<
TinyVector<T, SIZE> >
600 enum { size = SIZE };
603template <
class T,
unsigned int R,
unsigned int G,
unsigned int B>
604struct ExpandElementResult<
RGBValue<T, R, G, B> >
610#define VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(TYPE) \
612struct ExpandElementResult<TYPE> \
618VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
bool)
619VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
char)
620VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
signed char)
621VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
signed short)
622VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
signed int)
623VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
signed long)
624VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
signed long long)
625VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
unsigned char)
626VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
unsigned short)
627VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
unsigned int)
628VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
unsigned long)
629VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
unsigned long long)
630VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
float)
631VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
double)
632VIGRA_DEFINE_EXPAND_ELEMENT_RESULT(
long double)
634#undef VIGRA_DEFINE_EXPAND_ELEMENT_RESULT
643template <
unsigned int N,
class T,
class C>
646 typedef MultiArrayView<N, T, C> Type;
647 typedef typename NormTraits<T>::SquaredNormType SquaredNormType;
648 typedef typename SquareRootTraits<SquaredNormType>::SquareRootResult NormType;
651template <
unsigned int N,
class T,
class A>
653:
public NormTraits<typename MultiArray<N, T, A>::view_type>
655 typedef NormTraits<typename MultiArray<N, T, A>::view_type> BaseType;
656 typedef MultiArray<N, T, A> Type;
657 typedef typename BaseType::SquaredNormType SquaredNormType;
658 typedef typename BaseType::NormType NormType;
703template <
unsigned int N,
class T,
class Str
ideTag>
763 typedef typename vigra::detail::MultiIteratorChooser <
764 StrideTag>::template Traverser <actual_dimension, T, T &, T *>::type
traverser;
768 typedef typename vigra::detail::MultiIteratorChooser <
769 StrideTag>::template Traverser <actual_dimension, T, T const &, T const *>::type
const_traverser;
791 typedef typename difference_type::value_type diff_zero_t;
809 template <
class U,
class CN>
812 template <
class U,
class CN>
818 template <
class U,
class CN>
837 template <
class Str
ide>
843 vigra_precondition(other.checkInnerStride(StrideTag()),
844 "MultiArrayView<..., UnstridedArrayTag>(MultiArrayView const &): cannot create unstrided view from strided array.");
867 vigra_precondition(checkInnerStride(StrideTag()),
868 "MultiArrayView<..., UnstridedArrayTag>::MultiArrayView(): First dimension of given array is not unstrided.");
873 template <
class ALLOC>
916 template<
class Str
ide2>
927 template<
class U,
class C1>
930 vigra_precondition(this->
shape() == rhs.
shape(),
931 "MultiArrayView::operator=(): shape mismatch.");
946 template<
class U,
class C1>
952 template<
class U,
class C1>
958 template<
class U,
class C1>
964 template<
class U,
class C1>
971 detail::copyAddScalarMultiArrayData(
traverser_begin(),
shape(), rhs, MetaInt<actual_dimension-1>());
979 detail::copySubScalarMultiArrayData(
traverser_begin(),
shape(), rhs, MetaInt<actual_dimension-1>());
987 detail::copyMulScalarMultiArrayData(
traverser_begin(),
shape(), rhs, MetaInt<actual_dimension-1>());
995 detail::copyDivScalarMultiArrayData(
traverser_begin(),
shape(), rhs, MetaInt<actual_dimension-1>());
1002 template<
class Expression>
1005 multi_math::math_detail::assign(*
this, rhs);
1012 template<
class Expression>
1015 multi_math::math_detail::plusAssign(*
this, rhs);
1022 template<
class Expression>
1025 multi_math::math_detail::minusAssign(*
this, rhs);
1032 template<
class Expression>
1035 multi_math::math_detail::multiplyAssign(*
this, rhs);
1042 template<
class Expression>
1045 multi_math::math_detail::divideAssign(*
this, rhs);
1053 VIGRA_ASSERT_INSIDE(d);
1061 VIGRA_ASSERT_INSIDE(d);
1110 detail::ScanOrderToCoordinate<actual_dimension>::exec(d,
m_shape, result);
1118 return detail::CoordinateToScanOrder<actual_dimension>::exec(
m_shape, d);
1126 return m_ptr [detail::CoordinatesToOffest<StrideTag>::exec(
m_stride, x)];
1134 return m_ptr [detail::CoordinatesToOffest<StrideTag>::exec(
m_stride, x, y)];
1168 return m_ptr [detail::CoordinatesToOffest<StrideTag>::exec(
m_stride, x)];
1176 return m_ptr [detail::CoordinatesToOffest<StrideTag>::exec(
m_stride, x, y)];
1222 this->copyImpl(rhs);
1227 template <
class U,
class CN>
1230 this->copyImpl(rhs);
1257 std::swap(this->m_shape, other.
m_shape);
1258 std::swap(this->m_stride, other.
m_stride);
1259 std::swap(this->m_ptr, other.
m_ptr);
1276 template <
class T2,
class C2>
1291 for(
unsigned int k = 0; k <= dimension; ++k)
1311 template <
int M,
class Index>
1328 template <
int M,
class Index>
1348 template <
unsigned int M>
1349 MultiArrayView <N-1, T,
typename vigra::detail::MaybeStrided<StrideTag, M>::type >
1416 MultiArrayView <N, typename ExpandElementResult<T>::type,
StridedArrayTag>
1419 vigra_precondition(0 <= i && i < ExpandElementResult<T>::size,
1420 "MultiArrayView::bindElementChannel(i): 'i' out of range.");
1442 MultiArrayView <N+1, typename ExpandElementResult<T>::type,
StridedArrayTag>
1532 detail::RelativeToAbsoluteCoordinate<actual_dimension-1>::exec(
shape(), p);
1533 detail::RelativeToAbsoluteCoordinate<actual_dimension-1>::exec(
shape(), q);
1548 for (
unsigned int i = 0; i < actual_dimension; ++i)
1597 return permuteDimensions(permutation);
1635 for(
int i = 1; i < actual_dimension; ++i)
1700 template <
class U,
class C1>
1711 template <
class U,
class C1>
1721 for(
int d=0; d<actual_dimension; ++d)
1722 if(p[d] < 0 || p[d] >=
shape(d))
1730 for(
int d=0; d<actual_dimension; ++d)
1731 if(p[d] < 0 || p[d] >=
shape(d))
1744 detail::AllTrueReduceFunctor(),
1745 MetaInt<actual_dimension-1>());
1757 detail::AnyTrueReduceFunctor(),
1758 MetaInt<actual_dimension-1>());
1768 std::pair<T, T> res(NumericTraits<T>::max(), NumericTraits<T>::min());
1771 detail::MinmaxReduceFunctor(),
1772 MetaInt<actual_dimension-1>());
1773 *minimum = res.first;
1774 *maximum = res.second;
1784 typedef typename NumericTraits<U>::RealPromote R;
1786 triple<double, R, R> res(0.0, zero, zero);
1789 detail::MeanVarianceReduceFunctor(),
1790 MetaInt<actual_dimension-1>());
1792 *variance = res.third / res.first;
1807 U res = NumericTraits<U>::zero();
1810 detail::SumReduceFunctor(),
1811 MetaInt<actual_dimension-1>());
1840 template <
class U,
class S>
1844 destMultiArrayRange(sums),
1860 U res = NumericTraits<U>::one();
1863 detail::ProdReduceFunctor(),
1864 MetaInt<actual_dimension-1>());
1870 typename NormTraits<MultiArrayView>::SquaredNormType
1873 typedef typename NormTraits<MultiArrayView>::SquaredNormType SquaredNormType;
1874 SquaredNormType res = NumericTraits<SquaredNormType>::zero();
1877 detail::SquaredL2NormReduceFunctor(),
1878 MetaInt<actual_dimension-1>());
1895 typename NormTraits<MultiArrayView>::NormType
1896 norm(
int type = 2,
bool useSquaredNorm =
true)
const;
1941 return begin().getEndIterator();
1949 return begin().getEndIterator();
1977 ret +=
m_shape [actual_dimension-1];
1988 ret +=
m_shape [actual_dimension-1];
1998template <
unsigned int N,
class T,
class Str
ideTag>
2009template <
unsigned int N,
class T,
class Str
ide1>
2010template <
class Str
ide2>
2016 vigra_precondition(rhs.checkInnerStride(Stride1()),
2017 "MultiArrayView<..., UnstridedArrayTag>::operator=(MultiArrayView const &): cannot create unstrided view from strided array.");
2019 m_shape = rhs.shape();
2020 m_stride = rhs.stride();
2025 vigra_precondition(this->shape() == rhs.shape(),
2026 "MultiArrayView::operator=(MultiArrayView const &): shape mismatch.");
2027 this->copyImpl(rhs);
2031template <
unsigned int N,
class T,
class Str
ideTag>
2034MultiArrayView <N, T, StrideTag>::arraysOverlap(
const MultiArrayView <N, T, CN>& rhs)
const
2036 vigra_precondition (shape () == rhs.shape (),
2037 "MultiArrayView::arraysOverlap(): shape mismatch.");
2038 const_pointer first_element = this->m_ptr,
2039 last_element = first_element +
dot(this->m_shape -
difference_type(1), this->m_stride);
2041 rhs_first_element = rhs.data(),
2042 rhs_last_element = rhs_first_element +
dot(rhs.shape() -
difference_type(1), rhs.stride());
2043 return !(last_element < rhs_first_element || rhs_last_element < first_element);
2046template <
unsigned int N,
class T,
class Str
ideTag>
2047template <
class U,
class CN>
2049MultiArrayView <N, T, StrideTag>::copyImpl(
const MultiArrayView <N, U, CN>& rhs)
2051 if(!arraysOverlap(rhs))
2054 detail::copyMultiArrayData(rhs.traverser_begin(), shape(), traverser_begin(), MetaInt<actual_dimension-1>());
2061 detail::copyMultiArrayData(tmp.traverser_begin(), shape(), traverser_begin(), MetaInt<actual_dimension-1>());
2065#define VIGRA_MULTI_ARRAY_COMPUTED_ASSIGNMENT(name, op) \
2066template <unsigned int N, class T, class StrideTag> \
2067template<class U, class C1> \
2068MultiArrayView<N, T, StrideTag> & \
2069MultiArrayView <N, T, StrideTag>::operator op(MultiArrayView<N, U, C1> const & rhs) \
2071 vigra_precondition(this->shape() == rhs.shape(), "MultiArrayView::operator" #op "() size mismatch."); \
2072 if(!arraysOverlap(rhs)) \
2074 detail::name##MultiArrayData(rhs.traverser_begin(), shape(), traverser_begin(), MetaInt<actual_dimension-1>()); \
2078 MultiArray<N, T> tmp(rhs); \
2079 detail::name##MultiArrayData(tmp.traverser_begin(), shape(), traverser_begin(), MetaInt<actual_dimension-1>()); \
2084VIGRA_MULTI_ARRAY_COMPUTED_ASSIGNMENT(copyAdd, +=)
2085VIGRA_MULTI_ARRAY_COMPUTED_ASSIGNMENT(copySub, -=)
2086VIGRA_MULTI_ARRAY_COMPUTED_ASSIGNMENT(copyMul, *=)
2087VIGRA_MULTI_ARRAY_COMPUTED_ASSIGNMENT(copyDiv, /=)
2089#undef VIGRA_MULTI_ARRAY_COMPUTED_ASSIGNMENT
2091template <
unsigned int N,
class T,
class Str
ideTag>
2092template <
class U,
class CN>
2094MultiArrayView <N, T, StrideTag>::swapDataImpl(MultiArrayView <N, U, CN> rhs)
2096 vigra_precondition (shape () == rhs.shape (),
2097 "MultiArrayView::swapData(): shape mismatch.");
2100 const_pointer first_element = this->m_ptr,
2101 last_element = first_element +
dot(this->m_shape -
difference_type(1), this->m_stride);
2103 rhs_first_element = rhs.data(),
2104 rhs_last_element = rhs_first_element +
dot(rhs.shape() -
difference_type(1), rhs.stride());
2105 if(last_element < rhs_first_element || rhs_last_element < first_element)
2108 detail::swapDataImpl(traverser_begin(), shape(), rhs.traverser_begin(), MetaInt<actual_dimension-1>());
2120template <
unsigned int N,
class T,
class Str
ideTag>
2121MultiArrayView <N, T, StridedArrayTag>
2122MultiArrayView <N, T, StrideTag>::permuteDimensions (
const difference_type &s)
const
2124 difference_type shape, stride, check((
typename difference_type::value_type)0);
2125 for (
unsigned int i = 0; i < actual_dimension; ++i)
2127 shape[i] = m_shape[s[i]];
2128 stride[i] = m_stride[s[i]];
2132 "MultiArrayView::transpose(): every dimension must occur exactly once.");
2133 return MultiArrayView <N, T, StridedArrayTag>(shape, stride, m_ptr);
2136template <
unsigned int N,
class T,
class Str
ideTag>
2141 for(
int k=0; k<(int)N; ++k)
2143 for(
int k=0; k<(int)N-1; ++k)
2146 for(
int j=k+1; j<(int)N; ++j)
2154 std::swap(permutation[k], permutation[smallest]);
2158 for(
unsigned int k=0; k<N; ++k)
2159 ordering[permutation[k]] = k;
2163template <
unsigned int N,
class T,
class Str
ideTag>
2164MultiArrayView <N, T, StridedArrayTag>
2169 permutation[ordering[k]] = k;
2170 return permuteDimensions(permutation);
2173template <
unsigned int N,
class T,
class Str
ideTag>
2174MultiArrayView <N, T, StridedArrayTag>
2179 permutation[N-1-ordering[k]] = k;
2180 return permuteDimensions(permutation);
2183template <
unsigned int N,
class T,
class Str
ideTag>
2184template <
int M,
class Index>
2188 TinyVector <MultiArrayIndex, M>
stride;
2191 static const int NNew = (N-M == 0) ? 1 : N-M;
2192 TinyVector <MultiArrayIndex, NNew> inner_shape, inner_stride;
2195 inner_shape [0] = 1;
2196 inner_stride [0] = 1;
2203 return MultiArrayView <N-M, T, StrideTag> (inner_shape, inner_stride, ptr);
2206template <
unsigned int N,
class T,
class Str
ideTag>
2207template <
int M,
class Index>
2211 TinyVector <MultiArrayIndex, M> stride;
2212 stride.
init (m_stride.begin (), m_stride.end () - N + M);
2214 static const int NNew = (N-M == 0) ? 1 : N-M;
2215 TinyVector <MultiArrayIndex, NNew> outer_shape, outer_stride;
2218 outer_shape [0] = 1;
2219 outer_stride [0] = 1;
2223 outer_shape.
init (m_shape.begin () + M, m_shape.end ());
2224 outer_stride.
init (m_stride.begin () + M, m_stride.end ());
2227 (outer_shape, outer_stride, ptr);
2230template <
unsigned int N,
class T,
class Str
ideTag>
2231template <
unsigned int M>
2232MultiArrayView <N-1, T,
typename detail::MaybeStrided<StrideTag, M>::type >
2235 static const int NNew = (N-1 == 0) ? 1 : N-1;
2236 TinyVector <MultiArrayIndex, NNew> shape, stride;
2245 std::copy (m_shape.begin (), m_shape.begin () + M, shape.begin ());
2246 std::copy (m_shape.begin () + M+1, m_shape.end (),
2247 shape.begin () + M);
2248 std::copy (m_stride.begin (), m_stride.begin () + M, stride.begin ());
2249 std::copy (m_stride.begin () + M+1, m_stride.end (),
2250 stride.begin () + M);
2252 return MultiArrayView <N-1, T,
typename detail::MaybeStrided<StrideTag, M>::type>
2253 (shape, stride, m_ptr + d * m_stride[M]);
2256template <
unsigned int N,
class T,
class Str
ideTag>
2260 static const int NNew = (N-1 == 0) ? 1 : N-1;
2261 TinyVector <MultiArrayIndex, NNew> inner_shape, inner_stride;
2264 inner_shape [0] = 1;
2265 inner_stride [0] = 1;
2272 return MultiArrayView <N-1, T, StrideTag> (inner_shape, inner_stride,
2276template <
unsigned int N,
class T,
class Str
ideTag>
2280 static const int NNew = (N-1 == 0) ? 1 : N-1;
2281 TinyVector <MultiArrayIndex, NNew> outer_shape, outer_stride;
2284 outer_shape [0] = 1;
2285 outer_stride [0] = 1;
2296template <
unsigned int N,
class T,
class Str
ideTag>
2300 vigra_precondition (
2301 n <
static_cast <int> (N),
2302 "MultiArrayView <N, T, StrideTag>::bindAt(): dimension out of range.");
2303 static const int NNew = (N-1 == 0) ? 1 : N-1;
2315 shape.begin () + n);
2325template <
unsigned int N,
class T,
class Str
ideTag>
2326MultiArrayView <N+1, typename ExpandElementResult<T>::type,
StridedArrayTag>
2330 "MultiArrayView<N, ...>::expandElements(d): 0 <= 'd' <= N required.");
2332 int elementSize = ExpandElementResult<T>::size;
2334 for(
int k=0; k<d; ++k)
2337 newStrides[k] =
m_stride[k]*elementSize;
2340 newShape[d] = elementSize;
2343 for(
unsigned k=d; k<N; ++k)
2346 newStrides[k+1] =
m_stride[k]*elementSize;
2349 typedef typename ExpandElementResult<T>::type U;
2351 newShape, newStrides,
reinterpret_cast<U*
>(
m_ptr));
2354template <
unsigned int N,
class T,
class Str
ideTag>
2355MultiArrayView <N+1, T, StrideTag>
2358 vigra_precondition (
2360 "MultiArrayView <N, T, StrideTag>::insertSingletonDimension(): index out of range.");
2372template <
unsigned int N,
class T,
class Str
ideTag>
2373typename NormTraits<MultiArrayView <N, T, StrideTag> >::NormType
2376 typedef typename NormTraits<MultiArrayView>::NormType NormType;
2382 NormType res = NumericTraits<NormType>::zero();
2385 detail::MaxNormReduceFunctor(),
2386 MetaInt<actual_dimension-1>());
2391 NormType res = NumericTraits<NormType>::zero();
2394 detail::L1NormReduceFunctor(),
2395 MetaInt<actual_dimension-1>());
2406 NormType normMax = NumericTraits<NormType>::zero();
2409 detail::MaxNormReduceFunctor(),
2410 MetaInt<actual_dimension-1>());
2411 if(normMax == NumericTraits<NormType>::zero())
2413 NormType res = NumericTraits<NormType>::zero();
2416 detail::WeightedL2NormReduceFunctor<NormType>(1.0/normMax),
2417 MetaInt<actual_dimension-1>());
2418 return sqrt(res)*normMax;
2422 vigra_precondition(
false,
"MultiArrayView::norm(): Unknown norm type.");
2423 return NumericTraits<NormType>::zero();
2434template <
unsigned int N,
class T,
class Str
ideTag>
2435inline typename NormTraits<MultiArrayView <N, T, StrideTag> >::SquaredNormType
2436squaredNorm(MultiArrayView <N, T, StrideTag>
const & a)
2438 return a.squaredNorm();
2441template <
unsigned int N,
class T,
class Str
ideTag>
2442inline typename NormTraits<MultiArrayView <N, T, StrideTag> >::NormType
2443norm(MultiArrayView <N, T, StrideTag>
const & a)
2475template <
unsigned int N,
class T,
class A >
2477:
public MultiArrayView <N, typename vigra::detail::ResolveMultiband<T>::type,
2478 typename vigra::detail::ResolveMultiband<T>::Stride>
2481 typedef typename vigra::detail::ResolveMultiband<T>::Stride actual_stride;
2485 typedef MultiArrayView <N, typename vigra::detail::ResolveMultiband<T>::type,
2486 typename vigra::detail::ResolveMultiband<T>::Stride>
view_type;
2488 using view_type::actual_dimension;
2558 typedef typename difference_type::value_type diff_zero_t;
2578 template <
class U,
class Str
ideTag>
2585 template <
class U,
class Str
ideTag>
2650 template<
class Expression>
2651 MultiArray (multi_math::MultiMathOperand<Expression>
const & rhs,
2657 multi_math::math_detail::assignOrResize(*
this, rhs);
2662 template <
class U,
class Str
ideTag>
2674 this->copyOrReshape(rhs);
2683 template <
class U,
class Str
ideTag>
2686 this->copyOrReshape(rhs);
2695 return this->
init(v);
2704 template <
class U,
class Str
ideTag>
2720 template <
class U,
class Str
ideTag>
2735 template <
class U,
class Str
ideTag>
2751 template <
class U,
class Str
ideTag>
2795 template<
class Expression>
2798 multi_math::math_detail::assignOrResize(*
this, rhs);
2805 template<
class Expression>
2808 multi_math::math_detail::plusAssignOrResize(*
this, rhs);
2815 template<
class Expression>
2818 multi_math::math_detail::minusAssignOrResize(*
this, rhs);
2825 template<
class Expression>
2828 multi_math::math_detail::multiplyAssignOrResize(*
this, rhs);
2835 template<
class Expression>
2838 multi_math::math_detail::divideAssignOrResize(*
this, rhs);
2919 return vigra::detail::ResolveMultiband<T>::defaultStride(
shape);
2923template <
unsigned int N,
class T,
class A>
2934template <
unsigned int N,
class T,
class A>
2945template <
unsigned int N,
class T,
class A>
2949 defaultStride(
shape),
2961template <
unsigned int N,
class T,
class A>
2965 defaultStride(
shape),
2977template <
unsigned int N,
class T,
class A>
2981 defaultStride(
shape),
2997 vigra_precondition(
false,
2998 "MultiArray(): invalid MultiArrayInitializationTag.");
3002template <
unsigned int N,
class T,
class A>
3006 defaultStride(
shape),
3018template <
unsigned int N,
class T,
class A>
3019template <
class U,
class Str
ideTag>
3023 defaultStride(rhs.
shape()),
3030template <
unsigned int N,
class T,
class A>
3031template <
class U,
class Str
ideTag>
3035 if (this->shape() == rhs.shape())
3044template <
unsigned int N,
class T,
class A>
3052 else if(new_shape == this->shape())
3054 this->init(initial);
3061 allocate (new_ptr, new_size, initial);
3063 this->
m_ptr = new_ptr;
3070template <
unsigned int N,
class T,
class A>
3077 std::swap(this->m_alloc, other.m_alloc);
3080template <
unsigned int N,
class T,
class A>
3089 ptr =
m_alloc.allocate ((
typename A::size_type)s);
3093 std::allocator_traits<allocator_type>::construct (
m_alloc, ptr + i,
init);
3097 std::allocator_traits<allocator_type>::destroy (
m_alloc, ptr + j);
3098 m_alloc.deallocate (ptr, (
typename A::size_type)s);
3103template <
unsigned int N,
class T,
class A>
3113 ptr =
m_alloc.allocate ((
typename A::size_type)s);
3116 for (; i < s; ++i, ++
init)
3117 std::allocator_traits<allocator_type>::construct(
m_alloc, ptr + i, *
init);
3121 std::allocator_traits<allocator_type>::destroy (
m_alloc, ptr + j);
3122 m_alloc.deallocate (ptr, (
typename A::size_type)s);
3127template <
unsigned int N,
class T,
class A>
3128template <
class U,
class Str
ideTag>
3137 ptr =
m_alloc.allocate ((
typename A::size_type)s);
3140 detail::uninitializedCopyMultiArrayData(
init.traverser_begin(),
init.shape(),
3141 p,
m_alloc, MetaInt<actual_dimension-1>());
3144 for (
pointer pp = ptr; pp < p; ++pp)
3145 std::allocator_traits<allocator_type>::destroy (
m_alloc, pp);
3146 m_alloc.deallocate (ptr, (
typename A::size_type)s);
3151template <
unsigned int N,
class T,
class A>
3157 std::allocator_traits<allocator_type>::destroy (
m_alloc, ptr + i);
3158 m_alloc.deallocate (ptr, (
typename A::size_type)s);
3168template <
unsigned int N,
class T,
class Str
ideTag>
3169inline triple<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3171 typename AccessorTraits<T>::default_const_accessor >
3174 return triple<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3176 typename AccessorTraits<T>::default_const_accessor >
3177 ( array.traverser_begin(),
3179 typename AccessorTraits<T>::default_const_accessor() );
3182template <
unsigned int N,
class T,
class Str
ideTag,
class Accessor>
3183inline triple<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3186srcMultiArrayRange( MultiArrayView<N,T,StrideTag>
const & array, Accessor a )
3188 return triple<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3191 ( array.traverser_begin(),
3196template <
unsigned int N,
class T,
class Str
ideTag>
3197inline pair<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3198 typename AccessorTraits<T>::default_const_accessor >
3201 return pair<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3202 typename AccessorTraits<T>::default_const_accessor >
3203 ( array.traverser_begin(),
3204 typename AccessorTraits<T>::default_const_accessor() );
3207template <
unsigned int N,
class T,
class Str
ideTag,
class Accessor>
3208inline pair<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3212 return pair<typename MultiArrayView<N,T,StrideTag>::const_traverser,
3214 ( array.traverser_begin(), a );
3217template <
unsigned int N,
class T,
class Str
ideTag>
3218inline triple<typename MultiArrayView<N,T,StrideTag>::traverser,
3220 typename AccessorTraits<T>::default_accessor >
3223 return triple<typename MultiArrayView<N,T,StrideTag>::traverser,
3225 typename AccessorTraits<T>::default_accessor >
3226 ( array.traverser_begin(),
3228 typename AccessorTraits<T>::default_accessor() );
3231template <
unsigned int N,
class T,
class Str
ideTag,
class Accessor>
3232inline triple<typename MultiArrayView<N,T,StrideTag>::traverser,
3237 return triple<typename MultiArrayView<N,T,StrideTag>::traverser,
3240 ( array.traverser_begin(),
3245template <
unsigned int N,
class T,
class Str
ideTag>
3246inline pair<typename MultiArrayView<N,T,StrideTag>::traverser,
3247 typename AccessorTraits<T>::default_accessor >
3250 return pair<typename MultiArrayView<N,T,StrideTag>::traverser,
3251 typename AccessorTraits<T>::default_accessor >
3252 ( array.traverser_begin(),
3253 typename AccessorTraits<T>::default_accessor() );
3256template <
unsigned int N,
class T,
class Str
ideTag,
class Accessor>
3257inline pair<typename MultiArrayView<N,T,StrideTag>::traverser,
3261 return pair<typename MultiArrayView<N,T,StrideTag>::traverser,
3263 ( array.traverser_begin(), a );
3268template <
class PixelType,
class Accessor>
3269inline triple<ConstStridedImageIterator<PixelType>,
3274 ul(img.data(), 1, img.stride(0), img.stride(1));
3275 return triple<ConstStridedImageIterator<PixelType>,
3278 ul, ul +
Size2D(img.shape(0), img.shape(1)), a);
3281template <
class PixelType,
class Accessor>
3282inline pair<ConstStridedImageIterator<PixelType>,
Accessor>
3286 ul(img.data(), 1, img.stride(0), img.stride(1));
3287 return pair<ConstStridedImageIterator<PixelType>,
Accessor>
3291template <
class PixelType,
class Accessor>
3292inline triple<StridedImageIterator<PixelType>,
3297 ul(img.data(), 1, img.stride(0), img.stride(1));
3298 return triple<StridedImageIterator<PixelType>,
3301 ul, ul +
Size2D(img.shape(0), img.shape(1)), a);
3304template <
class PixelType,
class Accessor>
3305inline pair<StridedImageIterator<PixelType>,
Accessor>
3309 ul(img.data(), 1, img.stride(0), img.stride(1));
3310 return pair<StridedImageIterator<PixelType>,
Accessor>
3314template <
class PixelType,
class Accessor>
3315inline pair<StridedImageIterator<PixelType>,
Accessor>
3319 ul(img.data(), 1, img.stride(0), img.stride(1));
3320 return pair<StridedImageIterator<PixelType>,
Accessor>
3326template <
class PixelType>
3327inline triple<ConstStridedImageIterator<PixelType>,
3329 typename AccessorTraits<PixelType>::default_const_accessor>
3333 ul(img.data(), 1, img.stride(0), img.stride(1));
3334 typedef typename AccessorTraits<PixelType>::default_const_accessor
Accessor;
3335 return triple<ConstStridedImageIterator<PixelType>,
3341template <
class PixelType>
3342inline triple<ConstImageIterator<PixelType>,
3344 typename AccessorTraits<PixelType>::default_const_accessor>
3348 ul(img.data(), img.stride(1));
3349 typedef typename AccessorTraits<PixelType>::default_const_accessor
Accessor;
3350 return triple<ConstImageIterator<PixelType>,
3356template <
class PixelType>
3357inline pair< ConstStridedImageIterator<PixelType>,
3358 typename AccessorTraits<PixelType>::default_const_accessor>
3362 ul(img.data(), 1, img.stride(0), img.stride(1));
3363 typedef typename AccessorTraits<PixelType>::default_const_accessor
Accessor;
3364 return pair<ConstStridedImageIterator<PixelType>,
3369template <
class PixelType>
3370inline pair< ConstImageIterator<PixelType>,
3371 typename AccessorTraits<PixelType>::default_const_accessor>
3375 ul(img.data(), img.stride(1));
3376 typedef typename AccessorTraits<PixelType>::default_const_accessor
Accessor;
3377 return pair<ConstImageIterator<PixelType>,
3382template <
class PixelType>
3383inline triple< StridedImageIterator<PixelType>,
3385 typename AccessorTraits<PixelType>::default_accessor>
3389 ul(img.data(), 1, img.stride(0), img.stride(1));
3390 typedef typename AccessorTraits<PixelType>::default_accessor
Accessor;
3391 return triple<StridedImageIterator<PixelType>,
3397template <
class PixelType>
3398inline triple< ImageIterator<PixelType>,
3400 typename AccessorTraits<PixelType>::default_accessor>
3404 ul(img.data(), img.stride(1));
3405 typedef typename AccessorTraits<PixelType>::default_accessor
Accessor;
3406 return triple<ImageIterator<PixelType>,
3412template <
class PixelType>
3413inline pair< StridedImageIterator<PixelType>,
3414 typename AccessorTraits<PixelType>::default_accessor>
3418 ul(img.data(), 1, img.stride(0), img.stride(1));
3419 typedef typename AccessorTraits<PixelType>::default_accessor
Accessor;
3420 return pair<StridedImageIterator<PixelType>,
Accessor>
3424template <
class PixelType>
3425inline pair< ImageIterator<PixelType>,
3426 typename AccessorTraits<PixelType>::default_accessor>
3430 typedef typename AccessorTraits<PixelType>::default_accessor
Accessor;
3434template <
class PixelType>
3435inline pair< ConstStridedImageIterator<PixelType>,
3436 typename AccessorTraits<PixelType>::default_accessor>
3440 ul(img.data(), 1, img.stride(0), img.stride(1));
3441 typedef typename AccessorTraits<PixelType>::default_accessor
Accessor;
3442 return pair<ConstStridedImageIterator<PixelType>,
Accessor>
3446template <
class PixelType>
3447inline pair< ConstImageIterator<PixelType>,
3448 typename AccessorTraits<PixelType>::default_accessor>
3452 ul(img.data(), img.stride(1));
3453 typedef typename AccessorTraits<PixelType>::default_accessor
Accessor;
3454 return pair<ConstImageIterator<PixelType>,
Accessor>
3476template <
class T,
class Str
ide>
3480 vigra_precondition(array.isUnstrided(0),
3481 "makeBasicImageView(array): array must be unstrided along x (i.e. array.isUnstrided(0) == true).");
3482 return BasicImageView <T> (array.data (), array.shape (0),
3483 array.shape (1), array.stride(1));
3498 vigra_precondition(array.stride(1) == array.shape(0),
3499 "makeBasicImageView(): cannot join strided dimensions");
3500 return BasicImageView <T> (array.data (),
3501 array.shape (0)*array.shape (1), array.shape (2), array.stride(2));
3512template <
class T,
class Str
ide>
3513BasicImageView <RGBValue<T> >
3516 vigra_precondition(array.shape (0) == 3,
3517 "makeRGBImageView(): array.shape(0) must be 3.");
3518 vigra_precondition(array.isUnstrided(),
3519 "makeRGBImageView(array): array must be unstrided (i.e. array.isUnstrided() == true).");
3520 return BasicImageView <RGBValue<T> > (
3521 reinterpret_cast <RGBValue <T> *
> (array.data ()),
3522 array.shape (1), array.shape (2));
3529#undef VIGRA_ASSERT_INSIDE
Fundamental class template for images.
Definition basicimage.hxx:476
Standard 2D random access const iterator for images that store the data as a linear array.
Definition imageiterator.hxx:896
Const iterator to be used when pixels are to be skipped.
Definition imageiterator.hxx:1030
Wrapper class for the FFTW complex types 'fftw_complex'.
Definition fftw3.hxx:132
Find the sum of the pixel values in an image or ROI.
Definition inspectimage.hxx:1145
Standard 2D random access iterator for images that store the data in a linear array.
Definition imageiterator.hxx:851
TinyVector< MultiArrayIndex, N > type
Definition multi_shape.hxx:272
Base class for, and view to, MultiArray.
Definition multi_array.hxx:705
difference_type strideOrdering() const
Definition multi_array.hxx:1619
vigra::detail::MultiIteratorChooser< Stride >::template Traverser< actual_dimension, T, Tconst &, Tconst * >::type const_traverser
Definition multi_array.hxx:769
MultiArrayView< N-1, T, StridedArrayTag > bindAt(difference_type_1 m, difference_type_1 d) const
Definition multi_array.hxx:2298
MultiArrayView< N, T, StridedArrayTag > transpose(const difference_type &permutation) const
Definition multi_array.hxx:1595
MultiArrayView< 1, T, StridedArrayTag > diagonal() const
Definition multi_array.hxx:1506
MultiArrayView & operator/=(T const &rhs)
Definition multi_array.hxx:993
MultiArrayView< N, T, Stride > view_type
Definition multi_array.hxx:773
const value_type * const_pointer
Definition multi_array.hxx:735
const_reference operator[](difference_type_1 d) const
Definition multi_array.hxx:1099
NormTraits< MultiArrayView >::SquaredNormType squaredNorm() const
Definition multi_array.hxx:1871
MultiArrayIndex difference_type_1
Definition multi_array.hxx:751
void swapData(MultiArrayView rhs)
Definition multi_array.hxx:1266
MultiArrayView(MultiArrayView const &rhs)=default
void sum(MultiArrayView< N, U, S > sums) const
Definition multi_array.hxx:1841
T value_type
Definition multi_array.hxx:719
difference_type_1 size(difference_type_1 n) const
Definition multi_array.hxx:1657
difference_type_1 coordinateToScanOrderIndex(const difference_type &d) const
Definition multi_array.hxx:1116
const_iterator begin() const
Definition multi_array.hxx:1931
MultiArrayView< N, T, StridedArrayTag > permuteStridesAscending() const
Definition multi_array.hxx:2165
MultiArrayView subarray(difference_type p, difference_type q) const
Definition multi_array.hxx:1530
bool hasData() const
Definition multi_array.hxx:1915
const_traverser traverser_begin() const
Definition multi_array.hxx:1964
NormTraits< MultiArrayView >::NormType norm(int type=2, bool useSquaredNorm=true) const
Definition multi_array.hxx:2374
void swapData(MultiArrayView< N, T2, C2 > rhs)
Definition multi_array.hxx:1277
MultiArrayView & operator-=(MultiArrayView< N, U, C1 > const &rhs)
difference_type_1 stride(int n) const
Definition multi_array.hxx:1693
difference_type scanOrderIndexToCoordinate(difference_type_1 d) const
Definition multi_array.hxx:1107
MultiArrayView< N+1, typename ExpandElementResult< T >::type, StridedArrayTag > expandElements(difference_type_1 d) const
Definition multi_array.hxx:2327
MultiArrayView< N-1, T, typename vigra::detail::MaybeStrided< StrideTag, M >::type > bind(difference_type_1 d) const
MultiArrayView< N-1, T, StridedArrayTag > bindInner(difference_type_1 d) const
Definition multi_array.hxx:2278
bool isInside(difference_type const &p) const
Definition multi_array.hxx:1719
bool operator!=(MultiArrayView< N, U, C1 > const &rhs) const
Definition multi_array.hxx:1712
MultiArrayView< N+1, T, StrideTag > insertSingletonDimension(difference_type_1 i) const
Definition multi_array.hxx:2356
MultiArrayView(const difference_type &shape, const_pointer ptr)
Definition multi_array.hxx:849
traverser traverser_begin()
Definition multi_array.hxx:1955
const difference_type & shape() const
Definition multi_array.hxx:1650
difference_type m_shape
Definition multi_array.hxx:795
MultiArrayView< N, T, StridedArrayTag > stridearray(const difference_type &s) const
Definition multi_array.hxx:1545
MultiArrayView & operator/=(MultiArrayView< N, U, C1 > const &rhs)
static difference_type strideOrdering(difference_type strides)
Definition multi_array.hxx:2138
MultiArrayView & operator+=(MultiArrayView< N, U, C1 > const &rhs)
MultiArrayView(const MultiArrayView< N, T, Stride > &other)
Definition multi_array.hxx:838
pointer m_ptr
Definition multi_array.hxx:804
MultiArrayView & operator=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:1003
StridedScanOrderIterator< actual_dimension, T, T const &, T const * > const_iterator
Definition multi_array.hxx:759
MultiArrayView & operator-=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:1023
MultiArrayView & init(const U &init)
Definition multi_array.hxx:1208
bool all() const
Definition multi_array.hxx:1739
MultiArrayView< N-M, T, StrideTag > bindOuter(const TinyVector< Index, M > &d) const
Definition multi_array.hxx:2186
bool isOutside(difference_type const &p) const
Definition multi_array.hxx:1728
MultiArrayShape< actual_dimension >::type difference_type
Definition multi_array.hxx:739
traverser traverser_end()
Definition multi_array.hxx:1974
reference operator()(difference_type_1 x)
Definition multi_array.hxx:1123
MultiArrayView & operator+=(T const &rhs)
Definition multi_array.hxx:969
void copy(const MultiArrayView &rhs)
Definition multi_array.hxx:1218
void copy(const MultiArrayView< N, U, CN > &rhs)
Definition multi_array.hxx:1228
MultiArrayView & operator*=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:1033
difference_type_1 width() const
Definition multi_array.hxx:1672
const_traverser traverser_end() const
Definition multi_array.hxx:1985
difference_type_1 shape(difference_type_1 n) const
Definition multi_array.hxx:1665
reference operator[](difference_type_1 d)
Definition multi_array.hxx:1083
MultiArrayView & operator-=(T const &rhs)
Definition multi_array.hxx:977
void minmax(T *minimum, T *maximum) const
Definition multi_array.hxx:1766
difference_type size_type
Definition multi_array.hxx:747
bool isUnstrided(unsigned int dimension=N-1) const
Definition multi_array.hxx:1288
MultiArrayView & operator*=(MultiArrayView< N, U, C1 > const &rhs)
MultiArrayView & operator/=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:1043
difference_type key_type
Definition multi_array.hxx:743
MultiArrayView< N-M, T, StridedArrayTag > bindInner(const TinyVector< Index, M > &d) const
MultiArrayView & operator*=(T const &rhs)
Definition multi_array.hxx:985
MultiArrayView(const difference_type &shape, const difference_type &stride, const_pointer ptr)
Definition multi_array.hxx:860
bool operator==(MultiArrayView< N, U, C1 > const &rhs) const
Definition multi_array.hxx:1701
value_type & reference
Definition multi_array.hxx:723
MultiArrayView(BasicImage< T, ALLOC > const &image)
Definition multi_array.hxx:874
const difference_type & stride() const
Definition multi_array.hxx:1686
pointer data() const
Definition multi_array.hxx:1900
difference_type_1 elementCount() const
Definition multi_array.hxx:1632
void swap(MultiArrayView &other)
Definition multi_array.hxx:1253
MultiArrayView< N, T, StridedArrayTag > permuteStridesDescending() const
Definition multi_array.hxx:2175
iterator end()
Definition multi_array.hxx:1939
void meanVariance(U *mean, U *variance) const
Definition multi_array.hxx:1782
const_iterator end() const
Definition multi_array.hxx:1947
MultiArrayView()
Definition multi_array.hxx:829
difference_type m_stride
Definition multi_array.hxx:800
MultiArrayView< N-1, T, StrideTag > bindOuter(difference_type_1 d) const
Definition multi_array.hxx:2258
vigra::detail::MultiIteratorChooser< Stride >::template Traverser< actual_dimension, T, T &, T * >::type traverser
Definition multi_array.hxx:764
ActualDimension
Definition multi_array.hxx:715
void reset()
Definition multi_array.hxx:890
value_type * pointer
Definition multi_array.hxx:731
iterator begin()
Definition multi_array.hxx:1923
U product() const
Definition multi_array.hxx:1858
MultiArrayView< N, Multiband< value_type >, StrideTag > multiband() const
Definition multi_array.hxx:1485
difference_type_1 height() const
Definition multi_array.hxx:1679
MultiArrayView & operator=(MultiArrayView< N, U, C1 > const &rhs)
Definition multi_array.hxx:928
MultiArrayView< N, typename ExpandElementResult< T >::type, StridedArrayTag > bindElementChannel(difference_type_1 i) const
Definition multi_array.hxx:1417
MultiArray< N, T > matrix_type
Definition multi_array.hxx:777
bool any() const
Definition multi_array.hxx:1752
reference operator[](const difference_type &d)
Definition multi_array.hxx:1051
StridedScanOrderIterator< actual_dimension, T, T &, T * > iterator
Definition multi_array.hxx:755
U sum() const
Definition multi_array.hxx:1805
MultiArrayView & operator+=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:1013
difference_type_1 size() const
Definition multi_array.hxx:1643
MultiArrayView< N, T, StridedArrayTag > transpose() const
Definition multi_array.hxx:1569
MultiArrayView & operator=(value_type const &v)
Definition multi_array.hxx:938
const value_type & const_reference
Definition multi_array.hxx:727
Main MultiArray class containing the memory management.
Definition multi_array.hxx:2479
MultiArray & operator*=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:2826
view_type::const_traverser const_traverser
Definition multi_array.hxx:2536
view_type::const_reference const_reference
Definition multi_array.hxx:2516
allocator_type m_alloc
Definition multi_array.hxx:2562
MultiArray(multi_math::MultiMathOperand< Expression > const &rhs, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:2651
void allocate(pointer &ptr, difference_type_1 s, U const *init)
Definition multi_array.hxx:3105
void swap(MultiArray &other)
Definition multi_array.hxx:3072
MultiArray(const difference_type &shape, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:2946
view_type::size_type size_type
Definition multi_array.hxx:2520
void reshape(const difference_type &shape)
Definition multi_array.hxx:2863
MultiArray(const difference_type &shape, const_pointer init, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:3003
MultiArray & operator=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:2796
MultiArray()
Definition multi_array.hxx:2590
MultiArray & operator+=(const MultiArrayView< N, U, StrideTag > &rhs)
Definition multi_array.hxx:2705
MultiArray(const difference_type &shape, MultiArrayInitializationTag init, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:2978
MultiArray(const MultiArray &rhs)
Definition multi_array.hxx:2641
allocator_type const & allocator() const
Definition multi_array.hxx:2912
MultiArrayView< N, typename vigra::detail::ResolveMultiband< T >::type, typename vigra::detail::ResolveMultiband< T >::Stride > view_type
Definition multi_array.hxx:2486
view_type::iterator iterator
Definition multi_array.hxx:2550
view_type::difference_type_1 difference_type_1
Definition multi_array.hxx:2528
view_type::const_pointer const_pointer
Definition multi_array.hxx:2508
MultiArray & operator/=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:2836
view_type::difference_type difference_type
Definition multi_array.hxx:2524
MultiArray(allocator_type const &alloc)
Definition multi_array.hxx:2597
view_type::pointer pointer
Definition multi_array.hxx:2504
view_type::reference reference
Definition multi_array.hxx:2512
MultiArray & operator-=(const MultiArrayView< N, U, StrideTag > &rhs)
Definition multi_array.hxx:2721
A allocator_type
Definition multi_array.hxx:2492
MultiArray & init(const U &init)
Definition multi_array.hxx:2853
MultiArray(const MultiArrayView< N, U, StrideTag > &rhs, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:3020
void allocate(pointer &ptr, MultiArrayView< N, U, StrideTag > const &init)
Definition multi_array.hxx:3129
void allocate(pointer &ptr, difference_type_1 s, const_reference init)
Definition multi_array.hxx:3081
view_type::const_iterator const_iterator
Definition multi_array.hxx:2554
MultiArray & operator-=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:2816
MultiArray(difference_type_1 length, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:2924
MultiArray & operator=(const MultiArray &rhs)
Definition multi_array.hxx:2671
MultiArray(const difference_type &shape, const_reference init, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:2962
MultiArray(difference_type_1 width, difference_type_1 height, allocator_type const &alloc=allocator_type())
Definition multi_array.hxx:2935
MultiArray< N, T, A > matrix_type
Definition multi_array.hxx:2496
view_type::traverser traverser
Definition multi_array.hxx:2532
void deallocate(pointer &ptr, difference_type_1 s)
Definition multi_array.hxx:3152
MultiArray & operator/=(const MultiArrayView< N, U, StrideTag > &rhs)
Definition multi_array.hxx:2752
view_type::value_type value_type
Definition multi_array.hxx:2500
void reshape(const difference_type &shape, const_reference init)
Definition multi_array.hxx:3045
~MultiArray()
Definition multi_array.hxx:2844
MultiArray & operator*=(const MultiArrayView< N, U, StrideTag > &rhs)
Definition multi_array.hxx:2736
MultiArray & operator+=(multi_math::MultiMathOperand< Expression > const &rhs)
Definition multi_array.hxx:2806
MultiArray & operator=(value_type const &v)
Definition multi_array.hxx:2693
Class for a single RGB value.
Definition rgbvalue.hxx:128
Two dimensional size object.
Definition diff2d.hxx:483
Iterator to be used when pixels are to be skipped.
Definition imageiterator.hxx:969
Sequential iterator for MultiArrayView.
Definition multi_iterator.hxx:273
void init(Iterator i, Iterator end)
Definition tinyvector.hxx:708
Class for fixed size vectors.
Definition tinyvector.hxx:1008
BasicImageView< T > makeBasicImageView(MultiArrayView< 2, T, Stride > const &array)
Definition multi_array.hxx:3478
MultiArrayInitializationTag
Initialize a MultiArray in a standard way.
Definition multi_fwd.hxx:104
@ LinearSequence
Initialize array by a linear sequence in scan order.
Definition multi_fwd.hxx:105
void linearSequence(Iterator first, Iterator last, Value start, Value step)
Fill an array with a sequence of numbers.
Definition algorithm.hxx:208
FFTWComplex< R >::NormType norm(const FFTWComplex< R > &a)
norm (= magnitude)
Definition fftw3.hxx:1037
SquareRootTraits< FixedPoint< IntBits, FracBits > >::SquareRootResult sqrt(FixedPoint< IntBits, FracBits > v)
square root.
Definition fixedpoint.hxx:616
NumericTraits< V >::Promote sum(TinyVectorBase< V, SIZE, D1, D2 > const &l)
sum of the vector's elements
Definition tinyvector.hxx:2073
void transformMultiArray(...)
Transform a multi-dimensional array with a unary function or functor.
NumericTraits< V >::Promote prod(TinyVectorBase< V, SIZE, D1, D2 > const &l)
product of the vector's elements
Definition tinyvector.hxx:2097
FFTWComplex< R >::SquaredNormType squaredNorm(const FFTWComplex< R > &a)
squared norm (= squared magnitude)
Definition fftw3.hxx:1044
std::ptrdiff_t MultiArrayIndex
Definition multi_fwd.hxx:60
BasicImageView< RGBValue< T > > makeRGBImageView(MultiArrayView< 3, T, Stride > const &array)
Definition multi_array.hxx:3514
PromoteTraits< V1, V2 >::Promote dot(RGBValue< V1, RIDX1, GIDX1, BIDX1 > const &r1, RGBValue< V2, RIDX2, GIDX2, BIDX2 > const &r2)
dot product
Definition rgbvalue.hxx:906
Definition metaprogramming.hxx:116
Definition metaprogramming.hxx:123