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.

clauum.c 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "relapack.h"
  2. static void RELAPACK_clauum_rec(const char *, const blasint *, float *,
  3. const blasint *, blasint *);
  4. /** CLAUUM computes the product U * U**H or L**H * L, where the triangular factor U or L is stored in the upper or lower triangular part of the array A.
  5. *
  6. * This routine is functionally equivalent to LAPACK's clauum.
  7. * For details on its interface, see
  8. * http://www.netlib.org/lapack/explore-html/d2/d36/clauum_8f.html
  9. * */
  10. void RELAPACK_clauum(
  11. const char *uplo, const blasint *n,
  12. float *A, const blasint *ldA,
  13. blasint *info
  14. ) {
  15. // Check arguments
  16. const blasint lower = LAPACK(lsame)(uplo, "L");
  17. const blasint upper = LAPACK(lsame)(uplo, "U");
  18. *info = 0;
  19. if (!lower && !upper)
  20. *info = -1;
  21. else if (*n < 0)
  22. *info = -2;
  23. else if (*ldA < MAX(1, *n))
  24. *info = -4;
  25. if (*info) {
  26. const blasint minfo = -*info;
  27. LAPACK(xerbla)("CLAUUM", &minfo, strlen("CLAUUM"));
  28. return;
  29. }
  30. if (*n == 0) return;
  31. // Clean char * arguments
  32. const char cleanuplo = lower ? 'L' : 'U';
  33. // Recursive kernel
  34. RELAPACK_clauum_rec(&cleanuplo, n, A, ldA, info);
  35. }
  36. /** clauum's recursive compute kernel */
  37. static void RELAPACK_clauum_rec(
  38. const char *uplo, const blasint *n,
  39. float *A, const blasint *ldA,
  40. blasint *info
  41. ) {
  42. if (*n <= MAX(CROSSOVER_CLAUUM, 1)) {
  43. // Unblocked
  44. LAPACK(clauu2)(uplo, n, A, ldA, info);
  45. return;
  46. }
  47. // Constants
  48. const float ONE[] = { 1., 0. };
  49. // Splitting
  50. const blasint n1 = CREC_SPLIT(*n);
  51. const blasint n2 = *n - n1;
  52. // A_TL A_TR
  53. // A_BL A_BR
  54. float *const A_TL = A;
  55. float *const A_TR = A + 2 * *ldA * n1;
  56. float *const A_BL = A + 2 * n1;
  57. float *const A_BR = A + 2 * *ldA * n1 + 2 * n1;
  58. // recursion(A_TL)
  59. RELAPACK_clauum_rec(uplo, &n1, A_TL, ldA, info);
  60. if (*uplo == 'L') {
  61. // A_TL = A_TL + A_BL' * A_BL
  62. BLAS(cherk)("L", "C", &n1, &n2, ONE, A_BL, ldA, ONE, A_TL, ldA);
  63. // A_BL = A_BR' * A_BL
  64. BLAS(ctrmm)("L", "L", "C", "N", &n2, &n1, ONE, A_BR, ldA, A_BL, ldA);
  65. } else {
  66. // A_TL = A_TL + A_TR * A_TR'
  67. BLAS(cherk)("U", "N", &n1, &n2, ONE, A_TR, ldA, ONE, A_TL, ldA);
  68. // A_TR = A_TR * A_BR'
  69. BLAS(ctrmm)("R", "U", "C", "N", &n1, &n2, ONE, A_BR, ldA, A_TR, ldA);
  70. }
  71. // recursion(A_BR)
  72. RELAPACK_clauum_rec(uplo, &n2, A_BR, ldA, info);
  73. }