diff options
Diffstat (limited to 'lib/Data')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 10 | ||||
-rw-r--r-- | lib/Data/Packed/Vector.hs | 10 |
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index e7ee781..438dabc 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -37,7 +37,7 @@ module Data.Packed.Matrix ( | |||
37 | 37 | ||
38 | import Data.Packed.Internal | 38 | import Data.Packed.Internal |
39 | import qualified Data.Packed.ST as ST | 39 | import qualified Data.Packed.ST as ST |
40 | import Data.Packed.Vector | 40 | --import Data.Packed.Vector |
41 | import Data.Array | 41 | import Data.Array |
42 | import System.Process(readProcess) | 42 | import System.Process(readProcess) |
43 | import Text.Printf(printf) | 43 | import Text.Printf(printf) |
@@ -113,7 +113,7 @@ adaptBlocks ms = ms' where | |||
113 | 113 | ||
114 | g [Just nr,Just nc] m | 114 | g [Just nr,Just nc] m |
115 | | nr == r && nc == c = m | 115 | | nr == r && nc == c = m |
116 | | r == 1 && c == 1 = reshape nc (constant x (nr*nc)) | 116 | | r == 1 && c == 1 = reshape nc (constantD x (nr*nc)) |
117 | | r == 1 = fromRows (replicate nr (flatten m)) | 117 | | r == 1 = fromRows (replicate nr (flatten m)) |
118 | | otherwise = fromColumns (replicate nc (flatten m)) | 118 | | otherwise = fromColumns (replicate nc (flatten m)) |
119 | where | 119 | where |
@@ -165,7 +165,7 @@ takeDiag m = fromList [flatten m `at` (k*cols m+k) | k <- [0 .. min (rows m) (co | |||
165 | 165 | ||
166 | -- | creates the identity matrix of given dimension | 166 | -- | creates the identity matrix of given dimension |
167 | ident :: Element a => Int -> Matrix a | 167 | ident :: Element a => Int -> Matrix a |
168 | ident n = diag (constant 1 n) | 168 | ident n = diag (constantD 1 n) |
169 | 169 | ||
170 | ------------------------------------------------------------ | 170 | ------------------------------------------------------------ |
171 | 171 | ||
@@ -459,7 +459,7 @@ class (Element e) => Container c e where | |||
459 | instance Container Vector Float where | 459 | instance Container Vector Float where |
460 | toComplex = toComplexV | 460 | toComplex = toComplexV |
461 | fromComplex = fromComplexV | 461 | fromComplex = fromComplexV |
462 | comp v = toComplex (v,constant 0 (dim v)) | 462 | comp v = toComplex (v,constantD 0 (dim v)) |
463 | conj = conjV | 463 | conj = conjV |
464 | real = mapVector realToFrac | 464 | real = mapVector realToFrac |
465 | complex = (mapVector (\(r :+ i) -> (realToFrac r :+ realToFrac i))) . comp | 465 | complex = (mapVector (\(r :+ i) -> (realToFrac r :+ realToFrac i))) . comp |
@@ -467,7 +467,7 @@ instance Container Vector Float where | |||
467 | instance Container Vector Double where | 467 | instance Container Vector Double where |
468 | toComplex = toComplexV | 468 | toComplex = toComplexV |
469 | fromComplex = fromComplexV | 469 | fromComplex = fromComplexV |
470 | comp v = toComplex (v,constant 0 (dim v)) | 470 | comp v = toComplex (v,constantD 0 (dim v)) |
471 | conj = conjV | 471 | conj = conjV |
472 | real = id | 472 | real = id |
473 | complex = comp | 473 | complex = comp |
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index b87372f..760f724 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -33,7 +33,7 @@ module Data.Packed.Vector ( | |||
33 | import Data.Packed.Internal | 33 | import Data.Packed.Internal |
34 | import Numeric.GSL.Vector | 34 | import Numeric.GSL.Vector |
35 | -- import Data.Packed.ST | 35 | -- import Data.Packed.ST |
36 | 36 | import Numeric.LinearAlgebra.Linear | |
37 | 37 | ||
38 | import Data.Binary | 38 | import Data.Binary |
39 | import Foreign.Storable | 39 | import Foreign.Storable |
@@ -81,11 +81,9 @@ Logarithmic spacing can be defined as follows: | |||
81 | 81 | ||
82 | @logspace n (a,b) = 10 ** linspace n (a,b)@ | 82 | @logspace n (a,b) = 10 ** linspace n (a,b)@ |
83 | -} | 83 | -} |
84 | linspace :: Int -> (Double, Double) -> Vector Double | 84 | linspace :: (Enum e, Linear Vector e, Element e) => Int -> (e, e) -> Vector e |
85 | linspace n (a,b) = add a $ scale s $ fromList [0 .. fromIntegral n-1] | 85 | linspace n (a,b) = addConstant a $ scale s $ fromList [0 .. fromIntegral n-1] |
86 | where scale = vectorMapValR Scale | 86 | where s = (b-a)/fromIntegral (n-1) |
87 | add = vectorMapValR AddConstant | ||
88 | s = (b-a)/fromIntegral (n-1) | ||
89 | 87 | ||
90 | {- | 88 | {- |
91 | vectorFMax :: Vector Float -> Float | 89 | vectorFMax :: Vector Float -> Float |