free-vector-spaces-0.1.5.0: Instantiate the classes from the vector-space package with types from linear

Copyright (c) Justus Sagemüller 2016 GPL v3 (@) sagemueller \$ geo.uni-koeln.de experimental portable None Haskell2010

Data.VectorSpace.Free.FiniteSupportedSequence

Description

Synopsis

# Documentation

newtype FinSuppSeq n Source #

The space of finitely-supported sequences is an infinite-dimensional space. An vector of length l is here understood as an infinite sequence that begins with l nonzero values, and continues with infinite zeroes.

You may also consider this as the type that languages like Octave/Matlab (as well as Haskell's hmatrix library) approximate with their “vectors”, with one important difference: there is no such thing as a dimensional-mismatch error, since we consider all these vectors as elements of the same infinite-dimensional space. Adding two different-size vectors will simply zero-pad the shorter, and unlike in Matlab this behaviour extends consequently to matrix multiplication etc. (defined in linearmap-category)

Of course it can make sense to constrain the dimension, but for this the type system should be used, not runtime checks.

(This is the same behaviour that the linear library gives to the standard list and vector types, but the problem there is that it can't use unboxed arrays as these are not functors, but unboxing is crucial for performance.)

Constructors

 FinSuppSeq FieldsgetFiniteSeq :: Vector n

Instances

 Unbox n => IsList (FinSuppSeq n) Source # Associated Typestype Item (FinSuppSeq n) :: * # MethodsfromList :: [Item (FinSuppSeq n)] -> FinSuppSeq n #fromListN :: Int -> [Item (FinSuppSeq n)] -> FinSuppSeq n #toList :: FinSuppSeq n -> [Item (FinSuppSeq n)] # (Unbox n, Show n) => Show (FinSuppSeq n) Source # MethodsshowsPrec :: Int -> FinSuppSeq n -> ShowS #show :: FinSuppSeq n -> String #showList :: [FinSuppSeq n] -> ShowS # (Num n, Unbox n) => AffineSpace (FinSuppSeq n) Source # Associated Typestype Diff (FinSuppSeq n) :: * # Methods(.-.) :: FinSuppSeq n -> FinSuppSeq n -> Diff (FinSuppSeq n) #(.+^) :: FinSuppSeq n -> Diff (FinSuppSeq n) -> FinSuppSeq n # (Num n, Unbox n) => HasBasis (FinSuppSeq n) Source # Associated Typestype Basis (FinSuppSeq n) :: * # MethodsbasisValue :: Basis (FinSuppSeq n) -> FinSuppSeq n #decompose :: FinSuppSeq n -> [(Basis (FinSuppSeq n), Scalar (FinSuppSeq n))] #decompose' :: FinSuppSeq n -> Basis (FinSuppSeq n) -> Scalar (FinSuppSeq n) # (Num n, Unbox n) => VectorSpace (FinSuppSeq n) Source # Associated Typestype Scalar (FinSuppSeq n) :: * # Methods(*^) :: Scalar (FinSuppSeq n) -> FinSuppSeq n -> FinSuppSeq n # (Num n, AdditiveGroup n, Unbox n) => InnerSpace (FinSuppSeq n) Source # Methods(<.>) :: FinSuppSeq n -> FinSuppSeq n -> Scalar (FinSuppSeq n) # (Num n, Unbox n) => AdditiveGroup (FinSuppSeq n) Source # Methods(^+^) :: FinSuppSeq n -> FinSuppSeq n -> FinSuppSeq n #negateV :: FinSuppSeq n -> FinSuppSeq n #(^-^) :: FinSuppSeq n -> FinSuppSeq n -> FinSuppSeq n # (Num n, AdditiveGroup n, Unbox n) => FreeVectorSpace (FinSuppSeq n) Source # Methods(^*^) :: FinSuppSeq n -> FinSuppSeq n -> FinSuppSeq n Source #vmap :: (Scalar (FinSuppSeq n) -> Scalar (FinSuppSeq n)) -> FinSuppSeq n -> FinSuppSeq n Source # type Item (FinSuppSeq n) Source # type Item (FinSuppSeq n) = n type Diff (FinSuppSeq n) Source # type Diff (FinSuppSeq n) = FinSuppSeq n type Basis (FinSuppSeq n) Source # type Basis (FinSuppSeq n) = Int type Scalar (FinSuppSeq n) Source # type Scalar (FinSuppSeq n) = n

data SparseSuppSeq n Source #

Sparsely supported sequences (what other languages would call sparse vectors) are sequences consisting of lots of zeroes, with finitely many nonzeroes scattered around. Only these nonzero elements are stored.

Constructors

 SparseSuppSeq FieldssparseNonzeroes :: Vector (Int, n)

Instances

 (Unbox n, Eq n, Num n) => IsList (SparseSuppSeq n) Source # Associated Typestype Item (SparseSuppSeq n) :: * # MethodsfromList :: [Item (SparseSuppSeq n)] -> SparseSuppSeq n #fromListN :: Int -> [Item (SparseSuppSeq n)] -> SparseSuppSeq n #toList :: SparseSuppSeq n -> [Item (SparseSuppSeq n)] # (Num n, Unbox n) => AffineSpace (SparseSuppSeq n) Source # Associated Typestype Diff (SparseSuppSeq n) :: * # Methods(.-.) :: SparseSuppSeq n -> SparseSuppSeq n -> Diff (SparseSuppSeq n) #(.+^) :: SparseSuppSeq n -> Diff (SparseSuppSeq n) -> SparseSuppSeq n # (Num n, Unbox n) => HasBasis (SparseSuppSeq n) Source # Associated Typestype Basis (SparseSuppSeq n) :: * # Methodsdecompose :: SparseSuppSeq n -> [(Basis (SparseSuppSeq n), Scalar (SparseSuppSeq n))] # (Num n, Unbox n) => VectorSpace (SparseSuppSeq n) Source # Associated Typestype Scalar (SparseSuppSeq n) :: * # Methods(*^) :: Scalar (SparseSuppSeq n) -> SparseSuppSeq n -> SparseSuppSeq n # (Num n, AdditiveGroup n, Unbox n) => InnerSpace (SparseSuppSeq n) Source # Methods(<.>) :: SparseSuppSeq n -> SparseSuppSeq n -> Scalar (SparseSuppSeq n) # (Num n, Unbox n) => AdditiveGroup (SparseSuppSeq n) Source # Methods (Num n, Unbox n) => FreeVectorSpace (SparseSuppSeq n) Source # Methodsvmap :: (Scalar (SparseSuppSeq n) -> Scalar (SparseSuppSeq n)) -> SparseSuppSeq n -> SparseSuppSeq n Source # type Item (SparseSuppSeq n) Source # type Item (SparseSuppSeq n) = n type Diff (SparseSuppSeq n) Source # type Diff (SparseSuppSeq n) = SparseSuppSeq n type Basis (SparseSuppSeq n) Source # type Basis (SparseSuppSeq n) = Int type Scalar (SparseSuppSeq n) Source # type Scalar (SparseSuppSeq n) = n

Like SparseSuppSeq, this type of number-sequence ignores zeroes and only stores nonzero elements with positional information, but it does this not for every single entry separately: only the first position of each contiguous chunk of nonzeroes is tracked. It is thus more suited for vectors that are in some places dense but still have lots of zeroes.

The drawback is that random access (i.e. decompose') has complexity 𝓞(𝑛) – instead of 𝓞(1) for FinSuppSeq, or 𝓞(log 𝑛) for SparseSuppSeq – so this type should only be used for “abstract vector operations”.

Constructors

 SemisparseSuppSeq FieldschunkSparseNonzeroes :: Vector n sparseNonzeroLocation :: Vector (Int, Int)Start index of block, size of block of consecutive nonzeroes

Instances

 (Unbox n, Eq n, Num n) => IsList (SemisparseSuppSeq n) Source # Associated Typestype Item (SemisparseSuppSeq n) :: * # MethodsfromList :: [Item (SemisparseSuppSeq n)] -> SemisparseSuppSeq n #fromListN :: Int -> [Item (SemisparseSuppSeq n)] -> SemisparseSuppSeq n #toList :: SemisparseSuppSeq n -> [Item (SemisparseSuppSeq n)] # (Num n, Unbox n) => AffineSpace (SemisparseSuppSeq n) Source # Associated Typestype Diff (SemisparseSuppSeq n) :: * # Methods (Num n, Unbox n) => HasBasis (SemisparseSuppSeq n) Source # Associated Typestype Basis (SemisparseSuppSeq n) :: * # Methodsdecompose :: SemisparseSuppSeq n -> [(Basis (SemisparseSuppSeq n), Scalar (SemisparseSuppSeq n))] # (Num n, Unbox n) => VectorSpace (SemisparseSuppSeq n) Source # Associated Typestype Scalar (SemisparseSuppSeq n) :: * # Methods (Num n, AdditiveGroup n, Unbox n) => InnerSpace (SemisparseSuppSeq n) Source # Methods (Num n, Unbox n) => AdditiveGroup (SemisparseSuppSeq n) Source # Methods (Num n, Unbox n) => FreeVectorSpace (SemisparseSuppSeq n) Source # Methods type Item (SemisparseSuppSeq n) Source # type Item (SemisparseSuppSeq n) = n type Diff (SemisparseSuppSeq n) Source # type Diff (SemisparseSuppSeq n) = SemisparseSuppSeq n type Basis (SemisparseSuppSeq n) Source # type Basis (SemisparseSuppSeq n) = Int type Scalar (SemisparseSuppSeq n) Source # type Scalar (SemisparseSuppSeq n) = n