summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README21
-rw-r--r--lib/Numeric/GSL/gsl-aux.c25
2 files changed, 33 insertions, 13 deletions
diff --git a/README b/README
index 8d7775b..3a260a4 100644
--- a/README
+++ b/README
@@ -10,15 +10,12 @@ REQUIREMENTS ----------------------------
102) BLAS/LAPACK (http://www.netlib.org/lapack). 102) BLAS/LAPACK (http://www.netlib.org/lapack).
11 An optimized implementation is recommended. I have tested: 11 An optimized implementation is recommended. I have tested:
12 12
13 - Intel's MKL (http://www.intel.com/cd/software/products).
14 There is a free noncommercial download of MKL for Linux.
15
16 - ATLAS (http://math-atlas.sourceforge.net). 13 - ATLAS (http://math-atlas.sourceforge.net).
17 In Ubuntu the required packages are "refblas3-dev", "lapack3-dev", 14 In Ubuntu the required packages are "refblas3-dev", "lapack3-dev",
18 and "atlas3-base-dev" (or a version tuned for your machine). 15 and "atlas3-base-dev" (or a version tuned for your machine).
19 Please note that ATLAS currently requires compilation -fviaC in 32bit 16
20 machines. Otherwise many functions fail, producing strange NaN's. 17 - Intel's MKL (http://www.intel.com/cd/software/products).
21 Even with -fvia-C we may get wrong behavior in some cases. 18 There is a free noncommercial download of MKL for Linux.
22 19
23For ghc-6.8.x you may also need: 20For ghc-6.8.x you may also need:
24 21
@@ -59,6 +56,7 @@ Using Intel's MKL:
59 $ runhaskell Setup.lhs build 56 $ runhaskell Setup.lhs build
60 $ runhaskell Setup.lhs install 57 $ runhaskell Setup.lhs install
61 58
59More information: http://www.hmatrix.googlepages.com/installation
62 60
63See below for installation on Windows. 61See below for installation on Windows.
64 62
@@ -70,7 +68,7 @@ Prelude> Numeric.LinearAlgebra.Tests.runTests 20
70 68
71Additional tests with big matrices (taking a few minutes): 69Additional tests with big matrices (taking a few minutes):
72 70
73$ runhaskell examples/experiments bigtests 71$ runhaskell examples/experiments/bigtests
74 72
75EXAMPLES ------------------------------------------------------ 73EXAMPLES ------------------------------------------------------
76 74
@@ -99,10 +97,8 @@ A number of illustrative programs are included in the examples folder.
99KNOWN PROBLEMS / BUGS ------------------------------- 97KNOWN PROBLEMS / BUGS -------------------------------
100 98
101- Compilation with -O -fasm on 32-bit machines produces strange 99- Compilation with -O -fasm on 32-bit machines produces strange
102 NaN's results on certain blas/lapack calls. In these machines 100 NaN's results on certain foreign calls. More info at
103 the library is automatically compiled -fvia-C, which apparently 101 http://www.hmatrix.googlepages.com/bugs
104 solves the problem.
105 On 64-bit, or using MKL, the default and faster -fasm seems to work well.
106 102
107- On 64-bit machines the example "minimize.hs", when run from ghci, 103- On 64-bit machines the example "minimize.hs", when run from ghci,
108 produces a segmentation fault. It happens in the call to 104 produces a segmentation fault. It happens in the call to
@@ -228,3 +224,6 @@ in the Haskell mailing lists for their help.
228- Don Stewart fixed the implementation of the internal data structures 224- Don Stewart fixed the implementation of the internal data structures
229 to achieve excellent, C-like performance in Haskell functions which 225 to achieve excellent, C-like performance in Haskell functions which
230 explicitly work with the elements of vectors and matrices. 226 explicitly work with the elements of vectors and matrices.
227
228- Dylan Alex Simon improved the numeric instances to allow optimized
229 implementations of signum and abs on Vectors.
diff --git a/lib/Numeric/GSL/gsl-aux.c b/lib/Numeric/GSL/gsl-aux.c
index 052cafd..77e793e 100644
--- a/lib/Numeric/GSL/gsl-aux.c
+++ b/lib/Numeric/GSL/gsl-aux.c
@@ -95,6 +95,26 @@ inline double sign(double x) {
95 } 95 }
96} 96}
97 97
98inline gsl_complex complex_abs(gsl_complex z) {
99 gsl_complex r;
100 r.dat[0] = gsl_complex_abs(z);
101 r.dat[1] = 0;
102 return r;
103}
104
105inline gsl_complex complex_signum(gsl_complex z) {
106 gsl_complex r;
107 double mag;
108 if (z.dat[0] == 0 && z.dat[1] == 0) {
109 r.dat[0] = 0;
110 r.dat[1] = 0;
111 } else {
112 mag = gsl_complex_abs(z);
113 r.dat[0] = z.dat[0]/mag;
114 r.dat[1] = z.dat[1]/mag;
115 }
116 return r;
117}
98 118
99#define OP(C,F) case C: { for(k=0;k<xn;k++) rp[k] = F(xp[k]); OK } 119#define OP(C,F) case C: { for(k=0;k<xn;k++) rp[k] = F(xp[k]); OK }
100#define OPV(C,E) case C: { for(k=0;k<xn;k++) rp[k] = E; OK } 120#define OPV(C,E) case C: { for(k=0;k<xn;k++) rp[k] = E; OK }
@@ -124,6 +144,7 @@ int mapR(int code, KRVEC(x), RVEC(r)) {
124 } 144 }
125} 145}
126 146
147
127int mapCAux(int code, KGCVEC(x), GCVEC(r)) { 148int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
128 int k; 149 int k;
129 REQUIRES(xn == rn,BAD_SIZE); 150 REQUIRES(xn == rn,BAD_SIZE);
@@ -132,7 +153,7 @@ int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
132 OP(0,gsl_complex_sin) 153 OP(0,gsl_complex_sin)
133 OP(1,gsl_complex_cos) 154 OP(1,gsl_complex_cos)
134 OP(2,gsl_complex_tan) 155 OP(2,gsl_complex_tan)
135 156 OP(3,complex_abs)
136 OP(4,gsl_complex_arcsin) 157 OP(4,gsl_complex_arcsin)
137 OP(5,gsl_complex_arccos) 158 OP(5,gsl_complex_arccos)
138 OP(6,gsl_complex_arctan) 159 OP(6,gsl_complex_arctan)
@@ -144,7 +165,7 @@ int mapCAux(int code, KGCVEC(x), GCVEC(r)) {
144 OP(12,gsl_complex_arctanh) 165 OP(12,gsl_complex_arctanh)
145 OP(13,gsl_complex_exp) 166 OP(13,gsl_complex_exp)
146 OP(14,gsl_complex_log) 167 OP(14,gsl_complex_log)
147 168 OP(15,complex_signum)
148 OP(16,gsl_complex_sqrt) 169 OP(16,gsl_complex_sqrt)
149 170
150 // gsl_complex_arg 171 // gsl_complex_arg