summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c')
-rw-r--r--lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c62
1 files changed, 49 insertions, 13 deletions
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
index 77a8847..4bf29b7 100644
--- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
+++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
@@ -48,25 +48,55 @@
48void asm_finit() { 48void asm_finit() {
49#ifdef i386 49#ifdef i386
50 50
51 #if FPUDEBUG 51// asm("finit");
52 uint val=0;
53 asm("fstsw"
54 : "=a" (val)
55 : "a" (val)
56 );
57 52
58 val = (val%16384)/2048; // bits 13-11 53 static unsigned char buf[108];
54 asm("FSAVE %0":"=m" (buf));
59 55
60 if (val != 0) { 56 #if FPUDEBUG
61 printf("Warning: FPU Stack: %d\n",val); 57 if(buf[8]!=255 || buf[9]!=255) {
62 asm("finit"); 58 printf("Warning: Nonempty FPU Stack. TAG = %x %x\n",buf[8],buf[9]);
63 } 59 }
64 #else 60 #endif
65 asm("finit"); 61
62 #if NANDEBUG
63 asm("FRSTOR %0":"=m" (buf));
66 #endif 64 #endif
67 65
68#endif 66#endif
69} 67}
68
69//---------------------------------------
70
71#if NANDEBUG
72
73#define CHECKNANR(M,msg) \
74{ int k; \
75for(k=0; k<(M##r * M##c); k++) { \
76 if(M##p[k] != M##p[k]) { \
77 printf(msg); \
78 TRACEMAT(M) \
79 /*exit(1);*/ \
80 } \
81} \
82}
83
84#define CHECKNANC(M,msg) \
85{ int k; \
86for(k=0; k<(M##r * M##c); k++) { \
87 if( M##p[k].r != M##p[k].r \
88 || M##p[k].i != M##p[k].i) { \
89 printf(msg); \
90 /*exit(1);*/ \
91 } \
92} \
93}
94
95#else
96#define CHECKNANC(M,msg)
97#define CHECKNANR(M,msg)
98#endif
99
70//--------------------------------------- 100//---------------------------------------
71 101
72//////////////////// real svd //////////////////////////////////// 102//////////////////// real svd ////////////////////////////////////
@@ -1031,6 +1061,8 @@ void dgemm_(char *, char *, integer *, integer *, integer *,
1031int multiplyR(int ta, int tb, KDMAT(a),KDMAT(b),DMAT(r)) { 1061int multiplyR(int ta, int tb, KDMAT(a),KDMAT(b),DMAT(r)) {
1032 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE); 1062 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
1033 DEBUGMSG("dgemm_"); 1063 DEBUGMSG("dgemm_");
1064 CHECKNANR(a,"NaN multR Input\n")
1065 CHECKNANR(b,"NaN multR Input\n")
1034 integer m = ta?ac:ar; 1066 integer m = ta?ac:ar;
1035 integer n = tb?br:bc; 1067 integer n = tb?br:bc;
1036 integer k = ta?ar:ac; 1068 integer k = ta?ar:ac;
@@ -1040,6 +1072,7 @@ int multiplyR(int ta, int tb, KDMAT(a),KDMAT(b),DMAT(r)) {
1040 double alpha = 1; 1072 double alpha = 1;
1041 double beta = 0; 1073 double beta = 0;
1042 dgemm_(ta?"T":"N",tb?"T":"N",&m,&n,&k,&alpha,ap,&lda,bp,&ldb,&beta,rp,&ldc); 1074 dgemm_(ta?"T":"N",tb?"T":"N",&m,&n,&k,&alpha,ap,&lda,bp,&ldb,&beta,rp,&ldc);
1075 CHECKNANR(r,"NaN multR Output\n")
1043 OK 1076 OK
1044} 1077}
1045 1078
@@ -1050,6 +1083,8 @@ void zgemm_(char *, char *, integer *, integer *, integer *,
1050int multiplyC(int ta, int tb, KCMAT(a),KCMAT(b),CMAT(r)) { 1083int multiplyC(int ta, int tb, KCMAT(a),KCMAT(b),CMAT(r)) {
1051 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE); 1084 //REQUIRES(ac==br && ar==rr && bc==rc,BAD_SIZE);
1052 DEBUGMSG("zgemm_"); 1085 DEBUGMSG("zgemm_");
1086 CHECKNANC(a,"NaN multC Input\n")
1087 CHECKNANC(b,"NaN multC Input\n")
1053 integer m = ta?ac:ar; 1088 integer m = ta?ac:ar;
1054 integer n = tb?br:bc; 1089 integer n = tb?br:bc;
1055 integer k = ta?ar:ac; 1090 integer k = ta?ar:ac;
@@ -1062,6 +1097,7 @@ int multiplyC(int ta, int tb, KCMAT(a),KCMAT(b),CMAT(r)) {
1062 ap,&lda, 1097 ap,&lda,
1063 bp,&ldb,&beta, 1098 bp,&ldb,&beta,
1064 rp,&ldc); 1099 rp,&ldc);
1100 CHECKNANC(r,"NaN multC Output\n")
1065 OK 1101 OK
1066} 1102}
1067 1103