diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-09-10 09:13:20 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-09-10 09:13:20 +0000 |
commit | 89651db9f2577ba42dbbb91c85565a12f34d0fb2 (patch) | |
tree | cf7c5d023c2fe4bda50a4428c2171bd2f9ef83a2 /lib/LinearAlgebra/Linear.hs | |
parent | 631a32fbdc0d61f647d3217da86bcb1d552e5e5a (diff) |
simplified
Diffstat (limited to 'lib/LinearAlgebra/Linear.hs')
-rw-r--r-- | lib/LinearAlgebra/Linear.hs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/LinearAlgebra/Linear.hs b/lib/LinearAlgebra/Linear.hs new file mode 100644 index 0000000..5c5bf0d --- /dev/null +++ b/lib/LinearAlgebra/Linear.hs | |||
@@ -0,0 +1,45 @@ | |||
1 | {-# OPTIONS_GHC -fglasgow-exts #-} | ||
2 | ----------------------------------------------------------------------------- | ||
3 | {- | | ||
4 | Module : LinearAlgebra.Linear | ||
5 | Copyright : (c) Alberto Ruiz 2006-7 | ||
6 | License : GPL-style | ||
7 | |||
8 | Maintainer : Alberto Ruiz (aruiz at um dot es) | ||
9 | Stability : provisional | ||
10 | Portability : uses ffi | ||
11 | |||
12 | |||
13 | -} | ||
14 | ----------------------------------------------------------------------------- | ||
15 | |||
16 | module LinearAlgebra.Linear ( | ||
17 | Linear(..) | ||
18 | ) where | ||
19 | |||
20 | |||
21 | import Data.Packed.Internal | ||
22 | import GSL.Vector | ||
23 | import Complex | ||
24 | |||
25 | |||
26 | class (Num e, Field e) => Linear c e where | ||
27 | scale :: e -> c e -> c e | ||
28 | addConstant :: e -> c e -> c e | ||
29 | add :: c e -> c e -> c e | ||
30 | sub :: c e -> c e -> c e | ||
31 | mul :: c e -> c e -> c e | ||
32 | |||
33 | instance Linear Vector Double where | ||
34 | scale = vectorMapValR Scale | ||
35 | addConstant = vectorMapValR AddConstant | ||
36 | add = vectorZipR Add | ||
37 | sub = vectorZipR Sub | ||
38 | mul = vectorZipR Mul | ||
39 | |||
40 | instance Linear Vector (Complex Double) where | ||
41 | scale = vectorMapValC Scale | ||
42 | addConstant = vectorMapValC AddConstant | ||
43 | add = vectorZipC Add | ||
44 | sub = vectorZipC Sub | ||
45 | mul = vectorZipC Mul | ||