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