qchas-1.1.0.1: A library for implementing Quantum Algorithms

QC

Description

• Module : QC
• Description : Quantum Computing
• Copyright : (c) Mihai Sebastian Ardelean, 2018
• Maintainer : ardeleanasm@gmail.com
• Portability : POSIX

This module is used to import needed modules for Quantum Computing.

Synopsis

# Documentation

phase :: RealFloat a => Complex a -> a #

The phase of a complex number, in the range (-pi, pi]. If the magnitude is zero, then so is the phase.

magnitude :: RealFloat a => Complex a -> a #

The nonnegative magnitude of a complex number.

polar :: RealFloat a => Complex a -> (a, a) #

The function polar takes a complex number and returns a (magnitude, phase) pair in canonical form: the magnitude is nonnegative, and the phase in the range (-pi, pi]; if the magnitude is zero, then so is the phase.

cis :: Floating a => a -> Complex a #

cis t is a complex value with magnitude 1 and phase t (modulo 2*pi).

mkPolar :: Floating a => a -> a -> Complex a #

Form a complex number from polar components of magnitude and phase.

conjugate :: Num a => Complex a -> Complex a #

The conjugate of a complex number.

imagPart :: Complex a -> a #

Extracts the imaginary part of a complex number.

realPart :: Complex a -> a #

Extracts the real part of a complex number.

data Complex a #

Complex numbers are an algebraic type.

For a complex number z, abs z is a number with the magnitude of z, but oriented in the positive real direction, whereas signum z has the phase of z, but unit magnitude.

The Foldable and Traversable instances traverse the real part first.

Constructors

 !a :+ !a infix 6 forms a complex number from its real and imaginary rectangular components.
