{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module Numeric.Rounded.Hardware.Internal.Rounding
( RoundingMode(..)
, oppositeRoundingMode
, Rounding
, rounding
, reifyRounding
, Rounded(..)
, VUM.MVector(MV_Rounded)
, VU.Vector(V_Rounded)
) where
import Control.DeepSeq (NFData (..))
import Data.Coerce
import Data.Proxy
import Data.Tagged
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Foreign.Storable (Storable)
import GHC.Generics (Generic)
data RoundingMode
= ToNearest
| TowardNegInf
| TowardInf
| TowardZero
deriving (RoundingMode -> RoundingMode -> Bool
(RoundingMode -> RoundingMode -> Bool)
-> (RoundingMode -> RoundingMode -> Bool) -> Eq RoundingMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RoundingMode -> RoundingMode -> Bool
== :: RoundingMode -> RoundingMode -> Bool
$c/= :: RoundingMode -> RoundingMode -> Bool
/= :: RoundingMode -> RoundingMode -> Bool
Eq, Eq RoundingMode
Eq RoundingMode =>
(RoundingMode -> RoundingMode -> Ordering)
-> (RoundingMode -> RoundingMode -> Bool)
-> (RoundingMode -> RoundingMode -> Bool)
-> (RoundingMode -> RoundingMode -> Bool)
-> (RoundingMode -> RoundingMode -> Bool)
-> (RoundingMode -> RoundingMode -> RoundingMode)
-> (RoundingMode -> RoundingMode -> RoundingMode)
-> Ord RoundingMode
RoundingMode -> RoundingMode -> Bool
RoundingMode -> RoundingMode -> Ordering
RoundingMode -> RoundingMode -> RoundingMode
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
$ccompare :: RoundingMode -> RoundingMode -> Ordering
compare :: RoundingMode -> RoundingMode -> Ordering
$c< :: RoundingMode -> RoundingMode -> Bool
< :: RoundingMode -> RoundingMode -> Bool
$c<= :: RoundingMode -> RoundingMode -> Bool
<= :: RoundingMode -> RoundingMode -> Bool
$c> :: RoundingMode -> RoundingMode -> Bool
> :: RoundingMode -> RoundingMode -> Bool
$c>= :: RoundingMode -> RoundingMode -> Bool
>= :: RoundingMode -> RoundingMode -> Bool
$cmax :: RoundingMode -> RoundingMode -> RoundingMode
max :: RoundingMode -> RoundingMode -> RoundingMode
$cmin :: RoundingMode -> RoundingMode -> RoundingMode
min :: RoundingMode -> RoundingMode -> RoundingMode
Ord, ReadPrec [RoundingMode]
ReadPrec RoundingMode
Int -> ReadS RoundingMode
ReadS [RoundingMode]
(Int -> ReadS RoundingMode)
-> ReadS [RoundingMode]
-> ReadPrec RoundingMode
-> ReadPrec [RoundingMode]
-> Read RoundingMode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS RoundingMode
readsPrec :: Int -> ReadS RoundingMode
$creadList :: ReadS [RoundingMode]
readList :: ReadS [RoundingMode]
$creadPrec :: ReadPrec RoundingMode
readPrec :: ReadPrec RoundingMode
$creadListPrec :: ReadPrec [RoundingMode]
readListPrec :: ReadPrec [RoundingMode]
Read, Int -> RoundingMode -> ShowS
[RoundingMode] -> ShowS
RoundingMode -> String
(Int -> RoundingMode -> ShowS)
-> (RoundingMode -> String)
-> ([RoundingMode] -> ShowS)
-> Show RoundingMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RoundingMode -> ShowS
showsPrec :: Int -> RoundingMode -> ShowS
$cshow :: RoundingMode -> String
show :: RoundingMode -> String
$cshowList :: [RoundingMode] -> ShowS
showList :: [RoundingMode] -> ShowS
Show, Int -> RoundingMode
RoundingMode -> Int
RoundingMode -> [RoundingMode]
RoundingMode -> RoundingMode
RoundingMode -> RoundingMode -> [RoundingMode]
RoundingMode -> RoundingMode -> RoundingMode -> [RoundingMode]
(RoundingMode -> RoundingMode)
-> (RoundingMode -> RoundingMode)
-> (Int -> RoundingMode)
-> (RoundingMode -> Int)
-> (RoundingMode -> [RoundingMode])
-> (RoundingMode -> RoundingMode -> [RoundingMode])
-> (RoundingMode -> RoundingMode -> [RoundingMode])
-> (RoundingMode -> RoundingMode -> RoundingMode -> [RoundingMode])
-> Enum RoundingMode
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: RoundingMode -> RoundingMode
succ :: RoundingMode -> RoundingMode
$cpred :: RoundingMode -> RoundingMode
pred :: RoundingMode -> RoundingMode
$ctoEnum :: Int -> RoundingMode
toEnum :: Int -> RoundingMode
$cfromEnum :: RoundingMode -> Int
fromEnum :: RoundingMode -> Int
$cenumFrom :: RoundingMode -> [RoundingMode]
enumFrom :: RoundingMode -> [RoundingMode]
$cenumFromThen :: RoundingMode -> RoundingMode -> [RoundingMode]
enumFromThen :: RoundingMode -> RoundingMode -> [RoundingMode]
$cenumFromTo :: RoundingMode -> RoundingMode -> [RoundingMode]
enumFromTo :: RoundingMode -> RoundingMode -> [RoundingMode]
$cenumFromThenTo :: RoundingMode -> RoundingMode -> RoundingMode -> [RoundingMode]
enumFromThenTo :: RoundingMode -> RoundingMode -> RoundingMode -> [RoundingMode]
Enum, RoundingMode
RoundingMode -> RoundingMode -> Bounded RoundingMode
forall a. a -> a -> Bounded a
$cminBound :: RoundingMode
minBound :: RoundingMode
$cmaxBound :: RoundingMode
maxBound :: RoundingMode
Bounded, (forall x. RoundingMode -> Rep RoundingMode x)
-> (forall x. Rep RoundingMode x -> RoundingMode)
-> Generic RoundingMode
forall x. Rep RoundingMode x -> RoundingMode
forall x. RoundingMode -> Rep RoundingMode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RoundingMode -> Rep RoundingMode x
from :: forall x. RoundingMode -> Rep RoundingMode x
$cto :: forall x. Rep RoundingMode x -> RoundingMode
to :: forall x. Rep RoundingMode x -> RoundingMode
Generic)
instance NFData RoundingMode
oppositeRoundingMode :: RoundingMode -> RoundingMode
oppositeRoundingMode :: RoundingMode -> RoundingMode
oppositeRoundingMode RoundingMode
ToNearest = RoundingMode
ToNearest
oppositeRoundingMode RoundingMode
TowardZero = RoundingMode
TowardZero
oppositeRoundingMode RoundingMode
TowardInf = RoundingMode
TowardNegInf
oppositeRoundingMode RoundingMode
TowardNegInf = RoundingMode
TowardInf
class Rounding (r :: RoundingMode) where
roundingT :: Tagged r RoundingMode
instance Rounding 'ToNearest where
roundingT :: Tagged 'ToNearest RoundingMode
roundingT = RoundingMode -> Tagged 'ToNearest RoundingMode
forall {k} (s :: k) b. b -> Tagged s b
Tagged RoundingMode
ToNearest
instance Rounding 'TowardInf where
roundingT :: Tagged 'TowardInf RoundingMode
roundingT = RoundingMode -> Tagged 'TowardInf RoundingMode
forall {k} (s :: k) b. b -> Tagged s b
Tagged RoundingMode
TowardInf
instance Rounding 'TowardNegInf where
roundingT :: Tagged 'TowardNegInf RoundingMode
roundingT = RoundingMode -> Tagged 'TowardNegInf RoundingMode
forall {k} (s :: k) b. b -> Tagged s b
Tagged RoundingMode
TowardNegInf
instance Rounding 'TowardZero where
roundingT :: Tagged 'TowardZero RoundingMode
roundingT = RoundingMode -> Tagged 'TowardZero RoundingMode
forall {k} (s :: k) b. b -> Tagged s b
Tagged RoundingMode
TowardZero
rounding :: Rounding r => proxy r -> RoundingMode
rounding :: forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding = Tagged r RoundingMode -> proxy r -> RoundingMode
forall {k} (s :: k) a (proxy :: k -> *). Tagged s a -> proxy s -> a
Data.Tagged.proxy Tagged r RoundingMode
forall (r :: RoundingMode). Rounding r => Tagged r RoundingMode
roundingT
{-# INLINE rounding #-}
reifyRounding :: RoundingMode -> (forall s. Rounding s => Proxy s -> a) -> a
reifyRounding :: forall a.
RoundingMode
-> (forall (s :: RoundingMode). Rounding s => Proxy s -> a) -> a
reifyRounding RoundingMode
ToNearest forall (s :: RoundingMode). Rounding s => Proxy s -> a
f = Proxy 'ToNearest -> a
forall (s :: RoundingMode). Rounding s => Proxy s -> a
f (Proxy 'ToNearest
forall {k} (t :: k). Proxy t
Proxy :: Proxy 'ToNearest)
reifyRounding RoundingMode
TowardInf forall (s :: RoundingMode). Rounding s => Proxy s -> a
f = Proxy 'TowardInf -> a
forall (s :: RoundingMode). Rounding s => Proxy s -> a
f (Proxy 'TowardInf
forall {k} (t :: k). Proxy t
Proxy :: Proxy 'TowardInf)
reifyRounding RoundingMode
TowardNegInf forall (s :: RoundingMode). Rounding s => Proxy s -> a
f = Proxy 'TowardNegInf -> a
forall (s :: RoundingMode). Rounding s => Proxy s -> a
f (Proxy 'TowardNegInf
forall {k} (t :: k). Proxy t
Proxy :: Proxy 'TowardNegInf)
reifyRounding RoundingMode
TowardZero forall (s :: RoundingMode). Rounding s => Proxy s -> a
f = Proxy 'TowardZero -> a
forall (s :: RoundingMode). Rounding s => Proxy s -> a
f (Proxy 'TowardZero
forall {k} (t :: k). Proxy t
Proxy :: Proxy 'TowardZero)
{-# INLINE reifyRounding #-}
newtype Rounded (r :: RoundingMode) a = Rounded { forall (r :: RoundingMode) a. Rounded r a -> a
getRounded :: a }
deriving (Rounded r a -> Rounded r a -> Bool
(Rounded r a -> Rounded r a -> Bool)
-> (Rounded r a -> Rounded r a -> Bool) -> Eq (Rounded r a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (r :: RoundingMode) a.
Eq a =>
Rounded r a -> Rounded r a -> Bool
$c== :: forall (r :: RoundingMode) a.
Eq a =>
Rounded r a -> Rounded r a -> Bool
== :: Rounded r a -> Rounded r a -> Bool
$c/= :: forall (r :: RoundingMode) a.
Eq a =>
Rounded r a -> Rounded r a -> Bool
/= :: Rounded r a -> Rounded r a -> Bool
Eq, Eq (Rounded r a)
Eq (Rounded r a) =>
(Rounded r a -> Rounded r a -> Ordering)
-> (Rounded r a -> Rounded r a -> Bool)
-> (Rounded r a -> Rounded r a -> Bool)
-> (Rounded r a -> Rounded r a -> Bool)
-> (Rounded r a -> Rounded r a -> Bool)
-> (Rounded r a -> Rounded r a -> Rounded r a)
-> (Rounded r a -> Rounded r a -> Rounded r a)
-> Ord (Rounded r a)
Rounded r a -> Rounded r a -> Bool
Rounded r a -> Rounded r a -> Ordering
Rounded r a -> Rounded r a -> Rounded r 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 (r :: RoundingMode) a. Ord a => Eq (Rounded r a)
forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Bool
forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Ordering
forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Rounded r a
$ccompare :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Ordering
compare :: Rounded r a -> Rounded r a -> Ordering
$c< :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Bool
< :: Rounded r a -> Rounded r a -> Bool
$c<= :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Bool
<= :: Rounded r a -> Rounded r a -> Bool
$c> :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Bool
> :: Rounded r a -> Rounded r a -> Bool
$c>= :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Bool
>= :: Rounded r a -> Rounded r a -> Bool
$cmax :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Rounded r a
max :: Rounded r a -> Rounded r a -> Rounded r a
$cmin :: forall (r :: RoundingMode) a.
Ord a =>
Rounded r a -> Rounded r a -> Rounded r a
min :: Rounded r a -> Rounded r a -> Rounded r a
Ord, (forall x. Rounded r a -> Rep (Rounded r a) x)
-> (forall x. Rep (Rounded r a) x -> Rounded r a)
-> Generic (Rounded r a)
forall x. Rep (Rounded r a) x -> Rounded r a
forall x. Rounded r a -> Rep (Rounded r a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (r :: RoundingMode) a x. Rep (Rounded r a) x -> Rounded r a
forall (r :: RoundingMode) a x. Rounded r a -> Rep (Rounded r a) x
$cfrom :: forall (r :: RoundingMode) a x. Rounded r a -> Rep (Rounded r a) x
from :: forall x. Rounded r a -> Rep (Rounded r a) x
$cto :: forall (r :: RoundingMode) a x. Rep (Rounded r a) x -> Rounded r a
to :: forall x. Rep (Rounded r a) x -> Rounded r a
Generic, (forall a b. (a -> b) -> Rounded r a -> Rounded r b)
-> (forall a b. a -> Rounded r b -> Rounded r a)
-> Functor (Rounded r)
forall a b. a -> Rounded r b -> Rounded r a
forall a b. (a -> b) -> Rounded r a -> Rounded r b
forall (r :: RoundingMode) a b. a -> Rounded r b -> Rounded r a
forall (r :: RoundingMode) a b.
(a -> b) -> Rounded r a -> Rounded r b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall (r :: RoundingMode) a b.
(a -> b) -> Rounded r a -> Rounded r b
fmap :: forall a b. (a -> b) -> Rounded r a -> Rounded r b
$c<$ :: forall (r :: RoundingMode) a b. a -> Rounded r b -> Rounded r a
<$ :: forall a b. a -> Rounded r b -> Rounded r a
Functor, Ptr (Rounded r a) -> IO (Rounded r a)
Ptr (Rounded r a) -> Int -> IO (Rounded r a)
Ptr (Rounded r a) -> Int -> Rounded r a -> IO ()
Ptr (Rounded r a) -> Rounded r a -> IO ()
Rounded r a -> Int
(Rounded r a -> Int)
-> (Rounded r a -> Int)
-> (Ptr (Rounded r a) -> Int -> IO (Rounded r a))
-> (Ptr (Rounded r a) -> Int -> Rounded r a -> IO ())
-> (forall b. Ptr b -> Int -> IO (Rounded r a))
-> (forall b. Ptr b -> Int -> Rounded r a -> IO ())
-> (Ptr (Rounded r a) -> IO (Rounded r a))
-> (Ptr (Rounded r a) -> Rounded r a -> IO ())
-> Storable (Rounded r a)
forall b. Ptr b -> Int -> IO (Rounded r a)
forall b. Ptr b -> Int -> Rounded r 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
forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> IO (Rounded r a)
forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> Int -> IO (Rounded r a)
forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> Int -> Rounded r a -> IO ()
forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> Rounded r a -> IO ()
forall (r :: RoundingMode) a. Storable a => Rounded r a -> Int
forall (r :: RoundingMode) a b.
Storable a =>
Ptr b -> Int -> IO (Rounded r a)
forall (r :: RoundingMode) a b.
Storable a =>
Ptr b -> Int -> Rounded r a -> IO ()
$csizeOf :: forall (r :: RoundingMode) a. Storable a => Rounded r a -> Int
sizeOf :: Rounded r a -> Int
$calignment :: forall (r :: RoundingMode) a. Storable a => Rounded r a -> Int
alignment :: Rounded r a -> Int
$cpeekElemOff :: forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> Int -> IO (Rounded r a)
peekElemOff :: Ptr (Rounded r a) -> Int -> IO (Rounded r a)
$cpokeElemOff :: forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> Int -> Rounded r a -> IO ()
pokeElemOff :: Ptr (Rounded r a) -> Int -> Rounded r a -> IO ()
$cpeekByteOff :: forall (r :: RoundingMode) a b.
Storable a =>
Ptr b -> Int -> IO (Rounded r a)
peekByteOff :: forall b. Ptr b -> Int -> IO (Rounded r a)
$cpokeByteOff :: forall (r :: RoundingMode) a b.
Storable a =>
Ptr b -> Int -> Rounded r a -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> Rounded r a -> IO ()
$cpeek :: forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> IO (Rounded r a)
peek :: Ptr (Rounded r a) -> IO (Rounded r a)
$cpoke :: forall (r :: RoundingMode) a.
Storable a =>
Ptr (Rounded r a) -> Rounded r a -> IO ()
poke :: Ptr (Rounded r a) -> Rounded r a -> IO ()
Storable)
instance (Rounding r, Show a) => Show (Rounded r a) where
showsPrec :: Int -> Rounded r a -> ShowS
showsPrec Int
prec rx :: Rounded r a
rx@(Rounded a
x) = Bool -> ShowS -> ShowS
showParen (Int
prec Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String -> ShowS
showString String
"Rounded @" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
rs ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 a
x
where
toProxy :: Rounded r a -> Proxy r
toProxy :: forall (r :: RoundingMode) a. Rounded r a -> Proxy r
toProxy Rounded r a
_ = Proxy r
forall {k} (t :: k). Proxy t
Proxy
rs :: ShowS
rs = RoundingMode -> ShowS
forall a. Show a => a -> ShowS
shows (Proxy r -> RoundingMode
forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (Rounded r a -> Proxy r
forall (r :: RoundingMode) a. Rounded r a -> Proxy r
toProxy Rounded r a
rx))
instance NFData a => NFData (Rounded r a)
newtype instance VUM.MVector s (Rounded r a) = MV_Rounded (VUM.MVector s a)
newtype instance VU.Vector (Rounded r a) = V_Rounded (VU.Vector a)
instance VU.Unbox a => VGM.MVector VUM.MVector (Rounded r a) where
basicLength :: forall s. MVector s (Rounded r a) -> Int
basicLength (MV_Rounded MVector s a
mv) = MVector s a -> Int
forall s. MVector s a -> Int
forall (v :: * -> * -> *) a s. MVector v a => v s a -> Int
VGM.basicLength MVector s a
mv
basicUnsafeSlice :: forall s.
Int -> Int -> MVector s (Rounded r a) -> MVector s (Rounded r a)
basicUnsafeSlice Int
i Int
l (MV_Rounded MVector s a
mv) = MVector s a -> MVector s (Rounded r a)
forall s (r :: RoundingMode) a.
MVector s a -> MVector s (Rounded r a)
MV_Rounded (Int -> Int -> MVector s a -> MVector s a
forall s. Int -> Int -> MVector s a -> MVector s a
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> Int -> v s a -> v s a
VGM.basicUnsafeSlice Int
i Int
l MVector s a
mv)
basicOverlaps :: forall s.
MVector s (Rounded r a) -> MVector s (Rounded r a) -> Bool
basicOverlaps (MV_Rounded MVector s a
mv) (MV_Rounded MVector s a
mv') = MVector s a -> MVector s a -> Bool
forall s. MVector s a -> MVector s a -> Bool
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> Bool
VGM.basicOverlaps MVector s a
mv MVector s a
mv'
basicUnsafeNew :: forall s. Int -> ST s (MVector s (Rounded r a))
basicUnsafeNew Int
l = MVector s a -> MVector s (Rounded r a)
forall s (r :: RoundingMode) a.
MVector s a -> MVector s (Rounded r a)
MV_Rounded (MVector s a -> MVector s (Rounded r a))
-> ST s (MVector s a) -> ST s (MVector s (Rounded r a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> ST s (MVector s a)
forall s. Int -> ST s (MVector s a)
forall (v :: * -> * -> *) a s. MVector v a => Int -> ST s (v s a)
VGM.basicUnsafeNew Int
l
basicInitialize :: forall s. MVector s (Rounded r a) -> ST s ()
basicInitialize (MV_Rounded MVector s a
mv) = MVector s a -> ST s ()
forall s. MVector s a -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
VGM.basicInitialize MVector s a
mv
basicUnsafeReplicate :: forall s. Int -> Rounded r a -> ST s (MVector s (Rounded r a))
basicUnsafeReplicate Int
i Rounded r a
x = MVector s a -> MVector s (Rounded r a)
forall s (r :: RoundingMode) a.
MVector s a -> MVector s (Rounded r a)
MV_Rounded (MVector s a -> MVector s (Rounded r a))
-> ST s (MVector s a) -> ST s (MVector s (Rounded r a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> ST s (MVector s a)
forall s. Int -> a -> ST s (MVector s a)
forall (v :: * -> * -> *) a s.
MVector v a =>
Int -> a -> ST s (v s a)
VGM.basicUnsafeReplicate Int
i (Rounded r a -> a
forall a b. Coercible a b => a -> b
coerce Rounded r a
x)
basicUnsafeRead :: forall s. MVector s (Rounded r a) -> Int -> ST s (Rounded r a)
basicUnsafeRead (MV_Rounded MVector s a
mv) Int
i = a -> Rounded r a
forall a b. Coercible a b => a -> b
coerce (a -> Rounded r a) -> ST s a -> ST s (Rounded r a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVector s a -> Int -> ST s a
forall s. MVector s a -> Int -> ST s a
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> ST s a
VGM.basicUnsafeRead MVector s a
mv Int
i
basicUnsafeWrite :: forall s. MVector s (Rounded r a) -> Int -> Rounded r a -> ST s ()
basicUnsafeWrite (MV_Rounded MVector s a
mv) Int
i Rounded r a
x = MVector s a -> Int -> a -> ST s ()
forall s. MVector s a -> Int -> a -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> a -> ST s ()
VGM.basicUnsafeWrite MVector s a
mv Int
i (Rounded r a -> a
forall a b. Coercible a b => a -> b
coerce Rounded r a
x)
basicClear :: forall s. MVector s (Rounded r a) -> ST s ()
basicClear (MV_Rounded MVector s a
mv) = MVector s a -> ST s ()
forall s. MVector s a -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> ST s ()
VGM.basicClear MVector s a
mv
basicSet :: forall s. MVector s (Rounded r a) -> Rounded r a -> ST s ()
basicSet (MV_Rounded MVector s a
mv) Rounded r a
x = MVector s a -> a -> ST s ()
forall s. MVector s a -> a -> ST s ()
forall (v :: * -> * -> *) a s. MVector v a => v s a -> a -> ST s ()
VGM.basicSet MVector s a
mv (Rounded r a -> a
forall a b. Coercible a b => a -> b
coerce Rounded r a
x)
basicUnsafeCopy :: forall s.
MVector s (Rounded r a) -> MVector s (Rounded r a) -> ST s ()
basicUnsafeCopy (MV_Rounded MVector s a
mv) (MV_Rounded MVector s a
mv') = MVector s a -> MVector s a -> ST s ()
forall s. MVector s a -> MVector s a -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> ST s ()
VGM.basicUnsafeCopy MVector s a
mv MVector s a
mv'
basicUnsafeMove :: forall s.
MVector s (Rounded r a) -> MVector s (Rounded r a) -> ST s ()
basicUnsafeMove (MV_Rounded MVector s a
mv) (MV_Rounded MVector s a
mv') = MVector s a -> MVector s a -> ST s ()
forall s. MVector s a -> MVector s a -> ST s ()
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> v s a -> ST s ()
VGM.basicUnsafeMove MVector s a
mv MVector s a
mv'
basicUnsafeGrow :: forall s.
MVector s (Rounded r a) -> Int -> ST s (MVector s (Rounded r a))
basicUnsafeGrow (MV_Rounded MVector s a
mv) Int
n = MVector s a -> MVector s (Rounded r a)
forall s (r :: RoundingMode) a.
MVector s a -> MVector s (Rounded r a)
MV_Rounded (MVector s a -> MVector s (Rounded r a))
-> ST s (MVector s a) -> ST s (MVector s (Rounded r a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MVector s a -> Int -> ST s (MVector s a)
forall s. MVector s a -> Int -> ST s (MVector s a)
forall (v :: * -> * -> *) a s.
MVector v a =>
v s a -> Int -> ST s (v s a)
VGM.basicUnsafeGrow MVector s a
mv Int
n
instance VU.Unbox a => VG.Vector VU.Vector (Rounded r a) where
basicUnsafeFreeze :: forall s.
Mutable Vector s (Rounded r a) -> ST s (Vector (Rounded r a))
basicUnsafeFreeze (MV_Rounded MVector s a
mv) = Vector a -> Vector (Rounded r a)
forall (r :: RoundingMode) a. Vector a -> Vector (Rounded r a)
V_Rounded (Vector a -> Vector (Rounded r a))
-> ST s (Vector a) -> ST s (Vector (Rounded r a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mutable Vector s a -> ST s (Vector a)
forall s. Mutable Vector s a -> ST s (Vector a)
forall (v :: * -> *) a s. Vector v a => Mutable v s a -> ST s (v a)
VG.basicUnsafeFreeze Mutable Vector s a
MVector s a
mv
basicUnsafeThaw :: forall s.
Vector (Rounded r a) -> ST s (Mutable Vector s (Rounded r a))
basicUnsafeThaw (V_Rounded Vector a
v) = MVector s a -> MVector s (Rounded r a)
forall s (r :: RoundingMode) a.
MVector s a -> MVector s (Rounded r a)
MV_Rounded (MVector s a -> MVector s (Rounded r a))
-> ST s (MVector s a) -> ST s (MVector s (Rounded r a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector a -> ST s (Mutable Vector s a)
forall s. Vector a -> ST s (Mutable Vector s a)
forall (v :: * -> *) a s. Vector v a => v a -> ST s (Mutable v s a)
VG.basicUnsafeThaw Vector a
v
basicLength :: Vector (Rounded r a) -> Int
basicLength (V_Rounded Vector a
v) = Vector a -> Int
forall (v :: * -> *) a. Vector v a => v a -> Int
VG.basicLength Vector a
v
basicUnsafeSlice :: Int -> Int -> Vector (Rounded r a) -> Vector (Rounded r a)
basicUnsafeSlice Int
i Int
l (V_Rounded Vector a
v) = Vector a -> Vector (Rounded r a)
forall (r :: RoundingMode) a. Vector a -> Vector (Rounded r a)
V_Rounded (Int -> Int -> Vector a -> Vector a
forall (v :: * -> *) a. Vector v a => Int -> Int -> v a -> v a
VG.basicUnsafeSlice Int
i Int
l Vector a
v)
basicUnsafeIndexM :: Vector (Rounded r a) -> Int -> Box (Rounded r a)
basicUnsafeIndexM (V_Rounded Vector a
v) Int
i = a -> Rounded r a
forall a b. Coercible a b => a -> b
coerce (a -> Rounded r a) -> Box a -> Box (Rounded r a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Vector a -> Int -> Box a
forall (v :: * -> *) a. Vector v a => v a -> Int -> Box a
VG.basicUnsafeIndexM Vector a
v Int
i
basicUnsafeCopy :: forall s.
Mutable Vector s (Rounded r a) -> Vector (Rounded r a) -> ST s ()
basicUnsafeCopy (MV_Rounded MVector s a
mv) (V_Rounded Vector a
v) = Mutable Vector s a -> Vector a -> ST s ()
forall s. Mutable Vector s a -> Vector a -> ST s ()
forall (v :: * -> *) a s.
Vector v a =>
Mutable v s a -> v a -> ST s ()
VG.basicUnsafeCopy Mutable Vector s a
MVector s a
mv Vector a
v
elemseq :: forall b. Vector (Rounded r a) -> Rounded r a -> b -> b
elemseq (V_Rounded Vector a
v) Rounded r a
x b
y = Vector a -> a -> b -> b
forall b. Vector a -> a -> b -> b
forall (v :: * -> *) a b. Vector v a => v a -> a -> b -> b
VG.elemseq Vector a
v (Rounded r a -> a
forall a b. Coercible a b => a -> b
coerce Rounded r a
x) b
y
instance VU.Unbox a => VU.Unbox (Rounded r a)