22 #ifndef linear_algebra_h
23 #define linear_algebra_h
27 #include "square_matrix.h"
29 #include "row_vector.h"
30 #include "fixed_square_matrix.h"
31 #include "fixed_vector.h"
32 #include "fixed_row_vector.h"
33 #include "fixed_symmetric_matrix.h"
34 #include "var_square_matrix.h"
35 #include "var_symmetric_matrix.h"
36 #include "var_vector.h"
37 #include "var_row_vector.h"
38 #include "var_fixed_general_matrix.h"
39 #include "fixed_var_general_matrix.h"
54 #ifndef FMATVEC_NO_SIZE_CHECK
62 for (
int i = 0; i < x.
size(); i++)
63 z.er(i) = x.et(i) + y.et(i);
65 for (
int i = 0; i < x.
size(); i++)
66 z.er(i) = x.er(i) + y.et(i);
70 for (
int i = 0; i < x.
size(); i++)
71 z.er(i) = x.et(i) + y.er(i);
73 for (
int i = 0; i < x.
size(); i++)
74 z.er(i) = x.er(i) + y.er(i);
81 template <
class Row1,
class Row2,
class Row3,
class AT>
82 inline void add(
const Vector<Row1, AT> &a1,
const Vector<Row2, AT> &a2, Vector<Row3, AT> &a3) {
83 #ifndef FMATVEC_NO_SIZE_CHECK
84 assert(a1.size() == a2.size());
86 for (
int i = 0; i < a1.size(); i++)
87 a3.e(i) = a1.e(i) + a2.e(i);
90 template <
class Row1,
class Row2,
class AT>
91 inline void add(Vector<Row1, AT> &a1,
const Vector<Row2, AT> &a2) {
92 #ifndef FMATVEC_NO_SIZE_CHECK
93 assert(a1.size() == a2.size());
95 for (
int i = 0; i < a1.size(); i++)
99 template <
class Row1,
class Row2,
class Row3,
class AT>
100 inline void sub(
const Vector<Row1, AT> &a1,
const Vector<Row2, AT> &a2, Vector<Row3, AT> &a3) {
101 #ifndef FMATVEC_NO_SIZE_CHECK
102 assert(a1.size() == a2.size());
104 for (
int i = 0; i < a1.size(); i++)
105 a3.e(i) = a1.e(i) - a2.e(i);
108 template <
class Row1,
class Row2,
class AT>
109 inline void sub(Vector<Row1, AT> &a1,
const Vector<Row2, AT> &a2) {
110 #ifndef FMATVEC_NO_SIZE_CHECK
111 assert(a1.size() == a2.size());
113 for (
int i = 0; i < a1.size(); i++)
118 template <
class AT,
class Row1,
class Row2>
119 inline Vector<Var, AT>
operator+(
const Vector<Row1, AT> &a,
const Vector<Row2, AT> &b) {
120 Vector<Var, AT> c(a.size(), NONINIT);
124 template <
class AT,
class Row>
125 inline Vector<Row, AT>
operator+(
const Vector<Row, AT> &a,
const Vector<Row, AT> &b) {
126 Vector<Row, AT> c(a.size(), NONINIT);
130 template <
class AT,
int M,
class Row>
131 inline Vector<Fixed<M>, AT>
operator+(
const Vector<Fixed<M>, AT> &a,
const Vector<Row, AT> &b) {
132 Vector<Fixed<M>, AT> c(a.size(), NONINIT);
136 template <
class AT,
int M>
137 inline Vector<Fixed<M>, AT>
operator+(
const Vector<Fixed<M>, AT> &a,
const Vector<Fixed<M>, AT> &b) {
138 Vector<Fixed<M>, AT> c(a.size(), NONINIT);
142 template <
class AT,
class Row1,
class Row2>
143 inline Vector<Row1, AT> operator+=(
const Vector<Row1, AT> &a_,
const Vector<Row2, AT> &b) {
144 Vector<Row1, AT> &a =
const_cast<Vector<Row1, AT> &
>(a_);
150 template <
class AT,
class Row1,
class Row2>
156 template <
class AT,
class Row>
157 inline Vector<Row, AT>
operator-(
const Vector<Row, AT> &a,
const Vector<Row, AT> &b) {
158 Vector<Row, AT> c(a.size(), NONINIT);
162 template <
class AT,
int M,
class Row2>
163 inline Vector<Fixed<M>, AT>
operator-(
const Vector<Fixed<M>, AT> &a,
const Vector<Row2, AT> &b) {
164 Vector<Fixed<M>, AT> c(a.size(), NONINIT);
168 template <
class AT,
int M>
169 inline Vector<Fixed<M>, AT>
operator-(
const Vector<Fixed<M>, AT> &a,
const Vector<Fixed<M>, AT> &b) {
170 Vector<Fixed<M>, AT> c(a.size(), NONINIT);
174 template <
class AT,
class Row1,
class Row2>
175 inline Vector<Row1, AT> operator-=(
const Vector<Row1, AT> &a_,
const Vector<Row2, AT> &b) {
176 Vector<Row1, AT> &a =
const_cast<Vector<Row1, AT> &
>(a_);
182 template <
class Col1,
class Col2,
class Col3,
class AT>
183 inline void add(
const RowVector<Col1, AT> &a1,
const RowVector<Col2, AT> &a2, RowVector<Col3, AT> &a3) {
184 #ifndef FMATVEC_NO_SIZE_CHECK
185 assert(a1.size() == a2.size());
187 for (
int i = 0; i < a1.size(); i++)
188 a3.e(i) = a1.e(i) + a2.e(i);
191 template <
class Col1,
class Col2,
class AT>
192 inline void add(RowVector<Col1, AT> &a1,
const RowVector<Col2, AT> &a2) {
193 #ifndef FMATVEC_NO_SIZE_CHECK
194 assert(a1.size() == a2.size());
196 for (
int i = 0; i < a1.size(); i++)
200 template <
class Col1,
class Col2,
class Col3,
class AT>
201 inline void sub(
const RowVector<Col1, AT> &a1,
const RowVector<Col2, AT> &a2, RowVector<Col3, AT> &a3) {
202 #ifndef FMATVEC_NO_SIZE_CHECK
203 assert(a1.size() == a2.size());
205 for (
int i = 0; i < a1.size(); i++)
206 a3.e(i) = a1.e(i) - a2.e(i);
209 template <
class Col1,
class Col2,
class AT>
210 inline void sub(RowVector<Col1, AT> &a1,
const RowVector<Col2, AT> &a2) {
211 #ifndef FMATVEC_NO_SIZE_CHECK
212 assert(a1.size() == a2.size());
214 for (
int i = 0; i < a1.size(); i++)
219 template <
class AT,
class Col1,
class Col2>
220 inline RowVector<Var, AT>
operator+(
const RowVector<Col1, AT> &a,
const RowVector<Col2, AT> &b) {
221 RowVector<Var, AT> c(a.size(), NONINIT);
225 template <
class AT,
class Col>
226 inline RowVector<Col, AT>
operator+(
const RowVector<Col, AT> &a,
const RowVector<Col, AT> &b) {
227 RowVector<Col, AT> c(a.size(), NONINIT);
231 template <
class AT,
int N,
class Col2>
232 inline RowVector<Fixed<N>, AT>
operator+(
const RowVector<Fixed<N>, AT> &a,
const RowVector<Col2, AT> &b) {
233 RowVector<Fixed<N>, AT> c(a.size(), NONINIT);
237 template <
class AT,
int N>
238 inline RowVector<Fixed<N>, AT>
operator+(
const RowVector<Fixed<N>, AT> &a,
const RowVector<Fixed<N>, AT> &b) {
239 RowVector<Fixed<N>, AT> c(a.size(), NONINIT);
243 template <
class AT,
class Col1,
class Col2>
244 inline RowVector<Col1, AT> operator+=(
const RowVector<Col1, AT> &a_,
const RowVector<Col2, AT> &b) {
245 RowVector<Col1, AT> &a =
const_cast<RowVector<Col1, AT> &
>(a_);
251 template <
class AT,
class Col1,
class Col2>
257 template <
class AT,
class Col>
258 inline RowVector<Col, AT>
operator-(
const RowVector<Col, AT> &a,
const RowVector<Col, AT> &b) {
259 RowVector<Col, AT> c(a.size(), NONINIT);
263 template <
class AT,
int N,
class Col2>
264 inline RowVector<Fixed<N>, AT>
operator-(
const RowVector<Fixed<N>, AT> &a,
const RowVector<Col2, AT> &b) {
265 RowVector<Fixed<N>, AT> c(a.size(), NONINIT);
269 template <
class AT,
int N>
270 inline RowVector<Fixed<N>, AT>
operator-(
const RowVector<Fixed<N>, AT> &a,
const RowVector<Fixed<N>, AT> &b) {
271 RowVector<Fixed<N>, AT> c(a.size(), NONINIT);
275 template <
class AT,
class Col1,
class Col2>
276 inline RowVector<Col1, AT> operator-=(
const RowVector<Col1, AT> &a_,
const RowVector<Col2, AT> &b) {
277 RowVector<Col1, AT> &a =
const_cast<RowVector<Col1, AT> &
>(a_);
283 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT>
284 inline void add(
const Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2, Matrix<Type3, Row3, Col3, AT> &A3) {
285 #ifndef FMATVEC_NO_SIZE_CHECK
286 assert(A1.rows() == A2.rows());
287 assert(A1.cols() == A2.cols());
289 for (
int i = 0; i < A1.rows(); i++)
290 for (
int j = 0; j < A2.cols(); j++)
291 A3.e(i, j) = A1.e(i, j) + A2.e(i, j);
294 template <
class Row1,
class Row2,
class Row3,
class AT>
295 inline void add(
const Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2, Matrix<Symmetric, Row3, Row3, AT> &A3) {
296 #ifndef FMATVEC_NO_SIZE_CHECK
297 assert(A1.size() == A2.size());
299 for (
int i = 0; i < A1.size(); i++)
300 for (
int j = i; j < A2.size(); j++)
301 A3.ej(i, j) = A1.ej(i, j) + A2.ej(i, j);
304 template <
class Row1,
class Row2,
class Row3,
class AT>
305 inline void add(
const Matrix<Diagonal, Row1, Row1, AT> &A1,
const Matrix<Diagonal, Row2, Row2, AT> &A2, Matrix<Diagonal, Row3, Row3, AT> &A3) {
306 #ifndef FMATVEC_NO_SIZE_CHECK
307 assert(A1.size() == A2.size());
309 for (
int i = 0; i < A3.size(); i++)
310 A3.e(i) = A1.e(i) + A2.e(i);
313 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class AT>
314 inline void add(Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2) {
315 #ifndef FMATVEC_NO_SIZE_CHECK
316 assert(A1.rows() == A2.rows());
317 assert(A1.cols() == A2.cols());
319 for (
int i = 0; i < A1.rows(); i++)
320 for (
int j = 0; j < A2.cols(); j++)
321 A1.e(i, j) += A2.e(i, j);
324 template <
class Row1,
class Row2,
class AT>
325 inline void add(Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2) {
326 #ifndef FMATVEC_NO_SIZE_CHECK
327 assert(A1.size() == A2.size());
329 for (
int i = 0; i < A1.size(); i++)
330 for (
int j = i; j < A2.size(); j++)
331 A1.ej(i, j) += A2.ej(i, j);
334 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT>
335 inline void sub(
const Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2, Matrix<Type3, Row3, Col3, AT> &A3) {
336 #ifndef FMATVEC_NO_SIZE_CHECK
337 assert(A1.rows() == A2.rows());
338 assert(A1.cols() == A2.cols());
340 for (
int i = 0; i < A1.rows(); i++)
341 for (
int j = 0; j < A2.cols(); j++)
342 A3.e(i, j) = A1.e(i, j) - A2.e(i, j);
345 template <
class Row1,
class Row2,
class Row3,
class AT>
346 inline void sub(
const Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2, Matrix<Symmetric, Row3, Row3, AT> &A3) {
347 #ifndef FMATVEC_NO_SIZE_CHECK
348 assert(A1.size() == A2.size());
350 for (
int i = 0; i < A1.size(); i++)
351 for (
int j = i; j < A2.size(); j++)
352 A3.ej(i, j) = A1.ej(i, j) - A2.ej(i, j);
355 template <
class Row1,
class Row2,
class Row3,
class AT>
356 inline void sub(
const Matrix<Diagonal, Row1, Row1, AT> &A1,
const Matrix<Diagonal, Row2, Row2, AT> &A2, Matrix<Diagonal, Row3, Row3, AT> &A3) {
357 #ifndef FMATVEC_NO_SIZE_CHECK
358 assert(A1.size() == A2.size());
360 for (
int i = 0; i < A3.size(); i++)
361 A3.e(i) = A1.e(i) - A2.e(i);
364 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class AT>
365 inline void sub(Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2) {
366 #ifndef FMATVEC_NO_SIZE_CHECK
367 assert(A1.rows() == A2.rows());
368 assert(A1.cols() == A2.cols());
370 for (
int i = 0; i < A1.rows(); i++)
371 for (
int j = 0; j < A2.cols(); j++)
372 A1.e(i, j) -= A2.e(i, j);
375 template <
class Row1,
class Row2,
class AT>
376 inline void sub(Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2) {
377 #ifndef FMATVEC_NO_SIZE_CHECK
378 assert(A1.size() == A2.size());
380 for (
int i = 0; i < A1.size(); i++)
381 for (
int j = i; j < A2.size(); j++)
382 A1.ej(i, j) -= A2.ej(i, j);
387 template <
class AT,
class Type1,
class Type2,
class Row1,
class Col1,
class Row2,
class Col2>
388 inline Matrix<General, Var, Var, AT>
operator+(
const Matrix<Type1, Row1, Col1, AT> &A,
const Matrix<Type2, Row2, Col2, AT> &B) {
389 Matrix<General, Var, Var, AT> C(A.rows(), A.cols(), NONINIT);
393 template <
class AT,
class Type1,
class Type2,
class Row,
class Col>
394 inline Matrix<General, Row, Col, AT>
operator+(
const Matrix<Type1, Row, Col, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
395 Matrix<General, Row, Col, AT> C(A.rows(), A.cols(), NONINIT);
399 template <
class AT,
int M,
class Type1,
class Type2,
class Row,
class Col>
400 inline Matrix<General, Fixed<M>, Var, AT>
operator+(
const Matrix<Type1, Fixed<M>, Var, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
401 Matrix<General, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
405 template <
class AT,
int M,
class Type1,
class Type2>
406 inline Matrix<General, Fixed<M>, Var, AT>
operator+(
const Matrix<Type1, Fixed<M>, Var, AT> &A,
const Matrix<Type2, Fixed<M>, Var, AT> &B) {
407 Matrix<General, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
411 template <
class AT,
int N,
class Type1,
class Type2,
class Row,
class Col>
412 inline Matrix<General, Var, Fixed<N>, AT>
operator+(
const Matrix<Type1, Var, Fixed<N>, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
413 Matrix<General, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
417 template <
class AT,
int N,
class Type1,
class Type2>
418 inline Matrix<General, Var, Fixed<N>, AT>
operator+(
const Matrix<Type1, Var, Fixed<N>, AT> &A,
const Matrix<Type2, Var, Fixed<N>, AT> &B) {
419 Matrix<General, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
423 template <
class AT,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
424 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
425 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
429 template <
class AT,
int M,
int N,
class Type1,
class Type2>
430 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Fixed<M>, Var, AT> &B) {
431 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
435 template <
class AT,
int M,
int N,
class Type1,
class Type2>
436 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Var, Fixed<N>, AT> &B) {
437 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
441 template <
class AT,
int M,
int N,
class Type1,
class Type2>
442 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Fixed<M>, Fixed<N>, AT> &B) {
443 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
447 template <
class AT,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
448 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type2, Row, Col, AT> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &B) {
449 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
453 template <
class AT,
int M,
int N,
class Type1,
class Type2>
454 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type2, Fixed<M>, Var, AT> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &B) {
455 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
459 template <
class AT,
int M,
int N,
class Type1,
class Type2>
460 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type2, Var, Fixed<N>, AT> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &B) {
461 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
466 template <
class AT,
class Type,
class Row1,
class Col1,
class Row2,
class Col2>
467 inline Matrix<Type, Var, Var, AT>
operator+(
const Matrix<Type, Row1, Col1, AT> &A,
const Matrix<Type, Row2, Col2, AT> &B) {
468 Matrix<Type, Var, Var, AT> C(A.rows(), A.cols(), NONINIT);
472 template <
class AT,
class Type,
class Row,
class Col>
473 inline Matrix<Type, Row, Col, AT>
operator+(
const Matrix<Type, Row, Col, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
474 Matrix<Type, Row, Col, AT> C(A.rows(), A.cols(), NONINIT);
478 template <
class AT,
int M,
class Type,
class Row,
class Col>
479 inline Matrix<Type, Fixed<M>, Var, AT>
operator+(
const Matrix<Type, Fixed<M>, Var, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
480 Matrix<Type, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
484 template <
class AT,
int M,
class Type>
485 inline Matrix<Type, Fixed<M>, Var, AT>
operator+(
const Matrix<Type, Fixed<M>, Var, AT> &A,
const Matrix<Type, Fixed<M>, Var, AT> &B) {
486 Matrix<Type, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
490 template <
class AT,
int N,
class Type,
class Row,
class Col>
491 inline Matrix<Type, Var, Fixed<N>, AT>
operator+(
const Matrix<Type, Var, Fixed<N>, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
492 Matrix<Type, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
496 template <
class AT,
int N,
class Type>
497 inline Matrix<Type, Var, Fixed<N>, AT>
operator+(
const Matrix<Type, Var, Fixed<N>, AT> &A,
const Matrix<Type, Var, Fixed<N>, AT> &B) {
498 Matrix<Type, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
502 template <
class AT,
int M,
int N,
class Type,
class Row,
class Col>
503 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
504 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
508 template <
class AT,
int M,
int N,
class Type>
509 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Fixed<M>, Var, AT> &B) {
510 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
514 template <
class AT,
int M,
int N,
class Type>
515 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Var, Fixed<N>, AT> &B) {
516 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
520 template <
class AT,
int M,
int N,
class Type>
521 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
522 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
526 template <
class AT,
int M,
int N,
class Type,
class Row,
class Col>
527 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Row, Col, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
528 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
532 template <
class AT,
int M,
int N,
class Type>
533 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Fixed<M>, Var, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
534 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
538 template <
class AT,
int M,
int N,
class Type>
539 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator+(
const Matrix<Type, Var, Fixed<N>, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
540 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
544 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
545 inline Matrix<Type1, Row1, Col1, AT>& operator+=(
const Matrix<Type1, Row1, Col1, AT> &A_,
const Matrix<Type2, Row2, Col2, AT> &B) {
546 Matrix<Type1, Row1, Col1, AT> &A =
const_cast<Matrix<Type1, Row1, Col1, AT> &
>(A_);
553 template <
class AT,
class Type1,
class Type2,
class Row1,
class Col1,
class Row2,
class Col2>
554 inline Matrix<General, Var, Var, AT>
operator-(
const Matrix<Type1, Row1, Col1, AT> &A,
const Matrix<Type2, Row2, Col2, AT> &B) {
555 Matrix<General, Var, Var, AT> C(A.rows(), A.cols(), NONINIT);
559 template <
class AT,
class Type1,
class Type2,
class Row,
class Col>
560 inline Matrix<General, Row, Col, AT>
operator-(
const Matrix<Type1, Row, Col, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
561 Matrix<General, Row, Col, AT> C(A.rows(), A.cols(), NONINIT);
565 template <
class AT,
int M,
class Type1,
class Type2,
class Row,
class Col>
566 inline Matrix<General, Fixed<M>, Var, AT>
operator-(
const Matrix<Type1, Fixed<M>, Var, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
567 Matrix<General, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
571 template <
class AT,
int M,
class Type1,
class Type2>
572 inline Matrix<General, Fixed<M>, Var, AT>
operator-(
const Matrix<Type1, Fixed<M>, Var, AT> &A,
const Matrix<Type2, Fixed<M>, Var, AT> &B) {
573 Matrix<General, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
577 template <
class AT,
int N,
class Type1,
class Type2,
class Row,
class Col>
578 inline Matrix<General, Var, Fixed<N>, AT>
operator-(
const Matrix<Type1, Var, Fixed<N>, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
579 Matrix<General, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
583 template <
class AT,
int N,
class Type1,
class Type2>
584 inline Matrix<General, Var, Fixed<N>, AT>
operator-(
const Matrix<Type1, Var, Fixed<N>, AT> &A,
const Matrix<Type2, Var, Fixed<N>, AT> &B) {
585 Matrix<General, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
589 template <
class AT,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
590 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Row, Col, AT> &B) {
591 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
595 template <
class AT,
int M,
int N,
class Type1,
class Type2>
596 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Fixed<M>, Var, AT> &B) {
597 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
601 template <
class AT,
int M,
int N,
class Type1,
class Type2>
602 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Var, Fixed<N>, AT> &B) {
603 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
607 template <
class AT,
int M,
int N,
class Type1,
class Type2>
608 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type2, Fixed<M>, Fixed<N>, AT> &B) {
609 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
613 template <
class AT,
int M,
int N,
class Type1,
class Type2,
class Row,
class Col>
614 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type2, Row, Col, AT> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &B) {
615 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
619 template <
class AT,
int M,
int N,
class Type1,
class Type2>
620 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type2, Fixed<M>, Var, AT> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &B) {
621 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
625 template <
class AT,
int M,
int N,
class Type1,
class Type2>
626 inline Matrix<General, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type2, Var, Fixed<N>, AT> &A,
const Matrix<Type1, Fixed<M>, Fixed<N>, AT> &B) {
627 Matrix<General, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
632 template <
class AT,
class Type,
class Row1,
class Col1,
class Row2,
class Col2>
633 inline Matrix<Type, Var, Var, AT>
operator-(
const Matrix<Type, Row1, Col1, AT> &A,
const Matrix<Type, Row2, Col2, AT> &B) {
634 Matrix<Type, Var, Var, AT> C(A.rows(), A.cols(), NONINIT);
638 template <
class AT,
class Type,
class Row,
class Col>
639 inline Matrix<Type, Row, Col, AT>
operator-(
const Matrix<Type, Row, Col, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
640 Matrix<Type, Row, Col, AT> C(A.rows(), A.cols(), NONINIT);
644 template <
class AT,
int M,
class Type,
class Row,
class Col>
645 inline Matrix<Type, Fixed<M>, Var, AT>
operator-(
const Matrix<Type, Fixed<M>, Var, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
646 Matrix<Type, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
650 template <
class AT,
int M,
class Type>
651 inline Matrix<Type, Fixed<M>, Var, AT>
operator-(
const Matrix<Type, Fixed<M>, Var, AT> &A,
const Matrix<Type, Fixed<M>, Var, AT> &B) {
652 Matrix<Type, Fixed<M>, Var, AT> C(A.rows(), A.cols(), NONINIT);
656 template <
class AT,
int N,
class Type,
class Row,
class Col>
657 inline Matrix<Type, Var, Fixed<N>, AT>
operator-(
const Matrix<Type, Var, Fixed<N>, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
658 Matrix<Type, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
662 template <
class AT,
int N,
class Type>
663 inline Matrix<Type, Var, Fixed<N>, AT>
operator-(
const Matrix<Type, Var, Fixed<N>, AT> &A,
const Matrix<Type, Var, Fixed<N>, AT> &B) {
664 Matrix<Type, Var, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
668 template <
class AT,
int M,
int N,
class Type,
class Row,
class Col>
669 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Row, Col, AT> &B) {
670 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
674 template <
class AT,
int M,
int N,
class Type>
675 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Fixed<M>, Var, AT> &B) {
676 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
680 template <
class AT,
int M,
int N,
class Type>
681 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Var, Fixed<N>, AT> &B) {
682 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
686 template <
class AT,
int M,
int N,
class Type>
687 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
688 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
692 template <
class AT,
int M,
int N,
class Type,
class Row,
class Col>
693 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Row, Col, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
694 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
698 template <
class AT,
int M,
int N,
class Type>
699 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Fixed<M>, Var, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
700 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
704 template <
class AT,
int M,
int N,
class Type>
705 inline Matrix<Type, Fixed<M>, Fixed<N>, AT>
operator-(
const Matrix<Type, Var, Fixed<N>, AT> &A,
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &B) {
706 Matrix<Type, Fixed<M>, Fixed<N>, AT> C(A.rows(), A.cols(), NONINIT);
710 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
711 inline Matrix<Type1, Row1, Col1, AT>& operator-=(
const Matrix<Type1, Row1, Col1, AT> &A_,
const Matrix<Type2, Row2, Col2, AT> &B) {
712 Matrix<Type1, Row1, Col1, AT> &A =
const_cast<Matrix<Type1, Row1, Col1, AT> &
>(A_);
718 template <
class AT,
class Row1,
class Row2>
719 inline SquareMatrix<Var, AT>
operator+(
const SquareMatrix<Row1, AT> &A1,
const SquareMatrix<Row2, AT> &A2) {
720 SquareMatrix<Var, AT> A3(A1.size(), NONINIT);
724 template <
class AT,
class Row>
725 inline SquareMatrix<Row, AT>
operator+(
const SquareMatrix<Row, AT> &A1,
const SquareMatrix<Row, AT> &A2) {
726 SquareMatrix<Row, AT> A3(A1.size(), NONINIT);
732 template <
class AT,
class Row1,
class Row2>
733 inline SquareMatrix<Var, AT>
operator-(
const SquareMatrix<Row1, AT> &A1,
const SquareMatrix<Row2, AT> &A2) {
734 SquareMatrix<Var, AT> A3(A1.size(), NONINIT);
738 template <
class AT,
class Row>
739 inline SquareMatrix<Row, AT>
operator-(
const SquareMatrix<Row, AT> &A1,
const SquareMatrix<Row, AT> &A2) {
740 SquareMatrix<Row, AT> A3(A1.size(), NONINIT);
750 template <
class Type1,
class Row1,
class Col1,
class Row2,
class Row3,
class AT>
751 inline void mult(
const Matrix<Type1, Row1, Col1, AT> &A,
const Vector<Row2, AT> &x, Vector<Row3, AT> &y) {
752 #ifndef FMATVEC_NO_SIZE_CHECK
753 assert(A.cols() == x.size());
755 for (
int i = 0; i < y.size(); i++) {
757 for (
int j = 0; j < x.size(); j++)
758 y.e(i) += A.e(i, j) * x.e(j);
762 template <
class Row1,
class Row2,
class Row3,
class AT>
763 inline void mult(
const Matrix<Symmetric, Row1, Row1, AT> &A,
const Vector<Row2, AT> &x, Vector<Row3, AT> &y) {
764 #ifndef FMATVEC_NO_SIZE_CHECK
765 assert(A.cols() == x.size());
767 for (
int i = 0; i < y.size(); i++) {
769 for (
int j = 0; j < i; j++)
770 y.e(i) += A.ei(i, j) * x.e(j);
771 for (
int j = i; j < x.size(); j++)
772 y.e(i) += A.ej(i, j) * x.e(j);
777 template <
class AT,
class Type1,
class Row1,
class Col1,
class Row2>
778 inline Vector<Var, AT> operator*(
const Matrix<Type1, Row1, Col1, AT> &A,
const Vector<Row2, AT> &x) {
779 Vector<Var, AT> y(A.rows(), NONINIT);
783 template <
class AT,
class Type1,
class Row,
class Col>
784 inline Vector<Row, AT> operator*(
const Matrix<Type1, Row, Col, AT> &A,
const Vector<Row, AT> &x) {
785 Vector<Row, AT> y(A.rows(), NONINIT);
789 template <
class AT,
int M,
class Type1,
class Col1,
class Row2>
790 inline Vector<Fixed<M>, AT> operator*(
const Matrix<Type1, Fixed<M>, Col1, AT> &A,
const Vector<Row2, AT> &x) {
791 Vector<Fixed<M>, AT> y(A.rows(), NONINIT);
795 template <
class AT,
int M,
class Type1>
796 inline Vector<Fixed<M>, AT> operator*(
const Matrix<Type1, Fixed<M>, Fixed<M>, AT> &A,
const Vector<Fixed<M>, AT> &x) {
797 Vector<Fixed<M>, AT> y(A.rows(), NONINIT);
801 template <
class AT,
int M,
int N,
class Type,
class Row2>
802 inline Vector<Fixed<M>, AT> operator*(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Vector<Row2, AT> &x) {
803 Vector<Fixed<M>, AT> y(A.rows(), NONINIT);
807 template <
class AT,
int M,
int N,
class Type>
808 inline Vector<Fixed<M>, AT> operator*(
const Matrix<Type, Fixed<M>, Fixed<N>, AT> &A,
const Vector<Fixed<N>, AT> &x) {
809 Vector<Fixed<M>, AT> y(A.rows(), NONINIT);
815 template <
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Col3,
class AT>
816 inline void mult(
const RowVector<Col1, AT> &x,
const Matrix<Type2, Row2, Col2, AT> &A, RowVector<Col3, AT> &y) {
817 #ifndef FMATVEC_NO_SIZE_CHECK
818 assert(x.size() == A.rows());
820 for (
int i = 0; i < y.size(); i++) {
822 for (
int j = 0; j < x.size(); j++)
823 y.e(i) += x.e(j) * A.e(j, i);
827 template <
class Col1,
class Row2,
class Col3,
class AT>
828 inline void mult(
const RowVector<Col1, AT> &x,
const Matrix<Symmetric, Row2, Row2, AT> &A, RowVector<Col3, AT> &y) {
829 #ifndef FMATVEC_NO_SIZE_CHECK
830 assert(x.size() == A.rows());
832 for (
int i = 0; i < y.size(); i++) {
834 for (
int j = 0; j < i; j++)
835 y.e(i) += x.e(j) * A.ej(j, i);
836 for (
int j = i; j < x.size(); j++)
837 y.e(i) += x.e(j) * A.ei(j, i);
841 template <
class AT,
class Type2,
class Col2,
class Row1,
class Col1>
842 inline RowVector<Var, AT> operator*(
const RowVector<Col2, AT> &x,
const Matrix<Type2, Row1, Col1, AT> &A) {
843 RowVector<Var, AT> y(A.cols(), NONINIT);
847 template <
class AT,
class Type2,
class Row,
class Col>
848 inline RowVector<Col, AT> operator*(
const RowVector<Col, AT> &x,
const Matrix<Type2, Row, Col, AT> &A) {
849 RowVector<Col, AT> y(A.cols(), NONINIT);
853 template <
class AT,
int N,
class Type2,
class Col1,
class Row2>
854 inline RowVector<Fixed<N>, AT> operator*(
const RowVector<Col1, AT> &x,
const Matrix<Type2, Row2, Fixed<N>, AT> &A) {
855 RowVector<Fixed<N>, AT> y(A.cols(), NONINIT);
859 template <
class AT,
int N,
class Type2>
860 inline RowVector<Fixed<N>, AT> operator*(
const RowVector<Fixed<N>, AT> &x,
const Matrix<Type2, Fixed<N>, Fixed<N>, AT> &A) {
861 RowVector<Fixed<N>, AT> y(A.cols(), NONINIT);
867 template <
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT>
868 inline void mult(
const Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2, Matrix<Type3, Row3, Col3, AT> &A3) {
869 #ifndef FMATVEC_NO_SIZE_CHECK
870 assert(A1.cols() == A2.rows());
872 for (
int i = 0; i < A3.rows(); i++) {
873 for (
int k = 0; k < A3.cols(); k++) {
875 for (
int j = 0; j < A1.cols(); j++)
876 A3.e(i, k) += A1.e(i, j) * A2.e(j, k);
880 template <
class Row1,
class Type2,
class Row2,
class Col2,
class Type3,
class Row3,
class Col3,
class AT>
881 inline void mult(
const Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2, Matrix<Type3, Row3, Col3, AT> &A3) {
882 #ifndef FMATVEC_NO_SIZE_CHECK
883 assert(A1.size() == A2.rows());
885 for (
int i = 0; i < A3.rows(); i++) {
886 for (
int k = 0; k < A3.cols(); k++) {
888 for (
int j = 0; j < i; j++)
889 A3.e(i, k) += A1.ei(i, j) * A2.e(j, k);
890 for (
int j = i; j < A1.cols(); j++)
891 A3.e(i, k) += A1.ej(i, j) * A2.e(j, k);
895 template <
class Row1,
class Row2,
class Row3,
class AT>
896 inline void mult(
const Matrix<Diagonal, Row1, Row1, AT> &A1,
const Matrix<Diagonal, Row2, Row2, AT> &A2, Matrix<Diagonal, Row3, Row3, AT> &A3) {
897 #ifndef FMATVEC_NO_SIZE_CHECK
898 assert(A1.size() == A2.size());
900 for (
int i = 0; i < A3.size(); i++)
901 A3.e(i) = A1.e(i) * A2.e(i);
904 template <
class AT,
class Type1,
class Type2,
class Row1,
class Col1,
class Row2,
class Col2>
905 inline Matrix<General, Var, Var, AT> operator*(
const Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2) {
906 Matrix<General, Var, Var, AT> A3(A1.rows(), A2.cols(), NONINIT);
910 template <
class AT,
class Type1,
class Type2,
class Row,
class Col>
911 inline Matrix<General, Row, Col, AT> operator*(
const Matrix<Type1, Row, Col, AT> &A1,
const Matrix<Type2, Row, Col, AT> &A2) {
912 Matrix<General, Row, Col, AT> A3(A1.rows(), A2.cols(), NONINIT);
916 template <
class AT,
int M,
class Type1,
class Type2,
class Col1,
class Row2,
class Col2>
917 inline Matrix<General, Fixed<M>, Var, AT> operator*(
const Matrix<Type1, Fixed<M>, Col1, AT> &A1,
const Matrix<Type2, Row2, Col2, AT> &A2) {
918 Matrix<General, Fixed<M>, Var, AT> A3(A1.rows(), A2.cols(), NONINIT);
922 template <
class AT,
int N,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2>
923 inline Matrix<General, Var, Fixed<N>, AT> operator*(
const Matrix<Type1, Row1, Col1, AT> &A1,
const Matrix<Type2, Row2, Fixed<N>, AT> &A2) {
924 Matrix<General, Var, Fixed<N>, AT> A3(A1.rows(), A2.cols(), NONINIT);
928 template <
class AT,
int M,
int N,
class Type1,
class Type2,
class Col1,
class Row2>
929 inline Matrix<General, Fixed<M>, Fixed<N>, AT> operator*(
const Matrix<Type1, Fixed<M>, Col1, AT> &A1,
const Matrix<Type2, Row2, Fixed<N>, AT> &A2) {
930 Matrix<General, Fixed<M>, Fixed<N>, AT> A3(A1.rows(), A2.cols(), NONINIT);
934 template <
class AT,
int M,
class Type1,
class Type2>
935 inline Matrix<General, Fixed<M>, Fixed<M>, AT> operator*(
const Matrix<Type1, Fixed<M>, Fixed<M>, AT> &A1,
const Matrix<Type2, Fixed<M>, Fixed<M>, AT> &A2) {
936 Matrix<General, Fixed<M>, Fixed<M>, AT> A3(A1.rows(), A2.cols(), NONINIT);
940 template <
class AT,
class Type,
class Row1,
class Col1,
class Row2,
class Col2>
941 inline Matrix<Type, Var, Var, AT> operator*(
const Matrix<Type, Row1, Col1, AT> &A1,
const Matrix<Type, Row2, Col2, AT> &A2) {
942 Matrix<Type, Var, Var, AT> A3(A1.rows(), A2.cols(), NONINIT);
946 template <
class AT,
class Type,
class Row,
class Col>
947 inline Matrix<Type, Row, Col, AT> operator*(
const Matrix<Type, Row, Col, AT> &A1,
const Matrix<Type, Row, Col, AT> &A2) {
948 Matrix<Type, Row, Col, AT> A3(A1.rows(), A2.cols(), NONINIT);
952 template <
class AT,
int M,
class Type,
class Col1,
class Row2,
class Col2>
953 inline Matrix<Type, Fixed<M>, Var, AT> operator*(
const Matrix<Type, Fixed<M>, Col1, AT> &A1,
const Matrix<Type, Row2, Col2, AT> &A2) {
954 Matrix<Type, Fixed<M>, Var, AT> A3(A1.rows(), A2.cols(), NONINIT);
958 template <
class AT,
int N,
class Type,
class Row1,
class Col1,
class Row2>
959 inline Matrix<Type, Var, Fixed<N>, AT> operator*(
const Matrix<Type, Row1, Col1, AT> &A1,
const Matrix<Type, Row2, Fixed<N>, AT> &A2) {
960 Matrix<Type, Var, Fixed<N>, AT> A3(A1.rows(), A2.cols(), NONINIT);
964 template <
class AT,
int M,
int N,
class Type,
class Col1,
class Row2>
965 inline Matrix<Type, Fixed<M>, Fixed<N>, AT> operator*(
const Matrix<Type, Fixed<M>, Col1, AT> &A1,
const Matrix<Type, Row2, Fixed<N>, AT> &A2) {
966 Matrix<Type, Fixed<M>, Fixed<N>, AT> A3(A1.rows(), A2.cols(), NONINIT);
970 template <
class AT,
int M,
class Type>
971 inline Matrix<Type, Fixed<M>, Fixed<M>, AT> operator*(
const Matrix<Type, Fixed<M>, Fixed<M>, AT> &A1,
const Matrix<Type, Fixed<M>, Fixed<M>, AT> &A2) {
972 Matrix<Type, Fixed<M>, Fixed<M>, AT> A3(A1.rows(), A2.cols(), NONINIT);
978 template <
class AT,
class Row1,
class Row2>
979 inline SquareMatrix<Var, AT> operator*(
const SquareMatrix<Row1, AT> &A1,
const SquareMatrix<Row2, AT> &A2) {
980 SquareMatrix<Var, AT> A3(A1.size(), NONINIT);
984 template <
class AT,
class Row>
985 inline SquareMatrix<Row, AT> operator*(
const SquareMatrix<Row, AT> &A1,
const SquareMatrix<Row, AT> &A2) {
986 SquareMatrix<Row, AT> A3(A1.size(), NONINIT);
992 template <
class AT,
class Row1,
class Row2>
993 inline Matrix<General, Var, Var, AT> operator*(
const Matrix<Symmetric, Row1, Row1, AT> &A1,
const Matrix<Symmetric, Row2, Row2, AT> &A2) {
994 Matrix<General, Var, Var, AT> A3(A1.rows(), A2.cols(), NONINIT);
998 template <
class AT,
class Row>
999 inline Matrix<General, Row, Row, AT> operator*(
const Matrix<Symmetric, Row, Row, AT> &A1,
const Matrix<Symmetric, Row, Row, AT> &A2) {
1000 Matrix<General, Row, Row, AT> A3(A1.rows(), A2.cols(), NONINIT);
1013 template <
class Row,
class AT>
1018 for (
int i = 0; i < x.size(); i++)
1019 y.e(i) = x.e(i) * alpha;
1028 template <
class Row,
class AT>
1033 for (
int i = 0; i < x.size(); i++)
1034 y.e(i) = x.e(i) * alpha;
1039 template <
class Row,
class AT>
1040 inline Vector<Row, AT> operator*=(
const Vector<Row, AT> &x_,
const AT &alpha) {
1041 Vector<Row, AT> &x =
const_cast<Vector<Row, AT> &
>(x_);
1042 for (
int i = 0; i < x.size(); i++)
1047 template <
class Row,
class AT>
1048 inline Vector<Row, AT> operator/(
const Vector<Row, AT> &x,
const AT &alpha) {
1049 Vector<Row, AT> y(x.size(), NONINIT);
1050 for (
int i = 0; i < x.size(); i++)
1051 y.e(i) = x.e(i) / alpha;
1055 template <
class Row,
class AT>
1056 inline Vector<Row, AT> operator/=(
const Vector<Row, AT> &x_,
const AT &alpha) {
1057 Vector<Row, AT> &x =
const_cast<Vector<Row, AT> &
>(x_);
1058 for (
int i = 0; i < x.size(); i++)
1068 template <
class Col,
class AT>
1073 for (
int i = 0; i < x.size(); i++)
1074 y.e(i) = x.e(i) * alpha;
1083 template <
class Col,
class AT>
1088 for (
int i = 0; i < x.size(); i++)
1089 y.e(i) = x.e(i) * alpha;
1094 template <
class Col,
class AT>
1095 inline RowVector<Col, AT> operator*=(
const RowVector<Col, AT> &x_,
const AT &alpha) {
1096 RowVector<Col, AT> &x =
const_cast<RowVector<Col, AT> &
>(x_);
1097 for (
int i = 0; i < x.size(); i++)
1102 template <
class Col,
class AT>
1103 inline RowVector<Col, AT> operator/(
const RowVector<Col, AT> &x,
const AT &a) {
1104 RowVector<Col, AT> y(x.size(), NONINIT);
1105 for (
int i = 0; i < x.size(); i++)
1106 y.e(i) = x.e(i) / a;
1110 template <
class Col,
class AT>
1111 inline RowVector<Col, AT> operator/=(
const RowVector<Col, AT> &x_,
const AT &a) {
1112 RowVector<Col, AT> &x =
const_cast<RowVector<Col, AT> &
>(x_);
1113 for (
int i = 0; i < x.size(); i++)
1128 template <
class Col,
class Row,
class AT>
1131 #ifndef FMATVEC_NO_SIZE_CHECK
1132 assert(x.size() == y.size());
1137 for (
int i = 0; i < x.size(); i++)
1138 res += x.e(i) * y.e(i);
1148 template <
class Row,
class AT>
1151 #ifndef FMATVEC_NO_SIZE_CHECK
1152 assert(x.size() == y.size());
1157 for (
int i = 0; i < x.size(); i++)
1158 res += x.e(i) * y.e(i);
1168 template <
class Row,
class AT>
1171 #ifndef FMATVEC_NO_SIZE_CHECK
1172 assert(x.size() == 3);
1173 assert(y.size() == 3);
1178 z.e(0) = x.e(1) * y.e(2) - x.e(2) * y.e(1);
1179 z.e(1) = x.e(2) * y.e(0) - x.e(0) * y.e(2);
1180 z.e(2) = x.e(0) * y.e(1) - x.e(1) * y.e(0);
1190 template <
class Row,
class AT>
1193 #ifndef FMATVEC_NO_SIZE_CHECK
1194 assert(a.size() == 3);
1195 assert(x.size() == 3);
1196 assert(y.size() == 3);
1199 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));
1214 template <
class Type,
class Row,
class Col,
class AT>
1219 for (
int i = 0; i < A.
rows(); i++)
1220 for (
int j = 0; j < A.
cols(); j++)
1221 B.e(i, j) = A.e(i, j) * alpha;
1226 template <
class Type,
class Row,
class Col,
class AT>
1227 Matrix<Type, Row, Col, AT> operator*(
const AT &alpha,
const Matrix<Type, Row, Col, AT> &A) {
1229 Matrix<Type, Row, Col, AT> B(A.rows(), A.cols(), NONINIT);
1231 for (
int i = 0; i < A.rows(); i++)
1232 for (
int j = 0; j < A.cols(); j++)
1233 B.e(i, j) = A.e(i, j) * alpha;
1238 template <
class Row,
class AT>
1239 inline Matrix<Symmetric, Row, Row, AT> operator*(
const AT &alpha,
const Matrix<Symmetric, Row, Row, AT> &A) {
1240 Matrix<Symmetric, Row, Row, AT> B(A.size(), A.size(), NONINIT);
1241 for (
int i = 0; i < A.size(); i++)
1242 for (
int j = i; j < A.size(); j++)
1243 B.ej(i, j) = A.ej(i, j) * alpha;
1247 template <
class Row,
class AT>
1248 inline Matrix<Symmetric, Row, Row, AT> operator*(
const Matrix<Symmetric, Row, Row, AT> &A,
const AT &alpha) {
1249 Matrix<Symmetric, Row, Row, AT> B(A.size(), A.size(), NONINIT);
1250 for (
int i = 0; i < A.size(); i++)
1251 for (
int j = i; j < A.size(); j++)
1252 B.ej(i, j) = A.ej(i, j) * alpha;
1256 template <
class Row,
class AT>
1257 inline Matrix<Diagonal, Row, Row, AT> operator*(
const AT &alpha,
const Matrix<Diagonal, Row, Row, AT> &A) {
1258 Matrix<Diagonal, Row, Row, AT> B(A.size(), A.size(), NONINIT);
1259 for (
int i = 0; i < A.size(); i++)
1260 B.e(i) = A.e(i) * alpha;
1264 template <
class Row,
class AT>
1265 inline Matrix<Diagonal, Row, Row, AT> operator*(
const Matrix<Diagonal, Row, Row, AT> &A,
const AT &alpha) {
1266 Matrix<Diagonal, Row, Row, AT> B(A.size(), A.size(), NONINIT);
1267 for (
int i = 0; i < A.size(); i++)
1268 B.e(i) = A.e(i) * alpha;
1272 template <
class Type,
class Row,
class Col,
class AT>
1273 Matrix<Type, Row, Col, AT> operator/(
const Matrix<Type, Row, Col, AT> &A,
const AT &alpha) {
1275 Matrix<Type, Row, Col, AT> B(A.rows(), A.cols(), NONINIT);
1277 for (
int i = 0; i < A.rows(); i++)
1278 for (
int j = 0; j < A.cols(); j++)
1279 B.e(i, j) = A.e(i, j) / alpha;
1284 template <
class Row,
class AT>
1285 inline Matrix<Symmetric, Row, Row, AT> operator/(
const Matrix<Symmetric, Row, Row, AT> &A,
const AT &alpha) {
1286 Matrix<Symmetric, Row, Row, AT> B(A.size(), A.size(), NONINIT);
1287 for (
int i = 0; i < A.size(); i++)
1288 for (
int j = i; j < A.size(); j++)
1289 B.ej(i, j) = A.ej(i, j) / alpha;
1293 template <
class Row,
class AT>
1294 inline Matrix<Diagonal, Row, Row, AT> operator/(
const Matrix<Diagonal, Row, Row, AT> &A,
const AT &alpha) {
1295 Matrix<Diagonal, Row, Row, AT> B(A.size(), A.size(), NONINIT);
1296 for (
int i = 0; i < A.size(); i++)
1297 B.e(i) = A.e(i) / alpha;
1301 template <
class Row,
class AT>
1302 SquareMatrix<Row, AT> operator*(
const SquareMatrix<Row, AT> &A,
const AT &alpha) {
1304 SquareMatrix<Row, AT> B(A.size(), NONINIT);
1306 for (
int i = 0; i < A.size(); i++)
1307 for (
int j = 0; j < A.size(); j++)
1308 B.e(i, j) = A.e(i, j) * alpha;
1313 template <
class Row,
class AT>
1314 SquareMatrix<Row, AT> operator*(
const AT &alpha,
const SquareMatrix<Row, AT> &A) {
1316 SquareMatrix<Row, AT> B(A.size(), NONINIT);
1318 for (
int i = 0; i < A.size(); i++)
1319 for (
int j = 0; j < A.size(); j++)
1320 B.e(i, j) = A.e(i, j) * alpha;
1325 template <
class Row,
class AT>
1326 SquareMatrix<Row, AT> operator/(
const SquareMatrix<Row, AT> &A,
const AT &alpha) {
1328 SquareMatrix<Row, AT> B(A.size(), NONINIT);
1330 for (
int i = 0; i < A.size(); i++)
1331 for (
int j = 0; j < A.size(); j++)
1332 B.e(i, j) = A.e(i, j) / alpha;
1337 template <
class Type,
class Row,
class Col,
class AT>
1338 Matrix<Type, Row, Col, AT> operator*=(
const Matrix<Type, Row, Col, AT> &A_,
const AT &alpha) {
1339 Matrix<Type, Row, Col, AT> &A =
const_cast<Matrix<Type, Row, Col, AT> &
>(A_);
1340 for (
int i = 0; i < A.rows(); i++)
1341 for (
int j = 0; j < A.cols(); j++)
1347 template <
class Row,
class AT>
1348 inline Matrix<Symmetric, Row, Row, AT> operator*=(
const Matrix<Symmetric, Row, Row, AT> &A_,
const AT &alpha) {
1349 Matrix<Symmetric, Row, Row, AT> &A =
const_cast<Matrix<Symmetric, Row, Row, AT> &
>(A_);
1350 for (
int i = 0; i < A.size(); i++)
1351 for (
int j = i; j < A.size(); j++)
1352 A.ej(i, j) *= alpha;
1356 template <
class Row,
class AT>
1357 inline Matrix<Diagonal, Row, Row, AT> operator*=(
const Matrix<Diagonal, Row, Row, AT> &A_,
const AT &alpha) {
1358 Matrix<Diagonal, Row, Row, AT> &A =
const_cast<Matrix<Diagonal, Row, Row, AT> &
>(A_);
1359 for (
int i = 0; i < A.size(); i++)
1364 template <
class Type,
class Row,
class Col,
class AT>
1365 Matrix<Type, Row, Col, AT> operator/=(
const Matrix<Type, Row, Col, AT> &A_,
const AT &alpha) {
1366 Matrix<Type, Row, Col, AT> A =
const_cast<Matrix<Type, Row, Col, AT> &
>(A_);
1367 for (
int i = 0; i < A.rows(); i++)
1368 for (
int j = 0; j < A.cols(); j++)
1374 template <
class Row,
class AT>
1375 inline Matrix<Symmetric, Row, Row, AT> operator/=(
const Matrix<Symmetric, Row, Row, AT> &A_,
const AT &alpha) {
1376 Matrix<Symmetric, Row, Row, AT> A =
const_cast<Matrix<Symmetric, Row, Row, AT> &
>(A_);
1377 for (
int i = 0; i < A.size(); i++)
1378 for (
int j = i; j < A.size(); j++)
1379 A.ej(i, j) /= alpha;
1383 template <
class Row,
class AT>
1384 inline Matrix<Diagonal, Row, Row, AT> operator/=(
const Matrix<Diagonal, Row, Row, AT> &A_,
const AT &alpha) {
1385 Matrix<Diagonal, Row, Row, AT> A =
const_cast<Matrix<Diagonal, Row, Row, AT> &
>(A_);
1386 for (
int i = 0; i < A.size(); i++)
1400 template <
class Row,
class AT>
1405 for (
int i = 0; i < x.size(); i++)
1416 template <
class Col,
class AT>
1421 for (
int i = 0; i < a.size(); i++)
1432 template <
class Row,
class AT>
1437 for (
int i = 0; i < A.size(); i++)
1438 for (
int j = 0; j < A.size(); j++)
1439 B.e(i, j) = -A.e(i, j);
1449 template <
class Type,
class Row,
class Col,
class AT>
1454 for (
int i = 0; i < A.
rows(); i++)
1455 for (
int j = 0; j < A.
cols(); j++)
1456 B.e(i, j) = -A.e(i, j);
1485 return Vector<Ref, AT>(x.n, x.lda, x.tp ?
false :
true, x.memory, x.ele).copy();
1516 template <
class Type,
class Row,
class Col,
class AT>
1517 inline Matrix<Type, Col, Row, AT>
trans(
const Matrix<Type, Row, Col, AT> &A) {
1518 Matrix<Type, Col, Row, AT> B(A.cols(), A.rows(), NONINIT);
1519 for (
int i = 0; i < B.rows(); i++)
1520 for (
int j = 0; j < B.cols(); j++)
1521 B.e(i, j) = A.e(j, i);
1525 template <
class Row,
class AT>
1526 inline SquareMatrix<Row, AT>
trans(
const SquareMatrix<Row, AT> &A) {
1527 SquareMatrix<Row, AT> B(A.size(), NONINIT);
1528 for (
int i = 0; i < B.size(); i++)
1529 for (
int j = 0; j < B.size(); j++)
1530 B.e(i, j) = A.e(j, i);
1534 template <
class Row,
class AT>
1535 inline RowVector<Row, AT>
trans(
const Vector<Row, AT> &x) {
1536 RowVector<Row, AT> y(x.size(), NONINIT);
1537 for (
int i = 0; i < y.size(); i++)
1542 template <
class Row,
class AT>
1543 inline Vector<Row, AT>
trans(
const RowVector<Row, AT> &x) {
1544 Vector<Row, AT> y(x.size(), NONINIT);
1545 for (
int i = 0; i < y.size(); i++)
1553 template <
class Row,
class AT>
1554 inline AT nrmInf(
const Vector<Row, AT> &x) {
1556 for (
int i = 0; i < x.size(); i++)
1557 if (c < fabs(x.e(i)))
1562 template <
class Row,
class AT>
1563 inline AT nrmInf(
const RowVector<Row, AT> &x) {
1565 for (
int i = 0; i < x.size(); i++)
1566 if (c < fabs(x.e(i)))
1571 template <
class Row,
class AT>
1572 inline AT nrm2(
const Vector<Row, AT> &x) {
1574 for (
int i = 0; i < x.size(); i++)
1575 c += pow(x.e(i), 2);
1579 template <
class Col,
class AT>
1580 inline AT nrm2(
const RowVector<Col, AT> &x) {
1582 for (
int i = 0; i < x.size(); i++)
1583 c += pow(x.e(i), 2);
1600 template <
class Row,
class AT>
1608 B.e(0, 1) = -x.e(2);
1611 B.e(1, 2) = -x.e(0);
1612 B.e(2, 0) = -x.e(1);
1623 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
1632 for (
int i = 0; i < A.
rows(); i++)
1633 for (
int j = 0; j < A.
cols(); j++)
1634 if (A(i, j) != B(i, j))
1645 template <
class AT,
class Type1,
class Row1,
class Col1,
class Type2,
class Row2,
class Col2>
1651 for (
int i = 0; i < A.
rows(); i++)
1652 for (
int j = 0; j < A.
cols(); j++)
1653 if (A(i, j) != B(i, j))
1664 template <
class Row,
class AT>
1667 #ifndef FMATVEC_NO_SIZE_CHECK
1668 assert(x.size() > 0);
1670 AT maximum = x.e(0);
1671 for (
int i = 1; i < x.size(); i++) {
1672 if (x.e(i) > maximum)
1683 template <
class Row,
class AT>
1686 #ifndef FMATVEC_NO_SIZE_CHECK
1687 assert(x.size() > 0);
1689 AT maximum = x.e(0);
1691 for (
int i = 1; i < x.size(); i++) {
1692 if (x.e(i) > maximum) {
1705 template <
class Row,
class AT>
1708 #ifndef FMATVEC_NO_SIZE_CHECK
1709 assert(x.size() > 0);
1711 AT minimum = x.e(0);
1712 for (
int i = 1; i < x.size(); i++) {
1713 if (x.e(i) < minimum)
1724 template <
class Row,
class AT>
1727 #ifndef FMATVEC_NO_SIZE_CHECK
1728 assert(x.size() > 0);
1730 AT minimum = x.e(0);
1732 for (
int i = 1; i < x.size(); i++) {
1733 if (x.e(i) < minimum) {
1751 #ifndef FMATVEC_NO_SIZE_CHECK
1752 assert(A_.
rows() > 0);
1753 assert(A_.
cols() > 0);
1754 assert(A_.
cols() > PivotCol);
1760 for (i = 1; i <= N - 1; i++) {
1761 for (j = 0; j < N - 1; j++) {
1762 if (A(j, PivotCol) > A(j + 1, PivotCol)) {
1764 A.row(j) = A.row(j + 1);
1778 int i = l - 1, j = r;
1781 int m = l + (r - l) / 2;
1782 if (A(l, PivotCol) > A(m, PivotCol)) {
1787 if (A(l, PivotCol) > A(r, PivotCol)) {
1792 else if (A(r, PivotCol) > A(m, PivotCol)) {
1800 while(A(++i,PivotCol) < A(r,PivotCol));
1801 while(A(--j,PivotCol) > A(r,PivotCol) && j>i);
1841 for (
int i = 0; i < A.
size(); i++) {
1842 for (
int j = 0; j < A.
size(); j++) {
1843 if (fabs(A(i, j)) > 1e-16 || i == j) {
1859 for (
int j = 0; j < A.
cols(); j++) {
1860 for (
int i = j; i < A.
rows(); i++) {
1861 if (fabs(A(i, j)) > 1e-17 || i == j) {
1877 for (
int j = 0; j < A.
cols(); j++) {
1878 for (
int i = j; i < A.
rows(); i++) {
1879 if (fabs(A(i, j)) > 1e-17 || i == j) {
1887 template <
class Row,
class Col,
class AT>
1888 inline Matrix<Symmetric, Col, Col, AT> JTJ(
const Matrix<General, Row, Col, AT> &A) {
1889 Matrix<Symmetric, Col, Col, AT> S(A.cols(), A.cols(), NONINIT);
1890 for (
int i = 0; i < A.cols(); i++) {
1891 for (
int k = i; k < A.cols(); k++) {
1893 for (
int j = 0; j < A.rows(); j++)
1894 S.ej(i, k) += A.e(j, i) * A.e(j, k);
1900 template <
class Row,
class Col,
class AT>
1901 inline Matrix<Symmetric, Col, Col, AT> JTMJ(
const Matrix<Symmetric, Row, Row, AT> &B,
const Matrix<General, Row, Col, AT> &A) {
1903 Matrix<Symmetric, Col, Col, AT> S(A.cols(), A.cols(), NONINIT);
1904 Matrix<General, Row, Col, AT> C = B * A;
1906 for (
int i = 0; i < A.cols(); i++) {
1907 for (
int k = i; k < A.cols(); k++) {
1909 for (
int j = 0; j < A.rows(); j++)
1910 S.ej(i, k) += A.e(j, i) * C.e(j, k);
1916 template <
class Row,
class Col,
class AT>
1917 inline Matrix<Symmetric, Row, Row, AT> JMJT(
const Matrix<General, Row, Col, AT> &A,
const Matrix<Symmetric, Col, Col, AT> &B) {
1919 Matrix<Symmetric, Row, Row, AT> S(A.rows(), A.rows(), NONINIT);
1920 Matrix<General, Row, Col, AT> C = A * B;
1922 for (
int i = 0; i < S.size(); i++) {
1923 for (
int k = i; k < S.size(); k++) {
1925 for (
int j = 0; j < A.cols(); j++)
1926 S.ej(i, k) += C.e(k, j) * A.e(i, j);
This is a matrix class for symmetric matrices.
Definition: var_symmetric_matrix.h:37
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:1825
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:56
int rows() const
Number of rows.
Definition: var_symmetric_matrix.h:231
This is a vector class of general shape in dense storage format.
Definition: var_vector.h:39
int rows() const
Number of rows.
Definition: general_matrix.h:270
void quicksortmedian_intern(Matrix< General, Ref, Ref, AT > &A, int PivotCol, RowVector< Ref, AT > &tmp, int l, int r)
Definition: linear_algebra.h:1775
int minIndex(const Vector< Row, AT > &x)
Index of minimum value.
Definition: linear_algebra.h:1725
int rows() const
Number of rows.
Definition: symmetric_matrix.h:264
Vector< Var, AT > operator-(const Vector< Row1, AT > &a, const Vector< Row2, AT > &b)
// Subtraction
Definition: linear_algebra.h:151
RowVector< Ref, AT > row(int i)
Row operator.
Definition: general_matrix.h:680
bool operator==(const Index &I, const Index &J)
Equality operator for indices.
Definition: index.cc:26
int rows() const
Number of rows.
int countElements(const SquareMatrix< Ref, AT > &A)
Count nonzero elements.
Definition: linear_algebra.h:1839
int cols() const
Number of columns.
Vector< Ref, AT > operator+(const Vector< Ref, AT > &x, const Vector< Ref, AT > &y)
Vector-vector addition.
Definition: linear_algebra.h:52
Matrix< General, Ref, Ref, AT > copy() const
Matrix duplicating.
Definition: general_matrix.h:702
int size() const
Size.
Definition: square_matrix.h:183
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:1706
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:1749
int maxIndex(const Vector< Row, AT > &x)
Index of maximum value.
Definition: linear_algebra.h:1684
int cols() const
Number of columns.
Definition: symmetric_matrix.h:270
This is a matrix class for general matrices.
Definition: general_matrix.h:40
bool operator!=(const Matrix< Type1, Row1, Col1, AT > &A, const Matrix< Type2, Row2, Col2, AT > &B)
Matrix-matrix comparison.
Definition: linear_algebra.h:1646
int size() const
Size.
Definition: vector.h:260
Vector< Row, AT > crossProduct(const Vector< Row, AT > &x, const Vector< Row, AT > &y)
Cross product.
Definition: linear_algebra.h:1169
RowVector< Ref, AT > trans(const Vector< Ref, AT > &x)
Transpose of a vector.
Definition: linear_algebra.h:1470
AT max(const Vector< Row, AT > &x)
Maximum value.
Definition: linear_algebra.h:1665
This is a matrix class for symmetric matrices.
Definition: symmetric_matrix.h:39
bool transposed() const
Transposed status.
Definition: general_matrix.h:289
This is a vector class of general shape in dense storage format.
Definition: vector.h:39
double tripleProduct(const Vector< Row, AT > &a, const Vector< Row, AT > &x, const Vector< Row, AT > &y)
Triple product.
Definition: linear_algebra.h:1191
This is a matrix class of general quadratic matrices.
Definition: square_matrix.h:38
SquareMatrix< Row, AT > tilde(const Vector< Row, AT > &x)
Tilde operator.
Definition: linear_algebra.h:1601
int cols() const
Number of columns.
Definition: var_symmetric_matrix.h:237
int countElementsLT(const Matrix< Symmetric, Ref, Ref, AT > &A)
Count nonzero elements of the low triangular part of a symmetric matrix.
Definition: linear_algebra.h:1857
AT scalarProduct(const Vector< Row, AT > &x, const Vector< Row, AT > &y)
Scalar product.
Definition: linear_algebra.h:1149
This is a vector class of general shape in dense storage format.
Definition: var_row_vector.h:39
int cols() const
Number of columns.
Definition: general_matrix.h:276