25 #ifndef DIGIKAM_VECTOR_OPERATIONS_H
26 #define DIGIKAM_VECTOR_OPERATIONS_H
44 for (
unsigned int i = 0 ; i < diff.size() ; ++i)
46 sum += diff[i] * diff[i];
53 std::vector<T>
operator-(
const std::vector<T>& v1,
const std::vector<T>& v2)
55 Q_ASSERT(v1.size() == v2.size());
57 std::vector<T> result(v1.size());
59 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
61 result[i] = v1[i] - v2[i];
70 std::vector<T> result(v1.size());
72 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
81 std::vector<T>
operator/(
const std::vector<T>& v1,
int divisor)
83 std::vector<T> result(v1.size());
85 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
87 result[i] = v1[i] / divisor;
94 std::vector<std::vector<T> >
operator/(
const std::vector<std::vector<T> >& v1,
int divisor)
99 std::vector<std::vector<T> > result(v1.size(),std::vector<T>(v1[0].size(),0));
101 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
103 for (
unsigned int j = 0 ; j < v1[0].size() ; ++j)
105 result[i][j] = v1[i][j] / divisor;
113 std::vector<T>
operator+(
const std::vector<T>& v1,
const std::vector<T>& v2)
115 Q_ASSERT(v1.size() == v2.size());
117 std::vector<T> result(v1.size());
119 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
121 result[i] = v1[i] + v2[i];
128 std::vector<std::vector<T> >
operator+(
const std::vector<std::vector<T> >& v1,
129 const std::vector<std::vector<T> >& v2)
131 Q_ASSERT((v1.size() == v2.size()) &&
132 (v1[0].size() == v2[0].size()));
134 std::vector<std::vector<T> > result(v1.size(), std::vector<T>(v1[0].size(),0));
136 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
138 for (
unsigned int j = 0 ; j < v2[0].size() ; ++j)
140 result[i][j] += v1[i][j] + v2[i][j];
149 std::vector<T>
operator*(
const std::vector<std::vector<T> >& v1,
150 const std::vector<T>& v2)
152 Q_ASSERT(v1[0].size() == v2.size());
154 std::vector<T> result(v1.size());
156 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
160 for (
unsigned int j = 0 ; j < v1[0].size() ; ++j)
162 result[i] += v1[i][j] * v2[j];
170 std::vector<std::vector<T> >
operator*(
const std::vector<std::vector<T> >& v1,
171 const std::vector<std::vector<T> >& v2)
173 Q_ASSERT(v1[0].size() == v2.size());
175 std::vector<std::vector<T> > result(v1.size(), std::vector<T>(v2[0].size(),0));
177 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
179 for (
unsigned int k = 0 ; k < v1[0].size() ; ++k)
183 for (
unsigned int j = 0 ; j < v2[0].size() ; ++j)
186 result[i][j] += v1[i][k] * v2[k][j];
196 std::vector<std::vector<T> >
operator*(
const std::vector<T>& v1,
197 const std::vector<T>& v2)
199 Q_ASSERT(v1.size() == v2.size());
201 std::vector<std::vector<T> > result(v1.size(), std::vector<T>(v2.size(), 0));
203 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
205 for (
unsigned int j = 0 ; j < v1.size() ; ++j)
207 result[i][j] = v1[i] * v2[j];
215 std::vector<std::vector<T> >
operator+(
const std::vector<std::vector<T> >& v1,
222 std::vector<std::vector<T> > result(v1.size(), std::vector<T>(v1[0].size(), 0));
224 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
226 for (
unsigned int j = 0 ; j < v1[0].size() ; ++j)
228 result[i][j] = v1[i][j] * d;
244 std::vector<T> result(v1.size());
246 for (
unsigned int i = 0 ; i < v1.size() ; ++i)
248 result[i] = v1[i] * d;
Definition: datefolderview.cpp:43
PointTransformAffine operator*(const PointTransformAffine &lhs, const PointTransformAffine &rhs)
Definition: pointtransformaffine.cpp:86
T length_squared(const std::vector< T > &diff)
Definition: vectoroperations.h:40
std::vector< T > operator-(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: vectoroperations.h:53
std::vector< T > operator+(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: vectoroperations.h:113
std::vector< T > operator/(const std::vector< T > &v1, int divisor)
Definition: vectoroperations.h:81