22 #ifndef linear_algebra_h 23 #define linear_algebra_h 25 #include "square_matrix.h" 27 #include "row_vector.h" 28 #include "fixed_square_matrix.h" 29 #include "fixed_vector.h" 30 #include "fixed_row_vector.h" 31 #include "fixed_symmetric_matrix.h" 32 #include "var_square_matrix.h" 33 #include "var_symmetric_matrix.h" 34 #include "var_vector.h" 35 #include "var_row_vector.h" 36 #include "var_fixed_general_matrix.h" 37 #include "fixed_var_general_matrix.h" 43 template<
class T> std::complex<T> operator+(
const std::complex<T> &x,
int y);
44 template<
class T> std::complex<T> operator-(
const std::complex<T> &x,
int y);
45 template<
class T> std::complex<T> operator*(
const std::complex<T> &x,
int y);
46 template<
class T> std::complex<T> operator/(
const std::complex<T> &x,
int y);
47 template<
class T> std::complex<T> operator+(
int x,
const std::complex<T> &y);
48 template<
class T> std::complex<T> operator-(
int x,
const std::complex<T> &y);
49 template<
class T> std::complex<T> operator*(
int x,
const std::complex<T> &y);
50 template<
class T> std::complex<T> operator/(
int x,
const std::complex<T> &y);
55 template <
class Row1,
class Row2,
class Row3,
class AT1,
class AT2,
class AT3>
56 inline void add(
const Vector<Row1, AT1> &a1,
const Vector<Row2, AT2> &a2, Vector<Row3, AT3> &a3) {
57 FMATVEC_ASSERT(a1.size() == a2.size(), AT3);
58 for (
int i = 0; i < a1.size(); i++)
59 a3.e(i) = a1.e(i) + a2.e(i);
62 template <
class Row1,
class Row2,
class AT>
63 inline void add(Vector<Row1, AT> &a1,
const Vector<Row2, AT> &a2) {
64 FMATVEC_ASSERT(a1.size() == a2.size(), AT);
65 for (
int i = 0; i < a1.size(); i++)
69 template <
class Row1,
class Row2,
class Row3,
class AT1,
class AT2>
71 FMATVEC_ASSERT(a1.size() == a2.size(), AT2);
72 for (
int i = 0; i < a1.size(); i++)
73 a3.e(i) = a1.e(i) - a2.e(i);
76 template <
class Row1,
class Row2,
class AT1,
class AT2>
77 inline void sub(Vector<Row1, AT1> &a1,
const Vector<Row2, AT2> &a2) {
78 FMATVEC_ASSERT(a1.size() == a2.size(), AT2);
79 for (
int i = 0; i < a1.size(); i++)
84 template <
class AT1,
class AT2,
class Row1,
class Row2>
85 inline Vector<Var, typename OperatorResult<AT1, AT2>::Type> operator+(
const Vector<Row1, AT1> &a,
const Vector<Row2, AT2> &b) {
86 Vector<Var, typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
90 template <
class AT1,
class AT2,
class Row>
91 inline Vector<Row, typename OperatorResult<AT1, AT2>::Type> operator+(
const Vector<Row, AT1> &a,
const Vector<Row, AT2> &b) {
92 Vector<Row, typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
96 template <
class AT1,
class AT2,
int M,
class Row>
97 inline Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Vector<Fixed<M>, AT1> &a,
const Vector<Row, AT2> &b) {
98 Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
102 template <
class AT1,
class AT2,
int M>
103 inline Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Vector<Fixed<M>, AT1> &a,
const Vector<Fixed<M>, AT2> &b) {
104 Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
108 template <
class AT,
class Row1,
class Row2>
109 inline Vector<Row1, AT> operator+=(Vector<Row1, AT> &a,
const Vector<Row2, AT> &b) {
115 template <
class AT1,
class AT2,
class Row1,
class Row2>
121 template <
class AT1,
class AT2,
class Row>
122 inline Vector<Row, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Vector<Row, AT1> &a,
const Vector<Row, AT2> &b) {
123 Vector<Row, typename fmatvec::OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
127 template <
class AT1,
class AT2,
int M,
class Row2>
133 template <
class AT1,
class AT2,
int M>
139 template <
class AT,
class Row1,
class Row2>
140 inline Vector<Row1, AT> operator-=(Vector<Row1, AT> &a,
const Vector<Row2, AT> &b) {
146 template <
class Col1,
class Col2,
class Col3,
class AT>
147 inline void add(
const RowVector<Col1, AT> &a1,
const RowVector<Col2, AT> &a2, RowVector<Col3, AT> &a3) {
148 FMATVEC_ASSERT(a1.size() == a2.size(), AT);
149 for (
int i = 0; i < a1.size(); i++)
150 a3.e(i) = a1.e(i) + a2.e(i);
153 template <
class Col1,
class Col2,
class AT>
154 inline void add(RowVector<Col1, AT> &a1,
const RowVector<Col2, AT> &a2) {
155 FMATVEC_ASSERT(a1.size() == a2.size(), AT);
156 for (
int i = 0; i < a1.size(); i++)
160 template <
class Col1,
class Col2,
class Col3,
class AT1,
class AT2>
162 FMATVEC_ASSERT(a1.size() == a2.size(), AT2);
163 for (
int i = 0; i < a1.size(); i++)
164 a3.e(i) = a1.e(i) - a2.e(i);
167 template <
class Col1,
class Col2,
class AT1,
class AT2>
168 inline void sub(RowVector<Col1, AT1> &a1,
const RowVector<Col2, AT2> &a2) {
169 FMATVEC_ASSERT(a1.size() == a2.size(), AT2);
170 for (
int i = 0; i < a1.size(); i++)
175 template <
class AT1,
class AT2,
class Col1,
class Col2>
176 inline RowVector<Var, typename OperatorResult<AT1, AT2>::Type> operator+(
const RowVector<Col1, AT1> &a,
const RowVector<Col2, AT2> &b) {
177 RowVector<Var, typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
181 template <
class AT1,
class AT2,
class Col>
182 inline RowVector<Col, typename OperatorResult<AT1, AT2>::Type> operator+(
const RowVector<Col, AT1> &a,
const RowVector<Col, AT2> &b) {
183 RowVector<Col, typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
187 template <
class AT1,
class AT2,
int N,
class Col2>
188 inline RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const RowVector<Fixed<N>, AT1> &a,
const RowVector<Col2, AT2> &b) {
189 RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
193 template <
class AT1,
class AT2,
int N>
194 inline RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const RowVector<Fixed<N>, AT1> &a,
const RowVector<Fixed<N>, AT2> &b) {
195 RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
199 template <
class AT,
class Col1,
class Col2>
200 inline RowVector<Col1, AT> operator+=(RowVector<Col1, AT> &a,
const RowVector<Col2, AT> &b) {
206 template <
class AT1,
class AT2,
class Col1,
class Col2>
212 template <
class AT1,
class AT2,
class Col>
213 inline RowVector<Col, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const RowVector<Col, AT1> &a,
const RowVector<Col, AT2> &b) {
214 RowVector<Col, typename fmatvec::OperatorResult<AT1, AT2>::Type> c(a.size(), NONINIT);
218 template <
class AT1,
class AT2,
int N,
class Col2>
224 template <
class AT1,
class AT2,
int N>
230 template <
class AT,
class Col1,
class Col2>
231 inline RowVector<Col1, AT> operator-=(RowVector<Col1, AT> &a,
const RowVector<Col2, AT> &b) {
237 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT1,
class AT2,
class AT3>
238 inline void add(
const Matrix<Type1, Row1, Col1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2, Matrix<Type3, Row3, Col3, AT3> &A3) {
239 FMATVEC_ASSERT(A1.rows() == A2.rows(), AT3);
240 FMATVEC_ASSERT(A1.cols() == A2.cols(), AT3);
241 for (
int i = 0; i < A1.rows(); i++)
242 for (
int j = 0; j < A2.cols(); j++)
243 A3.e(i, j) = A1.e(i, j) + A2.e(i, j);
246 template <
class Row1,
class Row2,
class Row3,
class AT>
247 inline void add(
const Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2, Matrix<Symmetric, Row3, Row3, AT> &A3) {
248 FMATVEC_ASSERT(A1.size() == A2.size(), AT);
249 for (
int i = 0; i < A1.size(); i++)
250 for (
int j = i; j < A2.size(); j++)
251 A3.ej(i, j) = A1.ej(i, j) + A2.ej(i, j);
254 template <
class Row1,
class Row2,
class Row3,
class AT>
255 inline void add(
const Matrix<Diagonal, Row1, Row1, AT> &A1,
const Matrix<Diagonal, Row2, Row2, AT> &A2, Matrix<Diagonal, Row3, Row3, AT> &A3) {
256 FMATVEC_ASSERT(A1.size() == A2.size(), AT);
257 for (
int i = 0; i < A3.size(); i++)
258 A3.e(i) = A1.e(i) + A2.e(i);
261 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class AT>
262 inline void add(Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2) {
263 FMATVEC_ASSERT(A1.rows() == A2.rows(), AT);
264 FMATVEC_ASSERT(A1.cols() == A2.cols(), AT);
265 for (
int i = 0; i < A1.rows(); i++)
266 for (
int j = 0; j < A2.cols(); j++)
267 A1.e(i, j) += A2.e(i, j);
270 template <
class Row1,
class Row2,
class AT>
271 inline void add(Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2) {
272 FMATVEC_ASSERT(A1.size() == A2.size(), AT);
273 for (
int i = 0; i < A1.size(); i++)
274 for (
int j = i; j < A2.size(); j++)
275 A1.ej(i, j) += A2.ej(i, j);
278 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT1,
class AT2>
279 inline void sub(
const Matrix<Type1, Row1, Col1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2, Matrix<Type3, Row3, Col3,
typename fmatvec::OperatorResult<AT1, AT2>::Type> &A3) {
280 FMATVEC_ASSERT(A1.rows() == A2.rows(), AT2);
281 FMATVEC_ASSERT(A1.cols() == A2.cols(), AT2);
282 for (
int i = 0; i < A1.rows(); i++)
283 for (
int j = 0; j < A2.cols(); j++)
284 A3.e(i, j) = A1.e(i, j) - A2.e(i, j);
287 template <
class Row1,
class Row2,
class Row3,
class AT1,
class AT2>
288 inline void sub(
const Matrix<Symmetric, Row1, Row1, AT1> &A1,
const Matrix<Symmetric, Row2, Row2, AT2> &A2, Matrix<Symmetric, Row3, Row3,
typename fmatvec::OperatorResult<AT1, AT2>::Type> &A3) {
289 FMATVEC_ASSERT(A1.size() == A2.size(), AT2);
290 for (
int i = 0; i < A1.size(); i++)
291 for (
int j = i; j < A2.size(); j++)
292 A3.ej(i, j) = A1.ej(i, j) - A2.ej(i, j);
295 template <
class Row1,
class Row2,
class Row3,
class AT1,
class AT2>
296 inline void sub(
const Matrix<Diagonal, Row1, Row1, AT1> &A1,
const Matrix<Diagonal, Row2, Row2, AT2> &A2, Matrix<Diagonal, Row3, Row3,
typename fmatvec::OperatorResult<AT1, AT2>::Type> &A3) {
297 FMATVEC_ASSERT(A1.size() == A2.size(), AT2);
298 for (
int i = 0; i < A3.size(); i++)
299 A3.e(i) = A1.e(i) - A2.e(i);
302 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class AT1,
class AT2>
303 inline void sub(Matrix<Type1, Row1, Col1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2) {
304 FMATVEC_ASSERT(A1.rows() == A2.rows(), AT2);
305 FMATVEC_ASSERT(A1.cols() == A2.cols(), AT2);
306 for (
int i = 0; i < A1.rows(); i++)
307 for (
int j = 0; j < A2.cols(); j++)
308 A1.e(i, j) -= A2.e(i, j);
311 template <
class Row1,
class Row2,
class AT1,
class AT2>
312 inline void sub(Matrix<Symmetric, Row1, Row1, AT1> &A1,
const Matrix<Symmetric, Row2, Row2, AT2> &A2) {
313 FMATVEC_ASSERT(A1.size() == A2.size(), AT2);
314 for (
int i = 0; i < A1.size(); i++)
315 for (
int j = i; j < A2.size(); j++)
316 A1.ej(i, j) -= A2.ej(i, j);
321 template <
class AT1,
class AT2,
class Type1,
class Type2,
class Row1,
class Col1,
class Row2,
class Col2>
322 inline Matrix<General, Var, Var, typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Row1, Col1, AT1> &A,
const Matrix<Type2, Row2, Col2, AT2> &B) {
323 Matrix<General, Var, Var, typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
327 template <
class AT1,
class AT2,
class Type1,
class Type2,
class Row,
class Col>
328 inline Matrix<General, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Row, Col, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
329 Matrix<General, Row, Col, typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
333 template <
class AT1,
class AT2,
int M,
class Type1,
class Type2,
class Row,
class Col>
334 inline Matrix<General, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Fixed<M>, Var, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
335 Matrix<General, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
339 template <
class AT1,
class AT2,
int M,
class Type1,
class Type2>
340 inline Matrix<General, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Fixed<M>, Var, AT1> &A,
const Matrix<Type2, Fixed<M>, Var, AT2> &B) {
341 Matrix<General, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
345 template <
class AT1,
class AT2,
int N,
class Type1,
class Type2,
class Row,
class Col>
346 inline Matrix<General, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Var, Fixed<N>, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
347 Matrix<General, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
351 template <
class AT1,
class AT2,
int N,
class Type1,
class Type2>
352 inline Matrix<General, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Var, Fixed<N>, AT1> &A,
const Matrix<Type2, Var, Fixed<N>, AT2> &B) {
353 Matrix<General, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
357 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
358 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
359 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
363 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
364 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Fixed<M>, Var, AT2> &B) {
365 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
369 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
370 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Var, Fixed<N>, AT2> &B) {
371 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
375 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
376 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Fixed<M>, Fixed<N>, AT2> &B) {
377 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
381 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
382 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type2, Row, Col, AT1> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT2> &B) {
383 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
387 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
388 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type2, Fixed<M>, Var, AT1> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT2> &B) {
389 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
393 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
394 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type2, Var, Fixed<N>, AT1> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT2> &B) {
395 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
400 template <
class AT1,
class AT2,
class Type,
class Row1,
class Col1,
class Row2,
class Col2>
401 inline Matrix<Type, Var, Var, typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Row1, Col1, AT1> &A,
const Matrix<Type, Row2, Col2, AT2> &B) {
402 Matrix<Type, Var, Var, typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
406 template <
class AT1,
class AT2,
class Type,
class Row,
class Col>
407 inline Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Row, Col, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
408 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
412 template <
class AT1,
class AT2,
int M,
class Type,
class Row,
class Col>
413 inline Matrix<Type, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Var, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
414 Matrix<Type, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
418 template <
class AT1,
class AT2,
int M,
class Type>
419 inline Matrix<Type, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Var, AT1> &A,
const Matrix<Type, Fixed<M>, Var, AT2> &B) {
420 Matrix<Type, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
424 template <
class AT1,
class AT2,
int N,
class Type,
class Row,
class Col>
425 inline Matrix<Type, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Var, Fixed<N>, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
426 Matrix<Type, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
430 template <
class AT1,
class AT2,
int N,
class Type>
431 inline Matrix<Type, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Var, Fixed<N>, AT1> &A,
const Matrix<Type, Var, Fixed<N>, AT2> &B) {
432 Matrix<Type, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
436 template <
class AT1,
class AT2,
int M,
int N,
class Type,
class Row,
class Col>
437 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
438 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
442 template <
class AT1,
class AT2,
int M,
int N,
class Type>
443 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Fixed<M>, Var, AT2> &B) {
444 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
448 template <
class AT1,
class AT2,
int M,
int N,
class Type>
449 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Var, Fixed<N>, AT2> &B) {
450 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
454 template <
class AT1,
class AT2,
int M,
int N,
class Type>
455 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
456 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
460 template <
class AT1,
class AT2,
int M,
int N,
class Type,
class Row,
class Col>
461 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Row, Col, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
462 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
466 template <
class AT1,
class AT2,
int M,
int N,
class Type>
467 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Fixed<M>, Var, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
468 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
472 template <
class AT1,
class AT2,
int M,
int N,
class Type>
473 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator+(
const Matrix<Type, Var, Fixed<N>, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
474 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
478 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
479 inline Matrix<Type1, Row1, Col1, AT>& operator+=(Matrix<Type1, Row1, Col1, AT> &A,
const Matrix<Type2, Row2, Col2, AT> &B) {
486 template <
class AT1,
class AT2,
class Type1,
class Type2,
class Row1,
class Col1,
class Row2,
class Col2>
487 inline Matrix<General, Var, Var, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Row1, Col1, AT1> &A,
const Matrix<Type2, Row2, Col2, AT2> &B) {
488 Matrix<General, Var, Var, typename fmatvec::OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
492 template <
class AT1,
class AT2,
class Type1,
class Type2,
class Row,
class Col>
493 inline Matrix<General, Row, Col, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Row, Col, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
494 Matrix<General, Row, Col, typename fmatvec::OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
498 template <
class AT1,
class AT2,
int M,
class Type1,
class Type2,
class Row,
class Col>
499 inline Matrix<General, Fixed<M>, Var,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Fixed<M>, Var, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
504 template <
class AT1,
class AT2,
int M,
class Type1,
class Type2>
505 inline Matrix<General, Fixed<M>, Var,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Fixed<M>, Var, AT1> &A,
const Matrix<Type2, Fixed<M>, Var, AT2> &B) {
510 template <
class AT1,
class AT2,
int N,
class Type1,
class Type2,
class Row,
class Col>
511 inline Matrix<General, Var, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Var, Fixed<N>, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
516 template <
class AT1,
class AT2,
int N,
class Type1,
class Type2>
517 inline Matrix<General, Var, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Var, Fixed<N>, AT1> &A,
const Matrix<Type2, Var, Fixed<N>, AT2> &B) {
522 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
523 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Row, Col, AT2> &B) {
528 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
529 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Fixed<M>, Var, AT2> &B) {
534 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
535 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Var, Fixed<N>, AT2> &B) {
540 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
541 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type2, Fixed<M>, Fixed<N>, AT2> &B) {
546 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
547 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type2, Row, Col, AT1> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT2> &B) {
552 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
553 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type2, Fixed<M>, Var, AT1> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT2> &B) {
558 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2>
559 inline Matrix<General, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type2, Var, Fixed<N>, AT1> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT2> &B) {
565 template <
class AT1,
class AT2,
class Type,
class Row1,
class Col1,
class Row2,
class Col2>
566 inline Matrix<Type, Var, Var, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Row1, Col1, AT1> &A,
const Matrix<Type, Row2, Col2, AT2> &B) {
567 Matrix<Type, Var, Var, typename fmatvec::OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
571 template <
class AT1,
class AT2,
class Type,
class Row,
class Col>
572 inline Matrix<Type, Row, Col, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Row, Col, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
573 Matrix<Type, Row, Col, typename fmatvec::OperatorResult<AT1, AT2>::Type> C(A.rows(), A.cols(), NONINIT);
577 template <
class AT1,
class AT2,
int M,
class Type,
class Row,
class Col>
578 inline Matrix<Type, Fixed<M>, Var,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Var, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
583 template <
class AT1,
class AT2,
int M,
class Type>
584 inline Matrix<Type, Fixed<M>, Var,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Var, AT1> &A,
const Matrix<Type, Fixed<M>, Var, AT2> &B) {
589 template <
class AT1,
class AT2,
int N,
class Type,
class Row,
class Col>
590 inline Matrix<Type, Var, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Var, Fixed<N>, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
595 template <
class AT1,
class AT2,
int N,
class Type>
596 inline Matrix<Type, Var, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Var, Fixed<N>, AT1> &A,
const Matrix<Type, Var, Fixed<N>, AT2> &B) {
601 template <
class AT1,
class AT2,
int M,
int N,
class Type,
class Row,
class Col>
602 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Row, Col, AT2> &B) {
607 template <
class AT1,
class AT2,
int M,
int N,
class Type>
608 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Fixed<M>, Var, AT2> &B) {
613 template <
class AT1,
class AT2,
int M,
int N,
class Type>
614 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Var, Fixed<N>, AT2> &B) {
619 template <
class AT1,
class AT2,
int M,
int N,
class Type>
620 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
625 template <
class AT1,
class AT2,
int M,
int N,
class Type,
class Row,
class Col>
626 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Row, Col, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
631 template <
class AT1,
class AT2,
int M,
int N,
class Type>
632 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Fixed<M>, Var, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
637 template <
class AT1,
class AT2,
int M,
int N,
class Type>
638 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const Matrix<Type, Var, Fixed<N>, AT1> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT2> &B) {
643 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
644 inline Matrix<Type1, Row1, Col1, AT>& operator-=(Matrix<Type1, Row1, Col1, AT> &A,
const Matrix<Type2, Row2, Col2, AT> &B) {
650 template <
class AT1,
class AT2,
class Row1,
class Row2>
651 inline SquareMatrix<Var, typename OperatorResult<AT1, AT2>::Type> operator+(
const SquareMatrix<Row1, AT1> &A1,
const SquareMatrix<Row2, AT2> &A2) {
652 SquareMatrix<Var, typename OperatorResult<AT1, AT2>::Type> A3(A1.size(), NONINIT);
656 template <
class AT1,
class AT2,
class Row>
657 inline SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> operator+(
const SquareMatrix<Row, AT1> &A1,
const SquareMatrix<Row, AT2> &A2) {
658 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> A3(A1.size(), NONINIT);
664 template <
class AT1,
class AT2,
class Row1,
class Row2>
665 inline SquareMatrix<Var, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const SquareMatrix<Row1, AT1> &A1,
const SquareMatrix<Row2, AT2> &A2) {
666 SquareMatrix<Var, typename fmatvec::OperatorResult<AT1, AT2>::Type> A3(A1.size(), NONINIT);
670 template <
class AT1,
class AT2,
class Row>
671 inline SquareMatrix<Row, typename fmatvec::OperatorResult<AT1, AT2>::Type> operator-(
const SquareMatrix<Row, AT1> &A1,
const SquareMatrix<Row, AT2> &A2) {
672 SquareMatrix<Row, typename fmatvec::OperatorResult<AT1, AT2>::Type> A3(A1.size(), NONINIT);
682 template <
class Type1,
class Row1,
class Col1,
class Row2,
class Row3,
class AT1,
class AT2>
684 FMATVEC_ASSERT(A.cols() == x.size(), AT2);
685 for (
int i = 0; i < y.size(); i++) {
687 for (
int j = 0; j < x.size(); j++)
688 y.e(i) += A.e(i, j) * x.e(j);
692 template <
class Row1,
class Row2,
class Row3,
class AT1,
class AT2>
694 FMATVEC_ASSERT(A.cols() == x.size(), AT2);
695 for (
int i = 0; i < y.size(); i++) {
697 for (
int j = 0; j < i; j++)
698 y.e(i) += A.ei(i, j) * x.e(j);
699 for (
int j = i; j < x.size(); j++)
700 y.e(i) += A.ej(i, j) * x.e(j);
705 template <
class AT1,
class AT2,
class Type1,
class Row1,
class Col1,
class Row2>
706 inline Vector<Var, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Row1, Col1, AT1> &A,
const Vector<Row2, AT2> &x) {
707 Vector<Var, typename OperatorResult<AT1, AT2>::Type> y(A.rows(), NONINIT);
711 template <
class AT1,
class AT2,
class Type1,
class Row,
class Col>
712 inline Vector<Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Row, Col, AT1> &A,
const Vector<Row, AT2> &x) {
713 Vector<Row, typename OperatorResult<AT1, AT2>::Type> y(A.rows(), NONINIT);
717 template <
class AT1,
class AT2,
int M,
class Type1,
class Col1,
class Row2>
718 inline Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Fixed<M>, Col1, AT1> &A,
const Vector<Row2, AT2> &x) {
719 Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> y(A.rows(), NONINIT);
723 template <
class AT1,
class AT2,
int M,
class Type1>
724 inline Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Fixed<M>, Fixed<M>, AT1> &A,
const Vector<Fixed<M>, AT2> &x) {
725 Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> y(A.rows(), NONINIT);
729 template <
class AT1,
class AT2,
int M,
int N,
class Type,
class Row2>
730 inline Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Vector<Row2, AT2> &x) {
731 Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> y(A.rows(), NONINIT);
735 template <
class AT1,
class AT2,
int M,
int N,
class Type>
736 inline Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Fixed<M>, Fixed<N>, AT1> &A,
const Vector<Fixed<N>, AT2> &x) {
737 Vector<Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> y(A.rows(), NONINIT);
743 template <
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Col3,
class AT1,
class AT2>
745 FMATVEC_ASSERT(x.size() == A.rows(), AT2);
746 for (
int i = 0; i < y.size(); i++) {
748 for (
int j = 0; j < x.size(); j++)
749 y.e(i) += x.e(j) * A.e(j, i);
753 template <
class Col1,
class Row2,
class Col3,
class AT1,
class AT2>
755 FMATVEC_ASSERT(x.size() == A.rows(), AT2);
756 for (
int i = 0; i < y.size(); i++) {
758 for (
int j = 0; j < i; j++)
759 y.e(i) += x.e(j) * A.ej(j, i);
760 for (
int j = i; j < x.size(); j++)
761 y.e(i) += x.e(j) * A.ei(j, i);
765 template <
class AT1,
class AT2,
class Type2,
class Col2,
class Row1,
class Col1>
766 inline RowVector<Var, typename OperatorResult<AT1, AT2>::Type> operator*(
const RowVector<Col2, AT1> &x,
const Matrix<Type2, Row1, Col1, AT2> &A) {
767 RowVector<Var, typename OperatorResult<AT1, AT2>::Type> y(A.cols(), NONINIT);
771 template <
class AT1,
class AT2,
class Type2,
class Row,
class Col>
772 inline RowVector<Col, typename OperatorResult<AT1, AT2>::Type> operator*(
const RowVector<Col, AT1> &x,
const Matrix<Type2, Row, Col, AT2> &A) {
773 RowVector<Col, typename OperatorResult<AT1, AT2>::Type> y(A.cols(), NONINIT);
777 template <
class AT1,
class AT2,
int N,
class Type2,
class Col1,
class Row2>
778 inline RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const RowVector<Col1, AT1> &x,
const Matrix<Type2, Row2, Fixed<N>, AT2> &A) {
779 RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> y(A.cols(), NONINIT);
783 template <
class AT1,
class AT2,
int N,
class Type2>
784 inline RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const RowVector<Fixed<N>, AT1> &x,
const Matrix<Type2, Fixed<N>, Fixed<N>, AT2> &A) {
785 RowVector<Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> y(A.cols(), NONINIT);
791 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT1,
class AT2>
792 inline void mult(
const Matrix<Type1, Row1, Col1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2, Matrix<Type3, Row3, Col3,
typename fmatvec::OperatorResult<AT1, AT2>::Type> &A3) {
793 FMATVEC_ASSERT(A1.cols() == A2.rows(), AT2);
794 for (
int i = 0; i < A3.rows(); i++) {
795 for (
int k = 0; k < A3.cols(); k++) {
797 for (
int j = 0; j < A1.cols(); j++)
798 A3.e(i, k) += A1.e(i, j) * A2.e(j, k);
802 template <
class Row1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT1,
class AT2>
803 inline void mult(
const Matrix<Symmetric, Row1, Row1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2, Matrix<Type3, Row3, Col3,
typename fmatvec::OperatorResult<AT1, AT2>::Type> &A3) {
804 FMATVEC_ASSERT(A1.size() == A2.rows(), AT2);
805 for (
int i = 0; i < A3.rows(); i++) {
806 for (
int k = 0; k < A3.cols(); k++) {
808 for (
int j = 0; j < i; j++)
809 A3.e(i, k) += A1.ei(i, j) * A2.e(j, k);
810 for (
int j = i; j < A1.cols(); j++)
811 A3.e(i, k) += A1.ej(i, j) * A2.e(j, k);
815 template <
class Row1,
class Row2,
class Row3,
class AT1,
class AT2>
816 inline void mult(
const Matrix<Diagonal, Row1, Row1, AT1> &A1,
const Matrix<Diagonal, Row2, Row2, AT2> &A2, Matrix<Diagonal, Row3, Row3,
typename fmatvec::OperatorResult<AT1, AT2>::Type> &A3) {
817 FMATVEC_ASSERT(A1.size() == A2.size(), AT2);
818 for (
int i = 0; i < A3.size(); i++)
819 A3.e(i) = A1.e(i) * A2.e(i);
822 template <
class AT1,
class AT2,
class Type1,
class Type2,
class Row1,
class Col1,
class Row2,
class Col2>
823 inline Matrix<General, Var, Var, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Row1, Col1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2) {
824 Matrix<General, Var, Var, typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
828 template <
class AT1,
class AT2,
class Type1,
class Type2,
class Row,
class Col>
829 inline Matrix<General, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Row, Col, AT1> &A1,
const Matrix<Type2, Row, Col, AT2> &A2) {
830 Matrix<General, Row, Col, typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
834 template <
class AT1,
class AT2,
int M,
class Type1,
class Type2,
class Col1,
class Row2,
class Col2>
835 inline Matrix<General, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Fixed<M>, Col1, AT1> &A1,
const Matrix<Type2, Row2, Col2, AT2> &A2) {
836 Matrix<General, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
840 template <
class AT1,
class AT2,
int N,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2>
841 inline Matrix<General, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Row1, Col1, AT1> &A1,
const Matrix<Type2, Row2, Fixed<N>, AT2> &A2) {
842 Matrix<General, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
846 template <
class AT1,
class AT2,
int M,
int N,
class Type1,
class Type2,
class Col1,
class Row2>
847 inline Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Fixed<M>, Col1, AT1> &A1,
const Matrix<Type2, Row2, Fixed<N>, AT2> &A2) {
848 Matrix<General, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
852 template <
class AT1,
class AT2,
int M,
class Type1,
class Type2>
853 inline Matrix<General, Fixed<M>, Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type1, Fixed<M>, Fixed<M>, AT1> &A1,
const Matrix<Type2, Fixed<M>, Fixed<M>, AT2> &A2) {
854 Matrix<General, Fixed<M>, Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
858 template <
class AT1,
class AT2,
class Type,
class Row1,
class Col1,
class Row2,
class Col2>
859 inline Matrix<Type, Var, Var, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Row1, Col1, AT1> &A1,
const Matrix<Type, Row2, Col2, AT2> &A2) {
860 Matrix<Type, Var, Var, typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
864 template <
class AT1,
class AT2,
class Type,
class Row,
class Col>
865 inline Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Row, Col, AT1> &A1,
const Matrix<Type, Row, Col, AT2> &A2) {
866 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
870 template <
class AT1,
class AT2,
int M,
class Type,
class Col1,
class Row2,
class Col2>
871 inline Matrix<Type, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Fixed<M>, Col1, AT1> &A1,
const Matrix<Type, Row2, Col2, AT2> &A2) {
872 Matrix<Type, Fixed<M>, Var,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
876 template <
class AT1,
class AT2,
int N,
class Type,
class Row1,
class Col1,
class Row2>
877 inline Matrix<Type, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Row1, Col1, AT1> &A1,
const Matrix<Type, Row2, Fixed<N>, AT2> &A2) {
878 Matrix<Type, Var, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
882 template <
class AT1,
class AT2,
int M,
int N,
class Type,
class Col1,
class Row2>
883 inline Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Fixed<M>, Col1, AT1> &A1,
const Matrix<Type, Row2, Fixed<N>, AT2> &A2) {
884 Matrix<Type, Fixed<M>, Fixed<N>,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
888 template <
class AT1,
class AT2,
int M,
class Type>
889 inline Matrix<Type, Fixed<M>, Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Type, Fixed<M>, Fixed<M>, AT1> &A1,
const Matrix<Type, Fixed<M>, Fixed<M>, AT2> &A2) {
890 Matrix<Type, Fixed<M>, Fixed<M>,
typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
896 template <
class AT1,
class AT2,
class Row1,
class Row2>
897 inline SquareMatrix<Var, typename OperatorResult<AT1, AT2>::Type> operator*(
const SquareMatrix<Row1, AT1> &A1,
const SquareMatrix<Row2, AT2> &A2) {
898 SquareMatrix<Var, typename OperatorResult<AT1, AT2>::Type> A3(A1.size(), NONINIT);
902 template <
class AT1,
class AT2,
class Row>
903 inline SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const SquareMatrix<Row, AT1> &A1,
const SquareMatrix<Row, AT2> &A2) {
904 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> A3(A1.size(), NONINIT);
910 template <
class AT1,
class AT2,
class Row1,
class Row2>
911 inline Matrix<General, Var, Var, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Symmetric, Row1, Row1, AT1> &A1,
const Matrix<Symmetric, Row2, Row2, AT2> &A2) {
912 Matrix<General, Var, Var, typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
916 template <
class AT1,
class AT2,
class Row>
917 inline Matrix<General, Row, Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Symmetric, Row, Row, AT1> &A1,
const Matrix<Symmetric, Row, Row, AT2> &A2) {
918 Matrix<General, Row, Row, typename OperatorResult<AT1, AT2>::Type> A3(A1.rows(), A2.cols(), NONINIT);
931 template <
class Row,
class AT1,
class AT2>
936 for (
int i = 0; i < x.size(); i++)
937 y.e(i) = x.e(i) * alpha;
946 template <
class Row,
class AT1,
class AT2>
951 for (
int i = 0; i < x.size(); i++)
952 y.e(i) = x.e(i) * alpha;
957 template <
class Row,
class AT1,
class AT2>
958 inline Vector<Row, AT1> operator*=(Vector<Row, AT1> &x,
const AT2 &alpha) {
959 for (
int i = 0; i < x.size(); i++)
964 template <
class Row,
class AT1,
class AT2>
965 inline Vector<Row, typename OperatorResult<AT1, AT2>::Type> operator/(
const Vector<Row, AT1> &x,
const AT2 &alpha) {
966 Vector<Row, typename OperatorResult<AT1, AT2>::Type> y(x.size(), NONINIT);
967 for (
int i = 0; i < x.size(); i++)
968 y.e(i) = x.e(i) / alpha;
972 template <
class Row,
class AT1,
class AT2>
973 inline Vector<Row, AT1> operator/=(Vector<Row, AT1> &x,
const AT2 &alpha) {
974 for (
int i = 0; i < x.size(); i++)
984 template <
class Col,
class AT1,
class AT2>
989 for (
int i = 0; i < x.size(); i++)
990 y.e(i) = x.e(i) * alpha;
999 template <
class Col,
class AT1,
class AT2>
1004 for (
int i = 0; i < x.size(); i++)
1005 y.e(i) = x.e(i) * alpha;
1010 template <
class Col,
class AT1,
class AT2>
1011 inline RowVector<Col, AT1> operator*=(RowVector<Col, AT1> &x,
const AT2 &alpha) {
1012 for (
int i = 0; i < x.size(); i++)
1017 template <
class Col,
class AT1,
class AT2>
1018 inline RowVector<Col, typename OperatorResult<AT1, AT2>::Type> operator/(
const RowVector<Col, AT1> &x,
const AT2 &a) {
1019 RowVector<Col, typename OperatorResult<AT1, AT2>::Type> y(x.size(), NONINIT);
1020 for (
int i = 0; i < x.size(); i++)
1021 y.e(i) = x.e(i) / a;
1025 template <
class Col,
class AT1,
class AT2>
1026 inline RowVector<Col, AT1> operator/=(RowVector<Col, AT1> &x,
const AT2 &a) {
1027 for (
int i = 0; i < x.size(); i++)
1042 template <
class Col,
class Row,
class AT1,
class AT2>
1045 FMATVEC_ASSERT(x.size() == y.size(), AT2);
1049 for (
int i = 0; i < x.size(); i++)
1050 res += x.e(i) * y.e(i);
1060 template <
class Row,
class AT>
1063 FMATVEC_ASSERT(x.size() == y.size(), AT);
1067 for (
int i = 0; i < x.size(); i++)
1068 res += x.e(i) * y.e(i);
1078 template <
class Row1,
class Row2,
class AT1,
class AT2>
1081 FMATVEC_ASSERT(x.size() == 3, AT2);
1082 FMATVEC_ASSERT(y.size() == 3, AT2);
1086 z.e(0) = x.e(1) * y.e(2) - x.e(2) * y.e(1);
1087 z.e(1) = x.e(2) * y.e(0) - x.e(0) * y.e(2);
1088 z.e(2) = x.e(0) * y.e(1) - x.e(1) * y.e(0);
1098 template <
class Row,
class AT>
1101 FMATVEC_ASSERT(a.size() == 3, AT);
1102 FMATVEC_ASSERT(x.size() == 3, AT);
1103 FMATVEC_ASSERT(y.size() == 3, AT);
1105 return a.e(0) * (x.e(1) * y.e(2) - x.e(2) * y.e(1)) + a.e(1) * (x.e(2) * y.e(0) - x.e(0) * y.e(2)) + a.e(2) * (x.e(0) * y.e(1) - x.e(1) * y.e(0));
1120 template <
class Type,
class Row,
class Col,
class AT1,
class AT2>
1125 for (
int i = 0; i < A.
rows(); i++)
1126 for (
int j = 0; j < A.
cols(); j++)
1127 B.e(i, j) = A.e(i, j) * alpha;
1132 template <
class Type,
class Row,
class Col,
class AT1,
class AT2>
1133 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator*(
const AT1 &alpha,
const Matrix<Type, Row, Col, AT2> &A) {
1135 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> B(A.rows(), A.cols(), NONINIT);
1137 for (
int i = 0; i < A.rows(); i++)
1138 for (
int j = 0; j < A.cols(); j++)
1139 B.e(i, j) = A.e(i, j) * alpha;
1144 template <
class Row,
class AT1,
class AT2>
1145 inline Matrix<Symmetric, Row, Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const AT1 &alpha,
const Matrix<Symmetric, Row, Row, AT2> &A) {
1146 Matrix<Symmetric, Row, Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), A.size(), NONINIT);
1147 for (
int i = 0; i < A.size(); i++)
1148 for (
int j = i; j < A.size(); j++)
1149 B.ej(i, j) = A.ej(i, j) * alpha;
1153 template <
class Row,
class AT1,
class AT2>
1154 inline Matrix<Symmetric, Row, Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Symmetric, Row, Row, AT1> &A,
const AT2 &alpha) {
1155 Matrix<Symmetric, Row, Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), A.size(), NONINIT);
1156 for (
int i = 0; i < A.size(); i++)
1157 for (
int j = i; j < A.size(); j++)
1158 B.ej(i, j) = A.ej(i, j) * alpha;
1162 template <
class AT1,
class AT2>
1163 inline Matrix<Diagonal, Ref, Ref, typename OperatorResult<AT1, AT2>::Type> operator*(
const AT1 &alpha,
const Matrix<Diagonal, Ref, Ref, AT2> &A) {
1164 Matrix<Diagonal, Ref, Ref, typename OperatorResult<AT1, AT2>::Type> B(A.rows(), A.cols(), NONINIT);
1165 for (
int i = 0; i < A.rows(); i++)
1166 B.e(i) = A.e(i) * alpha;
1170 template <
class AT1,
class AT2>
1171 inline Matrix<Diagonal, Ref, Ref, typename OperatorResult<AT1, AT2>::Type> operator*(
const Matrix<Diagonal, Ref, Ref, AT1> &A,
const AT2 &alpha) {
1172 Matrix<Diagonal, Ref, Ref, typename OperatorResult<AT1, AT2>::Type> B(A.rows(), A.cols(), NONINIT);
1173 for (
int i = 0; i < A.size(); i++)
1174 B.e(i) = A.e(i) * alpha;
1178 template <
class Type,
class Row,
class Col,
class AT1,
class AT2>
1179 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator/(
const Matrix<Type, Row, Col, AT1> &A,
const AT2 &alpha) {
1181 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> B(A.rows(), A.cols(), NONINIT);
1183 for (
int i = 0; i < A.rows(); i++)
1184 for (
int j = 0; j < A.cols(); j++)
1185 B.e(i, j) = A.e(i, j) / alpha;
1190 template <
class Row,
class AT1,
class AT2>
1191 inline Matrix<Symmetric, Row, Row, typename OperatorResult<AT1, AT2>::Type> operator/(
const Matrix<Symmetric, Row, Row, AT1> &A,
const AT2 &alpha) {
1192 Matrix<Symmetric, Row, Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), A.size(), NONINIT);
1193 for (
int i = 0; i < A.size(); i++)
1194 for (
int j = i; j < A.size(); j++)
1195 B.ej(i, j) = A.ej(i, j) / alpha;
1199 template <
class Row,
class AT1,
class AT2>
1200 inline Matrix<Diagonal, Row, Row, typename OperatorResult<AT1, AT2>::Type> operator/(
const Matrix<Diagonal, Row, Row, AT1> &A,
const AT2 &alpha) {
1201 Matrix<Diagonal, Row, Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), A.size(), NONINIT);
1202 for (
int i = 0; i < A.size(); i++)
1203 B.e(i) = A.e(i) / alpha;
1207 template <
class Row,
class AT1,
class AT2>
1208 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const SquareMatrix<Row, AT1> &A,
const AT2 &alpha) {
1210 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), NONINIT);
1212 for (
int i = 0; i < A.size(); i++)
1213 for (
int j = 0; j < A.size(); j++)
1214 B.e(i, j) = A.e(i, j) * alpha;
1219 template <
class Row,
class AT1,
class AT2>
1220 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> operator*(
const AT1 &alpha,
const SquareMatrix<Row, AT2> &A) {
1222 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), NONINIT);
1224 for (
int i = 0; i < A.size(); i++)
1225 for (
int j = 0; j < A.size(); j++)
1226 B.e(i, j) = A.e(i, j) * alpha;
1231 template <
class Row,
class AT1,
class AT2>
1232 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> operator/(
const SquareMatrix<Row, AT1> &A,
const AT2 &alpha) {
1234 SquareMatrix<Row, typename OperatorResult<AT1, AT2>::Type> B(A.size(), NONINIT);
1236 for (
int i = 0; i < A.size(); i++)
1237 for (
int j = 0; j < A.size(); j++)
1238 B.e(i, j) = A.e(i, j) / alpha;
1243 template <
class Type,
class Row,
class Col,
class AT1,
class AT2>
1244 Matrix<Type, Row, Col, typename OperatorResult<AT1, AT2>::Type> operator*=(Matrix<Type, Row, Col, AT1> &A,
const AT2 &alpha) {
1245 for (
int i = 0; i < A.rows(); i++)
1246 for (
int j = 0; j < A.cols(); j++)
1252 template <
class Row,
class AT1,
class AT2>
1253 inline Matrix<Symmetric, Row, Row, AT1> operator*=(Matrix<Symmetric, Row, Row, AT1> &A,
const AT2 &alpha) {
1254 for (
int i = 0; i < A.size(); i++)
1255 for (
int j = i; j < A.size(); j++)
1256 A.ej(i, j) *= alpha;
1260 template <
class Row,
class AT1,
class AT2>
1261 inline Matrix<Diagonal, Row, Row, AT1> operator*=(Matrix<Diagonal, Row, Row, AT1> &A,
const AT2 &alpha) {
1262 for (
int i = 0; i < A.size(); i++)
1267 template <
class Type,
class Row,
class Col,
class AT1,
class AT2>
1268 Matrix<Type, Row, Col, AT1> operator/=(Matrix<Type, Row, Col, AT1> &A,
const AT2 &alpha) {
1269 for (
int i = 0; i < A.rows(); i++)
1270 for (
int j = 0; j < A.cols(); j++)
1276 template <
class Row,
class AT1,
class AT2>
1277 inline Matrix<Symmetric, Row, Row, AT1> operator/=(Matrix<Symmetric, Row, Row, AT1> &A,
const AT2 &alpha) {
1278 for (
int i = 0; i < A.size(); i++)
1279 for (
int j = i; j < A.size(); j++)
1280 A.ej(i, j) /= alpha;
1284 template <
class Row,
class AT1,
class AT2>
1285 inline Matrix<Diagonal, Row, Row, AT1> operator/=(Matrix<Diagonal, Row, Row, AT1> &A,
const AT2 &alpha) {
1286 for (
int i = 0; i < A.size(); i++)
1300 template <
class Row,
class AT>
1305 for (
int i = 0; i < x.size(); i++)
1316 template <
class Col,
class AT>
1321 for (
int i = 0; i < a.size(); i++)
1332 template <
class Row,
class AT>
1337 for (
int i = 0; i < A.size(); i++)
1338 for (
int j = 0; j < A.size(); j++)
1339 B.e(i, j) = -A.e(i, j);
1349 template <
class Type,
class Row,
class Col,
class AT>
1354 for (
int i = 0; i < A.
rows(); i++)
1355 for (
int j = 0; j < A.
cols(); j++)
1356 B.e(i, j) = -A.e(i, j);
1369 template <
class Row,
class AT>
1379 template <
class Col,
class AT>
1390 template <
class Type,
class Row,
class Col,
class AT>
1401 template <
class Row,
class AT>
1441 template <
class Row,
class AT>
1442 inline AT nrmInf(
const Vector<Row, AT> &x) {
1444 for (
int i = 0; i < x.size(); i++)
1445 if (c < fabs(x.e(i)))
1450 template <
class Row,
class AT>
1451 inline AT nrmInf(
const RowVector<Row, AT> &x) {
1453 for (
int i = 0; i < x.size(); i++)
1454 if (c < fabs(x.e(i)))
1459 template <
class Row,
class AT>
1460 inline typename OperatorResult<AT, AT>::Type nrm2(
const Vector<Row, AT> &x) {
1461 typename OperatorResult<AT, AT>::Type c=
typename OperatorResult<AT, AT>::Type();
1462 for (
int i = 0; i < x.size(); i++)
1463 c += pow(x.e(i), 2);
1467 template <
class Col,
class AT>
1468 inline typename OperatorResult<AT, AT>::Type nrm2(
const RowVector<Col, AT> &x) {
1469 typename OperatorResult<AT, AT>::Type c=
typename OperatorResult<AT, AT>::Type();
1470 for (
int i = 0; i < x.size(); i++)
1471 c += pow(x.e(i), 2);
1488 template <
class Row,
class AT>
1496 B.e(0, 1) = -x.e(2);
1499 B.e(1, 2) = -x.e(0);
1500 B.e(2, 0) = -x.e(1);
1511 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
1520 for (
int i = 0; i < A.
rows(); i++)
1521 for (
int j = 0; j < A.
cols(); j++)
1522 if (A(i, j) != B(i, j))
1533 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
1539 for (
int i = 0; i < A.
rows(); i++)
1540 for (
int j = 0; j < A.
cols(); j++)
1541 if (A(i, j) != B(i, j))
1552 template <
class Row,
class AT>
1555 FMATVEC_ASSERT(x.size() > 0, AT);
1556 AT maximum = x.e(0);
1557 for (
int i = 1; i < x.size(); i++) {
1558 if (x.e(i) > maximum)
1569 template <
class Row,
class AT>
1572 FMATVEC_ASSERT(x.size() > 0, AT);
1573 AT maximum = x.e(0);
1575 for (
int i = 1; i < x.size(); i++) {
1576 if (x.e(i) > maximum) {
1589 template <
class Row,
class AT>
1592 FMATVEC_ASSERT(x.size() > 0, AT);
1593 AT minimum = x.e(0);
1594 for (
int i = 1; i < x.size(); i++) {
1595 if (x.e(i) < minimum)
1606 template <
class Row,
class AT>
1609 FMATVEC_ASSERT(x.size() > 0, AT);
1610 AT minimum = x.e(0);
1612 for (
int i = 1; i < x.size(); i++) {
1613 if (x.e(i) < minimum) {
1631 FMATVEC_ASSERT(A_.
rows() > 0, AT);
1632 FMATVEC_ASSERT(A_.
cols() > 0, AT);
1633 FMATVEC_ASSERT(A_.
cols() > PivotCol, AT);
1638 for (i = 1; i <= N - 1; i++) {
1639 for (j = 0; j < N - 1; j++) {
1640 if (A(j, PivotCol) > A(j + 1, PivotCol)) {
1642 A.set(j, A.row(j + 1));
1656 int i = l - 1, j = r;
1659 int m = l + (r - l) / 2;
1660 if (A(l, PivotCol) > A(m, PivotCol)) {
1665 if (A(l, PivotCol) > A(r, PivotCol)) {
1670 else if (A(r, PivotCol) > A(m, PivotCol)) {
1678 while(A(++i,PivotCol) < A(r,PivotCol));
1679 while(A(--j,PivotCol) > A(r,PivotCol) && j>i);
1711 template <
class Row,
class Col,
class AT>
1712 inline Matrix<Symmetric, Col, Col, AT> JTJ(
const Matrix<General, Row, Col, AT> &A) {
1713 Matrix<Symmetric, Col, Col, AT> S(A.cols(), A.cols(), NONINIT);
1714 for (
int i = 0; i < A.cols(); i++) {
1715 for (
int k = i; k < A.cols(); k++) {
1717 for (
int j = 0; j < A.rows(); j++)
1718 S.ej(i, k) += A.e(j, i) * A.e(j, k);
1724 template <
class Row,
class Col,
class AT>
1725 inline Matrix<Symmetric, Col, Col, AT> JTMJ(
const Matrix<Symmetric, Row, Row, AT> &B,
const Matrix<General, Row, Col, AT> &A) {
1727 Matrix<Symmetric, Col, Col, AT> S(A.cols(), A.cols(), NONINIT);
1728 Matrix<General, Row, Col, AT> C = B * A;
1730 for (
int i = 0; i < A.cols(); i++) {
1731 for (
int k = i; k < A.cols(); k++) {
1733 for (
int j = 0; j < A.rows(); j++)
1734 S.ej(i, k) += A.e(j, i) * C.e(j, k);
1740 template <
class Row,
class Col,
class AT>
1741 inline Matrix<Symmetric, Row, Row, AT> JMJT(
const Matrix<General, Row, Col, AT> &A,
const Matrix<Symmetric, Col, Col, AT> &B) {
1743 Matrix<Symmetric, Row, Row, AT> S(A.rows(), A.rows(), NONINIT);
1744 Matrix<General, Row, Col, AT> C = A * B;
1746 for (
int i = 0; i < S.size(); i++) {
1747 for (
int k = i; k < S.size(); k++) {
1749 for (
int j = 0; j < A.cols(); j++)
1750 S.ej(i, k) += C.e(k, j) * A.e(i, j);
RowVector< Row, AT > trans(const Vector< Row, AT > &x)
Transpose of a vector.
Definition: linear_algebra.h:1370
Matrix< General, Ref, Ref, AT > quickSortMedian(const Matrix< General, Ref, Ref, AT > &A_, int PivotCol)
Modified QuickSort Algorithm (unstable sorting Algorithm )
Definition: linear_algebra.h:1703
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
int rows() const
Number of rows.
Definition: general_matrix.h:304
void quicksortmedian_intern(Matrix< General, Ref, Ref, AT > &A, int PivotCol, RowVector< Ref, AT > &tmp, int l, int r)
Definition: linear_algebra.h:1653
int minIndex(const Vector< Row, AT > &x)
Index of minimum value.
Definition: linear_algebra.h:1607
Vector< Fixed< 3 >, typename OperatorResult< AT1, AT2 >::Type > crossProduct(const Vector< Row1, AT1 > &x, const Vector< Row2, AT2 > &y)
Cross product.
Definition: linear_algebra.h:1079
This is a rowvector class of general shape in dense storage format.
Definition: row_vector.h:36
AT min(const Vector< Row, AT > &x)
Minimum value.
Definition: linear_algebra.h:1590
Matrix< General, Ref, Ref, AT > bubbleSort(const Matrix< General, Ref, Ref, AT > &A_, int PivotCol)
Bubble Sort Algorithm (stable sorting Algorithm )
Definition: linear_algebra.h:1629
int maxIndex(const Vector< Row, AT > &x)
Index of maximum value.
Definition: linear_algebra.h:1570
int cols() const
Number of columns.
This is a matrix class for general matrices.
Definition: general_matrix.h:41
Namespace fmatvec.
Definition: _memory.cc:28
bool operator==(const Matrix< Type1, Row1, Col1, AT > &A, const Matrix< Type2, Row2, Col2, AT > &B)
Matrix-matrix comparison.
Definition: linear_algebra.h:1512
int cols() const
Number of columns.
Definition: general_matrix.h:310
const RowVector< Ref, AT > row(int i) const
Row operator.
Definition: general_matrix.h:516
bool operator!=(const Matrix< Type1, Row1, Col1, AT > &A, const Matrix< Type2, Row2, Col2, AT > &B)
Matrix-matrix comparison.
Definition: linear_algebra.h:1534
AT max(const Vector< Row, AT > &x)
Maximum value.
Definition: linear_algebra.h:1553
double tripleProduct(const Vector< Row, AT > &a, const Vector< Row, AT > &x, const Vector< Row, AT > &y)
Triple product.
Definition: linear_algebra.h:1099
SquareMatrix< Row, AT > tilde(const Vector< Row, AT > &x)
Tilde operator.
Definition: linear_algebra.h:1489
int rows() const
Number of rows.
AT scalarProduct(const Vector< Row, AT > &x, const Vector< Row, AT > &y)
Scalar product.
Definition: linear_algebra.h:1061