summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Algorithms.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Algorithms.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs
index bea33ea..9806d6f 100644
--- a/lib/Numeric/LinearAlgebra/Algorithms.hs
+++ b/lib/Numeric/LinearAlgebra/Algorithms.hs
@@ -3,6 +3,7 @@
3{-# LANGUAGE MultiParamTypeClasses #-} 3{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE UndecidableInstances #-} 4{-# LANGUAGE UndecidableInstances #-}
5{-# LANGUAGE TypeFamilies #-} 5{-# LANGUAGE TypeFamilies #-}
6
6----------------------------------------------------------------------------- 7-----------------------------------------------------------------------------
7{- | 8{- |
8Module : Numeric.LinearAlgebra.Algorithms 9Module : Numeric.LinearAlgebra.Algorithms
@@ -82,7 +83,7 @@ import Data.Packed.Matrix
82import Numeric.LinearAlgebra.LAPACK as LAPACK 83import Numeric.LinearAlgebra.LAPACK as LAPACK
83import Data.List(foldl1') 84import Data.List(foldl1')
84import Data.Array 85import Data.Array
85import Numeric.ContainerBoot hiding ((.*),(*/)) 86import Numeric.ContainerBoot
86 87
87 88
88{- | Class used to define generic linear algebra computations for both real and complex matrices. Only double precision is supported in this version (we can 89{- | Class used to define generic linear algebra computations for both real and complex matrices. Only double precision is supported in this version (we can
@@ -567,7 +568,11 @@ epslist = [ (fromIntegral k, golubeps k k) | k <- [1..]]
567 568
568geps delta = head [ k | (k,g) <- epslist, g<delta] 569geps delta = head [ k | (k,g) <- epslist, g<delta]
569 570
570expGolub m = iterate msq f !! j 571{- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan,
572 based on a scaled Pade approximation.
573-}
574expm :: Field t => Matrix t -> Matrix t
575expm m = iterate msq f !! j
571 where j = max 0 $ floor $ logBase 2 $ pnorm Infinity m 576 where j = max 0 $ floor $ logBase 2 $ pnorm Infinity m
572 a = m */ fromIntegral ((2::Int)^j) 577 a = m */ fromIntegral ((2::Int)^j)
573 q = geps eps -- 7 steps 578 q = geps eps -- 7 steps
@@ -587,12 +592,6 @@ expGolub m = iterate msq f !! j
587 (.*) = scale 592 (.*) = scale
588 (|+|) = add 593 (|+|) = add
589 594
590{- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan,
591 based on a scaled Pade approximation.
592-}
593expm :: Field t => Matrix t -> Matrix t
594expm = expGolub
595
596-------------------------------------------------------------- 595--------------------------------------------------------------
597 596
598{- | Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia. 597{- | Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia.