31 #ifndef ATBTINYMATRIXOPERATORS_HH 32 #define ATBTINYMATRIXOPERATORS_HH 50 template<
typename DataT,
int NRows,
int NColumns>
52 TinyMatrix<DataT,NRows,NColumns>
const &m)
54 TinyMatrix<DataT,NRows,NColumns> res;
55 for (
int i = 0; i < NRows * NColumns; ++i) res.data()[i] = -m.data()[i];
69 template<
typename DataT,
int Dim1,
int Dim2>
71 TinyMatrix<DataT,Dim2,Dim1>
const &m,
72 TinyVector<DataT,Dim1>
const &v)
74 TinyVector<DataT,Dim2> res(DataT(0));
75 for (
int r = 0; r < Dim2; ++r)
76 for (
int c = 0; c < Dim1; ++c) res(r) += m(r,c) * v(c);
91 template<
typename DataT,
int Dim1,
int Dim2>
93 TinyVector<DataT,Dim2>
const &v,
94 TinyMatrix<DataT,Dim2,Dim1>
const &m)
96 TinyVector<DataT,Dim1> res(DataT(0));
97 for (
int r = 0; r < Dim2; ++r)
98 for (
int c = 0; c < Dim1; ++c) res(c) += m(r,c) * v(r);
112 template<
typename DataT,
int NRows,
int NColumns>
114 DataT
const &alpha, TinyMatrix<DataT,NRows,NColumns>
const &m)
116 TinyMatrix<DataT,NRows,NColumns> res;
117 for (
int i = 0; i < NRows * NColumns; ++i)
119 res.data()[i] = m.data()[i] * alpha;
134 template<
typename DataT,
int NRows,
int NColumns>
136 TinyMatrix<DataT,NRows,NColumns>
const &m, DataT
const &alpha)
138 TinyMatrix<DataT,NRows,NColumns> res;
139 for (
int i = 0; i < NRows * NColumns; ++i)
141 res.data()[i] = m.data()[i] * alpha;
156 template<
typename DataT,
int NRows,
int NColumns>
158 TinyMatrix<DataT,NRows,NColumns>
const &m, DataT
const &alpha)
160 TinyMatrix<DataT,NRows,NColumns> res;
161 for (
int i = 0; i < NRows * NColumns; ++i)
163 res.data()[i] = m.data()[i] / alpha;
178 template<
typename DataT,
int NRows,
int NColumns>
180 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
181 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
183 TinyMatrix<DataT,NRows,NColumns> res;
184 for (
int i = 0; i < NRows * NColumns; ++i)
186 res.data()[i] = lhs.data()[i] - rhs.data()[i];
201 template<
typename DataT,
int NRows,
int NColumns>
203 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
204 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
206 TinyMatrix<DataT,NRows,NColumns> res;
207 for (
int i = 0; i < NRows * NColumns; ++i)
209 res.data()[i] = lhs.data()[i] + rhs.data()[i];
224 template<
typename DataT,
int NRows,
int NColumns>
226 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
227 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
229 TinyMatrix<bool,NRows,NColumns> res;
230 for (
int i = 0; i < NRows * NColumns; ++i)
231 res.data()[i] = (lhs.data()[i] == rhs.data()[i]);
245 template<
typename DataT,
int NRows,
int NColumns>
247 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
248 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
250 TinyMatrix<bool,NRows,NColumns> res;
251 for (
int i = 0; i < NRows * NColumns; ++i)
252 res.data()[i] = (lhs.data()[i] != rhs.data()[i]);
267 template<
typename DataT,
int NRows,
int NColumns>
269 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
270 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
272 TinyMatrix<bool,NRows,NColumns> res;
273 for (
int i = 0; i < NRows * NColumns; ++i)
274 res.data()[i] = (lhs.data()[i] < rhs.data()[i]);
289 template<
typename DataT,
int NRows,
int NColumns>
291 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
292 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
294 TinyMatrix<bool,NRows,NColumns> res;
295 for (
int i = 0; i < NRows * NColumns; ++i)
296 res.data()[i] = (lhs.data()[i] <= rhs.data()[i]);
311 template<
typename DataT,
int NRows,
int NColumns>
313 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
314 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
316 TinyMatrix<bool,NRows,NColumns> res;
317 for (
int i = 0; i < NRows * NColumns; ++i)
318 res.data()[i] = (lhs.data()[i] > rhs.data()[i]);
333 template<
typename DataT,
int NRows,
int NColumns>
335 TinyMatrix<DataT,NRows,NColumns>
const &lhs,
336 TinyMatrix<DataT,NRows,NColumns>
const &rhs)
338 TinyMatrix<bool,NRows,NColumns> res;
339 for (
int i = 0; i < NRows * NColumns; ++i)
340 res.data()[i] = (lhs.data()[i] >= rhs.data()[i]);
355 template<
int NRows,
int NColumns>
356 bool all(blitz::TinyMatrix<bool,NRows,NColumns>
const &matrix)
358 for (
int i = 0; i < NRows * NColumns; ++i)
359 if (!matrix.data()[i])
return false;
374 template<
int NRows,
int NColumns>
375 bool any(blitz::TinyMatrix<bool,NRows,NColumns>
const &matrix)
377 for (
int i = 0; i < NRows * NColumns; ++i)
378 if (matrix.data()[i])
return true;
TinyMatrix< bool, NRows, NColumns > operator==(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Elementwise comparison for equality of two blitz::TinyMatrices.
TinyMatrix< DataT, NRows, NColumns > operator+(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Addition of a blitz::TinyMatrix to another blitz::TinyMatrix.
TinyMatrix< bool, NRows, NColumns > operator!=(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Elementwise comparison for inequality of two blitz::TinyMatrices.
TinyMatrix< bool, NRows, NColumns > operator<(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Elementwise comparison of two blitz::TinyMatrices using the less than operator.
TinyVector< DataT, Dim2 > operator*(TinyMatrix< DataT, Dim2, Dim1 > const &m, TinyVector< DataT, Dim1 > const &v)
Product of a blitz::TinyMatrix and a blitz::TinyVector.
TinyMatrix< bool, NRows, NColumns > operator<=(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Elementwise comparison of two blitz::TinyMatrices using the less than or equals operator.
TinyMatrix< bool, NRows, NColumns > operator>(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Elementwise comparison of two blitz::TinyMatrices using the greater than operator.
TinyMatrix< DataT, NRows, NColumns > operator/(TinyMatrix< DataT, NRows, NColumns > const &m, DataT const &alpha)
Division of a blitz::TinyMatrix by a scalar.
bool any(blitz::TinyMatrix< bool, NRows, NColumns > const &matrix)
any() reduction for boolean blitz::TinyMatrix.
TinyMatrix< bool, NRows, NColumns > operator>=(TinyMatrix< DataT, NRows, NColumns > const &lhs, TinyMatrix< DataT, NRows, NColumns > const &rhs)
Elementwise comparison of two blitz::TinyMatrices using the greater than or equals operator...
TinyMatrix< DataT, NRows, NColumns > operator-(TinyMatrix< DataT, NRows, NColumns > const &m)
Negation of a blitz::TinyMatrix.
bool all(blitz::TinyMatrix< bool, NRows, NColumns > const &matrix)
all() reduction for boolean blitz::TinyMatrix.