diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-09-23 12:41:35 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-09-23 12:41:35 +0000 |
commit | f50304b47f99ce0280d7ab7daf28ffe6b0d0b853 (patch) | |
tree | 020b9b66e4bc93e0928a7b3077a38db9fa7be189 /lib/Numeric/LinearAlgebra/Algorithms.hs | |
parent | 3cfce69bf3cb7d7f7976abb454b64f6fa3a32c97 (diff) |
ContainerBoot
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index c49bec7..f4f8bca 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -13,7 +13,7 @@ Maintainer : Alberto Ruiz (aruiz at um dot es) | |||
13 | Stability : provisional | 13 | Stability : provisional |
14 | Portability : uses ffi | 14 | Portability : uses ffi |
15 | 15 | ||
16 | Generic interface for the most common functions. Using it we can write higher level algorithms and testing properties for both real and complex matrices. | 16 | High level generic interface to common matrix computations. |
17 | 17 | ||
18 | Specific functions for particular base types can also be explicitly | 18 | Specific functions for particular base types can also be explicitly |
19 | imported from "Numeric.LinearAlgebra.LAPACK". | 19 | imported from "Numeric.LinearAlgebra.LAPACK". |
@@ -63,6 +63,7 @@ module Numeric.LinearAlgebra.Algorithms ( | |||
63 | nullspaceSVD, | 63 | nullspaceSVD, |
64 | -- * Norms | 64 | -- * Norms |
65 | Normed(..), NormType(..), | 65 | Normed(..), NormType(..), |
66 | relativeError, | ||
66 | -- * Misc | 67 | -- * Misc |
67 | eps, peps, i, | 68 | eps, peps, i, |
68 | -- * Util | 69 | -- * Util |
@@ -79,10 +80,10 @@ import Data.Packed.Matrix | |||
79 | import Numeric.LinearAlgebra.LAPACK as LAPACK | 80 | import Numeric.LinearAlgebra.LAPACK as LAPACK |
80 | import Data.List(foldl1') | 81 | import Data.List(foldl1') |
81 | import Data.Array | 82 | import Data.Array |
82 | import Numeric.Container hiding ((.*),(*/)) | 83 | import Numeric.ContainerBoot hiding ((.*),(*/)) |
83 | import Numeric.MatrixBoot | ||
84 | 84 | ||
85 | {- | Auxiliary typeclass used to define generic linear algebra computations for both real and complex matrices. Only double precision is supported in this version (we can | 85 | |
86 | {- | Class used to define generic linear algebra computations for both real and complex matrices. Only double precision is supported in this version (we can | ||
86 | transform single precision objects using 'single' and 'double'). | 87 | transform single precision objects using 'single' and 'double'). |
87 | 88 | ||
88 | -} | 89 | -} |
@@ -691,3 +692,9 @@ instance Normed Matrix (Complex Float) where | |||
691 | pnorm PNorm2 = realToFrac . (@>0) . singularValues . double | 692 | pnorm PNorm2 = realToFrac . (@>0) . singularValues . double |
692 | pnorm Infinity = pnorm PNorm1 . trans | 693 | pnorm Infinity = pnorm PNorm1 . trans |
693 | pnorm Frobenius = pnorm PNorm2 . flatten | 694 | pnorm Frobenius = pnorm PNorm2 . flatten |
695 | |||
696 | -- | Approximate number of common digits in the maximum element. | ||
697 | relativeError :: (Normed c t, Container c t) => c t -> c t -> Int | ||
698 | relativeError x y = dig (norm (x `sub` y) / norm x) | ||
699 | where norm = pnorm Infinity | ||
700 | dig r = round $ -logBase 10 (realToFrac r :: Double) | ||