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, CBLAS_INT ldA,
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 switchFullStorageOrder(order, n, n, A, ldA);
46 order = (order==ColMajor) ? RowMajor : ColMajor;
47 # endif
48
49 cxxblas::symv(order,
50 upLo,
51 n,
52 alpha,
53 A, ldA,
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, const CBLAS_INT *_ldA,
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 ldA = *_ldA;
89 CBLAS_INT incX = *_incX;
90 CBLAS_FLOAT beta = *_beta;
91 CBLAS_INT incY = *_incY;
92
93 CBLAS_INT info = 0;
94 if (incY==0) {
95 info = 10;
96 }
97 if (incX==0) {
98 info = 7;
99 }
100 if (ldA<std::max(1, n)) {
101 info = 5;
102 }
103 if (n<0) {
104 info = 2;
105 }
106 if (!checkUpLo) {
107 info = 1;
108 }
109 if (info!=0) {
110 char blasName[6];
111 strncpy(blasName, BLAS_NAME_STR, 6);
112 for (int i=0; i<6; ++i) {
113 blasName[i] = std::toupper(blasName[i]);
114 }
115 xerbla_(blasName, &info);
116 return;
117 }
118
119 // the blas interface calls the cblas interface
120 // so any blas-test will also test the cblas-interface
121 CBLAS_NAME(CblasColMajor,
122 upLo,
123 n,
124 alpha,
125 A, ldA,
126 x, incX,
127 beta,
128 y, incY);
129 }
130 #endif // CREATE_BLAS
131
132 } // 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, CBLAS_INT ldA,
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 switchFullStorageOrder(order, n, n, A, ldA);
46 order = (order==ColMajor) ? RowMajor : ColMajor;
47 # endif
48
49 cxxblas::symv(order,
50 upLo,
51 n,
52 alpha,
53 A, ldA,
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, const CBLAS_INT *_ldA,
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 ldA = *_ldA;
89 CBLAS_INT incX = *_incX;
90 CBLAS_FLOAT beta = *_beta;
91 CBLAS_INT incY = *_incY;
92
93 CBLAS_INT info = 0;
94 if (incY==0) {
95 info = 10;
96 }
97 if (incX==0) {
98 info = 7;
99 }
100 if (ldA<std::max(1, n)) {
101 info = 5;
102 }
103 if (n<0) {
104 info = 2;
105 }
106 if (!checkUpLo) {
107 info = 1;
108 }
109 if (info!=0) {
110 char blasName[6];
111 strncpy(blasName, BLAS_NAME_STR, 6);
112 for (int i=0; i<6; ++i) {
113 blasName[i] = std::toupper(blasName[i]);
114 }
115 xerbla_(blasName, &info);
116 return;
117 }
118
119 // the blas interface calls the cblas interface
120 // so any blas-test will also test the cblas-interface
121 CBLAS_NAME(CblasColMajor,
122 upLo,
123 n,
124 alpha,
125 A, ldA,
126 x, incX,
127 beta,
128 y, incY);
129 }
130 #endif // CREATE_BLAS
131
132 } // extern "C"