Instances
 Since: base-4.9.0.0 Instance detailsDefined in Data.Complex Methods(>>=) :: Complex a -> (a -> Complex b) -> Complex b #(>>) :: Complex a -> Complex b -> Complex b #return :: a -> Complex a #fail :: String -> Complex a # Instance detailsDefined in Data.Complex Methodsfmap :: (a -> b) -> Complex a -> Complex b #(<) :: a -> Complex b -> Complex a # Since: base-4.9.0.0 Instance detailsDefined in Data.Complex Methodspure :: a -> Complex a #(<*>) :: Complex (a -> b) -> Complex a -> Complex b #liftA2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c #(*>) :: Complex a -> Complex b -> Complex b #(<*) :: Complex a -> Complex b -> Complex a # Instance detailsDefined in Data.Complex Methodsfold :: Monoid m => Complex m -> m #foldMap :: Monoid m => (a -> m) -> Complex a -> m #foldr :: (a -> b -> b) -> b -> Complex a -> b #foldr' :: (a -> b -> b) -> b -> Complex a -> b #foldl :: (b -> a -> b) -> b -> Complex a -> b #foldl' :: (b -> a -> b) -> b -> Complex a -> b #foldr1 :: (a -> a -> a) -> Complex a -> a #foldl1 :: (a -> a -> a) -> Complex a -> a #toList :: Complex a -> [a] #null :: Complex a -> Bool #length :: Complex a -> Int #elem :: Eq a => a -> Complex a -> Bool #maximum :: Ord a => Complex a -> a #minimum :: Ord a => Complex a -> a #sum :: Num a => Complex a -> a #product :: Num a => Complex a -> a # Instance detailsDefined in Data.Complex Methodstraverse :: Applicative f => (a -> f b) -> Complex a -> f (Complex b) #sequenceA :: Applicative f => Complex (f a) -> f (Complex a) #mapM :: Monad m => (a -> m b) -> Complex a -> m (Complex b) #sequence :: Monad m => Complex (m a) -> m (Complex a) # CTrans C Instance detailsDefined in Internal.Numeric Methods Normed Matrix (Complex Double) Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Matrix (Complex Double) -> RealOf (Complex Double) Normed Matrix (Complex Float) Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Matrix (Complex Float) -> RealOf (Complex Float) Normed Vector (Complex Double) Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Vector (Complex Double) -> RealOf (Complex Double) Normed Vector (Complex Float) Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Vector (Complex Float) -> RealOf (Complex Float) Instance detailsDefined in Internal.Numeric Methodsequal :: Vector (Complex Double) -> Vector (Complex Double) -> Boolcmap' :: Element b => (Complex Double -> b) -> Vector (Complex Double) -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector (Complex Double) -> Vector (Complex Double)find' :: (Complex Double -> Bool) -> Vector (Complex Double) -> [IndexOf Vector]accum' :: Vector (Complex Double) -> (Complex Double -> Complex Double -> Complex Double) -> [(IndexOf Vector, Complex Double)] -> Vector (Complex Double) Instance detailsDefined in Internal.Numeric Methodsequal :: Vector (Complex Float) -> Vector (Complex Float) -> Boolcmap' :: Element b => (Complex Float -> b) -> Vector (Complex Float) -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector (Complex Float) -> Vector (Complex Float)find' :: (Complex Float -> Bool) -> Vector (Complex Float) -> [IndexOf Vector]accum' :: Vector (Complex Float) -> (Complex Float -> Complex Float -> Complex Float) -> [(IndexOf Vector, Complex Float)] -> Vector (Complex Float) Eq a => Eq (Complex a) Instance detailsDefined in Data.Complex Methods(==) :: Complex a -> Complex a -> Bool #(/=) :: Complex a -> Complex a -> Bool # RealFloat a => Floating (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methodspi :: Complex a #exp :: Complex a -> Complex a #log :: Complex a -> Complex a #sqrt :: Complex a -> Complex a #(**) :: Complex a -> Complex a -> Complex a #logBase :: Complex a -> Complex a -> Complex a #sin :: Complex a -> Complex a #cos :: Complex a -> Complex a #tan :: Complex a -> Complex a #asin :: Complex a -> Complex a #acos :: Complex a -> Complex a #atan :: Complex a -> Complex a #sinh :: Complex a -> Complex a #cosh :: Complex a -> Complex a #tanh :: Complex a -> Complex a #asinh :: Complex a -> Complex a #acosh :: Complex a -> Complex a #atanh :: Complex a -> Complex a #log1p :: Complex a -> Complex a #expm1 :: Complex a -> Complex a #log1pexp :: Complex a -> Complex a #log1mexp :: Complex a -> Complex a # RealFloat a => Fractional (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methods(/) :: Complex a -> Complex a -> Complex a #recip :: Complex a -> Complex a # Data a => Data (Complex a) Instance detailsDefined in Data.Complex Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Complex a -> c (Complex a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Complex a) #toConstr :: Complex a -> Constr #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Complex a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Complex a)) #gmapT :: (forall b. Data b => b -> b) -> Complex a -> Complex a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Complex a -> r #gmapQ :: (forall d. Data d => d -> u) -> Complex a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Complex a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Complex a -> m (Complex a) # RealFloat a => Num (Complex a) Since: base-2.1 Instance detailsDefined in Data.Complex Methods(+) :: Complex a -> Complex a -> Complex a #(-) :: Complex a -> Complex a -> Complex a #(*) :: Complex a -> Complex a -> Complex a #negate :: Complex a -> Complex a #abs :: Complex a -> Complex a #signum :: Complex a -> Complex a # Read a => Read (Complex a) Instance detailsDefined in Data.Complex MethodsreadsPrec :: Int -> ReadS (Complex a) # Show a => Show (Complex a) Instance detailsDefined in Data.Complex MethodsshowsPrec :: Int -> Complex a -> ShowS #show :: Complex a -> String #showList :: [Complex a] -> ShowS # Instance detailsDefined in Data.Complex Associated Typestype Rep (Complex a) :: * -> * # Methodsfrom :: Complex a -> Rep (Complex a) x #to :: Rep (Complex a) x -> Complex a # Storable a => Storable (Complex a) Since: base-4.8.0.0 Instance detailsDefined in Data.Complex MethodssizeOf :: Complex a -> Int #alignment :: Complex a -> Int #peekElemOff :: Ptr (Complex a) -> Int -> IO (Complex a) #pokeElemOff :: Ptr (Complex a) -> Int -> Complex a -> IO () #peekByteOff :: Ptr b -> Int -> IO (Complex a) #pokeByteOff :: Ptr b -> Int -> Complex a -> IO () #peek :: Ptr (Complex a) -> IO (Complex a) #poke :: Ptr (Complex a) -> Complex a -> IO () # CTrans (Complex Float) Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Util Methodsnorm_0 :: Matrix C -> R #norm_1 :: Matrix C -> R #norm_2 :: Matrix C -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector (Complex Float) -> R #norm_1 :: Vector (Complex Float) -> R #norm_2 :: Vector (Complex Float) -> R #norm_Inf :: Vector (Complex Float) -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector C -> R #norm_1 :: Vector C -> R #norm_2 :: Vector C -> R # Instance detailsDefined in Internal.Algorithms MethodsluPacked' :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int])luSolve' :: (Matrix (Complex Double), [Int]) -> Matrix (Complex Double) -> Matrix (Complex Double)ldlPacked' :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int])ldlSolve' :: (Matrix (Complex Double), [Int]) -> Matrix (Complex Double) -> Matrix (Complex Double)qr' :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double))qrgr' :: Int -> (Matrix (Complex Double), Vector (Complex Double)) -> Matrix (Complex Double) Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methodsreal :: Complexable c => c (RealOf (Complex Double)) -> c (Complex Double) #complex :: Complexable c => c (Complex Double) -> c (ComplexOf (Complex Double)) #single :: Complexable c => c (Complex Double) -> c (SingleOf (Complex Double)) #double :: Complexable c => c (Complex Double) -> c (DoubleOf (Complex Double)) #toComplex :: (Complexable c, RealElement (Complex Double)) => (c (Complex Double), c (Complex Double)) -> c (Complex (Complex Double)) #fromComplex :: (Complexable c, RealElement (Complex Double)) => c (Complex (Complex Double)) -> (c (Complex Double), c (Complex Double)) # Instance detailsDefined in Internal.Numeric Methodsreal :: Complexable c => c (RealOf (Complex Float)) -> c (Complex Float) #complex :: Complexable c => c (Complex Float) -> c (ComplexOf (Complex Float)) #single :: Complexable c => c (Complex Float) -> c (SingleOf (Complex Float)) #double :: Complexable c => c (Complex Float) -> c (DoubleOf (Complex Float)) #toComplex :: (Complexable c, RealElement (Complex Float)) => (c (Complex Float), c (Complex Float)) -> c (Complex (Complex Float)) #fromComplex :: (Complexable c, RealElement (Complex Float)) => c (Complex (Complex Float)) -> (c (Complex Float), c (Complex Float)) # Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix (Complex Double) -> Matrix (Complex Double) -> IO ()rowOp :: Int -> Complex Double -> Int -> Int -> Int -> Int -> Matrix (Complex Double) -> IO ()gemm :: Vector (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -> IO () Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix (Complex Float) -> Matrix (Complex Float) -> IO ()rowOp :: Int -> Complex Float -> Int -> Int -> Int -> Int -> Matrix (Complex Float) -> IO ()gemm :: Vector (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) -> IO () Instance detailsDefined in Data.Complex Associated Typestype Rep1 Complex :: k -> * # Methodsfrom1 :: Complex a -> Rep1 Complex a #to1 :: Rep1 Complex a -> Complex a # Precision (Complex Float) (Complex Double) Instance detailsDefined in Internal.Conversion Methods Instance detailsDefined in Internal.Util Methods Instance detailsDefined in Internal.Util Methods type Rep (Complex a) Instance detailsDefined in Data.Complex type Rep (Complex a) = D1 (MetaData "Complex" "Data.Complex" "base" False) (C1 (MetaCons ":+" (InfixI NotAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a))) type RealOf (Complex Double) Instance detailsDefined in Internal.Numeric type RealOf (Complex Double) = Double type RealOf (Complex Float) Instance detailsDefined in Internal.Numeric type RealOf (Complex Float) = Float type SingleOf (Complex a) Instance detailsDefined in Internal.Numeric type SingleOf (Complex a) = Complex (SingleOf a) type DoubleOf (Complex a) Instance detailsDefined in Internal.Numeric type DoubleOf (Complex a) = Complex (DoubleOf a) type Rep1 Complex Instance detailsDefined in Data.Complex type Rep1 Complex = D1 (MetaData "Complex" "Data.Complex" "base" False) (C1 (MetaCons ":+" (InfixI NotAssociative 6) False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1 :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1)) orth :: Field t => Matrix t -> Matrix t # return an orthonormal basis of the range space of a matrix. See also orthSVD. nullspace :: Field t => Matrix t -> Matrix t # return an orthonormal basis of the null space of a matrix. See also nullspaceSVD. linearSolve :: Field t => Matrix t -> Matrix t -> Maybe (Matrix t) # Solve a linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, returning Nothing for a singular system. For underconstrained or overconstrained systems use linearSolveLS or linearSolveSVD. a = (2><2) [ 1.0, 2.0 , 3.0, 5.0 ]  b = (2><3) [ 6.0, 1.0, 10.0 , 15.0, 3.0, 26.0 ]  >>> linearSolve a b Just (2><3) [ -1.4802973661668753e-15, 0.9999999999999997, 1.999999999999997 , 3.000000000000001, 1.6653345369377348e-16, 4.000000000000002 ]  >>> let Just x = it >>> disp 5 x 2x3 -0.00000 1.00000 2.00000 3.00000 0.00000 4.00000  >>> a <> x (2><3) [ 6.0, 1.0, 10.0 , 15.0, 3.0, 26.0 ]  (<>) :: Numeric t => Matrix t -> Matrix t -> Matrix t infixr 8 # dense matrix product >>> let a = (3><5) [1..] >>> a (3><5) [ 1.0, 2.0, 3.0, 4.0, 5.0 , 6.0, 7.0, 8.0, 9.0, 10.0 , 11.0, 12.0, 13.0, 14.0, 15.0 ]  >>> let b = (5><2) [1,3, 0,2, -1,5, 7,7, 6,0] >>> b (5><2) [ 1.0, 3.0 , 0.0, 2.0 , -1.0, 5.0 , 7.0, 7.0 , 6.0, 0.0 ]  >>> a <> b (3><2) [ 56.0, 50.0 , 121.0, 135.0 , 186.0, 220.0 ]  Arguments  :: Bool symmetric -> R relative tolerance for the residual (e.g. 1E-4) -> R relative tolerance for δx (e.g. 1E-3) -> Int maximum number of iterations -> GMatrix coefficient matrix -> Vector R initial solution -> Vector R right-hand side -> [CGState] solution Solve a sparse linear system using the conjugate gradient method with default parameters. Arguments  :: Bool is symmetric -> GMatrix coefficient matrix -> Vector R right-hand side -> Vector R solution Solve a sparse linear system using the conjugate gradient method with default parameters. data CGState # Constructors  CGState Fieldscgp :: Vector Rconjugate gradientcgr :: Vector Rresidualcgr2 :: Rsquared norm of residualcgx :: Vector Rcurrent solutioncgdx :: Rnormalized size of correction data Mod (n :: Nat) t # Wrapper with a phantom integer for statically checked modular arithmetic. Instances  KnownNat m => Container Vector (Mod m I) Instance detailsDefined in Internal.Modular Methodsconj' :: Vector (Mod m I) -> Vector (Mod m I)size' :: Vector (Mod m I) -> IndexOf Vectorscalar' :: Mod m I -> Vector (Mod m I)scale' :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)addConstant :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)add' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)sub :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)mul :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)equal :: Vector (Mod m I) -> Vector (Mod m I) -> Boolcmap' :: Element b => (Mod m I -> b) -> Vector (Mod m I) -> Vector bkonst' :: Mod m I -> IndexOf Vector -> Vector (Mod m I)build' :: IndexOf Vector -> ArgOf Vector (Mod m I) -> Vector (Mod m I)atIndex' :: Vector (Mod m I) -> IndexOf Vector -> Mod m IminIndex' :: Vector (Mod m I) -> IndexOf VectormaxIndex' :: Vector (Mod m I) -> IndexOf VectorminElement' :: Vector (Mod m I) -> Mod m ImaxElement' :: Vector (Mod m I) -> Mod m IsumElements' :: Vector (Mod m I) -> Mod m IprodElements' :: Vector (Mod m I) -> Mod m Istep' :: Vector (Mod m I) -> Vector (Mod m I)ccompare' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector Icselect' :: Vector I -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)find' :: (Mod m I -> Bool) -> Vector (Mod m I) -> [IndexOf Vector]assoc' :: IndexOf Vector -> Mod m I -> [(IndexOf Vector, Mod m I)] -> Vector (Mod m I)accum' :: Vector (Mod m I) -> (Mod m I -> Mod m I -> Mod m I) -> [(IndexOf Vector, Mod m I)] -> Vector (Mod m I)scaleRecip :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)divide :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)arctan2' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)cmod' :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)fromInt' :: Vector I -> Vector (Mod m I)toInt' :: Vector (Mod m I) -> Vector IfromZ' :: Vector Z -> Vector (Mod m I)toZ' :: Vector (Mod m I) -> Vector Z KnownNat m => Container Vector (Mod m Z) Instance detailsDefined in Internal.Modular Methodsconj' :: Vector (Mod m Z) -> Vector (Mod m Z)size' :: Vector (Mod m Z) -> IndexOf Vectorscalar' :: Mod m Z -> Vector (Mod m Z)scale' :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)addConstant :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)add' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)sub :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)mul :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)equal :: Vector (Mod m Z) -> Vector (Mod m Z) -> Boolcmap' :: Element b => (Mod m Z -> b) -> Vector (Mod m Z) -> Vector bkonst' :: Mod m Z -> IndexOf Vector -> Vector (Mod m Z)build' :: IndexOf Vector -> ArgOf Vector (Mod m Z) -> Vector (Mod m Z)atIndex' :: Vector (Mod m Z) -> IndexOf Vector -> Mod m ZminIndex' :: Vector (Mod m Z) -> IndexOf VectormaxIndex' :: Vector (Mod m Z) -> IndexOf VectorminElement' :: Vector (Mod m Z) -> Mod m ZmaxElement' :: Vector (Mod m Z) -> Mod m ZsumElements' :: Vector (Mod m Z) -> Mod m ZprodElements' :: Vector (Mod m Z) -> Mod m Zstep' :: Vector (Mod m Z) -> Vector (Mod m Z)ccompare' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector Icselect' :: Vector I -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)find' :: (Mod m Z -> Bool) -> Vector (Mod m Z) -> [IndexOf Vector]assoc' :: IndexOf Vector -> Mod m Z -> [(IndexOf Vector, Mod m Z)] -> Vector (Mod m Z)accum' :: Vector (Mod m Z) -> (Mod m Z -> Mod m Z -> Mod m Z) -> [(IndexOf Vector, Mod m Z)] -> Vector (Mod m Z)scaleRecip :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)divide :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)arctan2' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)cmod' :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)fromInt' :: Vector I -> Vector (Mod m Z)toInt' :: Vector (Mod m Z) -> Vector IfromZ' :: Vector Z -> Vector (Mod m Z)toZ' :: Vector (Mod m Z) -> Vector Z KnownNat m => Num (Vector (Mod m I)) Instance detailsDefined in Internal.Modular Methods(+) :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) #(-) :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) #(*) :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) #negate :: Vector (Mod m I) -> Vector (Mod m I) #abs :: Vector (Mod m I) -> Vector (Mod m I) #signum :: Vector (Mod m I) -> Vector (Mod m I) # KnownNat m => Num (Vector (Mod m Z)) Instance detailsDefined in Internal.Modular Methods(+) :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) #(-) :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) #(*) :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) #negate :: Vector (Mod m Z) -> Vector (Mod m Z) #abs :: Vector (Mod m Z) -> Vector (Mod m Z) #signum :: Vector (Mod m Z) -> Vector (Mod m Z) # KnownNat m => Normed (Vector (Mod m I)) Instance detailsDefined in Internal.Modular Methodsnorm_0 :: Vector (Mod m I) -> R #norm_1 :: Vector (Mod m I) -> R #norm_2 :: Vector (Mod m I) -> R #norm_Inf :: Vector (Mod m I) -> R # KnownNat m => Normed (Vector (Mod m Z)) Instance detailsDefined in Internal.Modular Methodsnorm_0 :: Vector (Mod m Z) -> R #norm_1 :: Vector (Mod m Z) -> R #norm_2 :: Vector (Mod m Z) -> R #norm_Inf :: Vector (Mod m Z) -> R # KnownNat m => Testable (Matrix (Mod m I)) Instance detailsDefined in Internal.Modular MethodscheckT :: Matrix (Mod m I) -> (Bool, IO ()) #ioCheckT :: Matrix (Mod m I) -> IO (Bool, IO ()) # (Storable t, Indexable (Vector t) t) => Indexable (Vector (Mod m t)) (Mod m t) Instance detailsDefined in Internal.Modular Methods(!) :: Vector (Mod m t) -> Int -> Mod m t # (Integral t, Enum t, KnownNat m) => Enum (Mod m t) Instance detailsDefined in Internal.Modular Methodssucc :: Mod m t -> Mod m t #pred :: Mod m t -> Mod m t #toEnum :: Int -> Mod m t #fromEnum :: Mod m t -> Int #enumFrom :: Mod m t -> [Mod m t] #enumFromThen :: Mod m t -> Mod m t -> [Mod m t] #enumFromTo :: Mod m t -> Mod m t -> [Mod m t] #enumFromThenTo :: Mod m t -> Mod m t -> Mod m t -> [Mod m t] # (Eq t, KnownNat m) => Eq (Mod m t) Instance detailsDefined in Internal.Modular Methods(==) :: Mod m t -> Mod m t -> Bool #(/=) :: Mod m t -> Mod m t -> Bool # (Show (Mod m t), Num (Mod m t), Eq t, KnownNat m) => Fractional (Mod m t) this instance is only valid for prime m Instance detailsDefined in Internal.Modular Methods(/) :: Mod m t -> Mod m t -> Mod m t #recip :: Mod m t -> Mod m t #fromRational :: Rational -> Mod m t # (Integral t, KnownNat m, Num (Mod m t)) => Integral (Mod m t) Instance detailsDefined in Internal.Modular Methodsquot :: Mod m t -> Mod m t -> Mod m t #rem :: Mod m t -> Mod m t -> Mod m t #div :: Mod m t -> Mod m t -> Mod m t #mod :: Mod m t -> Mod m t -> Mod m t #quotRem :: Mod m t -> Mod m t -> (Mod m t, Mod m t) #divMod :: Mod m t -> Mod m t -> (Mod m t, Mod m t) #toInteger :: Mod m t -> Integer # (Integral t, KnownNat n) => Num (Mod n t) Instance detailsDefined in Internal.Modular Methods(+) :: Mod n t -> Mod n t -> Mod n t #(-) :: Mod n t -> Mod n t -> Mod n t #(*) :: Mod n t -> Mod n t -> Mod n t #negate :: Mod n t -> Mod n t #abs :: Mod n t -> Mod n t #signum :: Mod n t -> Mod n t #fromInteger :: Integer -> Mod n t # (Ord t, KnownNat m) => Ord (Mod m t) Instance detailsDefined in Internal.Modular Methodscompare :: Mod m t -> Mod m t -> Ordering #(<) :: Mod m t -> Mod m t -> Bool #(<=) :: Mod m t -> Mod m t -> Bool #(>) :: Mod m t -> Mod m t -> Bool #(>=) :: Mod m t -> Mod m t -> Bool #max :: Mod m t -> Mod m t -> Mod m t #min :: Mod m t -> Mod m t -> Mod m t # (Integral t, Real t, KnownNat m, Integral (Mod m t)) => Real (Mod m t) Instance detailsDefined in Internal.Modular MethodstoRational :: Mod m t -> Rational # Show t => Show (Mod n t) Instance detailsDefined in Internal.Modular MethodsshowsPrec :: Int -> Mod n t -> ShowS #show :: Mod n t -> String #showList :: [Mod n t] -> ShowS # Storable t => Storable (Mod n t) Instance detailsDefined in Internal.Modular MethodssizeOf :: Mod n t -> Int #alignment :: Mod n t -> Int #peekElemOff :: Ptr (Mod n t) -> Int -> IO (Mod n t) #pokeElemOff :: Ptr (Mod n t) -> Int -> Mod n t -> IO () #peekByteOff :: Ptr b -> Int -> IO (Mod n t) #pokeByteOff :: Ptr b -> Int -> Mod n t -> IO () #peek :: Ptr (Mod n t) -> IO (Mod n t) #poke :: Ptr (Mod n t) -> Mod n t -> IO () # NFData t => NFData (Mod n t) Instance detailsDefined in Internal.Modular Methodsrnf :: Mod n t -> () # KnownNat m => CTrans (Mod m I) Instance detailsDefined in Internal.Modular Methodsctrans :: Matrix (Mod m I) -> Matrix (Mod m I) KnownNat m => CTrans (Mod m Z) Instance detailsDefined in Internal.Modular Methodsctrans :: Matrix (Mod m Z) -> Matrix (Mod m Z) KnownNat m => Numeric (Mod m I) Instance detailsDefined in Internal.Modular KnownNat m => Numeric (Mod m Z) Instance detailsDefined in Internal.Modular KnownNat m => Product (Mod m I) Instance detailsDefined in Internal.Modular Methodsmultiply :: Matrix (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I)absSum :: Vector (Mod m I) -> RealOf (Mod m I)norm1 :: Vector (Mod m I) -> RealOf (Mod m I)norm2 :: Vector (Mod m I) -> RealOf (Mod m I)normInf :: Vector (Mod m I) -> RealOf (Mod m I) KnownNat m => Product (Mod m Z) Instance detailsDefined in Internal.Modular Methodsmultiply :: Matrix (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z)absSum :: Vector (Mod m Z) -> RealOf (Mod m Z)norm1 :: Vector (Mod m Z) -> RealOf (Mod m Z)norm2 :: Vector (Mod m Z) -> RealOf (Mod m Z)normInf :: Vector (Mod m Z) -> RealOf (Mod m Z) KnownNat m => Element (Mod m I) Instance detailsDefined in Internal.Modular MethodsconstantD :: Mod m I -> Int -> Vector (Mod m I)extractR :: MatrixOrder -> Matrix (Mod m I) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Mod m I))setRect :: Int -> Int -> Matrix (Mod m I) -> Matrix (Mod m I) -> IO ()sortI :: Vector (Mod m I) -> Vector CIntsortV :: Vector (Mod m I) -> Vector (Mod m I)compareV :: Vector (Mod m I) -> Vector (Mod m I) -> Vector CIntselectV :: Vector CInt -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)remapM :: Matrix CInt -> Matrix CInt -> Matrix (Mod m I) -> Matrix (Mod m I)rowOp :: Int -> Mod m I -> Int -> Int -> Int -> Int -> Matrix (Mod m I) -> IO ()gemm :: Vector (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) -> IO ()reorderV :: Vector CInt -> Vector CInt -> Vector (Mod m I) -> Vector (Mod m I) KnownNat m => Element (Mod m Z) Instance detailsDefined in Internal.Modular MethodsconstantD :: Mod m Z -> Int -> Vector (Mod m Z)extractR :: MatrixOrder -> Matrix (Mod m Z) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Mod m Z))setRect :: Int -> Int -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> IO ()sortI :: Vector (Mod m Z) -> Vector CIntsortV :: Vector (Mod m Z) -> Vector (Mod m Z)compareV :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector CIntselectV :: Vector CInt -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)remapM :: Matrix CInt -> Matrix CInt -> Matrix (Mod m Z) -> Matrix (Mod m Z)rowOp :: Int -> Mod m Z -> Int -> Int -> Int -> Int -> Matrix (Mod m Z) -> IO ()gemm :: Vector (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> IO ()reorderV :: Vector CInt -> Vector CInt -> Vector (Mod m Z) -> Vector (Mod m Z) type RealOf (Mod n Z) Instance detailsDefined in Internal.Modular type RealOf (Mod n Z) = Z type RealOf (Mod n I) Instance detailsDefined in Internal.Modular type RealOf (Mod n I) = I type (./.) x (n :: Nat) = Mod n x infixr 5 # luSolve' :: (Fractional t, Container Vector t) => LU t -> Matrix t -> Matrix t # Experimental implementation of luSolve for any Fractional element type, including Mod n I and Mod n Z. >>> let a = (2><2) [1,2,3,5] :: Matrix (Z ./. 13) (2><2) [ 1, 2 , 3, 5 ] >>> b (2><3) [ 5, 1, 3 , 8, 6, 3 ]  >>> luSolve' (luPacked' a) b (2><3) [ 4, 7, 4 , 7, 10, 6 ]  luPacked' :: (Container Vector t, Fractional t, Normed (Vector t), Num (Vector t)) => Matrix t -> LU t # Experimental implementation of luPacked for any Fractional element type, including Mod n I and Mod n Z. >>> let m = ident 5 + (5><5) [0..] :: Matrix (Z ./. 17) (5><5) [ 1, 1, 2, 3, 4 , 5, 7, 7, 8, 9 , 10, 11, 13, 13, 14 , 15, 16, 0, 2, 2 , 3, 4, 5, 6, 8 ]  >>> let (l,u,p,s) = luFact luPacked' m
