xref: /libCEED/tests/t301-basis.c (revision 52bfb9bbf17f17edbcd45876cdc8689a879bc683)
14411cf47Sjeremylt /// @file
2*52bfb9bbSJeremy L Thompson /// Test QR Factorization
3*52bfb9bbSJeremy L Thompson /// \test Test QR Factorization
457c64913Sjeremylt #include <ceed.h>
557c64913Sjeremylt 
657c64913Sjeremylt int main(int argc, char **argv) {
757c64913Sjeremylt   Ceed ceed;
8*52bfb9bbSJeremy L Thompson   CeedScalar qr[12] = {1, -1, 4, 1, 4, -2, 1, 4, 2, 1, -1, 0};
9*52bfb9bbSJeremy L Thompson   CeedScalar tau[3];
1057c64913Sjeremylt 
1157c64913Sjeremylt   CeedInit(argv[1], &ceed);
12aedaa0e5Sjeremylt 
13*52bfb9bbSJeremy L Thompson   CeedQRFactorization(ceed, qr, tau, 4, 3);
14*52bfb9bbSJeremy L Thompson   for (int i=0; i<12; i++) {
15*52bfb9bbSJeremy L Thompson     if (qr[i] <= 1E-14 && qr[i] >= -1E-14) qr[i] = 0;
16*52bfb9bbSJeremy L Thompson     fprintf(stdout, "%12.8f\n", qr[i]);
17*52bfb9bbSJeremy L Thompson   }
18*52bfb9bbSJeremy L Thompson   for (int i=0; i<3; i++) {
19*52bfb9bbSJeremy L Thompson     if (tau[i] <= 1E-14 && qr[i] >= -1E-14) tau[i] = 0;
20*52bfb9bbSJeremy L Thompson     fprintf(stdout, "%12.8f\n", tau[i]);
21*52bfb9bbSJeremy L Thompson   }
2257c64913Sjeremylt   CeedDestroy(&ceed);
2357c64913Sjeremylt   return 0;
2457c64913Sjeremylt }
25