37 #ifndef VIGRA_TINYVECTOR_HXX 
   38 #define VIGRA_TINYVECTOR_HXX 
   52 #include "metaprogramming.hxx" 
   53 #include "numerictraits.hxx" 
   55 #include "mathutil.hxx" 
   57 #include "static_assert.hxx" 
   59 #ifdef VIGRA_CHECK_BOUNDS 
   60 #define VIGRA_ASSERT_INSIDE(diff) \ 
   61   vigra_precondition(diff >= 0, "Index out of bounds");\ 
   62   vigra_precondition(diff < SIZE, "Index out of bounds"); 
   64 #define VIGRA_ASSERT_INSIDE(diff) 
   71 #pragma warning( push ) 
   72 #pragma warning( disable : 4503 ) 
   81 template <
class V1, 
int SIZE, 
class D1, 
class D2>
 
   84 template <
class V1, 
int SIZE, 
class D1, 
class D2>
 
   92 #define VIGRA_EXEC_LOOP(NAME, OPER) \ 
   93     template <class T1, class T2>  \ 
   94     static void NAME(T1 * left, T2 const * right)  \ 
   96         for(int i=0; i<LEVEL; ++i)  \ 
   97             (left[i]) OPER (right[i]);  \ 
  100 #define VIGRA_EXEC_LOOP_MINMAX(NAME, OPER) \ 
  101     template <class T1, class T2>  \ 
  102     static void NAME(T1 * left, T2 const * right)  \ 
  104         for(int i=0; i<LEVEL; ++i)  \ 
  105             if(left[i] OPER right[i]) \ 
  106                 left[i] = right[i];  \ 
  109 #define VIGRA_EXEC_LOOP_SCALAR(NAME, OPER) \ 
  110     template <class T1, class T2>  \ 
  111     static void NAME(T1 * left, T2 right)  \ 
  113         for(int i=0; i<LEVEL; ++i)  \ 
  114             (left[i]) = detail::RequiresExplicitCast<T1>::cast((left[i]) OPER (right));  \ 
  120     template <
class T1, 
class T2>
 
  121     static void assignCast(T1 * left, T2 
const * right)
 
  123         for(
int i=0; i<LEVEL; ++i)
 
  124             left[i] = detail::RequiresExplicitCast<T1>::cast(right[i]);
 
  127     template <
class T1, 
class T2>
 
  128     static void reverseAssign(T1 * left, T2 
const * right)
 
  130         for(
int i=0; i<LEVEL; ++i)
 
  134     template <
class T1, 
class T2>
 
  135     static void assignScalar(T1 * left, T2 right)
 
  137         for(
int i=0; i<LEVEL; ++i)
 
  138             left[i] = detail::RequiresExplicitCast<T1>::cast(right);
 
  141     template <
class T1, 
class T2>
 
  142     static void power(T1 * left, T2 right)
 
  144         for(
int i=0; i<LEVEL; ++i)
 
  145             left[i] = detail::RequiresExplicitCast<T1>::cast(pow(left, right));
 
  148     VIGRA_EXEC_LOOP(assign, =)
 
  149     VIGRA_EXEC_LOOP(
add, +=)
 
  150     VIGRA_EXEC_LOOP(
sub, -=)
 
  151     VIGRA_EXEC_LOOP(
mul, *=)
 
  152     VIGRA_EXEC_LOOP(
div, /=)
 
  153     VIGRA_EXEC_LOOP(mod, %=)
 
  154     VIGRA_EXEC_LOOP(neg, = -)
 
  155     VIGRA_EXEC_LOOP(
abs, = vigra::abs)
 
  156     VIGRA_EXEC_LOOP(
floor, = vigra::floor)
 
  157     VIGRA_EXEC_LOOP(
ceil, = vigra::ceil)
 
  158     VIGRA_EXEC_LOOP(
round, = vigra::round)
 
  159     VIGRA_EXEC_LOOP(
sqrt, = vigra::sqrt)
 
  160     VIGRA_EXEC_LOOP(fromPromote, = NumericTraits<T1>::fromPromote)
 
  161     VIGRA_EXEC_LOOP(fromRealPromote, = NumericTraits<T1>::fromRealPromote)
 
  162     VIGRA_EXEC_LOOP_SCALAR(addScalar, +)
 
  163     VIGRA_EXEC_LOOP_SCALAR(subScalar, -)
 
  164     VIGRA_EXEC_LOOP_SCALAR(mulScalar, *)
 
  165     VIGRA_EXEC_LOOP_SCALAR(divScalar, /)
 
  167     VIGRA_EXEC_LOOP_MINMAX(min, >)
 
  168     VIGRA_EXEC_LOOP_MINMAX(max, <)
 
  171     static T const & minimum(T const * p)
 
  173         return *std::min_element(p, p+LEVEL);
 
  177     static T 
const & maximum(T 
const * p)
 
  179         return *std::max_element(p, p+LEVEL);
 
  183     static bool all(T 
const * p, T 
const & zero)
 
  185         for(
int i=0; i<LEVEL; ++i)
 
  192     static bool any(T 
const * p, T 
const & zero)
 
  194         for(
int i=0; i<LEVEL; ++i)
 
  200     template <
class T1, 
class T2>
 
  201     static bool notEqual(T1 
const * left, T2 
const * right)
 
  203         for(
int i=0; i<LEVEL; ++i)
 
  204             if(left[i] != right[i])
 
  209     template <
class T1, 
class T2>
 
  210     static bool lexicographicLessThan(T1 
const * left, T2 
const * right)
 
  212         for(
int i=0; i<LEVEL; ++i)
 
  214             if(left[i] < right[i])
 
  216             if(right[i] < left[i])
 
  226         for(
int i=0; i<LEVEL; ++i)
 
  234     static typename NumericTraits<T>::Promote
 
  237         typename NumericTraits<T>::Promote  res(*d * *d);
 
  238         for(
int i=1; i<LEVEL; ++i)
 
  243     template <
class T1, 
class T2>
 
  244     static typename PromoteTraits<T1, T2>::Promote
 
  245     dot(T1 
const * left, T2 
const * right)
 
  247         typename PromoteTraits<T1, T2>::Promote res(*left * *right);
 
  248         for(
int i=1; i<LEVEL; ++i)
 
  249             res += left[i] * right[i];
 
  254     static typename NormTraits<T>::SquaredNormType
 
  258         for(
int i=1; i<LEVEL; ++i)
 
  265 struct UnrollScalarResult
 
  268     static typename NumericTraits<T>::Promote
 
  274     template <
class T1, 
class T2>
 
  275     static typename PromoteTraits<T1, T2>::Promote
 
  276     dot(T1 
const * left, T2 
const * right)
 
  282     static typename NormTraits<T>::SquaredNormType
 
  288     static std::ptrdiff_t
 
  295     static T 
const & minimum(T 
const * p)
 
  297         T 
const & m = UnrollScalarResult<LEVEL - 1>::minimum(p+1);
 
  304     static T 
const & maximum(T 
const * p)
 
  306         T 
const & m = UnrollScalarResult<LEVEL - 1>::maximum(p+1);
 
  313     static bool all(T 
const * p, T 
const & zero)
 
  315         return *p != zero && UnrollScalarResult<LEVEL - 1>::all(p+1, zero);
 
  319     static bool any(T 
const * p, T 
const & zero)
 
  321         return *p != zero || UnrollScalarResult<LEVEL - 1>::any(p+1, zero);
 
  326 struct UnrollScalarResult<1>
 
  329     static typename NumericTraits<T>::Promote
 
  335     template <
