Copyright | (C) 2012-2015 Edward Kmett |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Stability | experimental |

Portability | non-portable |

Safe Haskell | Trustworthy |

Language | Haskell2010 |

n-D Vectors

## Synopsis

- newtype V n a = V {}
- int :: Int -> TypeQ
- dim :: forall n a. Dim n => V n a -> Int
- class Dim n where
- reflectDim :: p n -> Int

- reifyDim :: Int -> (forall (n :: Type). Dim n => Proxy n -> r) -> r
- reifyVector :: forall a r. Vector a -> (forall (n :: Type). Dim n => V n a -> r) -> r
- reifyDimNat :: Int -> (forall (n :: Nat). KnownNat n => Proxy n -> r) -> r
- reifyVectorNat :: forall a r. Vector a -> (forall (n :: Nat). KnownNat n => V n a -> r) -> r
- fromVector :: forall n a. Dim n => Vector a -> Maybe (V n a)
- class Finite v where
- _V :: (Finite u, Finite v) => Iso (V (Size u) a) (V (Size v) b) (u a) (v b)
- _V' :: Finite v => Iso (V (Size v) a) (V (Size v) b) (v a) (v b)

# Documentation

#### Instances

Generic1 (V n :: Type -> Type) Source # | |

FoldableWithIndex Int (V n) Source # | |

FunctorWithIndex Int (V n) Source # | |

TraversableWithIndex Int (V n) Source # | |

Dim n => Dim (V n a :: Type) Source # | |

(Dim n, Unbox a) => Vector Vector (V n a) Source # | |

Defined in Linear.V basicUnsafeFreeze :: Mutable Vector s (V n a) -> ST s (Vector (V n a)) # basicUnsafeThaw :: Vector (V n a) -> ST s (Mutable Vector s (V n a)) # basicLength :: Vector (V n a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (V n a) -> Vector (V n a) # basicUnsafeIndexM :: Vector (V n a) -> Int -> Box (V n a) # basicUnsafeCopy :: Mutable Vector s (V n a) -> Vector (V n a) -> ST s () # | |

(Dim n, Unbox a) => MVector MVector (V n a) Source # | |

