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_zhbmv.c 3.5 kB

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