class T1, 
class T2>
 
  336     static typename PromoteTraits<T1, T2>::Promote
 
  337     dot(T1 
const * left, T2 
const * right)
 
  339         return *left * *right;
 
  343     static typename NormTraits<T>::SquaredNormType
 
  349     static std::ptrdiff_t
 
  356     static T 
const & minimum(T 
const * p)
 
  362     static T 
const & maximum(T 
const * p)
 
  368     static bool all(T 
const * p, T 
const & zero)
 
  374     static bool any(T 
const * p, T 
const & zero)
 
  380 #undef VIGRA_EXEC_LOOP 
  381 #undef VIGRA_EXEC_LOOP_MINMAX 
  382 #undef VIGRA_EXEC_LOOP_SCALAR 
  384 #define VIGRA_UNROLL_LOOP(NAME, OPER) \ 
  385     template <class T1, class T2>  \ 
  386     static void NAME(T1 * left, T2 const * right)  \ 
  388         (*left) OPER (*right);  \ 
  389         UnrollLoop<LEVEL-1>::NAME(left+1, right+1); \ 
  392 #define VIGRA_UNROLL_LOOP_MINMAX(NAME, OPER) \ 
  393     template <class T1, class T2>  \ 
  394     static void NAME(T1 * left, T2 const * right)  \ 
  396         if(*left OPER *right) \ 
  398         UnrollLoop<LEVEL-1>::NAME(left+1, right+1); \ 
  401 #define VIGRA_UNROLL_LOOP_SCALAR(NAME, OPER) \ 
  402     template <class T1, class T2>  \ 
  403     static void NAME(T1 * left, T2 right)  \ 
  405         (*left) = detail::RequiresExplicitCast<T1>::cast((*left) OPER (right));  \ 
  406         UnrollLoop<LEVEL-1>::NAME(left+1, right); \ 
  413     template <
class T1, 
class T2>
 
  414     static void reverseAssign(T1 * left, T2 
const * right)
 
  417         UnrollLoop<LEVEL-1>::reverseAssign(left+1, right-1);
 
  420     template <
class T1, 
class T2>
 
  421     static void assignCast(T1 * left, T2 
const * right)
 
  423         *left = detail::RequiresExplicitCast<T1>::cast(*right);
 
  424         UnrollLoop<LEVEL-1>::assignCast(left+1, right+1);
 
  427     template <
class T1, 
class T2>
 
  428     static void assignScalar(T1 * left, T2 right)
 
  430         *left = detail::RequiresExplicitCast<T1>::cast(right);
 
  431         UnrollLoop<LEVEL-1>::assignScalar(left+1, right);
 
  434     template <
class T1, 
class T2>
 
  435     static void power(T1 * left, T2 right)
 
  437         *left = detail::RequiresExplicitCast<T1>::cast(pow(*left, right));
 
  441     VIGRA_UNROLL_LOOP(assign, =)
 
  442     VIGRA_UNROLL_LOOP(
add, +=)
 
  443     VIGRA_UNROLL_LOOP(
sub, -=)
 
  444     VIGRA_UNROLL_LOOP(
mul, *=)
 
  445     VIGRA_UNROLL_LOOP(
div, /=)
 
  446     VIGRA_UNROLL_LOOP(mod, %=)
 
  447     VIGRA_UNROLL_LOOP(neg, = -)
 
  448     VIGRA_UNROLL_LOOP(
abs, = vigra::abs)
 
  449     VIGRA_UNROLL_LOOP(
floor, = vigra::floor)
 
  450     VIGRA_UNROLL_LOOP(
ceil, = vigra::ceil)
 
  451     VIGRA_UNROLL_LOOP(
round, = vigra::round)
 
  452     VIGRA_UNROLL_LOOP(
sqrt, = vigra::sqrt)
 
  453     VIGRA_UNROLL_LOOP(fromPromote, = NumericTraits<T1>::fromPromote)
 
  454     VIGRA_UNROLL_LOOP(fromRealPromote, = NumericTraits<T1>::fromRealPromote)
 
  455     VIGRA_UNROLL_LOOP_SCALAR(addScalar, +)
 
  456     VIGRA_UNROLL_LOOP_SCALAR(subScalar, -)
 
  457     VIGRA_UNROLL_LOOP_SCALAR(mulScalar, *)
 
  458     VIGRA_UNROLL_LOOP_SCALAR(divScalar, /)
 
  460     VIGRA_UNROLL_LOOP_MINMAX(min, >)
 
  461     VIGRA_UNROLL_LOOP_MINMAX(max, <)
 
  464     static T const & minimum(T const * p)
 
  466         return UnrollScalarResult<LEVEL>::minimum(p);
 
  470     static T 
const & maximum(T 
const * p)
 
  472         return UnrollScalarResult<LEVEL>::maximum(p);
 
  476     static bool all(T 
const * p, T 
const & zero)
 
  478         return UnrollScalarResult<LEVEL>::all(p, zero);
 
  482     static bool any(T 
const * p, T 
const & zero)
 
  484         return UnrollScalarResult<LEVEL>::any(p, zero);
 
  487     template <
class T1, 
class T2>
 
  488     static bool notEqual(T1 
const * left, T2 
const * right)
 
  490         return (*left != *right) || UnrollLoop<LEVEL - 1>::notEqual(left+1, right+1);
 
  493     template <
class T1, 
class T2>
 
  494     static bool lexicographicLessThan(T1 
const * left, T2 
const * right)
 
  500         return UnrollLoop<LEVEL - 1>::lexicographicLessThan(left+1, right+1);
 
  507                   UnrollLoop<LEVEL - 1>::closeAtTolerance(left+1, right+1, epsilon);
 
  511     static typename NumericTraits<T>::Promote
 
  517     template <
class T1, 
class T2>
 
  518     static typename PromoteTraits<T1, T2>::Promote
 
  519     dot(T1 
const * left, T2 
const * right)
 
  525     static typename NormTraits<T>::SquaredNormType
 
  532 #undef VIGRA_UNROLL_LOOP 
  533 #undef VIGRA_UNROLL_LOOP_MINMAX 
  534 #undef VIGRA_UNROLL_LOOP_SCALAR 
  539     template <
class T1, 
class T2>
 
  540     static void reverseAssign(T1, T2) {}
 
  541     template <
class T1, 
class T2>
 
  542     static void assignCast(T1, T2) {}
 
  543     template <
class T1, 
class T2>
 
  544     static void assign(T1, T2) {}
 
  545     template <
class T1, 
class T2>
 
  546     static void assignScalar(T1, T2) {}
 
  547     template <
class T1, 
class T2>
 
  548     static void power(T1, T2) {}
 
  549     template <
class T1, 
class T2>
 
  550     static void add(T1, T2) {}
 
  551     template <
class T1, 
class T2>
 
  552     static void addScalar(T1, T2) {}
 
  553     template <
class T1, 
class T2>
 
  554     static void sub(T1, T2) {}
 
  555     template <
class T1, 
class T2>
 
  556     static void subScalar(T1, T2) {}
 
  557     template <
class T1, 
class T2>
 
  558     static void mul(T1, T2) {}
 
  559     template <
class T1, 
class T2>
 
  560     static void mulScalar(T1, T2) {}
 
  561     template <
class T1, 
class T2>
 
  562     static void div(T1, T2) {}
 
  563     template <
