00001
00002
00003
00004
00005
00006
00007 #include <stdlib.h>
00008 #include "cblas.h"
00009 #include "cblas_test.h"
00010 #define TEST_COL_MJR 0
00011 #define TEST_ROW_MJR 1
00012 #define UNDEFINED -1
00013
00014 void F77_dgemm(int *order, char *transpa, char *transpb, int *m, int *n,
00015 int *k, double *alpha, double *a, int *lda, double *b, int *ldb,
00016 double *beta, double *c, int *ldc ) {
00017
00018 double *A, *B, *C;
00019 int i,j,LDA, LDB, LDC;
00020 enum CBLAS_TRANSPOSE transa, transb;
00021
00022 get_transpose_type(transpa, &transa);
00023 get_transpose_type(transpb, &transb);
00024
00025 if (*order == TEST_ROW_MJR) {
00026 if (transa == CblasNoTrans) {
00027 LDA = *k+1;
00028 A = (double *)malloc( (*m)*LDA*sizeof( double ) );
00029 for( i=0; i<*m; i++ )
00030 for( j=0; j<*k; j++ )
00031 A[i*LDA+j]=a[j*(*lda)+i];
00032 }
00033 else {
00034 LDA = *m+1;
00035 A = ( double* )malloc( LDA*(*k)*sizeof( double ) );
00036 for( i=0; i<*k; i++ )
00037 for( j=0; j<*m; j++ )
00038 A[i*LDA+j]=a[j*(*lda)+i];
00039 }
00040 if (transb == CblasNoTrans) {
00041 LDB = *n+1;
00042 B = ( double* )malloc( (*k)*LDB*sizeof( double ) );
00043 for( i=0; i<*k; i++ )
00044 for( j=0; j<*n; j++ )
00045 B[i*LDB+j]=b[j*(*ldb)+i];
00046 }
00047 else {
00048 LDB = *k+1;
00049 B = ( double* )malloc( LDB*(*n)*sizeof( double ) );
00050 for( i=0; i<*n; i++ )
00051 for( j=0; j<*k; j++ )
00052 B[i*LDB+j]=b[j*(*ldb)+i];
00053 }
00054 LDC = *n+1;
00055 C = ( double* )malloc( (*m)*LDC*sizeof( double ) );
00056 for( j=0; j<*n; j++ )
00057 for( i=0; i<*m; i++ )
00058 C[i*LDC+j]=c[j*(*ldc)+i];
00059
00060 cblas_dgemm( CblasRowMajor, transa, transb, *m, *n, *k, *alpha, A, LDA,
00061 B, LDB, *beta, C, LDC );
00062 for( j=0; j<*n; j++ )
00063 for( i=0; i<*m; i++ )
00064 c[j*(*ldc)+i]=C[i*LDC+j];
00065 free(A);
00066 free(B);
00067 free(C);
00068 }
00069 else if (*order == TEST_COL_MJR)
00070 cblas_dgemm( CblasColMajor, transa, transb, *m, *n, *k, *alpha, a, *lda,
00071 b, *ldb, *beta, c, *ldc );
00072 else
00073 cblas_dgemm( UNDEFINED, transa, transb, *m, *n, *k, *alpha, a, *lda,
00074 b, *ldb, *beta, c, *ldc );
00075 }
00076 void F77_dsymm(int *order, char *rtlf, char *uplow, int *m, int *n,
00077 double *alpha, double *a, int *lda, double *b, int *ldb,
00078 double *beta, double *c, int *ldc ) {
00079
00080 double *A, *B, *C;
00081 int i,j,LDA, LDB, LDC;
00082 enum CBLAS_UPLO uplo;
00083 enum CBLAS_SIDE side;
00084
00085 get_uplo_type(uplow,&uplo);
00086 get_side_type(rtlf,&side);
00087
00088 if (*order == TEST_ROW_MJR) {
00089 if (side == CblasLeft) {
00090 LDA = *m+1;
00091 A = ( double* )malloc( (*m)*LDA*sizeof( double ) );
00092 for( i=0; i<*m; i++ )
00093 for( j=0; j<*m; j++ )
00094 A[i*LDA+j]=a[j*(*lda)+i];
00095 }
00096 else{
00097 LDA = *n+1;
00098 A = ( double* )malloc( (*n)*LDA*sizeof( double ) );
00099 for( i=0; i<*n; i++ )
00100 for( j=0; j<*n; j++ )
00101 A[i*LDA+j]=a[j*(*lda)+i];
00102 }
00103 LDB = *n+1;
00104 B = ( double* )malloc( (*m)*LDB*sizeof( double ) );
00105 for( i=0; i<*m; i++ )
00106 for( j=0; j<*n; j++ )
00107 B[i*LDB+j]=b[j*(*ldb)+i];
00108 LDC = *n+1;
00109 C = ( double* )malloc( (*m)*LDC*sizeof( double ) );
00110 for( j=0; j<*n; j++ )
00111 for( i=0; i<*m; i++ )
00112 C[i*LDC+j]=c[j*(*ldc)+i];
00113 cblas_dsymm( CblasRowMajor, side, uplo, *m, *n, *alpha, A, LDA, B, LDB,
00114 *beta, C, LDC );
00115 for( j=0; j<*n; j++ )
00116 for( i=0; i<*m; i++ )
00117 c[j*(*ldc)+i]=C[i*LDC+j];
00118 free(A);
00119 free(B);
00120 free(C);
00121 }
00122 else if (*order == TEST_COL_MJR)
00123 cblas_dsymm( CblasColMajor, side, uplo, *m, *n, *alpha, a, *lda, b, *ldb,
00124 *beta, c, *ldc );
00125 else
00126 cblas_dsymm( UNDEFINED, side, uplo, *m, *n, *alpha, a, *lda, b, *ldb,
00127 *beta, c, *ldc );
00128 }
00129
00130 void F77_dsyrk(int *order, char *uplow, char *transp, int *n, int *k,
00131 double *alpha, double *a, int *lda,
00132 double *beta, double *c, int *ldc ) {
00133
00134 int i,j,LDA,LDC;
00135 double *A, *C;
00136 enum CBLAS_UPLO uplo;
00137 enum CBLAS_TRANSPOSE trans;
00138
00139 get_uplo_type(uplow,&uplo);
00140 get_transpose_type(transp,&trans);
00141
00142 if (*order == TEST_ROW_MJR) {
00143 if (trans == CblasNoTrans) {
00144 LDA = *k+1;
00145 A = ( double* )malloc( (*n)*LDA*sizeof( double ) );
00146 for( i=0; i<*n; i++ )
00147 for( j=0; j<*k; j++ )
00148 A[i*LDA+j]=a[j*(*lda)+i];
00149 }
00150 else{
00151 LDA = *n+1;
00152 A = ( double* )malloc( (*k)*LDA*sizeof( double ) );
00153 for( i=0; i<*k; i++ )
00154 for( j=0; j<*n; j++ )
00155 A[i*LDA+j]=a[j*(*lda)+i];
00156 }
00157 LDC = *n+1;
00158 C = ( double* )malloc( (*n)*LDC*sizeof( double ) );
00159 for( i=0; i<*n; i++ )
00160 for( j=0; j<*n; j++ )
00161 C[i*LDC+j]=c[j*(*ldc)+i];
00162 cblas_dsyrk(CblasRowMajor, uplo, trans, *n, *k, *alpha, A, LDA, *beta,
00163 C, LDC );
00164 for( j=0; j<*n; j++ )
00165 for( i=0; i<*n; i++ )
00166 c[j*(*ldc)+i]=C[i*LDC+j];
00167 free(A);
00168 free(C);
00169 }
00170 else if (*order == TEST_COL_MJR)
00171 cblas_dsyrk(CblasColMajor, uplo, trans, *n, *k, *alpha, a, *lda, *beta,
00172 c, *ldc );
00173 else
00174 cblas_dsyrk(UNDEFINED, uplo, trans, *n, *k, *alpha, a, *lda, *beta,
00175 c, *ldc );
00176 }
00177
00178 void F77_dsyr2k(int *order, char *uplow, char *transp, int *n, int *k,
00179 double *alpha, double *a, int *lda, double *b, int *ldb,
00180 double *beta, double *c, int *ldc ) {
00181 int i,j,LDA,LDB,LDC;
00182 double *A, *B, *C;
00183 enum CBLAS_UPLO uplo;
00184 enum CBLAS_TRANSPOSE trans;
00185
00186 get_uplo_type(uplow,&uplo);
00187 get_transpose_type(transp,&trans);
00188
00189 if (*order == TEST_ROW_MJR) {
00190 if (trans == CblasNoTrans) {
00191 LDA = *k+1;
00192 LDB = *k+1;
00193 A = ( double* )malloc( (*n)*LDA*sizeof( double ) );
00194 B = ( double* )malloc( (*n)*LDB*sizeof( double ) );
00195 for( i=0; i<*n; i++ )
00196 for( j=0; j<*k; j++ ) {
00197 A[i*LDA+j]=a[j*(*lda)+i];
00198 B[i*LDB+j]=b[j*(*ldb)+i];
00199 }
00200 }
00201 else {
00202 LDA = *n+1;
00203 LDB = *n+1;
00204 A = ( double* )malloc( LDA*(*k)*sizeof( double ) );
00205 B = ( double* )malloc( LDB*(*k)*sizeof( double ) );
00206 for( i=0; i<*k; i++ )
00207 for( j=0; j<*n; j++ ){
00208 A[i*LDA+j]=a[j*(*lda)+i];
00209 B[i*LDB+j]=b[j*(*ldb)+i];
00210 }
00211 }
00212 LDC = *n+1;
00213 C = ( double* )malloc( (*n)*LDC*sizeof( double ) );
00214 for( i=0; i<*n; i++ )
00215 for( j=0; j<*n; j++ )
00216 C[i*LDC+j]=c[j*(*ldc)+i];
00217 cblas_dsyr2k(CblasRowMajor, uplo, trans, *n, *k, *alpha, A, LDA,
00218 B, LDB, *beta, C, LDC );
00219 for( j=0; j<*n; j++ )
00220 for( i=0; i<*n; i++ )
00221 c[j*(*ldc)+i]=C[i*LDC+j];
00222 free(A);
00223 free(B);
00224 free(C);
00225 }
00226 else if (*order == TEST_COL_MJR)
00227 cblas_dsyr2k(CblasColMajor, uplo, trans, *n, *k, *alpha, a, *lda,
00228 b, *ldb, *beta, c, *ldc );
00229 else
00230 cblas_dsyr2k(UNDEFINED, uplo, trans, *n, *k, *alpha, a, *lda,
00231 b, *ldb, *beta, c, *ldc );
00232 }
00233 void F77_dtrmm(int *order, char *rtlf, char *uplow, char *transp, char *diagn,
00234 int *m, int *n, double *alpha, double *a, int *lda, double *b,
00235 int *ldb) {
00236 int i,j,LDA,LDB;
00237 double *A, *B;
00238 enum CBLAS_SIDE side;
00239 enum CBLAS_DIAG diag;
00240 enum CBLAS_UPLO uplo;
00241 enum CBLAS_TRANSPOSE trans;
00242
00243 get_uplo_type(uplow,&uplo);
00244 get_transpose_type(transp,&trans);
00245 get_diag_type(diagn,&diag);
00246 get_side_type(rtlf,&side);
00247
00248 if (*order == TEST_ROW_MJR) {
00249 if (side == CblasLeft) {
00250 LDA = *m+1;
00251 A = ( double* )malloc( (*m)*LDA*sizeof( double ) );
00252 for( i=0; i<*m; i++ )
00253 for( j=0; j<*m; j++ )
00254 A[i*LDA+j]=a[j*(*lda)+i];
00255 }
00256 else{
00257 LDA = *n+1;
00258 A = ( double* )malloc( (*n)*LDA*sizeof( double ) );
00259 for( i=0; i<*n; i++ )
00260 for( j=0; j<*n; j++ )
00261 A[i*LDA+j]=a[j*(*lda)+i];
00262 }
00263 LDB = *n+1;
00264 B = ( double* )malloc( (*m)*LDB*sizeof( double ) );
00265 for( i=0; i<*m; i++ )
00266 for( j=0; j<*n; j++ )
00267 B[i*LDB+j]=b[j*(*ldb)+i];
00268 cblas_dtrmm(CblasRowMajor, side, uplo, trans, diag, *m, *n, *alpha,
00269 A, LDA, B, LDB );
00270 for( j=0; j<*n; j++ )
00271 for( i=0; i<*m; i++ )
00272 b[j*(*ldb)+i]=B[i*LDB+j];
00273 free(A);
00274 free(B);
00275 }
00276 else if (*order == TEST_COL_MJR)
00277 cblas_dtrmm(CblasColMajor, side, uplo, trans, diag, *m, *n, *alpha,
00278 a, *lda, b, *ldb);
00279 else
00280 cblas_dtrmm(UNDEFINED, side, uplo, trans, diag, *m, *n, *alpha,
00281 a, *lda, b, *ldb);
00282 }
00283
00284 void F77_dtrsm(int *order, char *rtlf, char *uplow, char *transp, char *diagn,
00285 int *m, int *n, double *alpha, double *a, int *lda, double *b,
00286 int *ldb) {
00287 int i,j,LDA,LDB;
00288 double *A, *B;
00289 enum CBLAS_SIDE side;
00290 enum CBLAS_DIAG diag;
00291 enum CBLAS_UPLO uplo;
00292 enum CBLAS_TRANSPOSE trans;
00293
00294 get_uplo_type(uplow,&uplo);
00295 get_transpose_type(transp,&trans);
00296 get_diag_type(diagn,&diag);
00297 get_side_type(rtlf,&side);
00298
00299 if (*order == TEST_ROW_MJR) {
00300 if (side == CblasLeft) {
00301 LDA = *m+1;
00302 A = ( double* )malloc( (*m)*LDA*sizeof( double ) );
00303 for( i=0; i<*m; i++ )
00304 for( j=0; j<*m; j++ )
00305 A[i*LDA+j]=a[j*(*lda)+i];
00306 }
00307 else{
00308 LDA = *n+1;
00309 A = ( double* )malloc( (*n)*LDA*sizeof( double ) );
00310 for( i=0; i<*n; i++ )
00311 for( j=0; j<*n; j++ )
00312 A[i*LDA+j]=a[j*(*lda)+i];
00313 }
00314 LDB = *n+1;
00315 B = ( double* )malloc( (*m)*LDB*sizeof( double ) );
00316 for( i=0; i<*m; i++ )
00317 for( j=0; j<*n; j++ )
00318 B[i*LDB+j]=b[j*(*ldb)+i];
00319 cblas_dtrsm(CblasRowMajor, side, uplo, trans, diag, *m, *n, *alpha,
00320 A, LDA, B, LDB );
00321 for( j=0; j<*n; j++ )
00322 for( i=0; i<*m; i++ )
00323 b[j*(*ldb)+i]=B[i*LDB+j];
00324 free(A);
00325 free(B);
00326 }
00327 else if (*order == TEST_COL_MJR)
00328 cblas_dtrsm(CblasColMajor, side, uplo, trans, diag, *m, *n, *alpha,
00329 a, *lda, b, *ldb);
00330 else
00331 cblas_dtrsm(UNDEFINED, side, uplo, trans, diag, *m, *n, *alpha,
00332 a, *lda, b, *ldb);
00333 }