diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Algorithms.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 1109296..f4b7ee9 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -1,4 +1,4 @@ | |||
1 | {-# OPTIONS_GHC -XFlexibleContexts -XFlexibleInstances #-} | 1 | {-# LANGUAGE FlexibleContexts, FlexibleInstances #-} |
2 | {-# LANGUAGE CPP #-} | 2 | {-# LANGUAGE CPP #-} |
3 | ----------------------------------------------------------------------------- | 3 | ----------------------------------------------------------------------------- |
4 | {- | | 4 | {- | |
@@ -85,7 +85,6 @@ import Numeric.LinearAlgebra.Linear | |||
85 | import Data.List(foldl1') | 85 | import Data.List(foldl1') |
86 | import Data.Array | 86 | import Data.Array |
87 | 87 | ||
88 | |||
89 | -- | Auxiliary typeclass used to define generic computations for both real and complex matrices. | 88 | -- | Auxiliary typeclass used to define generic computations for both real and complex matrices. |
90 | class (Normed (Matrix t), Linear Vector t, Linear Matrix t) => Field t where | 89 | class (Normed (Matrix t), Linear Vector t, Linear Matrix t) => Field t where |
91 | svd' :: Matrix t -> (Matrix t, Vector Double, Matrix t) | 90 | svd' :: Matrix t -> (Matrix t, Vector Double, Matrix t) |
@@ -397,6 +396,10 @@ ranksv teps maxdim s = k where | |||
397 | eps :: Double | 396 | eps :: Double |
398 | eps = 2.22044604925031e-16 | 397 | eps = 2.22044604925031e-16 |
399 | 398 | ||
399 | peps :: RealFloat x => x -> x | ||
400 | peps x = 2.0**(fromIntegral $ 1-floatDigits x) | ||
401 | |||
402 | |||
400 | -- | The imaginary unit: @i = 0.0 :+ 1.0@ | 403 | -- | The imaginary unit: @i = 0.0 :+ 1.0@ |
401 | i :: Complex Double | 404 | i :: Complex Double |
402 | i = 0:+1 | 405 | i = 0:+1 |
@@ -467,6 +470,21 @@ instance Normed (Matrix (Complex Double)) where | |||
467 | pnorm = pnormCM | 470 | pnorm = pnormCM |
468 | 471 | ||
469 | ----------------------------------------------------------------------- | 472 | ----------------------------------------------------------------------- |
473 | -- to be optimized | ||
474 | |||
475 | instance Normed (Vector Float) where | ||
476 | pnorm t = pnorm t . double | ||
477 | |||
478 | instance Normed (Vector (Complex Float)) where | ||
479 | pnorm t = pnorm t . double | ||
480 | |||
481 | instance Normed (Matrix Float) where | ||
482 | pnorm t = pnorm t . double | ||
483 | |||
484 | instance Normed (Matrix (Complex Float)) where | ||
485 | pnorm t = pnorm t . double | ||
486 | |||
487 | ----------------------------------------------------------------------- | ||
470 | 488 | ||
471 | -- | The nullspace of a matrix from its SVD decomposition. | 489 | -- | The nullspace of a matrix from its SVD decomposition. |
472 | nullspaceSVD :: Field t | 490 | nullspaceSVD :: Field t |