linear-1.20.7: Linear Algebra

Copyright(C) 2012-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellTrustworthy
LanguageHaskell98

Linear.V

Description

n-D Vectors

Synopsis

Documentation

newtype V n a Source #

Constructors

V 

Fields

Instances

FunctorWithIndex Int (V k n) Source # 

Methods

imap :: (Int -> a -> b) -> V k n a -> V k n b #

imapped :: (Indexable Int p, Settable f) => p a (f b) -> V k n a -> f (V k n b) #

FoldableWithIndex Int (V k n) Source # 

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> V k n a -> m #

ifolded :: (Indexable Int p, Contravariant f, Applicative f) => p a (f a) -> V k n a -> f (V k n a) #

ifoldr :: (Int -> a -> b -> b) -> b -> V k n a -> b #

ifoldl :: (Int -> b -> a -> b) -> b -> V k n a -> b #

ifoldr' :: (Int -> a -> b -> b) -> b -> V k n a -> b #

ifoldl' :: (Int -> b -> a -> b) -> b -> V k n a -> b #

TraversableWithIndex Int (V k n) Source # 

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> V k n a -> f (V k n b) #

itraversed :: (Indexable Int p, Applicative f) => p a (f b) -> V k n a -> f (V k n b) #

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

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (V k n a) -> m (Vector (V k n a)) #

basicUnsafeThaw :: PrimMonad m => Vector (V k n a) -> m (Mutable Vector (PrimState m) (V k n a)) #

basicLength :: Vector (V k n a) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (V k n a) -> Vector (V k n a) #

basicUnsafeIndexM :: Monad m => Vector (V k n a) -> Int -> m (V k n a) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (V k n a) -> Vector (V k n a) -> m () #

elemseq :: Vector (V k n a) -> V k n a -> b -> b #

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

Methods

basicLength :: MVector s (V k n a) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (V k n a) -> MVector s (V k n a) #

