gsl_cblas__source_tpmv_r.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* blas/source_tpmv_r.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 int nonunit = (Diag == CblasNonUnit);
  22. const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
  23. if (N == 0)
  24. return;
  25. if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasUpper)
  26. || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasLower)) {
  27. /* form x:= A*x */
  28. INDEX ix = OFFSET(N, incX);
  29. for (i = 0; i < N; i++) {
  30. BASE atmp = Ap[TPUP(N, i, i)];
  31. BASE temp = (nonunit ? X[ix] * atmp : X[ix]);
  32. INDEX jx = OFFSET(N, incX) + (i + 1) * incX;
  33. for (j = i + 1; j < N; j++) {
  34. atmp = Ap[TPUP(N, i, j)];
  35. temp += atmp * X[jx];
  36. jx += incX;
  37. }
  38. X[ix] = temp;
  39. ix += incX;
  40. }
  41. } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
  42. || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
  43. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  44. for (i = N; i > 0 && i--;) {
  45. BASE atmp = Ap[TPLO(N, i, i)];
  46. BASE temp = (nonunit ? X[ix] * atmp : X[ix]);
  47. INDEX jx = OFFSET(N, incX);
  48. for (j = 0; j < i; j++) {
  49. atmp = Ap[TPLO(N, i, j)];
  50. temp += atmp * X[jx];
  51. jx += incX;
  52. }
  53. X[ix] = temp;
  54. ix -= incX;
  55. }
  56. } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
  57. || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
  58. /* form x := A'*x */
  59. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  60. for (i = N; i > 0 && i--;) {
  61. BASE atmp = Ap[TPUP(N, i, i)];
  62. BASE temp = (nonunit ? X[ix] * atmp : X[ix]);
  63. INDEX jx = OFFSET(N, incX);
  64. for (j = 0; j < i; j++) {
  65. atmp = Ap[TPUP(N, j, i)];
  66. temp += atmp * X[jx];
  67. jx += incX;
  68. }
  69. X[ix] = temp;
  70. ix -= incX;
  71. }
  72. } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
  73. || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
  74. INDEX ix = OFFSET(N, incX);
  75. for (i = 0; i < N; i++) {
  76. BASE atmp = Ap[TPLO(N, i, i)];
  77. BASE temp = (nonunit ? X[ix] * atmp : X[ix]);
  78. INDEX jx = OFFSET(N, incX) + (i + 1) * incX;
  79. for (j = i + 1; j < N; j++) {
  80. atmp = Ap[TPLO(N, j, i)];
  81. temp += atmp * X[jx];
  82. jx += incX;
  83. }
  84. X[ix] = temp;
  85. ix += incX;
  86. }
  87. } else {
  88. BLAS_ERROR("unrecognized operation");
  89. }
  90. }