xref: /libCEED/tests/t305-basis.c (revision 7f823360fbc3647191038921f2e3d118a0cbeae1)
14411cf47Sjeremylt /// @file
252bfb9bbSJeremy L Thompson /// Test Simultaneous Diagonalization
352bfb9bbSJeremy L Thompson /// \test Simultaneous Diagonalization
457c64913Sjeremylt #include <ceed.h>
557c64913Sjeremylt 
657c64913Sjeremylt int main(int argc, char **argv) {
757c64913Sjeremylt   Ceed ceed;
852bfb9bbSJeremy L Thompson   CeedScalar M[16] = {0.19996678, 0.0745459, -0.07448852, 0.0332866,
952bfb9bbSJeremy L Thompson                       0.0745459, 1., 0.16666509, -0.07448852,
1052bfb9bbSJeremy L Thompson                       -0.07448852, 0.16666509, 1., 0.0745459,
11*7f823360Sjeremylt                       0.0332866, -0.07448852, 0.0745459, 0.19996678
12*7f823360Sjeremylt                      };
1352bfb9bbSJeremy L Thompson   CeedScalar K[16] = {3.03344425, -3.41501767, 0.49824435, -0.11667092,
1452bfb9bbSJeremy L Thompson                       -3.41501767, 5.83354662, -2.9167733, 0.49824435,
1552bfb9bbSJeremy L Thompson                       0.49824435, -2.9167733, 5.83354662, -3.41501767,
16*7f823360Sjeremylt                       -0.11667092, 0.49824435, -3.41501767, 3.03344425
17*7f823360Sjeremylt                      };
1852bfb9bbSJeremy L Thompson   CeedScalar x[16], lambda[4];
1957c64913Sjeremylt 
2057c64913Sjeremylt   CeedInit(argv[1], &ceed);
21aedaa0e5Sjeremylt 
2252bfb9bbSJeremy L Thompson   CeedSimultaneousDiagonalization(ceed, K, M, x, lambda, 4);
2352bfb9bbSJeremy L Thompson   fprintf(stdout, "x:\n");
2452bfb9bbSJeremy L Thompson   for (int i=0; i<4; i++) {
2552bfb9bbSJeremy L Thompson     for (int j=0; j<4; j++) {
2652bfb9bbSJeremy L Thompson       if (x[j+4*i] <= 1E-14 && x[j+4*i] >= -1E-14) x[j+4*i] = 0;
2752bfb9bbSJeremy L Thompson       fprintf(stdout, "%12.8f\t", x[j+4*i]);
2852bfb9bbSJeremy L Thompson     }
2952bfb9bbSJeremy L Thompson     fprintf(stdout, "\n");
3052bfb9bbSJeremy L Thompson   }
3152bfb9bbSJeremy L Thompson   fprintf(stdout, "lambda:\n");
3252bfb9bbSJeremy L Thompson   for (int i=0; i<4; i++) {
3352bfb9bbSJeremy L Thompson     if (lambda[i] <= 1E-14 && lambda[i] >= -1E-14) lambda[i] = 0;
3452bfb9bbSJeremy L Thompson     fprintf(stdout, "%12.8f\n", lambda[i]);
3552bfb9bbSJeremy L Thompson   }
3657c64913Sjeremylt   CeedDestroy(&ceed);
3757c64913Sjeremylt   return 0;
3857c64913Sjeremylt }
39