11 "Could not initialize"+std::string(e.
what()),
12 "DecompQR<T>::DecompQR"));
38 size_t n = mat.size();
42 for (i = 0; i < n; i++) {
43 for (j = 0; j < n; j++) {
51 std::vector<T> matcol(n), Qcol(n);
52 for (k = 0; k < n; k++) {
55 for (j = 0; j < n; j++) {
56 matcol[j] = mat[j][k];
62 for (i = 0; i < k; i++) {
63 for (j = 0; j < n; j++)
65 fact = DotProduct(matcol, Qcol)/DotProduct(Qcol, Qcol);
67 for (j = 0; j < n; j++)
68 _Q[j][k] -= fact*Qcol[j];
73 for (k = 0; k < n; k++) {
74 for (j = 0; j < n; j++)
77 norm = sqrt(DotProduct(Qcol, Qcol));
78 for (j = 0; j < n; j++)
83 for (k = 0; k < n; k++)
84 for (j = k; j < n; j++)
85 for (i = 0; i < n; i++)
86 _R[k][j] += _Q[i][k]*mat[i][j];
91 std::vector<std::vector<T>> mat(m);
93 for (i = 0; i < m; i++)
103 for (i = 0; i < a.size(); i++)
104 product += a[i]*b[i];
void DecomposeGramSchmidt(const std::vector< std::vector< T >> &mat)
Decomposes a square matrix into a parity matrix P, an orthogonal matrix Q and a right triangular matr...
Definition: DecompQR-inl.hh:31
const char * what() const
Return char buffer of message+" at "+location, memory remains owned by Exception. ...
Definition: Exception.hh:52
void IsSquare(const std::string &location, const std::string &what, const std::vector< std::vector< T >> &matrix)
Asserts that a matrix is square.
Definition: Assert.hh:116
std::vector< std::vector< T > > _R
R Matrix.
Definition: DecompQR.hh:73
std::vector< std::vector< T > > _Q
Q Matrix.
Definition: DecompQR.hh:72
Global exception object for all non-standard exceptions thrown by the code.
Definition: Exception.hh:30
std::vector< std::vector< T > > NewMatrix(size_t m, size_t n)
Returns a matrix of m rows and n columns.
Definition: DecompQR-inl.hh:89
Defines the QR decomposition algorithm of a square matrix.
Definition: DecompQR.hh:15
DecompQR & operator=(const DecompQR &decQR)
Equality operator.
Definition: DecompQR-inl.hh:20
void IsNotEmpty(const std::string &location, const std::string &what, const std::vector< T > &vector)
Asserts that a vector is not empty.
Definition: Assert.hh:53
DecompQR()
Default constructor, initilizes an empty matrix of dimension 0x0.
Definition: DecompQR-inl.hh:1
T DotProduct(const std::vector< T > &a, const std::vector< T > &b)
Returns the dot produt of two vectors.
Definition: DecompQR-inl.hh:99
~DecompQR()
Destructor.
Definition: DecompQR-inl.hh:29