TinyMatrix.hxx
1 #ifndef SELDON_FILE_TINY_MATRIX_HXX
2 
3 #include "vector/TinyVector.hxx"
4 
5 #include "TinyMatrixExpression.hxx"
6 
7 namespace Seldon
8 {
10  template<class T, class Prop, int m_, int n_>
11  class TinyMatrix
12  {
13  };
14 
15  template<class Prop, int m, int n, int p>
17  {
18  };
19 
20 
21  template<int p>
23 
24  template<int p, int q>
26 
27  template<int p, int q, int r>
29 
30  /******************
31  * General matrix *
32  ******************/
33 
36  template <class T, int m, int n>
37  class TinyMatrix<T, General, m, n>
38  : public TinyMatrixExpression<T, m, n, TinyMatrix<T, General, m, n> >
39  {
40  template<int p>
41  friend class TinyMatrixLoop;
42 
43  template<int p, int q>
44  friend class TinyMatrixDoubleLoop;
45 
46  template<int p, int q, int r>
47  friend class TinyMatrixTripleLoop;
48 
49  protected:
51  T data_[m*n];
52 
53  public :
54  enum{ size_ = m*n };
55 
56  TinyMatrix();
57  explicit TinyMatrix(int i);
58  explicit TinyMatrix(int i, int j);
59 
60  template<class T0>
62 
63  template<class E>
65 
66  // Basic methods.
67  static int GetM();
68  static int GetN();
69  static int GetSize();
70  T* GetData();
71 
72  // product of a matrix by a scalar this = this * a where a is a scalar
73  template<class T1>
74  TinyMatrix<T, General, m, n> & operator *=(const T1& a );
75 
76  // sum of matrices this = this + B
77  template<class T1, class E>
79 
80  // sum of matrices this = this - B
81  template<class T1, class E>
83 
84  // fills matrix with x
85  TinyMatrix<T, General, m, n> & operator =(const T& x);
86 
87  // *this = expression with matrices
88  template<class T0, class E>
90 
91  T& operator()(int i,int j);
92  const T& operator()(int i,int j) const;
93 
94  // Convenient functions
95  void Zero(); // Fills the matrix of 0
96  void SetIdentity();
97 
98  template<class T0>
99  void SetDiagonal(const T0& a);
100 
101  void Fill();
102  void FillRand();
103 
104  template<class T0>
105  void Fill(const T0& a); // Fills the matrix of a
106 
107  bool IsZero() const;
108 
109  void Write(const string& file_name) const;
110  void Write(ostream& out) const;
111 
112  };
113 
115  template<int m, int n, int p>
116  class TinyMatrixNode<General, m, n, p>
117  {
118  public :
119  enum{ i = p/n, j = p%n };
120  };
121 
122 
124  template<int m, int p>
125  class TinyMatrixNode<Symmetric, m, m, p>
126  {
127  public :
128  enum{ i = TinyMatrixNode<Symmetric, m, m, p-1>::i
129  + (TinyMatrixNode<Symmetric, m, m, p-1>::j==(m-1)),
130  j = (TinyMatrixNode<Symmetric, m, m, p-1>::j + 1)
133  *(TinyMatrixNode<Symmetric, m, m, p-1>::j == (m-1))
134  };
135 
136  };
137 
138  template<int m>
139  class TinyMatrixNode<Symmetric, m, m, 0>
140  {
141  public :
142  enum { i = 0, j = 0};
143  };
144 
145  /*****************************
146  * TinyMatrix loop unrolling *
147  *****************************/
148 
150  template<int p, int q, int r>
152  {
153  public :
154  template<class T, int m>
155  static void AddRow(TinyMatrix<T, General, m, m>& A, const T& val);
156 
157  template<class T, int m>
158  static void ModifyUpperCholesky(TinyMatrix<T, Symmetric, m, m>& A,
159  T& invVal, T& vloc);
160 
161  };
162 
164  template<int p, int q>
165  class TinyMatrixTripleLoop<p, q, 0>
166  {
167  public :
168  template<class T, int m>
169  static inline void AddRow(TinyMatrix<T, General, m, m>& A, const T& val) {}
170 
171  template<class T, int m>
172  static inline void ModifyUpperCholesky(TinyMatrix<T, Symmetric, m, m>& A,
173  T& invVal, T& vloc) {}
174 
175  };
176 
178  template<int p, int q>
180  {
181  public :
182  template<int m, int n, class T0, class T1>
183  static void Init(const TinyVector<T0, m>& x, TinyMatrix<T1, General, m, n>& A);
184 
185  template<int m, int n, class T, class E>
186  static void WriteText(ostream& out, const TinyMatrixExpression<T, m, n, E>& A);
187 
188  template<int m, int n, class T, class Prop>
189  static void Write(ostream& out, const TinyMatrix<T, Prop, m, n>& A);
190 
191  template<int m, int n, class T, class E1, class E2>
192  static bool IsEqual(const TinyMatrixExpression<T, m, n, E1>& A,
194 
195  template<int m, int n, class T0, class E0, class T1, class E1, class T2>
196  static void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
198  T2& y);
199 
200  template<int m, int n, int k, class T0, class E0,
201  class T1, class E1, class T2, class Prop2>
202  static void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
205 
206  template<int m, int n, class T0, class T1, class E1, class T2, class E2, class T3>
207  static void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
209 
210  template<int m, int n, class T1, class E1, class T2, class E2, class T3>
211  static void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
213 
214  template<int m, class T0, class T1, class E1, class T3>
215  static void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
217 
218  template<int m, class T1, class E1, class T3>
219  static void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
221 
222  template<class T, int m>
223  static void GetMaximumColumn(TinyMatrix<T, General, m, m>& A, int& jmax, T& val);
224 
225  template<class T, int m>
226  static void SwapRow(TinyMatrix<T, General, m, m>& A, int i2, T& val);
227 
228  template<class T, int m>
229  static void SwapColumn(TinyMatrix<T, General, m, m>& A, int i2, T& val);
230 
231  template<class T, int m>
232  static void MltRow(TinyMatrix<T, General, m, m>& A, const T& coef);
233 
234  template<class T, int m>
236  const T& coef, T& val);
237 
238  template<class T, int m>
239  static void PerformSolve(TinyMatrix<T, General, m, m>& A, T& val);
240 
241  template<class T, int m>
242  static void GetDiagonalCholesky(TinyMatrix<T, Symmetric, m, m>& A, T& val);
243 
244  template<class T, int m>
246  T& invVal, T& vloc);
247 
248  template<class T, class T2, int m>
249  static void SolveCholesky(const class_SeldonNoTrans& trans,
251  TinyVector<T2, m>& x);
252 
253  template<class T, class T2, int m>
254  static void SolveCholesky(const class_SeldonTrans& trans,
256  TinyVector<T2, m>& x, T2& val);
257 
258  template<class T, class T2, int m>
259  static void MltCholesky(const class_SeldonTrans& trans,
261  TinyVector<T2, m>& x, T2& val);
262 
263  template<class T, class T2, int m>
264  static void MltCholesky(const class_SeldonNoTrans& trans,
266  TinyVector<T2, m>& x);
267 
268  };
269 
270 
272  template<int p>
274  {
275  public :
276  template<int m, int n, class T0, class T1>
277  static inline void Init(const TinyVector<T0, m>& x, TinyMatrix<T1, General, m, n>& A)
278  {}
279 
280  template<int m, int n, class T, class E>
281  static inline void WriteText(ostream& out, const TinyMatrixExpression<T, m, n, E>& A) {}
282 
283  template<int m, int n, class T, class Prop>
284  static inline void Write(ostream& out, const TinyMatrix<T, Prop, m, n>& A) {}
285 
286  template<int m, int n, class T, class E1, class E2>
287  static inline bool IsEqual(const TinyMatrixExpression<T, m, n, E1>& A,
288  const TinyMatrixExpression<T, m, n, E2>& B) { return true; }
289 
290  template<int m, int n, class T0, class E0, class T1, class E1, class T2>
291  static inline void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
293  T2& val) {}
294 
295  template<int m, int n, int k, class T0, class E0,
296  class T1, class E1, class T2, class Prop2>
297  static inline void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
300 
301  template<int m, int n, class T0, class T1, class E1, class T2, class E2, class T3>
302  static inline void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
305  {}
306 
307  template<int m, int n, class T1, class E1, class T2, class E2, class T3>
308  static inline void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
311  {}
312 
313  template<int m, class T0, class T1, class E1, class T3>
314  static inline void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
316  {}
317 
318  template<int m, class T1, class E1, class T3>
319  static inline void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
321  {}
322 
323  template<class T, int m>
324  static inline void GetMaximumColumn(TinyMatrix<T, General, m, m>& A, int& jmax, T& val) {}
325 
326  template<class T, int m>
327  static inline void SwapRow(TinyMatrix<T, General, m, m>& A, int i2, T& val) {}
328 
329  template<class T, int m>
330  static inline void SwapColumn(TinyMatrix<T, General, m, m>& A, int i2, T& val) {}
331 
332  template<class T, int m>
333  static inline void MltRow(TinyMatrix<T, General, m, m>& A, const T& coef) {}
334 
335  template<class T, int m>
336  static inline void PerformElimination(TinyMatrix<T, General, m, m>& A,
337  const T& coef, T& val) {}
338 
339  template<class T, int m>
340  static inline void PerformSolve(TinyMatrix<T, General, m, m>& A, T& val) {}
341 
342  template<class T, int m>
343  static inline void GetDiagonalCholesky(TinyMatrix<T, Symmetric, m, m>& A, T& val) {}
344 
345  template<class T, int m>
347  T& invVal, T& vloc) {}
348 
349  template<class T, class T2, int m>
350  static inline void SolveCholesky(const class_SeldonNoTrans& trans,
352  TinyVector<T2, m>& x) {}
353 
354  template<class T, class T2, int m>
355  static inline void SolveCholesky(const class_SeldonTrans& trans,
357  TinyVector<T2, m>& x, T2& val) {}
358 
359  template<class T, class T2, int m>
360  static inline void MltCholesky(const class_SeldonTrans& trans,
362  TinyVector<T2, m>& x, T2& val) {}
363 
364  template<class T, class T2, int m>
365  static inline void MltCholesky(const class_SeldonNoTrans& trans,
367  TinyVector<T2, m>& x) {}
368 
369  };
370 
372  template<int p>
373  class TinyMatrixLoop
374  {
375  public :
376  template<int m, int n, class T0, class Prop>
377  static void Zero(TinyMatrix<T0, Prop, m, n>& A);
378 
379  template<int m, int n, class T0, class T1>
380  static void Init(const TinyVector<TinyVector<T0, m>, n>& x,
382 
383  template<int m, int n, class T0, class Prop, class T1>
384  static void MltScal(const T0& alpha, TinyMatrix<T1, Prop, m, n>& A);
385 
386  template<int m, int n, class T1, class E, class T0, class Prop>
387  static void Copy(const TinyMatrixExpression<T1, m, n, E>& x,
389 
390  template<int m, int n, class T1, class E, class T0, class Prop>
391  static void AddCopy(const TinyMatrixExpression<T1, m, n, E>& x,
393 
394  template<int m, int n, class T1, class E, class T0, class Prop>
395  static void DiffCopy(const TinyMatrixExpression<T1, m, n, E>& x,
397 
398  template<int m, int n, class T, class Prop>
399  static void SetIdentity(TinyMatrix<T, Prop, m, n>& A);
400 
401  template<int m, int n, class T, class Prop, class T0>
402  static void SetDiagonal(TinyMatrix<T, Prop, m, n>& A, const T0& diag);
403 
404  template<int m, int n, class T, class Prop>
405  static void Fill(TinyMatrix<T, Prop, m, n>& A);
406 
407  template<int m, int n, class T, class Prop>
408  static void FillRand(TinyMatrix<T, Prop, m, n>& A);
409 
410  template<int m, int n, class T, class Prop, class T0>
411  static void Fill(TinyMatrix<T, Prop, m, n>& A, const T0& alpha);
412 
413  template<int m, int n, class Prop, class T>
414  static bool IsZero(const TinyMatrix<T, Prop, m, n>& A);
415 
416  template<int m, int n, class T, class E>
417  static void WriteText(ostream& out, const TinyMatrixExpression<T, m, n, E>& A);
418 
419  template<int m, int n, class T, class Prop>
420  static void Write(ostream& out, const TinyMatrix<T, Prop, m, n>& A);
421 
422  template<int m, int n, class T, class E1, class E2>
423  static bool IsEqual(const TinyMatrixExpression<T, m, n, E1>& A,
425 
426  template<int m, int n, class T0, class E0, class T1, class E1, class T2>
427  static void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
429  TinyVector<T2, m>& y);
430 
431  template<int m, int n, class T0, class E0, class T1, class E1, class T2>
432  static void MltAdd(const TinyMatrixExpression<T0, m, n, E0>& A,
434 
435  template<int m, int n, class T0, class E0, class T1, class E1, class T2, class T3>
436  static void MltAdd(const T3& alpha, const TinyMatrixExpression<T0, m, n, E0>& A,
438 
439  template<int m, int n, int k, class T0, class E0,
440  class T1, class E1, class T2, class Prop2>
441  static void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
444 
445  template<int m, int n, class T0, class T1, class E1, class T2, class E2, class T3>
446  static void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
449 
450  template<int m, int n, class T1, class E1, class T2, class E2, class T3>
451  static void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
454 
455  template<int m, class T0, class T1, class E1, class T3>
456  static void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
458 
459  template<int m, class T1, class E1, class T3>
460  static void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
462 
463  template<int m, int n, class T1, class E1>
464  static void GetCol(const TinyMatrixExpression<T1, m, n, E1>& A,
465  int k, TinyVector<T1, m>& x);
466 
467  template<int m, int n, class T0, class E0, class T1>
468  static void GetRow(const TinyMatrixExpression<T0, m, n, E0>& A,
469  int k, TinyVector<T1, n>& x);
470 
471  template<int m, int n, class T1, class E1, class Prop>
472  static void SetCol(const TinyVectorExpression<T1, m, E1>& x,
473  int k, TinyMatrix<T1, Prop, m, n>& A);
474 
475  template<int m, int n, class T1, class E1, class Prop>
476  static void SetRow(const TinyVectorExpression<T1, n, E1>& x,
477  int k, TinyMatrix<T1, Prop, m, n>& A);
478 
479  template<int m, int n, class T, class Prop, class T0>
480  static void GetMaxAbs(const TinyMatrix<T, Prop, m, n>& A, T0& amax);
481 
482  template<class T, int m>
484 
485  template<class T, int m>
486  static void SolveUpper(TinyMatrix<T, General, m, m>& A);
487 
488  template<class T, int m>
489  static void PermuteColumn(TinyMatrix<T, General, m, m>& A, const TinyVector<int, m>& pivot);
490 
491  template<class T, int m>
493 
494  template<class T, class T2, int m>
495  static void SolveCholesky(const class_SeldonNoTrans& trans,
497  TinyVector<T2, m>& x);
498 
499  template<class T, class T2, int m>
500  static void SolveCholesky(const class_SeldonTrans& trans,
502  TinyVector<T2, m>& x);
503 
504  template<class T, class T2, int m>
505  static void MltCholesky(const class_SeldonTrans& trans,
507  TinyVector<T2, m>& x);
508 
509  template<class T, class T2, int m>
510  static void MltCholesky(const class_SeldonNoTrans& trans,
512  TinyVector<T2, m>& x);
513 
514  };
515 
517  template<>
518  class TinyMatrixLoop<0>
519  {
520  public :
521  template<int m, int n, class T0, class Prop>
522  static inline void Zero(TinyMatrix<T0, Prop, m, n>& A) {}
523 
524  template<int m, int n, class T0, class T1>
525  static inline void Init(const TinyVector<TinyVector<T0, m>, n>& x,
527 
528  template<int m, int n, class T0, class Prop, class T1>
529  static inline void MltScal(const T0& alpha, TinyMatrix<T1, Prop, m, n>& A) {}
530 
531  template<int m, int n, class T1, class E, class T0, class Prop>
532  static inline void Copy(const TinyMatrixExpression<T1, m, n, E>& x,
534 
535  template<int m, int n, class T1, class E, class T0, class Prop>
536  static inline void AddCopy(const TinyMatrixExpression<T1, m, n, E>& x,
538 
539  template<int m, int n, class T1, class E, class T0, class Prop>
540  static inline void DiffCopy(const TinyMatrixExpression<T1, m, n, E>& x,
542 
543  template<int m, int n, class T, class Prop>
544  static inline void SetIdentity(TinyMatrix<T, Prop, m, n>& A) {}
545 
546  template<int m, int n, class T, class Prop, class T0>
547  static inline void SetDiagonal(TinyMatrix<T, Prop, m, n>& A, const T0& alpha) {}
548 
549  template<int m, int n, class T, class Prop>
550  static inline void Fill(TinyMatrix<T, Prop, m, n>& A) {}
551 
552  template<int m, int n, class T, class Prop>
553  static inline void FillRand(TinyMatrix<T, Prop, m, n>& A) {}
554 
555  template<int m, int n, class T, class Prop, class T0>
556  static inline void Fill(TinyMatrix<T, Prop, m, n>& A, const T0& alpha) {}
557 
558  template<int m, int n, class Prop, class T>
559  static inline bool IsZero(const TinyMatrix<T, Prop, m, n>& A) { return true; }
560 
561  template<int m, int n, class T, class E>
562  static inline void WriteText(ostream& out, const TinyMatrixExpression<T, m, n, E>& A) {}
563 
564  template<int m, int n, class T, class Prop>
565  static inline void Write(ostream& out, const TinyMatrix<T, Prop, m, n>& A) {}
566 
567  template<int m, int n, class T, class E1, class E2>
568  static inline bool IsEqual(const TinyMatrixExpression<T, m, n, E1>& A,
570  { return true; }
571 
572  template<int m, int n, class T0, class E0, class T1, class E1, class T2>
573  static inline void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
575  TinyVector<T2, m>& y) {}
576 
577  template<int m, int n, class T0, class E0, class T1, class E1, class T2>
578  static inline void MltAdd(const TinyMatrixExpression<T0, m, n, E0>& A,
580 
581  template<int m, int n, class T0, class E0, class T1, class E1, class T2, class T3>
582  static inline void MltAdd(const T3& alpha, const TinyMatrixExpression<T0, m, n, E0>& A,
584 
585  template<int m, int n, int k, class T0, class E0,
586  class T1, class E1, class T2, class Prop2>
587  static inline void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
590 
591  template<int m, int n, class T0, class T1, class E1, class T2, class E2, class T3>
592  static inline void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
595 
596  template<int m, int n, class T1, class E1, class T2, class E2, class T3>
597  static inline void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
600 
601  template<int m, class T0, class T1, class E1, class T3>
602  static inline void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
604 
605  template<int m, class T1, class E1, class T3>
606  static inline void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
608 
609  template<int m, int n, class T1, class E1>
610  static inline void GetCol(const TinyMatrixExpression<T1, m, n, E1>& A,
611  int k, TinyVector<T1, m>& x ) {}
612 
613  template<int m, int n, class T0, class E0, class T1>
614  static inline void GetRow(const TinyMatrixExpression<T0, m, n, E0>& A,
615  int k, TinyVector<T1, n>& x ) {}
616 
617  template<int m, int n, class T1, class E1, class Prop>
618  static inline void SetCol(const TinyVectorExpression<T1, m, E1>& x ,
619  int k, TinyMatrix<T1, Prop, m, n>& A) {}
620 
621  template<int m, int n, class T1, class E1, class Prop>
622  static inline void SetRow(const TinyVectorExpression<T1, n, E1>& x ,
623  int k, TinyMatrix<T1, Prop, m, n>& A) {}
624 
625  template<int m, int n, class T, class Prop, class T0>
626  static inline void GetMaxAbs(const TinyMatrix<T, Prop, m, n>& A, T0& amax)
627  {}
628 
629  template<class T, int m>
630  static inline void PivotGauss(TinyMatrix<T, General, m, m>& A,
631  TinyVector<int, m>& pivot) {}
632 
633  template<class T, int m>
634  static inline void SolveUpper(TinyMatrix<T, General, m, m>& A) {}
635 
636  template<class T, int m>
637  static inline void PermuteColumn(TinyMatrix<T, General, m, m>& A,
638  const TinyVector<int, m>& pivot) {}
639 
640  template<class T, int m>
641  static inline void GetCholesky(TinyMatrix<T, Symmetric, m, m>& A) {}
642 
643  template<class T, class T2, int m>
644  static inline void SolveCholesky(const class_SeldonNoTrans& trans,
646  TinyVector<T2, m>& x) {}
647 
648  template<class T, class T2, int m>
649  static inline void SolveCholesky(const class_SeldonTrans& trans,
651  TinyVector<T2, m>& x) {}
652 
653  template<class T, class T2, int m>
654  static inline void MltCholesky(const class_SeldonTrans& trans,
656  TinyVector<T2, m>& x) {}
657 
658  template<class T, class T2, int m>
659  static inline void MltCholesky(const class_SeldonNoTrans& trans,
661  TinyVector<T2, m>& x) {}
662 
663  };
664 
665 
666  /********************
667  * Symmetric matrix *
668  ********************/
669 
671  template <class T, int m>
672  class TinyMatrix<T, Symmetric, m, m>
673  : public TinyMatrixExpression<T, m, m, TinyMatrix<T, Symmetric, m, m> >
674  {
675  template<int p>
676  friend class TinyMatrixLoop;
677 
678  template<int p, int q>
679  friend class TinyMatrixDoubleLoop;
680 
681  template<int p, int q, int r>
682  class TinyMatrixTripleLoop;
683 
684  protected :
686  T data_[m*(m+1)/2];
687 
688  public :
689  enum{ size_ = m*(m+1)/2 };
690 
691  TinyMatrix();
692  explicit TinyMatrix(int i);
693  explicit TinyMatrix(int i, int j);
694 
695  template<class E>
697 
698  // Basic methods.
699  static int GetM();
700  static int GetN();
701  static int GetSize();
702  T* GetData();
703 
704  // product of a matrix by a scalar this = this * a where a is a scalar
705  template<class T1>
706  TinyMatrix<T, Symmetric, m, m> & operator *=(const T1& a );
707 
708  // sum of matrices res = this + B where B is a symmetric matrix
709  template<class T1, class E>
711 
712  // sum of matrices res = this - B where B is a symmetric matrix
713  template<class T1, class E>
715 
716  // fills matrix with x
717  TinyMatrix<T, Symmetric, m, m> & operator =(const T& x);
718 
719  // this = expresion with matrices
720  template<class T0, class E>
722 
723  T& operator()(int i,int j);
724  const T& operator()(int i,int j) const;
725 
726  // Convenient functions
727  void Zero(); // Fills the matrix of 0
728  void SetIdentity();
729 
730  template<class T0>
731  void SetDiagonal(const T0& alpha);
732 
733  void Fill();
734  void FillRand();
735 
736  template<class T1>
737  void Fill(const T1& a); // Fills the matrix of a
738 
739  bool IsZero() const;
740 
741  void WriteText(const string& file_name) const;
742  void Write(const string& file_name) const;
743  void Write(ostream& out) const;
744 
745  };
746 
747 
748  /*************
749  * Operators *
750  *************/
751 
752  template<class T, int m, int n, class E1, class E2>
753  bool operator==(const TinyMatrixExpression<T, m, n, E1> & u,
754  const TinyMatrixExpression<T, m, n, E2> & v);
755 
756  template<class T, int m, int n, class E1, class E2>
757  bool operator!=(const TinyMatrixExpression<T, m, n, E1> & u,
758  const TinyMatrixExpression<T, m, n, E2> & v);
759 
760  template <class T, int m, int n, class E>
761  ostream& operator <<(ostream& out, const TinyMatrixExpression<T, m, n, E> & A);
762 
763 
764  /****************************
765  * Matrix-vector operations *
766  ****************************/
767 
768  // returns A*x
769  template<class T, int m, int n, class E, class T1, class E1> TinyVector<T1, m>
770  dot(const TinyMatrixExpression<T, m, n, E>& A,
771  const TinyVectorExpression<T1, n, E1>& x);
772 
773  // returns A*B
774  template<class T, int m, int n, class E, class T1, int k, class E1>
775  TinyMatrix<T, General, m, k>
776  dot(const TinyMatrixExpression<T, m, n, E>& A,
777  const TinyMatrixExpression<T1, n, k, E1> & B);
778 
779  // product of a matrix by a vector y = A * x
780  template<class T0, class E0, class T1, class E1, class T2, int m, int n>
781  void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
782  const TinyVectorExpression<T1, n, E1>& x, TinyVector<T2, m>& y);
783 
784  // product of a matrix by a vector y = y + A*x
785  template<class T1, class E1, class T2, class E2, class T3, int m, int n>
786  void MltAdd(const TinyMatrixExpression<T1, m, n, E1>& A,
787  const TinyVectorExpression<T2, n, E2>& x, TinyVector<T3, m>& y);
788 
789  // product of a matrix by a vector y = y + alpha*A*x
790  template<class T0, class T1, class E1, class T2, class E2,
791  class T3, int m, int n>
792  void MltAdd(const T0& alpha, const TinyMatrixExpression<T1, m, n, E1>& A,
793  const TinyVectorExpression<T2, n, E2>& x, TinyVector<T3, m>& y);
794 
795  template<class T0, class E0, class T1, class E1, class T2, int m, int n>
796  void MltTrans(const TinyMatrixExpression<T0, m, n, E0>& A,
797  const TinyVectorExpression<T1, m, E1>& x, TinyVector<T2, n>& y);
798 
799  template<class T0, class E0, class T1, class E1, class T2, int m, int n>
800  void Mlt(const class_SeldonTrans&,
801  const TinyMatrixExpression<T0, m, n, E0>& A,
802  const TinyVectorExpression<T1, m, E1>& x, TinyVector<T2, n>& y);
803 
804  template<int m, int n, class T0, class T1, class E1,
805  class T2, class E2, class T3>
806  void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
807  const TinyVectorExpression<T2, n, E2>& y, TinyMatrix<T3, General, m, n>& A);
808 
809  template<int m, int n, class T1, class E1, class T2, class E2, class T3>
810  void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
811  const TinyVectorExpression<T2, n, E2>& y, TinyMatrix<T3, General, m, n>& A);
812 
813  template<int m, class T0, class T1, class E1, class T3>
814  void Rank1Update(const T0& alpha, const TinyVectorExpression<T1, m, E1>& x,
815  TinyMatrix<T3, Symmetric, m, m>& A);
816 
817  template<int m, class T1, class E1, class T3>
818  void Rank1Matrix(const TinyVectorExpression<T1, m, E1>& x,
819  TinyMatrix<T3, Symmetric, m, m>& A);
820 
821  template<int m, int n, class T1, class E1>
822  void GetCol(const TinyMatrixExpression<T1, m, n, E1>& A, int k, TinyVector<T1, m>& x);
823 
824  template<int m, int n, class T0, class E0, class T1>
825  void GetRow(const TinyMatrixExpression<T0, m, n, E0>& A, int k, TinyVector<T1, n>& x);
826 
827  template<int m, int n, class T1, class E1, class Prop>
828  void SetCol(const TinyVectorExpression<T1, m, E1>& x, int k, TinyMatrix<T1, Prop, m, n>& A);
829 
830  template<int m, int n, class T1, class E1, class Prop>
831  void SetRow(const TinyVectorExpression<T1, n, E1>& x, int k, TinyMatrix<T1, Prop, m, n>& A);
832 
833 
834  /****************************
835  * Matrix-Matrix operations *
836  ****************************/
837 
838  // B = A
839  template<class T, int m, int n, class E, class Prop>
840  void Copy(const TinyMatrixExpression<T, m, n, E>& A, TinyMatrix<T, Prop, m, n>& B);
841 
842  // C = A + B
843  template<class T0, class E0, class T1, class E1,
844  class T2, class Prop2, int m, int n>
845  void Add(const TinyMatrixExpression<T0, m, n, E0>& A,
846  const TinyMatrixExpression<T1, m, n, E1>& B, TinyMatrix<T2, Prop2, m, n>& C);
847 
848  // B = B + alpha*A
849  template<class T1, class E1, class T2, class Prop2, int m, int n>
850  void Add(const T1& alpha, const TinyMatrixExpression<T1, m, n, E1>& A,
851  TinyMatrix<T2, Prop2, m, n>& B);
852 
853  // B = B + A
854  template<class T0, class E0, class T1, class Prop1, int m, int n>
855  void Add(const TinyMatrixExpression<T0, m, n, E0>& A, TinyMatrix<T1, Prop1, m, n>& B);
856 
857  // product of a matrix by a scalar A = alpha * A
858  template<class T0, class T1, class Prop, int m, int n>
859  void Mlt(const T0& alpha, TinyMatrix<T1, General, m, n>& A);
860 
861  // product of a matrix by a matrix C = A * B
862  template<class T0, class E0, class T1, class E1,
863  class T2, class Prop2, int m, int n, int k>
864  void Mlt(const TinyMatrixExpression<T0, m, n, E0>& A,
865  const TinyMatrixExpression<T1, n, k, E1>& B,
866  TinyMatrix<T2, Prop2, m, k>& C);
867 
868  // product of a matrix by a matrix C = A * B^t
869  template<class T0, class E0, class T1, class E1,
870  class T2, class Prop2, int m, int n, int k>
871  void MltTrans(const TinyMatrixExpression<T0, m, n, E0>& A,
872  const TinyMatrixExpression<T1, k, n, E1>& B, TinyMatrix<T2, Prop2, m, k>& C);
873 
874  template<class T3, class T0, class E0, class T1, class E1,
875  class T2, class Prop2, class T4, int m, int n, int k>
876  void MltAdd(const T3& alpha, const class_SeldonTrans&,
877  const TinyMatrixExpression<T0, n, m, E0>& A,
878  const class_SeldonNoTrans&, const TinyMatrixExpression<T1, n, k, E1>& B,
879  const T4& beta, TinyMatrix<T2, Prop2, m, k>& C);
880 
881  template<class T, int m, int n, class E>
882  void Transpose(const TinyMatrixExpression<T, m, n, E> & A, TinyMatrix<T, General, n, m> & B);
883 
884  template<class T, int m>
885  void Transpose(TinyMatrix<T, General, m, m> & B);
886 
887  template<class T, class Prop, int m, int n>
888  typename ClassComplexType<T>::Treal MaxAbs(const TinyMatrix<T, Prop, m, n>& A);
889 
890  /***************************************
891  * Specific functions for 1x1 matrices *
892  ***************************************/
893 
894 
895  template<class T, class Prop>
896  T Det(const TinyMatrix<T, Prop, 1, 1> & A);
897 
898  template<class T>
899  void GetInverse(const TinyMatrix<T, General, 1, 1> & A,
900  TinyMatrix<T, General, 1, 1> & B);
901 
902  template<class T>
903  void GetInverse(const TinyMatrix<T, Symmetric, 1, 1> & A,
904  TinyMatrix<T, Symmetric, 1, 1> & B);
905 
906  template<class T>
907  void GetInverse(TinyMatrix<T, General, 1, 1> & B);
908 
909  template<class T>
910  void GetInverse(TinyMatrix<T, Symmetric, 1, 1> & B);
911 
912  template<class T0, class T1>
913  void GetNormalProjector(const TinyVector<T0, 1>& n, TinyMatrix<T1, Symmetric, 1, 1>& P);
914 
915  template<class T0, class T1>
916  void GetNormalProjector(const T0& n, TinyMatrix<T1, Symmetric, 1, 1>& P);
917 
918 
919  /***************************************
920  * Specific functions for 2x2 matrices *
921  ***************************************/
922 
923 
924  // determinant of a matrix 2x2
925  template<class T, class Prop>
926  T Det(const TinyMatrix<T, Prop, 2, 2> & A);
927 
928  template<class T0, class T1>
929  void GetTangentialProjector(const TinyVector<T0, 2>& n,
930  TinyMatrix<T1, Symmetric, 2, 2>& P);
931 
932  template<class T0, class T1>
933  void GetNormalProjector(const TinyVector<T0, 2>& n, TinyMatrix<T1, Symmetric, 2, 2>& P);
934 
935  template<class T0, class T1>
936  void GetNormalProjector(const TinyVector<T0, 2>& n, TinyMatrix<T1, General, 2, 2>& P);
937 
938  // non-inline functions
939  template<class T>
940  void GetInverse(const TinyMatrix<T, General, 2, 2> & A, TinyMatrix<T, General, 2, 2> & B);
941 
942  template<class T>
943  void GetInverse(TinyMatrix<T, General, 2, 2> & B);
944 
945  template<class T>
946  void GetInverse(const TinyMatrix<T, Symmetric, 2, 2> & A,
947  TinyMatrix<T, Symmetric, 2, 2> & B);
948 
949  template<class T>
950  void GetInverse(TinyMatrix<T, Symmetric, 2, 2> & B);
951 
952 
953  template<class T>
954  void GetEigenvalues(TinyMatrix<T, General, 2, 2>& A,
955  TinyVector<T, 2> & LambdaR, TinyVector<T, 2>& LambdaI);
956 
957  template<class T>
958  void GetEigenvalues(TinyMatrix<complex<T>, General, 2, 2>& A,
959  TinyVector<complex<T>, 2> & Lambda);
960 
961  template<class T>
962  void GetSquareRoot(TinyMatrix<T, Symmetric, 2, 2>& A);
963 
964 
965  /***************************************
966  * Specific functions for 3x3 matrices *
967  ***************************************/
968 
969 
970  // non-inline functions
971  template<class T, class Prop>
972  T Det(const TinyMatrix<T, Prop, 3, 3> & A);
973 
974  template<class T>
975  void GetInverse(const TinyMatrix<T, General, 3, 3> & A,
976  TinyMatrix<T, General, 3, 3> & B);
977 
978  template<class T>
979  void GetInverse(TinyMatrix<T, General, 3, 3> & B);
980 
981  template<class T>
982  void GetInverse(const TinyMatrix<T, Symmetric, 3, 3> & A,
983  TinyMatrix<T, Symmetric, 3, 3> & B);
984 
985  template<class T>
986  void GetInverse(TinyMatrix<T, Symmetric, 3, 3> & B);
987 
988  template<class T0, class T1>
989  void GetTangentialProjector(const TinyVector<T0, 3>& n,
990  TinyMatrix<T1, Symmetric, 3, 3>& P);
991 
992  template<class T0, class T1>
993  void GetNormalProjector(const TinyVector<T0, 3>& n,
994  TinyMatrix<T1, Symmetric, 3, 3>& P);
995 
996  template<class T0, class T1>
997  void GetNormalProjector(const TinyVector<T0, 3>& n,
998  TinyMatrix<T1, General, 3, 3>& P);
999 
1000 
1001  /*******************
1002  * Other functions *
1003  *******************/
1004 
1005 
1006  template<class T0, class T1, int m>
1007  void GetTangentialProjector(const TinyVector<T0, m>& n,
1008  TinyMatrix<T1, Symmetric, m, m>& P);
1009 
1010  template<class T0, class T1, int m>
1011  void GetNormalProjector(const TinyVector<T0, m>& n,
1012  TinyMatrix<T1, Symmetric, m, m>& P);
1013 
1014  template<class T, class Prop, int m, int n>
1015  void FillZero(TinyMatrix<T, Prop, m, n>& X);
1016 
1018  template<class T, int m, int n>
1019  void DotProdCol(const TinyMatrix<T, General, m, n>& A,
1020  const TinyMatrix<T, General, m, n>& B, TinyVector<T, n>& res);
1021 
1022  // non-inline functions
1023  template<class T, class Property, int m, int n>
1024  typename ClassComplexType<T>::Treal
1025  Norm2_Column(const TinyMatrix<T, Property, m, n>& A,
1026  int first_row, int index_col);
1027 
1028  template<class T, class Property, class Storage, class Allocator>
1029  typename ClassComplexType<T>::Treal
1030  Norm2_Column(const Matrix<T, Property, Storage, Allocator>& A,
1031  int first_row, int index_col);
1032 
1033  template<class T, int m>
1034  void GetInverse(TinyMatrix<T, General, m, m>& A);
1035 
1036  template<class T, int m>
1037  void GetInverse(const TinyMatrix<T, General, m, m>& A,
1038  TinyMatrix<T, General, m, m>& B);
1039 
1040  template<class T, int m>
1041  void GetInverse(TinyMatrix<T, Symmetric, m, m> & A);
1042 
1043  template<class T, int m>
1044  void GetInverse(const TinyMatrix<T, Symmetric, m, m>& A,
1045  TinyMatrix<T, Symmetric, m, m>& B);
1046 
1047  template<class T, int m>
1048  void GetCholesky(TinyMatrix<T, Symmetric, m, m>& A);
1049 
1050  template<class T, class T2, int m>
1051  void SolveCholesky(const class_SeldonNoTrans& trans,
1052  const TinyMatrix<T, Symmetric, m, m>& A,
1053  TinyVector<T2, m>& x);
1054 
1055  template<class T, class T2, int m>
1056  void SolveCholesky(const class_SeldonTrans& trans,
1057  const TinyMatrix<T, Symmetric, m, m>& A,
1058  TinyVector<T2, m>& x);
1059 
1060  template<class T, class T2, int m>
1061  void MltCholesky(const class_SeldonNoTrans& trans,
1062  const TinyMatrix<T, Symmetric, m, m>& A,
1063  TinyVector<T2, m>& x);
1064 
1065  template<class T, class T2, int m>
1066  void MltCholesky(const class_SeldonTrans& trans,
1067  const TinyMatrix<T, Symmetric, m, m>& A,
1068  TinyVector<T2, m>& x);
1069 
1070  template<int m, class T>
1071  void GetEigenvaluesEigenvectors(TinyMatrix<T, Symmetric, m, m>& A,
1072  TinyVector<T, m>& w,
1073  TinyMatrix<T, General, m, m>& z);
1074 
1075  template<int m, class T>
1076  void GetEigenvalues(TinyMatrix<T, Symmetric, m, m>& A,
1077  TinyVector<T, m>& w);
1078 
1079  template<class T, int m>
1080  void GetSquareRoot(TinyMatrix<T, Symmetric, m, m>& A);
1081 
1082 } // end namespace
1083 
1084 
1085 #define SELDON_FILE_TINY_MATRIX_HXX
1086 #endif
1087 
Seldon::TinyMatrixTripleLoop::AddRow
static void AddRow(TinyMatrix< T, General, m, m > &A, const T &val)
A(j, :) += val*A(i, :)
Definition: TinyMatrixInline.cxx:265
Seldon::TinyMatrix< T, General, m, n >
Class storing small matrices whose number of rows and columns is known at compilation time.
Definition: TinyMatrix.hxx:37
Seldon::TinyMatrixLoop::IsZero
static bool IsZero(const TinyMatrix< T, Prop, m, n > &A)
returns true if the matrix is null
Definition: TinyMatrixInline.cxx:687
Seldon::TinyMatrixDoubleLoop::SwapColumn
static void SwapColumn(TinyMatrix< T, General, m, m > &A, int i2, T &val)
swapping columns i and i2 (for pivoting)
Definition: TinyMatrixInline.cxx:438
Seldon::TinyMatrixLoop::DiffCopy
static void DiffCopy(const TinyMatrixExpression< T1, m, n, E > &x, TinyMatrix< T0, Prop, m, n > &y)
y -= x
Definition: TinyMatrixInline.cxx:624
Seldon::TinyMatrixDoubleLoop::Mlt
static void Mlt(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, n, E1 > &x, T2 &y)
y = A*x
Definition: TinyMatrixInline.cxx:334
Seldon::operator==
bool operator==(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this == u
Definition: TinyMatrixInline.cxx:1245
Seldon::TinyMatrixLoop::MltAdd
static void MltAdd(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, n, E1 > &x, TinyVector< T2, m > &y)
y = y + A*x
Definition: TinyMatrixInline.cxx:746
Seldon::Rank1Matrix
void Rank1Matrix(const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = x y^T.
Definition: TinyMatrixInline.cxx:1358
Seldon::TinyMatrixNode
Definition: TinyMatrix.hxx:16
Seldon::TinyMatrix
empty class overloaded for general and symmetric matrices
Definition: TinyMatrix.hxx:11
Seldon::TinyMatrixDoubleLoop::Write
static void Write(ostream &out, const TinyMatrix< T, Prop, m, n > &A)
writes matrix A in binary format
Definition: TinyMatrixInline.cxx:310
Seldon::TinyMatrixDoubleLoop::GetDiagonalCholesky
static void GetDiagonalCholesky(TinyMatrix< T, Symmetric, m, m > &A, T &val)
Loop val -= A(k, j)*A(k, j) with k between 0 and j-1.
Definition: TinyMatrixInline.cxx:495
Seldon::TinyVectorExpression
Expression between vectors.
Definition: TinyVectorExpression.hxx:8
Seldon::TinyMatrixLoop::FillRand
static void FillRand(TinyMatrix< T, Prop, m, n > &A)
sets randomly all the elements of A
Definition: TinyMatrixInline.cxx:669
Seldon::TinyMatrixDoubleLoop::SwapRow
static void SwapRow(TinyMatrix< T, General, m, m > &A, int i2, T &val)
swapping rows i and i2 (for pivoting)
Definition: TinyMatrixInline.cxx:426
Seldon::TinyMatrixDoubleLoop::SolveCholesky
static void SolveCholesky(const class_SeldonNoTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x)
double loop for Cholesky resolution and NoTranspose
Definition: TinyMatrixInline.cxx:518
Seldon::TinyMatrixDoubleLoop::GetMaximumColumn
static void GetMaximumColumn(TinyMatrix< T, General, m, m > &A, int &jmax, T &val)
returns index jmax for which |A(i, j)| is maximal
Definition: TinyMatrixInline.cxx:410
Seldon::TinyMatrixLoop::Write
static void Write(ostream &out, const TinyMatrix< T, Prop, m, n > &A)
writes matrix A in binary format
Definition: TinyMatrixInline.cxx:709
Seldon::TinyMatrixLoop::SetIdentity
static void SetIdentity(TinyMatrix< T, Prop, m, n > &A)
sets matrix to the identity matrix
Definition: TinyMatrixInline.cxx:636
Seldon::TinyMatrixDoubleLoop::WriteText
static void WriteText(ostream &out, const TinyMatrixExpression< T, m, n, E > &A)
writes matrix A in ascii format
Definition: TinyMatrixInline.cxx:300
Seldon::class_SeldonNoTrans
Definition: MatrixFlag.hxx:62
Seldon::TinyMatrixLoop::Copy
static void Copy(const TinyMatrixExpression< T1, m, n, E > &x, TinyMatrix< T0, Prop, m, n > &y)
y = x
Definition: TinyMatrixInline.cxx:600
Seldon::TinyMatrixLoop::GetMaxAbs
static void GetMaxAbs(const TinyMatrix< T, Prop, m, n > &A, T0 &amax)
computes the maximal element of matrix A
Definition: TinyMatrixInline.cxx:873
Seldon::TinyMatrixLoop::SetCol
static void SetCol(const TinyVectorExpression< T1, m, E1 > &x, int k, TinyMatrix< T1, Prop, m, n > &A)
A(:, k) = x.
Definition: TinyMatrixInline.cxx:854
Seldon::TinyMatrixLoop::Init
static void Init(const TinyVector< TinyVector< T0, m >, n > &x, TinyMatrix< T1, General, m, n > &A)
Conversion from vector of vectors to matrix.
Definition: TinyMatrixInline.cxx:580
Seldon::TinyMatrixLoop::Fill
static void Fill(TinyMatrix< T, Prop, m, n > &A)
sets matrix to [0, 1, 2; 3, 4, 5 ...]
Definition: TinyMatrixInline.cxx:660
Seldon::TinyVector
vector with real/complex components
Definition: TinyVector.hxx:17
Seldon::TinyMatrixLoop
class for simple loops for matrix operations
Definition: TinyMatrix.hxx:22
Seldon::TinyMatrixDoubleLoop::ModifyUpperCholesky
static void ModifyUpperCholesky(TinyMatrix< T, Symmetric, m, m > &A, T &invVal, T &vloc)
Loop with k between j+1 and n-1.
Definition: TinyMatrixInline.cxx:505
Seldon::TinyMatrixLoop::GetRow
static void GetRow(const TinyMatrixExpression< T0, m, n, E0 > &A, int k, TinyVector< T1, n > &x)
x = A(k, :)
Definition: TinyMatrixInline.cxx:844
Seldon::TinyMatrixDoubleLoop::PerformSolve
static void PerformSolve(TinyMatrix< T, General, m, m > &A, T &val)
solving by upper matrix
Definition: TinyMatrixInline.cxx:478
Seldon::GetSquareRoot
void GetSquareRoot(TinyMatrix< T, Symmetric, 2, 2 > &A)
replaces A by its square root
Definition: TinyMatrix.cxx:109
Seldon::TinyMatrixLoop::SolveCholesky
static void SolveCholesky(const class_SeldonNoTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x)
simple loop for Cholesky resolution and NoTranspose
Definition: TinyMatrixInline.cxx:952
Seldon::TinyMatrixDoubleLoop::Init
static void Init(const TinyVector< T0, m > &x, TinyMatrix< T1, General, m, n > &A)
Conversion from vector of vectors to matrix.
Definition: TinyMatrixInline.cxx:290
Seldon::class_SeldonTrans
Definition: MatrixFlag.hxx:55
Seldon::TinyMatrixDoubleLoop::Rank1Update
static void Rank1Update(const T0 &alpha, const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = A + alpha * x y^T.
Definition: TinyMatrixInline.cxx:364
Seldon::TinyMatrixDoubleLoop::MltRow
static void MltRow(TinyMatrix< T, General, m, m > &A, const T &coef)
A(i, :) = A(i, :)*coef.
Definition: TinyMatrixInline.cxx:450
Seldon::TinyMatrixLoop::PivotGauss
static void PivotGauss(TinyMatrix< T, General, m, m > &A, TinyVector< int, m > &pivot)
step i1 of Gauss elimination
Definition: TinyMatrixInline.cxx:883
Seldon::TinyMatrixLoop::SetRow
static void SetRow(const TinyVectorExpression< T1, n, E1 > &x, int k, TinyMatrix< T1, Prop, m, n > &A)
A(k, :) = x.
Definition: TinyMatrixInline.cxx:864
Seldon::TinyMatrixLoop::PermuteColumn
static void PermuteColumn(TinyMatrix< T, General, m, m > &A, const TinyVector< int, m > &pivot)
swapping columns for Gauss pivoting
Definition: TinyMatrixInline.cxx:922
Seldon::TinyMatrix< T, Symmetric, m, m >
class storing tiny small matrices
Definition: TinyMatrix.hxx:672
Seldon::TinyMatrixLoop::AddCopy
static void AddCopy(const TinyMatrixExpression< T1, m, n, E > &x, TinyMatrix< T0, Prop, m, n > &y)
y += x
Definition: TinyMatrixInline.cxx:612
Seldon::General
Definition: Properties.hxx:26
Seldon::TinyMatrixLoop::WriteText
static void WriteText(ostream &out, const TinyMatrixExpression< T, m, n, E > &A)
writes matrix A in ascii format
Definition: TinyMatrixInline.cxx:699
Seldon::TinyMatrixLoop::GetCol
static void GetCol(const TinyMatrixExpression< T1, m, n, E1 > &A, int k, TinyVector< T1, m > &x)
x = A(:, k)
Definition: TinyMatrixInline.cxx:834
Seldon::TinyMatrixDoubleLoop
class for double loop in matrix functions
Definition: TinyMatrix.hxx:25
Seldon::MltTrans
void MltTrans(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, m, E1 > &x, TinyVector< T2, n > &y)
y = A^t * x
Definition: TinyMatrixInline.cxx:1329
Seldon::TinyMatrixExpression
Expression between vectors.
Definition: TinyMatrixExpression.hxx:8
Seldon::TinyMatrixLoop::GetCholesky
static void GetCholesky(TinyMatrix< T, Symmetric, m, m > &A)
main loop for Cholesky factorisation
Definition: TinyMatrixInline.cxx:934
Seldon::TinyMatrixLoop::Rank1Update
static void Rank1Update(const T0 &alpha, const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = A + alpha * x y^T.
Definition: TinyMatrixInline.cxx:789
Seldon::Transpose
void Transpose(Matrix< T, Prop, Storage, Allocator > &A)
Matrix transposition.
Definition: Functions_Matrix.cxx:2699
Seldon::operator!=
bool operator!=(const TinyMatrixExpression< T, m, n, E1 > &u, const TinyMatrixExpression< T, m, n, E2 > &v)
returns true if *this != u
Definition: TinyMatrixInline.cxx:1254
Seldon::TinyMatrixDoubleLoop::MltCholesky
static void MltCholesky(const class_SeldonTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x, T2 &val)
double loop for Cholesky multiplication and Transpose
Definition: TinyMatrixInline.cxx:554
Seldon::TinyMatrixLoop::MltScal
static void MltScal(const T0 &alpha, TinyMatrix< T1, Prop, m, n > &A)
A = alpha*A.
Definition: TinyMatrixInline.cxx:590
Seldon::TinyMatrixLoop::MltCholesky
static void MltCholesky(const class_SeldonTrans &trans, const TinyMatrix< T, Symmetric, m, m > &A, TinyVector< T2, m > &x)
simple loop for Cholesky multiplication and Transpose
Definition: TinyMatrixInline.cxx:991
Seldon::TinyMatrixLoop::Mlt
static void Mlt(const TinyMatrixExpression< T0, m, n, E0 > &A, const TinyVectorExpression< T1, n, E1 > &x, TinyVector< T2, m > &y)
y = A*x
Definition: TinyMatrixInline.cxx:733
Seldon::Symmetric
Definition: Properties.hxx:30
Seldon::MaxAbs
ClassComplexType< T >::Treal MaxAbs(const Matrix< T, Prop, Storage, Allocator > &A)
Returns the maximum (in absolute value) of a matrix.
Definition: Functions_Matrix.cxx:2386
Seldon::TinyMatrixLoop::SetDiagonal
static void SetDiagonal(TinyMatrix< T, Prop, m, n > &A, const T0 &diag)
sets matrix to the identity matrix multiplied by a coefficient alpha
Definition: TinyMatrixInline.cxx:647
Seldon::TinyMatrixDoubleLoop::Rank1Matrix
static void Rank1Matrix(const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = x y^T.
Definition: TinyMatrixInline.cxx:376
Seldon::TinyMatrixLoop::IsEqual
static bool IsEqual(const TinyMatrixExpression< T, m, n, E1 > &A, const TinyMatrixExpression< T, m, n, E2 > &B)
returns true if A == B
Definition: TinyMatrixInline.cxx:719
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::dot
TinyVector< T1, m > dot(const TinyMatrixExpression< T, m, n, E > &A, const TinyVectorExpression< T1, n, E1 > &x)
returns A*x
Definition: TinyMatrixInline.cxx:1277
Seldon::operator<<
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
Definition: Array.cxx:1617
Seldon::DotProdCol
void DotProdCol(const TinyMatrix< T, General, m, n > &A, const TinyMatrix< T, General, m, n > &B, TinyVector< T, n > &res)
res = A . B, where the scalar product is performed between columns of A and B
Definition: TinyMatrixInline.cxx:1680
Seldon::TinyMatrixTripleLoop
class for triple loop in matrix functions
Definition: TinyMatrix.hxx:28
Seldon::TinyMatrixLoop::Rank1Matrix
static void Rank1Matrix(const TinyVectorExpression< T1, m, E1 > &x, const TinyVectorExpression< T2, n, E2 > &y, TinyMatrix< T3, General, m, n > &A)
A = x y^T.
Definition: TinyMatrixInline.cxx:801
Seldon::TinyMatrixDoubleLoop::PerformElimination
static void PerformElimination(TinyMatrix< T, General, m, m > &A, const T &coef, T &val)
performs Lj = Lj - a_ji/aii Li to eliminate element a_ij
Definition: TinyMatrixInline.cxx:460
Seldon::TinyMatrixLoop::SolveUpper
static void SolveUpper(TinyMatrix< T, General, m, m > &A)
solving by upper matrix
Definition: TinyMatrixInline.cxx:910