diff options
author | Alberto Ruiz <aruiz@um.es> | 2011-12-22 17:26:09 +0100 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2011-12-22 17:26:09 +0100 |
commit | d7b7ff9dff27a6a74785c92c9393704fe0072e0e (patch) | |
tree | eb47835d7629f68ab700eec1f8ee7399ba4c06ad /lib/Numeric/LinearAlgebra/Algorithms.hs | |
parent | 49219343d035992c2942a309a1d5594f4f96a8b1 (diff) |
ok hmatrix, hmatrix-tests, hmatrix-glpk
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 15 |
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 | {- | |
8 | Module : Numeric.LinearAlgebra.Algorithms | 9 | Module : Numeric.LinearAlgebra.Algorithms |
@@ -82,7 +83,7 @@ import Data.Packed.Matrix | |||
82 | import Numeric.LinearAlgebra.LAPACK as LAPACK | 83 | import Numeric.LinearAlgebra.LAPACK as LAPACK |
83 | import Data.List(foldl1') | 84 | import Data.List(foldl1') |
84 | import Data.Array | 85 | import Data.Array |
85 | import Numeric.ContainerBoot hiding ((.*),(*/)) | 86 | import 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 | ||
568 | geps delta = head [ k | (k,g) <- epslist, g<delta] | 569 | geps delta = head [ k | (k,g) <- epslist, g<delta] |
569 | 570 | ||
570 | expGolub 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 | -} | ||
574 | expm :: Field t => Matrix t -> Matrix t | ||
575 | expm 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 | -} | ||
593 | expm :: Field t => Matrix t -> Matrix t | ||
594 | expm = 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. |