summaryrefslogtreecommitdiff
path: root/lib/Numeric/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-09-06 07:37:18 +0000
committerAlberto Ruiz <aruiz@um.es>2010-09-06 07:37:18 +0000
commit29099e3bfb4eec87ac3d4d675d7cfc82234c20d6 (patch)
tree82124829d5e2a51e1b272430cee2617b7e182e0e /lib/Numeric/Matrix.hs
parentfa4e2233a873bbfee26939c013b56acc160bca7b (diff)
working on conversion / linear
Diffstat (limited to 'lib/Numeric/Matrix.hs')
-rw-r--r--lib/Numeric/Matrix.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Numeric/Matrix.hs b/lib/Numeric/Matrix.hs
index 8d3764a..f240384 100644
--- a/lib/Numeric/Matrix.hs
+++ b/lib/Numeric/Matrix.hs
@@ -27,7 +27,8 @@ module Numeric.Matrix (
27import Data.Packed.Vector 27import Data.Packed.Vector
28import Data.Packed.Matrix 28import Data.Packed.Matrix
29import Numeric.Container 29import Numeric.Container
30import Numeric.Vector() 30import Numeric.LinearAlgebra.Linear
31--import Numeric.Vector
31 32
32import Control.Monad(ap) 33import Control.Monad(ap)
33 34
@@ -74,7 +75,7 @@ instance (Linear Vector a, Floating (Vector a), Fractional (Matrix a)) => Floati
74 75
75--------------------------------------------------------------- 76---------------------------------------------------------------
76 77
77instance (Linear Vector a, Container Matrix) => (Linear Matrix a) where 78instance (Linear Vector a, NumericContainer Matrix) => (Linear Matrix a) where
78 scale x = liftMatrix (scale x) 79 scale x = liftMatrix (scale x)
79 scaleRecip x = liftMatrix (scaleRecip x) 80 scaleRecip x = liftMatrix (scaleRecip x)
80 addConstant x = liftMatrix (addConstant x) 81 addConstant x = liftMatrix (addConstant x)
@@ -84,6 +85,9 @@ instance (Linear Vector a, Container Matrix) => (Linear Matrix a) where
84 divide = liftMatrix2 divide 85 divide = liftMatrix2 divide
85 equal a b = cols a == cols b && flatten a `equal` flatten b 86 equal a b = cols a == cols b && flatten a `equal` flatten b
86 scalar x = (1><1) [x] 87 scalar x = (1><1) [x]
88
89
90instance (Linear Vector a, NumericContainer Matrix) => (Container Matrix a) where
87 minIndex m = let (r,c) = (rows m,cols m) 91 minIndex m = let (r,c) = (rows m,cols m)
88 i = 1 + (minIndex $ flatten m) 92 i = 1 + (minIndex $ flatten m)
89 in (i `div` r,i `mod` r) 93 in (i `div` r,i `mod` r)
@@ -94,4 +98,3 @@ instance (Linear Vector a, Container Matrix) => (Linear Matrix a) where
94 maxElement = ap (@@>) maxIndex 98 maxElement = ap (@@>) maxIndex
95 99
96---------------------------------------------------- 100----------------------------------------------------
97