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
13 extern "C" {
14
15 void xerbla_(const char* srname, int* info);
16
17 enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};
18 enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112,
19 CblasConjTrans=113, CblasConjNoTrans=114};
20
21 void
22 CBLAS_NAME(enum CBLAS_ORDER _order,
23 CBLAS_INT m, CBLAS_INT n,
24 CBLAS_FLOAT alpha,
25 const CBLAS_FLOAT *x, CBLAS_INT incX,
26 const CBLAS_FLOAT *y, CBLAS_INT incY,
27 CBLAS_FLOAT *A, CBLAS_INT ldA)
28 #ifdef CREATE_CBLAS
29 {
30 StorageOrder order = (_order==CblasColMajor) ? ColMajor
31 : RowMajor;
32
33 CBLAS_FLOAT *__A = A;
34 CBLAS_INT __ldA = ldA;
35 StorageOrder __order = order;
36
37 # ifdef TEST_ROW_MAJOR
38 __order = (order==ColMajor) ? RowMajor : ColMajor;
39 allocateFullStorage(__order, m, n, __A, __ldA);
40 switchFullStorageOrder(order, m, n, A, ldA, __A, __ldA);
41 # endif
42
43 cxxblas::ger(__order,
44 m, n,
45 alpha,
46 x, incX,
47 y, incY,
48 __A, __ldA);
49
50 # ifdef TEST_ROW_MAJOR
51 switchFullStorageOrder(__order, m, n, __A, __ldA, A, ldA);
52 releaseStorage(__A);
53 # endif
54 }
55 #else
56 ;
57 #endif // CREATE_CBLAS
58
59 #ifdef CREATE_BLAS
60 void
61 BLAS_NAME(const CBLAS_INT *_m, const CBLAS_INT *_n,
62 const CBLAS_FLOAT *_alpha,
63 const CBLAS_FLOAT *x, const CBLAS_INT *_incX,
64 const CBLAS_FLOAT *y, const CBLAS_INT *_incY,
65 CBLAS_FLOAT *A, const CBLAS_INT *_ldA)
66 {
67 CBLAS_INT m = *_m;
68 CBLAS_INT n = *_n;
69 CBLAS_FLOAT alpha = *_alpha;
70 CBLAS_INT incX = *_incX;
71 CBLAS_INT incY = *_incY;
72 CBLAS_INT ldA = *_ldA;
73
74 CBLAS_INT info = 0;
75 if (incY==0) {
76 info = 7;
77 }
78 if (incX==0) {
79 info = 5;
80 }
81 if (ldA<std::max(1, m)) {
82 info = 9;
83 }
84 if (n<0) {
85 info = 2;
86 }
87 if (m<0) {
88 info = 1;
89 }
90 if (info!=0) {
91 char blasName[6];
92 strncpy(blasName, BLAS_NAME_STR, 6);
93 for (int i=0; i<6; ++i) {
94 blasName[i] = std::toupper(blasName[i]);
95 }
96 xerbla_(blasName, &info);
97 return;
98 }
99
100 // the blas interface calls the cblas interface
101 // so any blas-test will also test the cblas-interface
102 CBLAS_NAME(CblasColMajor,
103 m, n,
104 alpha,
105 x, incX,
106 y, incY,
107 A, ldA);
108 }
109 #endif // CREATE_BLAS
110
111 } // 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
13 extern "C" {
14
15 void xerbla_(const char* srname, int* info);
16
17 enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};
18 enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112,
19 CblasConjTrans=113, CblasConjNoTrans=114};
20
21 void
22 CBLAS_NAME(enum CBLAS_ORDER _order,
23 CBLAS_INT m, CBLAS_INT n,
24 CBLAS_FLOAT alpha,
25 const CBLAS_FLOAT *x, CBLAS_INT incX,
26 const CBLAS_FLOAT *y, CBLAS_INT incY,
27 CBLAS_FLOAT *A, CBLAS_INT ldA)
28 #ifdef CREATE_CBLAS
29 {
30 StorageOrder order = (_order==CblasColMajor) ? ColMajor
31 : RowMajor;
32
33 CBLAS_FLOAT *__A = A;
34 CBLAS_INT __ldA = ldA;
35 StorageOrder __order = order;
36
37 # ifdef TEST_ROW_MAJOR
38 __order = (order==ColMajor) ? RowMajor : ColMajor;
39 allocateFullStorage(__order, m, n, __A, __ldA);
40 switchFullStorageOrder(order, m, n, A, ldA, __A, __ldA);
41 # endif
42
43 cxxblas::ger(__order,
44 m, n,
45 alpha,
46 x, incX,
47 y, incY,
48 __A, __ldA);
49
50 # ifdef TEST_ROW_MAJOR
51 switchFullStorageOrder(__order, m, n, __A, __ldA, A, ldA);
52 releaseStorage(__A);
53 # endif
54 }
55 #else
56 ;
57 #endif // CREATE_CBLAS
58
59 #ifdef CREATE_BLAS
60 void
61 BLAS_NAME(const CBLAS_INT *_m, const CBLAS_INT *_n,
62 const CBLAS_FLOAT *_alpha,
63 const CBLAS_FLOAT *x, const CBLAS_INT *_incX,
64 const CBLAS_FLOAT *y, const CBLAS_INT *_incY,
65 CBLAS_FLOAT *A, const CBLAS_INT *_ldA)
66 {
67 CBLAS_INT m = *_m;
68 CBLAS_INT n = *_n;
69 CBLAS_FLOAT alpha = *_alpha;
70 CBLAS_INT incX = *_incX;
71 CBLAS_INT incY = *_incY;
72 CBLAS_INT ldA = *_ldA;
73
74 CBLAS_INT info = 0;
75 if (incY==0) {
76 info = 7;
77 }
78 if (incX==0) {
79 info = 5;
80 }
81 if (ldA<std::max(1, m)) {
82 info = 9;
83 }
84 if (n<0) {
85 info = 2;
86 }
87 if (m<0) {
88 info = 1;
89 }
90 if (info!=0) {
91 char blasName[6];
92 strncpy(blasName, BLAS_NAME_STR, 6);
93 for (int i=0; i<6; ++i) {
94 blasName[i] = std::toupper(blasName[i]);
95 }
96 xerbla_(blasName, &info);
97 return;
98 }
99
100 // the blas interface calls the cblas interface
101 // so any blas-test will also test the cblas-interface
102 CBLAS_NAME(CblasColMajor,
103 m, n,
104 alpha,
105 x, incX,
106 y, incY,
107 A, ldA);
108 }
109 #endif // CREATE_BLAS
110
111 } // extern "C"