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

© Witold Gantzke and Kirill Lepskiy