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