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.hs9
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
388matFunc :: Field t => (Complex Double -> Complex Double) -> Matrix t -> Matrix (Complex Double) 388matFunc :: Field t => (Complex Double -> Complex Double) -> Matrix t -> Matrix (Complex Double)
389matFunc f m = case diagonalize (complex m) of 389matFunc 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.