sparse-linear-algebra-0.2.2.0: Numerical computation in native Haskell

Numeric.LinearAlgebra.Class

Synopsis

class Functor f => Additive f where Source #

Minimal complete definition

Methods

zero :: Num a => f a Source #

Ring zero element

(^+^) :: Num a => f a -> f a -> f a Source #

Ring +

one :: Num a => f a Source #

(^*^) :: Num a => f a -> f a -> f a Source #

Instances

 Source # SpMatrixes form a ring, in that they can be added and possess a zero element Methodszero :: Num a => SpMatrix a Source #(^+^) :: Num a => SpMatrix a -> SpMatrix a -> SpMatrix a Source #one :: Num a => SpMatrix a Source #(^*^) :: Num a => SpMatrix a -> SpMatrix a -> SpMatrix a Source # Source # Methodszero :: Num a => SpVector a Source #(^+^) :: Num a => SpVector a -> SpVector a -> SpVector a Source #one :: Num a => SpVector a Source #(^*^) :: Num a => SpVector a -> SpVector a -> SpVector a Source #

negated :: (Num a, Functor f) => f a -> f a Source #

negate the values in a functor

(^-^) :: (Additive f, Num a) => f a -> f a -> f a Source #

# Vector space

class Additive f => VectorSpace f where Source #

Minimal complete definition

(.*)

Methods

(.*) :: Num a => a -> f a -> f a Source #

multiplication by a scalar

Instances

 Source # SpVectors form a vector space because they can be multiplied by a scalar Methods(.*) :: Num a => a -> SpVector a -> SpVector a Source #

lerp :: (VectorSpace f, Num a) => a -> f a -> f a -> f a Source #

linear interpolation

# Hilbert space (inner product)

class VectorSpace f => Hilbert f where Source #

Minimal complete definition

dot

Methods

dot :: Num a => f a -> f a -> a Source #

inner product

Instances

 Source # SpVectors form a Hilbert space, in that we can define an inner product over them Methodsdot :: Num a => SpVector a -> SpVector a -> a Source #

## Hilbert-space distance function

hilbertDistSq :: (Hilbert f, Num a) => f a -> f a -> a Source #

hilbertDistSq x y = || x - y ||^2

# Normed vector space

class Hilbert f => Normed f where Source #

Minimal complete definition

norm

Methods

norm :: (Floating a, Eq a) => a -> f a -> a Source #

Instances

 Source # Since SpVectors form a Hilbert space, we can define a norm for them Methodsnorm :: (Floating a, Eq a) => a -> SpVector a -> a Source #

## Norms and related results

normSq :: (Hilbert f, Num a) => f a -> a Source #

Squared 2-norm

norm1 :: (Foldable t, Num a, Functor t) => t a -> a Source #

L1 norm

norm2 :: (Hilbert f, Floating a) => f a -> a Source #

Euclidean norm

normP :: (Foldable t, Functor t, Floating a) => a -> t a -> a Source #

Lp norm (p > 0)

normInfty :: (Foldable t, Ord a) => t a -> a Source #

Infinity-norm

normalize :: (Normed f, Floating a, Eq a) => a -> f a -> f a Source #

Normalize w.r.t. p-norm (p finite)

dotLp :: (Set t, Foldable t, Floating a) => a -> t a -> t a -> a Source #

Lp inner product (p > 0)

reciprocal :: (Functor f, Fractional b) => f b -> f b Source #

Reciprocal

scale :: (Num b, Functor f) => b -> f b -> f b Source #

Scale

# FiniteDim : finite-dimensional objects

class Additive f => FiniteDim f where Source #

Minimal complete definition

dim

Associated Types

type FDSize f :: * Source #

Methods

dim :: f a -> FDSize f Source #

Instances

 Source # SpMatrixes are maps between finite-dimensional spaces Associated Typestype FDSize (SpMatrix :: * -> *) :: * Source # Methods Source # SpVectors are finite-dimensional vectors Associated Typestype FDSize (SpVector :: * -> *) :: * Source # Methods

withDim :: (FiniteDim f, Show e) => f a -> (FDSize f -> f a -> Bool) -> (f a -> c) -> String -> (f a -> e) -> c Source #

unary dimension-checking bracket

withDim2 :: (FiniteDim f, FiniteDim g, Show e) => f a -> g b -> (FDSize f -> FDSize g -> f a -> g b -> Bool) -> (f a -> g b -> c) -> String -> (f a -> g b -> e) -> c Source #

binary dimension-checking bracket

# HasData : accessing inner data (do not export)

class Additive f => HasData f a where Source #

Minimal complete definition

dat

Associated Types

type HDData f a :: * Source #

Methods

dat :: f a -> HDData f a Source #

Instances

 Source # Associated Typestype HDData (SpMatrix :: * -> *) a :: * Source # Methods Source # Associated Typestype HDData (SpVector :: * -> *) a :: * Source # Methods

# Sparse : sparse datastructures

class (FiniteDim f, HasData f a) => Sparse f a where Source #

Minimal complete definition

spy

Methods

spy :: Fractional b => f a -> b Source #

Instances

 Source # Methodsspy :: Fractional b => SpMatrix a -> b Source # Source # Methodsspy :: Fractional b => SpVector a -> b Source #

# Set : types that behave as sets

class Functor f => Set f where Source #

Minimal complete definition

Methods

liftU2 :: (a -> a -> a) -> f a -> f a -> f a Source #

union binary lift : apply function on _union_ of two Sets

liftI2 :: (a -> b -> c) -> f a -> f b -> f c Source #

intersection binary lift : apply function on _intersection_ of two Sets

Instances

 Source # MethodsliftU2 :: (a -> a -> a) -> SpMatrix a -> SpMatrix a -> SpMatrix a Source #liftI2 :: (a -> b -> c) -> SpMatrix a -> SpMatrix b -> SpMatrix c Source # Source # MethodsliftU2 :: (a -> a -> a) -> SpVector a -> SpVector a -> SpVector a Source #liftI2 :: (a -> b -> c) -> SpVector a -> SpVector b -> SpVector c Source #

class Sparse c a => SpContainer c a where Source #

Minimal complete definition

Associated Types

type ScIx c :: * Source #

Methods

scInsert :: ScIx c -> a -> c a -> c a Source #

scLookup :: c a -> ScIx c -> Maybe a Source #

(@@) :: c a -> ScIx c -> a Source #

Instances

 Source # SpMatrixes are sparse containers too, i.e. any specific component may be missing (so it is assumed to be 0) Associated Typestype ScIx (SpMatrix :: * -> *) :: * Source # MethodsscInsert :: ScIx SpMatrix -> a -> SpMatrix a -> SpMatrix a Source #(@@) :: SpMatrix a -> ScIx SpMatrix -> a Source # Source # SpVectors are sparse containers too, i.e. any specific component may be missing (so it is assumed to be 0) Associated Typestype ScIx (SpVector :: * -> *) :: * Source # MethodsscInsert :: ScIx SpVector -> a -> SpVector a -> SpVector a Source #(@@) :: SpVector a -> ScIx SpVector -> a Source #