MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlMatrix5.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_MATRIX5_H
14#define ML_MATRIX5_H
15
17
18// Include system independent file and project settings.
20#include "mlLinearAlgebraDefs.h"
21
22
24
25#include "mlVector5.h"
26
27#include "mlMatrix4.h"
28
29#include <mlErrorMacros.h>
30#include <mlErrorOutput.h>
31
32// All declarations of this header will be in the ML_LINEAR_ALGEBRA namespace.
34//--------------------------------------------------------------------
36// This is necessary because we do not know whether vector or
37// matrix header is included first and we cannot move template
38// code into the C++ file.
39//--------------------------------------------------------------------
40template <class DT> class Tvec5;
41template <class DT> class Tmat4;
43
44//--------------------------------------------------------------------
46//--------------------------------------------------------------------
47template <class DT> class Tmat5 : public FloatingPointMatrix<Tvec5<DT>, 5>
48{
49public:
51 typedef DT ComponentType;
52
55
57 Tmat5(const DT diagValue);
58
60 Tmat5(const Tvec5<DT>& row0, const Tvec5<DT>& row1, const Tvec5<DT>& row2, const Tvec5<DT>& row3,
61 const Tvec5<DT>& row4);
62
65
67 Tmat5(const float mat[25]);
68
70 Tmat5(const double mat[25]);
71
74 Tmat5(const double in00, const double in01, const double in02, const double in03, const double in04,
75 const double in10, const double in11, const double in12, const double in13, const double in14,
76 const double in20, const double in21, const double in22, const double in23, const double in24,
77 const double in30, const double in31, const double in32, const double in33, const double in34,
78 const double in40, const double in41, const double in42, const double in43, const double in44);
79
82 void setValues(const float m[25]);
83
88 void getValues(float m[25]) const;
89
92 void setValues(const double m[25]);
93
96 void getValues(double m[25]) const;
97
99 void setScaleMatrix(const DT scale);
100
102 static Tmat5<DT> getMat(const double val);
103
105 void set(const DT val);
106
109 bool operator<(const Tmat5<DT>&) const
110 {
111 return false;
112 }
113
116
119
122
124 const Tmat5<DT>& operator*=(const DT d);
125
128 const Tmat5<DT>& operator/=(const DT d);
129
130 //-------------------------------------------------
131 // Special functions
132 //-------------------------------------------------
134 DT determinantLower4(const int col1, const int col2, const int col3, const int col4) const;
135
137 DT det() const;
138
146 Tmat5<DT> inverse(bool* isInvertible = nullptr) const;
147
150
153
156
157}; // end of class *Tmat5*
158
159
160//---------------------------------------------------------------------
161// Constructors
162//---------------------------------------------------------------------
164template <class DT> inline Tmat5<DT>::Tmat5()
165{
166 this->v[0] = this->v[1] = this->v[2] = this->v[3] = this->v[4] = Tvec5<DT>(0);
167}
168
170template <class DT> inline Tmat5<DT>::Tmat5(const DT diagValue)
171{
172 this->v[0][0] = this->v[1][1] = this->v[2][2] = this->v[3][3] = this->v[4][4] = diagValue;
173 this->v[1][0] = this->v[2][0] = this->v[3][0] = this->v[4][0] = this->v[2][1] = this->v[3][1] = this->v[4][1] =
174 this->v[3][2] = this->v[4][2] = this->v[4][3] = 0;
175 this->v[0][1] = this->v[0][2] = this->v[0][3] = this->v[0][4] = this->v[1][2] = this->v[1][3] = this->v[1][4] =
176 this->v[2][3] = this->v[2][4] = this->v[3][4] = 0;
177}
178
179
181template <class DT> inline Tmat5<DT>::Tmat5(const Tvec5<DT>& row0, const Tvec5<DT>& row1, const Tvec5<DT>& row2,
182 const Tvec5<DT>& row3, const Tvec5<DT>& row4)
183{
184 this->v[0] = row0;
185 this->v[1] = row1;
186 this->v[2] = row2;
187 this->v[3] = row3;
188 this->v[4] = row4;
189}
190
192template <class DT> inline Tmat5<DT>::Tmat5(const Tmat5<DT>& mat)
193{
194 this->v[0] = mat.v[0];
195 this->v[1] = mat.v[1];
196 this->v[2] = mat.v[2];
197 this->v[3] = mat.v[3];
198 this->v[4] = mat.v[4];
199}
200
202template <class DT> inline Tmat5<DT>::Tmat5(const float mat[25])
203{
204 setValues(mat);
205}
206
208template <class DT> inline Tmat5<DT>::Tmat5(const double mat[25])
209{
210 setValues(mat);
211}
212
214template <class DT> inline Tmat5<DT> Tmat5<DT>::getMat(const double val)
215{
216 return Tmat5<DT>(val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val,
217 val, val, val, val, val);
218}
219
221template <class DT> inline void Tmat5<DT>::set(const DT val)
222{
223 this->v[0] = this->v[1] = this->v[2] = this->v[3] = this->v[4] = Tvec5<DT>(val);
224}
225
227template <class DT> inline const Tmat5<DT>& Tmat5<DT>::operator=(const Tmat5<DT>& m)
228{
229 if (&m != this) {
230 this->v[0] = m.v[0];
231 this->v[1] = m.v[1];
232 this->v[2] = m.v[2];
233 this->v[3] = m.v[3];
234 this->v[4] = m.v[4];
235 }
236
237 return *this;
238}
239
241template <class DT> inline const Tmat5<DT>& Tmat5<DT>::operator+=(const Tmat5<DT>& m)
242{
243 this->v[0] += m.v[0];
244 this->v[1] += m.v[1];
245 this->v[2] += m.v[2];
246 this->v[3] += m.v[3];
247 this->v[4] += m.v[4];
248
249 return *this;
250}
251
253template <class DT> inline const Tmat5<DT>& Tmat5<DT>::operator-=(const Tmat5<DT>& m)
254{
255 this->v[0] -= m.v[0];
256 this->v[1] -= m.v[1];
257 this->v[2] -= m.v[2];
258 this->v[3] -= m.v[3];
259 this->v[4] -= m.v[4];
260
261 return *this;
262}
263
265template <class DT> inline const Tmat5<DT>& Tmat5<DT>::operator*=(const DT d)
266{
267 this->v[0] *= d;
268 this->v[1] *= d;
269 this->v[2] *= d;
270 this->v[3] *= d;
271 this->v[4] *= d;
272
273 return *this;
274}
275
277template <class DT> inline const Tmat5<DT>& Tmat5<DT>::operator/=(const DT d)
278{
280 this->v[0] /= d;
281 this->v[1] /= d;
282 this->v[2] /= d;
283 this->v[3] /= d;
284 this->v[4] /= d;
285 return *this;
286}
287
288
289//--------------------------------------------------------------------
292//--------------------------------------------------------------------
294template <class DT> inline Tmat5<DT> operator-(const Tmat5<DT>& a)
295{
296 return Tmat5<DT>(a) *= static_cast<DT>(-1.0);
297}
298
300template <class DT> inline Tmat5<DT> operator+(const Tmat5<DT>& a, const Tmat5<DT>& b)
301{
302 return Tmat5<DT>(a) += b;
303}
304
306template <class DT> inline Tmat5<DT> operator-(const Tmat5<DT>& a, const Tmat5<DT>& b)
307{
308 return Tmat5<DT>(a) -= b;
309}
310
312template <class DT> inline Tmat5<DT> operator*(const Tmat5<DT>& a, const DT d)
313{
314 return Tmat5<DT>(a) *= d;
315}
316
318template <class DT> inline Tmat5<DT> operator*(const DT d, const Tmat5<DT>& a)
319{
320 return Tmat5<DT>(a) *= d;
321}
322
325template <class DT> inline Tmat5<DT> operator/(const Tmat5<DT>& a, const DT d)
326{
329 divided /= d;
330 return divided;
331}
333
334//-------------------------------------------------------------------
335//
336// Tmat5 member functions
337//
338//-------------------------------------------------------------------
339
340//-------------------------------------------------------------------
343//-------------------------------------------------------------------
344template <class DT>
345Tmat5<DT>::Tmat5(const double in00, const double in01, const double in02, const double in03, const double in04,
346 const double in10, const double in11, const double in12, const double in13, const double in14,
347 const double in20, const double in21, const double in22, const double in23, const double in24,
348 const double in30, const double in31, const double in32, const double in33, const double in34,
349 const double in40, const double in41, const double in42, const double in43, const double in44)
350{
351 this->v[0][0] = static_cast<DT>(in00);
352 this->v[0][1] = static_cast<DT>(in01);
353 this->v[0][2] = static_cast<DT>(in02);
354 this->v[0][3] = static_cast<DT>(in03);
355 this->v[0][4] = static_cast<DT>(in04);
356 this->v[1][0] = static_cast<DT>(in10);
357 this->v[1][1] = static_cast<DT>(in11);
358 this->v[1][2] = static_cast<DT>(in12);
359 this->v[1][3] = static_cast<DT>(in13);
360 this->v[1][4] = static_cast<DT>(in14);
361 this->v[2][0] = static_cast<DT>(in20);
362 this->v[2][1] = static_cast<DT>(in21);
363 this->v[2][2] = static_cast<DT>(in22);
364 this->v[2][3] = static_cast<DT>(in23);
365 this->v[2][4] = static_cast<DT>(in24);
366 this->v[3][0] = static_cast<DT>(in30);
367 this->v[3][1] = static_cast<DT>(in31);
368 this->v[3][2] = static_cast<DT>(in32);
369 this->v[3][3] = static_cast<DT>(in33);
370 this->v[3][4] = static_cast<DT>(in34);
371 this->v[4][0] = static_cast<DT>(in40);
372 this->v[4][1] = static_cast<DT>(in41);
373 this->v[4][2] = static_cast<DT>(in42);
374 this->v[4][3] = static_cast<DT>(in43);
375 this->v[4][4] = static_cast<DT>(in44);
376}
377
378
379//--------------------------------------------------------------------
382//--------------------------------------------------------------------
383template <class DT> void Tmat5<DT>::setValues(const float m[25])
384{
385 this->v[0][0] = static_cast<DT>(m[0]);
386 this->v[0][1] = static_cast<DT>(m[1]);
387 this->v[0][2] = static_cast<DT>(m[2]);
388 this->v[0][3] = static_cast<DT>(m[3]);
389 this->v[0][4] = static_cast<DT>(m[4]);
390
391 this->v[1][0] = static_cast<DT>(m[5]);
392 this->v[1][1] = static_cast<DT>(m[6]);
393 this->v[1][2] = static_cast<DT>(m[7]);
394 this->v[1][3] = static_cast<DT>(m[8]);
395 this->v[1][4] = static_cast<DT>(m[9]);
396
397 this->v[2][0] = static_cast<DT>(m[10]);
398 this->v[2][1] = static_cast<DT>(m[11]);
399 this->v[2][2] = static_cast<DT>(m[12]);
400 this->v[2][3] = static_cast<DT>(m[13]);
401 this->v[2][4] = static_cast<DT>(m[14]);
402
403 this->v[3][0] = static_cast<DT>(m[15]);
404 this->v[3][1] = static_cast<DT>(m[16]);
405 this->v[3][2] = static_cast<DT>(m[17]);
406 this->v[3][3] = static_cast<DT>(m[18]);
407 this->v[3][4] = static_cast<DT>(m[19]);
408
409 this->v[4][0] = static_cast<DT>(m[20]);
410 this->v[4][1] = static_cast<DT>(m[21]);
411 this->v[4][2] = static_cast<DT>(m[22]);
412 this->v[4][3] = static_cast<DT>(m[23]);
413 this->v[4][4] = static_cast<DT>(m[24]);
414}
415
416//--------------------------------------------------------------------
421//--------------------------------------------------------------------
422template <class DT> void Tmat5<DT>::getValues(float m[25]) const
423{
424 m[0] = static_cast<float>(this->v[0][0]);
425 m[1] = static_cast<float>(this->v[0][1]);
426 m[2] = static_cast<float>(this->v[0][2]);
427 m[3] = static_cast<float>(this->v[0][3]);
428 m[4] = static_cast<float>(this->v[0][4]);
429
430 m[5] = static_cast<float>(this->v[1][0]);
431 m[6] = static_cast<float>(this->v[1][1]);
432 m[7] = static_cast<float>(this->v[1][2]);
433 m[8] = static_cast<float>(this->v[1][3]);
434 m[9] = static_cast<float>(this->v[1][4]);
435
436 m[10] = static_cast<float>(this->v[2][0]);
437 m[11] = static_cast<float>(this->v[2][1]);
438 m[12] = static_cast<float>(this->v[2][2]);
439 m[13] = static_cast<float>(this->v[2][3]);
440 m[14] = static_cast<float>(this->v[2][4]);
441
442 m[15] = static_cast<float>(this->v[3][0]);
443 m[16] = static_cast<float>(this->v[3][1]);
444 m[17] = static_cast<float>(this->v[3][2]);
445 m[18] = static_cast<float>(this->v[3][3]);
446 m[19] = static_cast<float>(this->v[3][4]);
447
448 m[20] = static_cast<float>(this->v[4][0]);
449 m[21] = static_cast<float>(this->v[4][1]);
450 m[22] = static_cast<float>(this->v[4][2]);
451 m[23] = static_cast<float>(this->v[4][3]);
452 m[24] = static_cast<float>(this->v[4][4]);
453}
454
455//--------------------------------------------------------------------
458//--------------------------------------------------------------------
459template <class DT> void Tmat5<DT>::setValues(const double m[25])
460{
461 this->v[0][0] = static_cast<DT>(m[0]);
462 this->v[0][1] = static_cast<DT>(m[1]);
463 this->v[0][2] = static_cast<DT>(m[2]);
464 this->v[0][3] = static_cast<DT>(m[3]);
465 this->v[0][4] = static_cast<DT>(m[4]);
466
467 this->v[1][0] = static_cast<DT>(m[5]);
468 this->v[1][1] = static_cast<DT>(m[6]);
469 this->v[1][2] = static_cast<DT>(m[7]);
470 this->v[1][3] = static_cast<DT>(m[8]);
471 this->v[1][4] = static_cast<DT>(m[9]);
472
473 this->v[2][0] = static_cast<DT>(m[10]);
474 this->v[2][1] = static_cast<DT>(m[11]);
475 this->v[2][2] = static_cast<DT>(m[12]);
476 this->v[2][3] = static_cast<DT>(m[13]);
477 this->v[2][4] = static_cast<DT>(m[14]);
478
479 this->v[3][0] = static_cast<DT>(m[15]);
480 this->v[3][1] = static_cast<DT>(m[16]);
481 this->v[3][2] = static_cast<DT>(m[17]);
482 this->v[3][3] = static_cast<DT>(m[18]);
483 this->v[3][4] = static_cast<DT>(m[19]);
484
485 this->v[4][0] = static_cast<DT>(m[20]);
486 this->v[4][1] = static_cast<DT>(m[21]);
487 this->v[4][2] = static_cast<DT>(m[22]);
488 this->v[4][3] = static_cast<DT>(m[23]);
489 this->v[4][4] = static_cast<DT>(m[24]);
490}
491
492//--------------------------------------------------------------------
495//--------------------------------------------------------------------
496template <class DT> void Tmat5<DT>::getValues(double m[25]) const
497{
498 m[0] = static_cast<double>(this->v[0][0]);
499 m[1] = static_cast<double>(this->v[0][1]);
500 m[2] = static_cast<double>(this->v[0][2]);
501 m[3] = static_cast<double>(this->v[0][3]);
502 m[4] = static_cast<double>(this->v[0][4]);
503
504 m[5] = static_cast<double>(this->v[1][0]);
505 m[6] = static_cast<double>(this->v[1][1]);
506 m[7] = static_cast<double>(this->v[1][2]);
507 m[8] = static_cast<double>(this->v[1][3]);
508 m[9] = static_cast<double>(this->v[1][4]);
509
510 m[10] = static_cast<double>(this->v[2][0]);
511 m[11] = static_cast<double>(this->v[2][1]);
512 m[12] = static_cast<double>(this->v[2][2]);
513 m[13] = static_cast<double>(this->v[2][3]);
514 m[14] = static_cast<double>(this->v[2][4]);
515
516 m[15] = static_cast<double>(this->v[3][0]);
517 m[16] = static_cast<double>(this->v[3][1]);
518 m[17] = static_cast<double>(this->v[3][2]);
519 m[18] = static_cast<double>(this->v[3][3]);
520 m[19] = static_cast<double>(this->v[3][4]);
521
522 m[20] = static_cast<double>(this->v[4][0]);
523 m[21] = static_cast<double>(this->v[4][1]);
524 m[22] = static_cast<double>(this->v[4][2]);
525 m[23] = static_cast<double>(this->v[4][3]);
526 m[24] = static_cast<double>(this->v[4][4]);
527}
528
529
530//-------------------------------------------------------------------
532//-------------------------------------------------------------------
533template <class DT> void Tmat5<DT>::setScaleMatrix(const DT scale)
534{
535 this->v[0][0] = scale;
536 this->v[0][1] = 0;
537 this->v[0][2] = 0;
538 this->v[0][3] = 0;
539 this->v[0][4] = 0;
540 this->v[1][0] = 0;
541 this->v[1][1] = scale;
542 this->v[1][2] = 0;
543 this->v[1][3] = 0;
544 this->v[1][4] = 0;
545 this->v[2][0] = 0;
546 this->v[2][1] = 0;
547 this->v[2][2] = scale;
548 this->v[2][3] = 0;
549 this->v[2][4] = 0;
550 this->v[3][0] = 0;
551 this->v[3][1] = 0;
552 this->v[3][2] = 0;
553 this->v[3][3] = scale;
554 this->v[3][4] = 0;
555 this->v[4][0] = 0;
556 this->v[4][1] = 0;
557 this->v[4][2] = 0;
558 this->v[4][3] = 0;
559 this->v[4][4] = scale;
560}
561
562
563//-------------------------------------------------------------------
566//-------------------------------------------------------------------
567
568//--------------------------------------------------------------------
570//--------------------------------------------------------------------
571template <class DT>
572inline DT Tmat5<DT>::determinantLower4(const int col1, const int col2, const int col3, const int col4) const
573{
574 /* Determinant of 4x4 matrix with given entries */
575 return Tmat4<DT>(this->v[1][col1], this->v[1][col2], this->v[1][col3], this->v[1][col4], this->v[2][col1],
576 this->v[2][col2], this->v[2][col3], this->v[2][col4], this->v[3][col1], this->v[3][col2],
577 this->v[3][col3], this->v[3][col4], this->v[4][col1], this->v[4][col2], this->v[4][col3],
578 this->v[4][col4])
579 .det();
580}
581
582//--------------------------------------------------------------------
584//--------------------------------------------------------------------
585template <class DT> DT Tmat5<DT>::det() const
586{
587 return (this->v[0][0] * determinantLower4(1, 2, 3, 4) - this->v[0][1] * determinantLower4(0, 2, 3, 4) +
588 this->v[0][2] * determinantLower4(0, 1, 3, 4) - this->v[0][3] * determinantLower4(0, 1, 2, 4) +
589 this->v[0][4] * determinantLower4(0, 1, 2, 3));
590}
591
592//--------------------------------------------------------------------
600//--------------------------------------------------------------------
601template <class DT> Tmat5<DT> Tmat5<DT>::inverse(bool* isInvertible) const
602{
603 // Epsilon for comparison with 0 in inversion process.
604 static const DT Epsilon = static_cast<DT>(10e-13);
605
606 // Use helper function from tools to invert the matrix.
608 "Tmat5<DT> Tmat5<DT>::inverse(bool* isInvertible) const, matrix not invertable",
609 getIdentity(), 5);
610}
611
612
613//-------------------------------------------------------------------
615//-------------------------------------------------------------------
616template <class DT> inline Tmat5<DT> Tmat5<DT>::transpose() const
617{
618 return Tmat5<DT>(Tvec5<DT>(this->v[0][0], this->v[1][0], this->v[2][0], this->v[3][0], this->v[4][0]),
619 Tvec5<DT>(this->v[0][1], this->v[1][1], this->v[2][1], this->v[3][1], this->v[4][1]),
620 Tvec5<DT>(this->v[0][2], this->v[1][2], this->v[2][2], this->v[3][2], this->v[4][2]),
621 Tvec5<DT>(this->v[0][3], this->v[1][3], this->v[2][3], this->v[3][3], this->v[4][3]),
622 Tvec5<DT>(this->v[0][4], this->v[1][4], this->v[2][4], this->v[3][4], this->v[4][4]));
623}
624
625//-------------------------------------------------------------------
627//-------------------------------------------------------------------
628template <class DT> inline Tmat5<DT> Tmat5<DT>::getIdentity()
629{
630 return Tmat5<DT>(Tvec5<DT>(1, 0, 0, 0, 0), Tvec5<DT>(0, 1, 0, 0, 0), Tvec5<DT>(0, 0, 1, 0, 0),
631 Tvec5<DT>(0, 0, 0, 1, 0), Tvec5<DT>(0, 0, 0, 0, 1));
632}
633
634//-------------------------------------------------------------------
636//-------------------------------------------------------------------
637template <class DT> const Tmat5<DT>& Tmat5<DT>::apply(MLDblFuncPtr fct)
638{
639 this->v[0].apply(fct);
640 this->v[1].apply(fct);
641 this->v[2].apply(fct);
642 this->v[3].apply(fct);
643 this->v[4].apply(fct);
644 return *this;
645}
646
647
649#define _ML_MAT5_RC(i, j) \
650 a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j] + a[i][3] * b[3][j] + a[i][4] * b[4][j]
651//-------------------------------------------------------------------
653//-------------------------------------------------------------------
654template <class DT> Tmat5<DT> operator*(const Tmat5<DT>& a, const Tmat5<DT>& b)
655{
656 return Tmat5<DT>(
657 Tvec5<DT>(_ML_MAT5_RC(0, 0), _ML_MAT5_RC(0, 1), _ML_MAT5_RC(0, 2), _ML_MAT5_RC(0, 3), _ML_MAT5_RC(0, 4)),
658 Tvec5<DT>(_ML_MAT5_RC(1, 0), _ML_MAT5_RC(1, 1), _ML_MAT5_RC(1, 2), _ML_MAT5_RC(1, 3), _ML_MAT5_RC(1, 4)),
659 Tvec5<DT>(_ML_MAT5_RC(2, 0), _ML_MAT5_RC(2, 1), _ML_MAT5_RC(2, 2), _ML_MAT5_RC(2, 3), _ML_MAT5_RC(2, 4)),
660 Tvec5<DT>(_ML_MAT5_RC(3, 0), _ML_MAT5_RC(3, 1), _ML_MAT5_RC(3, 2), _ML_MAT5_RC(3, 3), _ML_MAT5_RC(3, 4)),
661 Tvec5<DT>(_ML_MAT5_RC(4, 0), _ML_MAT5_RC(4, 1), _ML_MAT5_RC(4, 2), _ML_MAT5_RC(4, 3), _ML_MAT5_RC(4, 4)));
662}
663#undef _ML_MAT5_RC
664
665
666// Note: Multiplications with Vector5 are implemented with/in class Tvec5.
667
668
669//-------------------------------------------------------------------
671//-------------------------------------------------------------------
672template <class DT> inline bool operator==(const Tmat5<DT>& a, const Tmat5<DT>& b)
673{
674 return (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]) && (a[3] == b[3]) && (a[4] == b[4]);
675}
676
677//-------------------------------------------------------------------
679//-------------------------------------------------------------------
680template <class DT> inline bool operator!=(const Tmat5<DT>& a, const Tmat5<DT>& b)
681{
682 return !(a == b);
683}
685
686
687//-----------------------------------------------------------------------------------
690//-----------------------------------------------------------------------------------
691
701
702
704
705namespace std
706{
707 //-------------------------------------------------------------------
709 //-------------------------------------------------------------------
710 template <class DT> inline std::ostream& operator<<(std::ostream& os, const ML_LA_NAMESPACE::Tmat5<DT>& m)
711 {
712 return os << m[0] << '\n' << m[1] << '\n' << m[2] << '\n' << m[3] << '\n' << m[4];
713 }
714
715 //-------------------------------------------------------------------
717 //-------------------------------------------------------------------
718 template <class DT> inline std::istream& operator>>(std::istream& is, ML_LA_NAMESPACE::Tmat5<DT>& m)
719 {
720 ML_LA_NAMESPACE::Tmat5<DT> m_tmp;
721
722 is >> m_tmp[0] >> m_tmp[1] >> m_tmp[2] >> m_tmp[3] >> m_tmp[4];
723 if (is) {
724 m = m_tmp;
725 }
726 return is;
727 }
728} // namespace std
729
730
731#endif // __mlMatrix5_H
Base class of all matrix classes that holds the data buffer and provides some general access methods.
VectorT v[size]
The rows constituting the matrix.
A 5x5 matrix class of five row vectors.
Definition mlMatrix5.h:48
Tmat5 transpose() const
Returns the transposed of this matrix.
Definition mlMatrix5.h:616
const Tmat5< DT > & operator+=(const Tmat5< DT > &m)
Adds component-wise by a Tmat5.
Definition mlMatrix5.h:241
const Tmat5< DT > & operator/=(const DT d)
Divides by a scalar constant d.
Definition mlMatrix5.h:277
void set(const DT val)
Sets all values to val.
Definition mlMatrix5.h:221
static Tmat5< DT > getMat(const double val)
Returns a matrix filled with values val.
Definition mlMatrix5.h:214
static Tmat5 getIdentity()
Returns the identity matrix.
Definition mlMatrix5.h:628
bool operator<(const Tmat5< DT > &) const
Dummy 'lesser than operator' which always returns false.
Definition mlMatrix5.h:109
Tmat5()
Builds a 5x5 matrix from 25 zero elements.
Definition mlMatrix5.h:164
DT ComponentType
A typedef to 'export' the type of components.
Definition mlMatrix5.h:51
void setScaleMatrix(const DT scale)
Sets the diagonal matrix with scale on the diagonal.
Definition mlMatrix5.h:533
DT det() const
Determinant.
Definition mlMatrix5.h:585
Tmat5(const float mat[25])
Constructor from 25 floats given as array mat, row by row.
Definition mlMatrix5.h:202
Tmat5(const Tvec5< DT > &row0, const Tvec5< DT > &row1, const Tvec5< DT > &row2, const Tvec5< DT > &row3, const Tvec5< DT > &row4)
Builds the matrix of the five row vectors row0, ..., row5.
Definition mlMatrix5.h:181
const Tmat5< DT > & operator=(const Tmat5< DT > &m)
Assigns from a Tmat5.
Definition mlMatrix5.h:227
void setValues(const float m[25])
Copies the contents from float array m into *this.
Definition mlMatrix5.h:383
const Tmat5< DT > & operator*=(const DT d)
Multiplies by a scalar constant d.
Definition mlMatrix5.h:265
Tmat5< DT > inverse(bool *isInvertible=nullptr) const
Returns the inverse Gauss-Jordan elimination with partial pivoting.
Definition mlMatrix5.h:601
const Tmat5< DT > & apply(MLDblFuncPtr fct)
Applies the function fct to each component.
Definition mlMatrix5.h:637
Tmat5(const double in00, const double in01, const double in02, const double in03, const double in04, const double in10, const double in11, const double in12, const double in13, const double in14, const double in20, const double in21, const double in22, const double in23, const double in24, const double in30, const double in31, const double in32, const double in33, const double in34, const double in40, const double in41, const double in42, const double in43, const double in44)
Initializes all matrix elements explicitly with scalars, filling it row by row.
Definition mlMatrix5.h:345
Tmat5(const Tmat5< DT > &mat)
Copy constructor from the Tmat5 mat.
Definition mlMatrix5.h:192
void getValues(double m[25]) const
Copies the contents of *this into double array m.
Definition mlMatrix5.h:496
void getValues(float m[25]) const
Copies the contents of *this into float array m.
Definition mlMatrix5.h:422
const Tmat5< DT > & operator-=(const Tmat5< DT > &m)
Subtracts component-wise by a Tmat5.
Definition mlMatrix5.h:253
Tmat5(const DT diagValue)
Builds a matrix that has the argument diagValue as the diagonal values, zero otherwise.
Definition mlMatrix5.h:170
Tmat5(const double mat[25])
Constructor from 25 doubles given as array mat, row by row.
Definition mlMatrix5.h:208
void setValues(const double m[25])
Copies the contents from double array m into *this.
Definition mlMatrix5.h:459
DT determinantLower4(const int col1, const int col2, const int col3, const int col4) const
Determines the (sub)determinant of columns given by col1, col2, col3, and col4.
Definition mlMatrix5.h:572
Forward declarations to resolve header file dependencies.
Definition mlVector5.h:47
#define ML_CHECK_FLOAT_THROW(x)
#define _ML_MAT5_RC(i, j)
Internal helper macro to multiply two matrices, do not use.
Definition mlMatrix5.h:649
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double(* MLDblFuncPtr)(double)
A function pointer type to a function that returns a double and takes a double as argument.
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component-wise division of lhs by specialized rhs of type MLdouble.
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Returns true if yes.
Definition mlMatrix2.h:399
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Returns true if yes.
Definition mlMatrix2.h:405
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component-wise subtraction of rhs from lhs.
BASE_TYPE MLInverseMatHelper(const BASE_TYPE &origMat, bool *isInvertible, const typename BASE_TYPE::ComponentType, const char *const ZeroDetErrString, const BASE_TYPE &Identity, const size_t Dim)
Computes an N dimensional inverse from given default parameters.
STL namespace.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
istream & operator>>(istream &is, ml::FloatingPointVector< T, size, DataContainer > &v)
Reads a vector from std::istream.