Defined in Linear.V basicLength :: MVector s (V n a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (V n a) -> MVector s (V n a) # basicOverlaps :: MVector s (V n a) -> MVector s (V n a) -> Bool # basicUnsafeNew :: Int -> ST s (MVector s (V n a)) # basicInitialize :: MVector s (V n a) -> ST s () # basicUnsafeReplicate :: Int -> V n a -> ST s (MVector s (V n a)) # basicUnsafeRead :: MVector s (V n a) -> Int -> ST s (V n a) # basicUnsafeWrite :: MVector s (V n a) -> Int -> V n a -> ST s () # basicClear :: MVector s (V n a) -> ST s () # basicSet :: MVector s (V n a) -> V n a -> ST s () # basicUnsafeCopy :: MVector s (V n a) -> MVector s (V n a) -> ST s () # basicUnsafeMove :: MVector s (V n a) -> MVector s (V n a) -> ST s () # basicUnsafeGrow :: MVector s (V n a) -> Int -> ST s (MVector s (V n a)) # | |

Dim n => Representable (V n) Source # | |

Dim n => MonadFix (V n) Source # | |

Dim n => MonadZip (V n) Source # | |

Foldable (V n) Source # | |

Defined in Linear.V fold :: Monoid m => V n m -> m # foldMap :: Monoid m => (a -> m) -> V n a -> m # foldMap' :: Monoid m => (a -> m) -> V n a -> m # foldr :: (a -> b -> b) -> b -> V n a -> b # foldr' :: (a -> b -> b) -> b -> V n a -> b # foldl :: (b -> a -> b) -> b -> V n a -> b # foldl' :: (b -> a -> b) -> b -> V n a -> b # foldr1 :: (a -> a -> a) -> V n a -> a # foldl1 :: (a -> a -> a) -> V n a -> a # elem :: Eq a => a -> V n a -> Bool # maximum :: Ord a => V n a -> a # | |

Eq1 (V n) Source # | |

Ord1 (V n) Source # | |

Dim n => Read1 (V n) Source # | |

Show1 (V n) Source # | |

Traversable (V n) Source # | |

Dim n => Applicative (V n) Source # | |

Functor (V n) Source # | |

Dim n => Monad (V n) Source # | |

Dim n => Serial1 (V n) Source # | |

Defined in Linear.V serializeWith :: MonadPut m => (a -> m ()) -> V n a -> m () # deserializeWith :: MonadGet m => m a -> m (V n a) # | |

Dim n => Distributive (V n) Source # | |

Dim n => Hashable1 (V n) Source # | |

Dim n => Affine (V n) Source # | |

Dim n => Metric (V n) Source # | |

Dim n => Trace (V n) Source # | |

Finite (V n) Source # | |

Dim n => Additive (V n) Source # | |

Apply (V n) Source # | |

Bind (V n) Source # | |

(Typeable (V n), Typeable (V n a), Dim n, Data a) => Data (V n a) Source # | |

Defined in Linear.V gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> V n a -> c (V n a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (V n a) # dataTypeOf :: V n a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (V n a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V n a)) # gmapT :: (forall b. Data b => b -> b) -> V n a -> V n a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V n a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V n a -> r # gmapQ :: (forall d. Data d => d -> u) -> V n a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> V n a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> V n a -> m (V n a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> V n a -> m (V n a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> V n a -> m (V n a) # | |

(Dim n, Storable a) => Storable (V n a) Source # | |

(Dim n, Monoid a) => Monoid (V n a) Source # | |

(Dim n, Semigroup a) => Semigroup (V n a) Source # | |

(Bounded a, Dim n) => Bounded (V n a) Source # | |

(Dim n, Floating a) => Floating (V n a) Source # | |

Generic (V n a) Source # | |

(Dim n, Num a) => Num (V n a) Source # | |

Read a => Read (V n a) Source # | |

(Dim n, Fractional a) => Fractional (V n a) Source # | |

Show a => Show (V n a) Source # | |

(Dim n, Binary a) => Binary (V n a) Source # | |

(Dim n, Serial a) => Serial (V n a) Source # | |

(Dim n, Serialize a) => Serialize (V n a) Source # | |

NFData a => NFData (V n a) Source # | |

Eq a => Eq (V n a) Source # | |

Ord a => Ord (V n a) Source # | |

Hashable a => Hashable (V n a) Source # | |

Ixed (V n a) Source # | |

(Dim n, Epsilon a) => Epsilon (V n a) Source # | |

(Dim n, Random a) => Random (V n a) Source # | |

(Dim n, Unbox a) => Unbox (V n a) Source # | |

Defined in Linear.V | |

Each (V n a) (V n b) a b Source # | |

1 <= n => Field1 (V n a) (V n a) a a Source # | |

10 <= n => Field10 (V n a) (V n a) a a Source # | |

11 <= n => Field11 (V n a) (V n a) a a Source # | |

12 <= n => Field12 (V n a) (V n a) a a Source # | |

13 <= n => Field13 (V n a) (V n a) a a Source # | |

14 <= n => Field14 (V n a) (V n a) a a Source # | |

15 <= n => Field15 (V n a) (V n a) a a Source # | |

16 <= n => Field16 (V n a) (V n a) a a Source # | |

17 <= n => Field17 (V n a) (V n a) a a Source # | |

18 <= n => Field18 (V n a) (V n a) a a Source # | |

19 <= n => Field19 (V n a) (V n a) a a Source # | |

2 <= n => Field2 (V n a) (V n a) a a Source # | |

3 <= n => Field3 (V n a) (V n a) a a Source # | |

4 <= n => Field4 (V n a) (V n a) a a Source # | |

5 <= n => Field5 (V n a) (V n a) a a Source # | |

6 <= n => Field6 (V n a) (V n a) a a Source # | |

7 <= n => Field7 (V n a) (V n a) a a Source # | |

8 <= n => Field8 (V n a) (V n a) a a Source # | |

9 <= n => Field9 (V n a) (V n a) a a Source # | |

type Rep1 (V n :: Type -> Type) Source # | |

data MVector s (V n a) Source # | |

type Rep (V n) Source # | |

type Diff (V n) Source # | |

Defined in Linear.Affine | |

type Size (V n) Source # | |

type Rep (V n a) Source # | |

type Index (V n a) Source # | |

type IxValue (V n a) Source # | |

data Vector (V n a) Source # | |

This can be used to generate a template haskell splice for a type level version of a given `int`

.

This does not use GHC TypeLits, instead it generates a numeric type by hand similar to the ones used in the "Functional Pearl: Implicit Configurations" paper by Oleg Kiselyov and Chung-Chieh Shan.

`instance Num (Q Exp)`

provided in this package allows writing `$(3)`

instead of `$(int 3)`

. Sometimes the two will produce the same
representation (if compiled without the `-DUSE_TYPE_LITS`

preprocessor
directive).

reflectDim :: p n -> Int Source #

reifyVectorNat :: forall a r. Vector a -> (forall (n :: Nat). KnownNat n => V n a -> r) -> r Source #

#### Instances

Finite Complex Source # | |

Finite Plucker Source # | |

Finite Quaternion Source # | |

Defined in Linear.Quaternion type Size Quaternion :: Nat Source # toV :: Quaternion a -> V (Size Quaternion) a Source # fromV :: V (Size Quaternion) a -> Quaternion a Source # | |

Finite V0 Source # | |

Finite V1 Source # | |

Finite V2 Source # | |

Finite V3 Source # | |

Finite V4 Source # | |

Finite f => Finite (Point f) Source # | |

Finite (V n) Source # | |