gsl_cblas__source_her.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* blas/source_her.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. {
  20. const int conj = (order == CblasColMajor) ? -1 : 1;
  21. INDEX i, j;
  22. if (alpha == 0.0)
  23. return;
  24. if ((order == CblasRowMajor && Uplo == CblasUpper)
  25. || (order == CblasColMajor && Uplo == CblasLower)) {
  26. INDEX ix = OFFSET(N, incX);
  27. for (i = 0; i < N; i++) {
  28. const BASE tmp_real = alpha * CONST_REAL(X, ix);
  29. const BASE tmp_imag = alpha * conj * CONST_IMAG(X, ix);
  30. INDEX jx = ix;
  31. {
  32. const BASE X_real = CONST_REAL(X, jx);
  33. const BASE X_imag = -conj * CONST_IMAG(X, jx);
  34. REAL(A, lda * i + i) += X_real * tmp_real - X_imag * tmp_imag;
  35. IMAG(A, lda * i + i) = 0;
  36. jx += incX;
  37. }
  38. for (j = i + 1; j < N; j++) {
  39. const BASE X_real = CONST_REAL(X, jx);
  40. const BASE X_imag = -conj * CONST_IMAG(X, jx);
  41. REAL(A, lda * i + j) += X_real * tmp_real - X_imag * tmp_imag;
  42. IMAG(A, lda * i + j) += X_imag * tmp_real + X_real * tmp_imag;
  43. jx += incX;
  44. }
  45. ix += incX;
  46. }
  47. } else if ((order == CblasRowMajor && Uplo == CblasLower)
  48. || (order == CblasColMajor && Uplo == CblasUpper)) {
  49. INDEX ix = OFFSET(N, incX);
  50. for (i = 0; i < N; i++) {
  51. const BASE tmp_real = alpha * CONST_REAL(X, ix);
  52. const BASE tmp_imag = alpha * conj * CONST_IMAG(X, ix);
  53. INDEX jx = OFFSET(N, incX);
  54. for (j = 0; j < i; j++) {
  55. const BASE X_real = CONST_REAL(X, jx);
  56. const BASE X_imag = -conj * CONST_IMAG(X, jx);
  57. REAL(A, lda * i + j) += X_real * tmp_real - X_imag * tmp_imag;
  58. IMAG(A, lda * i + j) += X_imag * tmp_real + X_real * tmp_imag;
  59. jx += incX;
  60. }
  61. {
  62. const BASE X_real = CONST_REAL(X, jx);
  63. const BASE X_imag = -conj * CONST_IMAG(X, jx);
  64. REAL(A, lda * i + i) += X_real * tmp_real - X_imag * tmp_imag;
  65. IMAG(A, lda * i + i) = 0;
  66. jx += incX;
  67. }
  68. ix += incX;
  69. }
  70. } else {
  71. BLAS_ERROR("unrecognized operation");
  72. }
  73. }