summaryrefslogtreecommitdiff
path: root/lib/LinearAlgebra
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-09-10 09:13:20 +0000
committerAlberto Ruiz <aruiz@um.es>2007-09-10 09:13:20 +0000
commit89651db9f2577ba42dbbb91c85565a12f34d0fb2 (patch)
treecf7c5d023c2fe4bda50a4428c2171bd2f9ef83a2 /lib/LinearAlgebra
parent631a32fbdc0d61f647d3217da86bcb1d552e5e5a (diff)
simplified
Diffstat (limited to 'lib/LinearAlgebra')
-rw-r--r--lib/LinearAlgebra/Linear.hs45
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{- |
4Module : LinearAlgebra.Linear
5Copyright : (c) Alberto Ruiz 2006-7
6License : GPL-style
7
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional
10Portability : uses ffi
11
12
13-}
14-----------------------------------------------------------------------------
15
16module LinearAlgebra.Linear (
17 Linear(..)
18) where
19
20
21import Data.Packed.Internal
22import GSL.Vector
23import Complex
24
25
26class (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
33instance 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
40instance 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