{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveLift #-}
#ifndef MIN_VERSION_hashable
#define MIN_VERSION_hashable(x,y,z) 1
#endif
#ifndef MIN_VERSION_vector
#define MIN_VERSION_vector(x,y,z) 1
#endif
#ifndef MIN_VERSION_transformers
#define MIN_VERSION_transformers(x,y,z) 1
#endif
#ifndef MIN_VERSION_base
#define MIN_VERSION_base(x,y,z) 1
#endif
module Linear.V1
( V1(..)
, R1(..)
, ex
) where
import Control.Applicative
import Control.DeepSeq (NFData)
import Control.Monad (liftM)
import Control.Monad.Fix
import Control.Monad.Zip
import Control.Lens as Lens
import Data.Binary as Binary
import Data.Bytes.Serial
import Data.Serialize as Cereal
import Data.Data
import Data.Distributive
import Data.Foldable
import qualified Data.Foldable.WithIndex as WithIndex
import Data.Functor.Bind
import Data.Functor.Classes
import Data.Functor.Rep
import qualified Data.Functor.WithIndex as WithIndex
import Data.Hashable
import Data.Hashable.Lifted
import Data.Semigroup.Foldable
import qualified Data.Traversable.WithIndex as WithIndex
import qualified Data.Vector as V
import Linear.V
import Foreign.Storable (Storable)
import GHC.Arr (Ix(..))
import GHC.Generics (Generic, Generic1)
#if defined(MIN_VERSION_template_haskell)
import Language.Haskell.TH.Syntax (Lift)
#endif
import Linear.Metric
import Linear.Epsilon
import Linear.Vector
import Prelude hiding (sum)
import System.Random (Random(..))
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup
#endif
import qualified Data.Vector.Generic.Mutable as M
import qualified Data.Vector.Generic as G
import qualified Data.Vector.Unboxed.Base as U
newtype V1 a = V1 a
deriving (V1 a -> V1 a -> Bool
forall a. Eq a => V1 a -> V1 a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: V1 a -> V1 a -> Bool
$c/= :: forall a. Eq a => V1 a -> V1 a -> Bool
== :: V1 a -> V1 a -> Bool
$c== :: forall a. Eq a => V1 a -> V1 a -> Bool
Eq,V1 a -> V1 a -> Bool
V1 a -> V1 a -> Ordering
V1 a -> V1 a -> V1 a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (V1 a)
forall a. Ord a => V1 a -> V1 a -> Bool
forall a. Ord a => V1 a -> V1 a -> Ordering
forall a. Ord a => V1 a -> V1 a -> V1 a
min :: V1 a -> V1 a -> V1 a
$cmin :: forall a. Ord a => V1 a -> V1 a -> V1 a
max :: V1 a -> V1 a -> V1 a
$cmax :: forall a. Ord a => V1 a -> V1 a -> V1 a
>= :: V1 a -> V1 a -> Bool
$c>= :: forall a. Ord a => V1 a -> V1 a -> Bool
> :: V1 a -> V1 a -> Bool
$c> :: forall a. Ord a => V1 a -> V1 a -> Bool
<= :: V1 a -> V1 a -> Bool
$c<= :: forall a. Ord a => V1 a -> V1 a -> Bool
< :: V1 a -> V1 a -> Bool
$c< :: forall a. Ord a => V1 a -> V1 a -> Bool
compare :: V1 a -> V1 a -> Ordering
$ccompare :: forall a. Ord a => V1 a -> V1 a -> Ordering
Ord,Int -> V1 a -> ShowS
forall a. Show a => Int -> V1 a -> ShowS
forall a. Show a => [V1 a] -> ShowS
forall a. Show a => V1 a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [V1 a] -> ShowS
$cshowList :: forall a. Show a => [V1 a] -> ShowS
show :: V1 a -> String
$cshow :: forall a. Show a => V1 a -> String
showsPrec :: Int -> V1 a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> V1 a -> ShowS
Show,ReadPrec [V1 a]
ReadPrec (V1 a)
ReadS [V1 a]
forall a. Read a => ReadPrec [V1 a]
forall a. Read a => ReadPrec (V1 a)
forall a. Read a => Int -> ReadS (V1 a)
forall a. Read a => ReadS [V1 a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [V1 a]
$creadListPrec :: forall a. Read a => ReadPrec [V1 a]
readPrec :: ReadPrec (V1 a)
$creadPrec :: forall a. Read a => ReadPrec (V1 a)
readList :: ReadS [V1 a]
$creadList :: forall a. Read a => ReadS [V1 a]
readsPrec :: Int -> ReadS (V1 a)
$creadsPrec :: forall a. Read a => Int -> ReadS (V1 a)
Read,V1 a -> DataType
V1 a -> Constr
forall {a}. Data a => Typeable (V1 a)
forall a. Data a => V1 a -> DataType
forall a. Data a => V1 a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> V1 a -> V1 a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> V1 a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> V1 a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V1 a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V1 a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V1 a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V1 a -> c (V1 a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (V1 a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V1 a))
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V1 a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V1 a -> c (V1 a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (V1 a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> V1 a -> m (V1 a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> V1 a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> V1 a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> V1 a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> V1 a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V1 a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> V1 a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V1 a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> V1 a -> r
gmapT :: (forall b. Data b => b -> b) -> V1 a -> V1 a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> V1 a -> V1 a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V1 a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (V1 a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (V1 a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (V1 a))
dataTypeOf :: V1 a -> DataType
$cdataTypeOf :: forall a. Data a => V1 a -> DataType
toConstr :: V1 a -> Constr
$ctoConstr :: forall a. Data a => V1 a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V1 a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (V1 a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V1 a -> c (V1 a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> V1 a -> c (V1 a)
Data,
forall a b. a -> V1 b -> V1 a
forall a b. (a -> b) -> V1 a -> V1 b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> V1 b -> V1 a
$c<$ :: forall a b. a -> V1 b -> V1 a
fmap :: forall a b. (a -> b) -> V1 a -> V1 b
$cfmap :: forall a b. (a -> b) -> V1 a -> V1 b
Functor,Functor V1
Foldable V1
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => V1 (m a) -> m (V1 a)
forall (f :: * -> *) a. Applicative f => V1 (f a) -> f (V1 a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> V1 a -> m (V1 b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> V1 a -> f (V1 b)
sequence :: forall (m :: * -> *) a. Monad m => V1 (m a) -> m (V1 a)
$csequence :: forall (m :: * -> *) a. Monad m => V1 (m a) -> m (V1 a)
mapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> V1 a -> m (V1 b)
$cmapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> V1 a -> m (V1 b)
sequenceA :: forall (f :: * -> *) a. Applicative f => V1 (f a) -> f (V1 a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => V1 (f a) -> f (V1 a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> V1 a -> f (V1 b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> V1 a -> f (V1 b)
Traversable,
V1 a -> Bool
forall a. Num a -> (a -> Bool) -> Epsilon a
forall {a}. Epsilon a => Num (V1 a)
forall a. Epsilon a => V1 a -> Bool
nearZero :: V1 a -> Bool
$cnearZero :: forall a. Epsilon a => V1 a -> Bool
Epsilon,Ptr (V1 a) -> IO (V1 a)
Ptr (V1 a) -> Int -> IO (V1 a)
Ptr (V1 a) -> Int -> V1 a -> IO ()
Ptr (V1 a) -> V1 a -> IO ()
V1 a -> Int
forall b. Ptr b -> Int -> IO (V1 a)
forall b. Ptr b -> Int -> V1 a -> IO ()
forall a. Storable a => Ptr (V1 a) -> IO (V1 a)
forall a. Storable a => Ptr (V1 a) -> Int -> IO (V1 a)
forall a. Storable a => Ptr (V1 a) -> Int -> V1 a -> IO ()
forall a. Storable a => Ptr (V1 a) -> V1 a -> IO ()
forall a. Storable a => V1 a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (V1 a)
forall a b. Storable a => Ptr b -> Int -> V1 a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr (V1 a) -> V1 a -> IO ()
$cpoke :: forall a. Storable a => Ptr (V1 a) -> V1 a -> IO ()
peek :: Ptr (V1 a) -> IO (V1 a)
$cpeek :: forall a. Storable a => Ptr (V1 a) -> IO (V1 a)
pokeByteOff :: forall b. Ptr b -> Int -> V1 a -> IO ()
$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> V1 a -> IO ()
peekByteOff :: forall b. Ptr b -> Int -> IO (V1 a)
$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (V1 a)
pokeElemOff :: Ptr (V1 a) -> Int -> V1 a -> IO ()
$cpokeElemOff :: forall a. Storable a => Ptr (V1 a) -> Int -> V1 a -> IO ()
peekElemOff :: Ptr (V1 a) -> Int -> IO (V1 a)
$cpeekElemOff :: forall a. Storable a => Ptr (V1 a) -> Int -> IO (V1 a)
alignment :: V1 a -> Int
$calignment :: forall a. Storable a => V1 a -> Int
sizeOf :: V1 a -> Int
$csizeOf :: forall a. Storable a => V1 a -> Int
Storable,V1 a -> ()
forall a. NFData a => V1 a -> ()
forall a. (a -> ()) -> NFData a
rnf :: V1 a -> ()
$crnf :: forall a. NFData a => V1 a -> ()
NFData
,forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (V1 a) x -> V1 a
forall a x. V1 a -> Rep (V1 a) x
$cto :: forall a x. Rep (V1 a) x -> V1 a
$cfrom :: forall a x. V1 a -> Rep (V1 a) x
Generic,forall a. Rep1 V1 a -> V1 a
forall a. V1 a -> Rep1 V1 a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a. Rep1 V1 a -> V1 a
$cfrom1 :: forall a. V1 a -> Rep1 V1 a
Generic1
#if defined(MIN_VERSION_template_haskell)
,forall a (m :: * -> *). (Lift a, Quote m) => V1 a -> m Exp
forall a (m :: * -> *). (Lift a, Quote m) => V1 a -> Code m (V1 a)
forall t.
(forall (m :: * -> *). Quote m => t -> m Exp)
-> (forall (m :: * -> *). Quote m => t -> Code m t) -> Lift t
forall (m :: * -> *). Quote m => V1 a -> m Exp
forall (m :: * -> *). Quote m => V1 a -> Code m (V1 a)
liftTyped :: forall (m :: * -> *). Quote m => V1 a -> Code m (V1 a)
$cliftTyped :: forall a (m :: * -> *). (Lift a, Quote m) => V1 a -> Code m (V1 a)
lift :: forall (m :: * -> *). Quote m => V1 a -> m Exp
$clift :: forall a (m :: * -> *). (Lift a, Quote m) => V1 a -> m Exp
Lift
#endif
)
instance Foldable V1 where
foldMap :: forall m a. Monoid m => (a -> m) -> V1 a -> m
foldMap a -> m
f (V1 a
a) = a -> m
f a
a
#if MIN_VERSION_base(4,13,0)
foldMap' :: forall m a. Monoid m => (a -> m) -> V1 a -> m
foldMap' a -> m
f (V1 a
a) = a -> m
f a
a
#endif
null :: forall a. V1 a -> Bool
null V1 a
_ = Bool
False
length :: forall a. V1 a -> Int
length V1 a
_ = Int
1
instance Finite V1 where
type Size V1 = 1
toV :: forall a. V1 a -> V (Size V1) a
toV (V1 a
a) = forall {k} (n :: k) a. Vector a -> V n a
V (forall a. a -> Vector a
V.singleton a
a)
fromV :: forall a. V (Size V1) a -> V1 a
fromV (V Vector a
v) = forall a. a -> V1 a
V1 (Vector a
v forall a. Vector a -> Int -> a
V.! Int
0)
instance Foldable1 V1 where
foldMap1 :: forall m a. Semigroup m => (a -> m) -> V1 a -> m
foldMap1 a -> m
f (V1 a
a) = a -> m
f a
a
{-# INLINE foldMap1 #-}
instance Traversable1 V1 where
traverse1 :: forall (f :: * -> *) a b. Apply f => (a -> f b) -> V1 a -> f (V1 b)
traverse1 a -> f b
f (V1 a
a) = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
a
{-# INLINE traverse1 #-}
instance Apply V1 where
V1 a -> b
f <.> :: forall a b. V1 (a -> b) -> V1 a -> V1 b
<.> V1 a
x = forall a. a -> V1 a
V1 (a -> b
f a
x)
{-# INLINE (<.>) #-}
instance Applicative V1 where
pure :: forall a. a -> V1 a
pure = forall a. a -> V1 a
V1
{-# INLINE pure #-}
V1 a -> b
f <*> :: forall a b. V1 (a -> b) -> V1 a -> V1 b
<*> V1 a
x = forall a. a -> V1 a
V1 (a -> b
f a
x)
{-# INLINE (<*>) #-}
instance Additive V1 where
zero :: forall a. Num a => V1 a
zero = forall (f :: * -> *) a. Applicative f => a -> f a
pure a
0
{-# INLINE zero #-}
liftU2 :: forall a. (a -> a -> a) -> V1 a -> V1 a -> V1 a
liftU2 = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
{-# INLINE liftU2 #-}
liftI2 :: forall a b c. (a -> b -> c) -> V1 a -> V1 b -> V1 c
liftI2 = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2
{-# INLINE liftI2 #-}
instance Bind V1 where
V1 a
a >>- :: forall a b. V1 a -> (a -> V1 b) -> V1 b
>>- a -> V1 b
f = a -> V1 b
f a
a
{-# INLINE (>>-) #-}
instance Monad V1 where
#if !(MIN_VERSION_base(4,11,0))
return = V1
{-# INLINE return #-}
#endif
V1 a
a >>= :: forall a b. V1 a -> (a -> V1 b) -> V1 b
>>= a -> V1 b
f = a -> V1 b
f a
a
{-# INLINE (>>=) #-}
instance Num a => Num (V1 a) where
+ :: V1 a -> V1 a -> V1 a
(+) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Num a => a -> a -> a
(+)
{-# INLINE (+) #-}
(-) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (-)
{-# INLINE (-) #-}
* :: V1 a -> V1 a -> V1 a
(*) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Num a => a -> a -> a
(*)
{-# INLINE (*) #-}
negate :: V1 a -> V1 a
negate = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Num a => a -> a
negate
{-# INLINE negate #-}
abs :: V1 a -> V1 a
abs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Num a => a -> a
abs
{-# INLINE abs #-}
signum :: V1 a -> V1 a
signum = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Num a => a -> a
signum
{-# INLINE signum #-}
fromInteger :: Integer -> V1 a
fromInteger = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => Integer -> a
fromInteger
{-# INLINE fromInteger #-}
instance Fractional a => Fractional (V1 a) where
recip :: V1 a -> V1 a
recip = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Fractional a => a -> a
recip
{-# INLINE recip #-}
/ :: V1 a -> V1 a -> V1 a
(/) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Fractional a => a -> a -> a
(/)
{-# INLINE (/) #-}
fromRational :: Rational -> V1 a
fromRational = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Fractional a => Rational -> a
fromRational
{-# INLINE fromRational #-}
instance Floating a => Floating (V1 a) where
pi :: V1 a
pi = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Floating a => a
pi
{-# INLINE pi #-}
exp :: V1 a -> V1 a
exp = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
exp
{-# INLINE exp #-}
sqrt :: V1 a -> V1 a
sqrt = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
sqrt
{-# INLINE sqrt #-}
log :: V1 a -> V1 a
log = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
log
{-# INLINE log #-}
** :: V1 a -> V1 a -> V1 a
(**) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Floating a => a -> a -> a
(**)
{-# INLINE (**) #-}
logBase :: V1 a -> V1 a -> V1 a
logBase = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Floating a => a -> a -> a
logBase
{-# INLINE logBase #-}
sin :: V1 a -> V1 a
sin = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
sin
{-# INLINE sin #-}
tan :: V1 a -> V1 a
tan = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
tan
{-# INLINE tan #-}
cos :: V1 a -> V1 a
cos = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
cos
{-# INLINE cos #-}
asin :: V1 a -> V1 a
asin = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
asin
{-# INLINE asin #-}
atan :: V1 a -> V1 a
atan = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
atan
{-# INLINE atan #-}
acos :: V1 a -> V1 a
acos = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
acos
{-# INLINE acos #-}
sinh :: V1 a -> V1 a
sinh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
sinh
{-# INLINE sinh #-}
tanh :: V1 a -> V1 a
tanh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
tanh
{-# INLINE tanh #-}
cosh :: V1 a -> V1 a
cosh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
cosh
{-# INLINE cosh #-}
asinh :: V1 a -> V1 a
asinh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
asinh
{-# INLINE asinh #-}
atanh :: V1 a -> V1 a
atanh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
atanh
{-# INLINE atanh #-}
acosh :: V1 a -> V1 a
acosh = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. Floating a => a -> a
acosh
{-# INLINE acosh #-}
instance Hashable a => Hashable (V1 a) where
hash :: V1 a -> Int
hash (V1 a
a) = forall a. Hashable a => a -> Int
hash a
a
hashWithSalt :: Int -> V1 a -> Int
hashWithSalt Int
s (V1 a
a) = Int
s forall a. Hashable a => Int -> a -> Int
`hashWithSalt` a
a
instance Hashable1 V1 where
liftHashWithSalt :: forall a. (Int -> a -> Int) -> Int -> V1 a -> Int
liftHashWithSalt Int -> a -> Int
h Int
s (V1 a
a) = Int -> a -> Int
h Int
s a
a
{-# INLINE liftHashWithSalt #-}
instance Metric V1 where
dot :: forall a. Num a => V1 a -> V1 a -> a
dot (V1 a
a) (V1 a
b) = a
a forall a. Num a => a -> a -> a
* a
b
{-# INLINE dot #-}
class R1 t where
_x :: Lens' (t a) a
ex :: R1 t => E t
ex :: forall (t :: * -> *). R1 t => E t
ex = forall (t :: * -> *). (forall x. Lens' (t x) x) -> E t
E forall (t :: * -> *) a. R1 t => Lens' (t a) a
_x
instance R1 V1 where
_x :: forall a. Lens' (V1 a) a
_x a -> f a
f (V1 a
a) = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f a
a
{-# INLINE _x #-}
instance R1 Identity where
_x :: forall a. Lens' (Identity a) a
_x a -> f a
f (Identity a
a) = forall a. a -> Identity a
Identity forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
f a
a
{-# INLINE _x #-}
instance Distributive V1 where
distribute :: forall (f :: * -> *) a. Functor f => f (V1 a) -> V1 (f a)
distribute f (V1 a)
f = forall a. a -> V1 a
V1 (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(V1 a
x) -> a
x) f (V1 a)
f)
{-# INLINE distribute #-}
instance Ix a => Ix (V1 a) where
{-# SPECIALISE instance Ix (V1 Int) #-}
range :: (V1 a, V1 a) -> [V1 a]
range (V1 a
l1, V1 a
u1) =
[ forall a. a -> V1 a
V1 a
i1 | a
i1 <- forall a. Ix a => (a, a) -> [a]
range (a
l1,a
u1) ]
{-# INLINE range #-}
unsafeIndex :: (V1 a, V1 a) -> V1 a -> Int
unsafeIndex (V1 a
l1,V1 a
u1) (V1 a
i1) = forall a. Ix a => (a, a) -> a -> Int
unsafeIndex (a
l1,a
u1) a
i1
{-# INLINE unsafeIndex #-}
inRange :: (V1 a, V1 a) -> V1 a -> Bool
inRange (V1 a
l1,V1 a
u1) (V1 a
i1) = forall a. Ix a => (a, a) -> a -> Bool
inRange (a
l1,a
u1) a
i1
{-# INLINE inRange #-}
instance Representable V1 where
type Rep V1 = E V1
tabulate :: forall a. (Rep V1 -> a) -> V1 a
tabulate Rep V1 -> a
f = forall a. a -> V1 a
V1 (Rep V1 -> a
f forall (t :: * -> *). R1 t => E t
ex)
{-# INLINE tabulate #-}
index :: forall a. V1 a -> Rep V1 -> a
index V1 a
xs (E forall a. Lens' (V1 a) a
l) = forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall a. Lens' (V1 a) a
l V1 a
xs
{-# INLINE index #-}
instance WithIndex.FunctorWithIndex (E V1) V1 where
imap :: forall a b. (E V1 -> a -> b) -> V1 a -> V1 b
imap E V1 -> a -> b
f (V1 a
a) = forall a. a -> V1 a
V1 (E V1 -> a -> b
f forall (t :: * -> *). R1 t => E t
ex a
a)
{-# INLINE imap #-}
instance WithIndex.FoldableWithIndex (E V1) V1 where
ifoldMap :: forall m a. Monoid m => (E V1 -> a -> m) -> V1 a -> m
ifoldMap E V1 -> a -> m
f (V1 a
a) = E V1 -> a -> m
f forall (t :: * -> *). R1 t => E t
ex a
a
{-# INLINE ifoldMap #-}
instance WithIndex.TraversableWithIndex (E V1) V1 where
itraverse :: forall (f :: * -> *) a b.
Applicative f =>
(E V1 -> a -> f b) -> V1 a -> f (V1 b)
itraverse E V1 -> a -> f b
f (V1 a
a) = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> E V1 -> a -> f b
f forall (t :: * -> *). R1 t => E t
ex a
a
{-# INLINE itraverse #-}
#if !MIN_VERSION_lens(5,0,0)
instance Lens.FunctorWithIndex (E V1) V1 where imap = WithIndex.imap
instance Lens.FoldableWithIndex (E V1) V1 where ifoldMap = WithIndex.ifoldMap
instance Lens.TraversableWithIndex (E V1) V1 where itraverse = WithIndex.itraverse
#endif
type instance Index (V1 a) = E V1
type instance IxValue (V1 a) = a
instance Ixed (V1 a) where
ix :: Index (V1 a) -> Traversal' (V1 a) (IxValue (V1 a))
ix Index (V1 a)
i = forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el Index (V1 a)
i
{-# INLINE ix #-}
instance Each (V1 a) (V1 b) a b where
each :: Traversal (V1 a) (V1 b) a b
each a -> f b
f (V1 a
x) = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
x
{-# INLINE each #-}
newtype instance U.Vector (V1 a) = V_V1 (U.Vector a)
newtype instance U.MVector s (V1 a) = MV_V1 (U.MVector s a)
instance U.Unbox a => U.Unbox (V1 a)
instance U.Unbox a => M.MVector U.MVector (V1 a) where
{-# INLINE basicLength #-}
{-# INLINE basicUnsafeSlice #-}
{-# INLINE basicOverlaps #-}
{-# INLINE basicUnsafeNew #-}
{-# INLINE basicUnsafeRead #-}
{-# INLINE basicUnsafeWrite #-}
basicLength :: forall s. MVector s (V1 a) -> Int
basicLength (MV_V1 MVector s a
v) = forall (v :: * -> * -> *) a s. MVector v a => v s a -> Int
M.basicLength MVector s a
v
basicUnsafeSlice :: forall s. Int -> Int -> MVector s (V1 a) -> MVector s (V1 a)
basicUnsafeSlice Int
m Int
n (MV_V1 MVector s a
v) = forall s a. MVector s a -> MVector s (V1 a)
MV_V1 (forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
M.basicUnsafeSlice Int
m Int
n MVector s a
v)
basicOverlaps :: forall s. MVector s (V1 a) -> MVector s (V1 a) -> Bool
basicOverlaps (MV_V1 MVector s a
v) (MV_V1 MVector s a
u) = forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> Bool
M.basicOverlaps MVector s a
v MVector s a
u
basicUnsafeNew :: forall s. Int -> ST s (MVector s (V1 a))
basicUnsafeNew Int
n = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM forall s a. MVector s a -> MVector s (V1 a)
MV_V1 (forall (v :: * -> * -> *) a s. MVector v a => Int -> ST s (v s a)
M.basicUnsafeNew Int
n)
basicUnsafeRead :: forall s. MVector s (V1 a) -> Int -> ST s (V1 a)
basicUnsafeRead (MV_V1 MVector s a
v) Int
i = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM forall a. a -> V1 a
V1 (forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> ST s a
M.basicUnsafeRead MVector s a
v Int
i)
basicUnsafeWrite :: forall s. MVector s (V1 a) -> Int -> V1 a -> ST s ()
basicUnsafeWrite (MV_V1 MVector s a
v) Int
i (V1 a
x) = forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> a -> ST s ()
M.basicUnsafeWrite MVector s a
v Int
i a
x
basicInitialize :: forall s. MVector s (V1 a) -> ST s ()
basicInitialize (MV_V1 MVector s a
v) = forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
M.basicInitialize MVector s a
v
{-# INLINE basicInitialize #-}
instance U.Unbox a => G.Vector U.Vector (V1 a) where
{-# INLINE basicUnsafeFreeze #-}
{-# INLINE basicUnsafeThaw #-}
{-# INLINE basicLength #-}
{-# INLINE basicUnsafeSlice #-}
{-# INLINE basicUnsafeIndexM #-}
basicUnsafeFreeze :: forall s. Mutable Vector s (V1 a) -> ST s (Vector (V1 a))
basicUnsafeFreeze (MV_V1 MVector s a
v) = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM forall a. Vector a -> Vector (V1 a)
V_V1 (forall (v :: * -> *) a s. Vector v a => Mutable v s a -> ST s (v a)
G.basicUnsafeFreeze MVector s a
v)
basicUnsafeThaw :: forall s. Vector (V1 a) -> ST s (Mutable Vector s (V1 a))
basicUnsafeThaw (V_V1 Vector a
v) = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM forall s a. MVector s a -> MVector s (V1 a)
MV_V1 (forall (v :: * -> *) a s. Vector v a => v a -> ST s (Mutable v s a)
G.basicUnsafeThaw Vector a
v)
basicLength :: Vector (V1 a) -> Int
basicLength (V_V1 Vector a
v) = forall (v :: * -> *) a. Vector v a => v a -> Int
G.basicLength Vector a
v
basicUnsafeSlice :: Int -> Int -> Vector (V1 a) -> Vector (V1 a)
basicUnsafeSlice Int
m Int
n (V_V1 Vector a
v) = forall a. Vector a -> Vector (V1 a)
V_V1 (forall (v :: * -> *) a. Vector v a => Int -> Int -> v a -> v a
G.basicUnsafeSlice Int
m Int
n Vector a
v)
basicUnsafeIndexM :: Vector (V1 a) -> Int -> Box (V1 a)
basicUnsafeIndexM (V_V1 Vector a
v) Int
i = forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM forall a. a -> V1 a
V1 (forall (v :: * -> *) a. Vector v a => v a -> Int -> Box a
G.basicUnsafeIndexM Vector a
v Int
i)
instance MonadZip V1 where
mzip :: forall a b. V1 a -> V1 b -> V1 (a, b)
mzip (V1 a
a) (V1 b
b) = forall a. a -> V1 a
V1 (a
a, b
b)
mzipWith :: forall a b c. (a -> b -> c) -> V1 a -> V1 b -> V1 c
mzipWith a -> b -> c
f (V1 a
a) (V1 b
b) = forall a. a -> V1 a
V1 (a -> b -> c
f a
a b
b)
munzip :: forall a b. V1 (a, b) -> (V1 a, V1 b)
munzip (V1 (a
a,b
b)) = (forall a. a -> V1 a
V1 a
a, forall a. a -> V1 a
V1 b
b)
instance MonadFix V1 where
mfix :: forall a. (a -> V1 a) -> V1 a
mfix a -> V1 a
f = forall a. a -> V1 a
V1 (let V1 a
a = a -> V1 a
f a
a in a
a)
instance Bounded a => Bounded (V1 a) where
minBound :: V1 a
minBound = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Bounded a => a
minBound
{-# INLINE minBound #-}
maxBound :: V1 a
maxBound = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Bounded a => a
maxBound
{-# INLINE maxBound #-}
instance Serial1 V1 where
serializeWith :: forall (m :: * -> *) a. MonadPut m => (a -> m ()) -> V1 a -> m ()
serializeWith a -> m ()
f (V1 a
a) = a -> m ()
f a
a
deserializeWith :: forall (m :: * -> *) a. MonadGet m => m a -> m (V1 a)
deserializeWith m a
m = forall a. a -> V1 a
V1 forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m a
m
instance Serial a => Serial (V1 a) where
serialize :: forall (m :: * -> *). MonadPut m => V1 a -> m ()
serialize (V1 a
a) = forall a (m :: * -> *). (Serial a, MonadPut m) => a -> m ()
serialize a
a
deserialize :: forall (m :: * -> *). MonadGet m => m (V1 a)
deserialize = forall a. a -> V1 a
V1 forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` forall a (m :: * -> *). (Serial a, MonadGet m) => m a
deserialize
instance Binary a => Binary (V1 a) where
put :: V1 a -> Put
put = forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
serializeWith forall t. Binary t => t -> Put
Binary.put
get :: Get (V1 a)
get = forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadGet m) =>
m a -> m (f a)
deserializeWith forall t. Binary t => Get t
Binary.get
instance Serialize a => Serialize (V1 a) where
put :: Putter (V1 a)
put = forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadPut m) =>
(a -> m ()) -> f a -> m ()
serializeWith forall t. Serialize t => Putter t
Cereal.put
get :: Get (V1 a)
get = forall (f :: * -> *) (m :: * -> *) a.
(Serial1 f, MonadGet m) =>
m a -> m (f a)
deserializeWith forall t. Serialize t => Get t
Cereal.get
instance Random a => Random (V1 a) where
random :: forall g. RandomGen g => g -> (V1 a, g)
random g
g = case forall a g. (Random a, RandomGen g) => g -> (a, g)
random g
g of (a
a, g
g') -> (forall a. a -> V1 a
V1 a
a, g
g')
randoms :: forall g. RandomGen g => g -> [V1 a]
randoms g
g = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a g. (Random a, RandomGen g) => g -> [a]
randoms g
g
randomR :: forall g. RandomGen g => (V1 a, V1 a) -> g -> (V1 a, g)
randomR (V1 a
a, V1 a
b) g
g = case forall a g. (Random a, RandomGen g) => (a, a) -> g -> (a, g)
randomR (a
a, a
b) g
g of (a
a', g
g') -> (forall a. a -> V1 a
V1 a
a', g
g')
randomRs :: forall g. RandomGen g => (V1 a, V1 a) -> g -> [V1 a]
randomRs (V1 a
a, V1 a
b) g
g = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a g. (Random a, RandomGen g) => (a, a) -> g -> [a]
randomRs (a
a, a
b) g
g
instance Eq1 V1 where
liftEq :: forall a b. (a -> b -> Bool) -> V1 a -> V1 b -> Bool
liftEq a -> b -> Bool
f (V1 a
a) (V1 b
b) = a -> b -> Bool
f a
a b
b
instance Ord1 V1 where
liftCompare :: forall a b. (a -> b -> Ordering) -> V1 a -> V1 b -> Ordering
liftCompare a -> b -> Ordering
f (V1 a
a) (V1 b
b) = a -> b -> Ordering
f a
a b
b
instance Show1 V1 where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> V1 a -> ShowS
liftShowsPrec Int -> a -> ShowS
f [a] -> ShowS
_ Int
d (V1 a
a) = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
>= Int
10) forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"V1 " forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
f Int
d a
a
instance Read1 V1 where
liftReadsPrec :: forall a. (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (V1 a)
liftReadsPrec Int -> ReadS a
f ReadS [a]
_ = forall a. (String -> ReadS a) -> Int -> ReadS a
readsData forall a b. (a -> b) -> a -> b
$ forall a t.
(Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
readsUnaryWith Int -> ReadS a
f String
"V1" forall a. a -> V1 a
V1
instance Field1 (V1 a) (V1 b) a b where
_1 :: Lens (V1 a) (V1 b) a b
_1 a -> f b
f (V1 a
x) = forall a. a -> V1 a
V1 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
x
instance Semigroup a => Semigroup (V1 a) where
<> :: V1 a -> V1 a -> V1 a
(<>) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a. Semigroup a => a -> a -> a
(<>)
instance Monoid a => Monoid (V1 a) where
mempty :: V1 a
mempty = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty
#if !(MIN_VERSION_base(4,11,0))
mappend = liftA2 mappend
#endif