diff options
Diffstat (limited to 'packages/base/src')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Algorithms.hs | 9 |
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. |
812 | It only works with invertible matrices that have a real solution. For diagonalizable matrices you can try @matFunc sqrt@. | 812 | It 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 | ||
822 | For 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 | -} |
823 | sqrtm :: Field t => Matrix t -> Matrix t | 830 | sqrtm :: Field t => Matrix t -> Matrix t |
824 | sqrtm = sqrtmInv | 831 | sqrtm = sqrtmInv |