Data.Vec.Packed
 Contents Packed Vector Types Packed Matrix Types
Description

Packed vectors : use these whenever possible. The regular vector type is just a gussied up linked list, but when vector functions are applied to these types, bracketed by pack and unpack, then things unfold into neatly optimized code.

Storable, Num, Fractional, Fold, Map, and ZipWith instances are provided for packed vectors, so some operations do not require pack/unpack. For example, dot does not require pack/unpack because it is defined in terms of zipWith and fold. However transpose, det, gaussElim and most others are recursive, and so you'll still need to use pack/unpack with these. This goes for multmm as well because it uses transpose, and multmv does not need its arguments to be unpacked, but the result will be a polymorphic vector of type (:.), so you will want to pack it again. This is all very experimental and likely to change.

Synopsis
class PackedVec pv v | pv -> v where
 pack :: v -> pv unpack :: pv -> v
data Vec2I = Vec2I !!Int !!Int
data Vec3I = Vec3I !!Int !!Int !!Int
data Vec4I = Vec4I !!Int !!Int !!Int !!Int
data Vec2F = Vec2F !!Float !!Float
data Vec3F = Vec3F !!Float !!Float !!Float
data Vec4F = Vec4F !!Float !!Float !!Float !!Float
data Vec2D = Vec2D !!Double !!Double
data Vec3D = Vec3D !!Double !!Double !!Double
data Vec4D = Vec4D !!Double !!Double !!Double !!Double
type Mat22I = Vec2 Vec2I
type Mat23I = Vec2 Vec3I
type Mat33I = Vec3 Vec3I
type Mat34I = Vec3 Vec4I
type Mat44I = Vec4 Vec3I
type Mat22F = Vec2 Vec2F
type Mat23F = Vec2 Vec3F
type Mat33F = Vec3 Vec3F
type Mat34F = Vec3 Vec4F
type Mat44F = Vec4 Vec3F
type Mat22D = Vec2 Vec2D
type Mat23D = Vec2 Vec3D
type Mat33D = Vec3 Vec3D
type Mat34D = Vec3 Vec4D
type Mat44D = Vec4 Vec4D
packMat :: (Map v pv m pm, PackedVec pv v) => m -> pm
unpackMat :: (Map pv v pm m, PackedVec pv v) => pm -> m
Documentation
 class PackedVec pv v | pv -> v where Source
PackedVec class : relates a packed vector type to its unpacked type For now, the fundep is not bijective -- It may be advantageous to have multiple packed representations for a canonical vector type. This may change. In the meantime, you may have to annotate return types.
Methods
 pack :: v -> pv Source
 unpack :: pv -> v Source
Instances
 PackedVec Vec4D (Vec4 Double) PackedVec Vec4D (Vec4 Double) PackedVec Vec3D (Vec3 Double) PackedVec Vec3D (Vec3 Double) PackedVec Vec2D (Vec2 Double) PackedVec Vec2D (Vec2 Double) PackedVec Vec4F (Vec4 Float) PackedVec Vec4F (Vec4 Float) PackedVec Vec3F (Vec3 Float) PackedVec Vec3F (Vec3 Float) PackedVec Vec2F (Vec2 Float) PackedVec Vec2F (Vec2 Float) PackedVec Vec4I (Vec4 Int) PackedVec Vec4I (Vec4 Int) PackedVec Vec3I (Vec3 Int) PackedVec Vec3I (Vec3 Int) PackedVec Vec2I (Vec2 Int) PackedVec Vec2I (Vec2 Int)
Packed Vector Types
 data Vec2I Source
Constructors
 Vec2I !!Int !!Int
Instances
 Eq Vec2I Num Vec2I Ord Vec2I Read Vec2I Show Vec2I Storable Vec2I Fold Int Vec2I Map Int Int Vec2I Vec2I ZipWith Int Int Int Vec2I Vec2I Vec2I PackedVec Vec2I (Vec2 Int)
 data Vec3I Source
Constructors
 Vec3I !!Int !!Int !!Int