class T1, 
class T2>
 
  564     static void mod(T1, T2) {}
 
  565     template <
class T1, 
class T2>
 
  566     static void divScalar(T1, T2) {}
 
  567     template <
class T1, 
class T2>
 
  568     static void fromPromote(T1, T2) {}
 
  569     template <
class T1, 
class T2>
 
  570     static void fromRealPromote(T1, T2) {}
 
  571     template <
class T1, 
class T2>
 
  572     static void neg(T1, T2) {}
 
  573     template <
class T1, 
class T2>
 
  574     static void abs(T1, T2) {}
 
  575     template <
class T1, 
class T2>
 
  576     static void floor(T1, T2) {}
 
  577     template <
class T1, 
class T2>
 
  578     static void ceil(T1, T2) {}
 
  579     template <
class T1, 
class T2>
 
  580     static void round(T1, T2) {}
 
  581     template <
class T1, 
class T2>
 
  582     static void sqrt(T1, T2) {}
 
  583     template <
class T1, 
class T2>
 
  584     static bool notEqual(T1, T2) { 
return false; }
 
  585     template <
class T1, 
class T2>
 
  586     static bool lexicographicLessThan(T1, T2) { 
return false; }
 
  587     template <
class T1, 
class T2>
 
  588     static void min(T1, T2) {}
 
  589     template <
class T1, 
class T2>
 
  590     static void max(T1, T2) {}
 
  596     static bool all(T 
const *, T 
const &) { 
return true; }
 
  598     static bool any(T 
const *, T 
const &) { 
return false; }
 
  606     static const int MaxUnrollSize = 5;
 
  607     typedef typename IfBool<(SIZE <= MaxUnrollSize), UnrollLoop<SIZE>, ExecLoop<SIZE> >::type type;
 
  613 inline DontInit dontInit() {
return DontInit(); }
 
  617 template <
class T, 
int SIZE>
 
  620 template <
class T, 
int SIZE>
 
  638 template <
class VALUETYPE, 
int SIZE, 
class DATA, 
class DERIVED>
 
  647     typedef typename detail::LoopType<SIZE>::type Loop;
 
  699     typedef typename SquareRootTraits<SquaredNormType>::SquareRootResult 
NormType;
 
  703     enum { static_size = SIZE };
 
  707     template <
class Iterator>
 
  710         vigra_precondition(end-i == SIZE,
 
  711             "TinyVector::init(): Sequence has wrong size.");
 
  712         Loop::assignCast(data_, i);
 
  719         Loop::assignScalar(data_, initial);
 
  724     template <
class T1, 
class D1, 
class D2>
 
  728         return static_cast<DERIVED &
>(*this);
 
  733     template <
class T1, 
class D1, 
class D2>
 
  737         return static_cast<DERIVED &
>(*this);
 
  742     template <
class T1, 
class D1, 
class D2>
 
  746         return static_cast<DERIVED &
>(*this);
 
  751     template <
class T1, 
class D1, 
class D2>
 
  755         return static_cast<DERIVED &
>(*this);
 
  760     template <
class T1, 
class D1, 
class D2>
 
  763         Loop::mod(data_, r.
begin());
 
  764         return static_cast<DERIVED &
>(*this);
 
  771         Loop::addScalar(data_, r);
 
  772         return static_cast<DERIVED &
>(*this);
 
  779         Loop::subScalar(data_, r);
 
  780         return static_cast<DERIVED &
>(*this);
 
  787         Loop::mulScalar(data_, r);
 
  788         return static_cast<DERIVED &
>(*this);
 
  795         Loop::divScalar(data_, r);
 
  796         return static_cast<DERIVED &
>(*this);
 
  804          return sqrt(
static_cast<typename
 
  805               SquareRootTraits<SquaredNormType>::SquareRootArgument
>(
squaredMagnitude()));
 
  819         return Loop::minimum(data_);
 
  826         return Loop::maximum(data_);
 
  833         return Loop::all(data_, VALUETYPE());
 
  840         return Loop::any(data_, VALUETYPE());
 
  847         VIGRA_ASSERT_INSIDE(i);
 
  855         VIGRA_ASSERT_INSIDE(i);
 
  886     template <
int FROM, 
int TO>
 
  889 #ifdef VIGRA_CHECK_BOUNDS 
  890         vigra_precondition(FROM >= 0, 
"Index out of bounds");
 
  891         vigra_precondition(FROM < TO, 
"Index out of bounds");
 
  892         vigra_precondition(TO <=SIZE, 
"Index out of bounds");
 
  898     dropIndex(
int m)
 const 
  900 #ifdef VIGRA_CHECK_BOUNDS 
  901         vigra_precondition(0 <= m && m < SIZE, 
"Dimension out of bounds");
 
  903         TinyVector<VALUETYPE, SIZE-1> res(SkipInitialization);
 
  904         for(
int k=0; k<m; ++k)
 
  906         for(
int k=m; k<SIZE-1; ++k)
 
  915     pointer data() { 
return data_; }
 
  931         return data_[SIZE-1];
 
  936         return data_[SIZE-1];
 
  943         VIGRA_ASSERT_INSIDE(k);
 
  956         for(
int k=0; k<SIZE; ++k, start+=step)
 
  968 template <
int SIZE, 
int DESIRED_SIZE>
 
  969 struct TinyVector_constructor_has_wrong_number_of_arguments
 
  970 : staticAssert::AssertBool<SIZE == DESIRED_SIZE>
 
  975 enum ReverseCopyTag { ReverseCopy };
 
 1005 template <
class T, 
int SIZE>
 
 1007 : 
public TinyVectorBase<T, SIZE, T[SIZE], TinyVector<T, SIZE> >
 
 1009     typedef TinyVectorBase<T, SIZE, T[SIZE], TinyVector<T, SIZE> > BaseType;
 
 1010     typedef typename BaseType::Loop Loop;
 
 1054         BaseType::data_[0] = detail::RequiresExplicitCast<T>::cast(initial.
x);
 
 1055         BaseType::data_[1] = detail::RequiresExplicitCast<T>::cast(initial.
y);
 
 1064         VIGRA_STATIC_ASSERT((TinyVector_constructor_has_wrong_number_of_arguments<SIZE, 2>));
 
 1065         BaseType::data_[0] = i1;
 
 1066         BaseType::data_[1] = i2;
 
 1072     TinyVector(value_type 
const & i1, value_type 
const & i2, value_type 
const & i3)
 
 1075         VIGRA_STATIC_ASSERT((TinyVector_constructor_has_wrong_number_of_arguments<SIZE, 3>));
 
 1076         BaseType::data_[0] = i1;
 
 1077         BaseType::data_[1] = i2;
 
 1078         BaseType::data_[2] = i3;
 
 1085                value_type 
const & i3, value_type 
const & i4)
 
 1088         VIGRA_STATIC_ASSERT((TinyVector_constructor_has_wrong_number_of_arguments<SIZE, 4>));
 
 1089         BaseType::data_[0] = i1;
 
 1090         BaseType::data_[1] = i2;
 
 1091         BaseType::data_[2] = i3;
 
 1092         BaseType::data_[3] = i4;
 
 1099                value_type 
const & i3, value_type 
const & i4,
 
 1100                value_type 
