Copyright | (c) Justus Sagemüller 2016 |
---|---|
License | GPL v3 |
Maintainer | (@) sagemueller $ geo.uni-koeln.de |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- data V0 a :: * -> *
- data V1 a :: * -> *
- data V2 a :: * -> *
- data V3 a :: * -> *
- data V4 a :: * -> *
- type Sequence = GSequence Vector
- data FinSuppSeq n
- class AdditiveGroup (Diff p) => AffineSpace p where
- class AdditiveGroup v where
- class AdditiveGroup v => VectorSpace v where
- class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where
- class VectorSpace v => HasBasis v where
- class (VectorSpace v, Fractional (Scalar v)) => OneDimensional v where
- class (VectorSpace v, Num (Scalar v)) => FreeVectorSpace v where
- class (VectorSpace v, Num (Scalar v)) => FiniteFreeSpace v where
Supported types
Fixed low dimension
These come from the linear package.
A 0-dimensional vector
>>>
pure 1 :: V0 Int
V0
>>>
V0 + V0
V0
Monad V0 | |
Functor V0 | |
MonadFix V0 | |
Applicative V0 | |
Foldable V0 | |
Traversable V0 | |
Distributive V0 | |
Representable V0 | |
Eq1 V0 | |
Ord1 V0 | |
Read1 V0 | |
Show1 V0 | |
MonadZip V0 | |
Serial1 V0 | |
Apply V0 | |
Affine V0 | |
Finite V0 | |
Metric V0 | |
Additive V0 | |
Bind V0 | |
Vector Vector (V0 a) | |
MVector MVector (V0 a) | |
Bounded (V0 a) | |
Enum (V0 a) | |
Eq (V0 a) | |
Floating (V0 a) | |
Fractional (V0 a) | |
Data a => Data (V0 a) | |
Num (V0 a) | |
Ord (V0 a) | |
Read (V0 a) | |
Show (V0 a) | |
Ix (V0 a) | |
Generic (V0 a) | |
Storable (V0 a) | |
Binary (V0 a) | |
Serial (V0 a) | |
Serialize (V0 a) | |
NFData (V0 a) | |
Hashable (V0 a) | |
Unbox (V0 a) | |
Ixed (V0 a) | |
Epsilon (V0 a) | |
Num s => FiniteFreeSpace (V0 s) Source # | |
Generic1 * V0 | |
FunctorWithIndex (E V0) V0 | |
FoldableWithIndex (E V0) V0 | |
TraversableWithIndex (E V0) V0 | |
Each (V0 a) (V0 b) a b | |
type Rep V0 | |
type Diff V0 | |
type Size V0 | |
data MVector s (V0 a) | |
type Rep (V0 a) | |
data (:->:) (E V0) # | |
data Vector (V0 a) | |
type Index (V0 a) | |
type IxValue (V0 a) | |
type Diff (V0 s) # | |
type Basis (V0 s) # | |
type Scalar (V0 s) # | |
type Rep1 * V0 | |
type Diff (Point V0 s) # | |
A 1-dimensional vector
>>>
pure 1 :: V1 Int
V1 1
>>>
V1 2 + V1 3
V1 5
>>>
V1 2 * V1 3
V1 6
>>>
sum (V1 2)
2
A 2-dimensional vector
>>>
pure 1 :: V2 Int
V2 1 1
>>>
V2 1 2 + V2 3 4
V2 4 6
>>>
V2 1 2 * V2 3 4
V2 3 8
>>>
sum (V2 1 2)
3
A 3-dimensional vector
A 4-dimensional vector.
Arbitrary dimension
data 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.)
Unbox n => IsList (FinSuppSeq n) Source # | |
(Unbox n, Show n) => Show (FinSuppSeq n) Source # | |
(Num n, Unbox n) => AffineSpace (FinSuppSeq n) Source # | |
(Num n, Unbox n) => HasBasis (FinSuppSeq n) Source # | |
(Num n, Unbox n) => VectorSpace (FinSuppSeq n) Source # | |
(Num n, AdditiveGroup n, Unbox n) => InnerSpace (FinSuppSeq n) Source # | |
(Num n, Unbox n) => AdditiveGroup (FinSuppSeq n) Source # | |
(Num n, AdditiveGroup n, Unbox n) => FreeVectorSpace (FinSuppSeq n) Source # | |
type Item (FinSuppSeq n) Source # | |
type Diff (FinSuppSeq n) Source # | |
type Basis (FinSuppSeq n) Source # | |
type Scalar (FinSuppSeq n) Source # | |
The vector-space type classes
General
These come from the vector-space package.
class AdditiveGroup (Diff p) => AffineSpace p where #
(.-.) :: p -> p -> Diff p infix 6 #
Subtract points
(.+^) :: p -> Diff p -> p infixl 6 #
Point plus vector
AffineSpace Double | |
AffineSpace Float | |
AffineSpace Int | |
AffineSpace Integer | |
AffineSpace CSChar | |
AffineSpace CShort | |
AffineSpace CInt | |
AffineSpace CLong | |
AffineSpace CLLong | |
AffineSpace CFloat | |
AffineSpace CDouble | |
AffineSpace CIntMax | |
Integral a => AffineSpace (Ratio a) | |
(Num n, Unbox n) => AffineSpace (SemisparseSuppSeq n) # | |
(Num n, Unbox n) => AffineSpace (SparseSuppSeq n) # | |
(Num n, Unbox n) => AffineSpace (FinSuppSeq n) # | |
(Num n, Unbox n) => AffineSpace (Sequence n) # | |
AffineSpace p => AffineSpace (a -> p) | |
(AffineSpace p, AffineSpace q) => AffineSpace (p, q) | |
AffineSpace a => AffineSpace (Rec0 * a s) | |
(AffineSpace p, AffineSpace q, AffineSpace r) => AffineSpace (p, q, r) | |
(AffineSpace (f p), AffineSpace (g p)) => AffineSpace (AffineDiffProductSpace f g p) | |
(AffineSpace (f p), AffineSpace (g p)) => AffineSpace ((:*:) * f g p) | |
AffineSpace (f p) => AffineSpace (M1 * i c f p) | |
class AdditiveGroup v where #
Additive group v
.
The zero element: identity for '(^+^)'
(^+^) :: v -> v -> v infixl 6 #
Add vectors
Additive inverse
(^-^) :: v -> v -> v infixl 6 #
Group subtraction
class AdditiveGroup v => VectorSpace v where #
Vector space v
.
class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where #
Adds inner (dot) products.
class VectorSpace v => HasBasis v where #
basisValue :: Basis v -> v #
Interpret basis rep as a vector
decompose :: v -> [(Basis v, Scalar v)] #
Extract coordinates
decompose' :: v -> Basis v -> Scalar v #
Experimental version. More elegant definitions, and friendly to infinite-dimensional vector spaces.
HasBasis Double | |
HasBasis Float | |
HasBasis CFloat | |
HasBasis CDouble | |
Integral a => HasBasis (Ratio a) | |
HasBasis (Diff (VRep p)) => HasBasis (GenericDiff p) | |
(Num n, Unbox n) => HasBasis (SemisparseSuppSeq n) # | |
(Num n, Unbox n) => HasBasis (SparseSuppSeq n) # | |
(Num n, Unbox n) => HasBasis (FinSuppSeq n) # | |
(Num n, Unbox n) => HasBasis (Sequence n) # | |
(HasBasis u, (~) * s (Scalar u), HasBasis v, (~) * s (Scalar v)) => HasBasis (u, v) | |
HasBasis a => HasBasis (Rec0 * a s) | |
(HasBasis u, (~) * s (Scalar u), HasBasis v, (~) * s (Scalar v), HasBasis w, (~) * s (Scalar w)) => HasBasis (u, v, w) | |
(AffineSpace (f p), AffineSpace (g p), HasBasis (Diff (f p)), HasBasis (Diff (g p)), (~) * (Scalar (Diff (f p))) (Scalar (Diff (g p)))) => HasBasis (AffineDiffProductSpace f g p) | |
(HasBasis (f p), HasBasis (g p), (~) * (Scalar (f p)) (Scalar (g p))) => HasBasis ((:*:) * f g p) | |
HasBasis (f p) => HasBasis (M1 * i c f p) | |
Small
class (VectorSpace v, Fractional (Scalar v)) => OneDimensional v where Source #
(^/^) :: v -> v -> Maybe (Scalar v) infixr 7 Source #
Compare the (directed) length of two vectors.
(^/^) :: (Generic v, OneDimensional (VRep v), Scalar (VRep v) ~ Scalar v) => v -> v -> Maybe (Scalar v) infixr 7 Source #
Compare the (directed) length of two vectors.
(^/!) :: v -> v -> Scalar v infixr 7 Source #
Unsafe version of ^/^
.
OneDimensional Double Source # | |
OneDimensional Float Source # | |
OneDimensional CFloat Source # | |
OneDimensional CDouble Source # | |
Integral i => OneDimensional (Ratio i) Source # | |
(Eq r, Fractional r) => OneDimensional (V1 r) Source # | |
OneDimensional a => OneDimensional (Rec0 * a s) Source # | |
OneDimensional (f p) => OneDimensional (M1 * i c f p) Source # | |
Free
class (VectorSpace v, Num (Scalar v)) => FreeVectorSpace v where Source #
Vector spaces that are spanned by a specific, canonical set of basis vectors.
Element-wise multiplication, equivalent to Matlab's .*
operator or
.liftI2
(*)
vmap :: (Scalar v -> Scalar v) -> v -> v Source #
Like a monomorphic fmap
. Only guaranteed to act on the nonzero entries;
whether the function is also applied on zeroes is instance-specific.
class (VectorSpace v, Num (Scalar v)) => FiniteFreeSpace v where Source #
freeDimension :: Functor p => p v -> Int Source #
freeDimension :: (Generic v, FiniteFreeSpace (VRep v)) => p v -> Int Source #
toFullUnboxVect :: Unbox (Scalar v) => v -> Vector (Scalar v) Source #
toFullUnboxVect :: (Generic v, FiniteFreeSpace (VRep v), Unbox (Scalar v), Scalar (VRep v) ~ Scalar v) => v -> Vector (Scalar v) Source #
unsafeFromFullUnboxVect :: Unbox (Scalar v) => Vector (Scalar v) -> v Source #
unsafeFromFullUnboxVect :: (Generic v, FiniteFreeSpace (VRep v), Unbox (Scalar v), Scalar (VRep v) ~ Scalar v) => Vector (Scalar v) -> v Source #
fromUnboxVect :: Unbox (Scalar v) => Vector (Scalar v) -> v Source #
FiniteFreeSpace Double Source # | |
FiniteFreeSpace Float Source # | |
FiniteFreeSpace Int Source # | |
Num s => FiniteFreeSpace (V0 s) Source # | |
Num s => FiniteFreeSpace (V4 s) Source # | |
Num s => FiniteFreeSpace (V3 s) Source # | |
Num s => FiniteFreeSpace (V2 s) Source # | |
Num s => FiniteFreeSpace (V1 s) Source # | |
(FiniteFreeSpace u, FiniteFreeSpace v, (~) * (Scalar u) (Scalar v)) => FiniteFreeSpace (u, v) Source # | |
FiniteFreeSpace a => FiniteFreeSpace (Rec0 * a s) Source # | |
(FiniteFreeSpace (f p), FiniteFreeSpace (g p), (~) * (Scalar (f p)) (Scalar (g p))) => FiniteFreeSpace ((:*:) * f g p) Source # | |
FiniteFreeSpace (f p) => FiniteFreeSpace (M1 * i c f p) Source # | |