>>> l
(5><5)
[  1,  0, 0,  0, 0
,  6,  1, 0,  0, 0
, 12,  7, 1,  0, 0
,  7, 10, 7,  1, 0
,  8,  2, 6, 11, 1 ]
>>> u
(5><5)
[ 15, 16,  0,  2,  2
,  0, 13,  7, 13, 14
,  0,  0, 15,  0, 11
,  0,  0,  0, 15, 15
,  0,  0,  0,  0,  1 ]


dispShort :: Int -> Int -> Int -> Matrix Double -> IO () #

solution of overconstrained homogeneous symmetric linear system

solution of overconstrained homogeneous linear system

outer products of rows

>>> a
(3><2)
[   1.0,   2.0
,  10.0,  20.0
, 100.0, 200.0 ]
>>> b
(3><3)
[ 1.0, 2.0, 3.0
, 4.0, 5.0, 6.0
, 7.0, 8.0, 9.0 ]

>>> rowOuters a (b ||| 1)
(3><8)
[   1.0,   2.0,   3.0,   1.0,    2.0,    4.0,    6.0,   2.0
,  40.0,  50.0,  60.0,  10.0,   80.0,  100.0,  120.0,  20.0
, 700.0, 800.0, 900.0, 100.0, 1400.0, 1600.0, 1800.0, 200.0 ]


Matrix of pairwise squared distances of row vectors (using the matrix product trick in blog.smola.org)

size :: Container c t => c t -> IndexOf c #

>>> size $vector [1..10] 10 >>> size$ (2><5)[1..10::Double]
(2,5)


normalize :: (Normed (Vector t), Num (Vector t), Field t) => Vector t -> Vector t #

Obtains a vector in the same direction with 2-norm=1

magnit :: (Element t, Normed (Vector t)) => R -> t -> Bool #

Check if the absolute value or complex magnitude is greater than a given threshold

>>> magnit 1E-6 (1E-12 :: R)
False
>>> magnit 1E-6 (3+iC :: C)
True
>>> magnit 0 (3 :: I ./. 5)
True


norm_nuclear :: Field t => Matrix t -> R #

Sum of singular values (Schatten p-norm with p=1)

norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R #

Frobenius norm (Schatten p-norm with p=2)

cross :: Product t => Vector t -> Vector t -> Vector t #

cross product (for three-element vectors)

(¿) :: Element t => Matrix t -> [Int] -> Matrix t infixl 9 #

extract columns

(unicode 0x00bf, inverted question mark, Alt-Gr ?)

>>> (3><4) [1..] ¿ [3,0]
(3><2)
[  4.0, 1.0
,  8.0, 5.0
, 12.0, 9.0 ]


(?) :: Element t => Matrix t -> [Int] -> Matrix t infixl 9 #

extract rows

>>> (20><4) [1..] ? [2,1,1]
(3><4)
[ 9.0, 10.0, 11.0, 12.0
, 5.0,  6.0,  7.0,  8.0
, 5.0,  6.0,  7.0,  8.0 ]


col :: [Double] -> Matrix Double #

create a single column real matrix from a list

>>> col [7,-2,4]
(3><1)
[  7.0
, -2.0
,  4.0 ]


row :: [Double] -> Matrix Double #

create a single row real matrix from a list

>>> row [2,3,1,8]
(1><4)
[ 2.0, 3.0, 1.0, 8.0 ]


(===) :: Element t => Matrix t -> Matrix t -> Matrix t infixl 2 #

vertical concatenation

(|||) :: Element t => Matrix t -> Matrix t -> Matrix t infixl 3 #

horizontal concatenation

>>> ident 3 ||| konst 7 (3,4)
(3><7)
[ 1.0, 0.0, 0.0, 7.0, 7.0, 7.0, 7.0
, 0.0, 1.0, 0.0, 7.0, 7.0, 7.0, 7.0
, 0.0, 0.0, 1.0, 7.0, 7.0, 7.0, 7.0 ]


diagl :: [Double] -> Matrix Double #

create a real diagonal matrix from a list

>>> diagl [1,2,3]
(3><3)
[ 1.0, 0.0, 0.0
, 0.0, 2.0, 0.0
, 0.0, 0.0, 3.0 ]


disp :: Int -> Matrix Double -> IO () #

print a real matrix with given number of digits after the decimal point

>>> disp 5 $ident 2 / 3 2x2 0.33333 0.00000 0.00000 0.33333  Arguments  :: Int number of columns -> [R] elements in row order -> Matrix R Create a real matrix. >>> matrix 5 [1..15] (3><5) [ 1.0, 2.0, 3.0, 4.0, 5.0 , 6.0, 7.0, 8.0, 9.0, 10.0 , 11.0, 12.0, 13.0, 14.0, 15.0 ]  vector :: [R] -> Vector R # Create a real vector. >>> vector [1..5] fromList [1.0,2.0,3.0,4.0,5.0]  iC :: C # imaginary unit class Normed a where # p-norm for vectors, operator norm for matrices Minimal complete definition Methods norm_0 :: a -> R # norm_1 :: a -> R # norm_2 :: a -> R # norm_Inf :: a -> R # Instances  Instance detailsDefined in Internal.Util Methodsnorm_0 :: Matrix R -> R #norm_1 :: Matrix R -> R #norm_2 :: Matrix R -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Matrix C -> R #norm_1 :: Matrix C -> R #norm_2 :: Matrix C -> R # Instance detailsDefined in Internal.Util Methods Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector (Complex Float) -> R #norm_1 :: Vector (Complex Float) -> R #norm_2 :: Vector (Complex Float) -> R #norm_Inf :: Vector (Complex Float) -> R # KnownNat m => Normed (Vector (Mod m I)) Instance detailsDefined in Internal.Modular Methodsnorm_0 :: Vector (Mod m I) -> R #norm_1 :: Vector (Mod m I) -> R #norm_2 :: Vector (Mod m I) -> R #norm_Inf :: Vector (Mod m I) -> R # KnownNat m => Normed (Vector (Mod m Z)) Instance detailsDefined in Internal.Modular Methodsnorm_0 :: Vector (Mod m Z) -> R #norm_1 :: Vector (Mod m Z) -> R #norm_2 :: Vector (Mod m Z) -> R #norm_Inf :: Vector (Mod m Z) -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector I -> R #norm_1 :: Vector I -> R #norm_2 :: Vector I -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector Z -> R #norm_1 :: Vector Z -> R #norm_2 :: Vector Z -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector R -> R #norm_1 :: Vector R -> R #norm_2 :: Vector R -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Vector C -> R #norm_1 :: Vector C -> R #norm_2 :: Vector C -> R # class Indexable c t | c -> t, t -> c where # Alternative indexing function. >>> vector [1..10] ! 3 4.0  On a matrix it gets the k-th row as a vector: >>> matrix 5 [1..15] ! 1 fromList [6.0,7.0,8.0,9.0,10.0]  >>> matrix 5 [1..15] ! 1 ! 3 9.0  Minimal complete definition (!) Methods (!) :: c -> Int -> t infixl 9 # Instances  Instance detailsDefined in Internal.Util Methods Instance detailsDefined in Internal.Util Methods(!) :: Vector Float -> Int -> Float # Instance detailsDefined in Internal.Util Methods(!) :: Vector I -> Int -> I # Instance detailsDefined in Internal.Util Methods(!) :: Vector Z -> Int -> Z # Element t => Indexable (Matrix t) (Vector t) Instance detailsDefined in Internal.Util Methods(!) :: Matrix t -> Int -> Vector t # Instance detailsDefined in Internal.Util Methods Instance detailsDefined in Internal.Util Methods (Storable t, Indexable (Vector t) t) => Indexable (Vector (Mod m t)) (Mod m t) Instance detailsDefined in Internal.Modular Methods(!) :: Vector (Mod m t) -> Int -> Mod m t # separable :: Element t => (Vector t -> Vector t) -> Matrix t -> Matrix t # matrix computation implemented as separated vector operations by rows and columns. Arguments  :: (Num (Matrix a), Product a, Container Vector a) => Matrix a kernel -> Matrix a -> Matrix a 2D convolution >>> disp 5$ conv2 (konst 1 (3,3)) (ident 10 :: Matrix Double)
12x12
1  1  1  0  0  0  0  0  0  0  0  0
1  2  2  1  0  0  0  0  0  0  0  0
1  2  3  2  1  0  0  0  0  0  0  0
0  1  2  3  2  1  0  0  0  0  0  0
0  0  1  2  3  2  1  0  0  0  0  0
0  0  0  1  2  3  2  1  0  0  0  0
0  0  0  0  1  2  3  2  1  0  0  0
0  0  0  0  0  1  2  3  2  1  0  0
0  0  0  0  0  0  1  2  3  2  1  0
0  0  0  0  0  0  0  1  2  3  2  1
0  0  0  0  0  0  0  0  1  2  2  1
0  0  0  0  0  0  0  0  0  1  1  1


corr2 :: Product a => Matrix a -> Matrix a -> Matrix a #

>>> disp 5 $corr2 (konst 1 (3,3)) (ident 10 :: Matrix Double) 8x8 3 2 1 0 0 0 0 0 2 3 2 1 0 0 0 0 1 2 3 2 1 0 0 0 0 1 2 3 2 1 0 0 0 0 1 2 3 2 1 0 0 0 0 1 2 3 2 1 0 0 0 0 1 2 3 2 0 0 0 0 0 1 2 3  corrMin :: (Container Vector t, RealElement t, Product t) => Vector t -> Vector t -> Vector t # similar to corr, using min instead of (*) conv :: (Container Vector t, Product t, Num t) => Vector t -> Vector t -> Vector t # convolution (corr with reversed kernel and padded input, equivalent to polynomial product) >>> conv (fromList[1,1]) (fromList [-1,1]) fromList [-1.0,0.0,1.0]  Arguments  :: (Container Vector t, Product t) => Vector t kernel -> Vector t source -> Vector t correlation >>> corr (fromList[1,2,3]) (fromList [1..10]) fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0]  remap :: Element t => Matrix I -> Matrix I -> Matrix t -> Matrix t # Extract elements from positions given in matrices of rows and columns. >>> r (3><3) [ 1, 1, 1 , 1, 2, 2 , 1, 2, 3 ] >>> c (3><3) [ 0, 1, 5 , 2, 2, 1 , 4, 4, 1 ] >>> m (4><6) [ 0, 1, 2, 3, 4, 5 , 6, 7, 8, 9, 10, 11 , 12, 13, 14, 15, 16, 17 , 18, 19, 20, 21, 22, 23 ]  >>> remap r c m (3><3) [ 6, 7, 11 , 8, 14, 13 , 10, 16, 19 ]  The indexes are autoconformable. >>> c' (3><1) [ 1 , 2 , 4 ] >>> remap r c' m (3><3) [ 7, 7, 7 , 8, 14, 14 , 10, 16, 22 ]  sortIndex :: (Ord t, Element t) => Vector t -> Vector I # >>> m <- randn 4 10 >>> disp 2 m 4x10 -0.31 0.41 0.43 -0.19 -0.17 -0.23 -0.17 -1.04 -0.07 -1.24 0.26 0.19 0.14 0.83 -1.54 -0.09 0.37 -0.63 0.71 -0.50 -0.11 -0.10 -1.29 -1.40 -1.04 -0.89 -0.68 0.35 -1.46 1.86 1.04 -0.29 0.19 -0.75 -2.20 -0.01 1.06 0.11 -2.09 -1.58  >>> disp 2$ m ?? (All, Pos $sortIndex (m!1)) 4x10 -0.17 -1.04 -1.24 -0.23 0.43 0.41 -0.31 -0.17 -0.07 -0.19 -1.54 -0.63 -0.50 -0.09 0.14 0.19 0.26 0.37 0.71 0.83 -1.04 0.35 1.86 -0.89 -1.29 -0.10 -0.11 -0.68 -1.46 -1.40 -2.20 0.11 -1.58 -0.01 0.19 -0.29 1.04 1.06 -2.09 -0.75  sortVector :: (Ord t, Element t) => Vector t -> Vector t # Compute mean vector and covariance matrix of the rows of a matrix. >>> meanCov$ gaussianSample 666 1000 (fromList[4,5]) (diagl[2,3])
(fromList [4.010341078059521,5.0197204699640405],
(2><2)
[     1.9862461923890056, -1.0127225830525157e-2
, -1.0127225830525157e-2,     3.0373954915729318 ])


dot :: Numeric t => Vector t -> Vector t -> t #

(<\>) :: (LSDiv c, Field t) => Matrix t -> c t -> c t infixl 7 #

Least squares solution of a linear system, similar to the \ operator of Matlab/Octave (based on linearSolveSVD)

a = (3><2)
[ 1.0,  2.0
, 2.0,  4.0
, 2.0, -1.0 ]

v = vector [13.0,27.0,1.0]

