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.

c_cblas2.c 27 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. /*
  2. * Written by D.P. Manley, Digital Equipment Corporation.
  3. * Prefixed "C_" to BLAS routines and their declarations.
  4. *
  5. * Modified by T. H. Do, 4/08/98, SGI/CRAY Research.
  6. */
  7. #include <stdlib.h>
  8. #include "common.h"
  9. #include "cblas_test.h"
  10. void F77_cgemv(int *order, char *transp, int *m, int *n,
  11. OPENBLAS_CONST void *alpha,
  12. CBLAS_TEST_COMPLEX *a, int *lda, OPENBLAS_CONST void *x, int *incx,
  13. OPENBLAS_CONST void *beta, void *y, int *incy) {
  14. CBLAS_TEST_COMPLEX *A;
  15. int i,j,LDA;
  16. enum CBLAS_TRANSPOSE trans;
  17. get_transpose_type(transp, &trans);
  18. if (*order == TEST_ROW_MJR) {
  19. LDA = *n+1;
  20. A = (CBLAS_TEST_COMPLEX *)malloc( (*m)*LDA*sizeof( CBLAS_TEST_COMPLEX) );
  21. for( i=0; i<*m; i++ )
  22. for( j=0; j<*n; j++ ){
  23. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  24. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  25. }
  26. cblas_cgemv( CblasRowMajor, trans, *m, *n, alpha, A, LDA, x, *incx,
  27. beta, y, *incy );
  28. free(A);
  29. }
  30. else if (*order == TEST_COL_MJR)
  31. cblas_cgemv( CblasColMajor, trans,
  32. *m, *n, alpha, a, *lda, x, *incx, beta, y, *incy );
  33. else
  34. cblas_cgemv( UNDEFINED, trans,
  35. *m, *n, alpha, a, *lda, x, *incx, beta, y, *incy );
  36. }
  37. void F77_cgbmv(int *order, char *transp, int *m, int *n, int *kl, int *ku,
  38. CBLAS_TEST_COMPLEX *alpha, CBLAS_TEST_COMPLEX *a, int *lda,
  39. CBLAS_TEST_COMPLEX *x, int *incx,
  40. CBLAS_TEST_COMPLEX *beta, CBLAS_TEST_COMPLEX *y, int *incy) {
  41. CBLAS_TEST_COMPLEX *A;
  42. int i,j,irow,jcol,LDA;
  43. enum CBLAS_TRANSPOSE trans;
  44. get_transpose_type(transp, &trans);
  45. if (*order == TEST_ROW_MJR) {
  46. LDA = *ku+*kl+2;
  47. A=( CBLAS_TEST_COMPLEX* )malloc((*n+*kl)*LDA*sizeof(CBLAS_TEST_COMPLEX));
  48. for( i=0; i<*ku; i++ ){
  49. irow=*ku+*kl-i;
  50. jcol=(*ku)-i;
  51. for( j=jcol; j<*n; j++ ){
  52. A[ LDA*(j-jcol)+irow ].real=a[ (*lda)*j+i ].real;
  53. A[ LDA*(j-jcol)+irow ].imag=a[ (*lda)*j+i ].imag;
  54. }
  55. }
  56. i=*ku;
  57. irow=*ku+*kl-i;
  58. for( j=0; j<*n; j++ ){
  59. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  60. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  61. }
  62. for( i=*ku+1; i<*ku+*kl+1; i++ ){
  63. irow=*ku+*kl-i;
  64. jcol=i-(*ku);
  65. for( j=jcol; j<(*n+*kl); j++ ){
  66. A[ LDA*j+irow ].real=a[ (*lda)*(j-jcol)+i ].real;
  67. A[ LDA*j+irow ].imag=a[ (*lda)*(j-jcol)+i ].imag;
  68. }
  69. }
  70. cblas_cgbmv( CblasRowMajor, trans, *m, *n, *kl, *ku, alpha, A, LDA, x,
  71. *incx, beta, y, *incy );
  72. free(A);
  73. }
  74. else if (*order == TEST_COL_MJR)
  75. cblas_cgbmv( CblasColMajor, trans, *m, *n, *kl, *ku, alpha, a, *lda, x,
  76. *incx, beta, y, *incy );
  77. else
  78. cblas_cgbmv( UNDEFINED, trans, *m, *n, *kl, *ku, alpha, a, *lda, x,
  79. *incx, beta, y, *incy );
  80. }
  81. void F77_cgeru(int *order, int *m, int *n, CBLAS_TEST_COMPLEX *alpha,
  82. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *y, int *incy,
  83. CBLAS_TEST_COMPLEX *a, int *lda){
  84. CBLAS_TEST_COMPLEX *A;
  85. int i,j,LDA;
  86. if (*order == TEST_ROW_MJR) {
  87. LDA = *n+1;
  88. A=(CBLAS_TEST_COMPLEX*)malloc((*m)*LDA*sizeof(CBLAS_TEST_COMPLEX));
  89. for( i=0; i<*m; i++ )
  90. for( j=0; j<*n; j++ ){
  91. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  92. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  93. }
  94. cblas_cgeru( CblasRowMajor, *m, *n, alpha, x, *incx, y, *incy, A, LDA );
  95. for( i=0; i<*m; i++ )
  96. for( j=0; j<*n; j++ ){
  97. a[ (*lda)*j+i ].real=A[ LDA*i+j ].real;
  98. a[ (*lda)*j+i ].imag=A[ LDA*i+j ].imag;
  99. }
  100. free(A);
  101. }
  102. else if (*order == TEST_COL_MJR)
  103. cblas_cgeru( CblasColMajor, *m, *n, alpha, x, *incx, y, *incy, a, *lda );
  104. else
  105. cblas_cgeru( UNDEFINED, *m, *n, alpha, x, *incx, y, *incy, a, *lda );
  106. }
  107. void F77_cgerc(int *order, int *m, int *n, CBLAS_TEST_COMPLEX *alpha,
  108. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *y, int *incy,
  109. CBLAS_TEST_COMPLEX *a, int *lda) {
  110. CBLAS_TEST_COMPLEX *A;
  111. int i,j,LDA;
  112. if (*order == TEST_ROW_MJR) {
  113. LDA = *n+1;
  114. A=(CBLAS_TEST_COMPLEX* )malloc((*m)*LDA*sizeof(CBLAS_TEST_COMPLEX ) );
  115. for( i=0; i<*m; i++ )
  116. for( j=0; j<*n; j++ ){
  117. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  118. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  119. }
  120. cblas_cgerc( CblasRowMajor, *m, *n, alpha, x, *incx, y, *incy, A, LDA );
  121. for( i=0; i<*m; i++ )
  122. for( j=0; j<*n; j++ ){
  123. a[ (*lda)*j+i ].real=A[ LDA*i+j ].real;
  124. a[ (*lda)*j+i ].imag=A[ LDA*i+j ].imag;
  125. }
  126. free(A);
  127. }
  128. else if (*order == TEST_COL_MJR)
  129. cblas_cgerc( CblasColMajor, *m, *n, alpha, x, *incx, y, *incy, a, *lda );
  130. else
  131. cblas_cgerc( UNDEFINED, *m, *n, alpha, x, *incx, y, *incy, a, *lda );
  132. }
  133. void F77_chemv(int *order, char *uplow, int *n, CBLAS_TEST_COMPLEX *alpha,
  134. CBLAS_TEST_COMPLEX *a, int *lda, CBLAS_TEST_COMPLEX *x,
  135. int *incx, CBLAS_TEST_COMPLEX *beta, CBLAS_TEST_COMPLEX *y, int *incy){
  136. CBLAS_TEST_COMPLEX *A;
  137. int i,j,LDA;
  138. enum CBLAS_UPLO uplo;
  139. get_uplo_type(uplow,&uplo);
  140. if (*order == TEST_ROW_MJR) {
  141. LDA = *n+1;
  142. A = (CBLAS_TEST_COMPLEX *)malloc((*n)*LDA*sizeof(CBLAS_TEST_COMPLEX));
  143. for( i=0; i<*n; i++ )
  144. for( j=0; j<*n; j++ ){
  145. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  146. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  147. }
  148. cblas_chemv( CblasRowMajor, uplo, *n, alpha, A, LDA, x, *incx,
  149. beta, y, *incy );
  150. free(A);
  151. }
  152. else if (*order == TEST_COL_MJR)
  153. cblas_chemv( CblasColMajor, uplo, *n, alpha, a, *lda, x, *incx,
  154. beta, y, *incy );
  155. else
  156. cblas_chemv( UNDEFINED, uplo, *n, alpha, a, *lda, x, *incx,
  157. beta, y, *incy );
  158. }
  159. void F77_chbmv(int *order, char *uplow, int *n, int *k,
  160. CBLAS_TEST_COMPLEX *alpha, CBLAS_TEST_COMPLEX *a, int *lda,
  161. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *beta,
  162. CBLAS_TEST_COMPLEX *y, int *incy){
  163. CBLAS_TEST_COMPLEX *A;
  164. int i,irow,j,jcol,LDA;
  165. enum CBLAS_UPLO uplo;
  166. get_uplo_type(uplow,&uplo);
  167. if (*order == TEST_ROW_MJR) {
  168. if (uplo != CblasUpper && uplo != CblasLower )
  169. cblas_chbmv(CblasRowMajor, UNDEFINED, *n, *k, alpha, a, *lda, x,
  170. *incx, beta, y, *incy );
  171. else {
  172. LDA = *k+2;
  173. A =(CBLAS_TEST_COMPLEX*)malloc((*n+*k)*LDA*sizeof(CBLAS_TEST_COMPLEX));
  174. if (uplo == CblasUpper) {
  175. for( i=0; i<*k; i++ ){
  176. irow=*k-i;
  177. jcol=(*k)-i;
  178. for( j=jcol; j<*n; j++ ) {
  179. A[ LDA*(j-jcol)+irow ].real=a[ (*lda)*j+i ].real;
  180. A[ LDA*(j-jcol)+irow ].imag=a[ (*lda)*j+i ].imag;
  181. }
  182. }
  183. i=*k;
  184. irow=*k-i;
  185. for( j=0; j<*n; j++ ) {
  186. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  187. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  188. }
  189. }
  190. else {
  191. i=0;
  192. irow=*k-i;
  193. for( j=0; j<*n; j++ ) {
  194. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  195. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  196. }
  197. for( i=1; i<*k+1; i++ ){
  198. irow=*k-i;
  199. jcol=i;
  200. for( j=jcol; j<(*n+*k); j++ ) {
  201. A[ LDA*j+irow ].real=a[ (*lda)*(j-jcol)+i ].real;
  202. A[ LDA*j+irow ].imag=a[ (*lda)*(j-jcol)+i ].imag;
  203. }
  204. }
  205. }
  206. cblas_chbmv( CblasRowMajor, uplo, *n, *k, alpha, A, LDA, x, *incx,
  207. beta, y, *incy );
  208. free(A);
  209. }
  210. }
  211. else if (*order == TEST_COL_MJR)
  212. cblas_chbmv(CblasColMajor, uplo, *n, *k, alpha, a, *lda, x, *incx,
  213. beta, y, *incy );
  214. else
  215. cblas_chbmv(UNDEFINED, uplo, *n, *k, alpha, a, *lda, x, *incx,
  216. beta, y, *incy );
  217. }
  218. void F77_chpmv(int *order, char *uplow, int *n, CBLAS_TEST_COMPLEX *alpha,
  219. CBLAS_TEST_COMPLEX *ap, CBLAS_TEST_COMPLEX *x, int *incx,
  220. CBLAS_TEST_COMPLEX *beta, CBLAS_TEST_COMPLEX *y, int *incy){
  221. CBLAS_TEST_COMPLEX *A, *AP;
  222. int i,j,k,LDA;
  223. enum CBLAS_UPLO uplo;
  224. get_uplo_type(uplow,&uplo);
  225. if (*order == TEST_ROW_MJR) {
  226. if (uplo != CblasUpper && uplo != CblasLower )
  227. cblas_chpmv(CblasRowMajor, UNDEFINED, *n, alpha, ap, x, *incx,
  228. beta, y, *incy);
  229. else {
  230. LDA = *n;
  231. A = (CBLAS_TEST_COMPLEX* )malloc(LDA*LDA*sizeof(CBLAS_TEST_COMPLEX ));
  232. AP = (CBLAS_TEST_COMPLEX* )malloc( (((LDA+1)*LDA)/2)*
  233. sizeof( CBLAS_TEST_COMPLEX ));
  234. if (uplo == CblasUpper) {
  235. for( j=0, k=0; j<*n; j++ )
  236. for( i=0; i<j+1; i++, k++ ) {
  237. A[ LDA*i+j ].real=ap[ k ].real;
  238. A[ LDA*i+j ].imag=ap[ k ].imag;
  239. }
  240. for( i=0, k=0; i<*n; i++ )
  241. for( j=i; j<*n; j++, k++ ) {
  242. AP[ k ].real=A[ LDA*i+j ].real;
  243. AP[ k ].imag=A[ LDA*i+j ].imag;
  244. }
  245. }
  246. else {
  247. for( j=0, k=0; j<*n; j++ )
  248. for( i=j; i<*n; i++, k++ ) {
  249. A[ LDA*i+j ].real=ap[ k ].real;
  250. A[ LDA*i+j ].imag=ap[ k ].imag;
  251. }
  252. for( i=0, k=0; i<*n; i++ )
  253. for( j=0; j<i+1; j++, k++ ) {
  254. AP[ k ].real=A[ LDA*i+j ].real;
  255. AP[ k ].imag=A[ LDA*i+j ].imag;
  256. }
  257. }
  258. cblas_chpmv( CblasRowMajor, uplo, *n, alpha, AP, x, *incx, beta, y,
  259. *incy );
  260. free(A);
  261. free(AP);
  262. }
  263. }
  264. else if (*order == TEST_COL_MJR)
  265. cblas_chpmv( CblasColMajor, uplo, *n, alpha, ap, x, *incx, beta, y,
  266. *incy );
  267. else
  268. cblas_chpmv( UNDEFINED, uplo, *n, alpha, ap, x, *incx, beta, y,
  269. *incy );
  270. }
  271. void F77_ctbmv(int *order, char *uplow, char *transp, char *diagn,
  272. int *n, int *k, CBLAS_TEST_COMPLEX *a, int *lda, CBLAS_TEST_COMPLEX *x,
  273. int *incx) {
  274. CBLAS_TEST_COMPLEX *A;
  275. int irow, jcol, i, j, LDA;
  276. enum CBLAS_TRANSPOSE trans;
  277. enum CBLAS_UPLO uplo;
  278. enum CBLAS_DIAG diag;
  279. get_transpose_type(transp,&trans);
  280. get_uplo_type(uplow,&uplo);
  281. get_diag_type(diagn,&diag);
  282. if (*order == TEST_ROW_MJR) {
  283. if (uplo != CblasUpper && uplo != CblasLower )
  284. cblas_ctbmv(CblasRowMajor, UNDEFINED, trans, diag, *n, *k, a, *lda,
  285. x, *incx);
  286. else {
  287. LDA = *k+2;
  288. A=(CBLAS_TEST_COMPLEX *)malloc((*n+*k)*LDA*sizeof(CBLAS_TEST_COMPLEX));
  289. if (uplo == CblasUpper) {
  290. for( i=0; i<*k; i++ ){
  291. irow=*k-i;
  292. jcol=(*k)-i;
  293. for( j=jcol; j<*n; j++ ) {
  294. A[ LDA*(j-jcol)+irow ].real=a[ (*lda)*j+i ].real;
  295. A[ LDA*(j-jcol)+irow ].imag=a[ (*lda)*j+i ].imag;
  296. }
  297. }
  298. i=*k;
  299. irow=*k-i;
  300. for( j=0; j<*n; j++ ) {
  301. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  302. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  303. }
  304. }
  305. else {
  306. i=0;
  307. irow=*k-i;
  308. for( j=0; j<*n; j++ ) {
  309. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  310. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  311. }
  312. for( i=1; i<*k+1; i++ ){
  313. irow=*k-i;
  314. jcol=i;
  315. for( j=jcol; j<(*n+*k); j++ ) {
  316. A[ LDA*j+irow ].real=a[ (*lda)*(j-jcol)+i ].real;
  317. A[ LDA*j+irow ].imag=a[ (*lda)*(j-jcol)+i ].imag;
  318. }
  319. }
  320. }
  321. cblas_ctbmv(CblasRowMajor, uplo, trans, diag, *n, *k, A, LDA, x,
  322. *incx);
  323. free(A);
  324. }
  325. }
  326. else if (*order == TEST_COL_MJR)
  327. cblas_ctbmv(CblasColMajor, uplo, trans, diag, *n, *k, a, *lda, x, *incx);
  328. else
  329. cblas_ctbmv(UNDEFINED, uplo, trans, diag, *n, *k, a, *lda, x, *incx);
  330. }
  331. void F77_ctbsv(int *order, char *uplow, char *transp, char *diagn,
  332. int *n, int *k, CBLAS_TEST_COMPLEX *a, int *lda, CBLAS_TEST_COMPLEX *x,
  333. int *incx) {
  334. CBLAS_TEST_COMPLEX *A;
  335. int irow, jcol, i, j, LDA;
  336. enum CBLAS_TRANSPOSE trans;
  337. enum CBLAS_UPLO uplo;
  338. enum CBLAS_DIAG diag;
  339. get_transpose_type(transp,&trans);
  340. get_uplo_type(uplow,&uplo);
  341. get_diag_type(diagn,&diag);
  342. if (*order == TEST_ROW_MJR) {
  343. if (uplo != CblasUpper && uplo != CblasLower )
  344. cblas_ctbsv(CblasRowMajor, UNDEFINED, trans, diag, *n, *k, a, *lda, x,
  345. *incx);
  346. else {
  347. LDA = *k+2;
  348. A=(CBLAS_TEST_COMPLEX*)malloc((*n+*k)*LDA*sizeof(CBLAS_TEST_COMPLEX ));
  349. if (uplo == CblasUpper) {
  350. for( i=0; i<*k; i++ ){
  351. irow=*k-i;
  352. jcol=(*k)-i;
  353. for( j=jcol; j<*n; j++ ) {
  354. A[ LDA*(j-jcol)+irow ].real=a[ (*lda)*j+i ].real;
  355. A[ LDA*(j-jcol)+irow ].imag=a[ (*lda)*j+i ].imag;
  356. }
  357. }
  358. i=*k;
  359. irow=*k-i;
  360. for( j=0; j<*n; j++ ) {
  361. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  362. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  363. }
  364. }
  365. else {
  366. i=0;
  367. irow=*k-i;
  368. for( j=0; j<*n; j++ ) {
  369. A[ LDA*j+irow ].real=a[ (*lda)*j+i ].real;
  370. A[ LDA*j+irow ].imag=a[ (*lda)*j+i ].imag;
  371. }
  372. for( i=1; i<*k+1; i++ ){
  373. irow=*k-i;
  374. jcol=i;
  375. for( j=jcol; j<(*n+*k); j++ ) {
  376. A[ LDA*j+irow ].real=a[ (*lda)*(j-jcol)+i ].real;
  377. A[ LDA*j+irow ].imag=a[ (*lda)*(j-jcol)+i ].imag;
  378. }
  379. }
  380. }
  381. cblas_ctbsv(CblasRowMajor, uplo, trans, diag, *n, *k, A, LDA,
  382. x, *incx);
  383. free(A);
  384. }
  385. }
  386. else if (*order == TEST_COL_MJR)
  387. cblas_ctbsv(CblasColMajor, uplo, trans, diag, *n, *k, a, *lda, x, *incx);
  388. else
  389. cblas_ctbsv(UNDEFINED, uplo, trans, diag, *n, *k, a, *lda, x, *incx);
  390. }
  391. void F77_ctpmv(int *order, char *uplow, char *transp, char *diagn,
  392. int *n, CBLAS_TEST_COMPLEX *ap, CBLAS_TEST_COMPLEX *x, int *incx) {
  393. CBLAS_TEST_COMPLEX *A, *AP;
  394. int i, j, k, LDA;
  395. enum CBLAS_TRANSPOSE trans;
  396. enum CBLAS_UPLO uplo;
  397. enum CBLAS_DIAG diag;
  398. get_transpose_type(transp,&trans);
  399. get_uplo_type(uplow,&uplo);
  400. get_diag_type(diagn,&diag);
  401. if (*order == TEST_ROW_MJR) {
  402. if (uplo != CblasUpper && uplo != CblasLower )
  403. cblas_ctpmv( CblasRowMajor, UNDEFINED, trans, diag, *n, ap, x, *incx );
  404. else {
  405. LDA = *n;
  406. A=(CBLAS_TEST_COMPLEX*)malloc(LDA*LDA*sizeof(CBLAS_TEST_COMPLEX));
  407. AP=(CBLAS_TEST_COMPLEX*)malloc((((LDA+1)*LDA)/2)*
  408. sizeof(CBLAS_TEST_COMPLEX));
  409. if (uplo == CblasUpper) {
  410. for( j=0, k=0; j<*n; j++ )
  411. for( i=0; i<j+1; i++, k++ ) {
  412. A[ LDA*i+j ].real=ap[ k ].real;
  413. A[ LDA*i+j ].imag=ap[ k ].imag;
  414. }
  415. for( i=0, k=0; i<*n; i++ )
  416. for( j=i; j<*n; j++, k++ ) {
  417. AP[ k ].real=A[ LDA*i+j ].real;
  418. AP[ k ].imag=A[ LDA*i+j ].imag;
  419. }
  420. }
  421. else {
  422. for( j=0, k=0; j<*n; j++ )
  423. for( i=j; i<*n; i++, k++ ) {
  424. A[ LDA*i+j ].real=ap[ k ].real;
  425. A[ LDA*i+j ].imag=ap[ k ].imag;
  426. }
  427. for( i=0, k=0; i<*n; i++ )
  428. for( j=0; j<i+1; j++, k++ ) {
  429. AP[ k ].real=A[ LDA*i+j ].real;
  430. AP[ k ].imag=A[ LDA*i+j ].imag;
  431. }
  432. }
  433. cblas_ctpmv( CblasRowMajor, uplo, trans, diag, *n, AP, x, *incx );
  434. free(A);
  435. free(AP);
  436. }
  437. }
  438. else if (*order == TEST_COL_MJR)
  439. cblas_ctpmv( CblasColMajor, uplo, trans, diag, *n, ap, x, *incx );
  440. else
  441. cblas_ctpmv( UNDEFINED, uplo, trans, diag, *n, ap, x, *incx );
  442. }
  443. void F77_ctpsv(int *order, char *uplow, char *transp, char *diagn,
  444. int *n, CBLAS_TEST_COMPLEX *ap, CBLAS_TEST_COMPLEX *x, int *incx) {
  445. CBLAS_TEST_COMPLEX *A, *AP;
  446. int i, j, k, LDA;
  447. enum CBLAS_TRANSPOSE trans;
  448. enum CBLAS_UPLO uplo;
  449. enum CBLAS_DIAG diag;
  450. get_transpose_type(transp,&trans);
  451. get_uplo_type(uplow,&uplo);
  452. get_diag_type(diagn,&diag);
  453. if (*order == TEST_ROW_MJR) {
  454. if (uplo != CblasUpper && uplo != CblasLower )
  455. cblas_ctpsv( CblasRowMajor, UNDEFINED, trans, diag, *n, ap, x, *incx );
  456. else {
  457. LDA = *n;
  458. A=(CBLAS_TEST_COMPLEX*)malloc(LDA*LDA*sizeof(CBLAS_TEST_COMPLEX));
  459. AP=(CBLAS_TEST_COMPLEX*)malloc((((LDA+1)*LDA)/2)*
  460. sizeof(CBLAS_TEST_COMPLEX));
  461. if (uplo == CblasUpper) {
  462. for( j=0, k=0; j<*n; j++ )
  463. for( i=0; i<j+1; i++, k++ ) {
  464. A[ LDA*i+j ].real=ap[ k ].real;
  465. A[ LDA*i+j ].imag=ap[ k ].imag;
  466. }
  467. for( i=0, k=0; i<*n; i++ )
  468. for( j=i; j<*n; j++, k++ ) {
  469. AP[ k ].real=A[ LDA*i+j ].real;
  470. AP[ k ].imag=A[ LDA*i+j ].imag;
  471. }
  472. }
  473. else {
  474. for( j=0, k=0; j<*n; j++ )
  475. for( i=j; i<*n; i++, k++ ) {
  476. A[ LDA*i+j ].real=ap[ k ].real;
  477. A[ LDA*i+j ].imag=ap[ k ].imag;
  478. }
  479. for( i=0, k=0; i<*n; i++ )
  480. for( j=0; j<i+1; j++, k++ ) {
  481. AP[ k ].real=A[ LDA*i+j ].real;
  482. AP[ k ].imag=A[ LDA*i+j ].imag;
  483. }
  484. }
  485. cblas_ctpsv( CblasRowMajor, uplo, trans, diag, *n, AP, x, *incx );
  486. free(A);
  487. free(AP);
  488. }
  489. }
  490. else if (*order == TEST_COL_MJR)
  491. cblas_ctpsv( CblasColMajor, uplo, trans, diag, *n, ap, x, *incx );
  492. else
  493. cblas_ctpsv( UNDEFINED, uplo, trans, diag, *n, ap, x, *incx );
  494. }
  495. void F77_ctrmv(int *order, char *uplow, char *transp, char *diagn,
  496. int *n, CBLAS_TEST_COMPLEX *a, int *lda, CBLAS_TEST_COMPLEX *x,
  497. int *incx) {
  498. CBLAS_TEST_COMPLEX *A;
  499. int i,j,LDA;
  500. enum CBLAS_TRANSPOSE trans;
  501. enum CBLAS_UPLO uplo;
  502. enum CBLAS_DIAG diag;
  503. get_transpose_type(transp,&trans);
  504. get_uplo_type(uplow,&uplo);
  505. get_diag_type(diagn,&diag);
  506. if (*order == TEST_ROW_MJR) {
  507. LDA=*n+1;
  508. A=(CBLAS_TEST_COMPLEX*)malloc((*n)*LDA*sizeof(CBLAS_TEST_COMPLEX));
  509. for( i=0; i<*n; i++ )
  510. for( j=0; j<*n; j++ ) {
  511. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  512. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  513. }
  514. cblas_ctrmv(CblasRowMajor, uplo, trans, diag, *n, A, LDA, x, *incx);
  515. free(A);
  516. }
  517. else if (*order == TEST_COL_MJR)
  518. cblas_ctrmv(CblasColMajor, uplo, trans, diag, *n, a, *lda, x, *incx);
  519. else
  520. cblas_ctrmv(UNDEFINED, uplo, trans, diag, *n, a, *lda, x, *incx);
  521. }
  522. void F77_ctrsv(int *order, char *uplow, char *transp, char *diagn,
  523. int *n, CBLAS_TEST_COMPLEX *a, int *lda, CBLAS_TEST_COMPLEX *x,
  524. int *incx) {
  525. CBLAS_TEST_COMPLEX *A;
  526. int i,j,LDA;
  527. enum CBLAS_TRANSPOSE trans;
  528. enum CBLAS_UPLO uplo;
  529. enum CBLAS_DIAG diag;
  530. get_transpose_type(transp,&trans);
  531. get_uplo_type(uplow,&uplo);
  532. get_diag_type(diagn,&diag);
  533. if (*order == TEST_ROW_MJR) {
  534. LDA = *n+1;
  535. A =(CBLAS_TEST_COMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_COMPLEX ) );
  536. for( i=0; i<*n; i++ )
  537. for( j=0; j<*n; j++ ) {
  538. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  539. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  540. }
  541. cblas_ctrsv(CblasRowMajor, uplo, trans, diag, *n, A, LDA, x, *incx );
  542. free(A);
  543. }
  544. else if (*order == TEST_COL_MJR)
  545. cblas_ctrsv(CblasColMajor, uplo, trans, diag, *n, a, *lda, x, *incx );
  546. else
  547. cblas_ctrsv(UNDEFINED, uplo, trans, diag, *n, a, *lda, x, *incx );
  548. }
  549. void F77_chpr(int *order, char *uplow, int *n, float *alpha,
  550. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *ap) {
  551. CBLAS_TEST_COMPLEX *A, *AP;
  552. int i,j,k,LDA;
  553. enum CBLAS_UPLO uplo;
  554. get_uplo_type(uplow,&uplo);
  555. if (*order == TEST_ROW_MJR) {
  556. if (uplo != CblasUpper && uplo != CblasLower )
  557. cblas_chpr(CblasRowMajor, UNDEFINED, *n, *alpha, x, *incx, ap );
  558. else {
  559. LDA = *n;
  560. A = (CBLAS_TEST_COMPLEX* )malloc(LDA*LDA*sizeof(CBLAS_TEST_COMPLEX ) );
  561. AP = ( CBLAS_TEST_COMPLEX* )malloc( (((LDA+1)*LDA)/2)*
  562. sizeof( CBLAS_TEST_COMPLEX ));
  563. if (uplo == CblasUpper) {
  564. for( j=0, k=0; j<*n; j++ )
  565. for( i=0; i<j+1; i++, k++ ){
  566. A[ LDA*i+j ].real=ap[ k ].real;
  567. A[ LDA*i+j ].imag=ap[ k ].imag;
  568. }
  569. for( i=0, k=0; i<*n; i++ )
  570. for( j=i; j<*n; j++, k++ ){
  571. AP[ k ].real=A[ LDA*i+j ].real;
  572. AP[ k ].imag=A[ LDA*i+j ].imag;
  573. }
  574. }
  575. else {
  576. for( j=0, k=0; j<*n; j++ )
  577. for( i=j; i<*n; i++, k++ ){
  578. A[ LDA*i+j ].real=ap[ k ].real;
  579. A[ LDA*i+j ].imag=ap[ k ].imag;
  580. }
  581. for( i=0, k=0; i<*n; i++ )
  582. for( j=0; j<i+1; j++, k++ ){
  583. AP[ k ].real=A[ LDA*i+j ].real;
  584. AP[ k ].imag=A[ LDA*i+j ].imag;
  585. }
  586. }
  587. cblas_chpr(CblasRowMajor, uplo, *n, *alpha, x, *incx, AP );
  588. if (uplo == CblasUpper) {
  589. for( i=0, k=0; i<*n; i++ )
  590. for( j=i; j<*n; j++, k++ ){
  591. A[ LDA*i+j ].real=AP[ k ].real;
  592. A[ LDA*i+j ].imag=AP[ k ].imag;
  593. }
  594. for( j=0, k=0; j<*n; j++ )
  595. for( i=0; i<j+1; i++, k++ ){
  596. ap[ k ].real=A[ LDA*i+j ].real;
  597. ap[ k ].imag=A[ LDA*i+j ].imag;
  598. }
  599. }
  600. else {
  601. for( i=0, k=0; i<*n; i++ )
  602. for( j=0; j<i+1; j++, k++ ){
  603. A[ LDA*i+j ].real=AP[ k ].real;
  604. A[ LDA*i+j ].imag=AP[ k ].imag;
  605. }
  606. for( j=0, k=0; j<*n; j++ )
  607. for( i=j; i<*n; i++, k++ ){
  608. ap[ k ].real=A[ LDA*i+j ].real;
  609. ap[ k ].imag=A[ LDA*i+j ].imag;
  610. }
  611. }
  612. free(A);
  613. free(AP);
  614. }
  615. }
  616. else if (*order == TEST_COL_MJR)
  617. cblas_chpr(CblasColMajor, uplo, *n, *alpha, x, *incx, ap );
  618. else
  619. cblas_chpr(UNDEFINED, uplo, *n, *alpha, x, *incx, ap );
  620. }
  621. void F77_chpr2(int *order, char *uplow, int *n, CBLAS_TEST_COMPLEX *alpha,
  622. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *y, int *incy,
  623. CBLAS_TEST_COMPLEX *ap) {
  624. CBLAS_TEST_COMPLEX *A, *AP;
  625. int i,j,k,LDA;
  626. enum CBLAS_UPLO uplo;
  627. get_uplo_type(uplow,&uplo);
  628. if (*order == TEST_ROW_MJR) {
  629. if (uplo != CblasUpper && uplo != CblasLower )
  630. cblas_chpr2( CblasRowMajor, UNDEFINED, *n, alpha, x, *incx, y,
  631. *incy, ap );
  632. else {
  633. LDA = *n;
  634. A=(CBLAS_TEST_COMPLEX*)malloc( LDA*LDA*sizeof(CBLAS_TEST_COMPLEX ) );
  635. AP=(CBLAS_TEST_COMPLEX*)malloc( (((LDA+1)*LDA)/2)*
  636. sizeof( CBLAS_TEST_COMPLEX ));
  637. if (uplo == CblasUpper) {
  638. for( j=0, k=0; j<*n; j++ )
  639. for( i=0; i<j+1; i++, k++ ) {
  640. A[ LDA*i+j ].real=ap[ k ].real;
  641. A[ LDA*i+j ].imag=ap[ k ].imag;
  642. }
  643. for( i=0, k=0; i<*n; i++ )
  644. for( j=i; j<*n; j++, k++ ) {
  645. AP[ k ].real=A[ LDA*i+j ].real;
  646. AP[ k ].imag=A[ LDA*i+j ].imag;
  647. }
  648. }
  649. else {
  650. for( j=0, k=0; j<*n; j++ )
  651. for( i=j; i<*n; i++, k++ ) {
  652. A[ LDA*i+j ].real=ap[ k ].real;
  653. A[ LDA*i+j ].imag=ap[ k ].imag;
  654. }
  655. for( i=0, k=0; i<*n; i++ )
  656. for( j=0; j<i+1; j++, k++ ) {
  657. AP[ k ].real=A[ LDA*i+j ].real;
  658. AP[ k ].imag=A[ LDA*i+j ].imag;
  659. }
  660. }
  661. cblas_chpr2( CblasRowMajor, uplo, *n, alpha, x, *incx, y, *incy, AP );
  662. if (uplo == CblasUpper) {
  663. for( i=0, k=0; i<*n; i++ )
  664. for( j=i; j<*n; j++, k++ ) {
  665. A[ LDA*i+j ].real=AP[ k ].real;
  666. A[ LDA*i+j ].imag=AP[ k ].imag;
  667. }
  668. for( j=0, k=0; j<*n; j++ )
  669. for( i=0; i<j+1; i++, k++ ) {
  670. ap[ k ].real=A[ LDA*i+j ].real;
  671. ap[ k ].imag=A[ LDA*i+j ].imag;
  672. }
  673. }
  674. else {
  675. for( i=0, k=0; i<*n; i++ )
  676. for( j=0; j<i+1; j++, k++ ) {
  677. A[ LDA*i+j ].real=AP[ k ].real;
  678. A[ LDA*i+j ].imag=AP[ k ].imag;
  679. }
  680. for( j=0, k=0; j<*n; j++ )
  681. for( i=j; i<*n; i++, k++ ) {
  682. ap[ k ].real=A[ LDA*i+j ].real;
  683. ap[ k ].imag=A[ LDA*i+j ].imag;
  684. }
  685. }
  686. free(A);
  687. free(AP);
  688. }
  689. }
  690. else if (*order == TEST_COL_MJR)
  691. cblas_chpr2( CblasColMajor, uplo, *n, alpha, x, *incx, y, *incy, ap );
  692. else
  693. cblas_chpr2( UNDEFINED, uplo, *n, alpha, x, *incx, y, *incy, ap );
  694. }
  695. void F77_cher(int *order, char *uplow, int *n, float *alpha,
  696. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *a, int *lda) {
  697. CBLAS_TEST_COMPLEX *A;
  698. int i,j,LDA;
  699. enum CBLAS_UPLO uplo;
  700. get_uplo_type(uplow,&uplo);
  701. if (*order == TEST_ROW_MJR) {
  702. LDA = *n+1;
  703. A=(CBLAS_TEST_COMPLEX*)malloc((*n)*LDA*sizeof( CBLAS_TEST_COMPLEX ));
  704. for( i=0; i<*n; i++ )
  705. for( j=0; j<*n; j++ ) {
  706. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  707. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  708. }
  709. cblas_cher(CblasRowMajor, uplo, *n, *alpha, x, *incx, A, LDA );
  710. for( i=0; i<*n; i++ )
  711. for( j=0; j<*n; j++ ) {
  712. a[ (*lda)*j+i ].real=A[ LDA*i+j ].real;
  713. a[ (*lda)*j+i ].imag=A[ LDA*i+j ].imag;
  714. }
  715. free(A);
  716. }
  717. else if (*order == TEST_COL_MJR)
  718. cblas_cher( CblasColMajor, uplo, *n, *alpha, x, *incx, a, *lda );
  719. else
  720. cblas_cher( UNDEFINED, uplo, *n, *alpha, x, *incx, a, *lda );
  721. }
  722. void F77_cher2(int *order, char *uplow, int *n, CBLAS_TEST_COMPLEX *alpha,
  723. CBLAS_TEST_COMPLEX *x, int *incx, CBLAS_TEST_COMPLEX *y, int *incy,
  724. CBLAS_TEST_COMPLEX *a, int *lda) {
  725. CBLAS_TEST_COMPLEX *A;
  726. int i,j,LDA;
  727. enum CBLAS_UPLO uplo;
  728. get_uplo_type(uplow,&uplo);
  729. if (*order == TEST_ROW_MJR) {
  730. LDA = *n+1;
  731. A= ( CBLAS_TEST_COMPLEX* )malloc((*n)*LDA*sizeof(CBLAS_TEST_COMPLEX ) );
  732. for( i=0; i<*n; i++ )
  733. for( j=0; j<*n; j++ ) {
  734. A[ LDA*i+j ].real=a[ (*lda)*j+i ].real;
  735. A[ LDA*i+j ].imag=a[ (*lda)*j+i ].imag;
  736. }
  737. cblas_cher2(CblasRowMajor, uplo, *n, alpha, x, *incx, y, *incy, A, LDA );
  738. for( i=0; i<*n; i++ )
  739. for( j=0; j<*n; j++ ) {
  740. a[ (*lda)*j+i ].real=A[ LDA*i+j ].real;
  741. a[ (*lda)*j+i ].imag=A[ LDA*i+j ].imag;
  742. }
  743. free(A);
  744. }
  745. else if (*order == TEST_COL_MJR)
  746. cblas_cher2( CblasColMajor, uplo, *n, alpha, x, *incx, y, *incy, a, *lda);
  747. else
  748. cblas_cher2( UNDEFINED, uplo, *n, alpha, x, *incx, y, *incy, a, *lda);
  749. }