147 const std::valarray<std::valarray<T>> &A,
148 std::valarray<std::valarray<T>> *Q,
149 std::valarray<std::valarray<T>> *R
151 std::size_t ROWS = A.size();
152 std::size_t COLUMNS = A[0].size();
153 std::valarray<T> col_vector(ROWS);
154 std::valarray<T> col_vector2(ROWS);
155 std::valarray<T> tmp_vector(ROWS);
157 for (
int i = 0; i < COLUMNS; i++) {
167 for (j = 0; j < ROWS; j++) {
168 tmp_vector[j] = A[j][i];
169 col_vector[j] = A[j][i];
171 for (j = 0; j < i; j++) {
172 for (
int k = 0; k < ROWS; k++) {
173 col_vector2[k] = Q[0][k][j];
175 col_vector2 =
vector_proj(col_vector, col_vector2);
176 tmp_vector -= col_vector2;
185 for (j = 0; j < ROWS; j++) Q[0][j][i] = tmp_vector[j] / mag;
192 for (
int kk = 0; kk < ROWS; kk++) {
193 col_vector[kk] = Q[0][kk][i];
200 for (
int k = i; k < COLUMNS; k++) {
201 for (
int kk = 0; kk < ROWS; kk++) {
202 col_vector2[kk] = A[kk][k];
204 R[0][i][k] = (col_vector * col_vector2).sum();