>>> let x = a <\> v
>>> x
fromList [3.0799999999999996,5.159999999999999]

>>> a #> x
fromList [13.399999999999999,26.799999999999997,1.0]


It also admits multiple right-hand sides stored as columns in a matrix.

(<#) :: Numeric t => Vector t -> Matrix t -> Vector t infixl 8 #

dense vector-matrix product

(#>) :: Numeric t => Matrix t -> Vector t -> Vector t infixr 8 #

dense matrix-vector product

>>> let m = (2><3) [1..]
>>> m
(2><3)
[ 1.0, 2.0, 3.0
, 4.0, 5.0, 6.0 ]

>>> let v = vector [10,20,30]

>>> m #> v
fromList [140.0,320.0]


(<.>) :: Numeric t => Vector t -> Vector t -> t infixr 8 #

An infix synonym for dot

>>> vector [1,2,3,4] <.> vector [-2,0,1,1]
5.0

>>> let 𝑖 = 0:+1 :: C
>>> fromList [1+𝑖,1] <.> fromList [1,1+𝑖]
2.0 :+ 0.0


linspace :: (Fractional e, Container Vector e) => Int -> (e, e) -> Vector e #

Creates a real vector containing a range of values:

>>> linspace 5 (-3,7::Double)
fromList [-3.0,-0.5,2.0,4.5,7.0]@

>>> linspace 5 (8,2+i) :: Vector (Complex Double)
fromList [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0]


Logarithmic spacing can be defined as follows:

logspace n (a,b) = 10 ** linspace n (a,b)

class LSDiv (c :: * -> *) #

Minimal complete definition

linSolve

Instances
 Instance detailsDefined in Internal.Container MethodslinSolve :: Field t => Matrix t -> Matrix t -> Matrix t Instance detailsDefined in Internal.Container MethodslinSolve :: Field t => Matrix t -> Vector t -> Vector t

class Build d f (c :: * -> *) e | d -> c, c -> d, f -> e, f -> d, f -> c, c e -> f, d e -> f where #

Minimal complete definition

build

Methods

build :: d -> f -> c e #

>>> build 5 (**2) :: Vector Double
fromList [0.0,1.0,4.0,9.0,16.0]


Hilbert matrix of order N:

>>> let hilb n = build (n,n) (\i j -> 1/(i+j+1)) :: Matrix Double
>>> putStr . dispf 2 $hilb 3 3x3 1.00 0.50 0.33 0.50 0.33 0.25 0.33 0.25 0.20  Instances  Container Vector e => Build Int (e -> e) Vector e Instance detailsDefined in Internal.Container Methodsbuild :: Int -> (e -> e) -> Vector e # Container Matrix e => Build (Int, Int) (e -> e -> e) Matrix e Instance detailsDefined in Internal.Container Methodsbuild :: (Int, Int) -> (e -> e -> e) -> Matrix e # randn :: Int -> Int -> IO (Matrix Double) # pseudorandom matrix with normal elements >>> disp 3 =<< randn 3 5 3x5 0.386 -1.141 0.491 -0.510 1.512 0.069 -0.919 1.022 -0.181 0.745 0.313 -0.670 -0.097 -1.575 -0.583  rand :: Int -> Int -> IO (Matrix Double) # pseudorandom matrix with uniform elements between 0 and 1 Arguments  :: Seed -> Int number of rows -> [(Double, Double)] ranges for each column -> Matrix Double result Obtains a matrix whose rows are pseudorandom samples from a multivariate uniform distribution. Arguments  :: Seed -> Int number of rows -> Vector Double mean vector -> Herm Double covariance matrix -> Matrix Double result Obtains a matrix whose rows are pseudorandom samples from a multivariate Gaussian distribution. trustSym :: Matrix t -> Herm t # At your own risk, declare that a matrix is complex Hermitian or real symmetric for usage in chol, eigSH, etc. Only a triangular part of the matrix will be used. mTm :: Numeric t => Matrix t -> Herm t # Compute the contraction tr x <> x of a general matrix. sym :: Field t => Matrix t -> Herm t # Compute the complex Hermitian or real symmetric part of a square matrix ((x + tr x)/2). unSym :: Herm t -> Matrix t # Extract the general matrix from a Herm structure, forgetting its symmetric or Hermitian property. Arguments  :: Field t => Herm t A -> Herm t B -> (Vector Double, Matrix t) Generalized symmetric positive definite eigensystem Av = lBv, for A and B symmetric, B positive definite. relativeError :: Num a => (a -> Double) -> a -> a -> Double # luFact :: Numeric t => LU t -> (Matrix t, Matrix t, Matrix t, t) # Compute the explicit LU decomposition from the compact one obtained by luPacked. sqrtm :: Field t => Matrix t -> Matrix t # Matrix square root. Currently it uses a simple iterative algorithm described in Wikipedia. It only works with invertible matrices that have a real solution. m = (2><2) [4,9 ,0,4] :: Matrix Double >>> sqrtm m (2><2) [ 2.0, 2.25 , 0.0, 2.0 ]  For diagonalizable matrices you can try matFunc sqrt: >>> matFunc sqrt ((2><2) [1,0,0,-1]) (2><2) [ 1.0 :+ 0.0, 0.0 :+ 0.0 , 0.0 :+ 0.0, 0.0 :+ 1.0 ]  expm :: Field t => Matrix t -> Matrix t # Matrix exponential. It uses a direct translation of Algorithm 11.3.1 in Golub & Van Loan, based on a scaled Pade approximation. Generic matrix functions for diagonalizable matrices. For instance: logm = matFunc log rank :: Field t => Matrix t -> Int # Number of linearly independent rows or columns. See also ranksv rcond :: Field t => Matrix t -> Double # Reciprocal of the 2-norm condition number of a matrix, computed from the singular values. haussholder :: Field a => a -> Vector a -> Matrix a # Arguments  :: Field t => Either Double Int Left "numeric" zero (eg. 1*eps), or Right "theoretical" matrix rank. -> Matrix t input matrix m -> (Matrix t, Vector Double) leftSV of m -> Matrix t orth The range space a matrix from its precomputed SVD decomposition. Arguments  :: Field t => Either Double Int Left "numeric" zero (eg. 1*eps), or Right "theoretical" matrix rank. -> Matrix t input matrix m -> (Vector Double, Matrix t) rightSV of m -> Matrix t nullspace The nullspace of a matrix from its precomputed SVD decomposition. peps :: RealFloat x => x # 1 + 0.5*peps == 1, 1 + 0.6*peps /= 1 Arguments  :: Double numeric zero (e.g. 1*eps) -> Int maximum dimension of the matrix -> [Double] singular values -> Int rank of m Numeric rank of a matrix from its singular values. pinvTol :: Field t => Double -> Matrix t -> Matrix t # pinvTol r computes the pseudoinverse of a matrix with tolerance tol=r*g*eps*(max rows cols), where g is the greatest singular value. m = (3><3) [ 1, 0, 0 , 0, 1, 0 , 0, 0, 1e-10] :: Matrix Double  >>> pinv m 1. 0. 0. 0. 1. 0. 0. 0. 10000000000.  >>> pinvTol 1E8 m 1. 0. 0. 0. 1. 0. 0. 0. 1.  pinv :: Field t => Matrix t -> Matrix t # Pseudoinverse of a general matrix with default tolerance (pinvTol 1, similar to GNU-Octave). inv :: Field t => Matrix t -> Matrix t # Inverse of a square matrix. See also invlndet. lu :: Field t => Matrix t -> (Matrix t, Matrix t, Matrix t, t) # Explicit LU factorization of a general matrix. If (l,u,p,s) = lu m then m == p <> l <> u, where l is lower triangular, u is upper triangular, p is a permutation matrix and s is the signature of the permutation. det :: Field t => Matrix t -> t # Determinant of a square matrix. To avoid possible overflow or underflow use invlndet. Arguments  :: Field t => Matrix t -> (Matrix t, (t, t)) (inverse, (log abs det, sign or phase of det)) Joint computation of inverse and logarithm of determinant of a square matrix. mbChol :: Field t => Herm t -> Maybe (Matrix t) # Similar to chol, but instead of an error (e.g., caused by a matrix not positive definite) it returns Nothing. chol :: Field t => Herm t -> Matrix t # Cholesky factorization of a positive definite hermitian or symmetric matrix. If c = chol m then c is upper triangular and m == tr c <> c. schur :: Field t => Matrix t -> (Matrix t, Matrix t) # Schur factorization. If (u,s) = schur m then m == u <> s <> tr u, where u is unitary and s is a Shur matrix. A complex Schur matrix is upper triangular. A real Schur matrix is upper triangular in 2x2 blocks. "Anything that the Jordan decomposition can do, the Schur decomposition can do better!" (Van Loan) hess :: Field t => Matrix t -> (Matrix t, Matrix t) # Hessenberg factorization. If (p,h) = hess m then m == p <> h <> tr p, where p is unitary and h is in upper Hessenberg form (it has zero entries below the first subdiagonal). thinRQ :: Field t => Matrix t -> (Matrix t, Matrix t) # A version of rq which returns only the min (rows m) (cols m) columns of r and rows of q. rq :: Field t => Matrix t -> (Matrix t, Matrix t) # RQ factorization. If (r,q) = rq m then m == r <> q, where q is unitary and r is upper triangular. Note: the current implementation is very slow for large matrices. thinRQ is much faster. qrgr :: Field t => Int -> QR t -> Matrix t # generate a matrix with k orthogonal columns from the compact QR decomposition obtained by qrRaw. qrRaw :: Field t => Matrix t -> QR t # Compute the QR decomposition of a matrix in compact form. thinQR :: Field t => Matrix t -> (Matrix t, Matrix t) # A version of qr which returns only the min (rows m) (cols m) columns of q and rows of r. qr :: Field t => Matrix t -> (Matrix t, Matrix t) # QR factorization. If (q,r) = qr m then m == q <> r, where q is unitary and r is upper triangular. Note: the current implementation is very slow for large matrices. thinQR is much faster. eigenvaluesSH :: Field t => Herm t -> Vector Double # Eigenvalues (in descending order) of a complex hermitian or real symmetric matrix. eigSH :: Field t => Herm t -> (Vector Double, Matrix t) # Eigenvalues and eigenvectors (as columns) of a complex hermitian or real symmetric matrix, in descending order. If (s,v) = eigSH m then m == v <> diag s <> tr v a = (3><3) [ 1.0, 2.0, 3.0 , 2.0, 4.0, 5.0 , 3.0, 5.0, 6.0 ]  >>> let (l, v) = eigSH a  >>> l fromList [11.344814282762075,0.17091518882717918,-0.5157294715892575]  >>> disp 3$ v <> diag l <> tr v
3x3
1.000  2.000  3.000
2.000  4.000  5.000
3.000  5.000  6.000


eigenvalues :: Field t => Matrix t -> Vector (Complex Double) #

Eigenvalues (not ordered) of a general square matrix.

eig :: Field t => Matrix t -> (Vector (Complex Double), Matrix (Complex Double)) #

Eigenvalues (not ordered) and eigenvectors (as columns) of a general square matrix.

If (s,v) = eig m then m <> v == v <> diag s

a = (3><3)
[ 3, 0, -2
, 4, 5, -1
, 3, 1,  0 ] :: Matrix Double

>>> let (l, v) = eig a

>>> putStr . dispcf 3 . asRow $l 1x3 1.925+1.523i 1.925-1.523i 4.151  >>> putStr . dispcf 3$ v
3x3
-0.455+0.365i  -0.455-0.365i   0.181
0.603          0.603  -0.978
0.033+0.543i   0.033-0.543i  -0.104

>>> putStr . dispcf 3 $complex a <> v 3x3 -1.432+0.010i -1.432-0.010i 0.753 1.160+0.918i 1.160-0.918i -4.059 -0.763+1.096i -0.763-1.096i -0.433  >>> putStr . dispcf 3$ v <> diag l
3x3
-1.432+0.010i  -1.432-0.010i   0.753
1.160+0.918i   1.160-0.918i  -4.059
-0.763+1.096i  -0.763-1.096i  -0.433


ldlSolve :: Field t => LDL t -> Matrix t -> Matrix t #

Solution of a linear system (for several right hand sides) from a precomputed LDL factorization obtained by ldlPacked.

Note: this can be slower than the general solver based on the LU decomposition.

ldlPacked :: Field t => Herm t -> LDL t #

Obtains the LDL decomposition of a matrix in a compact data structure suitable for ldlSolve.

linearSolveLS :: Field t => Matrix t -> Matrix t -> Matrix t #

Least squared error solution of an overconstrained linear system, or the minimum norm solution of an underconstrained system. For rank-deficient systems use linearSolveSVD.

linearSolveSVD :: Field t => Matrix t -> Matrix t -> Matrix t #

Minimum norm solution of a general linear least squares problem Ax=B using the SVD. Admits rank-deficient systems but it is slower than linearSolveLS. The effective rank of A is determined by treating as zero those singular valures which are less than eps times the largest singular value.

Arguments

 :: Field t => Vector t lower diagonal: $$n - 1$$ elements -> Vector t diagonal: $$n$$ elements -> Vector t upper diagonal: $$n - 1$$ elements -> Matrix t right hand sides -> Matrix t solution

Solve a tridiagonal linear system. Suppose you wish to solve $$Ax = b$$ where

$A = \begin{bmatrix} 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 & 0.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 & 4.0 \\ 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 3.0 & 1.0 \end{bmatrix} \quad b = \begin{bmatrix} 1.0 & 1.0 & 1.0 \\ 1.0 & -1.0 & 2.0 \\ 1.0 & 1.0 & 3.0 \\ 1.0 & -1.0 & 4.0 \\ 1.0 & 1.0 & 5.0 \\ 1.0 & -1.0 & 6.0 \\ 1.0 & 1.0 & 7.0 \\ 1.0 & -1.0 & 8.0 \\ 1.0 & 1.0 & 9.0 \end{bmatrix}$

then

dL =  fromList [3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0]
d  =  fromList [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
dU =  fromList [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0]

b = (9><3)
[
1.0,   1.0,   1.0,
1.0,  -1.0,   2.0,
1.0,   1.0,   3.0,
1.0,  -1.0,   4.0,
1.0,   1.0,   5.0,
1.0,  -1.0,   6.0,
1.0,   1.0,   7.0,
1.0,  -1.0,   8.0,
1.0,   1.0,   9.0
]

x = triDiagSolve dL d dU b


Arguments

 :: Field t => UpLo Lower or Upper -> Matrix t coefficient matrix -> Matrix t right hand sides -> Matrix t solution

Solve a triangular linear system. If Upper is specified then all elements below the diagonal are ignored; if Lower is specified then all elements above the diagonal are ignored.

Arguments

 :: Field t => Matrix t Cholesky decomposition of the coefficient matrix -> Matrix t right hand sides -> Matrix t solution

Solve a symmetric or Hermitian positive definite linear system using a precomputed Cholesky decomposition obtained by chol.

luSolve :: Field t => LU t -> Matrix t -> Matrix t #

Solution of a linear system (for several right hand sides) from the precomputed LU factorization obtained by luPacked.

luPacked :: Field t => Matrix t -> LU t #

Obtains the LU decomposition of a matrix in a compact data structure suitable for luSolve.

leftSV :: Field t => Matrix t -> (Matrix t, Vector Double) #

Singular values and all left singular vectors (as columns).

rightSV :: Field t => Matrix t -> (Vector Double, Matrix t) #

Singular values and all right singular vectors (as columns).

compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t) #

compactSVDTol r is similar to compactSVD (for which r=1), but uses tolerance tol=r*g*eps*(max rows cols) to distinguish nonzero singular values, where g is the greatest singular value. If g<r*eps, then only one singular value is returned.

compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) #

Similar to thinSVD, returning only the nonzero singular values and the corresponding singular vectors.

a = (5><3)
[  1.0,  2.0,  3.0
,  4.0,  5.0,  6.0
,  7.0,  8.0,  9.0
, 10.0, 11.0, 12.0
, 13.0, 14.0, 15.0 ] :: Matrix Double

>>> let (u,s,v) = compactSVD a

>>> disp 3 u
5x2
-0.101   0.768
-0.249   0.488
-0.396   0.208
-0.543  -0.072
-0.690  -0.352

>>> s
fromList [35.18264833189422,1.4769076999800903]

>>> disp 3 u
5x2
-0.101   0.768
-0.249   0.488
-0.396   0.208
-0.543  -0.072
-0.690  -0.352

>>> disp 3 $u <> diag s <> tr v 5x3 1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000 9.000 10.000 11.000 12.000 13.000 14.000 15.000  singularValues :: Field t => Matrix t -> Vector Double # Singular values only. thinSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) # A version of svd which returns only the min (rows m) (cols m) singular vectors of m. If (u,s,v) = thinSVD m then m == u <> diag s <> tr v. a = (5><3) [ 1.0, 2.0, 3.0 , 4.0, 5.0, 6.0 , 7.0, 8.0, 9.0 , 10.0, 11.0, 12.0 , 13.0, 14.0, 15.0 ] :: Matrix Double  >>> let (u,s,v) = thinSVD a  >>> disp 3 u 5x3 -0.101 0.768 0.614 -0.249 0.488 -0.503 -0.396 0.208 -0.405 -0.543 -0.072 -0.140 -0.690 -0.352 0.433  >>> s fromList [35.18264833189422,1.4769076999800903,1.089145439970417e-15]  >>> disp 3 v 3x3 -0.519 -0.751 0.408 -0.576 -0.046 -0.816 -0.632 0.659 0.408  >>> disp 3$ u <> diag s <> tr v
5x3
1.000   2.000   3.000
4.000   5.000   6.000
7.000   8.000   9.000
10.000  11.000  12.000
13.000  14.000  15.000


svd :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) #

