summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/kalman.hs6
-rw-r--r--hmatrix.cabal6
-rw-r--r--lib/Numeric/LinearAlgebra/LAPACK/f2c.h67
3 files changed, 69 insertions, 10 deletions
diff --git a/examples/kalman.hs b/examples/kalman.hs
index e191cbb..7fbe3d2 100644
--- a/examples/kalman.hs
+++ b/examples/kalman.hs
@@ -26,12 +26,12 @@ type Measurement = Vector Double
26kalman :: System -> State -> Measurement -> State 26kalman :: System -> State -> Measurement -> State
27kalman (System f h q r) (State x p) z = State x' p' where 27kalman (System f h q r) (State x p) z = State x' p' where
28 px = f <> x -- prediction 28 px = f <> x -- prediction
29 pq = f <> p <> trans f -- its covariance 29 pq = f <> p <> trans f + q -- its covariance
30 y = z - h <> px -- residue 30 y = z - h <> px -- residue
31 cy = h <> pq <> trans h + r -- its covariance 31 cy = h <> pq <> trans h + r -- its covariance
32 k = pq <> trans h <> inv cy -- kalman gain 32 k = pq <> trans h <> inv cy -- kalman gain
33 x' = px + k <> y -- new state 33 x' = px + k <> y -- new state
34 p' = (ident (dim x) - k <> h) <> pq -- its covariance 34 p' = (ident (dim x) - k <> h) <> pq -- its covariance
35 35
36sys = System f h q r 36sys = System f h q r
37 37
@@ -49,5 +49,3 @@ main = do
49 print $ fromRows $ take 10 (map sX xs) 49 print $ fromRows $ take 10 (map sX xs)
50 mapM_ (print . sP) $ take 10 xs 50 mapM_ (print . sP) $ take 10 xs
51 mplot (evolution 20 (xs,des)) 51 mplot (evolution 20 (xs,des))
52
53--(<>) = multiply \ No newline at end of file
diff --git a/hmatrix.cabal b/hmatrix.cabal
index 89a7ccd..9a0235f 100644
--- a/hmatrix.cabal
+++ b/hmatrix.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix 1Name: hmatrix
2Version: 0.1.1.0 2Version: 0.1.1.1
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -48,7 +48,6 @@ library
48 Numeric.GSL.Polynomials, 48 Numeric.GSL.Polynomials,
49 Numeric.GSL.Minimization, 49 Numeric.GSL.Minimization,
50 Numeric.GSL.Special, 50 Numeric.GSL.Special,
51 Numeric.GSL.Special.Internal,
52 Numeric.GSL.Special.Gamma, 51 Numeric.GSL.Special.Gamma,
53 Numeric.GSL.Special.Erf, 52 Numeric.GSL.Special.Erf,
54 Numeric.GSL.Special.Airy, 53 Numeric.GSL.Special.Airy,
@@ -86,7 +85,8 @@ library
86 other-modules: Data.Packed.Internal, 85 other-modules: Data.Packed.Internal,
87 Data.Packed.Internal.Common, 86 Data.Packed.Internal.Common,
88 Data.Packed.Internal.Vector, 87 Data.Packed.Internal.Vector,
89 Data.Packed.Internal.Matrix 88 Data.Packed.Internal.Matrix,
89 Numeric.GSL.Special.Internal
90 C-sources: lib/Data/Packed/Internal/auxi.c, 90 C-sources: lib/Data/Packed/Internal/auxi.c,
91 lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c, 91 lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c,
92 lib/Numeric/GSL/gsl-aux.c 92 lib/Numeric/GSL/gsl-aux.c
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/f2c.h b/lib/Numeric/LinearAlgebra/LAPACK/f2c.h
index b94ee7c..6a07e09 100644
--- a/lib/Numeric/LinearAlgebra/LAPACK/f2c.h
+++ b/lib/Numeric/LinearAlgebra/LAPACK/f2c.h
@@ -7,21 +7,74 @@
7#ifndef F2C_INCLUDE 7#ifndef F2C_INCLUDE
8#define F2C_INCLUDE 8#define F2C_INCLUDE
9 9
10/*
11
12Extracted from http://opengrok.creo.hu/dragonfly/xref/src/contrib/gcc-3.4/libf2c/readme.netlib
13
14NOTE: f2c.h defines several types, e.g., real, integer, doublereal.
15 115 The definitions in f2c.h are suitable for most machines, but if
16 116 your machine has sizeof(double) > 2*sizeof(long), you may need
17 117 to adjust f2c.h appropriately. f2c assumes
18 118 sizeof(doublecomplex) = 2*sizeof(doublereal)
19 119 sizeof(doublereal) = sizeof(complex)
20 120 sizeof(doublereal) = 2*sizeof(real)
21 121 sizeof(real) = sizeof(integer)
22 122 sizeof(real) = sizeof(logical)
23 123 sizeof(real) = 2*sizeof(shortint)
24 124 EQUIVALENCEs may not be translated correctly if these
25 125 assumptions are violated.
26 126
27 127 On machines, such as those using a DEC Alpha processor, on
28 128 which sizeof(short) == 2, sizeof(int) == sizeof(float) == 4,
29 129 and sizeof(long) == sizeof(double) == 8, it suffices to
30 130 modify f2c.h by removing the first occurrence of "long "
31 131 on each line containing "long ", e.g., by issuing the
32 132 commands
33 133 mv f2c.h f2c.h0
34 134 sed 's/long //' f2c.h0 >f2c.h
35 135 On such machines, one can enable INTEGER*8 by uncommenting
36 136 the typedef of longint in f2c.h, so it reads
37 137 typedef long longint;
38 138 by compiling libI77 with -DAllow_TYQUAD, and by adjusting
39 139 libF77/makefile as described in libF77/README.
40 140
41 141 Some machines may have sizeof(int) == 4, sizeof(float) == 8,
42 142 and sizeof(long long) == 8. On such machines, adjust f2c.h
43 143 by changing "long int " to "long long ", e.g., by saying
44 144 mv f2c.h f2c.h0
45 145 sed 's/long int /long long /' f2c.h0 >f2c.h
46 146 One can enable INTEGER*8 on such machines as described
47 147 above, but with
48 148 typedef long long longint;
49
50I thing that the following definitions are correct:
51
52*/
53
54#ifdef _LP64
55typedef int integer;
56typedef unsigned int uinteger;
57typedef int logical;
58typedef long longint; /* system-dependent */
59typedef unsigned long ulongint; /* system-dependent */
60#else
10typedef long int integer; 61typedef long int integer;
11typedef unsigned long int uinteger; 62typedef unsigned long int uinteger;
63typedef long int logical;
64typedef long long longint; /* system-dependent */
65typedef unsigned long long ulongint; /* system-dependent */
66#endif
67
12typedef char *address; 68typedef char *address;
13typedef short int shortint; 69typedef short int shortint;
14typedef float real; 70typedef float real;
15typedef double doublereal; 71typedef double doublereal;
16typedef struct { real r, i; } complex; 72typedef struct { real r, i; } complex;
17typedef struct { doublereal r, i; } doublecomplex; 73typedef struct { doublereal r, i; } doublecomplex;
18typedef long int logical;
19typedef short int shortlogical; 74typedef short int shortlogical;
20typedef char logical1; 75typedef char logical1;
21typedef char integer1; 76typedef char integer1;
22#ifdef INTEGER_STAR_8 /* Adjust for integer*8. */ 77#ifdef INTEGER_STAR_8 /* Adjust for integer*8. */
23typedef long long longint; /* system-dependent */
24typedef unsigned long long ulongint; /* system-dependent */
25#define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b))) 78#define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
26#define qbit_set(a,b) ((a) | ((ulongint)1 << (b))) 79#define qbit_set(a,b) ((a) | ((ulongint)1 << (b)))
27#endif 80#endif
@@ -42,11 +95,19 @@ typedef short flag;
42typedef short ftnlen; 95typedef short ftnlen;
43typedef short ftnint; 96typedef short ftnint;
44#else 97#else
98
99#ifdef _LP64
100typedef int flag;
101typedef int ftnlen;
102typedef int ftnint;
103#else
45typedef long int flag; 104typedef long int flag;
46typedef long int ftnlen; 105typedef long int ftnlen;
47typedef long int ftnint; 106typedef long int ftnint;
48#endif 107#endif
49 108
109#endif
110
50/*external read, write*/ 111/*external read, write*/
51typedef struct 112typedef struct
52{ flag cierr; 113{ flag cierr;