{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Numeric.Rounded.Hardware.Vector.Storable
(
coercion
, fromVectorOfRounded
, toVectorOfRounded
, coercionM
, fromMVectorOfRounded
, toMVectorOfRounded
, roundedSum
, zipWith_roundedAdd
, zipWith_roundedSub
, zipWith_roundedMul
, zipWith3_roundedFusedMultiplyAdd
, zipWith_roundedDiv
, map_roundedSqrt
, sum
, zipWith_add
, zipWith_sub
, zipWith_mul
, zipWith3_fusedMultiplyAdd
, zipWith_div
, map_sqrt
) where
import Data.Coerce
import Data.Proxy
import Data.Type.Coercion
import qualified Data.Vector.Storable as VS
import qualified Data.Vector.Storable.Mutable as VSM
import Foreign.Storable
import Numeric.Rounded.Hardware.Internal
import Prelude hiding (sum)
import Unsafe.Coerce
coercion :: Coercion (VS.Vector a) (VS.Vector (Rounded r a))
coercion :: forall a (r :: RoundingMode).
Coercion (Vector a) (Vector (Rounded r a))
coercion = forall a b. a -> b
unsafeCoerce (forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion :: Coercion (VS.Vector a) (VS.Vector a))
fromVectorOfRounded :: VS.Vector (Rounded r a) -> VS.Vector a
fromVectorOfRounded :: forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded = forall a b. a -> b
unsafeCoerce
toVectorOfRounded :: VS.Vector a -> VS.Vector (Rounded r a)
toVectorOfRounded :: forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded = forall a b. a -> b
unsafeCoerce
coercionM :: Coercion (VSM.MVector s a) (VSM.MVector s (Rounded r a))
coercionM :: forall s a (r :: RoundingMode).
Coercion (MVector s a) (MVector s (Rounded r a))
coercionM = forall a b. a -> b
unsafeCoerce (forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion :: Coercion (VSM.MVector s a) (VSM.MVector s a))
fromMVectorOfRounded :: VSM.MVector s (Rounded r a) -> VSM.MVector s a
fromMVectorOfRounded :: forall s (r :: RoundingMode) a.
MVector s (Rounded r a) -> MVector s a
fromMVectorOfRounded = forall a b. a -> b
unsafeCoerce
toMVectorOfRounded :: VSM.MVector s a -> VSM.MVector s (Rounded r a)
toMVectorOfRounded :: forall s a (r :: RoundingMode).
MVector s a -> MVector s (Rounded r a)
toMVectorOfRounded = forall a b. a -> b
unsafeCoerce
sum :: forall r a. (Rounding r, Storable a, RoundedRing_Vector VS.Vector a) => VS.Vector (Rounded r a) -> Rounded r a
sum :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedRing_Vector Vector a) =>
Vector (Rounded r a) -> Rounded r a
sum Vector (Rounded r a)
v = coerce :: forall a b. Coercible a b => a -> b
coerce (forall (vector :: * -> *) a.
RoundedRing_Vector vector a =>
RoundingMode -> vector a -> a
roundedSum RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE sum #-}
zipWith_add :: forall r a. (Rounding r, Storable a, RoundedRing_Vector VS.Vector a) => VS.Vector (Rounded r a) -> VS.Vector (Rounded r a) -> VS.Vector (Rounded r a)
zipWith_add :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedRing_Vector Vector a) =>
Vector (Rounded r a)
-> Vector (Rounded r a) -> Vector (Rounded r a)
zipWith_add Vector (Rounded r a)
v1 Vector (Rounded r a)
v2 = forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded (forall (vector :: * -> *) a.
RoundedRing_Vector vector a =>
RoundingMode -> vector a -> vector a -> vector a
zipWith_roundedAdd RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v1) (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v2))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE zipWith_add #-}
zipWith_sub :: forall r a. (Rounding r, Storable a, RoundedRing_Vector VS.Vector a) => VS.Vector (Rounded r a) -> VS.Vector (Rounded r a) -> VS.Vector (Rounded r a)
zipWith_sub :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedRing_Vector Vector a) =>
Vector (Rounded r a)
-> Vector (Rounded r a) -> Vector (Rounded r a)
zipWith_sub Vector (Rounded r a)
v1 Vector (Rounded r a)
v2 = forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded (forall (vector :: * -> *) a.
RoundedRing_Vector vector a =>
RoundingMode -> vector a -> vector a -> vector a
zipWith_roundedSub RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v1) (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v2))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE zipWith_sub #-}
zipWith_mul :: forall r a. (Rounding r, Storable a, RoundedRing_Vector VS.Vector a) => VS.Vector (Rounded r a) -> VS.Vector (Rounded r a) -> VS.Vector (Rounded r a)
zipWith_mul :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedRing_Vector Vector a) =>
Vector (Rounded r a)
-> Vector (Rounded r a) -> Vector (Rounded r a)
zipWith_mul Vector (Rounded r a)
v1 Vector (Rounded r a)
v2 = forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded (forall (vector :: * -> *) a.
RoundedRing_Vector vector a =>
RoundingMode -> vector a -> vector a -> vector a
zipWith_roundedMul RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v1) (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v2))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE zipWith_mul #-}
zipWith3_fusedMultiplyAdd :: forall r a. (Rounding r, Storable a, RoundedRing_Vector VS.Vector a) => VS.Vector (Rounded r a) -> VS.Vector (Rounded r a) -> VS.Vector (Rounded r a) -> VS.Vector (Rounded r a)
zipWith3_fusedMultiplyAdd :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedRing_Vector Vector a) =>
Vector (Rounded r a)
-> Vector (Rounded r a)
-> Vector (Rounded r a)
-> Vector (Rounded r a)
zipWith3_fusedMultiplyAdd Vector (Rounded r a)
v1 Vector (Rounded r a)
v2 Vector (Rounded r a)
v3 = forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded (forall (vector :: * -> *) a.
RoundedRing_Vector vector a =>
RoundingMode -> vector a -> vector a -> vector a -> vector a
zipWith3_roundedFusedMultiplyAdd RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v1) (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v2) (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v3))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE zipWith3_fusedMultiplyAdd #-}
zipWith_div :: forall r a. (Rounding r, Storable a, RoundedFractional_Vector VS.Vector a) => VS.Vector (Rounded r a) -> VS.Vector (Rounded r a) -> VS.Vector (Rounded r a)
zipWith_div :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedFractional_Vector Vector a) =>
Vector (Rounded r a)
-> Vector (Rounded r a) -> Vector (Rounded r a)
zipWith_div Vector (Rounded r a)
v1 Vector (Rounded r a)
v2 = forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded (forall (vector :: * -> *) a.
RoundedFractional_Vector vector a =>
RoundingMode -> vector a -> vector a -> vector a
zipWith_roundedDiv RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v1) (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v2))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE zipWith_div #-}
map_sqrt :: forall r a. (Rounding r, Storable a, RoundedSqrt_Vector VS.Vector a) => VS.Vector (Rounded r a) -> VS.Vector (Rounded r a)
map_sqrt :: forall (r :: RoundingMode) a.
(Rounding r, Storable a, RoundedSqrt_Vector Vector a) =>
Vector (Rounded r a) -> Vector (Rounded r a)
map_sqrt Vector (Rounded r a)
v = forall a (r :: RoundingMode). Vector a -> Vector (Rounded r a)
toVectorOfRounded (forall (vector :: * -> *) a.
RoundedSqrt_Vector vector a =>
RoundingMode -> vector a -> vector a
map_roundedSqrt RoundingMode
r (forall (r :: RoundingMode) a. Vector (Rounded r a) -> Vector a
fromVectorOfRounded Vector (Rounded r a)
v))
where r :: RoundingMode
r = forall (r :: RoundingMode) (proxy :: RoundingMode -> *).
Rounding r =>
proxy r -> RoundingMode
rounding (forall {k} (t :: k). Proxy t
Proxy :: Proxy r)
{-# INLINE map_sqrt #-}