Full singular value decomposition.

a = (5><3)
[  1.0,  2.0,  3.0
,  4.0,  5.0,  6.0
,  7.0,  8.0,  9.0
, 10.0, 11.0, 12.0
, 13.0, 14.0, 15.0 ] :: Matrix Double

>>> let (u,s,v) = svd a

>>> disp 3 u
5x5
-0.101   0.768   0.614   0.028  -0.149
-0.249   0.488  -0.503   0.172   0.646
-0.396   0.208  -0.405  -0.660  -0.449
-0.543  -0.072  -0.140   0.693  -0.447
-0.690  -0.352   0.433  -0.233   0.398

>>> s
fromList [35.18264833189422,1.4769076999800903,1.089145439970417e-15]

>>> disp 3 v
3x3
-0.519  -0.751   0.408
-0.576  -0.046  -0.816
-0.632   0.659   0.408

>>> let d = diagRect 0 s 5 3
>>> disp 3 d
5x3
35.183  0.000  0.000
0.000  1.477  0.000
0.000  0.000  0.000
0.000  0.000  0.000

>>> disp 3 $u <> d <> tr v 5x3 1.000 2.000 3.000 4.000 5.000 6.000 7.000 8.000 9.000 10.000 11.000 12.000 13.000 14.000 15.000  class (Numeric t, Convert t, Normed Matrix t, Normed Vector t, Floating t, Linear t Vector, Linear t Matrix, Additive (Vector t), Additive (Matrix t), RealOf t ~ Double) => Field t # Generic linear algebra functions for double precision real and complex matrices. (Single precision data can be converted using single and double). Minimal complete definition svd', thinSVD', sv', luPacked', luSolve', mbLinearSolve', linearSolve', cholSolve', triSolve', triDiagSolve', ldlPacked', ldlSolve', linearSolveSVD', linearSolveLS', eig', eigSH'', eigOnly, eigOnlySH, cholSH', mbCholSH', qr', qrgr', hess', schur' Instances  Instance detailsDefined in Internal.Algorithms MethodsluPacked' :: Matrix Double -> (Matrix Double, [Int])luSolve' :: (Matrix Double, [Int]) -> Matrix Double -> Matrix DoubleldlPacked' :: Matrix Double -> (Matrix Double, [Int])ldlSolve' :: (Matrix Double, [Int]) -> Matrix Double -> Matrix Doubleqrgr' :: Int -> (Matrix Double, Vector Double) -> Matrix Double Instance detailsDefined in Internal.Algorithms MethodsluPacked' :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int])luSolve' :: (Matrix (Complex Double), [Int]) -> Matrix (Complex Double) -> Matrix (Complex Double)ldlPacked' :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int])ldlSolve' :: (Matrix (Complex Double), [Int]) -> Matrix (Complex Double) -> Matrix (Complex Double)qr' :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double))qrgr' :: Int -> (Matrix (Complex Double), Vector (Complex Double)) -> Matrix (Complex Double) data LU t # LU decomposition of a matrix in a compact format. Constructors  LU (Matrix t) [Int] Instances  (Show t, Element t) => Show (LU t) Instance detailsDefined in Internal.Algorithms MethodsshowsPrec :: Int -> LU t -> ShowS #show :: LU t -> String #showList :: [LU t] -> ShowS # (NFData t, Numeric t) => NFData (LU t) Instance detailsDefined in Internal.Algorithms Methodsrnf :: LU t -> () # data LDL t # LDL decomposition of a complex Hermitian or real symmetric matrix in a compact format. Constructors  LDL (Matrix t) [Int] Instances  (Show t, Element t) => Show (LDL t) Instance detailsDefined in Internal.Algorithms MethodsshowsPrec :: Int -> LDL t -> ShowS #show :: LDL t -> String #showList :: [LDL t] -> ShowS # (NFData t, Numeric t) => NFData (LDL t) Instance detailsDefined in Internal.Algorithms Methodsrnf :: LDL t -> () # data QR t # QR decomposition of a matrix in compact form. (The orthogonal matrix is not explicitly formed.) Constructors  QR (Matrix t) (Vector t) Instances  (NFData t, Numeric t) => NFData (QR t) Instance detailsDefined in Internal.Algorithms Methodsrnf :: QR t -> () # data Herm t # A matrix that, by construction, it is known to be complex Hermitian or real symmetric. It can be created using sym, mTm, or trustSym, and the matrix can be extracted using unSym. Instances  Field t => Linear t Herm Instance detailsDefined in Internal.Algorithms Methodsscale :: t -> Herm t -> Herm t # (Show t, Element t) => Show (Herm t) Instance detailsDefined in Internal.Algorithms MethodsshowsPrec :: Int -> Herm t -> ShowS #show :: Herm t -> String #showList :: [Herm t] -> ShowS # (NFData t, Numeric t) => NFData (Herm t) Instance detailsDefined in Internal.Algorithms Methodsrnf :: Herm t -> () # Field t => Additive (Herm t) Instance detailsDefined in Internal.Algorithms Methodsadd :: Herm t -> Herm t -> Herm t # (!#>) :: GMatrix -> Vector Double -> Vector Double infixr 8 # general matrix - vector product >>> let m = mkSparse [((0,999),1.0),((1,1999),2.0)] >>> m !#> vector [1..2000] fromList [1000.0,4000.0]  type AssocMatrix = [((Int, Int), Double)] # data GMatrix # General matrix with specialized internal representations for dense, sparse, diagonal, banded, and constant elements. >>> let m = mkSparse [((0,999),1.0),((1,1999),2.0)] >>> m SparseR {gmCSR = CSR {csrVals = fromList [1.0,2.0], csrCols = fromList [1000,2000], csrRows = fromList [1,2,3], csrNRows = 2, csrNCols = 2000}, nRows = 2, nCols = 2000}  >>> let m = mkDense (mat 2 [1..4]) >>> m Dense {gmDense = (2><2) [ 1.0, 2.0 , 3.0, 4.0 ], nRows = 2, nCols = 2}  Instances  Instance detailsDefined in Internal.Sparse MethodsshowList :: [GMatrix] -> ShowS # Instance detailsDefined in Internal.Sparse Methods ident :: (Num a, Element a) => Int -> Matrix a # creates the identity matrix of given dimension diag :: (Num a, Element a) => Vector a -> Matrix a # Creates a square matrix with a given diagonal. kronecker :: Product t => Matrix t -> Matrix t -> Matrix t # Kronecker product of two matrices. m1=(2><3) [ 1.0, 2.0, 0.0 , 0.0, -1.0, 3.0 ] m2=(4><3) [ 1.0, 2.0, 3.0 , 4.0, 5.0, 6.0 , 7.0, 8.0, 9.0 , 10.0, 11.0, 12.0 ] >>> kronecker m1 m2 (8><9) [ 1.0, 2.0, 3.0, 2.0, 4.0, 6.0, 0.0, 0.0, 0.0 , 4.0, 5.0, 6.0, 8.0, 10.0, 12.0, 0.0, 0.0, 0.0 , 7.0, 8.0, 9.0, 14.0, 16.0, 18.0, 0.0, 0.0, 0.0 , 10.0, 11.0, 12.0, 20.0, 22.0, 24.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, -1.0, -2.0, -3.0, 3.0, 6.0, 9.0 , 0.0, 0.0, 0.0, -4.0, -5.0, -6.0, 12.0, 15.0, 18.0 , 0.0, 0.0, 0.0, -7.0, -8.0, -9.0, 21.0, 24.0, 27.0 , 0.0, 0.0, 0.0, -10.0, -11.0, -12.0, 30.0, 33.0, 36.0 ]  outer :: Product t => Vector t -> Vector t -> Matrix t # Outer product of two vectors. >>> fromList [1,2,3] outer fromList [5,2,3] (3><3) [ 5.0, 2.0, 3.0 , 10.0, 4.0, 6.0 , 15.0, 6.0, 9.0 ]  udot :: Product e => Vector e -> Vector e -> e # unconjugated dot product Arguments  :: Container c e => c e initial structure -> (e -> e -> e) update function -> [(IndexOf c, e)] association list -> c e result Modify a structure using an update function >>> accum (ident 5) (+) [((1,1),5),((0,3),3)] :: Matrix Double (5><5) [ 1.0, 0.0, 0.0, 3.0, 0.0 , 0.0, 6.0, 0.0, 0.0, 0.0 , 0.0, 0.0, 1.0, 0.0, 0.0 , 0.0, 0.0, 0.0, 1.0, 0.0 , 0.0, 0.0, 0.0, 0.0, 1.0 ]  computation of histogram: >>> accum (konst 0 7) (+) (map (flip (,) 1) [4,5,4,1,5,2,5]) :: Vector Double fromList [0.0,1.0,1.0,0.0,2.0,3.0,0.0]  Arguments  :: Container c e => IndexOf c size -> e default value -> [(IndexOf c, e)] association list -> c e result Create a structure from an association list >>> assoc 5 0 [(3,7),(1,4)] :: Vector Double fromList [0.0,4.0,0.0,7.0,0.0]  >>> assoc (2,3) 0 [((0,2),7),((1,0),2*i-3)] :: Matrix (Complex Double) (2><3) [ 0.0 :+ 0.0, 0.0 :+ 0.0, 7.0 :+ 0.0 , (-3.0) :+ 2.0, 0.0 :+ 0.0, 0.0 :+ 0.0 ]  find :: Container c e => (e -> Bool) -> c e -> [IndexOf c] # Find index of elements which satisfy a predicate >>> find (>0) (ident 3 :: Matrix Double) [(0,0),(1,1),(2,2)]  Arguments  :: (Ord e, Container c e, Container c x) => c e a -> c e b -> c x l -> c x e -> c x g -> c x result Element by element version of case compare a b of {LT -> l; EQ -> e; GT -> g}. Arguments with any dimension = 1 are automatically expanded: >>> cond ((1><4)[1..]) ((3><1)[1..]) 0 100 ((3><4)[1..]) :: Matrix Double (3><4) [ 100.0, 2.0, 3.0, 4.0 , 0.0, 100.0, 7.0, 8.0 , 0.0, 0.0, 100.0, 12.0 ]  >>> let chop x = cond (abs x) 1E-6 0 0 x  step :: (Ord e, Container c e) => c e -> c e # A more efficient implementation of cmap (\x -> if x>0 then 1 else 0) >>> step$ linspace 5 (-1,1::Double)
5 |> [0.0,0.0,0.0,1.0,1.0]


