ACF $AcfVersion:0$
TMatrix.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <istd/TArray.h>
7#include <istd/CIndex2d.h>
8#include <iser/CArchiveTag.h>
9#include <imath/TVector.h>
10
11
12namespace iser
13{
14 class IArchive;
15}
16
17
18namespace imath
19{
20
21
25template <int Width, int Height, typename Element = double>
27{
28public:
31 typedef Element ElementType;
34
58
63
67 explicit TMatrix(MatrixInitMode mode);
68
72 TMatrix(const TMatrix& matrix);
73
78 void Reset();
79
84 void Clear();
85
91
96 int GetDimensionsCount() const;
97
104 bool SetDimensionsCount(int count);
105
109 const SizesType& GetSizes() const;
110
116 bool SetSizes(const SizesType& sizes);
117
121 int GetSize(int dimension) const;
122
128 bool SetSize(int dimension, int size);
129
133 const ElementType& GetAt(const IndexType& index) const;
134
138 const ElementType& GetAt(int x, int y) const;
139
144
148 ElementType& GetAtRef(int x, int y);
149
153 void SetAt(const IndexType& index, const ElementType& value);
154
158 void SetAt(int x, int y, const ElementType& value);
159
164
165 /*
166 Get maximal element.
167 */
168 double GetMaxElement() const;
169
170 /*
171 Get minimal element.
172 */
173 double GetMinElement() const;
174
179
184
189
193 template <int SecondWidth>
195 {
196 for (int resultY = 0; resultY < Height; ++resultY){
197 for (int resultX = 0; resultX < SecondWidth; ++resultX){
198 double sum = 0;
199 for (int i = 0; i < Width; ++i){
200 sum += m_elements[i][resultY] * matrix.m_elements[resultX][i];
201 }
202
203 result.m_elements[resultX][resultY] = sum;
204 }
205 }
206 }
207
211 template <int SecondWidth>
213 {
215
216 GetMultiplied(matrix, retVal);
217
218 return retVal;
219 }
220
225
230
234 void GetScaled(double value, TMatrix<Width, Height, Element>& result) const;
235
240
245
249 void Transpose();
250
254 double GetTrace() const;
255
256 /*
257 Get square of euclidean norm.
258 */
259 double GetFrobeniusNorm2() const;
260
261 /*
262 Get euclidean norm.
263 */
264 double GetFrobeniusNorm() const;
265
278 int maxColumns = -1,
279 double minHhNorm = I_BIG_EPSILON) const;
280
285 bool GetDecompositionQDQ(TMatrix<Height, Height, Element>& matrixQ, TVector<Height, Element>& diagonalD, double tolerance = I_BIG_EPSILON, int maxIterations = 100) const;
286
290 void GetColumnVector(int columnIndex, TVector<Height, Element>& result) const;
291
295 void SetColumnVector(int columnIndex, const TVector<Height, Element>& columnVector);
296
300 void GetRowVector(int rowIndex, TVector<Width, Element>& result);
301
302 bool Serialize(iser::IArchive& archive);
303
304 // operators
308
309 template <int SecondWidth>
311 {
313
314 GetMultiplied(matrix, retVal);
315
316 return retVal;
317 }
318
320
324
327
328 const ElementType& operator[](const IndexType& index) const;
330
332
333private:
334 typedef Element Elements[Width][Height];
335
336 Elements m_elements;
337};
338
339
340// inline methods
341
342template <int Width, int Height, typename Element>
344{
346
347 GetTransposed(retVal);
348
349 return retVal;
350}
351
352
353template <int Width, int Height, typename Element>
355{
357
358 GetTransposed(retVal);
359
360 *this = retVal;
361}
362
363
364template <int Width, int Height, typename Element>
366{
368
369 GetMultiplied(vector, retVal);
370
371 return retVal;
372}
373
374
375template <int Width, int Height, typename Element>
377{
379
380 GetAdded(matrix, retVal);
381
382 return retVal;
383}
384
385
386template <int Width, int Height, typename Element>
388{
390
391 GetSubstracted(matrix, retVal);
392
393 return retVal;
394}
395
396
397template <int Width, int Height, typename Element>
399{
401
402 GetNegated(retVal);
403
404 return retVal;
405}
406
407
408template <int Width, int Height, typename Element>
410{
411 TMatrix retVal;
412
413 GetScaled(value, retVal);
414
415 return retVal;
416}
417
418
419template <int Width, int Height, typename Element>
421{
422 GetAdded(matrix, *this);
423
424 return *this;
425}
426
427
428template <int Width, int Height, typename Element>
430{
431 GetSubstracted(matrix, *this);
432
433 return *this;
434}
435
436
437template <int Width, int Height, typename Element>
439{
440 GetScaled(value, *this);
441
442 return *this;
443}
444
445
446template <int Width, int Height, typename Element>
448{
449 return matrix * value;
450}
451
452
453// public methods
454
455template <int Width, int Height, typename Element>
459
460
461template <int Width, int Height, typename Element>
463{
464 switch (mode){
465 case MIM_ZERO:
466 for (int x = 0; x < Width; ++x){
467 for (int y = 0; y < Height; ++y){
468 m_elements[x][y] = 0;
469 }
470 }
471 break;
472
473 case MIM_ONES:
474 for (int x = 0; x < Width; ++x){
475 for (int y = 0; y < Height; ++y){
476 m_elements[x][y] = 1;
477 }
478 }
479 break;
480
481 case MIM_IDENTITY:
482 for (int x = 0; x < Width; ++x){
483 for (int y = 0; y < Height; ++y){
484 if (x == y){
485 m_elements[x][y] = 1;
486 }
487 else{
488 m_elements[x][y] = 0;
489 }
490 }
491 }
492 break;
493
494 case MIM_UPPER_TRIANGLE:
495 for (int x = 0; x < Width; ++x){
496 for (int y = 0; y < Height; ++y){
497 if (x <= y){
498 m_elements[x][y] = 1;
499 }
500 else{
501 m_elements[x][y] = 0;
502 }
503 }
504 }
505 break;
506
507 case MIM_DOWNER_TRIANGLE:
508 for (int x = 0; x < Width; ++x){
509 for (int y = 0; y < Height; ++y){
510 if (x >= y){
511 m_elements[x][y] = 1;
512 }
513 else{
514 m_elements[x][y] = 0;
515 }
516 }
517 }
518 break;
519 }
520}
521
522
523template <int Width, int Height, typename Element>
525{
526 for (int x = 0; x < Width; ++x){
527 for (int y = 0; y < Height; ++y){
528 m_elements[x][y] = matrix.m_elements[x][y];
529 }
530 }
531}
532
533
534// init operations
535
536template <int Width, int Height, typename Element>
538{
539 for (int x = 0; x < Width; ++x){
540 for (int y = 0; y < Height; ++y){
541 m_elements[x][y] = 0;
542 }
543 }
544}
545
546
547template <int Width, int Height, typename Element>
549{
550 Reset();
551}
552
553
554template <int Width, int Height, typename Element>
556{
557 return true;
558}
559
560
561template <int Width, int Height, typename Element>
563{
564 return 2;
565}
566
567
568template <int Width, int Height, typename Element>
570{
571 return (count == 2);
572}
573
574
575template <int Width, int Height, typename Element>
577{
578 static SizesType retVal(Width, Height);
579
580 return retVal;
581}
582
583
584template <int Width, int Height, typename Element>
586{
587 return (sizes[0] == Width) && (sizes[1] == Height);
588}
589
590
591template <int Width, int Height, typename Element>
593{
594 switch (dimension){
595 case 0:
596 return Width;
597
598 case 1:
599 return Height;
600
601 default:
602 return 0;
603 }
604}
605
606
607template <int Width, int Height, typename Element>
608bool TMatrix<Width, Height, Element>::SetSize(int dimension, int size)
609{
610 switch (dimension){
611 case 0:
612 return (size == Width);
613
614 case 1:
615 return (size == Height);
616
617 default:
618 return false;
619 }
620}
621
622
623template <int Width, int Height, typename Element>
625{
626 return m_elements[index[0]][index[1]];
627}
628
629
630template <int Width, int Height, typename Element>
632{
633 return m_elements[x][y];
634}
635
636
637template <int Width, int Height, typename Element>
639{
640 return m_elements[index[0]][index[1]];
641}
642
643
644template <int Width, int Height, typename Element>
646{
647 return m_elements[x][y];
648}
649
650
651template <int Width, int Height, typename Element>
653{
654 m_elements[index[0]][index[1]] = value;
655}
656
657
658template <int Width, int Height, typename Element>
660{
661 m_elements[x][y] = value;
662}
663
664
665template <int Width, int Height, typename Element>
667{
668 for (int x = 0; x < Width; ++x){
669 for (int y = 0; y < Height; ++y){
670 if (x != y){
671 m_elements[x][y] = 0;
672 }
673 else{
674 m_elements[x][y] = 1;
675 }
676 }
677 }
678}
679
680
681template <int Width, int Height, typename Element>
683{
684 double retVal = m_elements[0][0];
685
686 for (int x = 0; x < Width; ++x){
687 for (int y = 0; y < Height; ++y){
688 double value = m_elements[x][y];
689
690 if (value > retVal){
691 retVal = value;
692 }
693 }
694 }
695
696 return retVal;
697}
698
699
700template <int Width, int Height, typename Element>
702{
703 double retVal = m_elements[0][0];
704
705 for (int x = 0; x < Width; ++x){
706 for (int y = 0; y < Height; ++y){
707 double value = m_elements[x][y];
708
709 if (value < retVal){
710 retVal = value;
711 }
712 }
713 }
714
715 return retVal;
716}
717
718
719template <int Width, int Height, typename Element>
721{
722 for (int x = 0; x < Width; ++x){
723 for (int y = 0; y < Height; ++y){
724 result.m_elements[x][y] = -m_elements[x][y];
725 }
726 }
727}
728
729
730template <int Width, int Height, typename Element>
732{
733 for (int x = 0; x < Width; ++x){
734 for (int y = 0; y < Height; ++y){
735 result.m_elements[x][y] = m_elements[x][y] + matrix.m_elements[x][y];
736 }
737 }
738}
739
740
741template <int Width, int Height, typename Element>
743{
744 for (int x = 0; x < Width; ++x){
745 for (int y = 0; y < Height; ++y){
746 result.m_elements[x][y] = m_elements[x][y] - matrix.m_elements[x][y];
747 }
748 }
749}
750
751
752template <int Width, int Height, typename Element>
754{
755 for (int resultY = 0; resultY < Height; ++resultY){
756 double sum = 0;
757 for (int i = 0; i < Width; ++i){
758 sum += m_elements[i][resultY] * vector[i];
759 }
760
761 result[resultY] = sum;
762 }
763}
764
765
766template <int Width, int Height, typename Element>
768{
769 for (int x = 0; x < Width; ++x){
770 for (int y = 0; y < Height; ++y){
771 result.m_elements[x][y] = m_elements[x][y] * value;
772 }
773 }
774}
775
776
777template <int Width, int Height, typename Element>
779{
780 for (int x = 0; x < Width; ++x){
781 for (int y = 0; y < Height; ++y){
782 result.SetAt(y, x, GetAt(x, y));
783 }
784 }
785}
786
787
788template <int Width, int Height, typename Element>
790{
791 int commonSize = qMin(Width, Height);
792
793 double retVal = 0;
794 for (int i = 0; i < commonSize; ++i){
795 retVal += m_elements[i][i];
796 }
797
798 return retVal;
799}
800
801
802template <int Width, int Height, typename Element>
804{
805 double retVal = 0.0;
806
807 for (int x = 0; x < Width; ++x){
808 for (int y = 0; y < Height; ++y){
809 double value = m_elements[x][y];
810 retVal += double(value * value);
811 }
812 }
813 return retVal;
814}
815
816
817template <int Width, int Height, typename Element>
819{
820 return qSqrt(GetFrobeniusNorm2());
821}
822
823
824template <int Width, int Height, typename Element>
826{
827 if (Width != Height){
828 return false;
829 }
830
831 TMatrix<Width, Height, Element> matrixR = *this;
832 matrixQ.Clear();
833
834 for (int i = 0; i < maxIterations; ++i){
837 if (!matrixR.GetTriangleDecomposed(tempMatrixR, &tempMatrixQ)){
838 return false;
839 }
840 matrixR = tempMatrixR.GetMultiplied(tempMatrixQ);
841
842 matrixQ = tempMatrixQ.GetMultiplied(matrixQ);
843
844 double residue = 0;
845 istd::CIndex2d index;
846 for (index[0] = 0; index[0] < Width; ++index[0]){
847 for (index[1] = 0; index[1] < Width; ++index[1]){
848 if (index[0] != index[1]){
849 double element = matrixR.GetAt(index);
850
851 residue += element * element;
852 }
853 }
854 }
855
856 if (residue <= tolerance){
857 for (int i = 0; i < Height; ++i){
858 diagonalD[i] = matrixR.GetAt(i, i);
859 }
860
861 return true;
862 }
863 }
864
865 return false;
866}
867
868
869template <int Width, int Height, typename Element>
871{
872 Q_ASSERT(columnIndex < Width);
873 Q_ASSERT(columnIndex >= 0);
874
875 for (int y = 0; y < Height; ++y){
876 result[y] = m_elements[columnIndex][y];
877 }
878}
879
880
881template <int Width, int Height, typename Element>
883{
884 Q_ASSERT(columnIndex < Width);
885 Q_ASSERT(columnIndex >= 0);
886
887 for (int y = 0; y < Height; ++y){
888 m_elements[columnIndex][y] = columnVector[y];
889 }
890}
891
892
893template <int Width, int Height, typename Element>
895{
896 Q_ASSERT(rowIndex < Height);
897
898 for (int x = 0; x < Width; ++x){
899 result[x] = m_elements[x][rowIndex];
900 }
901}
902
903
904template <int Width, int Height, typename Element>
908 int maxColumns,
909 double minHhNorm) const
910{
911 if (&result != this){
912 result = *this;
913 }
914
915 int columnsCount = qMin(Height - 1, Width);
916 if ((maxColumns >= 0) && (maxColumns < columnsCount)){
917 columnsCount = maxColumns;
918 }
919
920 for (int hhIndex = 0; hhIndex < columnsCount; ++hhIndex){
921 double hhNorm2 = 0;
922 for (istd::CIndex2d normIndex(hhIndex, hhIndex); normIndex[1] < Height; ++normIndex[1]){
923 double element = result.GetAt(normIndex);
924
925 hhNorm2 += element * element;
926 }
927
928 if (hhNorm2 < minHhNorm){
929 return false;
930 }
931
932 double element0 = result[istd::CIndex2d(hhIndex, hhIndex)];
933
934 double hhLength = (element0 >= 0)? qSqrt(hhNorm2): -qSqrt(hhNorm2); // destination diagonal value of current processed column, sign is choosen optimal for maximal householder vector length
935
936 double hhVector0 = element0 + hhLength; // element 0 of householder vector, rest of ist will be taken directly from matrix elements
937 double hhVectorNorm2 = hhNorm2 + hhVector0 * hhVector0 - element0 * element0; // sqare of norm of householder vector, first element replaced from original column norm sqare
938
939 // correct next columns
940 istd::CIndex2d matrixIndex;
941 for (matrixIndex[0] = hhIndex + 1; matrixIndex[0] < Width; ++matrixIndex[0]){
942 matrixIndex[1] = hhIndex;
943 double dotProduct = result[matrixIndex] * hhVector0;
944 for (matrixIndex[1]++; matrixIndex[1] < Height; ++matrixIndex[1]){
945 dotProduct += result.GetAt(matrixIndex) * result.GetAt(istd::CIndex2d(hhIndex, matrixIndex[1]));
946 }
947
948 double reflexionFactor = 2 * dotProduct / hhVectorNorm2;
949 matrixIndex[1] = hhIndex;
950 result[matrixIndex] -= hhVector0 * reflexionFactor;
951 for (matrixIndex[1]++; matrixIndex[1] < Height; ++matrixIndex[1]){
952 result.GetAtRef(matrixIndex) -= result[istd::CIndex2d(hhIndex, matrixIndex[1])] * reflexionFactor;
953 }
954 }
955
956 // correct optional matrix
957 if (matrixQPtr != NULL){
958 istd::CIndex2d matrix2Index;
959 for (matrix2Index[0] = 0; matrix2Index[0] < Height; ++matrix2Index[0]){
960 matrix2Index[1] = hhIndex;
961 double dotProduct = matrixQPtr->GetAt(matrix2Index) * hhVector0;
962 for (++matrix2Index[1]; matrix2Index[1] < Height; ++matrix2Index[1]){
963 dotProduct += matrixQPtr->GetAt(matrix2Index) * result[istd::CIndex2d(hhIndex, matrix2Index[1])];
964 }
965
966 double reflexionFactor = 2 * dotProduct / hhVectorNorm2;
967 matrix2Index[1] = hhIndex;
968 matrixQPtr->GetAtRef(matrix2Index) -= hhVector0 * reflexionFactor;
969 for (matrix2Index[1]++; matrix2Index[1] < Height; ++matrix2Index[1]){
970 matrixQPtr->GetAtRef(matrix2Index) -= result.GetAt(istd::CIndex2d(hhIndex, matrix2Index[1])) * reflexionFactor;
971 }
972 }
973 }
974
975 // correct current column
976 result.SetAt(istd::CIndex2d(hhIndex, hhIndex), -hhLength);
977 for (int i = hhIndex + 1; i < Height; ++i){
978 result.SetAt(istd::CIndex2d(hhIndex, i), 0);
979 }
980 }
981
982 return true;
983}
984
985
986template <int Width, int Height, typename Element>
988{
989 bool retVal = true;
990
991 static iser::CArchiveTag sizeTag("Size", "Size of matrix", iser::CArchiveTag::TT_GROUP);
992 static iser::CArchiveTag cellsTag("Cells", "Values of matrix cells", iser::CArchiveTag::TT_GROUP);
993
994 retVal = retVal && archive.BeginTag(sizeTag);
995 if (archive.IsStoring()){
996 int width = Width;
997 int height = Height;
998
999 retVal = retVal && archive.Process(width);
1000 retVal = retVal && archive.Process(height);
1001 }
1002 else{
1003 int width = 0;
1004 int height = 0;
1005
1006 retVal = retVal && archive.Process(width);
1007 retVal = retVal && archive.Process(height);
1008
1009 if (!retVal || (width != Width) || (height != Height)){
1010 return false;
1011 }
1012 }
1013
1014 retVal = retVal && archive.EndTag(sizeTag);
1015
1016 retVal = retVal && archive.BeginTag(cellsTag);
1017 for (int y = 0; y < Height; ++y){
1018 for (int x = 0; x < Width; ++x){
1019 retVal = retVal && archive.Process(m_elements[x][y]);
1020 }
1021 }
1022 retVal = retVal && archive.EndTag(cellsTag);
1023
1024 return retVal;
1025}
1026
1027
1028template <int Width, int Height, typename Element>
1030{
1031 for (int x = 0; x < Width; ++x){
1032 for (int y = 0; y < Height; ++y){
1033 if (m_elements[x][y] != matrix.m_elements[x][y]){
1034 return false;
1035 }
1036 }
1037 }
1038
1039 return true;
1040}
1041
1042
1043template <int Width, int Height, typename Element>
1045{
1046 for (int x = 0; x < Width; ++x){
1047 for (int y = 0; y < Height; ++y){
1048 if (m_elements[x][y] != matrix.m_elements[x][y]){
1049 return true;
1050 }
1051 }
1052 }
1053
1054 return false;
1055}
1056
1057
1058template <int Width, int Height, typename Element>
1060{
1061 return m_elements[index[0]][index[1]];
1062}
1063
1064
1065template <int Width, int Height, typename Element>
1067{
1068 return m_elements[index[0]][index[1]];
1069}
1070
1071
1072} // namespace imath
1073
1074
Definition of mathematical matrix with fixed dimensions.
Definition TMatrix.h:27
TVector< Height, Element > GetMultiplied(const TVector< Width, Element > &vector) const
Get result of multiplication of this matrix and some vector.
Definition TMatrix.h:365
bool operator==(const TMatrix< Width, Height, Element > &matrix) const
Definition TMatrix.h:1029
TMatrix< Height, Width, Element > GetTransposed() const
Get transposed matrix.
Definition TMatrix.h:343
void GetAdded(const TMatrix< Width, Height, Element > &matrix, TMatrix< Width, Height, Element > &result) const
Get sum of two matrices.
Definition TMatrix.h:731
Element ElementType
Definition TMatrix.h:31
double GetTrace() const
Get trace of this matrix.
Definition TMatrix.h:789
void GetMultiplied(const TMatrix< SecondWidth, Width, Element > &matrix, TMatrix< SecondWidth, Height, Element > &result) const
Get result of multiplication of two matrices.
Definition TMatrix.h:194
TMatrix< Width, Height, Element > & operator-=(const TMatrix< Width, Height, Element > &matrix)
Definition TMatrix.h:429
TMatrix(const TMatrix &matrix)
Copy constructor.
Definition TMatrix.h:524
TMatrix(MatrixInitMode mode)
Create matrix with initialization to some specified one.
Definition TMatrix.h:462
int GetDimensionsCount() const
Get number of dimensions of this array.
Definition TMatrix.h:562
void GetNegated(TMatrix< Width, Height, Element > &result)
Get result matrix with negated all elements.
Definition TMatrix.h:720
bool SetSizes(const SizesType &sizes)
Set list of all sizes.
Definition TMatrix.h:585
TMatrix< Width, Height, Element > & operator=(const TMatrix< Width, Height, Element > &matrix)=default
const SizesType & GetSizes() const
Get list of all sizes.
Definition TMatrix.h:576
const ElementType & GetAt(int x, int y) const
Get element stored at specified index.
Definition TMatrix.h:631
TMatrix< SecondWidth, Height, Element > operator*(const TMatrix< SecondWidth, Width, Element > &matrix) const
Definition TMatrix.h:310
TMatrix< Width, Height, Element > operator-(const TMatrix< Width, Height, Element > &matrix) const
Definition TMatrix.h:387
double GetFrobeniusNorm2() const
Definition TMatrix.h:803
istd::CIndex2d SizesType
Definition TMatrix.h:30
void GetMultiplied(const TVector< Width, Element > &vector, TVector< Height, Element > &result) const
Get result of multiplication of this matrix and some vector.
Definition TMatrix.h:753
bool SetSize(int dimension, int size)
Set size of array for specified dimension.
Definition TMatrix.h:608
@ MIM_ZERO
All elements initialized to 0.
Definition TMatrix.h:40
@ MIM_ONES
All elements initialized to 1.
Definition TMatrix.h:44
@ MIM_IDENTITY
Identity matrix.
Definition TMatrix.h:48
@ MIM_DOWNER_TRIANGLE
Downer triangle matrix.
Definition TMatrix.h:56
@ MIM_UPPER_TRIANGLE
Upper triangle matrix.
Definition TMatrix.h:52
double GetFrobeniusNorm() const
Definition TMatrix.h:818
void Transpose()
Transpose matrix.
Definition TMatrix.h:354
void GetScaled(double value, TMatrix< Width, Height, Element > &result) const
Get result of multiplication of this matrix with scalar value.
Definition TMatrix.h:767
void SetAt(int x, int y, const ElementType &value)
Set element at specified index.
Definition TMatrix.h:659
void GetRowVector(int rowIndex, TVector< Width, Element > &result)
Get single row as vector.
Definition TMatrix.h:894
istd::CIndex2d IndexType
Definition TMatrix.h:29
void InitToIdentity()
Create identity matrix.
Definition TMatrix.h:666
ElementType & operator[](const IndexType &index)
Definition TMatrix.h:1066
TMatrix< Width, Height, Element > & operator*=(double value)
Definition TMatrix.h:438
int GetSize(int dimension) const
Get size of array for specified dimension.
Definition TMatrix.h:592
TMatrix()
Create matrix without initialization.
Definition TMatrix.h:456
TMatrix< Width, Height, Element > & operator+=(const TMatrix< Width, Height, Element > &matrix)
Definition TMatrix.h:420
ElementType & GetAtRef(int x, int y)
Get reference to element stored at specified index.
Definition TMatrix.h:645
bool GetDecompositionQDQ(TMatrix< Height, Height, Element > &matrixQ, TVector< Height, Element > &diagonalD, double tolerance=I_BIG_EPSILON, int maxIterations=100) const
Calculate decomposition in form of QDQ where Q is orthogonal matrix and D is diagonal one.
Definition TMatrix.h:825
bool GetTriangleDecomposed(TMatrix< Width, Height, Element > &result, TMatrix< Height, Height, Element > *matrixQPtr=NULL, int maxColumns=-1, double minHhNorm=I_BIG_EPSILON) const
Transform matrix to upper triangle form using method of Householder reflexions.
Definition TMatrix.h:905
TMatrix< Width, Height, Element > operator*(double value) const
Definition TMatrix.h:409
double GetMinElement() const
Definition TMatrix.h:701
imath::TVector< Width, Element > RowVector
Definition TMatrix.h:33
void GetColumnVector(int columnIndex, TVector< Height, Element > &result) const
Get single column as vector.
Definition TMatrix.h:870
TMatrix< SecondWidth, Height, Element > GetMultiplied(const TMatrix< SecondWidth, Width, Element > &matrix) const
Get result of multiplication of two matrices.
Definition TMatrix.h:212
ElementType & GetAtRef(const IndexType &index)
Get reference to element stored at specified index.
Definition TMatrix.h:638
void SetAt(const IndexType &index, const ElementType &value)
Set element at specified index.
Definition TMatrix.h:652
void Reset()
Set all matrix cells to zero.
Definition TMatrix.h:537
const ElementType & GetAt(const IndexType &index) const
Get element stored at specified index.
Definition TMatrix.h:624
void SetColumnVector(int columnIndex, const TVector< Height, Element > &columnVector)
Set a single column vector to matrix.
Definition TMatrix.h:882
bool SetDimensionsCount(int count)
Set number of dimensions of this array.
Definition TMatrix.h:569
TMatrix< Width, Height, Element > operator-()
Definition TMatrix.h:398
bool Serialize(iser::IArchive &archive)
Definition TMatrix.h:987
void GetTransposed(TMatrix< Height, Width, Element > &result) const
Get transposed matrix.
Definition TMatrix.h:778
void GetSubstracted(const TMatrix< Width, Height, Element > &matrix, TMatrix< Width, Height, Element > &result) const
Get result of substraction of two matrices.
Definition TMatrix.h:742
double GetMaxElement() const
Definition TMatrix.h:682
TMatrix< Width, Height, Element > operator+(const TMatrix< Width, Height, Element > &matrix) const
Definition TMatrix.h:376
bool operator!=(const TMatrix< Width, Height, Element > &matrix) const
Definition TMatrix.h:1044
imath::TVector< Height, Element > ColumnVector
Definition TMatrix.h:32
void Clear()
Set all matrix cells to zero.
Definition TMatrix.h:548
bool IsDimensionsCountFixed() const
Check, if number dimensions is fixed.
Definition TMatrix.h:555
const ElementType & operator[](const IndexType &index) const
Definition TMatrix.h:1059
Implementation of fixed-size mathematical vector with specified type of elements.
Definition TVector.h:95
Process tag used to group data in archive stream.
Definition CArchiveTag.h:22
@ TT_GROUP
Normal tag used for grouping of tags or processed elements.
Definition CArchiveTag.h:37
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
virtual bool Process(bool &value)=0
Processes (reads or writes) a boolean value.
virtual bool EndTag(const CArchiveTag &tag)=0
Ends a tagged section in the archive.
virtual bool IsStoring() const =0
Checks if this archive is in storing (writing) or loading (reading) mode.
virtual bool BeginTag(const CArchiveTag &tag)=0
Begins a tagged section in the archive.
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
#define NULL
Definition istd.h:74
static const double I_BIG_EPSILON
Definition istd.h:26
Package with mathematical functions and algebraical primitives.
CVarMatrix operator*(double value, const imath::CVarMatrix &matrix)
Definition CVarMatrix.h:373
Contains general persistence mechanism with basic archives implementations.