00001
00018 #include <stdio.h>
00019
00020 extern "C" {
00021
00022 #if FC_SYMBOL==2
00023 #define F_DAXPY daxpy_
00024 #define F_DCOPY dcopy_
00025 #define F_DGEMM dgemm_
00026 #define F_DROT drot_
00027 #define F_DSCAL dscal_
00028 #define F_DGEMV dgemv_
00029 #define F_DSPMV dspmv_
00030 #define F_DDOT ddot_
00031 #elif FC_SYMBOL==1
00032 #define F_DAXPY daxpy
00033 #define F_DCOPY dcopy
00034 #define F_DGEMM dgemm
00035 #define F_DROT drot
00036 #define F_DSCAL dscal
00037 #define F_DGEMV dgemv
00038 #define F_DSPMV dspmv
00039 #define F_DDOT ddot
00040 #elif FC_SYMBOL==3
00041 #define F_DAXPY DAXPY
00042 #define F_DCOPY DCOPY
00043 #define F_DGEMM DGEMM
00044 #define F_DROT DROT
00045 #define F_DSCAL DSCAL
00046 #define F_DGEMV DGEMV
00047 #define F_DSPMV DSPMV
00048 #define F_DDOT DDOT
00049 #elif FC_SYMBOL==4
00050 #define F_DAXPY DAXPY_
00051 #define F_DCOPY DCOPY_
00052 #define F_DGEMM DGEMM_
00053 #define F_DROT DROT_
00054 #define F_DSCAL DSCAL_
00055 #define F_DGEMV DGEMV_
00056 #define F_DSPMV DSPMV_
00057 #define F_DDOT DDOT_
00058 #endif
00059
00060 extern void F_DAXPY(int *length, double *a, double *x, int *inc_x,
00061 double *y, int *inc_y);
00062 extern void F_DCOPY(int *length, double *x, int *inc_x,
00063 double *y, int *inc_y);
00064 extern void F_DGEMM(char *transa, char *transb, int *m, int *n, int *k,
00065 double *alpha, double *A, int *lda, double *B, int *ldb,
00066 double *beta, double *C, int *ldc);
00067 extern void F_DROT(int *ntot, double *x, int *incx, double *y, int *incy,
00068 double *cotheta, double *sintheta);
00069 extern void F_DSCAL(int *n, double *alpha, double *vec, int *inc);
00070 extern void F_DGEMV(char *transa, int *m, int *n, double *alpha, double *A,
00071 int *lda, double *X, int *inc_x, double *beta, double *Y, int *inc_y);
00072 extern void F_DSPMV(char *uplo, int *n, double *alpha, double *A, double *X,
00073 int *inc_x, double *beta, double *Y, int *inc_y);
00074 extern double F_DDOT(int *n, double *x, int *incx, double *y, int *incy);
00075
00076
00093 void C_DAXPY(int length, double a, double *x, int inc_x,
00094 double *y, int inc_y)
00095 {
00096 F_DAXPY(&length, &a, x, &inc_x, y, &inc_y);
00097 }
00098
00099
00115 void C_DCOPY(int length, double *x, int inc_x,
00116 double *y, int inc_y)
00117 {
00118 F_DCOPY(&length, x, &inc_x, y, &inc_y);
00119 }
00120
00121
00134 void C_DSCAL(int length, double alpha, double *vec, int inc)
00135 {
00136 F_DSCAL(&length, &alpha, vec, &inc);
00137 }
00138
00139
00154 void C_DROT(int length, double *x, int inc_x, double *y, int inc_y,
00155 double costheta, double sintheta)
00156 {
00157
00158 F_DROT(&length,x,&inc_x,y,&inc_y,&costheta,&sintheta);
00159 }
00160
00161
00235 void C_DGEMM(char transa, char transb, int m, int n, int k, double alpha,
00236 double *A, int nca, double *B, int ncb, double beta, double *C,
00237 int ncc)
00238 {
00239
00240
00241
00242
00243
00244
00245 if (m == 0 || n == 0 || k == 0) return;
00246
00247 F_DGEMM(&transb,&transa,&n,&m,&k,&alpha,B,&ncb,A,&nca,&beta,C,&ncc);
00248
00249 }
00250
00251
00286 void C_DGEMV(char transa, int m, int n, double alpha, double *A,
00287 int nca, double *X, int inc_x, double beta, double *Y,
00288 int inc_y)
00289 {
00290 if (m == 0 || n == 0) return;
00291
00292 if(transa == 'n') transa = 't';
00293 else transa = 'n';
00294
00295 F_DGEMV(&transa,&n,&m,&alpha,A,&nca,X,&inc_x,&beta,Y,&inc_y);
00296
00297 }
00298
00299
00331 void C_DSPMV(char uplo, int n, double alpha, double *A,
00332 double *X, int inc_x, double beta, double *Y,
00333 int inc_y)
00334 {
00335 if (n == 0) return;
00336
00337 if (uplo != 'U' && uplo != 'u' && uplo != 'L' && uplo != 'l')
00338 fprintf(stderr, "C_DSPMV: called with unrecognized option for uplo!\n");
00339
00340 if (uplo == 'U' || uplo == 'u') uplo = 'L';
00341 else uplo = 'U';
00342
00343 F_DSPMV(&uplo,&n,&alpha,A,X,&inc_x,&beta,Y,&inc_y);
00344
00345 }
00346
00347
00365 double C_DDOT(int n, double *x, int inc_x, double *y, int inc_y)
00366 {
00367 if(n == 0) return 0.0;
00368
00369 return F_DDOT(&n,x,&inc_x,y,&inc_y);
00370 }
00371
00372 }