1 #include <cxxblas/cxxblas.cxx>
2 #include <cxxblas/interface/aux.h>
3
4 using cxxblas::StorageOrder;
5 using cxxblas::ColMajor;
6 using cxxblas::RowMajor;
7 using cxxblas::Transpose;
8 using cxxblas::NoTrans;
9 using cxxblas::Trans;
10 using cxxblas::Conj;
11 using cxxblas::ConjTrans;
12 using cxxblas::StorageUpLo;
13 using cxxblas::Upper;
14 using cxxblas::Lower;
15
16
17 extern "C" {
18
19 void xerbla_(const char* srname, int* info);
20
21 enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};
22 enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112,
23 CblasConjTrans=113, CblasConjNoTrans=114};
24 enum CBLAS_UPLO {CblasUpper=121, CblasLower=122};
25
26 void
27 CBLAS_NAME(enum CBLAS_ORDER _order,
28 enum CBLAS_UPLO _upLo,
29 CBLAS_INT n,
30 CBLAS_FLOAT alpha,
31 const CBLAS_FLOAT *A,
32 const CBLAS_FLOAT *x, CBLAS_INT incX,
33 CBLAS_FLOAT beta,
34 CBLAS_FLOAT *y, CBLAS_INT incY)
35 #ifdef CREATE_CBLAS
36 {
37 StorageOrder order = (_order==CblasColMajor) ? ColMajor
38 : RowMajor;
39 StorageUpLo upLo = Lower;
40 if (_upLo==CblasUpper) {
41 upLo = Upper;
42 }
43
44 # ifdef TEST_ROW_MAJOR
45 switchPackedStorageOrder(order, upLo, n, A);
46 order = (order==ColMajor) ? RowMajor : ColMajor;
47 # endif
48
49 cxxblas::spmv(order,
50 upLo,
51 n,
52 alpha,
53 A,
54 x, incX,
55 beta,
56 y, incY);
57
58 # ifdef TEST_ROW_MAJOR
59 releaseStorage(A);
60 # endif
61 }
62 #else
63 ;
64 #endif // CREATE_CBLAS
65
66 #ifdef CREATE_BLAS
67 void
68 BLAS_NAME(const char *_upLo,
69 const CBLAS_INT *_n,
70 const CBLAS_FLOAT *_alpha,
71 const CBLAS_FLOAT *A,
72 const CBLAS_FLOAT *x, const CBLAS_INT *_incX,
73 const CBLAS_FLOAT *_beta,
74 CBLAS_FLOAT *y, const CBLAS_INT *_incY)
75 {
76 bool checkUpLo = false;
77 CBLAS_UPLO upLo = CblasUpper;
78 if ((*_upLo=='L') || (*_upLo=='l')) {
79 upLo = CblasLower;
80 checkUpLo = true;
81 }
82 if ((*_upLo=='U') || (*_upLo=='u')) {
83 checkUpLo = true;
84 }
85
86 CBLAS_INT n = *_n;
87 CBLAS_FLOAT alpha = *_alpha;
88 CBLAS_INT incX = *_incX;
89 CBLAS_FLOAT beta = *_beta;
90 CBLAS_INT incY = *_incY;
91
92 CBLAS_INT info = 0;
93 if (incY==0) {
94 info = 9;
95 }
96 if (incX==0) {
97 info = 6;
98 }
99 if (n<0) {
100 info = 2;
101 }
102 if (!checkUpLo) {
103 info = 1;
104 }
105 if (info!=0) {
106 char blasName[6];
107 strncpy(blasName, BLAS_NAME_STR, 6);
108 for (int i=0; i<6; ++i) {
109 blasName[i] = std::toupper(blasName[i]);
110 }
111 xerbla_(blasName, &info);
112 return;
113 }
114
115 // the blas interface calls the cblas interface
116 // so any blas-test will also test the cblas-interface
117 CBLAS_NAME(CblasColMajor,
118 upLo,
119 n,
120 alpha,
121 A,
122 x, incX,
123 beta,
124 y, incY);
125 }
126 #endif // CREATE_BLAS
127
128 } // extern "C"
2 #include <cxxblas/interface/aux.h>
3
4 using cxxblas::StorageOrder;
5 using cxxblas::ColMajor;
6 using cxxblas::RowMajor;
7 using cxxblas::Transpose;
8 using cxxblas::NoTrans;
9 using cxxblas::Trans;
10 using cxxblas::Conj;
11 using cxxblas::ConjTrans;
12 using cxxblas::StorageUpLo;
13 using cxxblas::Upper;
14 using cxxblas::Lower;
15
16
17 extern "C" {
18
19 void xerbla_(const char* srname, int* info);
20
21 enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};
22 enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112,
23 CblasConjTrans=113, CblasConjNoTrans=114};
24 enum CBLAS_UPLO {CblasUpper=121, CblasLower=122};
25
26 void
27 CBLAS_NAME(enum CBLAS_ORDER _order,
28 enum CBLAS_UPLO _upLo,
29 CBLAS_INT n,
30 CBLAS_FLOAT alpha,
31 const CBLAS_FLOAT *A,
32 const CBLAS_FLOAT *x, CBLAS_INT incX,
33 CBLAS_FLOAT beta,
34 CBLAS_FLOAT *y, CBLAS_INT incY)
35 #ifdef CREATE_CBLAS
36 {
37 StorageOrder order = (_order==CblasColMajor) ? ColMajor
38 : RowMajor;
39 StorageUpLo upLo = Lower;
40 if (_upLo==CblasUpper) {
41 upLo = Upper;
42 }
43
44 # ifdef TEST_ROW_MAJOR
45 switchPackedStorageOrder(order, upLo, n, A);
46 order = (order==ColMajor) ? RowMajor : ColMajor;
47 # endif
48
49 cxxblas::spmv(order,
50 upLo,
51 n,
52 alpha,
53 A,
54 x, incX,
55 beta,
56 y, incY);
57
58 # ifdef TEST_ROW_MAJOR
59 releaseStorage(A);
60 # endif
61 }
62 #else
63 ;
64 #endif // CREATE_CBLAS
65
66 #ifdef CREATE_BLAS
67 void
68 BLAS_NAME(const char *_upLo,
69 const CBLAS_INT *_n,
70 const CBLAS_FLOAT *_alpha,
71 const CBLAS_FLOAT *A,
72 const CBLAS_FLOAT *x, const CBLAS_INT *_incX,
73 const CBLAS_FLOAT *_beta,
74 CBLAS_FLOAT *y, const CBLAS_INT *_incY)
75 {
76 bool checkUpLo = false;
77 CBLAS_UPLO upLo = CblasUpper;
78 if ((*_upLo=='L') || (*_upLo=='l')) {
79 upLo = CblasLower;
80 checkUpLo = true;
81 }
82 if ((*_upLo=='U') || (*_upLo=='u')) {
83 checkUpLo = true;
84 }
85
86 CBLAS_INT n = *_n;
87 CBLAS_FLOAT alpha = *_alpha;
88 CBLAS_INT incX = *_incX;
89 CBLAS_FLOAT beta = *_beta;
90 CBLAS_INT incY = *_incY;
91
92 CBLAS_INT info = 0;
93 if (incY==0) {
94 info = 9;
95 }
96 if (incX==0) {
97 info = 6;
98 }
99 if (n<0) {
100 info = 2;
101 }
102 if (!checkUpLo) {
103 info = 1;
104 }
105 if (info!=0) {
106 char blasName[6];
107 strncpy(blasName, BLAS_NAME_STR, 6);
108 for (int i=0; i<6; ++i) {
109 blasName[i] = std::toupper(blasName[i]);
110 }
111 xerbla_(blasName, &info);
112 return;
113 }
114
115 // the blas interface calls the cblas interface
116 // so any blas-test will also test the cblas-interface
117 CBLAS_NAME(CblasColMajor,
118 upLo,
119 n,
120 alpha,
121 A,
122 x, incX,
123 beta,
124 y, incY);
125 }
126 #endif // CREATE_BLAS
127
128 } // extern "C"