MyraMath
QRSolver.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_QRSOLVER_H
7 #define MYRAMATH_DENSE_QRSOLVER_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
16 
17 #include <myramath/dense/Vector.h>
18 #include <myramath/dense/Matrix.h>
19 
20 #include <stdint.h> // for uint64_t
21 
22 namespace myra {
23 
24 // Forward declarations.
25 class InputStream;
26 class OutputStream;
27 template<class Number> class MatrixRange;
28 template<class Number> class VectorRange;
29 
31 template<class Number> class MYRAMATH_EXPORT QRSolver
32  {
33  public:
34 
36  explicit QRSolver(const Matrix<Number>& in_A);
37 
38 #ifdef MYRAMATH_ENABLE_CPP11
39  explicit QRSolver(Matrix<Number>&& in_A);
41 #endif
42 
44  explicit QRSolver(Matrix<Number>& A);
45 
47  explicit QRSolver(InputStream& in);
48 
50  void write(OutputStream& out) const;
51 
53  // Overwrites B, but returns the subrange of B that contains X (the top).
54  MatrixRange<Number> solve(const MatrixRange<Number>& B) const;
55 
57  // Overwrites b, but returns the subrange of b that contains x (the top).
58  VectorRange<Number> solve(const VectorRange<Number>& b) const;
59 
61  std::pair<int,int> size() const;
62 
63  private:
64 
65  // Storage for Q and R - must have A.I >= A.J and full column rank.
67 
68  // Householder metadata.
69  Vector<Number> tau;
70  };
71 
73 template<class Number> class ReflectNumber <QRSolver<Number> >
74  { public: typedef Number type; };
75 
76 } // namespace
77 
78 #endif
Reflects Number trait for a Container, containers of Numbers (Matrix&#39;s, Vector&#39;s, etc) should special...
Definition: Number.h:55
Factors a square matrix A into Q*R, presents solve methods.
Definition: QRSolver.h:31
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
Represents a mutable VectorRange.
Definition: axpy.h:21
Definition: syntax.dox:1
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
General purpose dense matrix container, O(i*j) storage.
Tabulates a vector of length N, allows random access.
Definition: conjugate.h:21
Container for either a column vector or row vector (depends upon the usage context) ...