linear-1.20.8: Linear Algebra

Copyright (C) 2012-2015 Edward Kmett BSD-style (see the file LICENSE) Edward Kmett experimental non-portable Trustworthy Haskell98

Linear.V2

Description

2-D Vectors

Synopsis

# Documentation

data V2 a Source #

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


Constructors

 V2 !a !a
Instances
 Source # Instance detailsDefined in Linear.V2 Methods(>>=) :: V2 a -> (a -> V2 b) -> V2 b #(>>) :: V2 a -> V2 b -> V2 b #return :: a -> V2 a #fail :: String -> V2 a # Source # Instance detailsDefined in Linear.V2 Methodsfmap :: (a -> b) -> V2 a -> V2 b #(<) :: a -> V2 b -> V2 a # Source # Instance detailsDefined in Linear.V2 Methodsmfix :: (a -> V2 a) -> V2 a # Source # Instance detailsDefined in Linear.V2 Methodspure :: a -> V2 a #(<*>) :: V2 (a -> b) -> V2 a -> V2 b #liftA2 :: (a -> b -> c) -> V2 a -> V2 b -> V2 c #(*>) :: V2 a -> V2 b -> V2 b #(<*) :: V2 a -> V2 b -> V2 a # Source # Instance detailsDefined in Linear.V2 Methodsfold :: Monoid m => V2 m -> m #foldMap :: Monoid m => (a -> m) -> V2 a -> m #foldr :: (a -> b -> b) -> b -> V2 a -> b #foldr' :: (a -> b -> b) -> b -> V2 a -> b #foldl :: (b -> a -> b) -> b -> V2 a -> b #foldl' :: (b -> a -> b) -> b -> V2 a -> b #foldr1 :: (a -> a -> a) -> V2 a -> a #foldl1 :: (a -> a -> a) -> V2 a -> a #toList :: V2 a -> [a] #null :: V2 a -> Bool #length :: V2 a -> Int #elem :: Eq a => a -> V2 a -> Bool #maximum :: Ord a => V2 a -> a #minimum :: Ord a => V2 a -> a #sum :: Num a => V2 a -> a #product :: Num a => V2 a -> a # Source # Instance detailsDefined in Linear.V2 Methodstraverse :: Applicative f => (a -> f b) -> V2 a -> f (V2 b) #sequenceA :: Applicative f => V2 (f a) -> f (V2 a) #mapM :: Monad m => (a -> m b) -> V2 a -> m (V2 b) #sequence :: Monad m => V2 (m a) -> m (V2 a) # Source # Instance detailsDefined in Linear.V2 Methodsdistribute :: Functor f => f (V2 a) -> V2 (f a) #collect :: Functor f => (a -> V2 b) -> f a -> V2 (f b) #distributeM :: Monad m => m (V2 a) -> V2 (m a) #collectM :: Monad m => (a -> V2 b) -> m a -> V2 (m b) # Source # Instance detailsDefined in Linear.V2 Associated Typestype Rep V2 :: * # Methodstabulate :: (Rep V2 -> a) -> V2 a #index :: V2 a -> Rep V2 -> a # Source # Instance detailsDefined in Linear.V2 MethodsliftEq :: (a -> b -> Bool) -> V2 a -> V2 b -> Bool # Source # Instance detailsDefined in Linear.V2 MethodsliftCompare :: (a -> b -> Ordering) -> V2 a -> V2 b -> Ordering # Source # Instance detailsDefined in Linear.V2 MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (V2 a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [V2 a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (V2 a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [V2 a] # Source # Instance detailsDefined in Linear.V2 MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> V2 a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [V2 a] -> ShowS # Source # Instance detailsDefined in Linear.V2 Methodsmzip :: V2 a -> V2 b -> V2 (a, b) #mzipWith :: (a -> b -> c) -> V2 a -> V2 b -> V2 c #munzip :: V2 (a, b) -> (V2 a, V2 b) # Source # Instance detailsDefined in Linear.V2 MethodsserializeWith :: MonadPut m => (a -> m ()) -> V2 a -> m () #deserializeWith :: MonadGet m => m a -> m (V2 a) # Source # Instance detailsDefined in Linear.V2 MethodsliftHashWithSalt :: (Int -> a -> Int) -> Int -> V2 a -> Int # Source # Instance detailsDefined in Linear.V2 Methods(<.>) :: V2 (a -> b) -> V2 a -> V2 b #(.>) :: V2 a -> V2 b -> V2 b #(<.) :: V2 a -> V2 b -> V2 a #liftF2 :: (a -> b -> c) -> V2 a -> V2 b -> V2 c # Source # Instance detailsDefined in Linear.V2 Methodstraverse1 :: Apply f => (a -> f b) -> V2 a -> f (V2 b) #sequence1 :: Apply f => V2 (f b) -> f (V2 b) # Source # Instance detailsDefined in Linear.V2 Methodsfold1 :: Semigroup m => V2 m -> m #foldMap1 :: Semigroup m => (a -> m) -> V2 a -> m #toNonEmpty :: V2 a -> NonEmpty a # Source # Instance detailsDefined in Linear.V2 Methods(>>-) :: V2 a -> (a -> V2 b) -> V2 b #join :: V2 (V2 a) -> V2 a # Source # Instance detailsDefined in Linear.V2 Methodszero :: Num a => V2 a Source #(^+^) :: Num a => V2 a -> V2 a -> V2 a Source #(^-^) :: Num a => V2 a -> V2 a -> V2 a Source #lerp :: Num a => a -> V2 a -> V2 a -> V2 a Source #liftU2 :: (a -> a -> a) -> V2 a -> V2 a -> V2 a Source #liftI2 :: (a -> b -> c) -> V2 a -> V2 b -> V2 c Source # Source # Instance detailsDefined in Linear.V2 Methodsdot :: Num a => V2 a -> V2 a -> a Source #quadrance :: Num a => V2 a -> a Source #qd :: Num a => V2 a -> V2 a -> a Source #distance :: Floating a => V2 a -> V2 a -> a Source #norm :: Floating a => V2 a -> a Source #signorm :: Floating a => V2 a -> V2 a Source # Source # Instance detailsDefined in Linear.V2 Associated Typestype Size V2 :: Nat Source # MethodstoV :: V2 a -> V (Size V2) a Source #fromV :: V (Size V2) a -> V2 a Source # Source # Instance detailsDefined in Linear.V2 Methods_x :: Functor f => (a -> f a) -> V2 a -> f (V2 a) Source # Source # Instance detailsDefined in Linear.V2 Methods_y :: Functor f => (a -> f a) -> V2 a -> f (V2 a) Source #_xy :: Functor f => (V2 a -> f (V2 a)) -> V2 a -> f (V2 a) Source # Source # Instance detailsDefined in Linear.Trace Methodstrace :: Num a => V2 (V2 a) -> a Source #diagonal :: V2 (V2 a) -> V2 a Source # Source # Instance detailsDefined in Linear.Affine Associated Typestype Diff V2 :: * -> * Source # Methods(.-.) :: Num a => V2 a -> V2 a -> Diff V2 a Source #(.+^) :: Num a => V2 a -> Diff V2 a -> V2 a Source #(.-^) :: Num a => V2 a -> Diff V2 a -> V2 a Source # Unbox a => Vector Vector (V2 a) Source # Instance detailsDefined in Linear.V2 MethodsbasicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (V2 a) -> m (Vector (V2 a)) #basicUnsafeThaw :: PrimMonad m => Vector (V2 a) -> m (Mutable Vector (PrimState m) (V2 a)) #basicLength :: Vector (V2 a) -> Int #basicUnsafeSlice :: Int -> Int -> Vector (V2 a) -> Vector (V2 a) #basicUnsafeIndexM :: Monad m => Vector (V2 a) -> Int -> m (V2 a) #basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (V2 a) -> Vector (V2 a) -> m () #elemseq :: Vector (V2 a) -> V2 a -> b -> b # Unbox a => MVector MVector (V2 a) Source # Instance detailsDefined in Linear.V2 MethodsbasicLength :: MVector s (V2 a) -> Int #basicUnsafeSlice :: Int -> Int -> MVector s (V2 a) -> MVector s (V2 a) #basicOverlaps :: MVector s (V2 a) -> MVector s (V2 a) -> Bool #basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (V2 a)) #basicInitialize :: PrimMonad m => MVector (PrimState m) (V2 a) -> m () #basicUnsafeReplicate :: PrimMonad m => Int -> V2 a -> m (MVector (PrimState m) (V2 a)) #basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (V2 a) -> Int -> m (V2 a) #basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (V2 a) -> Int -> V2 a -> m () #basicClear :: PrimMonad m => MVector (PrimState m) (V2 a) -> m () #basicSet :: PrimMonad m => MVector (PrimState m) (V2 a) -> V2 a -> m () #basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (V2 a) -> MVector (PrimState m) (V2 a) -> m () #basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (V2 a) -> MVector (PrimState m) (V2 a) -> m () #basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (V2 a) -> Int -> m (MVector (PrimState m) (V2 a)) # Num r => Coalgebra r (E V2) Source # Instance detailsDefined in Linear.Algebra Methodscomult :: (E V2 -> r) -> E V2 -> E V2 -> r Source #counital :: (E V2 -> r) -> r Source # Bounded a => Bounded (V2 a) Source # Instance detailsDefined in Linear.V2 MethodsminBound :: V2 a #maxBound :: V2 a # Eq a => Eq (V2 a) Source # Instance detailsDefined in Linear.V2 Methods(==) :: V2 a -> V2 a -> Bool #(/=) :: V2 a -> V2 a -> Bool # Floating a => Floating (V2 a) Source # Instance detailsDefined in Linear.V2 Methodspi :: V2 a #exp :: V2 a -> V2 a #log :: V2 a -> V2 a #sqrt :: V2 a -> V2 a #(**) :: V2 a -> V2 a -> V2 a #logBase :: V2 a -> V2 a -> V2 a #sin :: V2 a -> V2 a #cos :: V2 a -> V2 a #tan :: V2 a -> V2 a #asin :: V2 a -> V2 a #acos :: V2 a -> V2 a #atan :: V2 a -> V2 a #sinh :: V2 a -> V2 a #cosh :: V2 a -> V2 a #tanh :: V2 a -> V2 a #asinh :: V2 a -> V2 a #acosh :: V2 a -> V2 a #atanh :: V2 a -> V2 a #log1p :: V2 a -> V2 a #expm1 :: V2 a -> V2 a #log1pexp :: V2 a -> V2 a #log1mexp :: V2 a -> V2 a # Fractional a => Fractional (V2 a) Source # Instance detailsDefined in Linear.V2 Methods(/) :: V2 a -> V2 a -> V2 a #recip :: V2 a -> V2 a # Data a => Data (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> V2 a -> c (V2 a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (V2 a) #toConstr :: V2 a -> Constr #dataTypeOf :: V2 a -> DataType #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (V2 a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V2 a)) #gmapT :: (forall b. Data b => b -> b) -> V2 a -> V2 a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V2 a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V2 a -> r #gmapQ :: (forall d. Data d => d -> u) -> V2 a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> V2 a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> V2 a -> m (V2 a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> V2 a -> m (V2 a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> V2 a -> m (V2 a) # Num a => Num (V2 a) Source # Instance detailsDefined in Linear.V2 Methods(+) :: V2 a -> V2 a -> V2 a #(-) :: V2 a -> V2 a -> V2 a #(*) :: V2 a -> V2 a -> V2 a #negate :: V2 a -> V2 a #abs :: V2 a -> V2 a #signum :: V2 a -> V2 a # Ord a => Ord (V2 a) Source # Instance detailsDefined in Linear.V2 Methodscompare :: V2 a -> V2 a -> Ordering #(<) :: V2 a -> V2 a -> Bool #(<=) :: V2 a -> V2 a -> Bool #(>) :: V2 a -> V2 a -> Bool #(>=) :: V2 a -> V2 a -> Bool #max :: V2 a -> V2 a -> V2 a #min :: V2 a -> V2 a -> V2 a # Read a => Read (V2 a) Source # Instance detailsDefined in Linear.V2 MethodsreadsPrec :: Int -> ReadS (V2 a) #readList :: ReadS [V2 a] #readPrec :: ReadPrec (V2 a) # Show a => Show (V2 a) Source # Instance detailsDefined in Linear.V2 MethodsshowsPrec :: Int -> V2 a -> ShowS #show :: V2 a -> String #showList :: [V2 a] -> ShowS # Ix a => Ix (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsrange :: (V2 a, V2 a) -> [V2 a] #index :: (V2 a, V2 a) -> V2 a -> Int #unsafeIndex :: (V2 a, V2 a) -> V2 a -> IntinRange :: (V2 a, V2 a) -> V2 a -> Bool #rangeSize :: (V2 a, V2 a) -> Int #unsafeRangeSize :: (V2 a, V2 a) -> Int Generic (V2 a) Source # Instance detailsDefined in Linear.V2 Associated Typestype Rep (V2 a) :: * -> * # Methodsfrom :: V2 a -> Rep (V2 a) x #to :: Rep (V2 a) x -> V2 a # Storable a => Storable (V2 a) Source # Instance detailsDefined in Linear.V2 MethodssizeOf :: V2 a -> Int #alignment :: V2 a -> Int #peekElemOff :: Ptr (V2 a) -> Int -> IO (V2 a) #pokeElemOff :: Ptr (V2 a) -> Int -> V2 a -> IO () #peekByteOff :: Ptr b -> Int -> IO (V2 a) #pokeByteOff :: Ptr b -> Int -> V2 a -> IO () #peek :: Ptr (V2 a) -> IO (V2 a) #poke :: Ptr (V2 a) -> V2 a -> IO () # Binary a => Binary (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsput :: V2 a -> Put #get :: Get (V2 a) #putList :: [V2 a] -> Put # Serial a => Serial (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsserialize :: MonadPut m => V2 a -> m () #deserialize :: MonadGet m => m (V2 a) # Serialize a => Serialize (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsput :: Putter (V2 a) #get :: Get (V2 a) # NFData a => NFData (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsrnf :: V2 a -> () # Hashable a => Hashable (V2 a) Source # Instance detailsDefined in Linear.V2 MethodshashWithSalt :: Int -> V2 a -> Int #hash :: V2 a -> Int # Unbox a => Unbox (V2 a) Source # Instance detailsDefined in Linear.V2 Ixed (V2 a) Source # Instance detailsDefined in Linear.V2 Methodsix :: Index (V2 a) -> Traversal' (V2 a) (IxValue (V2 a)) # Epsilon a => Epsilon (V2 a) Source # Instance detailsDefined in Linear.V2 MethodsnearZero :: V2 a -> Bool Source # Source # Instance detailsDefined in Linear.V2 Associated Typestype Rep1 V2 :: k -> * # Methodsfrom1 :: V2 a -> Rep1 V2 a #to1 :: Rep1 V2 a -> V2 a # Source # Instance detailsDefined in Linear.V2 Methodsimap :: (E V2 -> a -> b) -> V2 a -> V2 b #imapped :: (Indexable (E V2) p, Settable f) => p a (f b) -> V2 a -> f (V2 b) # Source # Instance detailsDefined in Linear.V2 MethodsifoldMap :: Monoid m => (E V2 -> a -> m) -> V2 a -> m #ifolded :: (Indexable (E V2) p, Contravariant f, Applicative f) => p a (f a) -> V2 a -> f (V2 a) #ifoldr :: (E V2 -> a -> b -> b) -> b -> V2 a -> b #ifoldl :: (E V2 -> b -> a -> b) -> b -> V2 a -> b #ifoldr' :: (E V2 -> a -> b -> b) -> b -> V2 a -> b #ifoldl' :: (E V2 -> b -> a -> b) -> b -> V2 a -> b # Source # Instance detailsDefined in Linear.V2 Methodsitraverse :: Applicative f => (E V2 -> a -> f b) -> V2 a -> f (V2 b) #itraversed :: (Indexable (E V2) p, Applicative f) => p a (f b) -> V2 a -> f (V2 b) # Each (V2 a) (V2 b) a b Source # Instance detailsDefined in Linear.V2 Methodseach :: Traversal (V2 a) (V2 b) a b # Field1 (V2 a) (V2 a) a a Source # Instance detailsDefined in Linear.V2 Methods_1 :: Lens (V2 a) (V2 a) a a # Field2 (V2 a) (V2 a) a a Source # Instance detailsDefined in Linear.V2 Methods_2 :: Lens (V2 a) (V2 a) a a # type Rep V2 Source # Instance detailsDefined in Linear.V2 type Rep V2 = E V2 type Size V2 Source # Instance detailsDefined in Linear.V2 type Size V2 = 2 type Diff V2 Source # Instance detailsDefined in Linear.Affine type Diff V2 = V2 data MVector s (V2 a) Source # Instance detailsDefined in Linear.V2 data MVector s (V2 a) = MV_V2 !Int !(MVector s a) type Rep (V2 a) Source # Instance detailsDefined in Linear.V2 type Rep (V2 a) = D1 (MetaData "V2" "Linear.V2" "linear-1.20.8-4jvM2AhWPKJ52IYIsAvjCt" False) (C1 (MetaCons "V2" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 a))) data Vector (V2 a) Source # Instance detailsDefined in Linear.V2 data Vector (V2 a) = V_V2 !Int !(Vector a) type Index (V2 a) Source # Instance detailsDefined in Linear.V2 type Index (V2 a) = E V2 type IxValue (V2 a) Source # Instance detailsDefined in Linear.V2 type IxValue (V2 a) = a type Rep1 V2 Source # Instance detailsDefined in Linear.V2 type Rep1 V2 = D1 (MetaData "V2" "Linear.V2" "linear-1.20.8-4jvM2AhWPKJ52IYIsAvjCt" False) (C1 (MetaCons "V2" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1 :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) Par1)) class R1 t where Source # A space that has at least 1 basis vector _x. Minimal complete definition _x Methods _x :: Lens' (t a) a Source # >>> V1 2 ^._x 2  >>> V1 2 & _x .~ 3 V1 3  Instances  Source # Instance detailsDefined in Linear.V1 Methods_x :: Functor f => (a -> f a) -> Identity a -> f (Identity a) Source # Source # Instance detailsDefined in Linear.V1 Methods_x :: Functor f => (a -> f a) -> V1 a -> f (V1 a) Source # Source # Instance detailsDefined in Linear.V2 Methods_x :: Functor f => (a -> f a) -> V2 a -> f (V2 a) Source # Source # Instance detailsDefined in Linear.V3 Methods_x :: Functor f => (a -> f a) -> V3 a -> f (V3 a) Source # Source # Instance detailsDefined in Linear.V4 Methods_x :: Functor f => (a -> f a) -> V4 a -> f (V4 a) Source # R1 f => R1 (Point f) Source # Instance detailsDefined in Linear.Affine Methods_x :: Functor f0 => (a -> f0 a) -> Point f a -> f0 (Point f a) Source # class R1 t => R2 t where Source # A space that distinguishes 2 orthogonal basis vectors _x and _y, but may have more. Minimal complete definition _xy Methods _y :: Lens' (t a) a Source # >>> V2 1 2 ^._y 2  >>> V2 1 2 & _y .~ 3 V2 1 3  _xy :: Lens' (t a) (V2 a) Source # Instances  Source # Instance detailsDefined in Linear.V2 Methods_y :: Functor f => (a -> f a) -> V2 a -> f (V2 a) Source #_xy :: Functor f => (V2 a -> f (V2 a)) -> V2 a -> f (V2 a) Source # Source # Instance detailsDefined in Linear.V3 Methods_y :: Functor f => (a -> f a) -> V3 a -> f (V3 a) Source #_xy :: Functor f => (V2 a -> f (V2 a)) -> V3 a -> f (V3 a) Source # Source # Instance detailsDefined in Linear.V4 Methods_y :: Functor f => (a -> f a) -> V4 a -> f (V4 a) Source #_xy :: Functor f => (V2 a -> f (V2 a)) -> V4 a -> f (V4 a) Source # R2 f => R2 (Point f) Source # Instance detailsDefined in Linear.Affine Methods_y :: Functor f0 => (a -> f0 a) -> Point f a -> f0 (Point f a) Source #_xy :: Functor f0 => (V2 a -> f0 (V2 a)) -> Point f a -> f0 (Point f a) Source # _yx :: R2 t => Lens' (t a) (V2 a) Source # >>> V2 1 2 ^. _yx V2 2 1  ex :: R1 t => E t Source # ey :: R2 t => E t Source # perp :: Num a => V2 a -> V2 a Source # the counter-clockwise perpendicular vector >>> perp V2 10 20
V2 (-20) 10


angle :: Floating a => a -> V2 a Source #

crossZ :: Num a => V2 a -> V2 a -> a Source #

The Z-component of the cross product of two vectors in the XY-plane.

>>> crossZ (V2 1 0) (V2 0 1)
1