const & i5)
 
 1103         VIGRA_STATIC_ASSERT((TinyVector_constructor_has_wrong_number_of_arguments<SIZE, 5>));
 
 1104         BaseType::data_[0] = i1;
 
 1105         BaseType::data_[1] = i2;
 
 1106         BaseType::data_[2] = i3;
 
 1107         BaseType::data_[3] = i4;
 
 1108         BaseType::data_[4] = i5;
 
 1116         Loop::assignScalar(BaseType::data_, value_type());
 
 1134         Loop::assign(BaseType::data_, r.data_);
 
 1143         Loop::assign(BaseType::data_, data);
 
 1157         Loop::reverseAssign(BaseType::data_, data+SIZE-1);
 
 1162     template <
class U, 
class DATA, 
class DERIVED>
 
 1166         Loop::assignCast(BaseType::data_, r.
begin());
 
 1173         Loop::assign(BaseType::data_, r.data_);
 
 1179     template <
class U, 
class DATA, 
class DERIVED>
 
 1182         Loop::assignCast(BaseType::data_, r.
begin());
 
 1192         BaseType::data_[0] = detail::RequiresExplicitCast<T>::cast(r.
x);
 
 1193         BaseType::data_[1] = detail::RequiresExplicitCast<T>::cast(r.
y);
 
 1209     template <
class U, 
int USIZE, 
class DATA, 
class DERIVED>
 
 1212         static const int minSize = USIZE < SIZE
 
 1216         typedef typename detail::LoopType<minSize>::type MinLoop;
 
 1217         MinLoop::assignCast(BaseType::data_, r.
begin());
 
 1251 template <
class T, 
int SIZE>
 
 1252 class TinyVectorView
 
 1253 : 
public TinyVectorBase<T, SIZE, T *, TinyVectorView<T, SIZE> >
 
 1255     typedef TinyVectorBase<T, SIZE, T *, TinyVectorView<T, SIZE> > BaseType;
 
 1256     typedef typename BaseType::Loop Loop;
 
 1279         BaseType::data_ = 0;
 
 1287         BaseType::data_ = 
const_cast<pointer
>(data);
 
 1295         BaseType::data_ = 
const_cast<pointer
>(other.data_);
 
 1300     template <
class DATA, 
class DERIVED>
 
 1304         BaseType::data_ = 
const_cast<pointer
>(other.data());
 
 1311         Loop::assign(BaseType::data_, r.begin());
 
 1317     template <
class U, 
class DATA, 
class DERIVED>
 
 1320         Loop::assignCast(BaseType::data_, r.
begin());
 
 1343 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1352 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1357     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1358     return ltype::notEqual(l.
begin(), r.
begin());
 
 1362 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1364 operator<(TinyVectorBase<V1, SIZE, D1, D2> 
const & l,
 
 1367     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1368     return ltype::lexicographicLessThan(l.begin(), r.begin());
 
 1373 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1378     for(
int k=0; k < SIZE; ++k)
 
 1385 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1390     for(
int k=0; k < SIZE; ++k)
 
 1397 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1402     for(
int k=0; k < SIZE; ++k)
 
 1409 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1414     for(
int k=0; k < SIZE; ++k)
 
 1420 template <
class V, 
int SIZE, 
class D1, 
class D2, 
class D3, 
class D4>
 
 1423                  TinyVectorBase<V, SIZE, D3, D4> 
const & r,
 
 1424                  V epsilon = NumericTraits<V>::epsilon())
 
 1426     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1427     return ltype::closeAtTolerance(l.begin(), r.begin(), epsilon);
 
 1430 template <
class V, 
int SIZE>
 
 1433                  TinyVector<V, SIZE> 
const & r,
 
 1434                  V epsilon = NumericTraits<V>::epsilon())
 
 1436     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1437     return ltype::closeAtTolerance(l.begin(), r.begin(), epsilon);
 
 1447 template <
class V1, 
int SIZE, 
class DATA, 
class DERIVED>
 
 1449 operator<<(std::ostream & out, TinyVectorBase<V1, SIZE, DATA, DERIVED> 
const & l)
 
 1453     for(i=0; i<SIZE-1; ++i)
 
 1454         out << l[i] << 
", ";
 
 1512 #if !defined(NO_PARTIAL_TEMPLATE_SPECIALIZATION) 
 1514 template <
class T, 
int SIZE>
 
 1515 struct NumericTraits<TinyVector<T, SIZE> >
 
 1517     typedef TinyVector<T, SIZE> Type;
 
 1518     typedef TinyVector<typename NumericTraits<T>::Promote, SIZE> Promote;
 
 1519     typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> RealPromote;
 
 1520     typedef TinyVector<typename NumericTraits<T>::ComplexPromote, SIZE> ComplexPromote;
 
 1521     typedef T ValueType;
 
 1523     typedef typename NumericTraits<T>::isIntegral isIntegral;
 
 1524     typedef VigraFalseType isScalar;
 
 1525     typedef typename NumericTraits<T>::isSigned isSigned;
 
 1526     typedef VigraTrueType isOrdered;
 
 1527     typedef VigraFalseType isComplex;
 
 1529     static TinyVector<T, SIZE> zero()
 
 1531         return TinyVector<T, SIZE>(NumericTraits<T>::zero());
 
 1533     static TinyVector<T, SIZE> one()
 
 1535         return TinyVector<T, SIZE>(NumericTraits<T>::one());
 
 1537     static TinyVector<T, SIZE> nonZero()
 
 1539         return TinyVector<T, SIZE>(NumericTraits<T>::nonZero());
 
 1542     static TinyVector<T, SIZE> min()
 
 1546     static TinyVector<T, SIZE> max()
 
 1551     template <
class D1, 
class D2>
 
 1552     static Promote toPromote(TinyVectorBase<T, SIZE, D1, D2> 
const & v)
 
 1557     template <
class D1, 
class D2>
 
 1558     static RealPromote toRealPromote(TinyVectorBase<T, SIZE, D1, D2> 
const & v)
 
 1560         return RealPromote(v);
 
 1563     template <
class D1, 
class D2>
 
 1564     static TinyVector<T, SIZE>
 
 1565     fromPromote(TinyVectorBase<
typename NumericTraits<T>::Promote, SIZE, D1, D2> 
const & v)
 
 1567         TinyVector<T, SIZE> res(detail::dontInit());
 
 1568         typedef typename detail::LoopType<SIZE>::type ltype;
 
 1569         ltype::fromPromote(res.begin(), v.begin());
 
 1573     template <
class D1, 
class D2>
 
 1574     static TinyVector<T, SIZE>
 
 1575     fromRealPromote(TinyVectorBase<
typename NumericTraits<T>::RealPromote, SIZE, D1, D2> 
const & v)
 
 1577         TinyVector<T, SIZE> res(detail::dontInit());
 
 1578         typedef typename detail::LoopType<SIZE>::type ltype;
 
 1579         ltype::fromRealPromote(res.begin(), v.begin());
 
 1584 template <
class T, 
int SIZE>
 
 1585 struct NumericTraits<TinyVectorView<T, SIZE> >
 
 1586 : 
public NumericTraits<TinyVector<T, SIZE> >
 
 1588     typedef TinyVector<T, SIZE> Type;
 
 1589     typedef TinyVector<typename NumericTraits<T>::Promote, SIZE> Promote;
 
 1590     typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> RealPromote;
 
 1591     typedef TinyVector<typename NumericTraits<T>::ComplexPromote, SIZE> ComplexPromote;
 
 1592     typedef T ValueType;
 
 1594     typedef typename NumericTraits<T>::isIntegral isIntegral;
 
 1595     typedef VigraFalseType isScalar;
 
 1596     typedef typename NumericTraits<T>::isSigned isSigned;
 
 1597     typedef VigraFalseType isOrdered;
 
 1598     typedef VigraFalseType isComplex;
 
 1601 template <
