linear-1.20.7: Linear Algebra

Linear.V

Description

n-D Vectors

Synopsis

Documentation

newtype V n a #

Constructors

 V FieldstoVector :: Vector a

Instances

 FunctorWithIndex Int (V k n) # Methodsimap :: (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) # # MethodsifoldMap :: 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 # # Methodsitraverse :: 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) # MethodsbasicUnsafeFreeze :: 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) # MethodsbasicLength :: 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) # MethodsreflectDim :: p n -> Int # Dim k n => Monad (V k n) # 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) # Methodsfmap :: (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) # Methodsmfix :: (a -> V k n a) -> V k n a # Dim k n => Applicative (V k n) # Methodspure :: 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) # Methodsfold :: 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) # Methodstraverse :: 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) # Associated Typestype Rep1 (V k n :: * -> *) :: * -> * # Methodsfrom1 :: 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) # Methodsdistribute :: 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) # Associated Typestype Rep (V k n :: * -> *) :: * # Methodstabulate :: (Rep (V k n) -> a) -> V k n a #index :: V k n a -> Rep (V k n) -> a # Eq1 (V k n) # MethodsliftEq :: (a -> b -> Bool) -> V k n a -> V k n b -> Bool # Ord1 (V k n) # MethodsliftCompare :: (a -> b -> Ordering) -> V k n a -> V k n b -> Ordering # Dim k n => Read1 (V k n) # MethodsliftReadsPrec :: (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) # MethodsliftShowsPrec :: (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) # Methodsmzip :: 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) # MethodsserializeWith :: MonadPut m => (a -> m ()) -> V k n a -> m () #deserializeWith :: MonadGet m => m a -> m (V k n a) # Apply (V k n) # 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) # 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) # Methodszero :: Num a => V k n a #(^+^) :: Num a => V k n a -> V k n a -> V k n a #(^-^) :: Num a => V k n a -> V k n a -> V k n a #lerp :: Num a => a -> V k n a -> V k n a -> V k n a #liftU2 :: (a -> a -> a) -> V k n a -> V k n a -> V k n a #liftI2 :: (a -> b -> c) -> V k n a -> V k n b -> V k n c # Dim k n => Metric (V k n) # Methodsdot :: Num a => V k n a -> V k n a -> a #quadrance :: Num a => V k n a -> a #qd :: Num a => V k n a -> V k n a -> a #distance :: Floating a => V k n a -> V k n a -> a #norm :: Floating a => V k n a -> a #signorm :: Floating a => V k n a -> V k n a # Finite (V Nat n) # Associated Typestype Size (V Nat n :: * -> *) :: Nat # MethodstoV :: V Nat n a -> V Nat (Size (V Nat n)) a #fromV :: V Nat (Size (V Nat n)) a -> V Nat n a # Dim k n => Trace (V k n) # Methodstrace :: Num a => V k n (V k n a) -> a #diagonal :: V k n (V k n a) -> V k n a # Dim * n => Affine (V * n) # Associated Typestype Diff (V * n :: * -> *) :: * -> * # Methods(.-.) :: Num a => V * n a -> V * n a -> Diff (V * n) a #(.+^) :: Num a => V * n a -> Diff (V * n) a -> V * n a #(.-^) :: Num a => V * n a -> Diff (V * n) a -> V * n a # (Bounded a, Dim k n) => Bounded (V k n a) # MethodsminBound :: V k n a #maxBound :: V k n a # Eq a => Eq (V k n a) # 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) # Methodspi :: 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) # 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) # Methodsgfoldl :: (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) # 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) # Methodscompare :: 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) # MethodsreadsPrec :: 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) # MethodsshowsPrec :: Int -> V k n a -> ShowS #show :: V k n a -> String #showList :: [V k n a] -> ShowS # Generic (V k n a) # Associated Typestype Rep (V k n a) :: * -> * # Methodsfrom :: 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) # MethodssizeOf :: 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) # Methodsput :: 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) # Methodsserialize :: 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) # Methodsput :: Putter (V k n a) #get :: Get (V k n a) # NFData a => NFData (V k n a) # Methodsrnf :: V k n a -> () # (Dim k n, Unbox a) => Unbox (V k n a) # Ixed (V k n a) # Methodsix :: 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) # MethodsnearZero :: V k n a -> Bool # Each (V k n a) (V k n b) a b # Methodseach :: Traversal (V k n a) (V k n b) a b # data MVector s (V k n a) # data MVector s (V k n a) = MV_VN !Int !(MVector s a) type Rep1 (V k n) # type Rep1 (V k n) = D1 (MetaData "V" "Linear.V" "linear-1.20.7-LM9jZhdWZ2yIxbtdhUjC67" True) (C1 (MetaCons "V" PrefixI True) (S1 (MetaSel (Just Symbol "toVector") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 Vector))) type Rep (V k n) # type Rep (V k n) = Int type Size (V Nat n) # type Size (V Nat n) = n type Diff (V * n) # type Diff (V * n) = V * n type Rep (V k n a) # type Rep (V k n a) = D1 (MetaData "V" "Linear.V" "linear-1.20.7-LM9jZhdWZ2yIxbtdhUjC67" True) (C1 (MetaCons "V" PrefixI True) (S1 (MetaSel (Just Symbol "toVector") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector a)))) data Vector (V k n a) # data Vector (V k n a) = V_VN !Int !(Vector a) type Index (V k n a) # type Index (V k n a) = Int type IxValue (V k n a) # 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 #

