summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Algorithms.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-09-23 12:41:35 +0000
committerAlberto Ruiz <aruiz@um.es>2010-09-23 12:41:35 +0000
commitf50304b47f99ce0280d7ab7daf28ffe6b0d0b853 (patch)
tree020b9b66e4bc93e0928a7b3077a38db9fa7be189 /lib/Numeric/LinearAlgebra/Algorithms.hs
parent3cfce69bf3cb7d7f7976abb454b64f6fa3a32c97 (diff)
ContainerBoot
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Algorithms.hs15
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)
13Stability : provisional 13Stability : provisional
14Portability : uses ffi 14Portability : uses ffi
15 15
16Generic interface for the most common functions. Using it we can write higher level algorithms and testing properties for both real and complex matrices. 16High level generic interface to common matrix computations.
17 17
18Specific functions for particular base types can also be explicitly 18Specific functions for particular base types can also be explicitly
19imported from "Numeric.LinearAlgebra.LAPACK". 19imported 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
79import Numeric.LinearAlgebra.LAPACK as LAPACK 80import Numeric.LinearAlgebra.LAPACK as LAPACK
80import Data.List(foldl1') 81import Data.List(foldl1')
81import Data.Array 82import Data.Array
82import Numeric.Container hiding ((.*),(*/)) 83import Numeric.ContainerBoot hiding ((.*),(*/))
83import 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
86transform single precision objects using 'single' and 'double'). 87transform 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.
697relativeError :: (Normed c t, Container c t) => c t -> c t -> Int
698relativeError x y = dig (norm (x `sub` y) / norm x)
699 where norm = pnorm Infinity
700 dig r = round $ -logBase 10 (realToFrac r :: Double)