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.hs22
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
85import Data.List(foldl1') 85import Data.List(foldl1')
86import Data.Array 86import 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.
90class (Normed (Matrix t), Linear Vector t, Linear Matrix t) => Field t where 89class (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
397eps :: Double 396eps :: Double
398eps = 2.22044604925031e-16 397eps = 2.22044604925031e-16
399 398
399peps :: RealFloat x => x -> x
400peps 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@
401i :: Complex Double 404i :: Complex Double
402i = 0:+1 405i = 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
475instance Normed (Vector Float) where
476 pnorm t = pnorm t . double
477
478instance Normed (Vector (Complex Float)) where
479 pnorm t = pnorm t . double
480
481instance Normed (Matrix Float) where
482 pnorm t = pnorm t . double
483
484instance 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.
472nullspaceSVD :: Field t 490nullspaceSVD :: Field t