Instances
 Eq Vec3I Num Vec3I Ord Vec3I Read Vec3I Show Vec3I Storable Vec3I Fold Int Vec3I Map Int Int Vec3I Vec3I ZipWith Int Int Int Vec3I Vec3I Vec3I PackedVec Vec3I (Vec3 Int)
 data Vec4I Source
Constructors
 Vec4I !!Int !!Int !!Int !!Int
Instances
 Eq Vec4I Num Vec4I Ord Vec4I Read Vec4I Show Vec4I Storable Vec4I Fold Int Vec4I Map Int Int Vec4I Vec4I ZipWith Int Int Int Vec4I Vec4I Vec4I PackedVec Vec4I (Vec4 Int)
 data Vec2F Source
Constructors
 Vec2F !!Float !!Float
Instances
 Eq Vec2F Fractional Vec2F Num Vec2F Ord Vec2F Read Vec2F Show Vec2F Storable Vec2F Fold Float Vec2F Map Float Float Vec2F Vec2F ZipWith Float Float Float Vec2F Vec2F Vec2F PackedVec Vec2F (Vec2 Float)
 data Vec3F Source
Constructors
 Vec3F !!Float !!Float !!Float
Instances
 Eq Vec3F Fractional Vec3F Num Vec3F Ord Vec3F Read Vec3F Show Vec3F Storable Vec3F Fold Float Vec3F Map Float Float Vec3F Vec3F ZipWith Float Float Float Vec3F Vec3F Vec3F PackedVec Vec3F (Vec3 Float)
 data Vec4F Source
Constructors
 Vec4F !!Float !!Float !!Float !!Float
Instances
 Eq Vec4F Fractional Vec4F Num Vec4F Ord Vec4F Read Vec4F Show Vec4F Storable Vec4F Fold Float Vec4F Map Float Float Vec4F Vec4F ZipWith Float Float Float Vec4F Vec4F Vec4F PackedVec Vec4F (Vec4 Float)
 data Vec2D Source
Constructors
 Vec2D !!Double !!Double
Instances
 Eq Vec2D Fractional Vec2D Num Vec2D Ord Vec2D Read Vec2D Show Vec2D Storable Vec2D Fold Double Vec2D Map Double Double Vec2D Vec2D ZipWith Double Double Double Vec2D Vec2D Vec2D PackedVec Vec2D (Vec2 Double)
 data Vec3D Source
Constructors
 Vec3D !!Double !!Double !!Double
Instances
 Eq Vec3D Fractional Vec3D Num Vec3D Ord Vec3D Read Vec3D Show Vec3D Storable Vec3D Fold Double Vec3D Map Double Double Vec3D Vec3D ZipWith Double Double Double Vec3D Vec3D Vec3D PackedVec Vec3D (Vec3 Double)
 data Vec4D Source
Constructors
 Vec4D !!Double !!Double !!Double !!Double
Instances
 Eq Vec4D Fractional Vec4D Num Vec4D Ord Vec4D Read Vec4D Show Vec4D Storable Vec4D Fold Double Vec4D Map Double Double Vec4D Vec4D ZipWith Double Double Double Vec4D Vec4D Vec4D PackedVec Vec4D (Vec4 Double)
Packed Matrix Types
 type Mat22I = Vec2 Vec2I Source
 type Mat23I = Vec2 Vec3I Source
 type Mat33I = Vec3 Vec3I Source
 type Mat34I = Vec3 Vec4I Source
 type Mat44I = Vec4 Vec3I Source
 type Mat22F = Vec2 Vec2F Source
 type Mat23F = Vec2 Vec3F Source
 type Mat33F = Vec3 Vec3F Source
 type Mat34F = Vec3 Vec4F Source
 type Mat44F = Vec4 Vec3F Source
 type Mat22D = Vec2 Vec2D Source
 type Mat23D = Vec2 Vec3D Source
 type Mat33D = Vec3 Vec3D Source
 type Mat34D = Vec3 Vec4D Source
 type Mat44D = Vec4 Vec4D Source
 packMat :: (Map v pv m pm, PackedVec pv v) => m -> pm Source
pack a matrix
 unpackMat :: (Map pv v pm m, PackedVec pv v) => pm -> m Source
unpack a matrix