You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

xtgsyl.c 3.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include "test.h"
  2. datatype *A[2], *B[2], *C[2], *D[2], *E[2], *F[2], *Work, scale[2], dif[2];
  3. int *iWork, lWork, info;
  4. #define xlascl XPREF(LAPACK(lascl))
  5. void xlascl(const char *, const int *, const int *, const datatype *, const
  6. datatype *, const int *, const int *, datatype *, const int *, int *);
  7. #define xscal XPREF(LAPACK(scal))
  8. void xscal(const int *, const datatype *, datatype *, const int *);
  9. void pre() {
  10. int i;
  11. x2matgen(n, n, A[0], A[1]);
  12. x2matgen(n, n, B[0], B[1]);
  13. x2matgen(n, n, C[0], C[1]);
  14. x2matgen(n, n, D[0], D[1]);
  15. x2matgen(n, n, E[0], E[1]);
  16. x2matgen(n, n, F[0], F[1]);
  17. for (i = 0; i < n; i++) {
  18. // set diagonal
  19. A[0][x1 * (i + n * i)] =
  20. A[1][x1 * (i + n * i)] = (datatype) rand() / RAND_MAX;
  21. E[0][x1 * (i + n * i)] =
  22. E[1][x1 * (i + n * i)] = (datatype) rand() / RAND_MAX;
  23. // clear first subdiagonal
  24. A[0][x1 * (i + 1 + n * i)] =
  25. A[1][x1 * (i + 1 + n * i)] =
  26. B[0][x1 * (i + 1 + n * i)] =
  27. B[1][x1 * (i + 1 + n * i)] =
  28. A[0][x1 * (i + 1 + n * i) + x1 - 1] =
  29. A[1][x1 * (i + 1 + n * i) + x1 - 1] =
  30. B[0][x1 * (i + 1 + n * i) + x1 - 1] =
  31. B[1][x1 * (i + 1 + n * i) + x1 - 1] = 0;
  32. }
  33. }
  34. void post() {
  35. if (scale[0] != 1 || scale[0] != 1)
  36. printf("scale[RELAPACK] = %12g\tscale[LAPACK] = %12g\n", scale[0], scale[1]);
  37. if (scale[0]) {
  38. xlascl("G", iZERO, iZERO, &scale[0], &scale[1], &n, &n, C[0], &n, &info);
  39. xlascl("G", iZERO, iZERO, &scale[0], &scale[1], &n, &n, F[0], &n, &info);
  40. }
  41. error = x2vecerr(n * n, C[0], C[1]) + x2vecerr(n * n, F[0], F[1]);
  42. }
  43. void tests() {
  44. lWork = 2 * n * n;
  45. A[0] = xmalloc(n * n);
  46. A[1] = xmalloc(n * n);
  47. B[0] = xmalloc(n * n);
  48. B[1] = xmalloc(n * n);
  49. C[0] = xmalloc(n * n);
  50. C[1] = xmalloc(n * n);
  51. D[0] = xmalloc(n * n);
  52. D[1] = xmalloc(n * n);
  53. E[0] = xmalloc(n * n);
  54. E[1] = xmalloc(n * n);
  55. F[0] = xmalloc(n * n);
  56. F[1] = xmalloc(n * n);
  57. Work = xmalloc(lWork);
  58. iWork = imalloc(n + n + 2);
  59. #define ROUTINE XPREF(tgsyl)
  60. TEST("N", iZERO, &n, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  61. TEST("N", iZERO, &n2, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  62. TEST("N", iZERO, &n, &n2, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  63. TEST("N", iONE, &n, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  64. TEST("N", iTWO, &n, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  65. TEST("N", iTHREE, &n, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  66. TEST("N", iFOUR, &n, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  67. TEST(xCTRANS, iZERO, &n, &n, A[i], &n, B[i], &n, C[i], &n, D[i], &n, E[i], &n, F[i], &n, &scale[i], &dif[i], Work, &lWork, iWork, &info);
  68. free(A[0]);
  69. free(A[1]);
  70. free(B[0]);
  71. free(B[1]);
  72. free(C[0]);
  73. free(C[1]);
  74. free(D[0]);
  75. free(D[1]);
  76. free(E[0]);
  77. free(E[1]);
  78. free(F[0]);
  79. free(F[1]);
  80. free(Work);
  81. free(iWork);
  82. }