diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-01-17 18:15:33 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-01-17 18:15:33 +0000 |
commit | 0d26c1fc0eccdeb585a74d96cbe7861cf20c7bd2 (patch) | |
tree | 1747de32361cf1485108aae2dcb82ce4a6d75ebf | |
parent | c520939e33cc895febed271d5c3218457317bba9 (diff) |
f2c.h hack, trying to support both 32 and 64 bit mahines
-rw-r--r-- | examples/kalman.hs | 6 | ||||
-rw-r--r-- | hmatrix.cabal | 6 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK/f2c.h | 67 |
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 | |||
26 | kalman :: System -> State -> Measurement -> State | 26 | kalman :: System -> State -> Measurement -> State |
27 | kalman (System f h q r) (State x p) z = State x' p' where | 27 | kalman (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 | ||
36 | sys = System f h q r | 36 | sys = 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 @@ | |||
1 | Name: hmatrix | 1 | Name: hmatrix |
2 | Version: 0.1.1.0 | 2 | Version: 0.1.1.1 |
3 | License: GPL | 3 | License: GPL |
4 | License-file: LICENSE | 4 | License-file: LICENSE |
5 | Author: Alberto Ruiz | 5 | Author: 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 | |||
12 | Extracted from http://opengrok.creo.hu/dragonfly/xref/src/contrib/gcc-3.4/libf2c/readme.netlib | ||
13 | |||
14 | NOTE: 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 | |||
50 | I thing that the following definitions are correct: | ||
51 | |||
52 | */ | ||
53 | |||
54 | #ifdef _LP64 | ||
55 | typedef int integer; | ||
56 | typedef unsigned int uinteger; | ||
57 | typedef int logical; | ||
58 | typedef long longint; /* system-dependent */ | ||
59 | typedef unsigned long ulongint; /* system-dependent */ | ||
60 | #else | ||
10 | typedef long int integer; | 61 | typedef long int integer; |
11 | typedef unsigned long int uinteger; | 62 | typedef unsigned long int uinteger; |
63 | typedef long int logical; | ||
64 | typedef long long longint; /* system-dependent */ | ||
65 | typedef unsigned long long ulongint; /* system-dependent */ | ||
66 | #endif | ||
67 | |||
12 | typedef char *address; | 68 | typedef char *address; |
13 | typedef short int shortint; | 69 | typedef short int shortint; |
14 | typedef float real; | 70 | typedef float real; |
15 | typedef double doublereal; | 71 | typedef double doublereal; |
16 | typedef struct { real r, i; } complex; | 72 | typedef struct { real r, i; } complex; |
17 | typedef struct { doublereal r, i; } doublecomplex; | 73 | typedef struct { doublereal r, i; } doublecomplex; |
18 | typedef long int logical; | ||
19 | typedef short int shortlogical; | 74 | typedef short int shortlogical; |
20 | typedef char logical1; | 75 | typedef char logical1; |
21 | typedef char integer1; | 76 | typedef char integer1; |
22 | #ifdef INTEGER_STAR_8 /* Adjust for integer*8. */ | 77 | #ifdef INTEGER_STAR_8 /* Adjust for integer*8. */ |
23 | typedef long long longint; /* system-dependent */ | ||
24 | typedef 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; | |||
42 | typedef short ftnlen; | 95 | typedef short ftnlen; |
43 | typedef short ftnint; | 96 | typedef short ftnint; |
44 | #else | 97 | #else |
98 | |||
99 | #ifdef _LP64 | ||
100 | typedef int flag; | ||
101 | typedef int ftnlen; | ||
102 | typedef int ftnint; | ||
103 | #else | ||
45 | typedef long int flag; | 104 | typedef long int flag; |
46 | typedef long int ftnlen; | 105 | typedef long int ftnlen; |
47 | typedef long int ftnint; | 106 | typedef long int ftnint; |
48 | #endif | 107 | #endif |
49 | 108 | ||
109 | #endif | ||
110 | |||
50 | /*external read, write*/ | 111 | /*external read, write*/ |
51 | typedef struct | 112 | typedef struct |
52 | { flag cierr; | 113 | { flag cierr; |