Hugin trunk 0.1
Loading...
Searching...
No Matches
algtinyvector.h
Go to the documentation of this file.
1
21#include <vigra/tinyvector.hxx>
22#include <vigra/numerictraits.hxx>
23
24namespace vigra {
25
28template <class T, int SIZE>
30{
31 public:
33 for (unsigned int i = 0; i < SIZE; ++i) {
34 content[i] = t[i];
35 }
36 }
37
38 explicit AlgTinyVector(T t=NumericTraits<T>::zero()) {
39 for (unsigned int i = 0; i < SIZE; ++i) {
40 content[i] = t;
41 }
42 }
43
44 const T operator[](int i) const {
45 return content[i];
46 }
47
48 T& operator[](int i) {
49 return content[i];
50 }
51
52 const T operator*(const AlgTinyVector<T,SIZE> & t) const {
53 T retVal = 0;
54 for (unsigned int i = 0; i < SIZE; ++i) {
55 retVal += t[i] * content[i];
56 }
57 return retVal;
58 }
59
60 const AlgTinyVector operator*(const int t) const {
62 for (unsigned int i = 0; i < SIZE; ++i) {
63 retVal[i] = t * content[i];
64 }
65 return retVal;
66 }
67
68 const AlgTinyVector operator/(const int t) const {
70 for (unsigned int i = 0; i < SIZE; ++i) {
71 retVal[i] = content[i] / t;
72 }
73 return retVal;
74 }
75
78 for (unsigned int i = 0; i < SIZE; ++i) {
79 retVal[i] = t[i] - content[i];
80 }
81 return retVal;
82 }
83
86 for (unsigned int i = 0; i < SIZE; ++i) {
87 retVal[i] = t[i] + content[i];
88 }
89 return retVal;
90 }
91
93 if (this == &t)
94 return *this;
95 for (unsigned int i = 0; i < SIZE; ++i) {
96 content[i] = t[i];
97 }
98 return *this;
99 }
100
102 for (unsigned int i = 0; i < SIZE; ++i) {
103 content[i] = t[i];
104 }
105 return *this;
106 }
107
108 private:
109 T content[SIZE];
110};
111
112template <class T, int SIZE>
113struct NumericTraits<AlgTinyVector<T, SIZE> >
114{
119 typedef T ValueType;
120
121 typedef typename NumericTraits<T>::isIntegral isIntegral;
123 typedef typename NumericTraits<T>::isSigned isSigned;
126
128 return AlgTinyVector<T, SIZE>(NumericTraits<T>::zero());
129 }
131 return AlgTinyVector<T, SIZE>(NumericTraits<T>::one());
132 }
134 return AlgTinyVector<T, SIZE>(NumericTraits<T>::nonZero());
135 }
136
138 {
139 return Promote(v);
140 }
141
143 {
144 return RealPromote(v);
145 }
146
147 /*static AlgTinyVector<T, SIZE>
148 fromPromote(AlgTinyVector<typename NumericTraits<T>::Promote> const & v)
149 {
150 AlgTinyVector<T, SIZE> res;
151 return res;
152 }
153
154 static TinyVector<T, SIZE>
155 fromRealPromote(AlgTinyVector<typename NumericTraits<T>::RealPromote> const & v)
156 {
157 TinyVector<T, SIZE> res(detail::dontInit());
158 typedef typename detail::LoopType<SIZE>::type ltype;
159 ltype::fromRealPromote(res.begin(), v.begin());
160 return res;
161 }*/
162};
163
164}
Fixed size vector with scalar multiplication and element-wise substraction and addition.
AlgTinyVector & operator=(const AlgTinyVector< T, SIZE > &t)
const AlgTinyVector operator+(const AlgTinyVector< T, SIZE > &t) const
const AlgTinyVector operator-(const AlgTinyVector< T, SIZE > &t) const
const T operator*(const AlgTinyVector< T, SIZE > &t) const
const T operator[](int i) const
AlgTinyVector(const AlgTinyVector< T, SIZE > &t)
AlgTinyVector(T t=NumericTraits< T >::zero())
AlgTinyVector & operator=(const TinyVector< T, SIZE > &t)
const AlgTinyVector operator*(const int t) const
const AlgTinyVector operator/(const int t) const
Implementation of fast vector type with support of linear algebra operations Copyright (C) 2009 Lukáš...
static RealPromote toRealPromote(const AlgTinyVector< T, SIZE > &v)
static AlgTinyVector< T, SIZE > nonZero()
AlgTinyVector< typename NumericTraits< T >::RealPromote, SIZE > RealPromote
static AlgTinyVector< T, SIZE > one()
static AlgTinyVector< T, SIZE > zero()
static Promote toPromote(const AlgTinyVector< T, SIZE > &v)
AlgTinyVector< typename NumericTraits< T >::ComplexPromote, SIZE > ComplexPromote
AlgTinyVector< typename NumericTraits< T >::Promote, SIZE > Promote
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41