summaryrefslogtreecommitdiff
path: root/lib/LinearAlgebra/Linear.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/LinearAlgebra/Linear.hs')
-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