class Dim n where #

Minimal complete definition

reflectDim

Methods

reflectDim :: p n -> Int #

Instances

 KnownNat n => Dim Nat n # MethodsreflectDim :: p n -> Int # Dim k n => Dim * (V k n a) # MethodsreflectDim :: p n -> Int #

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

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

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

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

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

class Finite v where #

Minimal complete definition

fromV

Associated Types

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

Methods

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

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

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

Instances

 # Associated Typestype Size (Complex :: * -> *) :: Nat # MethodstoV :: Complex a -> V Nat (Size Complex) a #fromV :: V Nat (Size Complex) a -> Complex a # # Associated Typestype Size (V0 :: * -> *) :: Nat # MethodstoV :: V0 a -> V Nat (Size V0) a #fromV :: V Nat (Size V0) a -> V0 a # # Associated Typestype Size (V1 :: * -> *) :: Nat # MethodstoV :: V1 a -> V Nat (Size V1) a #fromV :: V Nat (Size V1) a -> V1 a # # Associated Typestype Size (V2 :: * -> *) :: Nat # MethodstoV :: V2 a -> V Nat (Size V2) a #fromV :: V Nat (Size V2) a -> V2 a # # Associated Typestype Size (V3 :: * -> *) :: Nat # MethodstoV :: V3 a -> V Nat (Size V3) a #fromV :: V Nat (Size V3) a -> V3 a # # Associated Typestype Size (V4 :: * -> *) :: Nat # MethodstoV :: V4 a -> V Nat (Size V4) a #fromV :: V Nat (Size V4) a -> V4 a # # Associated Typestype Size (Plucker :: * -> *) :: Nat # MethodstoV :: Plucker a -> V Nat (Size Plucker) a #fromV :: V Nat (Size Plucker) a -> Plucker a # # Associated Typestype Size (Quaternion :: * -> *) :: Nat # MethodstoV :: Quaternion a -> V Nat (Size Quaternion) a #fromV :: V Nat (Size Quaternion) a -> Quaternion a # Finite f => Finite (Point f) # Associated Typestype Size (Point f :: * -> *) :: Nat # MethodstoV :: Point f a -> V Nat (Size (Point f)) a #fromV :: V Nat (Size (Point f)) a -> Point f a # Finite (V Nat n) # Associated Typestype Size (V Nat n :: * -> *) :: Nat # MethodstoV :: V Nat n a -> V Nat (Size (V Nat n)) a #fromV :: V Nat (Size (V Nat n)) a -> V Nat n a #

_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) #