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.

cblas_zgbmv.c 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * cblas_zgbmv.c
  3. * The program is a C interface of zgbmv
  4. *
  5. * Keita Teranishi 5/20/98
  6. *
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "cblas.h"
  11. #include "cblas_f77.h"
  12. void cblas_zgbmv(const CBLAS_LAYOUT layout,
  13. const CBLAS_TRANSPOSE TransA, const int M, const int N,
  14. const int KL, const int KU,
  15. const void *alpha, const void *A, const int lda,
  16. const void *X, const int incX, const void *beta,
  17. void *Y, const int incY)
  18. {
  19. char TA;
  20. #ifdef F77_CHAR
  21. F77_CHAR F77_TA;
  22. #else
  23. #define F77_TA &TA
  24. #endif
  25. #ifdef F77_INT
  26. F77_INT F77_M=M, F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
  27. F77_INT F77_KL=KL,F77_KU=KU;
  28. #else
  29. #define F77_M M
  30. #define F77_N N
  31. #define F77_lda lda
  32. #define F77_KL KL
  33. #define F77_KU KU
  34. #define F77_incX incx
  35. #define F77_incY incY
  36. #endif
  37. int n, i=0, incx=incX;
  38. const double *xx= (double *)X, *alp= (double *)alpha, *bet = (double *)beta;
  39. double ALPHA[2],BETA[2];
  40. int tincY, tincx;
  41. double *x=(double *)X, *y=(double *)Y, *st=0, *tx;
  42. extern int CBLAS_CallFromC;
  43. extern int RowMajorStrg;
  44. RowMajorStrg = 0;
  45. CBLAS_CallFromC = 1;
  46. if (layout == CblasColMajor)
  47. {
  48. if (TransA == CblasNoTrans) TA = 'N';
  49. else if (TransA == CblasTrans) TA = 'T';
  50. else if (TransA == CblasConjTrans) TA = 'C';
  51. else
  52. {
  53. cblas_xerbla(2, "cblas_zgbmv","Illegal TransA setting, %d\n", TransA);
  54. CBLAS_CallFromC = 0;
  55. RowMajorStrg = 0;
  56. return;
  57. }
  58. #ifdef F77_CHAR
  59. F77_TA = C2F_CHAR(&TA);
  60. #endif
  61. F77_zgbmv(F77_TA, &F77_M, &F77_N, &F77_KL, &F77_KU, alpha,
  62. A, &F77_lda, X, &F77_incX, beta, Y, &F77_incY);
  63. }
  64. else if (layout == CblasRowMajor)
  65. {
  66. RowMajorStrg = 1;
  67. if (TransA == CblasNoTrans) TA = 'T';
  68. else if (TransA == CblasTrans) TA = 'N';
  69. else if (TransA == CblasConjTrans)
  70. {
  71. ALPHA[0]= *alp;
  72. ALPHA[1]= -alp[1];
  73. BETA[0]= *bet;
  74. BETA[1]= -bet[1];
  75. TA = 'N';
  76. if (M > 0)
  77. {
  78. n = M << 1;
  79. x = malloc(n*sizeof(double));
  80. tx = x;
  81. if( incX > 0 ) {
  82. i = incX << 1 ;
  83. tincx = 2;
  84. st= x+n;
  85. } else {
  86. i = incX *(-2);
  87. tincx = -2;
  88. st = x-2;
  89. x +=(n-2);
  90. }
  91. do
  92. {
  93. *x = *xx;
  94. x[1] = -xx[1];
  95. x += tincx ;
  96. xx += i;
  97. }
  98. while (x != st);
  99. x=tx;
  100. #ifdef F77_INT
  101. F77_incX = 1;
  102. #else
  103. incx = 1;
  104. #endif
  105. if( incY > 0 )
  106. tincY = incY;
  107. else
  108. tincY = -incY;
  109. y++;
  110. if (N > 0)
  111. {
  112. i = tincY << 1;
  113. n = i * N ;
  114. st = y + n;
  115. do {
  116. *y = -(*y);
  117. y += i;
  118. } while(y != st);
  119. y -= n;
  120. }
  121. }
  122. else x = (double *) X;
  123. }
  124. else
  125. {
  126. cblas_xerbla(2, "cblas_zgbmv","Illegal TransA setting, %d\n", TransA);
  127. CBLAS_CallFromC = 0;
  128. RowMajorStrg = 0;
  129. return;
  130. }
  131. #ifdef F77_CHAR
  132. F77_TA = C2F_CHAR(&TA);
  133. #endif
  134. if (TransA == CblasConjTrans)
  135. F77_zgbmv(F77_TA, &F77_N, &F77_M, &F77_KU, &F77_KL, ALPHA,
  136. A ,&F77_lda, x,&F77_incX, BETA, Y, &F77_incY);
  137. else
  138. F77_zgbmv(F77_TA, &F77_N, &F77_M, &F77_KU, &F77_KL, alpha,
  139. A ,&F77_lda, x,&F77_incX, beta, Y, &F77_incY);
  140. if (TransA == CblasConjTrans)
  141. {
  142. if (x != X) free(x);
  143. if (N > 0)
  144. {
  145. do
  146. {
  147. *y = -(*y);
  148. y += i;
  149. }
  150. while (y != st);
  151. }
  152. }
  153. }
  154. else cblas_xerbla(1, "cblas_zgbmv", "Illegal layout setting, %d\n", layout);
  155. CBLAS_CallFromC = 0;
  156. RowMajorStrg = 0;
  157. return;
  158. }