prodElements :: Container c e => c e -> e #

the product of elements

sumElements :: Container c e => c e -> e #

the sum of elements

maxElement :: Container c e => c e -> e #

value of maximum element

minElement :: Container c e => c e -> e #

value of minimum element

maxIndex :: Container c e => c e -> IndexOf c #

index of maximum element

minIndex :: Container c e => c e -> IndexOf c #

index of minimum element

atIndex :: Container c e => c e -> IndexOf c -> e #

generic indexing function

>>> vector [1,2,3] atIndex 1
2.0

>>> matrix 3 [0..8] atIndex (2,0)
6.0


cmap :: (Element b, Container c e) => (e -> b) -> c e -> c b #

like fmap (cannot implement instance Functor because of Element class constraint)

toZ :: Container c e => c e -> c Z #

fromZ :: Container c e => c Z -> c e #

toInt :: Container c e => c e -> c I #

fromInt :: Container c e => c I -> c e #

>>> fromInt ((2><2) [0..3]) :: Matrix (Complex Double)
(2><2)
[ 0.0 :+ 0.0, 1.0 :+ 0.0
, 2.0 :+ 0.0, 3.0 :+ 0.0 ]


cmod :: (Integral e, Container c e) => e -> c e -> c e #

mod for integer arrays

>>> cmod 3 (range 5)
fromList [0,1,2,0,1]


arctan2 :: (Fractional e, Container c e) => c e -> c e -> c e #

conj :: Container c e => c e -> c e #

complex conjugate

scalar :: Container c e => e -> c e #

create a structure with a single element

>>> let v = fromList [1..3::Double]
>>> v / scalar (norm2 v)
fromList [0.2672612419124244,0.5345224838248488,0.8017837257372732]


type family IndexOf (c :: * -> *) :: * #

Instances
 type IndexOf Matrix Instance detailsDefined in Internal.Numeric type IndexOf Matrix = (Int, Int) type IndexOf Vector Instance detailsDefined in Internal.Numeric type IndexOf Vector = Int

class Element e => Container (c :: * -> *) e #

Basic element-by-element functions for numeric containers

Minimal complete definition

conj', size', scalar', scale', addConstant, add', sub, mul, equal, cmap', konst', build', atIndex', minIndex', maxIndex', minElement', maxElement', sumElements', prodElements', step', ccompare', cselect', find', assoc', accum', scaleRecip, divide, arctan2', cmod', fromInt', toInt', fromZ', toZ'

Instances
 (Num a, Element a, Container Vector a) => Container Matrix a Instance detailsDefined in Internal.Numeric Methodsconj' :: Matrix a -> Matrix asize' :: Matrix a -> IndexOf Matrixscalar' :: a -> Matrix ascale' :: a -> Matrix a -> Matrix aaddConstant :: a -> Matrix a -> Matrix aadd' :: Matrix a -> Matrix a -> Matrix asub :: Matrix a -> Matrix a -> Matrix amul :: Matrix a -> Matrix a -> Matrix aequal :: Matrix a -> Matrix a -> Boolcmap' :: Element b => (a -> b) -> Matrix a -> Matrix bkonst' :: a -> IndexOf Matrix -> Matrix abuild' :: IndexOf Matrix -> ArgOf Matrix a -> Matrix aatIndex' :: Matrix a -> IndexOf Matrix -> aminElement' :: Matrix a -> amaxElement' :: Matrix a -> asumElements' :: Matrix a -> aprodElements' :: Matrix a -> astep' :: Matrix a -> Matrix accompare' :: Matrix a -> Matrix a -> Matrix Icselect' :: Matrix I -> Matrix a -> Matrix a -> Matrix a -> Matrix afind' :: (a -> Bool) -> Matrix a -> [IndexOf Matrix]assoc' :: IndexOf Matrix -> a -> [(IndexOf Matrix, a)] -> Matrix aaccum' :: Matrix a -> (a -> a -> a) -> [(IndexOf Matrix, a)] -> Matrix ascaleRecip :: a -> Matrix a -> Matrix adivide :: Matrix a -> Matrix a -> Matrix aarctan2' :: Matrix a -> Matrix a -> Matrix acmod' :: a -> Matrix a -> Matrix atoInt' :: Matrix a -> Matrix IfromZ' :: Matrix Z -> Matrix atoZ' :: Matrix a -> Matrix Z Instance detailsDefined in Internal.Numeric Methodscmap' :: Element b => (Double -> b) -> Vector Double -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector Double -> Vector Doublefind' :: (Double -> Bool) -> Vector Double -> [IndexOf Vector]assoc' :: IndexOf Vector -> Double -> [(IndexOf Vector, Double)] -> Vector Doubleaccum' :: Vector Double -> (Double -> Double -> Double) -> [(IndexOf Vector, Double)] -> Vector Double Instance detailsDefined in Internal.Numeric Methodscmap' :: Element b => (Float -> b) -> Vector Float -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector Float -> Vector Floatfind' :: (Float -> Bool) -> Vector Float -> [IndexOf Vector]assoc' :: IndexOf Vector -> Float -> [(IndexOf Vector, Float)] -> Vector Floataccum' :: Vector Float -> (Float -> Float -> Float) -> [(IndexOf Vector, Float)] -> Vector Float Instance detailsDefined in Internal.Numeric Methodsscalar' :: I -> Vector Iscale' :: I -> Vector I -> Vector Isub :: Vector I -> Vector I -> Vector Imul :: Vector I -> Vector I -> Vector Iequal :: Vector I -> Vector I -> Boolcmap' :: Element b => (I -> b) -> Vector I -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector I -> Vector Ifind' :: (I -> Bool) -> Vector I -> [IndexOf Vector]assoc' :: IndexOf Vector -> I -> [(IndexOf Vector, I)] -> Vector Iaccum' :: Vector I -> (I -> I -> I) -> [(IndexOf Vector, I)] -> Vector Icmod' :: I -> Vector I -> Vector I Instance detailsDefined in Internal.Numeric Methodsscalar' :: Z -> Vector Zscale' :: Z -> Vector Z -> Vector Zsub :: Vector Z -> Vector Z -> Vector Zmul :: Vector Z -> Vector Z -> Vector Zequal :: Vector Z -> Vector Z -> Boolcmap' :: Element b => (Z -> b) -> Vector Z -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector Z -> Vector Zfind' :: (Z -> Bool) -> Vector Z -> [IndexOf Vector]assoc' :: IndexOf Vector -> Z -> [(IndexOf Vector, Z)] -> Vector Zaccum' :: Vector Z -> (Z -> Z -> Z) -> [(IndexOf Vector, Z)] -> Vector Zcmod' :: Z -> Vector Z -> Vector Z Instance detailsDefined in Internal.Numeric Methodsequal :: Vector (Complex Double) -> Vector (Complex Double) -> Boolcmap' :: Element b => (Complex Double -> b) -> Vector (Complex Double) -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector (Complex Double) -> Vector (Complex Double)find' :: (Complex Double -> Bool) -> Vector (Complex Double) -> [IndexOf Vector]accum' :: Vector (Complex Double) -> (Complex Double -> Complex Double -> Complex Double) -> [(IndexOf Vector, Complex Double)] -> Vector (Complex Double) Instance detailsDefined in Internal.Numeric Methodsequal :: Vector (Complex Float) -> Vector (Complex Float) -> Boolcmap' :: Element b => (Complex Float -> b) -> Vector (Complex Float) -> Vector bbuild' :: IndexOf Vector -> ArgOf Vector (Complex Float) -> Vector (Complex Float)find' :: (Complex Float -> Bool) -> Vector (Complex Float) -> [IndexOf Vector]accum' :: Vector (Complex Float) -> (Complex Float -> Complex Float -> Complex Float) -> [(IndexOf Vector, Complex Float)] -> Vector (Complex Float) KnownNat m => Container Vector (Mod m I) Instance detailsDefined in Internal.Modular Methodsconj' :: Vector (Mod m I) -> Vector (Mod m I)size' :: Vector (Mod m I) -> IndexOf Vectorscalar' :: Mod m I -> Vector (Mod m I)scale' :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)addConstant :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)add' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)sub :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)mul :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)equal :: Vector (Mod m I) -> Vector (Mod m I) -> Boolcmap' :: Element b => (Mod m I -> b) -> Vector (Mod m I) -> Vector bkonst' :: Mod m I -> IndexOf Vector -> Vector (Mod m I)build' :: IndexOf Vector -> ArgOf Vector (Mod m I) -> Vector (Mod m I)atIndex' :: Vector (Mod m I) -> IndexOf Vector -> Mod m IminIndex' :: Vector (Mod m I) -> IndexOf VectormaxIndex' :: Vector (Mod m I) -> IndexOf VectorminElement' :: Vector (Mod m I) -> Mod m ImaxElement' :: Vector (Mod m I) -> Mod m IsumElements' :: Vector (Mod m I) -> Mod m IprodElements' :: Vector (Mod m I) -> Mod m Istep' :: Vector (Mod m I) -> Vector (Mod m I)ccompare' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector Icselect' :: Vector I -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)find' :: (Mod m I -> Bool) -> Vector (Mod m I) -> [IndexOf Vector]assoc' :: IndexOf Vector -> Mod m I -> [(IndexOf Vector, Mod m I)] -> Vector (Mod m I)accum' :: Vector (Mod m I) -> (Mod m I -> Mod m I -> Mod m I) -> [(IndexOf Vector, Mod m I)] -> Vector (Mod m I)scaleRecip :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)divide :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)arctan2' :: Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)cmod' :: Mod m I -> Vector (Mod m I) -> Vector (Mod m I)fromInt' :: Vector I -> Vector (Mod m I)toInt' :: Vector (Mod m I) -> Vector IfromZ' :: Vector Z -> Vector (Mod m I)toZ' :: Vector (Mod m I) -> Vector Z KnownNat m => Container Vector (Mod m Z) Instance detailsDefined in Internal.Modular Methodsconj' :: Vector (Mod m Z) -> Vector (Mod m Z)size' :: Vector (Mod m Z) -> IndexOf Vectorscalar' :: Mod m Z -> Vector (Mod m Z)scale' :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)addConstant :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)add' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)sub :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)mul :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)equal :: Vector (Mod m Z) -> Vector (Mod m Z) -> Boolcmap' :: Element b => (Mod m Z -> b) -> Vector (Mod m Z) -> Vector bkonst' :: Mod m Z -> IndexOf Vector -> Vector (Mod m Z)build' :: IndexOf Vector -> ArgOf Vector (Mod m Z) -> Vector (Mod m Z)atIndex' :: Vector (Mod m Z) -> IndexOf Vector -> Mod m ZminIndex' :: Vector (Mod m Z) -> IndexOf VectormaxIndex' :: Vector (Mod m Z) -> IndexOf VectorminElement' :: Vector (Mod m Z) -> Mod m ZmaxElement' :: Vector (Mod m Z) -> Mod m ZsumElements' :: Vector (Mod m Z) -> Mod m ZprodElements' :: Vector (Mod m Z) -> Mod m Zstep' :: Vector (Mod m Z) -> Vector (Mod m Z)ccompare' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector Icselect' :: Vector I -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)find' :: (Mod m Z -> Bool) -> Vector (Mod m Z) -> [IndexOf Vector]assoc' :: IndexOf Vector -> Mod m Z -> [(IndexOf Vector, Mod m Z)] -> Vector (Mod m Z)accum' :: Vector (Mod m Z) -> (Mod m Z -> Mod m Z -> Mod m Z) -> [(IndexOf Vector, Mod m Z)] -> Vector (Mod m Z)scaleRecip :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)divide :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)arctan2' :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)cmod' :: Mod m Z -> Vector (Mod m Z) -> Vector (Mod m Z)fromInt' :: Vector I -> Vector (Mod m Z)toInt' :: Vector (Mod m Z) -> Vector IfromZ' :: Vector Z -> Vector (Mod m Z)toZ' :: Vector (Mod m Z) -> Vector Z

class Konst e d (c :: * -> *) | d -> c, c -> d where #

Minimal complete definition

konst

Methods

konst :: e -> d -> c e #

>>> konst 7 3 :: Vector Float
fromList [7.0,7.0,7.0]

>>> konst i (3::Int,4::Int)
(3><4)
[ 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0
, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0
, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 ]

Instances
 Instance detailsDefined in Internal.Numeric Methodskonst :: e -> Int -> Vector e # (Num e, Container Vector e) => Konst e (Int, Int) Matrix Instance detailsDefined in Internal.Numeric Methodskonst :: e -> (Int, Int) -> Matrix e #

class (Container Vector t, Container Matrix t, Konst t Int Vector, Konst t (Int, Int) Matrix, CTrans t, Product t, Additive (Vector t), Additive (Matrix t), Linear t Vector, Linear t Matrix) => Numeric t #

Instances
 Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric Instance detailsDefined in Internal.Numeric KnownNat m => Numeric (Mod m I) Instance detailsDefined in Internal.Modular KnownNat m => Numeric (Mod m Z) Instance detailsDefined in Internal.Modular

class (Num e, Element e) => Product e #

Matrix product and related functions

Minimal complete definition

multiply, absSum, norm1, norm2, normInf

Instances
 Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methods Instance detailsDefined in Internal.Numeric Methods KnownNat m => Product (Mod m I) Instance detailsDefined in Internal.Modular Methodsmultiply :: Matrix (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I)absSum :: Vector (Mod m I) -> RealOf (Mod m I)norm1 :: Vector (Mod m I) -> RealOf (Mod m I)norm2 :: Vector (Mod m I) -> RealOf (Mod m I)normInf :: Vector (Mod m I) -> RealOf (Mod m I) KnownNat m => Product (Mod m Z) Instance detailsDefined in Internal.Modular Methodsmultiply :: Matrix (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z)absSum :: Vector (Mod m Z) -> RealOf (Mod m Z)norm1 :: Vector (Mod m Z) -> RealOf (Mod m Z)norm2 :: Vector (Mod m Z) -> RealOf (Mod m Z)normInf :: Vector (Mod m Z) -> RealOf (Mod m Z)

