lapack-0.5.1: Numerical Linear Algebra using LAPACK

Safe HaskellNone
LanguageHaskell98

Numeric.LAPACK.Vector

Synopsis

Documentation

type family RealOf x :: Type #

Instances
type RealOf Double 
Instance details

Defined in Numeric.BLAS.Scalar

type RealOf Float 
Instance details

Defined in Numeric.BLAS.Scalar

type RealOf (Complex a) 
Instance details

Defined in Numeric.BLAS.Scalar

type RealOf (Complex a) = a

type ComplexOf x = Complex (RealOf x) #

toList :: (C sh, Storable a) => Vector sh a -> [a] #

fromList :: (C sh, Storable a) => sh -> [a] -> Vector sh a #

append :: (C shx, C shy, Storable a) => Array shx a -> Array shy a -> Array (shx ::+ shy) a infixr 5 #

(+++) :: (C shx, C shy, Storable a) => Vector shx a -> Vector shy a -> Vector (shx ::+ shy) a infixr 5 #

Precedence and associativity (right) of (List.++). This also matches '(::+)'.

\(ArbVector xs) (ArbVector ys) (ArbVector zs) -> Vector.toList ((xs +++ ys) +++ zs) == Vector.toList (xs +++ (ys +++ zs))

take :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a #

\(QC.NonNegative n) (Array16 x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))

drop :: (Integral n, Storable a) => n -> Array (ZeroBased n) a -> Array (ZeroBased n) a #

\(QC.NonNegative n) (Array16 x)  ->  x == Array.mapShape (Shape.ZeroBased . Shape.size) (Array.append (Array.take n x) (Array.drop n x))

takeLeft :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh0 a #

\(Array16 x) (Array16 y) -> let xy = Array.append x y in x == Array.takeLeft xy  &&  y == Array.takeRight xy

takeRight :: (C sh0, C sh1, Storable a) => Array (sh0 ::+ sh1) a -> Array sh1 a #

swap :: (Indexed sh, Storable a) => Index sh -> Index sh -> Vector sh a -> Vector sh a #

QC.forAll (QC.choose (1,100)) $ \dim -> QC.forAll (QC.choose (0, dim-1)) $ \i -> QC.forAll (QC.choose (0, dim-1)) $ \j -> Vector.unit (Shape.ZeroBased dim) i == (Vector.swap i j (Vector.unit (Shape.ZeroBased dim) j) :: Vector Number_)

singleton :: Storable a => a -> Array () a #

\x  ->  Array.singleton x ! () == (x::Word16)

constant :: (C sh, Floating a) => sh -> a -> Vector sh a #

constant () = singleton

However, singleton does not need Floating constraint.

zero :: (C sh, Floating a) => sh -> Vector sh a #

one :: (C sh, Floating a) => sh -> Vector sh a #

unit :: (Indexed sh, Floating a) => sh -> Index sh -> Vector sh a #

dot :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> a #

dot x y = Matrix.toScalar (singleRow x -*| singleColumn y)

inner :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> a #

\(ArbVector2 xs ys) -> Vector.inner xs ys == Vector.dot (Vector.conjugate xs) ys

(-*|) :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> a infixl 7 #

dot x y = Matrix.toScalar (singleRow x -*| singleColumn y)

sum :: (C sh, Floating a) => Vector sh a -> a #

\(ArbVector xs) -> Vector.sum xs == List.sum (Vector.toList xs)

absSum :: (C sh, Floating a) => Vector sh a -> RealOf a #

Sum of the absolute values of real numbers or components of complex numbers. For real numbers it is equivalent to norm1.

norm1 :: (C sh, Floating a) => Vector sh a -> RealOf a Source #

norm2 :: (C sh, Floating a) => Vector sh a -> RealOf a #

Euclidean norm of a vector or Frobenius norm of a matrix.

norm2Squared :: (C sh, Floating a) => Vector sh a -> RealOf a #

normInf :: (C sh, Floating a) => Vector sh a -> RealOf a Source #

normInf1 :: (C sh, Floating a) => Vector sh a -> RealOf a #

Computes (almost) the infinity norm of the vector. For complex numbers every element is replaced by the sum of the absolute component values first.

argAbsMaximum :: (InvIndexed sh, Floating a) => Vector sh a -> (Index sh, a) Source #

Returns the index and value of the element with the maximal absolute value. Caution: It actually returns the value of the element, not its absolute value!

argAbs1Maximum :: (InvIndexed sh, Floating a) => Vector sh a -> (Index sh, a) #

Returns the index and value of the element with the maximal absolute value. The function does not strictly compare the absolute value of a complex number but the sum of the absolute complex components. Caution: It actually returns the value of the element, not its absolute value!

>>> Vector.argAbs1Maximum $ Vector.autoFromList [1:+2, 3:+4, 5, 6 :: Complex_]
(1,3.0 :+ 4.0)
\(ArbRealVector xs) -> isNonEmpty xs ==> Vector.argAbsMaximum xs == Vector.argAbs1Maximum xs

product :: (C sh, Floating a) => Vector sh a -> a #

QC.forAll (QC.choose (0,10)) $ \dim -> QC.forAll (genVector 3 dim) $ \xs -> approx 1e-2 (Vector.product xs) (List.product (Vector.toList (xs :: Vector Number_)))

scale :: (C sh, Floating a) => a -> Vector sh a -> Vector sh a #

\(ArbVector xs) -> Vector.negate xs == Vector.scale minusOne xs
\(ArbVector xs) -> Vector.scale 2 xs == xs |+| xs

