Peano 4
Loading...
Searching...
No Matches
GramSchmidt.cpph
Go to the documentation of this file.
1template<int Rows, int Cols, typename Scalar>
6) {
7 for (int i=0; i < Rows; i++){
8 Q(i,0) = A(i,0);
9 }
10
11 for (int k=0; k < Cols; k++){
12 // Compute norm of k-th column vector of (modified) A
13 R(k,k) = 0.0;
14 for (int i=0; i < Rows; i++){
15 R(k,k) += std::pow(A(i,k), 2);
16 }
17 R(k,k) = std::sqrt(R(k,k));
18
19 // Normalize k-th column of matrix Q
20 for (int i=0; i < Rows; i++){
21 Q(i,k) = A(i,k) / R(k,k);
22 }
23
24 // Compute entries in R and next orthonormal vector
25 for (int j=k+1; j < Cols; j++){
26 // Compute entries of R from current Q and A
27 for (int i=0; i < Rows; i++){
28 R(k,j) += Q(i,k) * A(i,j);
29 }
30 // Subtract contributions from computed to open orthonormal vectors
31 for (int i=0; i < Rows; i++){
32 A(i,j) -= Q(i,k) * R(k,j);
33 }
34 }
35 }
36}
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ j
we integrate over each cell and then take the sum across each of the cells We also consider the terms that enter the f$ k
Static (i.e.
Definition Matrix.h:31
void modifiedGramSchmidt(Matrix< Rows, Cols, Scalar > A, Matrix< Rows, Cols, Scalar > &Q, Matrix< Cols, Cols, Scalar > &R)
Produces an economy-size QR decomposition of a matrix A, A is changed.