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                const CBLAS_FLOAT *y, CBLAS_INT incY,
 26                CBLAS_FLOAT  *A)
 27 #ifdef CREATE_CBLAS
 28     {
 29         StorageOrder order = (_order==CblasColMajor) ? ColMajor
 30                                                      : RowMajor;
 31         StorageUpLo upLo = Lower;
 32         if (_upLo==CblasUpper) {
 33             upLo = Upper;
 34         }
 35 
 36         CBLAS_FLOAT *__A = A;
 37         StorageOrder __order = order;
 38 
 39 #   ifdef TEST_ROW_MAJOR
 40         __order = (order==ColMajor) ? RowMajor : ColMajor;
 41         allocatePackedStorage(n, __A);
 42         switchPackedStorageOrder(order, upLo, n, A, __A);
 43 #   endif
 44 
 45         cxxblas::spr2(__order, upLo,
 46                       n,
 47                       alpha,
 48                       x, incX,
 49                       y, incY,
 50                       __A);
 51 
 52 #   ifdef TEST_ROW_MAJOR
 53         switchPackedStorageOrder(__order, upLo, n, __A, A);
 54         releaseStorage(__A);
 55 #   endif
 56     }
 57 #else
 58     ;
 59 #endif // CREATE_CBLAS
 60 
 61 #ifdef CREATE_BLAS
 62     void
 63     BLAS_NAME(const char *_upLo,
 64               const CBLAS_INT *_n,
 65               const CBLAS_FLOAT *_alpha,
 66               const CBLAS_FLOAT *x, const CBLAS_INT *_incX,
 67               const CBLAS_FLOAT *y, const CBLAS_INT *_incY,
 68               CBLAS_FLOAT *A)
 69     {
 70         bool checkUpLo = false;
 71         CBLAS_UPLO upLo = CblasUpper;
 72         if ((*_upLo=='L') || (*_upLo=='l')) {
 73             upLo = CblasLower;
 74             checkUpLo = true;
 75         }
 76         if ((*_upLo=='U') || (*_upLo=='u')) {
 77             checkUpLo = true;
 78         }
 79 
 80         CBLAS_INT n       = *_n;
 81         CBLAS_FLOAT alpha = *_alpha;
 82         CBLAS_INT incX    = *_incX;
 83         CBLAS_INT incY    = *_incY;
 84 
 85         CBLAS_INT info = 0;
 86         if (incX==0) {
 87             info = 5;
 88         }
 89         if (incY==0) {
 90             info = 7;
 91         }
 92         if (n<0) {
 93             info = 2;
 94         }
 95         if (!checkUpLo) {
 96             info = 1;
 97         }
 98         if (info!=0) {
 99             char blasName[6];
100             strncpy(blasName, BLAS_NAME_STR, 6);
101             for (int i=0; i<6; ++i) {
102                 blasName[i] = std::toupper(blasName[i]);
103             }
104             xerbla_(blasName, &info);
105           return;
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                    y, incY,
115                    A);
116     }
117 #endif // CREATE_BLAS
118 
119 // extern "C"