summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-08-26 17:49:45 +0000
committerAlberto Ruiz <aruiz@um.es>2010-08-26 17:49:45 +0000
commit6058e1b17c005be1ea95ebb7d98d9fd15bb538d2 (patch)
treec4277e00c2c92a0ed8f3750255154fa8e2b6fe2d /lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
parentf541d7dbdc8338b1dd1c0538751d837a16740bd8 (diff)
Float matrix product
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c')
-rw-r--r--lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c81
1 files changed, 77 insertions, 4 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
index 7a40991..9e44431 100644
--- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
+++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
@@ -11,15 +11,25 @@
11 11
12#define MIN(A,B) ((A)<(B)?(A):(B)) 12#define MIN(A,B) ((A)<(B)?(A):(B))
13#define MAX(A,B) ((A)>(B)?(A):(B)) 13#define MAX(A,B) ((A)>(B)?(A):(B))
14 14
15// #define DBGL
16
15#ifdef DBGL 17#ifdef DBGL
16#define DEBUGMSG(M) printf("LAPACK Wrapper "M"\n: "); size_t t0 = time(NULL); 18#define DEBUGMSG(M) printf("\nLAPACK "M"\n");
17#define OK MACRO(printf("%ld s\n",time(0)-t0); return 0;);
18#else 19#else
19#define DEBUGMSG(M) 20#define DEBUGMSG(M)
20#define OK return 0;
21#endif 21#endif
22 22
23#define OK return 0;
24
25// #ifdef DBGL
26// #define DEBUGMSG(M) printf("LAPACK Wrapper "M"\n: "); size_t t0 = time(NULL);
27// #define OK MACRO(printf("%ld s\n",time(0)-t0); return 0;);
28// #else
29// #define DEBUGMSG(M)
30// #define OK return 0;
31// #endif
32
23#define TRACEMAT(M) {int q; printf(" %d x %d: ",M##r,M##c); \ 33#define TRACEMAT(M) {int q; printf(" %d x %d: ",M##r,M##c); \
24 for(q=0;q<M##r*M##c;q++) printf("%.1f ",M##p[q]); printf("\n");} 34 for(q=0;q<M##r*M##c;q++) printf("%.1f ",M##p[q]); printf("\n");}
25 35
@@ -1004,6 +1014,7 @@ void dgemm_(char *, char *, integer *, integer *, integer *,
1004 1014
1005int multiplyR(int ta, int tb, KDMAT(a),KDMAT(b),DMAT(r)) { 1015int multiplyR(int ta, int tb, KDMAT(a),KDMAT(b),DMAT(r)) {
1006 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE); 1016 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
1017 DEBUGMSG("dgemm_");
1007 integer m = ta?ac:ar; 1018 integer m = ta?ac:ar;
1008 integer n = tb?br:bc; 1019 integer n = tb?br:bc;
1009 integer k = ta?ar:ac; 1020 integer k = ta?ar:ac;
@@ -1022,6 +1033,7 @@ void zgemm_(char *, char *, integer *, integer *, integer *,
1022 1033
1023int multiplyC(int ta, int tb, KCMAT(a),KCMAT(b),CMAT(r)) { 1034int multiplyC(int ta, int tb, KCMAT(a),KCMAT(b),CMAT(r)) {
1024 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE); 1035 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
1036 DEBUGMSG("zgemm_");
1025 integer m = ta?ac:ar; 1037 integer m = ta?ac:ar;
1026 integer n = tb?br:bc; 1038 integer n = tb?br:bc;
1027 integer k = ta?ar:ac; 1039 integer k = ta?ar:ac;
@@ -1037,6 +1049,47 @@ int multiplyC(int ta, int tb, KCMAT(a),KCMAT(b),CMAT(r)) {
1037 OK 1049 OK
1038} 1050}
1039 1051
1052void sgemm_(char *, char *, integer *, integer *, integer *,
1053 float *, const float *, integer *, const float *,
1054 integer *, float *, float *, integer *);
1055
1056int multiplyF(int ta, int tb, KFMAT(a),KFMAT(b),FMAT(r)) {
1057 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
1058 DEBUGMSG("sgemm_");
1059 integer m = ta?ac:ar;
1060 integer n = tb?br:bc;
1061 integer k = ta?ar:ac;
1062 integer lda = ar;
1063 integer ldb = br;
1064 integer ldc = rr;
1065 float alpha = 1;
1066 float beta = 0;
1067 sgemm_(ta?"T":"N",tb?"T":"N",&m,&n,&k,&alpha,ap,&lda,bp,&ldb,&beta,rp,&ldc);
1068 OK
1069}
1070
1071void cgemm_(char *, char *, integer *, integer *, integer *,
1072 complex *, const complex *, integer *, const complex *,
1073 integer *, complex *, complex *, integer *);
1074
1075int multiplyQ(int ta, int tb, KQMAT(a),KQMAT(b),QMAT(r)) {
1076 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
1077 DEBUGMSG("cgemm_");
1078 integer m = ta?ac:ar;
1079 integer n = tb?br:bc;
1080 integer k = ta?ar:ac;
1081 integer lda = ar;
1082 integer ldb = br;
1083 integer ldc = rr;
1084 complex alpha = {1,0};
1085 complex beta = {0,0};
1086 cgemm_(ta?"T":"N",tb?"T":"N",&m,&n,&k,&alpha,
1087 (complex*)ap,&lda,
1088 (complex*)bp,&ldb,&beta,
1089 (complex*)rp,&ldc);
1090 OK
1091}
1092
1040//////////////////// transpose ///////////////////////// 1093//////////////////// transpose /////////////////////////
1041 1094
1042int transF(KFMAT(x),FMAT(t)) { 1095int transF(KFMAT(x),FMAT(t)) {
@@ -1128,3 +1181,23 @@ int constantC(doublecomplex* pval, CVEC(r)) {
1128 } 1181 }
1129 OK 1182 OK
1130} 1183}
1184
1185//////////////////// float-double conversion /////////////////////////
1186
1187int float2double(FVEC(x),DVEC(y)) {
1188 DEBUGMSG("float2double")
1189 int k;
1190 for(k=0;k<xn;k++) {
1191 yp[k]=xp[k];
1192 }
1193 OK
1194}
1195
1196int double2float(DVEC(x),FVEC(y)) {
1197 DEBUGMSG("double2float")
1198 int k;
1199 for(k=0;k<xn;k++) {
1200 yp[k]=xp[k];
1201 }
1202 OK
1203}