class T, 
int SIZE>
 
 1602 struct NormTraits<TinyVector<T, SIZE> >
 
 1604     typedef TinyVector<T, SIZE> Type;
 
 1605     typedef typename Type::SquaredNormType    SquaredNormType;
 
 1606     typedef typename Type::NormType           NormType;
 
 1609 template <
class T, 
int SIZE>
 
 1610 struct NormTraits<TinyVectorView<T, SIZE> >
 
 1612     typedef TinyVector<T, SIZE> Type;
 
 1613     typedef typename Type::SquaredNormType    SquaredNormType;
 
 1614     typedef typename Type::NormType           NormType;
 
 1617 template <
class T1, 
class T2, 
int SIZE>
 
 1618 struct PromoteTraits<TinyVector<T1, SIZE>, TinyVector<T2, SIZE> >
 
 1620     typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
 
 1623 template <
class T1, 
class T2, 
int SIZE>
 
 1624 struct PromoteTraits<TinyVectorView<T1, SIZE>, TinyVectorView<T2, SIZE> >
 
 1626     typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
 
 1629 template <
class T1, 
class T2, 
int SIZE>
 
 1630 struct PromoteTraits<TinyVectorView<T1, SIZE>, TinyVector<T2, SIZE> >
 
 1632     typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
 
 1635 template <
class T1, 
class T2, 
int SIZE>
 
 1636 struct PromoteTraits<TinyVector<T1, SIZE>, TinyVectorView<T2, SIZE> >
 
 1638     typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
 
 1641 template <
class T, 
int SIZE>
 
 1642 struct PromoteTraits<TinyVector<T, SIZE>, double >
 
 1644     typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
 
 1647 template <
class T, 
int SIZE>
 
 1648 struct PromoteTraits<double, TinyVector<T, SIZE> >
 
 1650     typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
 
 1653 template <
class T, 
int SIZE>
 
 1654 struct PromoteTraits<TinyVectorView<T, SIZE>, double >
 
 1656     typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
 
 1659 template <
class T, 
int SIZE>
 
 1660 struct PromoteTraits<double, TinyVectorView<T, SIZE> >
 
 1662     typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
 
 1665 template<
class T, 
int SIZE>
 
 1666 struct CanSkipInitialization<TinyVectorView<T, SIZE> >
 
 1668     typedef typename CanSkipInitialization<T>::type type;
 
 1669     static const bool value = type::asBool;
 
 1672 template<
