diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-11-22 17:17:15 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-11-22 17:17:15 +0000 |
commit | e685015b98c8ca272e37376b50b3b17afe747529 (patch) | |
tree | bf9cf392488b610612bd8b195f1567615c3fe858 /lib/Numeric/LinearAlgebra/Algorithms.hs | |
parent | 01a14ad32e0fd8586498ead61a426f20b724652b (diff) |
minor changes
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 16ea32a..fd16973 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -388,7 +388,7 @@ diagonalize m = if rank v == n | |||
388 | matFunc :: Field t => (Complex Double -> Complex Double) -> Matrix t -> Matrix (Complex Double) | 388 | matFunc :: Field t => (Complex Double -> Complex Double) -> Matrix t -> Matrix (Complex Double) |
389 | matFunc f m = case diagonalize (complex m) of | 389 | matFunc f m = case diagonalize (complex m) of |
390 | Just (l,v) -> v `mXm` diag (liftVector f l) `mXm` inv v | 390 | Just (l,v) -> v `mXm` diag (liftVector f l) `mXm` inv v |
391 | Nothing -> error "Sorry, matFunc requieres a diagonalizable matrix" | 391 | Nothing -> error "Sorry, matFunc requires a diagonalizable matrix" |
392 | 392 | ||
393 | -------------------------------------------------------------- | 393 | -------------------------------------------------------------- |
394 | 394 | ||
@@ -413,13 +413,16 @@ expGolub m = iterate msq f !! j | |||
413 | where k' = k+1 | 413 | where k' = k+1 |
414 | c' = c * fromIntegral (q-k+1) / fromIntegral ((2*q-k+1)*k) | 414 | c' = c * fromIntegral (q-k+1) / fromIntegral ((2*q-k+1)*k) |
415 | x' = a <> x | 415 | x' = a <> x |
416 | n' = n `add` (c' `scale` x') | 416 | n' = n |+| (c' .* x') |
417 | d' = d `add` (((-1)^k * c') `scale` x') | 417 | d' = d |+| (((-1)^k * c') .* x') |
418 | (_,_,_,n,d) = iterate work (1,1,eye,eye,eye) !! q | 418 | (_,_,_,n,d) = iterate work (1,1,eye,eye,eye) !! q |
419 | f = linearSolve d n | 419 | f = linearSolve d n |
420 | msq m = m <> m | 420 | msq m = m <> m |
421 | |||
421 | (<>) = multiply | 422 | (<>) = multiply |
422 | v */ x = scale (recip x) v | 423 | v */ x = scale (recip x) v |
424 | (.*) = scale | ||
425 | (|+|) = add | ||
423 | 426 | ||
424 | {- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan, | 427 | {- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan, |
425 | based on a scaled Pade approximation. | 428 | based on a scaled Pade approximation. |