basicOverlaps :: MVector s (V k n a) -> MVector s (V k n a) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (V k n a)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (V k n a) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> V k n a -> m (MVector (PrimState m) (V k n a)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (V k n a) -> Int -> m (V k n a) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (V k n a) -> Int -> V k n a -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (V k n a) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (V k n a) -> V k n a -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (V k n a) -> MVector (PrimState m) (V k n a) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (V k n a) -> MVector (PrimState m) (V k n a) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (V k n a) -> Int -> m (MVector (PrimState m) (V k n a)) #

Dim k n => Dim * (V k n a) Source # 

Methods

reflectDim :: p n -> Int Source #

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

Methods

(>>=) :: V k n a -> (a -> V k n b) -> V k n b #

(>>) :: V k n a -> V k n b -> V k n b #

return :: a -> V k n a #

fail :: String -> V k n a #

Functor (V k n) Source # 

Methods

fmap :: (a -> b) -> V k n a -> V k n b #

(<$) :: a -> V k n b -> V k n a #

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

Methods

mfix :: (a -> V k n a) -> V k n a #

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

Methods

pure :: a -> V k n a #

(<*>) :: V k n (a -> b) -> V k n a -> V k n b #

(*>) :: V k n a -> V k n b -> V k n b #

(<*) :: V k n a -> V k n b -> V k n a #

Foldable (V k n) Source # 

Methods

fold :: Monoid m => V k n m -> m #

foldMap :: Monoid m => (a -> m) -> V k n a -> m #

foldr :: (a -> b -> b) -> b -> V k n a -> b #

foldr' :: (a -> b -> b) -> b -> V k n a -> b #

foldl :: (b -> a -> b) -> b -> V k n a -> b #

foldl' :: (b -> a -> b) -> b -> V k n a -> b #

foldr1 :: (a -> a -> a) -> V k n a -> a #

foldl1 :: (a -> a -> a) -> V k n a -> a #

toList :: V k n a -> [a] #

null :: V k n a -> Bool #

length :: V k n a -> Int #

elem :: Eq a => a -> V k n a -> Bool #

maximum :: Ord a => V k n a -> a #

minimum :: Ord a => V k n a -> a #

sum :: Num a => V k n a -> a #

product :: Num a => V k n a -> a #

Traversable (V k n) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> V k n a -> f (V k n b) #

sequenceA :: Applicative f => V k n (f a) -> f (V k n a) #

mapM :: Monad m => (a -> m b) -> V k n a -> m (V k n b) #

sequence :: Monad m => V k n (m a) -> m (V k n a) #

Generic1 (V k n) Source # 

Associated Types

type Rep1 (V k n :: * -> *) :: * -> * #

Methods

from1 :: V k n a -> Rep1 (V k n) a #

to1 :: Rep1 (V k n) a -> V k n a #

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

Methods

distribute :: Functor f => f (V k n a) -> V k n (f a) #

collect :: Functor f => (a -> V k n b) -> f a -> V k n (f b) #

distributeM :: Monad m => m (V k n a) -> V k n (m a) #

collectM :: Monad m => (a -> V k n b) -> m a -> V k n (m b) #

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

Associated Types

type Rep (V k n :: * -> *) :: * #

Methods

tabulate :: (Rep (V k n) -> a) -> V k n a #

index :: V k n a -> Rep (V k n) -> a #

Eq1 (V k n) Source # 

Methods

liftEq :: (a -> b -> Bool) -> V k n a -> V k n b -> Bool #

Ord1 (V k n) Source # 

Methods

liftCompare :: (a -> b -> Ordering) -> V k n a -> V k n b -> Ordering #

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

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (V k n a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [V k n a] #

Show1 (V k n) Source # 

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> V k n a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [V k n a] -> ShowS #

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

Methods

mzip :: V k n a -> V k n b -> V k n (a, b) #

mzipWith :: (a -> b -> c) -> V k n a -> V k n b -> V k n c #

munzip :: V k n (a, b) -> (V k n a, V k n b) #

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

Methods

serializeWith :: MonadPut m => (a -> m ()) -> V k n a -> m () #

deserializeWith :: MonadGet m => m a -> m (V k n a) #

Apply (V k n) Source # 

Methods

(<.>) :: V k n (a -> b) -> V k n a -> V k n b #

(.>) :: V k n a -> V k n b -> V k n b #

(<.) :: V k n a -> V k n b -> V k n a #

Bind (V k n) Source # 

Methods

(>>-) :: V k n a -> (a -> V k n b) -> V k n b #

join :: V k n (V k n a) -> V k n a #

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

Methods

zero :: Num a => V k n a Source #

(^+^) :: Num a => V k n a -> V k n a -> V k n a Source #

(^-^) :: Num a => V k n a -> V k n a -> V k n a Source #

lerp :: Num a => a -> V k n a -> V k n a -> V k n a Source #

liftU2 :: (a -> a -> a) -> V k n a -> V k n a -> V k n a Source #

liftI2 :: (a -> b -> c) -> V k n a -> V k n b -> V k n c Source #

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

Methods

dot :: Num a => V k n a -> V k n a -> a Source #

quadrance :: Num a => V k n a -> a Source #

qd :: Num a => V k n a -> V k n a -> a Source #

distance :: Floating a => V k n a -> V k n a -> a Source #

norm :: Floating a => V k n a -> a Source #

signorm :: Floating a => V k n a -> V k n a Source #

Finite (V Nat n) Source # 

Associated Types

type Size (V Nat n :: * -> *) :: Nat Source #

Methods

toV :: V Nat n a -> V Nat (Size (V Nat n)) a Source #

fromV :: V Nat (Size (V Nat n)) a -> V Nat n a Source #

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

Methods

trace :: Num a => V k n (V k n a) -> a Source #

diagonal :: V k n (V k n a) -> V k n a Source #

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

Associated Types

type Diff (V * n :: * -> *) :: * -> * Source #

Methods

(.-.) :: Num a => V * n a -> V * n a -> Diff (V * n) a Source #

(.+^) :: Num a => V * n a -> Diff (V * n) a -> V * n a Source #

(.-^) :: Num a => V * n a -> Diff (V * n) a -> V * n a Source #

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

Methods

minBound :: V k n a #

maxBound :: V k n a #

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

Methods

(==) :: V k n a -> V k n a -> Bool #

(/=) :: V k n a -> V k n a -> Bool #

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

Methods

pi :: V k n a #

exp :: V k n a -> V k n a #

log :: V k n a -> V k n a #

sqrt :: V k n a -> V k n a #

(**) :: V k n a -> V k n a -> V k n a #

logBase :: V k n a -> V k n a -> V k n a #

sin :: V k n a -> V k n a #

cos :: V k n a -> V k n a #

tan :: V k n a -> V k n a #

asin :: V k n a -> V k n a #

acos :: V k n a -> V k n a #

atan :: V k n a -> V k n a #

sinh :: V k n a -> V k n a #

cosh :: V k n a -> V k n a #

tanh :: V k n a -> V k n a #

asinh :: V k n a -> V k n a #

acosh :: V k n a -> V k n a #

atanh :: V k n a -> V k n a #

log1p :: V k n a -> V k n a #

expm1 :: V k n a -> V k n a #

log1pexp :: V k n a -> V k n a #

log1mexp :: V k n a -> V k n a #

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

Methods

(/) :: V k n a -> V k n a -> V k n a #

recip :: V k n a -> V k n a #

fromRational :: Rational -> V k n a #

(Typeable (* -> *) (V k n), Typeable * (V k n a), Dim k n, Data a) => Data (V k n a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> V k n a -> c (V k n a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (V k n a) #

toConstr :: V k n a -> Constr #

dataTypeOf :: V k n a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (V k n a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V k n a)) #

gmapT :: (forall b. Data b => b -> b) -> V k n a -> V k n a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V k n a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V k n a -> r #

gmapQ :: (forall d. Data d => d -> u) -> V k n a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> V k n a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> V k n a -> m (V k n a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> V k n a -> m (V k n a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> V k n a -> m (V k n a) #

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

Methods

(+) :: V k n a -> V k n a -> V k n a #

(-) :: V k n a -> V k n a -> V k n a #

(*) :: V k n a -> V k n a -> V k n a #

negate :: V k n a -> V k n a #

abs :: V k n a -> V k n a #

signum :: V k n a -> V k n a #

fromInteger :: Integer -> V k n a #

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

Methods

compare :: V k n a -> V k n a -> Ordering #

(<) :: V k n a -> V k n a -> Bool #

(<=) :: V k n a -> V k n a -> Bool #

(>) :: V k n a -> V k n a -> Bool #

(>=) :: V k n a -> V k n a -> Bool #

max :: V k n a -> V k n a -> V k n a #

min :: V k n a -> V k n a -> V k n a #

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

Methods

readsPrec :: Int -> ReadS (V k n a) #

readList :: ReadS [V k n a] #

readPrec :: ReadPrec (V k n a) #

readListPrec :: ReadPrec [V k n a] #

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

Methods

showsPrec :: Int -> V k n a -> ShowS #

show :: V k n a -> String #

showList :: [V k n a] -> ShowS #

Generic (V k n a) Source # 

Associated Types

type Rep (V k n a) :: * -> * #

Methods

from :: V k n a -> Rep (V k n a) x #

to :: Rep (V k n a) x -> V k n a #

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

Methods

sizeOf :: V k n a -> Int #

alignment :: V k n a -> Int #

peekElemOff :: Ptr (V k n a) -> Int -> IO (V k n a) #

pokeElemOff :: Ptr (V k n a) -> Int -> V k n a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (V k n a) #

pokeByteOff :: Ptr b -> Int -> V k n a -> IO () #

peek :: Ptr (V k n a) -> IO (V k n a) #

poke :: Ptr (V k n a) -> V k n a -> IO () #

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

Methods

put :: V k n a -> Put #

get :: Get (V k n a) #

putList :: [V k n a] -> Put #

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

Methods

serialize :: MonadPut m => V k n a -> m () #

deserialize :: MonadGet m => m (V k n a) #

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

Methods

put :: Putter (V k n a) #

get :: Get (V k n a) #

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

Methods

rnf :: V k n a -> () #

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

Methods

ix :: Index (V k n a) -> Traversal' (V k n a) (IxValue (V k n a)) #

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

Methods

nearZero :: V k n a -> Bool Source #

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

Methods

each :: Traversal (V k n a) (V k n b) a b #

data MVector s (V k n a) Source # 
data MVector s (V k n a) = MV_VN !Int !(MVector s a)
type Rep1 (V k n) Source # 
type Rep1 (V k n) = D1 (MetaData "V" "Linear.V" "linear-1.20.7-5lThnmKUFiyAbTBcmo6MON" True) (C1 (MetaCons "V" PrefixI True) (S1 (MetaSel (Just Symbol "toVector") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 Vector)))
type Rep (V k n) Source # 
type Rep (V k n) = Int
type Size (V Nat n) Source # 
type Size (V Nat n) = n
type Diff (V * n) Source # 
type Diff (V * n) = V * n
type Rep (V k n a) Source # 
type Rep (V k n a) = D1 (MetaData "V" "Linear.V" "linear-1.20.7-5lThnmKUFiyAbTBcmo6MON" True) (C1 (MetaCons "V" PrefixI True) (S1 (MetaSel (Just Symbol "toVector") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector a))))
data Vector (V k n a) Source # 
data Vector (V k n a) = V_VN !Int !(Vector a)
type Index (V k n a) Source # 
type Index (V k n a) = Int
type IxValue (V k n a) Source # 
type IxValue (V k n a) = a

int :: Int -> TypeQ #

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).

dim :: forall n a. Dim n => V n a -> Int Source #

class Dim n where Source #

Minimal complete definition

reflectDim

Methods

reflectDim :: p n -> Int Source #

Instances

KnownNat n => Dim Nat n Source # 

Methods

reflectDim :: p n -> Int Source #

Dim k n => Dim * (V k n a) Source # 

Methods

reflectDim :: p n -> Int Source #

reifyDim :: Int -> (forall n. Dim n => Proxy n -> r) -> r Source #

reifyVector :: forall a r. Vector a -> (forall n. Dim n => V n a -> r) -> r Source #

reifyDimNat :: Int -> (forall n. KnownNat n => Proxy n -> r) -> r Source #

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

fromVector :: forall n a. Dim n => Vector a -> Maybe (V n a) Source #

class Finite v where Source #

Minimal complete definition

fromV

Associated Types

type Size (v :: * -> *) :: Nat Source #

Methods

toV :: v a -> V (Size v) a Source #

toV :: Foldable v => v a -> V (Size v) a Source #

fromV :: V (Size v) a -> v a Source #

Instances

Finite Complex Source # 

Associated Types

type Size (Complex :: * -> *) :: Nat Source #

Methods

toV :: Complex a -> V Nat (Size Complex) a Source #

fromV :: V Nat (Size Complex) a -> Complex a Source #

Finite V0 Source # 

Associated Types

type Size (V0 :: * -> *) :: Nat Source #

Methods

toV :: V0 a -> V Nat (Size V0) a Source #

fromV :: V Nat (Size V0) a -> V0 a Source #

Finite V1 Source # 

Associated Types

type Size (V1 :: * -> *) :: Nat Source #

Methods

toV :: V1 a -> V Nat (Size V1) a Source #

fromV :: V Nat (Size V1) a -> V1 a Source #

Finite V2 Source # 

Associated Types

type Size (V2 :: * -> *) :: Nat Source #

Methods

toV :: V2 a -> V Nat (Size V2) a Source #

fromV :: V Nat (Size V2) a -> V2 a Source #

Finite V3 Source # 

Associated Types

type Size (V3 :: * -> *) :: Nat Source #

Methods

toV :: V3 a -> V Nat (Size V3) a Source #

fromV :: V Nat (Size V3) a -> V3 a Source #

Finite V4 Source # 

Associated Types

type Size (V4 :: * -> *) :: Nat Source #

Methods

toV :: V4 a -> V Nat (Size V4) a Source #

fromV :: V Nat (Size V4) a -> V4 a Source #

Finite Plucker Source # 

Associated Types

type Size (Plucker :: * -> *) :: Nat Source #

Methods

toV :: Plucker a -> V Nat (Size Plucker) a Source #

fromV :: V Nat (Size Plucker) a -> Plucker a Source #

Finite Quaternion Source # 

Associated Types

type Size (Quaternion :: * -> *) :: Nat Source #

Finite f => Finite (Point f) Source # 

Associated Types

type Size (Point f :: * -> *) :: Nat Source #

Methods

toV :: Point f a -> V Nat (Size (Point f)) a Source #

fromV :: V Nat (Size (Point f)) a -> Point f a Source #

Finite (V Nat n) Source # 

Associated Types

type Size (V Nat n :: * -> *) :: Nat Source #

Methods

toV :: V Nat n a -> V Nat (Size (V Nat n)) a Source #

fromV :: V Nat (Size (V Nat n)) a -> V Nat n a Source #

_V :: (Finite u, Finite v) => Iso (V (Size u) a) (V (Size v) b) (u a) (v b) Source #

_V' :: Finite v => Iso (V (Size v) a) (V (Size v) b) (v a) (v b) Source #