gsl_cblas__source_geru.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* blas/source_geru.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. INDEX i, j;
  21. const BASE alpha_real = CONST_REAL0(alpha);
  22. const BASE alpha_imag = CONST_IMAG0(alpha);
  23. if (order == CblasRowMajor) {
  24. INDEX ix = OFFSET(M, incX);
  25. for (i = 0; i < M; i++) {
  26. const BASE X_real = CONST_REAL(X, ix);
  27. const BASE X_imag = CONST_IMAG(X, ix);
  28. const BASE tmp_real = alpha_real * X_real - alpha_imag * X_imag;
  29. const BASE tmp_imag = alpha_imag * X_real + alpha_real * X_imag;
  30. INDEX jy = OFFSET(N, incY);
  31. for (j = 0; j < N; j++) {
  32. const BASE Y_real = CONST_REAL(Y, jy);
  33. const BASE Y_imag = CONST_IMAG(Y, jy);
  34. REAL(A, lda * i + j) += Y_real * tmp_real - Y_imag * tmp_imag;
  35. IMAG(A, lda * i + j) += Y_imag * tmp_real + Y_real * tmp_imag;
  36. jy += incY;
  37. }
  38. ix += incX;
  39. }
  40. } else if (order == CblasColMajor) {
  41. INDEX jy = OFFSET(N, incY);
  42. for (j = 0; j < N; j++) {
  43. const BASE Y_real = CONST_REAL(Y, jy);
  44. const BASE Y_imag = CONST_IMAG(Y, jy);
  45. const BASE tmp_real = alpha_real * Y_real - alpha_imag * Y_imag;
  46. const BASE tmp_imag = alpha_imag * Y_real + alpha_real * Y_imag;
  47. INDEX ix = OFFSET(M, incX);
  48. for (i = 0; i < M; i++) {
  49. const BASE X_real = CONST_REAL(X, ix);
  50. const BASE X_imag = CONST_IMAG(X, ix);
  51. REAL(A, i + lda * j) += X_real * tmp_real - X_imag * tmp_imag;
  52. IMAG(A, i + lda * j) += X_imag * tmp_real + X_real * tmp_imag;
  53. ix += incX;
  54. }
  55. jy += incY;
  56. }
  57. } else {
  58. BLAS_ERROR("unrecognized operation");
  59. }
  60. }