class T, 
int SIZE>
 
 1673 struct CanSkipInitialization<TinyVector<T, SIZE> >
 
 1675     typedef typename CanSkipInitialization<T>::type type;
 
 1676     static const bool value = type::asBool;
 
 1681 #else // NO_PARTIAL_TEMPLATE_SPECIALIZATION 
 1684 #define TINYVECTOR_NUMTRAITS(T, SIZE) \ 
 1686 struct NumericTraits<TinyVector<T, SIZE> >\ 
 1688     typedef TinyVector<T, SIZE> Type;\ 
 1689     typedef TinyVector<NumericTraits<T>::Promote, SIZE> Promote;\ 
 1690     typedef TinyVector<NumericTraits<T>::RealPromote, SIZE> RealPromote;\ 
 1691     typedef TinyVector<NumericTraits<T>::ComplexPromote, SIZE> ComplexPromote;\ 
 1692     typedef T ValueType; \ 
 1693     typedef NumericTraits<T>::isIntegral isIntegral;\ 
 1694     typedef VigraFalseType isScalar;\ 
 1695     typedef NumericTraits<T>::isSigned isSigned; \ 
 1696     typedef VigraFalseType isOrdered;\ 
 1697     typedef VigraFalseType isComplex;\ 
 1699     static TinyVector<T, SIZE> zero() { \ 
 1700         return TinyVector<T, SIZE>(NumericTraits<T>::zero()); \ 
 1702     static TinyVector<T, SIZE> one() { \ 
 1703         return TinyVector<T, SIZE>(NumericTraits<T>::one()); \ 
 1705     static TinyVector<T, SIZE> nonZero() { \ 
 1706         return TinyVector<T, SIZE>(NumericTraits<T>::nonZero()); \ 
 1709     static Promote toPromote(TinyVector<T, SIZE> const & v) { \ 
 1710         return Promote(v); \ 
 1712     static RealPromote toRealPromote(TinyVector<T, SIZE> const & v) { \ 
 1713         return RealPromote(v); \ 
 1715     static TinyVector<T, SIZE> fromPromote(Promote const & v) { \ 
 1716         TinyVector<T, SIZE> res;\ 
 1717         TinyVector<T, SIZE>::iterator d = res.begin(), dend = res.end();\ 
 1718         Promote::const_iterator s = v.begin();\ 
 1719         for(; d != dend; ++d, ++s)\ 
 1720             *d = NumericTraits<T>::fromPromote(*s);\ 
 1723     static TinyVector<T, SIZE> fromRealPromote(RealPromote const & v) {\ 
 1724         TinyVector<T, SIZE> res;\ 
 1725         TinyVector<T, SIZE>::iterator d = res.begin(), dend = res.end();\ 
 1726         RealPromote::const_iterator s = v.begin();\ 
 1727         for(; d != dend; ++d, ++s)\ 
 1728             *d = NumericTraits<T>::fromRealPromote(*s);\ 
 1733 struct NormTraits<TinyVector<T, SIZE> >\ 
 1735     typedef TinyVector<T, SIZE> Type;\ 
 1736     typedef Type::SquaredNormType           SquaredNormType; \ 
 1737     typedef Type::NormType NormType; \ 
 1740 #define TINYVECTOR_PROMTRAITS1(type1, SIZE) \ 
 1742 struct PromoteTraits<TinyVector<type1, SIZE>, TinyVector<type1, SIZE> > \ 
 1744     typedef TinyVector<PromoteTraits<type1, type1>::Promote, SIZE> Promote; \ 
 1745     static Promote toPromote(TinyVector<type1, SIZE> const & v) { \ 
 1746         return static_cast<Promote>(v); } \ 
 1749 #define TINYVECTOR_PROMTRAITS2(type1, type2, SIZE) \ 
 1751 struct PromoteTraits<TinyVector<type1, SIZE>, TinyVector<type2, SIZE> > \ 
 1753     typedef TinyVector<PromoteTraits<type1, type2>::Promote, SIZE> Promote; \ 
 1754     static Promote toPromote(TinyVector<type1, SIZE> const & v) { \ 
 1755         return static_cast<Promote>(v); } \ 
 1756     static Promote toPromote(TinyVector<type2, SIZE> const & v) { \ 
 1757        return static_cast<Promote>(v); } \ 
 1760 #define TINYVECTOR_TRAITS(SIZE) \ 
 1761 TINYVECTOR_NUMTRAITS(unsigned char, SIZE)\ 
 1762 TINYVECTOR_NUMTRAITS(int, SIZE)\ 
 1763 TINYVECTOR_NUMTRAITS(float, SIZE)\ 
 1764 TINYVECTOR_NUMTRAITS(double, SIZE)\ 
 1765 TINYVECTOR_PROMTRAITS1(unsigned char, SIZE)\ 
 1766 TINYVECTOR_PROMTRAITS1(int, SIZE)\ 
 1767 TINYVECTOR_PROMTRAITS1(float, SIZE)\ 
 1768 TINYVECTOR_PROMTRAITS1(double, SIZE)\ 
 1769 TINYVECTOR_PROMTRAITS2(float, unsigned char, SIZE)\ 
 1770 TINYVECTOR_PROMTRAITS2(unsigned char, float, SIZE)\ 
 1771 TINYVECTOR_PROMTRAITS2(int, unsigned char, SIZE)\ 
 1772 TINYVECTOR_PROMTRAITS2(unsigned char, int, SIZE)\ 
 1773 TINYVECTOR_PROMTRAITS2(int, float, SIZE)\ 
 1774 TINYVECTOR_PROMTRAITS2(float, int, SIZE)\ 
 1775 TINYVECTOR_PROMTRAITS2(double, unsigned char, SIZE)\ 
 1776 TINYVECTOR_PROMTRAITS2(unsigned char, double, SIZE)\ 
 1777 TINYVECTOR_PROMTRAITS2(int, double, SIZE)\ 
 1778 TINYVECTOR_PROMTRAITS2(double, int, SIZE)\ 
 1779 TINYVECTOR_PROMTRAITS2(double, float, SIZE)\ 
 1780 TINYVECTOR_PROMTRAITS2(float, double, SIZE) 
 1782 TINYVECTOR_TRAITS(2)
 
 1783 TINYVECTOR_TRAITS(3)
 
 1784 TINYVECTOR_TRAITS(4)
 
 1786 #undef TINYVECTOR_NUMTRAITS 
 1787 #undef TINYVECTOR_PROMTRAITS1 
 1788 #undef TINYVECTOR_PROMTRAITS2 
 1789 #undef TINYVECTOR_TRAITS 
 1791 #endif // NO_PARTIAL_TEMPLATE_SPECIALIZATION 
 1805 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1807 typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
 
 1815 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1817 typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
 
 1825 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1827 typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
 
 1835 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1837 typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
 
 1845 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 1847 typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
 
 1855 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1857 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1860     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(r) += v;
 
 1864 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1866 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1869     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(l) += v;
 
 1873 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1875 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1878     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(v) -= r;
 
 1882 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1884 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1887     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(l) -= v;
 
 1891 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1893 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1896     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(r) *= v;
 
 1900 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1902 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1905     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(l) *= v;
 
 1909 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1911 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1914     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(v) /= r;
 
 1918 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1920 typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
 
 1923     return typename NumericTraits<TinyVector<V, SIZE> >::RealPromote(l) /= v;
 
 1927 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1933     typedef typename detail::LoopType<SIZE>::type Loop;
 
 1934     Loop::divScalar(result.data(), v);
 
 1941 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1947     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1948     ltype::neg(res.begin(), v.
begin());
 
 1953 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1959     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1966 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1972     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1979 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1985     typedef typename detail::LoopType<SIZE>::type ltype;
 
 1992 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 1998     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2005 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2007 TinyVector<std::ptrdiff_t, SIZE>
 
 2011     for(
int k=0; k<SIZE; ++k)
 
 2018 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2024     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2033 template <
class V, 
int SIZE, 
class D1, 
class D2, 
class E>
 
 2039     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2045 template <
class V1, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 2047 TinyVector<typename PromoteTraits<V1, V2>::Promote, 3>
 
 2053     return  Res(r1[1]*r2[2] - r1[2]*r2[1],
 
 2054                 r1[2]*r2[0] - r1[0]*r2[2],
 
 2055                 r1[0]*r2[1] - r1[1]*r2[0]);
 
 2059 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 2061 typename PromoteTraits<V1, V2>::Promote
 
 2065     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2070 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2072 typename NumericTraits<V>::Promote
 
 2075     typename NumericTraits<V>::Promote res = l[0];
 
 2076     for(
int k=1; k<SIZE; ++k)
 
 2082 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2084 TinyVector<typename NumericTraits<V>::Promote, SIZE>
 
 2088     for(
int k=1; k<SIZE; ++k)
 
 2094 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2096 typename NumericTraits<V>::Promote
 
 2099     typename NumericTraits<V>::Promote res = l[0];
 
 2100     for(
int k=1; k<SIZE; ++k)
 
 2106 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2108 TinyVector<typename NumericTraits<V>::Promote, SIZE>
 
 2112     for(
int k=1; k<SIZE; ++k)
 
 2120 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 2122 TinyVector<typename PromoteTraits<V1, V2>::Promote, SIZE>
 
 2126     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2133 template <
class V1, 
int SIZE, 
class D1, 
class D2>
 
 2135 TinyVector<V1, SIZE>
 
 2136 min(TinyVectorBase<V1, SIZE, D1, D2> 
const & l,
 
 2137     TinyVectorBase<V1, SIZE, D1, D2> 
const & r)
 
 2139     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2140     TinyVector<V1, SIZE> res(l);
 
 2145 template <
class V1, 
int SIZE>
 
 2147 TinyVector<V1, SIZE>
 
 2148 min(TinyVector<V1, SIZE> 
const & l,
 
 2149     TinyVector<V1, SIZE> 
const & r)
 
 2151     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2152     TinyVector<V1, SIZE> res(l);
 
 2158 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2169 template <
class V1, 
int SIZE, 
class D1, 
class D2, 
class V2, 
class D3, 
class D4>
 
 2171 TinyVector<typename PromoteTraits<V1, V2>::Promote, SIZE>
 
 2175     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2182 template <
class V1, 
int SIZE, 
class D1, 
class D2>
 
 2184 TinyVector<V1, SIZE>
 
 2185 max(TinyVectorBase<V1, SIZE, D1, D2> 
const & l,
 
 2186     TinyVectorBase<V1, SIZE, D1, D2> 
const & r)
 
 2188     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2189     TinyVector<V1, SIZE> res(l);
 
 2194 template <
class V1, 
int SIZE>
 
 2196 TinyVector<V1, SIZE>
 
 2197 max(TinyVector<V1, SIZE> 
const & l,
 
 2198     TinyVector<V1, SIZE> 
const & r)
 
 2200     typedef typename detail::LoopType<SIZE>::type ltype;
 
 2201     TinyVector<V1, SIZE> res(l);
 
 2207 template <
class V, 
int SIZE, 
class D1, 
class D2>
 
 2216 template <
class V1, 
int SIZE, 
class D1, 
class D2>
 
 2218 typename TinyVectorBase<V1, SIZE, D1, D2>::SquaredNormType
 
 2225 template <
class V, 
int SIZE>
 
 2227 typename TinyVector<V, SIZE>::SquaredNormType
 
 2230     return t.squaredMagnitude();
 
 2236 template <
class V, 
int SIZE>
 
 2248 template <
class V, 
int SIZE, 
class T>
 
 2254     for(
int k=0; k<SIZE; ++k)
 
 2256         VIGRA_ASSERT_INSIDE(permutation[k]);
 
 2257         res[k] = t[permutation[k]];
 
 2266 template<
class V,
int SIZE>
 
 2276 template<
class V,
int SIZE>
 
 2280     for(
int k=0; k<SIZE; ++k){
 
 2281         res[k]=t[k]< val ? val :  t[k];
 
 2290 template<
class V,
int SIZE>
 
 2294     for(
int k=0; k<SIZE; ++k){
 
 2295         res[k]=t[k]> val ? val :  t[k];
 
 2305 template<
class V,
int SIZE>
 
 2309     for(
int k=0; k<SIZE; ++k){
 
 2310         res[k] =  (t[k] < valLower)
 
 2324 template<
class V,
int SIZE>
 
 2331     for(
int k=0; k<SIZE; ++k){
 
 2332         res[k] =  (t[k] < valLower[k])
 
 2334                        : (t[k] > valUpper[k])
 
 2348     for( 
size_t k = 0; k < SIZE; k++) 
 
 2360     for( 
size_t k = 0; k < SIZE; k++) 
 
 2365 template<
class V,
int SIZE>
 
 2367 bool isZero(TinyVector<V, SIZE> 
const & t){
 
 2368     for(
int k=0; k<SIZE; ++k){
 
 2369         if(t[k]!=static_cast<V>(0))
 
 2375 template<
class V,
int SIZE>
 
 2376 inline typename NumericTraits<V>::RealPromote
 
 2377 mean(TinyVector<V, SIZE> 
const & t){
 
 2378     const V sumVal = 
sum(t);
 
 2379     return static_cast< typename NumericTraits<V>::RealPromote
>(sumVal)/SIZE;
 
 2383 template<
class V,
int SIZE>
 
 2384 inline typename NumericTraits<V>::RealPromote
 
 2385 sizeDividedSquaredNorm(TinyVector<V, SIZE> 
const & t){
 
 2389 template<
class V,
int SIZE>
 
 2390 inline typename NumericTraits<V>::RealPromote
 
 2391 sizeDividedNorm(TinyVector<V, SIZE> 
const & t){
 
 2392     return norm(t)/SIZE;
 
 2400 #if defined(_MSC_VER) 
 2401 #pragma warning( pop ) 
 2405 #undef VIGRA_ASSERT_INSIDE 
 2406 #endif // VIGRA_TINYVECTOR_HXX 
static TinyVector< VALUETYPE, SIZE > linearSequence(VALUETYPE start=VALUETYPE(), VALUETYPE step=VALUETYPE(1))
Factory function for a linear sequence. 
Definition: tinyvector.hxx:953
NormType magnitude() const 
Definition: tinyvector.hxx:802
const_reference operator[](difference_type i) const 
Definition: tinyvector.hxx:853
DERIVED & operator/=(double r)
Definition: tinyvector.hxx:793
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
PromoteTraits< RGBValue< V1, R, G, B >, RGBValue< V2, R, G, B > >::Promote cross(RGBValue< V1, R, G, B > const &r1, RGBValue< V2, R, G, B > const &r2)
cross product 
Definition: rgbvalue.hxx:889
TinyVectorView & operator=(TinyVectorView const &r)
Definition: tinyvector.hxx:1309
bool all() const 
Definition: tinyvector.hxx:831
TinyVector(value_type const &initial)
Definition: tinyvector.hxx:1031
int y
Definition: diff2d.hxx:392
Int32 roundi(FixedPoint16< IntBits, OverflowHandling > v)
rounding to the nearest integer. 
Definition: fixedpoint.hxx:1775
VALUETYPE * pointer
Definition: tinyvector.hxx:667
Diff2D operator-(Diff2D const &a, Diff2D const &b)
Definition: diff2d.hxx:711
value_type const * const_iterator
Definition: tinyvector.hxx:679
double scalar_multiplier
Definition: tinyvector.hxx:691
DERIVED & operator-=(double r)
Definition: tinyvector.hxx:777
VALUETYPE const * const_pointer
Definition: tinyvector.hxx:671
TinyVector(TinyVector const &r)
Definition: tinyvector.hxx:1131
TinyVector< V, SIZE > round(TinyVectorBase< V, SIZE, D1, D2 > const &v)
Definition: tinyvector.hxx:1995
DERIVED & operator+=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition: tinyvector.hxx:725
TinyVector(TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
Definition: tinyvector.hxx:1163
void sub(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r, FixedPoint< IntBits3, FracBits3 > &result)
subtraction with enforced result type. 
Definition: fixedpoint.hxx:583
TinyVector< V, SIZE > div(TinyVectorBase< V, SIZE, D1, D2 > const &l, V v)
component-wise scalar division without type promotion 
Definition: tinyvector.hxx:1930
TinyVector< V, SIZE > clipUpper(TinyVector< V, SIZE > const &t, const V val)
Clip values above a threshold. 
Definition: tinyvector.hxx:2292
TinyVector(value_type const &i1, value_type const &i2, value_type const &i3, value_type const &i4, value_type const &i5)
Definition: tinyvector.hxx:1098
DERIVED & operator+=(double r)
Definition: tinyvector.hxx:769
int x
Definition: diff2d.hxx:385
FFTWComplex< R >::SquaredNormType squaredNorm(const FFTWComplex< R > &a)
squared norm (= squared magnitude) 
Definition: fftw3.hxx:1044
V power(const V &x)
Exponentiation to a positive integer power by squaring. 
Definition: mathutil.hxx:427
const_iterator begin() const 
Definition: tinyvector.hxx:868
const_iterator end() const 
Definition: tinyvector.hxx:872
int round(FixedPoint< IntBits, FracBits > v)
rounding to the nearest integer. 
Definition: fixedpoint.hxx:683
iterator end()
Definition: tinyvector.hxx:864
Diff2D operator+(Diff2D const &a, Diff2D const &b)
Definition: diff2d.hxx:739
Two dimensional difference vector. 
Definition: diff2d.hxx:185
void add(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r, FixedPoint< IntBits3, FracBits3 > &result)
addition with enforced result type. 
Definition: fixedpoint.hxx:561
const_iterator cbegin() const 
Definition: tinyvector.hxx:876
TinyVector< V, SIZE > ceil(TinyVectorBase< V, SIZE, D1, D2 > const &v)
Definition: tinyvector.hxx:1969
SquaredNormType squaredMagnitude() const 
Definition: tinyvector.hxx:810
bool allLess(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise less-than 
Definition: tinyvector.hxx:1375
TinyVector(Diff2D const &initial)
Definition: tinyvector.hxx:1051
TinyVector(const_pointer data, ReverseCopyTag)
Definition: tinyvector.hxx:1154
DERIVED & operator/=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition: tinyvector.hxx:752
TinyVector< V, SIZE > sqrt(TinyVectorBase< V, SIZE, D1, D2 > const &v)
Definition: tinyvector.hxx:2021
TinyVector & copy(TinyVectorBase< U, USIZE, DATA, DERIVED > const &r)
Definition: tinyvector.hxx:1210
value_type * iterator
Definition: tinyvector.hxx:675
DERIVED & operator*=(double r)
Definition: tinyvector.hxx:785
DERIVED & operator-=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition: tinyvector.hxx:734
FFTWComplex< R >::NormType norm(const FFTWComplex< R > &a)
norm (= magnitude) 
Definition: fftw3.hxx:1037
TinyVector & operator=(TinyVector const &r)
Definition: tinyvector.hxx:1171
TinyVector()
Definition: tinyvector.hxx:1113
VALUETYPE value_type
Definition: tinyvector.hxx:655
TinyVector< V, SIZE > clip(TinyVector< V, SIZE > const &t, const V valLower, const V valUpper)
Clip values to an interval. 
Definition: tinyvector.hxx:2307
void mul(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r, FixedPoint< IntBits3, FracBits3 > &result)
multiplication with enforced result type. 
Definition: fixedpoint.hxx:605
NumericTraits< V >::Promote prod(TinyVectorBase< V, SIZE, D1, D2 > const &l)
product of the vector's elements 
Definition: tinyvector.hxx:2097
TinyVectorView(TinyVectorBase< T, SIZE, DATA, DERIVED > const &other)
Definition: tinyvector.hxx:1301
NumericTraits< V >::Promote sum(TinyVectorBase< V, SIZE, D1, D2 > const &l)
sum of the vector's elements 
Definition: tinyvector.hxx:2073
TinyVector(value_type const &i1, value_type const &i2, value_type const &i3, value_type const &i4)
Definition: tinyvector.hxx:1084
TinyVectorView()
Definition: tinyvector.hxx:1276
bool operator!=(FFTWComplex< R > const &a, const FFTWComplex< R > &b)
not equal 
Definition: fftw3.hxx:841
void init(value_type initial)
Definition: tinyvector.hxx:717
VALUETYPE & reference
Definition: tinyvector.hxx:659
iterator begin()
Definition: tinyvector.hxx:861
bool operator==(FFTWComplex< R > const &a, const FFTWComplex< R > &b)
equal 
Definition: fftw3.hxx:825
size_type size() const 
Definition: tinyvector.hxx:913
TinyVector< V, SIZE > pow(TinyVectorBase< V, SIZE, D1, D2 > const &v, E exponent)
Definition: tinyvector.hxx:2036
VALUETYPE const & const_reference
Definition: tinyvector.hxx:663
TinyVector & operator=(value_type const &v)
Definition: tinyvector.hxx:1199
TinyVector< V, SIZE >::SquaredNormType squaredNorm(TinyVector< V, SIZE > const &t)
squared norm 
Definition: tinyvector.hxx:2228
static TinyVector< VALUETYPE, SIZE > unitVector(int k)
Factory function for a unit vector for dimension k. 
Definition: tinyvector.hxx:941
TinyVector(value_type const &i1, value_type const &i2, value_type const &i3)
Definition: tinyvector.hxx:1072
TinyVector(SkipInitializationTag)
Definition: tinyvector.hxx:1121
TinyVectorView & operator=(TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
Definition: tinyvector.hxx:1318
V const & max(TinyVectorBase< V, SIZE, D1, D2 > const &l)
maximum element 
Definition: tinyvector.hxx:2210
TinyVector< typename NumericTraits< V >::Promote, SIZE > cumsum(TinyVectorBase< V, SIZE, D1, D2 > const &l)
cumulative sum of the vector's elements 
Definition: tinyvector.hxx:2085
Wrapper for fixed size vectors. 
Definition: tinyvector.hxx:621
bool allGreaterEqual(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise greater-equal 
Definition: tinyvector.hxx:1411
Class for fixed size vectors.This class contains an array of size SIZE of the specified VALUETYPE...
Definition: accessor.hxx:940
bool closeAtTolerance(T1 l, T2 r, typename PromoteTraits< T1, T2 >::Promote epsilon)
Tolerance based floating-point equality. 
Definition: mathutil.hxx:1638
FixedPoint16< IntBits3, OverflowHandling > & div(FixedPoint16< IntBits1, OverflowHandling > l, FixedPoint16< IntBits2, OverflowHandling > r, FixedPoint16< IntBits3, OverflowHandling > &result)
division with enforced result type. 
Definition: fixedpoint.hxx:1616
unsigned int size_type
Definition: tinyvector.hxx:683
TinyVectorView< VALUETYPE, TO-FROM > subarray() const 
Definition: tinyvector.hxx:887
TinyVectorView(TinyVectorView const &other)
Definition: tinyvector.hxx:1292
Base class for fixed size vectors. 
Definition: tinyvector.hxx:82
FFTWComplex< R >::NormType abs(const FFTWComplex< R > &a)
absolute value (= magnitude) 
Definition: fftw3.hxx:1002
TinyVector< V, SIZE > floor(TinyVectorBase< V, SIZE, D1, D2 > const &v)
Definition: tinyvector.hxx:1982
TinyVector(U const *data)
Definition: tinyvector.hxx:1140
SquareRootTraits< SquaredNormType >::SquareRootResult NormType
Definition: tinyvector.hxx:699
VALUETYPE const & maximum() const 
Definition: tinyvector.hxx:824
std::ptrdiff_t difference_type
Definition: tinyvector.hxx:687
TinyVector< V, SIZE > clipLower(TinyVector< V, SIZE > const &t)
Clip negative values. 
Definition: tinyvector.hxx:2268
UInt32 floorPower2(UInt32 x)
Round down to the nearest power of 2. 
Definition: mathutil.hxx:317
bool any() const 
Definition: tinyvector.hxx:838
TinyVector(value_type const &i1, value_type const &i2)
Definition: tinyvector.hxx:1061
bool allLessEqual(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise less-equal 
Definition: tinyvector.hxx:1399
UInt32 ceilPower2(UInt32 x)
Round up to the nearest power of 2. 
Definition: mathutil.hxx:294
bool allGreater(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise greater-than 
Definition: tinyvector.hxx:1387
int ceil(FixedPoint< IntBits, FracBits > v)
rounding up. 
Definition: fixedpoint.hxx:675
const_iterator cend() const 
Definition: tinyvector.hxx:880
TinyVector< V, SIZE > reverse(TinyVector< V, SIZE > const &t)
reversed copy 
Definition: tinyvector.hxx:2239
TinyVectorView(const_pointer data)
Definition: tinyvector.hxx:1284
TinyVector & operator=(TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
Definition: tinyvector.hxx:1180
int floor(FixedPoint< IntBits, FracBits > v)
rounding down. 
Definition: fixedpoint.hxx:667
TinyVector< typename NumericTraits< V >::Promote, SIZE > cumprod(TinyVectorBase< V, SIZE, D1, D2 > const &l)
cumulative product of the vector's elements 
Definition: tinyvector.hxx:2109
VALUETYPE const & minimum() const 
Definition: tinyvector.hxx:817
DERIVED & operator%=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition: tinyvector.hxx:761
void init(Iterator i, Iterator end)
Definition: tinyvector.hxx:708
TinyVector< V, SIZE > abs(TinyVectorBase< V, SIZE, D1, D2 > const &v)
component-wise absolute value 
Definition: tinyvector.hxx:1956
NormTraits< VALUETYPE >::SquaredNormType SquaredNormType
Definition: tinyvector.hxx:695
DERIVED & operator*=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition: tinyvector.hxx:743
TinyVector & operator=(Diff2D const &r)
Definition: tinyvector.hxx:1190
reference operator[](difference_type i)
Definition: tinyvector.hxx:845
SquareRootTraits< FixedPoint< IntBits, FracBits > >::SquareRootResult sqrt(FixedPoint< IntBits, FracBits > v)
square root. 
Definition: fixedpoint.hxx:616
PromoteTraits< TinyVector< V1, SIZE >, TinyVector< V2, SIZE > >::Promote operator%(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
component-wise modulo 
Definition: tinyvector.hxx:1848
TinyVector(lemon::Invalid const &)
Definition: tinyvector.hxx:1041
V const & min(TinyVectorBase< V, SIZE, D1, D2 > const &l)
minimum element 
Definition: tinyvector.hxx:2161
PromoteTraits< V1, V2 >::Promote dot(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
dot product 
Definition: tinyvector.hxx:2062