linear-1.20.6: Linear Algebra

Linear.V

Description

n-D Vectors

Synopsis

# Documentation

newtype V n a Source #

Constructors

 V FieldstoVector :: Vector a

Instances

 FunctorWithIndex Int (V k n) Source # 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) # Source # 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 # Source # 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) Source # 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) Source # 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) Source # MethodsreflectDim :: 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 # 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) Source # Methodsmfix :: (a -> V k n a) -> V k n a # Dim k n => Applicative (V k n) Source # 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) Source # 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) Source # 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) Source # 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) Source # 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) Source # 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) Source # MethodsliftEq :: (a -> b -> Bool) -> V k n a -> V k n b -> Bool # Ord1 (V k n) Source # MethodsliftCompare :: (a -> b -> Ordering) -> V k n a -> V k n b -> Ordering # Dim k n => Read1 (V k n) Source # 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) Source # 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) Source # 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) Source # MethodsserializeWith :: 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 # Methodszero :: 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 # Methodsdot :: 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 Typestype Size (V Nat n :: * -> *) :: Nat Source # MethodstoV :: 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 # Methodstrace :: 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 Typestype 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 # MethodsminBound :: 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 # 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) 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 # 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) 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 # 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) Source # 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) Source # MethodsshowsPrec :: 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 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) Source # 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) Source # 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) Source # 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) Source # Methodsput :: Putter (V k n a) #get :: Get (V k n a) # NFData a => NFData (V k n a) Source # Methodsrnf :: V k n a -> () # (Dim k n, Unbox a) => Unbox (V k n a) Source # Ixed (V k n a) Source # 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) Source # MethodsnearZero :: V k n a -> Bool Source # Each (V k n a) (V k n b) a b Source # Methodseach :: 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.6-7GMSraBBXwf75Iqz3D0i5l" 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.6-7GMSraBBXwf75Iqz3D0i5l" 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 # MethodsreflectDim :: p n -> Int Source # Dim k n => Dim * (V k n a) Source # MethodsreflectDim :: 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

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