MyraMath
PivotMatrix.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_DENSE_PIVOTMATRIX_H
7 #define MYRAMATH_DENSE_PIVOTMATRIX_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
16 
18 
19 #include <vector>
20 
21 namespace myra {
22 
23 // Forward declarations.
24 class InputStream;
25 class OutputStream;
26 template<class Number> class Matrix;
27 
29 template<class Number> class MYRAMATH_EXPORT PivotMatrix
30  {
31  public:
32 
34  typedef std::vector<int> Offsets;
35  typedef Matrix22<Number> Pivot;
36  typedef std::vector<Pivot> Pivots;
37  typedef MatrixRange<Number> Range;
39 
40  // ------------------------------------ Construction, serialization, value semantics.
41 
43  PivotMatrix();
44 
46  PivotMatrix(int in_N);
47 
49  PivotMatrix(const PivotMatrix<Number>& that);
50 
52  void swap(PivotMatrix<Number>& that);
53 
55  PivotMatrix<Number>& operator = (PivotMatrix that);
56 
58  explicit PivotMatrix(InputStream& in);
59 
61  void write(OutputStream& out) const;
62 
63  // ------------------------------------ Initialization API.
64 
66  Matrix22<Number>& operator[] (int n);
67 
69  void push_back(const PivotMatrix<Number>& that);
70 
72  void conjugate();
73 
75  void transpose();
76 
78  void hermitian();
79 
81  void reverse();
82 
83  // ------------------------------------ Solve API.
84 
86  // side = Solve by A from the 'L'eft or from the 'R'ight?
87  // op = Apply an operation to A? ('T'ranspose, 'H'ermitian, 'C'onjugate or 'N'othing)
88  void solve(const Range& B, char side, char op) const;
89 
91  // side = Solve by A from the 'L'eft or from the 'R'ight?
92  // op = Apply an operation to A? ('T'ranspose, 'H'ermitian, 'C'onjugate or 'N'othing)
93  void multiply(const Range& B, char side, char op) const;
94 
96  Matrix<Number> make_Matrix() const;
97 
98  private:
99 
100  // Implements solve(B,'L'eft,op)
101  void solve_left(const Range& B, char op) const;
102 
103  // Implements solve(B,'R'ight,op)
104  void solve_right(const Range& B, char op) const;
105 
106  // Implements solve(B,'L'eft,op)
107  void multiply_left(const Range& B, char op) const;
108 
109  // Implements solve(B,'R'ight,op)
110  void multiply_right(const Range& B, char op) const;
111 
112  // Returns op(inverse(pivot))
113  Matrix22<Number> apply_op(char op, const Matrix22<Number>& pivot) const;
114 
115  // Underlying system size.
116  int N;
117 
118  // Row/column offsets.
119  Offsets offsets;
120 
121  // Numeric contents.
122  Pivots pivots;
123 
124  };
125 
126 } // namespace
127 
128 #endif
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
A mostly-identity matrix type, with the occasional Matrix22 at a specific diagonal offset (n...
Definition: PivotMatrix.h:29
Definition: syntax.dox:1
Represents a const MatrixRange.
Definition: bothcat.h:22
Matrix type with fixed size of 2x2, algorithms that operate upon them.
std::vector< int > Offsets
Useful typedefs.
Definition: PivotMatrix.h:34
Abstraction layer, serializable objects write themselves to these.
Definition: Streams.h:39
Various utility functions/classes related to scalar Number types.
Represents a mutable MatrixRange.
Definition: conjugate.h:26
Abstraction layer, deserializable objects read themselves from these.
Definition: Streams.h:47
Matrix type with fixed size 2x2.
Definition: Matrix22.h:25