class Convert t where #

Minimal complete definition

Methods

real :: Complexable c => c (RealOf t) -> c t #

complex :: Complexable c => c t -> c (ComplexOf t) #

single :: Complexable c => c t -> c (SingleOf t) #

double :: Complexable c => c t -> c (DoubleOf t) #

toComplex :: (Complexable c, RealElement t) => (c t, c t) -> c (Complex t) #

fromComplex :: (Complexable c, RealElement t) => c (Complex t) -> (c t, c t) #

Instances
 Instance detailsDefined in Internal.Numeric Methodsreal :: Complexable c => c (RealOf Double) -> c Double #complex :: Complexable c => c Double -> c (ComplexOf Double) #single :: Complexable c => c Double -> c (SingleOf Double) #double :: Complexable c => c Double -> c (DoubleOf Double) #toComplex :: (Complexable c, RealElement Double) => (c Double, c Double) -> c (Complex Double) #fromComplex :: (Complexable c, RealElement Double) => c (Complex Double) -> (c Double, c Double) # Instance detailsDefined in Internal.Numeric Methodsreal :: Complexable c => c (RealOf Float) -> c Float #complex :: Complexable c => c Float -> c (ComplexOf Float) #single :: Complexable c => c Float -> c (SingleOf Float) #double :: Complexable c => c Float -> c (DoubleOf Float) #toComplex :: (Complexable c, RealElement Float) => (c Float, c Float) -> c (Complex Float) #fromComplex :: (Complexable c, RealElement Float) => c (Complex Float) -> (c Float, c Float) # Instance detailsDefined in Internal.Numeric Methodsreal :: Complexable c => c (RealOf (Complex Double)) -> c (Complex Double) #complex :: Complexable c => c (Complex Double) -> c (ComplexOf (Complex Double)) #single :: Complexable c => c (Complex Double) -> c (SingleOf (Complex Double)) #double :: Complexable c => c (Complex Double) -> c (DoubleOf (Complex Double)) #toComplex :: (Complexable c, RealElement (Complex Double)) => (c (Complex Double), c (Complex Double)) -> c (Complex (Complex Double)) #fromComplex :: (Complexable c, RealElement (Complex Double)) => c (Complex (Complex Double)) -> (c (Complex Double), c (Complex Double)) # Instance detailsDefined in Internal.Numeric Methodsreal :: Complexable c => c (RealOf (Complex Float)) -> c (Complex Float) #complex :: Complexable c => c (Complex Float) -> c (ComplexOf (Complex Float)) #single :: Complexable c => c (Complex Float) -> c (SingleOf (Complex Float)) #double :: Complexable c => c (Complex Float) -> c (DoubleOf (Complex Float)) #toComplex :: (Complexable c, RealElement (Complex Float)) => (c (Complex Float), c (Complex Float)) -> c (Complex (Complex Float)) #fromComplex :: (Complexable c, RealElement (Complex Float)) => c (Complex (Complex Float)) -> (c (Complex Float), c (Complex Float)) #

type family RealOf x :: * #

Instances
 type RealOf Double Instance detailsDefined in Internal.Numeric type RealOf Double = Double type RealOf Float Instance detailsDefined in Internal.Numeric type RealOf Float = Float type RealOf I Instance detailsDefined in Internal.Numeric type RealOf I = I type RealOf Z Instance detailsDefined in Internal.Numeric type RealOf Z = Z type RealOf (Complex Double) Instance detailsDefined in Internal.Numeric type RealOf (Complex Double) = Double type RealOf (Complex Float) Instance detailsDefined in Internal.Numeric type RealOf (Complex Float) = Float type RealOf (Mod n Z) Instance detailsDefined in Internal.Modular type RealOf (Mod n Z) = Z type RealOf (Mod n I) Instance detailsDefined in Internal.Modular type RealOf (Mod n I) = I

type ComplexOf x = Complex (RealOf x) #

type family SingleOf x :: * #

Instances
 type SingleOf Double Instance detailsDefined in Internal.Numeric type SingleOf Double = Float type SingleOf Float Instance detailsDefined in Internal.Numeric type SingleOf Float = Float type SingleOf (Complex a) Instance detailsDefined in Internal.Numeric type SingleOf (Complex a) = Complex (SingleOf a)

type family DoubleOf x :: * #

Instances
 type DoubleOf Double Instance detailsDefined in Internal.Numeric type DoubleOf Double = Double type DoubleOf Float Instance detailsDefined in Internal.Numeric type DoubleOf Float = Double type DoubleOf (Complex a) Instance detailsDefined in Internal.Numeric type DoubleOf (Complex a) = Complex (DoubleOf a)

class Transposable m mt | m -> mt, mt -> m where #

Minimal complete definition

Methods

tr :: m -> mt #

conjugate transpose

tr' :: m -> mt #

transpose

Instances
 Instance detailsDefined in Internal.Sparse Methodstr :: CSR -> CSC #tr' :: CSR -> CSC # Instance detailsDefined in Internal.Sparse Methods Instance detailsDefined in Internal.Sparse Methodstr :: CSC -> CSR #tr' :: CSC -> CSR # (CTrans t, Container Vector t) => Transposable (Matrix t) (Matrix t) Instance detailsDefined in Internal.Numeric Methodstr :: Matrix t -> Matrix t #tr' :: Matrix t -> Matrix t #

Minimal complete definition

Methods

add :: c -> c -> c #

Instances
 Field t => Additive (Herm t) Instance detailsDefined in Internal.Algorithms Methodsadd :: Herm t -> Herm t -> Herm t # Instance detailsDefined in Internal.Numeric Methodsadd :: Matrix t -> Matrix t -> Matrix t # Instance detailsDefined in Internal.Numeric Methodsadd :: Vector t -> Vector t -> Vector t #

class Linear t (c :: * -> *) where #

Minimal complete definition

scale

Methods

scale :: t -> c t -> c t #

Instances
 Instance detailsDefined in Internal.Numeric Methodsscale :: t -> Vector t -> Vector t # Field t => Linear t Herm Instance detailsDefined in Internal.Algorithms Methodsscale :: t -> Herm t -> Herm t # Instance detailsDefined in Internal.Numeric Methodsscale :: t -> Matrix t -> Matrix t #

class Testable t where #

Minimal complete definition

checkT

Methods

checkT :: t -> (Bool, IO ()) #

ioCheckT :: t -> IO (Bool, IO ()) #

Instances
 KnownNat m => Testable (Matrix (Mod m I)) Instance detailsDefined in Internal.Modular MethodscheckT :: Matrix (Mod m I) -> (Bool, IO ()) #ioCheckT :: Matrix (Mod m I) -> IO (Bool, IO ()) #

data UpLo #

Constructors

 Lower Upper

class (Element t, Element (Complex t), RealFloat t) => RealElement t #

Supported real types

Instances
 Instance detailsDefined in Internal.Conversion Instance detailsDefined in Internal.Conversion

class Complexable (c :: * -> *) #

Structures that may contain complex numbers

Minimal complete definition

toComplex', fromComplex', comp', single', double'

Instances
 Instance detailsDefined in Internal.Conversion MethodstoComplex' :: RealElement e => (Matrix e, Matrix e) -> Matrix (Complex e)fromComplex' :: RealElement e => Matrix (Complex e) -> (Matrix e, Matrix e)comp' :: RealElement e => Matrix e -> Matrix (Complex e)single' :: Precision a b => Matrix b -> Matrix adouble' :: Precision a b => Matrix a -> Matrix b Instance detailsDefined in Internal.Conversion MethodstoComplex' :: RealElement e => (Vector e, Vector e) -> Vector (Complex e)fromComplex' :: RealElement e => Vector (Complex e) -> (Vector e, Vector e)comp' :: RealElement e => Vector e -> Vector (Complex e)single' :: Precision a b => Vector b -> Vector adouble' :: Precision a b => Vector a -> Vector b

toBlocksEvery :: Element t => Int -> Int -> Matrix t -> [[Matrix t]] #

Fully partition a matrix into blocks of the same size. If the dimensions are not a multiple of the given size the last blocks will be smaller.

toBlocks :: Element t => [Int] -> [Int] -> Matrix t -> [[Matrix t]] #

Partition a matrix into blocks with the given numbers of rows and columns. The remaining rows and columns are discarded.

repmat :: Element t => Matrix t -> Int -> Int -> Matrix t #

creates matrix by repetition of a matrix a given number of rows and columns

>>> repmat (ident 2) 2 3
(4><6)
[ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0
, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0
, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0
, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]


asColumn :: Storable a => Vector a -> Matrix a #

creates a 1-column matrix from a vector

>>> asColumn (fromList [1..5])
(5><1)
[ 1.0
, 2.0
, 3.0
, 4.0
, 5.0 ]


asRow :: Storable a => Vector a -> Matrix a #

creates a 1-row matrix from a vector

>>> asRow (fromList [1..5])
 (1><5)
[ 1.0, 2.0, 3.0, 4.0, 5.0 ]


fromLists :: Element t => [[t]] -> Matrix t #

Creates a Matrix from a list of lists (considered as rows).

>>> fromLists [[1,2],[3,4],[5,6]]
(3><2)
[ 1.0, 2.0
, 3.0, 4.0
, 5.0, 6.0 ]


dropColumns :: Element t => Int -> Matrix t -> Matrix t #

takeColumns :: Element t => Int -> Matrix t -> Matrix t #

dropRows :: Element t => Int -> Matrix t -> Matrix t #

takeRows :: Element t => Int -> Matrix t -> Matrix t #

(><) :: Storable a => Int -> Int -> [a] -> Matrix a #

Create a matrix from a list of elements

>>> (2><3) [2, 4, 7+2*iC,   -3, 11, 0]
(2><3)
[       2.0 :+ 0.0,  4.0 :+ 0.0, 7.0 :+ 2.0
, (-3.0) :+ (-0.0), 11.0 :+ 0.0, 0.0 :+ 0.0 ]


The input list is explicitly truncated, so that it can safely be used with lists that are too long (like infinite lists).

>>> (2><3)[1..]
(2><3)
[ 1.0, 2.0, 3.0
, 4.0, 5.0, 6.0 ]


This is the format produced by the instances of Show (Matrix a), which can also be used for input.

takeDiag :: Element t => Matrix t -> Vector t #

extracts the diagonal from a rectangular matrix

diagRect :: Storable t => t -> Vector t -> Int -> Int -> Matrix t #

creates a rectangular diagonal matrix:

>>> diagRect 7 (fromList [10,20,30]) 4 5 :: Matrix Double
(4><5)
[ 10.0,  7.0,  7.0, 7.0, 7.0
,  7.0, 20.0,  7.0, 7.0, 7.0
,  7.0,  7.0, 30.0, 7.0, 7.0
,  7.0,  7.0,  7.0, 7.0, 7.0 ]


fliprl :: Element t => Matrix t -> Matrix t #

Reverse columns

flipud :: Element t => Matrix t -> Matrix t #

Reverse rows

diagBlock :: (Element t, Num t) => [Matrix t] -> Matrix t #

create a block diagonal matrix

>>> disp 2 $diagBlock [konst 1 (2,2), konst 2 (3,5), col [5,7]] 7x8 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 2 2 2 2 2 0 0 0 2 2 2 2 2 0 0 0 2 2 2 2 2 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 7  >>> diagBlock [(0><4)[], konst 2 (2,3)] :: Matrix Double (2><7) [ 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0 , 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0 ]  fromBlocks :: Element t => [[Matrix t]] -> Matrix t # Create a matrix from blocks given as a list of lists of matrices. Single row-column components are automatically expanded to match the corresponding common row and column: disp = putStr . dispf 2  >>> disp$ fromBlocks [[ident 5, 7, row[10,20]], [3, diagl[1,2,3], 0]]
8x10
1  0  0  0  0  7  7  7  10  20
0  1  0  0  0  7  7  7  10  20
0  0  1  0  0  7  7  7  10  20
0  0  0  1  0  7  7  7  10  20
0  0  0  0  1  7  7  7  10  20
3  3  3  3  3  1  0  0   0   0
3  3  3  3  3  0  2  0   0   0
3  3  3  3  3  0  0  3   0   0


(??) :: Element t => Matrix t -> (Extractor, Extractor) -> Matrix t infixl 9 #

General matrix slicing.

>>> m
(4><5)
[  0,  1,  2,  3,  4
,  5,  6,  7,  8,  9
, 10, 11, 12, 13, 14
, 15, 16, 17, 18, 19 ]

>>> m ?? (Take 3, DropLast 2)
(3><3)
[  0,  1,  2
,  5,  6,  7
, 10, 11, 12 ]

>>> m ?? (Pos (idxs[2,1]), All)
(2><5)
[ 10, 11, 12, 13, 14
,  5,  6,  7,  8,  9 ]

>>> m ?? (PosCyc (idxs[-7,80]), Range 4 (-2) 0)
(2><3)
[ 9, 7, 5
, 4, 2, 0 ]


data Extractor #

Specification of indexes for the operator ??.

Constructors

 All Range Int Int Int Pos (Vector I) PosCyc (Vector I) Take Int TakeLast Int Drop Int DropLast Int
Instances
 Instance detailsDefined in Internal.Element MethodsshowList :: [Extractor] -> ShowS #

load a matrix from an ASCII file formatted as a 2D table.

dispcf :: Int -> Matrix (Complex Double) -> String #

Pretty print a complex matrix with at most n decimal digits.

Arguments

 :: String type of braces: "matrix", "bmatrix", "pmatrix", etc. -> String Formatted matrix, with elements separated by spaces and newlines -> String

Tool to display matrices with latex syntax.

>>> latexFormat "bmatrix" (dispf 2 $ident 2) "\\begin{bmatrix}\n1 & 0\n\\\\\n0 & 1\n\\end{bmatrix}"  Show a matrix with a given number of decimal places. >>> dispf 2 (1/3 + ident 3) "3x3\n1.33 0.33 0.33\n0.33 1.33 0.33\n0.33 0.33 1.33\n"  >>> putStr . dispf 2$ (3><4)[1,1.5..]
3x4
1.00  1.50  2.00  2.50
3.00  3.50  4.00  4.50
5.00  5.50  6.00  6.50

