hgeometry-0.8.0.0: Geometric Algorithms, Data structures, and Data types.

Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Vector.VectorFamily

Contents

Description

Implementation of \(d\)-dimensional vectors. The implementation automatically selects an optimized representation for small (up to size 4) vectors.

Synopsis

d dimensional Vectors

newtype Vector (d :: Nat) (r :: *) Source #

Datatype representing d dimensional vectors. The default implementation is based n VectorFixed. However, for small vectors we automatically select a more efficient representation.

Constructors

MKVector 

Fields

Instances
Arity d => Functor (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

fmap :: (a -> b) -> Vector d a -> Vector d b #

(<$) :: a -> Vector d b -> Vector d a #

Arity d => Applicative (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

pure :: a -> Vector d a #

(<*>) :: Vector d (a -> b) -> Vector d a -> Vector d b #

liftA2 :: (a -> b -> c) -> Vector d a -> Vector d b -> Vector d c #

(*>) :: Vector d a -> Vector d b -> Vector d b #

(<*) :: Vector d a -> Vector d b -> Vector d a #

Arity d => Foldable (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

fold :: Monoid m => Vector d m -> m #

foldMap :: Monoid m => (a -> m) -> Vector d a -> m #

foldr :: (a -> b -> b) -> b -> Vector d a -> b #

foldr' :: (a -> b -> b) -> b -> Vector d a -> b #

foldl :: (b -> a -> b) -> b -> Vector d a -> b #

foldl' :: (b -> a -> b) -> b -> Vector d a -> b #

foldr1 :: (a -> a -> a) -> Vector d a -> a #

foldl1 :: (a -> a -> a) -> Vector d a -> a #

toList :: Vector d a -> [a] #

null :: Vector d a -> Bool #

length :: Vector d a -> Int #

elem :: Eq a => a -> Vector d a -> Bool #

maximum :: Ord a => Vector d a -> a #

minimum :: Ord a => Vector d a -> a #

sum :: Num a => Vector d a -> a #

product :: Num a => Vector d a -> a #

Arity d => Traversable (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

traverse :: Applicative f => (a -> f b) -> Vector d a -> f (Vector d b) #

sequenceA :: Applicative f => Vector d (f a) -> f (Vector d a) #

mapM :: Monad m => (a -> m b) -> Vector d a -> m (Vector d b) #

sequence :: Monad m => Vector d (m a) -> m (Vector d a) #

Arity d => Affine (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Associated Types

type Diff (Vector d) :: Type -> Type #

Methods

(.-.) :: Num a => Vector d a -> Vector d a -> Diff (Vector d) a #

(.+^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a #

(.-^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a #

Arity d => Metric (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

dot :: Num a => Vector d a -> Vector d a -> a #

quadrance :: Num a => Vector d a -> a #

qd :: Num a => Vector d a -> Vector d a -> a #

distance :: Floating a => Vector d a -> Vector d a -> a #

norm :: Floating a => Vector d a -> a #

signorm :: Floating a => Vector d a -> Vector d a #

Arity d => Additive (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

zero :: Num a => Vector d a #

(^+^) :: Num a => Vector d a -> Vector d a -> Vector d a #

(^-^) :: Num a => Vector d a -> Vector d a -> Vector d a #

lerp :: Num a => a -> Vector d a -> Vector d a -> Vector d a #

liftU2 :: (a -> a -> a) -> Vector d a -> Vector d a -> Vector d a #

liftI2 :: (a -> b -> c) -> Vector d a -> Vector d b -> Vector d c #

Arity d => Vector (Vector d) r Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

construct :: Fun (Peano (Dim (Vector d))) r (Vector d r) #

inspect :: Vector d r -> Fun (Peano (Dim (Vector d))) r b -> b #

basicIndex :: Vector d r -> Int -> r #

(Eq r, Arity d) => Eq (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

(==) :: Vector d r -> Vector d r -> Bool #

(/=) :: Vector d r -> Vector d r -> Bool #

(Ord r, Arity d) => Ord (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

compare :: Vector d r -> Vector d r -> Ordering #

(<) :: Vector d r -> Vector d r -> Bool #

(<=) :: Vector d r -> Vector d r -> Bool #

(>) :: Vector d r -> Vector d r -> Bool #

(>=) :: Vector d r -> Vector d r -> Bool #

max :: Vector d r -> Vector d r -> Vector d r #

min :: Vector d r -> Vector d r -> Vector d r #

(Read r, Arity d) => Read (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

(Arity d, Show r) => Show (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

showsPrec :: Int -> Vector d r -> ShowS #

show :: Vector d r -> String #

showList :: [Vector d r] -> ShowS #

(Arbitrary r, Arity d) => Arbitrary (Vector d r) Source # 
Instance details

Defined in Test.QuickCheck.HGeometryInstances

Methods

arbitrary :: Gen (Vector d r) #

shrink :: Vector d r -> [Vector d r] #

(ToJSON r, Arity d) => ToJSON (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

toJSON :: Vector d r -> Value #

toEncoding :: Vector d r -> Encoding #

toJSONList :: [Vector d r] -> Value #

toEncodingList :: [Vector d r] -> Encoding #

(FromJSON r, Arity d) => FromJSON (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

parseJSON :: Value -> Parser (Vector d r) #

parseJSONList :: Value -> Parser [Vector d r] #

(NFData r, Arity d) => NFData (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

rnf :: Vector d r -> () #

Arity d => Ixed (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

Methods

ix :: Index (Vector d r) -> Traversal' (Vector d r) (IxValue (Vector d r)) #

(Fractional r, Arity d, Arity (d + 1)) => IsTransformable (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Transformation

Methods

transformBy :: Transformation (Dimension (Vector d r)) (NumType (Vector d r)) -> Vector d r -> Vector d r Source #

type Dim (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

type Dim (Vector d) = FromPeano (Peano d)
type Diff (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

type Diff (Vector d) = Vector d
type Index (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

type Index (Vector d r) = Int
type IxValue (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFamily

type IxValue (Vector d r) = r
type NumType (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector

type NumType (Vector d r) = r
type Dimension (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector

type Dimension (Vector d r) = d

unV :: Lens (Vector d r) (Vector d s) (VectorFamily (Peano d) r) (VectorFamily (Peano d) s) Source #

readVec :: forall d r. (Arity d, Read r) => ReadP (Vector d r) Source #

Convenience "constructors"

pattern Vector :: VectorFamilyF (Peano d) r -> Vector d r Source #

pattern Vector1 :: r -> Vector 1 r Source #

pattern Vector2 :: r -> r -> Vector 2 r Source #

pattern Vector3 :: r -> r -> r -> Vector 3 r Source #

pattern Vector4 :: r -> r -> r -> r -> Vector 4 r Source #

vectorFromList :: Arity d => [r] -> Maybe (Vector d r) Source #

destruct :: (Arity d, Arity (d + 1)) => Vector (d + 1) r -> (r, Vector d r) Source #

Indexing vectors

element :: forall proxy i d r. (Arity d, KnownNat i, (i + 1) <= d) => proxy i -> Lens' (Vector d r) r Source #

Lens into the i th element

element' :: forall d r. Arity d => Int -> Traversal' (Vector d r) r Source #

Similar to element above. Except that we don't have a static guarantee that the index is in bounds. Hence, we can only return a Traversal

Snoccing and consindg

snoc :: (Arity (d + 1), Arity d) => Vector d r -> r -> Vector (d + 1) r Source #

Add an element at the back of the vector

init :: (Arity d, Arity (d + 1)) => Vector (d + 1) r -> Vector d r Source #

Get a vector of the first d - 1 elements.

last :: forall d r. (KnownNat d, Arity (d + 1)) => Vector (d + 1) r -> r Source #

prefix :: forall i d r. (Arity d, Arity i, i <= d) => Vector d r -> Vector i r Source #

Get a prefix of i elements of a vector

Specific on 3-dimensional vectors

cross :: Num r => Vector 3 r -> Vector 3 r -> Vector 3 r Source #

Cross product of two three-dimensional vectors