diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index a6b4dae..e2ecd4d 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,6 +568,13 @@ 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 | ||
571 | |||
572 | {- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan, | ||
573 | based on a scaled Pade approximation. | ||
574 | -} | ||
575 | expm :: Field t => Matrix t -> Matrix t | ||
576 | expm = expGolub | ||
577 | |||
570 | expGolub :: ( Fractional t, Element t, Field t | 578 | expGolub :: ( Fractional t, Element t, Field t |
571 | , Normed Matrix t | 579 | , Normed Matrix t |
572 | , RealFrac (RealOf t) | 580 | , RealFrac (RealOf t) |
@@ -592,12 +600,6 @@ expGolub m = iterate msq f !! j | |||
592 | (.*) = scale | 600 | (.*) = scale |
593 | (|+|) = add | 601 | (|+|) = add |
594 | 602 | ||
595 | {- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan, | ||
596 | based on a scaled Pade approximation. | ||
597 | -} | ||
598 | expm :: Field t => Matrix t -> Matrix t | ||
599 | expm = expGolub | ||
600 | |||
601 | -------------------------------------------------------------- | 603 | -------------------------------------------------------------- |
602 | 604 | ||
603 | {- | Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia. | 605 | {- | Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia. |