summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-09-28 11:58:12 +0200
committerAlberto Ruiz <aruiz@um.es>2014-09-28 11:58:12 +0200
commit2ca163be0d77b6e2e9a53df6c990b1cd5661f6f5 (patch)
tree862122d7f06b5e6fd48f395076b6d91cdda0c675 /packages
parent2045b16e6a044d50135f09342962f936f7d62724 (diff)
haddock example of matFunc sqrt
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Algorithms.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
index 25700bc..02ac6a0 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
@@ -809,7 +809,7 @@ expGolub m = iterate msq f !! j
809-------------------------------------------------------------- 809--------------------------------------------------------------
810 810
811{- | Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia. 811{- | Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia.
812It only works with invertible matrices that have a real solution. For diagonalizable matrices you can try @matFunc sqrt@. 812It only works with invertible matrices that have a real solution.
813 813
814@m = (2><2) [4,9 814@m = (2><2) [4,9
815 ,0,4] :: Matrix Double@ 815 ,0,4] :: Matrix Double@
@@ -819,6 +819,13 @@ It only works with invertible matrices that have a real solution. For diagonaliz
819 [ 2.0, 2.25 819 [ 2.0, 2.25
820 , 0.0, 2.0 ] 820 , 0.0, 2.0 ]
821 821
822For diagonalizable matrices you can try 'matFunc' @sqrt@:
823
824>>> matFunc sqrt ((2><2) [1,0,0,-1])
825(2><2)
826 [ 1.0 :+ 0.0, 0.0 :+ 0.0
827 , 0.0 :+ 0.0, 0.0 :+ 1.0 ]
828
822-} 829-}
823sqrtm :: Field t => Matrix t -> Matrix t 830sqrtm :: Field t => Matrix t -> Matrix t
824sqrtm = sqrtmInv 831sqrtm = sqrtmInv