scaleReal :: (C sh, Floating a) => RealOf a -> Vector sh a -> Vector sh a #

(.*|) :: (C sh, Floating a) => a -> Vector sh a -> Vector sh a infixl 7 #

\(ArbVector xs) -> Vector.negate xs == Vector.scale minusOne xs
\(ArbVector xs) -> Vector.scale 2 xs == xs |+| xs

add :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a infixl 6 #

\(ArbVector2 xs ys) -> xs |+| ys == ys |+| xs
\(ArbVector2 xs ys) -> xs == xs |-| ys |+| ys

sub :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a infixl 6 #

\(ArbVector2 xs ys) -> xs |+| ys == ys |+| xs
\(ArbVector2 xs ys) -> xs == xs |-| ys |+| ys

(|+|) :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a infixl 6 #

\(ArbVector2 xs ys) -> xs |+| ys == ys |+| xs
\(ArbVector2 xs ys) -> xs == xs |-| ys |+| ys

(|-|) :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a infixl 6 #

\(ArbVector2 xs ys) -> xs |+| ys == ys |+| xs
\(ArbVector2 xs ys) -> xs == xs |-| ys |+| ys

negate :: (C sh, Floating a) => Vector sh a -> Vector sh a #

\(ArbVector xs) -> xs == Vector.negate (Vector.negate xs)

raise :: (C sh, Floating a) => a -> Vector sh a -> Vector sh a #

QC.forAll (genNumber maxElem) $ \d (ArbVector xs) -> xs == Vector.raise (-d) (Vector.raise d xs)

mac :: (C sh, Eq sh, Floating a) => a -> Vector sh a -> Vector sh a -> Vector sh a #

mul :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a #

\(ArbVector2 xs ys) -> Vector.mul xs ys == Vector.mul ys xs

mulConj :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a #

\(ArbVector2 xs ys) -> Vector.mulConj xs ys == Vector.mul (Vector.conjugate xs) ys

divide :: (C sh, Eq sh, Floating a) => Vector sh a -> Vector sh a -> Vector sh a Source #

recip :: (C sh, Floating a) => Vector sh a -> Vector sh a Source #

minimum :: (C sh, Real a) => Vector sh a -> a #

For restrictions see limits.

\(ArbRealVector xs) -> isNonEmpty xs ==> Vector.minimum xs == List.minimum (Vector.toList xs)
\(ArbRealVector xs) -> isNonEmpty xs ==> Vector.maximum xs == List.maximum (Vector.toList xs)
\(ArbRealVector xs) -> isNonEmpty xs ==> - Vector.maximum xs == Vector.minimum (Vector.negate xs)

argMinimum :: (InvIndexed sh, Index sh ~ ix, Real a) => Vector sh a -> (ix, a) #

For restrictions see limits.

maximum :: (C sh, Real a) => Vector sh a -> a #

For restrictions see limits.

\(ArbRealVector xs) -> isNonEmpty xs ==> Vector.minimum xs == List.minimum (Vector.toList xs)
\(ArbRealVector xs) -> isNonEmpty xs ==> Vector.maximum xs == List.maximum (Vector.toList xs)
\(ArbRealVector xs) -> isNonEmpty xs ==> - Vector.maximum xs == Vector.minimum (Vector.negate xs)

argMaximum :: (InvIndexed sh, Index sh ~ ix, Real a) => Vector sh a -> (ix, a) #

For restrictions see limits.

limits :: (C sh, Real a) => Vector sh a -> (a, a) #

\(ArbRealVector xs) -> isNonEmpty xs ==> Vector.limits xs == Array.limits xs

In contrast to limits this implementation is based on fast BLAS functions. It should be faster than Array.minimum and Array.maximum although it is certainly not as fast as possible. Boths limits share the precision of the limit with the larger absolute value. This implies for example that you cannot rely on the property that raise (- minimum x) x has only non-negative elements.

argLimits :: (InvIndexed sh, Index sh ~ ix, Real a) => Vector sh a -> ((ix, a), (ix, a)) #

For restrictions see limits.

foldl :: (C sh, Storable a) => (b -> a -> b) -> b -> Array sh a -> b #

foldl1 :: (C sh, Storable a) => (a -> a -> a) -> Array sh a -> a #

foldMap :: (C sh, Storable a, Ord a, Semigroup m) => (a -> m) -> Array sh a -> m #

conjugate :: (C sh, Floating a) => Vector sh a -> Vector sh a Source #

fromReal :: (C sh, Floating a) => Vector sh (RealOf a) -> Vector sh a #

toComplex :: (C sh, Floating a) => Vector sh a -> Vector sh (ComplexOf a) #

realPart :: (C sh, Floating a) => Vector sh a -> Vector sh (RealOf a) #

imaginaryPart :: (C sh, Real a) => Vector sh (Complex a) -> Vector sh a #

zipComplex :: (C sh, Eq sh, Real a) => Vector sh a -> Vector sh a -> Vector sh (Complex a) #

unzipComplex :: (C sh, Real a) => Vector sh (Complex a) -> (Vector sh a, Vector sh a) #

random :: (C sh, Floating a) => RandomDistribution -> sh -> Word64 -> Vector sh a Source #

data RandomDistribution Source #

Instances
Enum RandomDistribution Source # 
Instance details

Defined in Numeric.LAPACK.Vector

Eq RandomDistribution Source # 
Instance details

Defined in Numeric.LAPACK.Vector

Ord RandomDistribution Source # 
Instance details

Defined in Numeric.LAPACK.Vector

Show RandomDistribution Source # 
Instance details

Defined in Numeric.LAPACK.Vector