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 )
76using VIGRA_CSTD::ceil;
77using VIGRA_CSTD::floor;
78using VIGRA_CSTD::sqrt;
81template <
class V1,
int SIZE,
class D1,
class D2>
84template <
class V1,
int SIZE,
class D1,
class D2>
87squaredNorm(TinyVectorBase<V1, SIZE, D1, D2>
const & t);
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)
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])
223 static bool closeAtTolerance(T
const * left, T
const * right, T epsilon)
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)
265struct UnrollScalarResult
268 static typename NumericTraits<T>::Promote
271 return *d * *d + UnrollScalarResult<LEVEL-1>::dot(d+1);
274 template <
class T1,
class T2>
275 static typename PromoteTraits<T1, T2>::Promote
276 dot(T1
const * left, T2
const * right)
278 return *left * *right + UnrollScalarResult<LEVEL-1>::dot(left+1, right+1);
282 static typename NormTraits<T>::SquaredNormType
288 static std::ptrdiff_t
291 return (*d)*(*d) + UnrollScalarResult<LEVEL-1>::squaredNorm(d+1);
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);
326struct 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));
438 UnrollLoop<LEVEL-1>::power(left+1, 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)
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);
504 static bool closeAtTolerance(T
const * left, T
const * right, T epsilon)
507 UnrollLoop<LEVEL - 1>::closeAtTolerance(left+1, right+1, epsilon);
511 static typename NumericTraits<T>::Promote
514 return UnrollScalarResult<LEVEL>::dot(d);
517 template <
class T1,
class T2>
518 static typename PromoteTraits<T1, T2>::Promote
519 dot(T1
const * left, T2
const * right)
521 return UnrollScalarResult<LEVEL>::dot(left, right);
525 static typename NormTraits<T>::SquaredNormType
528 return UnrollScalarResult<LEVEL>::squaredNorm(d);
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) {}
592 static T minimum(T
const *) {
return NumericTraits<T>::max(); }
594 static T maximum(T
const *) {
return NumericTraits<T>::min(); }
596 static bool all(T
const *, T
const &) {
return true; }
598 static bool any(T
const *, T
const &) {
return false; }
600 static bool closeAtTolerance(T
const *, T
const *, T) {
return true; }
606 static const int MaxUnrollSize = 5;
607 typedef typename IfBool<(SIZE <= MaxUnrollSize), UnrollLoop<SIZE>, ExecLoop<SIZE> >::type type;
613inline DontInit dontInit() {
return DontInit(); }
617template <
class T,
int SIZE>
620template <
class T,
int SIZE>
638template <
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>
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>
727 Loop::add(data_, r.
begin());
728 return static_cast<DERIVED &
>(*this);
733 template <
class T1,
class D1,
class D2>
736 Loop::sub(data_, r.
begin());
737 return static_cast<DERIVED &
>(*this);
742 template <
class T1,
class D1,
class D2>
745 Loop::mul(data_, r.
begin());
746 return static_cast<DERIVED &
>(*this);
751 template <
class T1,
class D1,
class D2>
754 Loop::div(data_, r.
begin());
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);
805 SquareRootTraits<SquaredNormType>::SquareRootArgument
>(
squaredMagnitude()));
812 return Loop::squaredNorm(data_);
819 return Loop::minimum(data_);
826 return Loop::maximum(data_);
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");
904 for(
int k=0;
k<
m; ++
k)
915 pointer data() {
return data_; }
931 return data_[SIZE-1];
936 return data_[SIZE-1];
943 VIGRA_ASSERT_INSIDE(
k);
968template <
int SIZE,
int DESIRED_SIZE>
969struct TinyVector_constructor_has_wrong_number_of_arguments
970: staticAssert::AssertBool<SIZE == DESIRED_SIZE>
975enum ReverseCopyTag { ReverseCopy };
1005template <
class T,
int SIZE>
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);
1065 BaseType::data_[0] =
i1;
1066 BaseType::data_[1] =
i2;
1076 BaseType::data_[0] =
i1;
1077 BaseType::data_[1] =
i2;
1078 BaseType::data_[2] =
i3;
1085 value_type
const &
i3, value_type
const &
i4)
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)
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>
1216 typedef typename detail::LoopType<minSize>::type
MinLoop;
1217 MinLoop::assignCast(BaseType::data_, r.
begin());
1251template <
class T,
int SIZE>
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());
1343template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1352template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1357 typedef typename detail::LoopType<SIZE>::type
ltype;
1362template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1367 typedef typename detail::LoopType<SIZE>::type
ltype;
1368 return ltype::lexicographicLessThan(
l.
begin(), r.
begin());
1373template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1385template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1397template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1409template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1420template <
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);
1430template <
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);
1447template <
class V1,
int SIZE,
class DATA,
class DERIVED>
1454 out <<
l[
i] <<
", ";
1512#if !defined(NO_PARTIAL_TEMPLATE_SPECIALIZATION)
1514template <
class T,
int SIZE>
1515struct 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()
1544 return TinyVector<T, SIZE>(NumericTraits<T>::min());
1546 static TinyVector<T, SIZE> max()
1548 return TinyVector<T, SIZE>(NumericTraits<T>::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());
1584template <
class T,
int SIZE>
1585struct 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;
1601template <
class T,
int SIZE>
1602struct NormTraits<TinyVector<T, SIZE> >
1604 typedef TinyVector<T, SIZE> Type;
1605 typedef typename Type::SquaredNormType SquaredNormType;
1606 typedef typename Type::NormType NormType;
1609template <
class T,
int SIZE>
1610struct NormTraits<TinyVectorView<T, SIZE> >
1612 typedef TinyVector<T, SIZE> Type;
1613 typedef typename Type::SquaredNormType SquaredNormType;
1614 typedef typename Type::NormType NormType;
1617template <
class T1,
class T2,
int SIZE>
1618struct PromoteTraits<TinyVector<T1, SIZE>, TinyVector<T2, SIZE> >
1620 typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
1623template <
class T1,
class T2,
int SIZE>
1624struct PromoteTraits<TinyVectorView<T1, SIZE>, TinyVectorView<T2, SIZE> >
1626 typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
1629template <
class T1,
class T2,
int SIZE>
1630struct PromoteTraits<TinyVectorView<T1, SIZE>, TinyVector<T2, SIZE> >
1632 typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
1635template <
class T1,
class T2,
int SIZE>
1636struct PromoteTraits<TinyVector<T1, SIZE>, TinyVectorView<T2, SIZE> >
1638 typedef TinyVector<typename PromoteTraits<T1, T2>::Promote, SIZE> Promote;
1641template <
class T,
int SIZE>
1642struct PromoteTraits<TinyVector<T, SIZE>, double >
1644 typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
1647template <
class T,
int SIZE>
1648struct PromoteTraits<double, TinyVector<T, SIZE> >
1650 typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
1653template <
class T,
int SIZE>
1654struct PromoteTraits<TinyVectorView<T, SIZE>, double >
1656 typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
1659template <
class T,
int SIZE>
1660struct PromoteTraits<double, TinyVectorView<T, SIZE> >
1662 typedef TinyVector<typename NumericTraits<T>::RealPromote, SIZE> Promote;
1665template<
class T,
int SIZE>
1666struct CanSkipInitialization<TinyVectorView<T, SIZE> >
1668 typedef typename CanSkipInitialization<T>::type type;
1669 static const bool value = type::asBool;
1672template<
class T,
int SIZE>
1673struct CanSkipInitialization<TinyVector<T, SIZE> >
1675 typedef typename CanSkipInitialization<T>::type type;
1676 static const bool value = type::asBool;
1684#define TINYVECTOR_NUMTRAITS(T, SIZE) \
1686struct 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);\
1733struct 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) \
1742struct 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) \
1751struct 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) \
1761TINYVECTOR_NUMTRAITS(unsigned char, SIZE)\
1762TINYVECTOR_NUMTRAITS(int, SIZE)\
1763TINYVECTOR_NUMTRAITS(float, SIZE)\
1764TINYVECTOR_NUMTRAITS(double, SIZE)\
1765TINYVECTOR_PROMTRAITS1(unsigned char, SIZE)\
1766TINYVECTOR_PROMTRAITS1(int, SIZE)\
1767TINYVECTOR_PROMTRAITS1(float, SIZE)\
1768TINYVECTOR_PROMTRAITS1(double, SIZE)\
1769TINYVECTOR_PROMTRAITS2(float, unsigned char, SIZE)\
1770TINYVECTOR_PROMTRAITS2(unsigned char, float, SIZE)\
1771TINYVECTOR_PROMTRAITS2(int, unsigned char, SIZE)\
1772TINYVECTOR_PROMTRAITS2(unsigned char, int, SIZE)\
1773TINYVECTOR_PROMTRAITS2(int, float, SIZE)\
1774TINYVECTOR_PROMTRAITS2(float, int, SIZE)\
1775TINYVECTOR_PROMTRAITS2(double, unsigned char, SIZE)\
1776TINYVECTOR_PROMTRAITS2(unsigned char, double, SIZE)\
1777TINYVECTOR_PROMTRAITS2(int, double, SIZE)\
1778TINYVECTOR_PROMTRAITS2(double, int, SIZE)\
1779TINYVECTOR_PROMTRAITS2(double, float, SIZE)\
1780TINYVECTOR_PROMTRAITS2(float, double, SIZE)
1786#undef TINYVECTOR_NUMTRAITS
1787#undef TINYVECTOR_PROMTRAITS1
1788#undef TINYVECTOR_PROMTRAITS2
1789#undef TINYVECTOR_TRAITS
1805template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1807typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
1815template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1817typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
1825template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1827typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
1835template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1837typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
1845template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
1847typename PromoteTraits<TinyVector<V1, SIZE>, TinyVector<V2, SIZE> >::Promote
1855template <
class V,
int SIZE,
class D1,
class D2>
1857typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1864template <
class V,
int SIZE,
class D1,
class D2>
1866typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1873template <
class V,
int SIZE,
class D1,
class D2>
1875typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1882template <
class V,
int SIZE,
class D1,
class D2>
1884typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1891template <
class V,
int SIZE,
class D1,
class D2>
1893typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1900template <
class V,
int SIZE,
class D1,
class D2>
1902typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1909template <
class V,
int SIZE,
class D1,
class D2>
1911typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1918template <
class V,
int SIZE,
class D1,
class D2>
1920typename NumericTraits<TinyVector<V, SIZE> >::RealPromote
1927template <
class V,
int SIZE,
class D1,
class D2>
1933 typedef typename detail::LoopType<SIZE>::type Loop;
1934 Loop::divScalar(result.data(), v);
1941template <
class V,
int SIZE,
class D1,
class D2>
1947 typedef typename detail::LoopType<SIZE>::type
ltype;
1953template <
class V,
int SIZE,
class D1,
class D2>
1959 typedef typename detail::LoopType<SIZE>::type
ltype;
1966template <
class V,
int SIZE,
class D1,
class D2>
1972 typedef typename detail::LoopType<SIZE>::type
ltype;
1979template <
class V,
int SIZE,
class D1,
class D2>
1985 typedef typename detail::LoopType<SIZE>::type
ltype;
1992template <
class V,
int SIZE,
class D1,
class D2>
1998 typedef typename detail::LoopType<SIZE>::type
ltype;
2005template <
class V,
int SIZE,
class D1,
class D2>
2007TinyVector<std::ptrdiff_t, SIZE>
2018template <
class V,
int SIZE,
class D1,
class D2>
2024 typedef typename detail::LoopType<SIZE>::type
ltype;
2033template <
class V,
int SIZE,
class D1,
class D2,
class E>
2039 typedef typename detail::LoopType<SIZE>::type
ltype;
2045template <
class V1,
class D1,
class D2,
class V2,
class D3,
class D4>
2047TinyVector<typename PromoteTraits<V1, V2>::Promote, 3>
2059template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
2061typename PromoteTraits<V1, V2>::Promote
2065 typedef typename detail::LoopType<SIZE>::type
ltype;
2070template <
class V,
int SIZE,
class D1,
class D2>
2072typename NumericTraits<V>::Promote
2075 typename NumericTraits<V>::Promote res =
l[0];
2082template <
class V,
int SIZE,
class D1,
class D2>
2084TinyVector<typename NumericTraits<V>::Promote, SIZE>
2094template <
class V,
int SIZE,
class D1,
class D2>
2096typename NumericTraits<V>::Promote
2099 typename NumericTraits<V>::Promote res =
l[0];
2106template <
class V,
int SIZE,
class D1,
class D2>
2108TinyVector<typename NumericTraits<V>::Promote, SIZE>
2120template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
2122TinyVector<typename PromoteTraits<V1, V2>::Promote, SIZE>
2126 typedef typename detail::LoopType<SIZE>::type
ltype;
2133template <
class V1,
int SIZE,
class D1,
class D2>
2136min(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);
2141 ltype::min(res.begin(), r.begin());
2145template <
class V1,
int SIZE>
2148min(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);
2153 ltype::min(res.begin(), r.begin());
2158template <
class V,
int SIZE,
class D1,
class D2>
2169template <
class V1,
int SIZE,
class D1,
class D2,
class V2,
class D3,
class D4>
2171TinyVector<typename PromoteTraits<V1, V2>::Promote, SIZE>
2175 typedef typename detail::LoopType<SIZE>::type
ltype;
2182template <
class V1,
int SIZE,
class D1,
class D2>
2185max(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);
2190 ltype::max(res.begin(), r.begin());
2194template <
class V1,
int SIZE>
2197max(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);
2202 ltype::max(res.begin(), r.begin());
2207template <
class V,
int SIZE,
class D1,
class D2>
2216template <
class V1,
int SIZE,
class D1,
class D2>
2225template <
class V,
int SIZE>
2227typename TinyVector<V, SIZE>::SquaredNormType
2236template <
class V,
int SIZE>
2248template <
class V,
int SIZE,
class T>
2266template<
class V,
int SIZE>
2276template<
class V,
int SIZE>
2281 res[
k]=t[
k]< val ? val : t[
k];
2290template<
class V,
int SIZE>
2295 res[
k]=t[
k]> val ? val : t[
k];
2305template<
class V,
int SIZE>
2324template<
class V,
int SIZE>
2348 for(
size_t k = 0;
k <
SIZE;
k++)
2360 for(
size_t k = 0;
k <
SIZE;
k++)
2365template<
class V,
int SIZE>
2367bool isZero(TinyVector<V, SIZE>
const & t){
2368 for(
int k=0; k<SIZE; ++k){
2369 if(t[k]!=
static_cast<V
>(0))
2375template<
class V,
int SIZE>
2376inline typename NumericTraits<V>::RealPromote
2377mean(TinyVector<V, SIZE>
const & t){
2378 const V sumVal =
sum(t);
2379 return static_cast< typename NumericTraits<V>::RealPromote
>(sumVal)/SIZE;
2383template<
class V,
int SIZE>
2384inline typename NumericTraits<V>::RealPromote
2385sizeDividedSquaredNorm(TinyVector<V, SIZE>
const & t){
2389template<
class V,
int SIZE>
2390inline typename NumericTraits<V>::RealPromote
2391sizeDividedNorm(TinyVector<V, SIZE>
const & t){
2392 return norm(t)/SIZE;
2400#if defined(_MSC_VER)
2401#pragma warning( pop )
2405#undef VIGRA_ASSERT_INSIDE
Two dimensional difference vector.
Definition diff2d.hxx:186
int y
Definition diff2d.hxx:392
int x
Definition diff2d.hxx:385
Class for a single RGB value.
Definition rgbvalue.hxx:128
SquaredNormType squaredMagnitude() const
Definition rgbvalue.hxx:313
Base class for fixed size vectors.
Definition tinyvector.hxx:640
NormType magnitude() const
Definition tinyvector.hxx:802
DERIVED & operator%=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition tinyvector.hxx:761
const_iterator begin() const
Definition tinyvector.hxx:868
static TinyVector< VALUETYPE, SIZE > unitVector(int k)
Factory function for a unit vector for dimension k.
Definition tinyvector.hxx:941
const_iterator cbegin() const
Definition tinyvector.hxx:876
SquareRootTraits< SquaredNormType >::SquareRootResult NormType
Definition tinyvector.hxx:699
DERIVED & operator/=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition tinyvector.hxx:752
value_type * iterator
Definition tinyvector.hxx:675
VALUETYPE const & const_reference
Definition tinyvector.hxx:663
VALUETYPE & reference
Definition tinyvector.hxx:659
void init(Iterator i, Iterator end)
Definition tinyvector.hxx:708
size_type size() const
Definition tinyvector.hxx:913
DERIVED & operator*=(double r)
Definition tinyvector.hxx:785
DERIVED & operator+=(double r)
Definition tinyvector.hxx:769
NormTraits< VALUETYPE >::SquaredNormType SquaredNormType
Definition tinyvector.hxx:695
TinyVectorView< VALUETYPE, TO-FROM > subarray() const
Definition tinyvector.hxx:887
VALUETYPE const & minimum() const
Definition tinyvector.hxx:817
DERIVED & operator/=(double r)
Definition tinyvector.hxx:793
bool all() const
Definition tinyvector.hxx:831
VALUETYPE const & maximum() const
Definition tinyvector.hxx:824
DERIVED & operator*=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition tinyvector.hxx:743
value_type const * const_iterator
Definition tinyvector.hxx:679
const_iterator cend() const
Definition tinyvector.hxx:880
reference operator[](difference_type i)
Definition tinyvector.hxx:845
VALUETYPE const * const_pointer
Definition tinyvector.hxx:671
DERIVED & operator-=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition tinyvector.hxx:734
VALUETYPE * pointer
Definition tinyvector.hxx:667
iterator end()
Definition tinyvector.hxx:864
const_iterator end() const
Definition tinyvector.hxx:872
DERIVED & operator+=(TinyVectorBase< T1, SIZE, D1, D2 > const &r)
Definition tinyvector.hxx:725
std::ptrdiff_t difference_type
Definition tinyvector.hxx:687
iterator begin()
Definition tinyvector.hxx:861
VALUETYPE value_type
Definition tinyvector.hxx:655
void init(value_type initial)
Definition tinyvector.hxx:717
unsigned int size_type
Definition tinyvector.hxx:683
double scalar_multiplier
Definition tinyvector.hxx:691
const_reference operator[](difference_type i) const
Definition tinyvector.hxx:853
DERIVED & operator-=(double r)
Definition tinyvector.hxx:777
SquaredNormType squaredMagnitude() const
Definition tinyvector.hxx:810
static TinyVector< VALUETYPE, SIZE > linearSequence(VALUETYPE start=VALUETYPE(), VALUETYPE step=VALUETYPE(1))
Factory function for a linear sequence.
Definition tinyvector.hxx:953
bool any() const
Definition tinyvector.hxx:838
Wrapper for fixed size vectors.
Definition tinyvector.hxx:1254
TinyVectorView & operator=(TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
Definition tinyvector.hxx:1318
TinyVectorView & operator=(TinyVectorView const &r)
Definition tinyvector.hxx:1309
TinyVectorView(const_pointer data)
Definition tinyvector.hxx:1284
TinyVectorView(TinyVectorBase< T, SIZE, DATA, DERIVED > const &other)
Definition tinyvector.hxx:1301
TinyVectorView()
Definition tinyvector.hxx:1276
TinyVectorView(TinyVectorView const &other)
Definition tinyvector.hxx:1292
Class for fixed size vectors.
Definition tinyvector.hxx:1008
TinyVector(lemon::Invalid const &)
Definition tinyvector.hxx:1041
TinyVector(value_type const &initial)
Definition tinyvector.hxx:1031
TinyVector & operator=(Diff2D const &r)
Definition tinyvector.hxx:1190
TinyVector & operator=(TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
Definition tinyvector.hxx:1180
TinyVector & operator=(TinyVector const &r)
Definition tinyvector.hxx:1171
TinyVector(SkipInitializationTag)
Definition tinyvector.hxx:1121
TinyVector(TinyVector const &r)
Definition tinyvector.hxx:1131
TinyVector & operator=(value_type const &v)
Definition tinyvector.hxx:1199
TinyVector & copy(TinyVectorBase< U, USIZE, DATA, DERIVED > const &r)
Definition tinyvector.hxx:1210
TinyVector(U const *data)
Definition tinyvector.hxx:1140
TinyVector(value_type const &i1, value_type const &i2)
Definition tinyvector.hxx:1061
TinyVector(value_type const &i1, value_type const &i2, value_type const &i3)
Definition tinyvector.hxx:1072
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
TinyVector(Diff2D const &initial)
Definition tinyvector.hxx:1051
TinyVector(const_pointer data, ReverseCopyTag)
Definition tinyvector.hxx:1154
TinyVector()
Definition tinyvector.hxx:1113
TinyVector(value_type const &i1, value_type const &i2, value_type const &i3, value_type const &i4)
Definition tinyvector.hxx:1084
TinyVector(TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
Definition tinyvector.hxx:1163
NormTraits< T >::SquaredNormType dot(const MultiArrayView< 2, T, C1 > &x, const MultiArrayView< 2, T, C2 > &y)
Definition matrix.hxx:1342
int floor(FixedPoint< IntBits, FracBits > v)
rounding down.
Definition fixedpoint.hxx:667
bool allGreater(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise greater-than
Definition tinyvector.hxx:1387
void sub(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r, FixedPoint< IntBits3, FracBits3 > &result)
subtraction with enforced result type.
Definition fixedpoint.hxx:583
bool allGreaterEqual(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise greater-equal
Definition tinyvector.hxx:1411
int round(FixedPoint< IntBits, FracBits > v)
rounding to the nearest integer.
Definition fixedpoint.hxx:683
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
V power(const V &x)
Exponentiation to a positive integer power by squaring.
Definition mathutil.hxx:427
bool allLessEqual(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise less-equal
Definition tinyvector.hxx:1399
Diff2D operator+(Diff2D const &a, Diff2D const &b)
Definition diff2d.hxx:725
void mul(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r, FixedPoint< IntBits3, FracBits3 > &result)
multiplication with enforced result type.
Definition fixedpoint.hxx:605
void add(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r, FixedPoint< IntBits3, FracBits3 > &result)
addition with enforced result type.
Definition fixedpoint.hxx:561
FFTWComplex< R >::NormType norm(const FFTWComplex< R > &a)
norm (= magnitude)
Definition fftw3.hxx:1037
TinyVector< V, SIZE > clipUpper(TinyVector< V, SIZE > const &t, const V val)
Clip values above a threshold.
Definition tinyvector.hxx:2292
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
Int32 roundi(FixedPoint16< IntBits, OverflowHandling > v)
rounding to the nearest integer.
Definition fixedpoint.hxx:1775
UInt32 ceilPower2(UInt32 x)
Round up to the nearest power of 2.
Definition mathutil.hxx:294
NumericTraits< V >::Promote sum(TinyVectorBase< V, SIZE, D1, D2 > const &l)
sum of the vector's elements
Definition tinyvector.hxx:2073
UInt32 floorPower2(UInt32 x)
Round down to the nearest power of 2.
Definition mathutil.hxx:317
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
NumericTraits< V >::Promote prod(TinyVectorBase< V, SIZE, D1, D2 > const &l)
product of the vector's elements
Definition tinyvector.hxx:2097
TinyVector< V, SIZE > clipLower(TinyVector< V, SIZE > const &t)
Clip negative values.
Definition tinyvector.hxx:2268
TinyVector< V, SIZE > clip(TinyVector< V, SIZE > const &t, const V valLower, const V valUpper)
Clip values to an interval.
Definition tinyvector.hxx:2307
FFTWComplex< R >::SquaredNormType squaredNorm(const FFTWComplex< R > &a)
squared norm (= squared magnitude)
Definition fftw3.hxx:1044
bool allLess(TinyVectorBase< V1, SIZE, D1, D2 > const &l, TinyVectorBase< V2, SIZE, D3, D4 > const &r)
pointwise less-than
Definition tinyvector.hxx:1375
bool closeAtTolerance(T1 l, T2 r, typename PromoteTraits< T1, T2 >::Promote epsilon)
Tolerance based floating-point equality.
Definition mathutil.hxx:1638
bool operator<(FixedPoint< IntBits1, FracBits1 > l, FixedPoint< IntBits2, FracBits2 > r)
less than
Definition fixedpoint.hxx:512
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
bool operator==(FFTWComplex< R > const &a, const FFTWComplex< R > &b)
equal
Definition fftw3.hxx:825
int ceil(FixedPoint< IntBits, FracBits > v)
rounding up.
Definition fixedpoint.hxx:675
bool operator!=(FFTWComplex< R > const &a, const FFTWComplex< R > &b)
not equal
Definition fftw3.hxx:841
Diff2D operator-(Diff2D const &a, Diff2D const &b)
Definition diff2d.hxx:697