{-# LANGUAGE CPP                   #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeApplications      #-}
{-# LANGUAGE UnboxedTuples         #-}
{-# LANGUAGE UndecidableInstances  #-}
module Numeric.DataFrame.Internal.Backend.Family.DoubleX2 (DoubleX2 (..)) where

import           GHC.Base
import           Numeric.DataFrame.Internal.PrimArray
import           Numeric.PrimBytes
import           Numeric.ProductOrd
import qualified Numeric.ProductOrd.NonTransitive     as NonTransitive
import qualified Numeric.ProductOrd.Partial           as Partial


data DoubleX2 = DoubleX2# Double# Double#

-- | Since @Bounded@ is not implemented for floating point types, this instance
--   has an unresolvable constraint.
--   Nevetheless, it is good to have it here for nicer error messages.
instance Bounded Double => Bounded DoubleX2 where
    maxBound :: DoubleX2
maxBound = case Double
forall a. Bounded a => a
maxBound of D# Double#
x -> Double# -> Double# -> DoubleX2
DoubleX2# Double#
x Double#
x
    minBound :: DoubleX2
minBound = case Double
forall a. Bounded a => a
minBound of D# Double#
x -> Double# -> Double# -> DoubleX2
DoubleX2# Double#
x Double#
x


instance Eq DoubleX2 where

    DoubleX2# Double#
a1 Double#
a2 == :: DoubleX2 -> DoubleX2 -> Bool
== DoubleX2# Double#
b1 Double#
b2 =
      Int# -> Bool
isTrue#
      (       (Double#
a1 Double# -> Double# -> Int#
==## Double#
b1)
      Int# -> Int# -> Int#
`andI#` (Double#
a2 Double# -> Double# -> Int#
==## Double#
b2)
      )
    {-# INLINE (==) #-}

    DoubleX2# Double#
a1 Double#
a2 /= :: DoubleX2 -> DoubleX2 -> Bool
/= DoubleX2# Double#
b1 Double#
b2 =
      Int# -> Bool
isTrue#
      (      (Double#
a1 Double# -> Double# -> Int#
/=## Double#
b1)
      Int# -> Int# -> Int#
`orI#` (Double#
a2 Double# -> Double# -> Int#
/=## Double#
b2)
      )
    {-# INLINE (/=) #-}



cmp' :: Double# -> Double# -> PartialOrdering
cmp' :: Double# -> Double# -> PartialOrdering
cmp' Double#
a Double#
b
  | Int# -> Bool
isTrue# (Double#
a Double# -> Double# -> Int#
>## Double#
b) = PartialOrdering
PGT
  | Int# -> Bool
isTrue# (Double#
a Double# -> Double# -> Int#
<## Double#
b) = PartialOrdering
PLT
  | Bool
otherwise  = PartialOrdering
PEQ

instance ProductOrder DoubleX2 where
    cmp :: DoubleX2 -> DoubleX2 -> PartialOrdering
cmp (DoubleX2# Double#
a1 Double#
a2) (DoubleX2# Double#
b1 Double#
b2)
      = Double# -> Double# -> PartialOrdering
cmp' Double#
a1 Double#
b1 PartialOrdering -> PartialOrdering -> PartialOrdering
forall a. Semigroup a => a -> a -> a
<> Double# -> Double# -> PartialOrdering
cmp' Double#
a2 Double#
b2
    {-# INLINE cmp #-}

instance Ord (NonTransitive.ProductOrd DoubleX2) where
    NonTransitive.ProductOrd DoubleX2
x > :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
> NonTransitive.ProductOrd DoubleX2
y = DoubleX2 -> DoubleX2 -> PartialOrdering
forall a. ProductOrder a => a -> a -> PartialOrdering
cmp DoubleX2
x DoubleX2
y PartialOrdering -> PartialOrdering -> Bool
forall a. Eq a => a -> a -> Bool
== PartialOrdering
PGT
    {-# INLINE (>) #-}
    NonTransitive.ProductOrd DoubleX2
x < :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
< NonTransitive.ProductOrd DoubleX2
y = DoubleX2 -> DoubleX2 -> PartialOrdering
forall a. ProductOrder a => a -> a -> PartialOrdering
cmp DoubleX2
x DoubleX2
y PartialOrdering -> PartialOrdering -> Bool
forall a. Eq a => a -> a -> Bool
== PartialOrdering
PLT
    {-# INLINE (<) #-}
    >= :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
(>=) (NonTransitive.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
         (NonTransitive.ProductOrd (DoubleX2# Double#
b1 Double#
b2)) = Int# -> Bool
isTrue#
      ((Double#
a1 Double# -> Double# -> Int#
>=## Double#
b1) Int# -> Int# -> Int#
`andI#` (Double#
a2 Double# -> Double# -> Int#
>=## Double#
b2))
    {-# INLINE (>=) #-}
    <= :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
(<=) (NonTransitive.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
         (NonTransitive.ProductOrd (DoubleX2# Double#
b1 Double#
b2)) = Int# -> Bool
isTrue#
      ((Double#
a1 Double# -> Double# -> Int#
<=## Double#
b1) Int# -> Int# -> Int#
`andI#` (Double#
a2 Double# -> Double# -> Int#
<=## Double#
b2))
    {-# INLINE (<=) #-}
    compare :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Ordering
compare (NonTransitive.ProductOrd DoubleX2
a) (NonTransitive.ProductOrd DoubleX2
b)
      = PartialOrdering -> Ordering
NonTransitive.toOrdering (PartialOrdering -> Ordering) -> PartialOrdering -> Ordering
forall a b. (a -> b) -> a -> b
$ DoubleX2 -> DoubleX2 -> PartialOrdering
forall a. ProductOrder a => a -> a -> PartialOrdering
cmp DoubleX2
a DoubleX2
b
    {-# INLINE compare #-}
    min :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> ProductOrd DoubleX2
min (NonTransitive.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
        (NonTransitive.ProductOrd (DoubleX2# Double#
b1 Double#
b2))
      = DoubleX2 -> ProductOrd DoubleX2
forall a. a -> ProductOrd a
NonTransitive.ProductOrd
        ( Double# -> Double# -> DoubleX2
DoubleX2#
          (if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) then Double#
b1 else Double#
a1)
          (if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>## Double#
b2) then Double#
b2 else Double#
a2)
        )
    {-# INLINE min #-}
    max :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> ProductOrd DoubleX2
max (NonTransitive.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
        (NonTransitive.ProductOrd (DoubleX2# Double#
b1 Double#
b2))
      = DoubleX2 -> ProductOrd DoubleX2
forall a. a -> ProductOrd a
NonTransitive.ProductOrd
        ( Double# -> Double# -> DoubleX2
DoubleX2#
          (if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) then Double#
b1 else Double#
a1)
          (if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
<## Double#
b2) then Double#
b2 else Double#
a2)
        )
    {-# INLINE max #-}

instance Ord (Partial.ProductOrd DoubleX2) where
    Partial.ProductOrd DoubleX2
x > :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
> Partial.ProductOrd DoubleX2
y = DoubleX2 -> DoubleX2 -> PartialOrdering
forall a. ProductOrder a => a -> a -> PartialOrdering
cmp DoubleX2
x DoubleX2
y PartialOrdering -> PartialOrdering -> Bool
forall a. Eq a => a -> a -> Bool
== PartialOrdering
PGT
    {-# INLINE (>) #-}
    Partial.ProductOrd DoubleX2
x < :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
< Partial.ProductOrd DoubleX2
y = DoubleX2 -> DoubleX2 -> PartialOrdering
forall a. ProductOrder a => a -> a -> PartialOrdering
cmp DoubleX2
x DoubleX2
y PartialOrdering -> PartialOrdering -> Bool
forall a. Eq a => a -> a -> Bool
== PartialOrdering
PLT
    {-# INLINE (<) #-}
    >= :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
(>=) (Partial.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
         (Partial.ProductOrd (DoubleX2# Double#
b1 Double#
b2)) = Int# -> Bool
isTrue#
      ((Double#
a1 Double# -> Double# -> Int#
>=## Double#
b1) Int# -> Int# -> Int#
`andI#` (Double#
a2 Double# -> Double# -> Int#
>=## Double#
b2))
    {-# INLINE (>=) #-}
    <= :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Bool
(<=) (Partial.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
         (Partial.ProductOrd (DoubleX2# Double#
b1 Double#
b2)) = Int# -> Bool
isTrue#
      ((Double#
a1 Double# -> Double# -> Int#
<=## Double#
b1) Int# -> Int# -> Int#
`andI#` (Double#
a2 Double# -> Double# -> Int#
<=## Double#
b2))
    {-# INLINE (<=) #-}
    compare :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> Ordering
compare (Partial.ProductOrd DoubleX2
a) (Partial.ProductOrd DoubleX2
b)
      = PartialOrdering -> Ordering
Partial.toOrdering (PartialOrdering -> Ordering) -> PartialOrdering -> Ordering
forall a b. (a -> b) -> a -> b
$ DoubleX2 -> DoubleX2 -> PartialOrdering
forall a. ProductOrder a => a -> a -> PartialOrdering
cmp DoubleX2
a DoubleX2
b
    {-# INLINE compare #-}
    min :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> ProductOrd DoubleX2
min (Partial.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
        (Partial.ProductOrd (DoubleX2# Double#
b1 Double#
b2))
      = DoubleX2 -> ProductOrd DoubleX2
forall a. a -> ProductOrd a
Partial.ProductOrd
        ( Double# -> Double# -> DoubleX2
DoubleX2#
          (if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) then Double#
b1 else Double#
a1)
          (if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>## Double#
b2) then Double#
b2 else Double#
a2)
        )
    {-# INLINE min #-}
    max :: ProductOrd DoubleX2 -> ProductOrd DoubleX2 -> ProductOrd DoubleX2
max (Partial.ProductOrd (DoubleX2# Double#
a1 Double#
a2))
        (Partial.ProductOrd (DoubleX2# Double#
b1 Double#
b2))
      = DoubleX2 -> ProductOrd DoubleX2
forall a. a -> ProductOrd a
Partial.ProductOrd
        ( Double# -> Double# -> DoubleX2
DoubleX2#
          (if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) then Double#
b1 else Double#
a1)
          (if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
<## Double#
b2) then Double#
b2 else Double#
a2)
        )
    {-# INLINE max #-}

instance Ord DoubleX2 where
    DoubleX2# Double#
a1 Double#
a2 > :: DoubleX2 -> DoubleX2 -> Bool
> DoubleX2# Double#
b1 Double#
b2
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) = Bool
True
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) = Bool
False
      | Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>## Double#
b2) = Bool
True
      | Bool
otherwise           = Bool
False
    {-# INLINE (>) #-}

    DoubleX2# Double#
a1 Double#
a2 < :: DoubleX2 -> DoubleX2 -> Bool
< DoubleX2# Double#
b1 Double#
b2
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) = Bool
True
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) = Bool
False
      | Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
<## Double#
b2) = Bool
True
      | Bool
otherwise           = Bool
False
    {-# INLINE (<) #-}

    DoubleX2# Double#
a1 Double#
a2 >= :: DoubleX2 -> DoubleX2 -> Bool
>= DoubleX2# Double#
b1 Double#
b2
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) = Bool
False
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) = Bool
True
      | Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
<## Double#
b2) = Bool
False
      | Bool
otherwise           = Bool
True
    {-# INLINE (>=) #-}

    DoubleX2# Double#
a1 Double#
a2 <= :: DoubleX2 -> DoubleX2 -> Bool
<= DoubleX2# Double#
b1 Double#
b2
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) = Bool
False
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) = Bool
True
      | Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>## Double#
b2) = Bool
False
      | Bool
otherwise           = Bool
True
    {-# INLINE (<=) #-}

    compare :: DoubleX2 -> DoubleX2 -> Ordering
compare (DoubleX2# Double#
a1 Double#
a2) (DoubleX2# Double#
b1 Double#
b2)
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
b1) = Ordering
GT
      | Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
b1) = Ordering
LT
      | Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>## Double#
b2) = Ordering
GT
      | Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
<## Double#
b2) = Ordering
LT
      | Bool
otherwise           = Ordering
EQ
    {-# INLINE compare #-}



-- | element-wise operations for vectors
instance Num DoubleX2 where

    DoubleX2# Double#
a1 Double#
a2 + :: DoubleX2 -> DoubleX2 -> DoubleX2
+ DoubleX2# Double#
b1 Double#
b2
      = Double# -> Double# -> DoubleX2
DoubleX2# (Double# -> Double# -> Double#
(+##) Double#
a1 Double#
b1) (Double# -> Double# -> Double#
(+##) Double#
a2 Double#
b2)
    {-# INLINE (+) #-}

    DoubleX2# Double#
a1 Double#
a2 - :: DoubleX2 -> DoubleX2 -> DoubleX2
- DoubleX2# Double#
b1 Double#
b2
      = Double# -> Double# -> DoubleX2
DoubleX2# (Double# -> Double# -> Double#
(-##) Double#
a1 Double#
b1) (Double# -> Double# -> Double#
(-##) Double#
a2 Double#
b2)
    {-# INLINE (-) #-}

    DoubleX2# Double#
a1 Double#
a2 * :: DoubleX2 -> DoubleX2 -> DoubleX2
* DoubleX2# Double#
b1 Double#
b2
      = Double# -> Double# -> DoubleX2
DoubleX2# (Double# -> Double# -> Double#
(*##) Double#
a1 Double#
b1) (Double# -> Double# -> Double#
(*##) Double#
a2 Double#
b2)
    {-# INLINE (*) #-}

    negate :: DoubleX2 -> DoubleX2
negate (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
negateDouble# Double#
a1) (Double# -> Double#
negateDouble# Double#
a2)
    {-# INLINE negate #-}

    abs :: DoubleX2 -> DoubleX2
abs (DoubleX2# Double#
a1 Double#
a2)
      = Double# -> Double# -> DoubleX2
DoubleX2#
      (if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>=## Double#
0.0##) then Double#
a1 else Double# -> Double#
negateDouble# Double#
a1)
      (if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>=## Double#
0.0##) then Double#
a2 else Double# -> Double#
negateDouble# Double#
a2)
    {-# INLINE abs #-}

    signum :: DoubleX2 -> DoubleX2
signum (DoubleX2# Double#
a1 Double#
a2)
      = Double# -> Double# -> DoubleX2
DoubleX2# (if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
>## Double#
0.0##)
                  then Double#
1.0##
                  else if Int# -> Bool
isTrue# (Double#
a1 Double# -> Double# -> Int#
<## Double#
0.0##) then Double#
-1.0## else Double#
0.0## )
                 (if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
>## Double#
0.0##)
                  then Double#
1.0##
                  else if Int# -> Bool
isTrue# (Double#
a2 Double# -> Double# -> Int#
<## Double#
0.0##) then Double#
-1.0## else Double#
0.0## )
    {-# INLINE signum #-}

    fromInteger :: Integer -> DoubleX2
fromInteger Integer
n = case Integer -> Double
forall a. Num a => Integer -> a
fromInteger Integer
n of D# Double#
x -> Double# -> Double# -> DoubleX2
DoubleX2# Double#
x Double#
x
    {-# INLINE fromInteger #-}



instance Fractional DoubleX2 where

    DoubleX2# Double#
a1 Double#
a2 / :: DoubleX2 -> DoubleX2 -> DoubleX2
/ DoubleX2# Double#
b1 Double#
b2 = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double# -> Double#
(/##) Double#
a1 Double#
b1) (Double# -> Double# -> Double#
(/##) Double#
a2 Double#
b2)
    {-# INLINE (/) #-}

    recip :: DoubleX2 -> DoubleX2
recip (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double# -> Double#
(/##) Double#
1.0## Double#
a1) (Double# -> Double# -> Double#
(/##) Double#
1.0## Double#
a2)
    {-# INLINE recip #-}

    fromRational :: Rational -> DoubleX2
fromRational Rational
r = case Rational -> Double
forall a. Fractional a => Rational -> a
fromRational Rational
r of D# Double#
x -> Double# -> Double# -> DoubleX2
DoubleX2# Double#
x Double#
x
    {-# INLINE fromRational #-}



instance Floating DoubleX2 where

    pi :: DoubleX2
pi = Double# -> Double# -> DoubleX2
DoubleX2#
      Double#
3.141592653589793238##
      Double#
3.141592653589793238##
    {-# INLINE pi #-}

    exp :: DoubleX2 -> DoubleX2
exp (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
expDouble# Double#
a1) (Double# -> Double#
expDouble# Double#
a2)
    {-# INLINE exp #-}

    log :: DoubleX2 -> DoubleX2
log (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
logDouble# Double#
a1) (Double# -> Double#
logDouble# Double#
a2)
    {-# INLINE log #-}

    sqrt :: DoubleX2 -> DoubleX2
sqrt (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
sqrtDouble# Double#
a1) (Double# -> Double#
sqrtDouble# Double#
a2)
    {-# INLINE sqrt #-}

    sin :: DoubleX2 -> DoubleX2
sin (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
sinDouble# Double#
a1) (Double# -> Double#
sinDouble# Double#
a2)
    {-# INLINE sin #-}

    cos :: DoubleX2 -> DoubleX2
cos (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
cosDouble# Double#
a1) (Double# -> Double#
cosDouble# Double#
a2)
    {-# INLINE cos #-}

    tan :: DoubleX2 -> DoubleX2
tan (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
tanDouble# Double#
a1) (Double# -> Double#
tanDouble# Double#
a2)
    {-# INLINE tan #-}

    asin :: DoubleX2 -> DoubleX2
asin (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
asinDouble# Double#
a1) (Double# -> Double#
asinDouble# Double#
a2)
    {-# INLINE asin #-}

    acos :: DoubleX2 -> DoubleX2
acos (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
acosDouble# Double#
a1) (Double# -> Double#
acosDouble# Double#
a2)
    {-# INLINE acos #-}

    atan :: DoubleX2 -> DoubleX2
atan (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
atanDouble# Double#
a1) (Double# -> Double#
atanDouble# Double#
a2)
    {-# INLINE atan #-}

    sinh :: DoubleX2 -> DoubleX2
sinh (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
sinhDouble# Double#
a1) (Double# -> Double#
sinhDouble# Double#
a2)
    {-# INLINE sinh #-}

    cosh :: DoubleX2 -> DoubleX2
cosh (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
coshDouble# Double#
a1) (Double# -> Double#
coshDouble# Double#
a2)
    {-# INLINE cosh #-}

    tanh :: DoubleX2 -> DoubleX2
tanh (DoubleX2# Double#
a1 Double#
a2) = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double#
tanhDouble# Double#
a1) (Double# -> Double#
tanhDouble# Double#
a2)
    {-# INLINE tanh #-}

    DoubleX2# Double#
a1 Double#
a2 ** :: DoubleX2 -> DoubleX2 -> DoubleX2
** DoubleX2# Double#
b1 Double#
b2 = Double# -> Double# -> DoubleX2
DoubleX2#
      (Double# -> Double# -> Double#
(**##) Double#
a1 Double#
b1) (Double# -> Double# -> Double#
(**##) Double#
a2 Double#
b2)
    {-# INLINE (**) #-}

    logBase :: DoubleX2 -> DoubleX2 -> DoubleX2
logBase DoubleX2
x DoubleX2
y         =  DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
log DoubleX2
y DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Fractional a => a -> a -> a
/ DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
log DoubleX2
x
    {-# INLINE logBase #-}

    asinh :: DoubleX2 -> DoubleX2
asinh DoubleX2
x = DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
log (DoubleX2
x DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
+ DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
sqrt (DoubleX2
1.0DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
+DoubleX2
xDoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
*DoubleX2
x))
    {-# INLINE asinh #-}

    acosh :: DoubleX2 -> DoubleX2
acosh DoubleX2
x = DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
log (DoubleX2
x DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
+ (DoubleX2
xDoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
+DoubleX2
1.0) DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
* DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
sqrt ((DoubleX2
xDoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
-DoubleX2
1.0)DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Fractional a => a -> a -> a
/(DoubleX2
xDoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
+DoubleX2
1.0)))
    {-# INLINE acosh #-}

    atanh :: DoubleX2 -> DoubleX2
atanh DoubleX2
x = DoubleX2
0.5 DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
* DoubleX2 -> DoubleX2
forall a. Floating a => a -> a
log ((DoubleX2
1.0DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
+DoubleX2
x) DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Fractional a => a -> a -> a
/ (DoubleX2
1.0DoubleX2 -> DoubleX2 -> DoubleX2
forall a. Num a => a -> a -> a
-DoubleX2
x))
    {-# INLINE atanh #-}

-- offset in bytes is S times bigger than offset in prim elements,
-- when S is power of two, this is equal to shift
#define BOFF_TO_PRIMOFF(off) uncheckedIShiftRL# off 3#
#define ELEM_N 2

instance PrimBytes DoubleX2 where

    getBytes :: DoubleX2 -> ByteArray#
getBytes (DoubleX2# Double#
a1 Double#
a2) = case (State# RealWorld -> (# State# RealWorld, ByteArray# #))
-> (# State# RealWorld, ByteArray# #)
forall o. (State# RealWorld -> o) -> o
runRW#
       ( \State# RealWorld
s0 -> case Int#
-> State# RealWorld
-> (# State# RealWorld, MutableByteArray# RealWorld #)
forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)
newByteArray# (DoubleX2 -> Int#
forall a. PrimBytes a => a -> Int#
byteSize @DoubleX2 DoubleX2
forall a. HasCallStack => a
undefined) State# RealWorld
s0 of
           (# State# RealWorld
s1, MutableByteArray# RealWorld
marr #) -> case MutableByteArray# RealWorld
-> Int# -> Double# -> State# RealWorld -> State# RealWorld
forall d.
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeDoubleArray# MutableByteArray# RealWorld
marr Int#
0# Double#
a1 State# RealWorld
s1 of
             State# RealWorld
s2 -> case MutableByteArray# RealWorld
-> Int# -> Double# -> State# RealWorld -> State# RealWorld
forall d.
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeDoubleArray# MutableByteArray# RealWorld
marr Int#
1# Double#
a2 State# RealWorld
s2 of
               State# RealWorld
s3 -> MutableByteArray# RealWorld
-> State# RealWorld -> (# State# RealWorld, ByteArray# #)
forall d.
MutableByteArray# d -> State# d -> (# State# d, ByteArray# #)
unsafeFreezeByteArray# MutableByteArray# RealWorld
marr State# RealWorld
s3
       ) of (# State# RealWorld
_, ByteArray#
a #) -> ByteArray#
a
    {-# INLINE getBytes #-}

    fromBytes :: Int# -> ByteArray# -> DoubleX2
fromBytes Int#
off ByteArray#
arr
      | Int#
i <- BOFF_TO_PRIMOFF(off)
      = Double# -> Double# -> DoubleX2
DoubleX2#
      (ByteArray# -> Int# -> Double#
indexDoubleArray# ByteArray#
arr Int#
i)
      (ByteArray# -> Int# -> Double#
indexDoubleArray# ByteArray#
arr (Int#
i Int# -> Int# -> Int#
+# Int#
1#))
    {-# INLINE fromBytes #-}

    readBytes :: MutableByteArray# s -> Int# -> State# s -> (# State# s, DoubleX2 #)
readBytes MutableByteArray# s
mba Int#
off State# s
s0
      | Int#
i <- BOFF_TO_PRIMOFF(off)
      = case MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
readDoubleArray# MutableByteArray# s
mba Int#
i State# s
s0 of
      (# State# s
s1, Double#
a1 #) -> case MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
readDoubleArray# MutableByteArray# s
mba (Int#
i Int# -> Int# -> Int#
+# Int#
1#) State# s
s1 of
        (# State# s
s2, Double#
a2 #) -> (# State# s
s2, Double# -> Double# -> DoubleX2
DoubleX2# Double#
a1 Double#
a2 #)
    {-# INLINE readBytes #-}

    writeBytes :: MutableByteArray# s -> Int# -> DoubleX2 -> State# s -> State# s
writeBytes MutableByteArray# s
mba Int#
off (DoubleX2# Double#
a1 Double#
a2) State# s
s
      | Int#
i <- BOFF_TO_PRIMOFF(off)
      = MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeDoubleArray# MutableByteArray# s
mba (Int#
i Int# -> Int# -> Int#
+# Int#
1#) Double#
a2
      ( MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeDoubleArray# MutableByteArray# s
mba  Int#
i        Double#
a1 State# s
s )
    {-# INLINE writeBytes #-}

    readAddr :: Addr# -> State# s -> (# State# s, DoubleX2 #)
readAddr Addr#
addr State# s
s0
      = case Addr# -> Int# -> State# s -> (# State# s, Double# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Double# #)
readDoubleOffAddr# Addr#
addr Int#
0# State# s
s0 of
      (# State# s
s1, Double#
a1 #) -> case Addr# -> Int# -> State# s -> (# State# s, Double# #)
forall d. Addr# -> Int# -> State# d -> (# State# d, Double# #)
readDoubleOffAddr# Addr#
addr Int#
1# State# s
s1 of
        (# State# s
s2, Double#
a2 #) -> (# State# s
s2, Double# -> Double# -> DoubleX2
DoubleX2# Double#
a1 Double#
a2 #)
    {-# INLINE readAddr #-}

    writeAddr :: DoubleX2 -> Addr# -> State# s -> State# s
writeAddr (DoubleX2# Double#
a1 Double#
a2) Addr#
addr State# s
s
      = Addr# -> Int# -> Double# -> State# s -> State# s
forall d. Addr# -> Int# -> Double# -> State# d -> State# d
writeDoubleOffAddr# Addr#
addr Int#
1# Double#
a2
      ( Addr# -> Int# -> Double# -> State# s -> State# s
forall d. Addr# -> Int# -> Double# -> State# d -> State# d
writeDoubleOffAddr# Addr#
addr Int#
0# Double#
a1 State# s
s )
    {-# INLINE writeAddr #-}

    byteSize :: DoubleX2 -> Int#
byteSize DoubleX2
_ = Double -> Int#
forall a. PrimBytes a => a -> Int#
byteSize @Double Double
forall a. HasCallStack => a
undefined Int# -> Int# -> Int#
*# ELEM_N#
    {-# INLINE byteSize #-}

    byteAlign :: DoubleX2 -> Int#
byteAlign DoubleX2
_ = Double -> Int#
forall a. PrimBytes a => a -> Int#
byteAlign @Double Double
forall a. HasCallStack => a
undefined
    {-# INLINE byteAlign #-}

    byteOffset :: DoubleX2 -> Int#
byteOffset DoubleX2
_ = Int#
0#
    {-# INLINE byteOffset #-}

    byteFieldOffset :: Proxy# name -> DoubleX2 -> Int#
byteFieldOffset Proxy# name
_ DoubleX2
_ = Int# -> Int#
negateInt# Int#
1#
    {-# INLINE byteFieldOffset #-}

    indexArray :: ByteArray# -> Int# -> DoubleX2
indexArray ByteArray#
ba Int#
off
      | Int#
i <- Int#
off Int# -> Int# -> Int#
*# ELEM_N#
      = Double# -> Double# -> DoubleX2
DoubleX2#
      (ByteArray# -> Int# -> Double#
indexDoubleArray# ByteArray#
ba Int#
i)
      (ByteArray# -> Int# -> Double#
indexDoubleArray# ByteArray#
ba (Int#
i Int# -> Int# -> Int#
+# Int#
1#))
    {-# INLINE indexArray #-}

    readArray :: MutableByteArray# s -> Int# -> State# s -> (# State# s, DoubleX2 #)
readArray MutableByteArray# s
mba Int#
off State# s
s0
      | Int#
i <- Int#
off Int# -> Int# -> Int#
*# ELEM_N#
      = case MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
readDoubleArray# MutableByteArray# s
mba Int#
i State# s
s0 of
      (# State# s
s1, Double#
a1 #) -> case MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
forall d.
MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
readDoubleArray# MutableByteArray# s
mba (Int#
i Int# -> Int# -> Int#
+# Int#
1#) State# s
s1 of
        (# State# s
s2, Double#
a2 #) -> (# State# s
s2, Double# -> Double# -> DoubleX2
DoubleX2# Double#
a1 Double#
a2 #)
    {-# INLINE readArray #-}

    writeArray :: MutableByteArray# s -> Int# -> DoubleX2 -> State# s -> State# s
writeArray MutableByteArray# s
mba Int#
off (DoubleX2# Double#
a1 Double#
a2) State# s
s
      | Int#
i <- Int#
off Int# -> Int# -> Int#
*# ELEM_N#
      = MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeDoubleArray# MutableByteArray# s
mba (Int#
i Int# -> Int# -> Int#
+# Int#
1#) Double#
a2
      ( MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
forall d.
MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeDoubleArray# MutableByteArray# s
mba  Int#
i        Double#
a1 State# s
s )
    {-# INLINE writeArray #-}


instance PrimArray Double DoubleX2 where

    broadcast# :: Double -> DoubleX2
broadcast# (D# Double#
x) = Double# -> Double# -> DoubleX2
DoubleX2# Double#
x Double#
x
    {-# INLINE broadcast# #-}

    ix# :: Int# -> DoubleX2 -> Double
ix# Int#
0# (DoubleX2# Double#
a1 Double#
_) = Double# -> Double
D# Double#
a1
    ix# Int#
1# (DoubleX2# Double#
_ Double#
a2) = Double# -> Double
D# Double#
a2
    ix# Int#
_   DoubleX2
_               = Double
forall a. HasCallStack => a
undefined
    {-# INLINE ix# #-}

    gen# :: CumulDims -> (s -> (# s, Double #)) -> s -> (# s, DoubleX2 #)
gen# CumulDims
_ s -> (# s, Double #)
f s
s0 = case s -> (# s, Double #)
f s
s0 of
      (# s
s1, D# Double#
a1 #) -> case s -> (# s, Double #)
f s
s1 of
        (# s
s2, D# Double#
a2 #) -> (# s
s2, Double# -> Double# -> DoubleX2
DoubleX2# Double#
a1 Double#
a2 #)


    upd# :: CumulDims -> Int# -> Double -> DoubleX2 -> DoubleX2
upd# CumulDims
_ Int#
0# (D# Double#
q) (DoubleX2# Double#
_ Double#
y) = Double# -> Double# -> DoubleX2
DoubleX2# Double#
q Double#
y
    upd# CumulDims
_ Int#
1# (D# Double#
q) (DoubleX2# Double#
x Double#
_) = Double# -> Double# -> DoubleX2
DoubleX2# Double#
x Double#
q
    upd# CumulDims
_ Int#
_ Double
_ DoubleX2
x                     = DoubleX2
x
    {-# INLINE upd# #-}

    withArrayContent# :: (Double -> r)
-> (CumulDims -> Int# -> ByteArray# -> r) -> DoubleX2 -> r
withArrayContent# Double -> r
_ CumulDims -> Int# -> ByteArray# -> r
g DoubleX2
x = CumulDims -> Int# -> ByteArray# -> r
g ([Word] -> CumulDims
CumulDims [ELEM_N, 1]) 0# (getBytes x)
    {-# INLINE withArrayContent# #-}

    offsetElems :: DoubleX2 -> Int#
offsetElems DoubleX2
_ = Int#
0#
    {-# INLINE offsetElems #-}

    uniqueOrCumulDims :: DoubleX2 -> Either Double CumulDims
uniqueOrCumulDims DoubleX2
_ = CumulDims -> Either Double CumulDims
forall a b. b -> Either a b
Right ([Word] -> CumulDims
CumulDims [ELEM_N, 1])
    {-# INLINE uniqueOrCumulDims #-}

    fromElems# :: CumulDims -> Int# -> ByteArray# -> DoubleX2
fromElems# CumulDims
_ Int#
off ByteArray#
ba = Double# -> Double# -> DoubleX2
DoubleX2#
      (ByteArray# -> Int# -> Double#
indexDoubleArray# ByteArray#
ba Int#
off)
      (ByteArray# -> Int# -> Double#
indexDoubleArray# ByteArray#
ba (Int#
off Int# -> Int# -> Int#
+# Int#
1#))
    {-# INLINE fromElems# #-}