Program to compute the QR decomposition of a given matrix.
More...
#include <array>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include "./qr_decompose.h"
Program to compute the QR decomposition of a given matrix.
- Author
- Krishna Vedala
◆ main()
main function
23 {
24 unsigned int ROWS, COLUMNS;
25
26 std::cout <<
"Enter the number of rows and columns: ";
28
29 std::cout <<
"Enter matrix elements row-wise:\n";
30
34 for (
int i = 0; i <
std::max(ROWS, COLUMNS); i++) {
35 if (i < ROWS) {
38 }
39 if (i < COLUMNS) {
41 }
42 }
43
44 for (int i = 0; i < ROWS; i++)
45 for (int j = 0; j < COLUMNS; j++) std::cin >> A[i][j];
46
48
50 qr_decompose(A, &Q, &R);
51 double dtime =
static_cast<double>(
clock() - t1) / CLOCKS_PER_SEC;
52
55 std::cout <<
"Time taken to compute: " << dtime <<
" sec\n ";
56
57 return 0;
58}