>>> putStr . unlines . tail . lines . dispf 2 . asRow $linspace 10 (0,1) 0.00 0.11 0.22 0.33 0.44 0.56 0.67 0.78 0.89 1.00  Show a matrix with "autoscaling" and a given number of decimal places. >>> putStr . disps 2$ 120 * (3><4) [1..]
3x4  E3
0.12  0.24  0.36  0.48
0.60  0.72  0.84  0.96
1.08  1.20  1.32  1.44


format :: Element t => String -> (t -> String) -> Matrix t -> String #

Creates a string from a matrix given a separator and a function to show each entry. Using this function the user can easily define any desired display function:

import Text.Printf(printf)
disp = putStr . format "  " (printf "%.2f")

Arguments

 :: FilePath -> String "printf" format (e.g. "%.2f", "%g", etc.) -> Matrix Double -> IO ()

save a matrix as a 2D ASCII table

Arguments

 :: Element a => (Int, Int) (r0,c0) starting position -> (Int, Int) (rt,ct) dimensions of submatrix -> Matrix a input matrix -> Matrix a result

reference to a rectangular slice of a matrix (no data copy)

reshape :: Storable t => Int -> Vector t -> Matrix t #

Creates a matrix from a vector by grouping the elements in rows with the desired number of columns. (GNU-Octave groups by columns. To do it you can define reshapeF r = tr' . reshape r where r is the desired number of rows.)

>>> reshape 4 (fromList [1..12])
(3><4)
[ 1.0,  2.0,  3.0,  4.0
, 5.0,  6.0,  7.0,  8.0
, 9.0, 10.0, 11.0, 12.0 ]


toColumns :: Element t => Matrix t -> [Vector t] #

Creates a list of vectors from the columns of a matrix

fromColumns :: Element t => [Vector t] -> Matrix t #

Creates a matrix from a list of vectors, as columns

toRows :: Element t => Matrix t -> [Vector t] #

extracts the rows of a matrix as a list of vectors

fromRows :: Element t => [Vector t] -> Matrix t #

Create a matrix from a list of vectors. All vectors must have the same dimension, or dimension 1, which is are automatically expanded.

toLists :: Element t => Matrix t -> [[t]] #

the inverse of fromLists

flatten :: Element t => Matrix t -> Vector t #

Creates a vector by concatenation of rows. If the matrix is ColumnMajor, this operation requires a transpose.

>>> flatten (ident 3)
fromList [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]


cols :: Matrix t -> Int #

rows :: Matrix t -> Int #

data Matrix t #

Matrix representation suitable for BLAS/LAPACK computations.

Instances
 Instance detailsDefined in Internal.Container MethodslinSolve :: Field t => Matrix t -> Matrix t -> Matrix t Instance detailsDefined in Internal.Conversion MethodstoComplex' :: RealElement e => (Matrix e, Matrix e) -> Matrix (Complex e)fromComplex' :: RealElement e => Matrix (Complex e) -> (Matrix e, Matrix e)comp' :: RealElement e => Matrix e -> Matrix (Complex e)single' :: Precision a b => Matrix b -> Matrix adouble' :: Precision a b => Matrix a -> Matrix b Normed Matrix Double Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Matrix Double -> RealOf Double Normed Matrix Float Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Matrix Float -> RealOf Float (Num a, Element a, Container Vector a) => Container Matrix a Instance detailsDefined in Internal.Numeric Methodsconj' :: Matrix a -> Matrix asize' :: Matrix a -> IndexOf Matrixscalar' :: a -> Matrix ascale' :: a -> Matrix a -> Matrix aaddConstant :: a -> Matrix a -> Matrix aadd' :: Matrix a -> Matrix a -> Matrix asub :: Matrix a -> Matrix a -> Matrix amul :: Matrix a -> Matrix a -> Matrix aequal :: Matrix a -> Matrix a -> Boolcmap' :: Element b => (a -> b) -> Matrix a -> Matrix bkonst' :: a -> IndexOf Matrix -> Matrix abuild' :: IndexOf Matrix -> ArgOf Matrix a -> Matrix aatIndex' :: Matrix a -> IndexOf Matrix -> aminElement' :: Matrix a -> amaxElement' :: Matrix a -> asumElements' :: Matrix a -> aprodElements' :: Matrix a -> astep' :: Matrix a -> Matrix accompare' :: Matrix a -> Matrix a -> Matrix Icselect' :: Matrix I -> Matrix a -> Matrix a -> Matrix a -> Matrix afind' :: (a -> Bool) -> Matrix a -> [IndexOf Matrix]assoc' :: IndexOf Matrix -> a -> [(IndexOf Matrix, a)] -> Matrix aaccum' :: Matrix a -> (a -> a -> a) -> [(IndexOf Matrix, a)] -> Matrix ascaleRecip :: a -> Matrix a -> Matrix adivide :: Matrix a -> Matrix a -> Matrix aarctan2' :: Matrix a -> Matrix a -> Matrix acmod' :: a -> Matrix a -> Matrix atoInt' :: Matrix a -> Matrix IfromZ' :: Matrix Z -> Matrix atoZ' :: Matrix a -> Matrix Z Instance detailsDefined in Internal.Numeric Methodsscale :: t -> Matrix t -> Matrix t # Instance detailsDefined in Internal.Container Methods(<>) :: Product t => Matrix t -> Matrix t -> Matrix t Instance detailsDefined in Internal.Container Methods(<>) :: Product t => Matrix t -> Vector t -> Vector t Instance detailsDefined in Internal.Container Methods(<>) :: Product t => Vector t -> Matrix t -> Vector t Normed Matrix (Complex Double) Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Matrix (Complex Double) -> RealOf (Complex Double) Normed Matrix (Complex Float) Instance detailsDefined in Internal.Algorithms Methodspnorm :: NormType -> Matrix (Complex Float) -> RealOf (Complex Float) (Num e, Container Vector e) => Konst e (Int, Int) Matrix Instance detailsDefined in Internal.Numeric Methodskonst :: e -> (Int, Int) -> Matrix e # (Storable t, NFData t) => NFData (Matrix t) Instance detailsDefined in Internal.Matrix Methodsrnf :: Matrix t -> () # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Matrix R -> R #norm_1 :: Matrix R -> R #norm_2 :: Matrix R -> R # Instance detailsDefined in Internal.Util Methodsnorm_0 :: Matrix C -> R #norm_1 :: Matrix C -> R #norm_2 :: Matrix C -> R # Instance detailsDefined in Internal.Numeric Methodsadd :: Matrix t -> Matrix t -> Matrix t # KnownNat m => Testable (Matrix (Mod m I)) Instance detailsDefined in Internal.Modular MethodscheckT :: Matrix (Mod m I) -> (Bool, IO ()) #ioCheckT :: Matrix (Mod m I) -> IO (Bool, IO ()) # Storable t => TransArray (Matrix t) Instance detailsDefined in Internal.Matrix Associated Typestype Trans (Matrix t) b :: * #type TransRaw (Matrix t) b :: * # Methodsapply :: Matrix t -> (b -> IO r) -> Trans (Matrix t) b -> IO r #applyRaw :: Matrix t -> (b -> IO r) -> TransRaw (Matrix t) b -> IO r # Element t => Indexable (Matrix t) (Vector t) Instance detailsDefined in Internal.Util Methods(!) :: Matrix t -> Int -> Vector t # (CTrans t, Container Vector t) => Transposable (Matrix t) (Matrix t) Instance detailsDefined in Internal.Numeric Methodstr :: Matrix t -> Matrix t #tr' :: Matrix t -> Matrix t # Container Matrix e => Build (Int, Int) (e -> e -> e) Matrix e Instance detailsDefined in Internal.Container Methodsbuild :: (Int, Int) -> (e -> e -> e) -> Matrix e # type IndexOf Matrix Instance detailsDefined in Internal.Numeric type IndexOf Matrix = (Int, Int) type ArgOf Matrix a Instance detailsDefined in Internal.Numeric type ArgOf Matrix a = a -> a -> a type ElementOf (Matrix a) Instance detailsDefined in Internal.Numeric type ElementOf (Matrix a) = a type TransRaw (Matrix t) b Instance detailsDefined in Internal.Matrix type TransRaw (Matrix t) b = CInt -> CInt -> Ptr t -> b type Trans (Matrix t) b Instance detailsDefined in Internal.Matrix type Trans (Matrix t) b = CInt -> CInt -> CInt -> CInt -> Ptr t -> b

class Storable a => Element a #

Supported matrix elements.

Minimal complete definition

constantD, extractR, setRect, sortI, sortV, compareV, selectV, remapM, rowOp, gemm, reorderV

Instances
 Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix Double -> Matrix Double -> IO ()rowOp :: Int -> Double -> Int -> Int -> Int -> Int -> Matrix Double -> IO () Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix Float -> Matrix Float -> IO ()rowOp :: Int -> Float -> Int -> Int -> Int -> Int -> Matrix Float -> IO () Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix CInt -> Matrix CInt -> IO ()rowOp :: Int -> CInt -> Int -> Int -> Int -> Int -> Matrix CInt -> IO ()gemm :: Vector CInt -> Matrix CInt -> Matrix CInt -> Matrix CInt -> IO () Instance detailsDefined in Internal.Matrix MethodsconstantD :: Z -> Int -> Vector ZextractR :: MatrixOrder -> Matrix Z -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix Z)setRect :: Int -> Int -> Matrix Z -> Matrix Z -> IO ()rowOp :: Int -> Z -> Int -> Int -> Int -> Int -> Matrix Z -> IO ()gemm :: Vector Z -> Matrix Z -> Matrix Z -> Matrix Z -> IO () Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix (Complex Double) -> Matrix (Complex Double) -> IO ()rowOp :: Int -> Complex Double -> Int -> Int -> Int -> Int -> Matrix (Complex Double) -> IO ()gemm :: Vector (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -> IO () Instance detailsDefined in Internal.Matrix MethodssetRect :: Int -> Int -> Matrix (Complex Float) -> Matrix (Complex Float) -> IO ()rowOp :: Int -> Complex Float -> Int -> Int -> Int -> Int -> Matrix (Complex Float) -> IO ()gemm :: Vector (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex Float) -> IO () KnownNat m => Element (Mod m I) Instance detailsDefined in Internal.Modular MethodsconstantD :: Mod m I -> Int -> Vector (Mod m I)extractR :: MatrixOrder -> Matrix (Mod m I) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Mod m I))setRect :: Int -> Int -> Matrix (Mod m I) -> Matrix (Mod m I) -> IO ()sortI :: Vector (Mod m I) -> Vector CIntsortV :: Vector (Mod m I) -> Vector (Mod m I)compareV :: Vector (Mod m I) -> Vector (Mod m I) -> Vector CIntselectV :: Vector CInt -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I) -> Vector (Mod m I)remapM :: Matrix CInt -> Matrix CInt -> Matrix (Mod m I) -> Matrix (Mod m I)rowOp :: Int -> Mod m I -> Int -> Int -> Int -> Int -> Matrix (Mod m I) -> IO ()gemm :: Vector (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) -> Matrix (Mod m I) -> IO ()reorderV :: Vector CInt -> Vector CInt -> Vector (Mod m I) -> Vector (Mod m I) KnownNat m => Element (Mod m Z) Instance detailsDefined in Internal.Modular MethodsconstantD :: Mod m Z -> Int -> Vector (Mod m Z)extractR :: MatrixOrder -> Matrix (Mod m Z) -> CInt -> Vector CInt -> CInt -> Vector CInt -> IO (Matrix (Mod m Z))setRect :: Int -> Int -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> IO ()sortI :: Vector (Mod m Z) -> Vector CIntsortV :: Vector (Mod m Z) -> Vector (Mod m Z)compareV :: Vector (Mod m Z) -> Vector (Mod m Z) -> Vector CIntselectV :: Vector CInt -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z) -> Vector (Mod m Z)remapM :: Matrix CInt -> Matrix CInt -> Matrix (Mod m Z) -> Matrix (Mod m Z)rowOp :: Int -> Mod m Z -> Int -> Int -> Int -> Int -> Matrix (Mod m Z) -> IO ()gemm :: Vector (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> Matrix (Mod m Z) -> IO ()reorderV :: Vector CInt -> Vector CInt -> Vector (Mod m Z) -> Vector (Mod m Z)

range :: Int -> Vector I #

>>> range 5
fromList [0,1,2,3,4]


Arguments

 :: Seed -> RandDist distribution -> Int vector size -> Vector Double

Obtains a vector of pseudorandom elements (use randomIO to get a random seed).

type Seed = Int #

data RandDist #

Constructors

 Uniform uniform distribution in [0,1) Gaussian normal distribution with mean zero and standard deviation one
Instances
 Instance detailsDefined in Internal.Vectorized MethodsenumFrom :: RandDist -> [RandDist] #enumFromTo :: RandDist -> RandDist -> [RandDist] #

takesV :: Storable t => [Int] -> Vector t -> [Vector t] #

Extract consecutive subvectors of the given sizes.

>>> takesV [3,4] (linspace 10 (1,10::Double))
[fromList [1.0,2.0,3.0],fromList [4.0,5.0,6.0,7.0]]


vjoin :: Storable t => [Vector t] -> Vector t #

concatenate a list of vectors

>>> vjoin [fromList [1..5::Double], konst 1 3]
fromList [1.0,2.0,3.0,4.0,5.0,1.0,1.0,1.0]


Arguments

 :: Storable t => Int index of the starting element -> Int number of elements to extract -> Vector t source -> Vector t result

takes a number of consecutive elements from a Vector

>>> subVector 2 3 (fromList [1..10])
fromList [3.0,4.0,5.0]


idxs :: [Int] -> Vector I #

Create a vector of indexes, useful for matrix extraction using '(??)'

toList :: Storable a => Vector a -> [a] #

type I = CInt #

type Z = Int64 #

type R = Double #

type C = Complex Double #

data Vector a #

Storable-based vectors

Instances