Heidelberg Educational Numerics Library Version 0.27 (from 15 March 2021)
|
This file implements QR decomposition using Gram-Schmidt method. More...
#include <cmath>
#include <utility>
#include "densematrix.hh"
#include "vector.hh"
Go to the source code of this file.
Functions | |
template<class T > | |
DenseMatrix< T > | hdnum::gram_schmidt (const DenseMatrix< T > &A) |
computes orthonormal basis of Im(A) using classical Gram-Schmidt | |
template<class T > | |
DenseMatrix< T > | hdnum::modified_gram_schmidt (const DenseMatrix< T > &A) |
computes orthonormal basis of Im(A) using modified Gram-Schmidt | |
template<class T > | |
DenseMatrix< T > | hdnum::qr_gram_schmidt_simple (DenseMatrix< T > &Q) |
computes qr decomposition using modified Gram-Schmidt - works only with small (m>n) and square matrices | |
template<class T > | |
DenseMatrix< T > | hdnum::qr_gram_schmidt (DenseMatrix< T > &Q) |
computes qr decomposition using modified Gram-Schmidt - works only with small (m>n) and square matrices | |
template<class T > | |
DenseMatrix< T > | hdnum::qr_gram_schmidt_pivoting (DenseMatrix< T > &Q, Vector< int > &p, int &rank, T threshold=0.00000000001) |
computes qr decomposition using modified Gram-Schmidt and pivoting - works with all types of matrices | |
template<typename T > | |
void | hdnum::permute_forward (DenseMatrix< T > &A, Vector< int > &p) |
applies a permutation vector to a matrix | |
This file implements QR decomposition using Gram-Schmidt method.
DenseMatrix< T > hdnum::gram_schmidt | ( | const DenseMatrix< T > & | A | ) |
computes orthonormal basis of Im(A) using classical Gram-Schmidt
hdnum::DenseMatrix<T> | A |
Example:
Output:
A = 0 1 0 2.000e+00 9.000e+00 1 1.000e+00 -5.000e+00 Q = 0 1 0 8.944e-01 4.472e-01 1 4.472e-01 -8.944e-01
DenseMatrix< T > hdnum::modified_gram_schmidt | ( | const DenseMatrix< T > & | A | ) |
computes orthonormal basis of Im(A) using modified Gram-Schmidt
hdnum::DenseMatrix<T> | A |
Example:
Output:
A = 0 1 0 2.000e+00 9.000e+00 1 1.000e+00 -5.000e+00 Q = 0 1 0 8.944e-01 4.472e-01 1 4.472e-01 -8.944e-01
void hdnum::permute_forward | ( | DenseMatrix< T > & | A, |
Vector< int > & | p ) |
applies a permutation vector to a matrix
hdnum::DenseMatrix<T> | A |
hdnum::Vector<int> | p |
Example:
Output:
A = 0 1 0 9.000e+00 2.000e+00 1 -5.000e+00 1.000e+00 p = [ 0] 0 [ 1] 1
DenseMatrix< T > hdnum::qr_gram_schmidt | ( | DenseMatrix< T > & | Q | ) |
computes qr decomposition using modified Gram-Schmidt - works only with small (m>n) and square matrices
hdnum::DenseMatrix<T> | Q |
Example:
Output:
A = 0 1 0 2.000e+00 9.000e+00 1 1.000e+00 -5.000e+00 Q = 0 1 0 8.944e-01 4.472e-01 1 4.472e-01 -8.944e-01 R = 0 1 0 2.236e+00 5.814e+00 1 0.000e+00 8.497e+00 QR = 0 1 0 2.000e+00 9.000e+00 1 1.000e+00 -5.000e+00
DenseMatrix< T > hdnum::qr_gram_schmidt_pivoting | ( | DenseMatrix< T > & | Q, |
Vector< int > & | p, | ||
int & | rank, | ||
T | threshold = 0.00000000001 ) |
computes qr decomposition using modified Gram-Schmidt and pivoting - works with all types of matrices
hdnum::DenseMatrix<T> | Q |
T | threshold (optional) |
hdnum::Vector<int> | p |
int | rank |
Example:
Output:
A = 0 1 2 0 5.000e+00 2.000e+00 3.000e+00 1 1.100e+01 9.000e+00 2.000e+00 Q = 0 1 0 4.138e-01 -9.104e-01 1 9.104e-01 4.138e-01 R = 0 1 2 0 1.208e+01 9.021e+00 3.062e+00 1 0.000e+00 1.903e+00 -1.903e+00 QR = 0 1 2 0 5.000e+00 2.000e+00 3.000e+00 1 1.100e+01 9.000e+00 2.000e+00
DenseMatrix< T > hdnum::qr_gram_schmidt_simple | ( | DenseMatrix< T > & | Q | ) |
computes qr decomposition using modified Gram-Schmidt - works only with small (m>n) and square matrices
hdnum::DenseMatrix<T> | Q |
Example:
Output:
A = 0 1 0 2.000e+00 9.000e+00 1 1.000e+00 -5.000e+00 Q = 0 1 0 8.944e-01 4.472e-01 1 4.472e-01 -8.944e-01 R = 0 1 0 2.236e+00 5.814e+00 1 0.000e+00 8.497e+00 QR = 0 1 0 2.000e+00 9.000e+00 1 1.000e+00 -5.000e+00