module Data.Number.Flint.Acb.ComplexField (
CF(..)
, RF'(..)
, Special (..)
, realPart
, imagPart
, mkPolar
, cis
, polar
, magnitude
, phase
, conjugate
) where
import GHC.TypeLits
import Data.Proxy
import Data.Ratio
import System.IO.Unsafe
import Control.Monad
import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Ptr ( Ptr, FunPtr, castPtr )
import Foreign.Storable
import Foreign.Marshal ( free )
import Foreign.Marshal.Array ( advancePtr )
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpz.Instances
import Data.Number.Flint.Arb
import Data.Number.Flint.Arb.RealField
import Data.Number.Flint.Arb.Types
import Data.Number.Flint.Acb
import Data.Number.Flint.Acb.Acf
import Data.Number.Flint.Acb.Types
import Data.Number.Flint.Acb.Hypgeom
import Data.Number.Flint.Acb.Modular
import Data.Number.Flint.Acb.Elliptic
import Data.Number.Flint.Support.D.Interval
newtype CF (n :: Nat) = CF Acb
realPart :: forall n. KnownNat n => (CF n) -> (RF n)
realPart :: forall (n :: Nat). KnownNat n => CF n -> RF n
realPart (CF Acb
z) = IO (RF n) -> RF n
forall a. IO a -> a
unsafePerformIO (IO (RF n) -> RF n) -> IO (RF n) -> RF n
forall a b. (a -> b) -> a -> b
$ do
Arb
res <- IO Arb
newArb
Arb -> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
res ((Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ())))
-> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
res -> do
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
z ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
z -> do
Ptr CArb -> Ptr CAcb -> IO ()
acb_get_real Ptr CArb
res Ptr CAcb
z
RF n -> IO (RF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (RF n -> IO (RF n)) -> RF n -> IO (RF n)
forall a b. (a -> b) -> a -> b
$ Arb -> RF n
forall (n :: Nat). Arb -> RF n
RF Arb
res
imagPart :: forall n. KnownNat n => (CF n) -> (RF n)
imagPart :: forall (n :: Nat). KnownNat n => CF n -> RF n
imagPart (CF Acb
z) = IO (RF n) -> RF n
forall a. IO a -> a
unsafePerformIO (IO (RF n) -> RF n) -> IO (RF n) -> RF n
forall a b. (a -> b) -> a -> b
$ do
Arb
res <- IO Arb
newArb
Arb -> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
res ((Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ())))
-> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
res -> do
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
z ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
z -> do
Ptr CArb -> Ptr CAcb -> IO ()
acb_get_imag Ptr CArb
res Ptr CAcb
z
RF n -> IO (RF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (RF n -> IO (RF n)) -> RF n -> IO (RF n)
forall a b. (a -> b) -> a -> b
$ Arb -> RF n
forall (n :: Nat). Arb -> RF n
RF Arb
res
mkPolar :: forall n. KnownNat n => (RF n) -> (RF n) -> (CF n)
mkPolar :: forall (n :: Nat). KnownNat n => RF n -> RF n -> CF n
mkPolar (RF Arb
r) (RF Arb
theta) = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
let prec :: CLong
prec = Integer -> CLong
forall a. Num a => Integer -> a
fromInteger (Integer -> CLong) -> Integer -> CLong
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Acb
res <- IO Acb
newAcb
Acb
-> (Ptr CAcb -> IO (Arb, (Arb, (Arb, (Arb, ())))))
-> IO (Acb, (Arb, (Arb, (Arb, (Arb, ())))))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
res ((Ptr CAcb -> IO (Arb, (Arb, (Arb, (Arb, ())))))
-> IO (Acb, (Arb, (Arb, (Arb, (Arb, ()))))))
-> (Ptr CAcb -> IO (Arb, (Arb, (Arb, (Arb, ())))))
-> IO (Acb, (Arb, (Arb, (Arb, (Arb, ())))))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
res -> do
Arb
-> (Ptr CArb -> IO (Arb, (Arb, (Arb, ()))))
-> IO (Arb, (Arb, (Arb, (Arb, ()))))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
r ((Ptr CArb -> IO (Arb, (Arb, (Arb, ()))))
-> IO (Arb, (Arb, (Arb, (Arb, ())))))
-> (Ptr CArb -> IO (Arb, (Arb, (Arb, ()))))
-> IO (Arb, (Arb, (Arb, (Arb, ()))))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
r -> do
Arb
-> (Ptr CArb -> IO (Arb, (Arb, ()))) -> IO (Arb, (Arb, (Arb, ())))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
theta ((Ptr CArb -> IO (Arb, (Arb, ()))) -> IO (Arb, (Arb, (Arb, ()))))
-> (Ptr CArb -> IO (Arb, (Arb, ()))) -> IO (Arb, (Arb, (Arb, ())))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
theta -> do
(Ptr CArb -> IO (Arb, ())) -> IO (Arb, (Arb, ()))
forall {a}. (Ptr CArb -> IO a) -> IO (Arb, a)
withNewArb ((Ptr CArb -> IO (Arb, ())) -> IO (Arb, (Arb, ())))
-> (Ptr CArb -> IO (Arb, ())) -> IO (Arb, (Arb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
x -> do
(Ptr CArb -> IO ()) -> IO (Arb, ())
forall {a}. (Ptr CArb -> IO a) -> IO (Arb, a)
withNewArb ((Ptr CArb -> IO ()) -> IO (Arb, ()))
-> (Ptr CArb -> IO ()) -> IO (Arb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
y -> do
Ptr CArb -> Ptr CArb -> Ptr CArb -> CLong -> IO ()
arb_sin_cos Ptr CArb
y Ptr CArb
x Ptr CArb
theta CLong
prec
Ptr CArb -> Ptr CArb -> Ptr CArb -> CLong -> IO ()
arb_mul Ptr CArb
x Ptr CArb
x Ptr CArb
r CLong
prec
Ptr CArb -> Ptr CArb -> Ptr CArb -> CLong -> IO ()
arb_mul Ptr CArb
y Ptr CArb
y Ptr CArb
r CLong
prec
Ptr CAcb -> Ptr CArb -> Ptr CArb -> IO ()
acb_set_arb_arb Ptr CAcb
res Ptr CArb
x Ptr CArb
y
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CF n -> IO (CF n)) -> CF n -> IO (CF n)
forall a b. (a -> b) -> a -> b
$ Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
res
cis :: forall n. KnownNat n => (RF n) -> (CF n)
cis :: forall (n :: Nat). KnownNat n => RF n -> CF n
cis (RF Arb
theta) = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
let prec :: CLong
prec = Integer -> CLong
forall a. Num a => Integer -> a
fromInteger (Integer -> CLong) -> Integer -> CLong
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Acb
res <- IO Acb
newAcb
Acb
-> (Ptr CAcb -> IO (Arb, (Arb, (Arb, ()))))
-> IO (Acb, (Arb, (Arb, (Arb, ()))))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
res ((Ptr CAcb -> IO (Arb, (Arb, (Arb, ()))))
-> IO (Acb, (Arb, (Arb, (Arb, ())))))
-> (Ptr CAcb -> IO (Arb, (Arb, (Arb, ()))))
-> IO (Acb, (Arb, (Arb, (Arb, ()))))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
res -> do
Arb
-> (Ptr CArb -> IO (Arb, (Arb, ()))) -> IO (Arb, (Arb, (Arb, ())))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
theta ((Ptr CArb -> IO (Arb, (Arb, ()))) -> IO (Arb, (Arb, (Arb, ()))))
-> (Ptr CArb -> IO (Arb, (Arb, ()))) -> IO (Arb, (Arb, (Arb, ())))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
theta -> do
(Ptr CArb -> IO (Arb, ())) -> IO (Arb, (Arb, ()))
forall {a}. (Ptr CArb -> IO a) -> IO (Arb, a)
withNewArb ((Ptr CArb -> IO (Arb, ())) -> IO (Arb, (Arb, ())))
-> (Ptr CArb -> IO (Arb, ())) -> IO (Arb, (Arb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
x -> do
(Ptr CArb -> IO ()) -> IO (Arb, ())
forall {a}. (Ptr CArb -> IO a) -> IO (Arb, a)
withNewArb ((Ptr CArb -> IO ()) -> IO (Arb, ()))
-> (Ptr CArb -> IO ()) -> IO (Arb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
y -> do
Ptr CArb -> Ptr CArb -> Ptr CArb -> CLong -> IO ()
arb_sin_cos Ptr CArb
y Ptr CArb
x Ptr CArb
theta CLong
prec
Ptr CAcb -> Ptr CArb -> Ptr CArb -> IO ()
acb_set_arb_arb Ptr CAcb
res Ptr CArb
x Ptr CArb
y
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CF n -> IO (CF n)) -> CF n -> IO (CF n)
forall a b. (a -> b) -> a -> b
$ Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
res
polar :: forall n. KnownNat n => (CF n) -> (RF n, RF n)
polar :: forall (n :: Nat). KnownNat n => CF n -> (RF n, RF n)
polar CF n
z = (CF n -> RF n
forall (n :: Nat). KnownNat n => CF n -> RF n
magnitude CF n
z, CF n -> RF n
forall (n :: Nat). KnownNat n => CF n -> RF n
phase CF n
z)
magnitude :: forall n. KnownNat n => (CF n) -> (RF n)
magnitude :: forall (n :: Nat). KnownNat n => CF n -> RF n
magnitude (CF Acb
z) = IO (RF n) -> RF n
forall a. IO a -> a
unsafePerformIO (IO (RF n) -> RF n) -> IO (RF n) -> RF n
forall a b. (a -> b) -> a -> b
$ do
let prec :: CLong
prec = Integer -> CLong
forall a. Num a => Integer -> a
fromInteger (Integer -> CLong) -> Integer -> CLong
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Arb
res <- IO Arb
newArb
Arb -> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
res ((Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ())))
-> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
res -> do
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
z ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
z -> do
Ptr CArb -> Ptr CAcb -> CLong -> IO ()
acb_abs Ptr CArb
res Ptr CAcb
z CLong
prec
RF n -> IO (RF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (RF n -> IO (RF n)) -> RF n -> IO (RF n)
forall a b. (a -> b) -> a -> b
$ Arb -> RF n
forall (n :: Nat). Arb -> RF n
RF Arb
res
phase :: forall n. KnownNat n => (CF n) -> (RF n)
phase :: forall (n :: Nat). KnownNat n => CF n -> RF n
phase (CF Acb
z) = IO (RF n) -> RF n
forall a. IO a -> a
unsafePerformIO (IO (RF n) -> RF n) -> IO (RF n) -> RF n
forall a b. (a -> b) -> a -> b
$ do
let prec :: CLong
prec = Integer -> CLong
forall a. Num a => Integer -> a
fromInteger (Integer -> CLong) -> Integer -> CLong
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Arb
res <- IO Arb
newArb
Arb -> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
res ((Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ())))
-> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
res -> do
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
z ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
z -> do
Ptr CArb -> Ptr CAcb -> CLong -> IO ()
acb_arg Ptr CArb
res Ptr CAcb
z CLong
prec
RF n -> IO (RF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (RF n -> IO (RF n)) -> RF n -> IO (RF n)
forall a b. (a -> b) -> a -> b
$ Arb -> RF n
forall (n :: Nat). Arb -> RF n
RF Arb
res
conjugate :: forall n. KnownNat n => (CF n) -> (CF n)
conjugate :: forall (n :: Nat). KnownNat n => CF n -> CF n
conjugate (CF Acb
z) = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
Acb
res <- IO Acb
newAcb
Acb -> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
res ((Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ())))
-> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
res -> do
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
z ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
z -> do
Ptr CAcb -> Ptr CAcb -> IO ()
acb_conj Ptr CAcb
res Ptr CAcb
z
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CF n -> IO (CF n)) -> CF n -> IO (CF n)
forall a b. (a -> b) -> a -> b
$ Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
res
instance forall n. KnownNat n => Eq (CF n) where
{-# INLINE (==) #-}
== :: CF n -> CF n -> Bool
(==) = Cmp -> CF n -> CF n -> Bool
forall (n :: Nat). KnownNat n => Cmp -> CF n -> CF n -> Bool
liftCmp Cmp
acb_eq
{-# INLINE (/=) #-}
/= :: CF n -> CF n -> Bool
(/=) = Cmp -> CF n -> CF n -> Bool
forall (n :: Nat). KnownNat n => Cmp -> CF n -> CF n -> Bool
liftCmp Cmp
acb_ne
instance forall n. KnownNat n => Ord (CF n) where
compare :: CF n -> CF n -> Ordering
compare = CF n -> CF n -> Ordering
forall a. HasCallStack => a
undefined
instance forall n. KnownNat n => Num (CF n) where
{-# INLINE (+) #-}
+ :: CF n -> CF n -> CF n
(+) = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_add
{-# INLINE (-) #-}
(-) = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_sub
{-# INLINE (*) #-}
* :: CF n -> CF n -> CF n
(*) = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_mul
{-# INLINE negate #-}
negate :: CF n -> CF n
negate = (Ptr CAcb -> Ptr CAcb -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> IO ()) -> CF n -> CF n
lift1 Ptr CAcb -> Ptr CAcb -> IO ()
acb_neg
abs :: CF n -> CF n
abs = CF n -> CF n
forall a. HasCallStack => a
undefined
{-# INLINE fromInteger #-}
fromInteger :: Integer -> CF n
fromInteger Integer
x = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
Acb
result <- IO Acb
newAcb
let prec :: Integer
prec = Integer -> Integer
forall a. Num a => Integer -> a
fromInteger (Integer -> Integer) -> Integer -> Integer
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
result ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
result -> do
Ptr CAcb -> CULong -> IO ()
acb_set_ui Ptr CAcb
result (Integer -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
x)
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
result)
signum :: CF n -> CF n
signum = CF n -> CF n
forall a. HasCallStack => a
undefined
instance forall n. KnownNat n => Fractional (CF n) where
{-# INLINE (/) #-}
/ :: CF n -> CF n -> CF n
(/) = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_div
fromRational :: Rational -> CF n
fromRational Rational
x = CF n
p CF n -> CF n -> CF n
forall a. Fractional a => a -> a -> a
/ CF n
q where
p :: CF n
p = Integer -> CF n
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Rational -> Integer
forall a. Ratio a -> a
numerator Rational
x) :: CF n
q :: CF n
q = Integer -> CF n
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Rational -> Integer
forall a. Ratio a -> a
denominator Rational
x) :: CF n
instance forall n. KnownNat n => Real (CF n) where
toRational :: CF n -> Rational
toRational = CF n -> Rational
forall a. HasCallStack => a
undefined
instance forall n. KnownNat n => RealFrac (CF n) where
properFraction :: forall b. Integral b => CF n -> (b, CF n)
properFraction = CF n -> (b, CF n)
forall a. HasCallStack => a
undefined
instance forall n. KnownNat n => Floating (CF n) where
pi :: CF n
pi = (Ptr CArb -> CLong -> IO ()) -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant Ptr CArb -> CLong -> IO ()
arb_const_pi
exp :: CF n -> CF n
exp = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_exp
log :: CF n -> CF n
log = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_log
sqrt :: CF n -> CF n
sqrt = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_sqrt
sin :: CF n -> CF n
sin = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_sin
cos :: CF n -> CF n
cos = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_cos
tan :: CF n -> CF n
tan = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_tan
asin :: CF n -> CF n
asin = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_asin
acos :: CF n -> CF n
acos = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_acos
atan :: CF n -> CF n
atan = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_atan
sinh :: CF n -> CF n
sinh = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_sinh
cosh :: CF n -> CF n
cosh = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_cosh
tanh :: CF n -> CF n
tanh = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_tanh
asinh :: CF n -> CF n
asinh = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_asinh
acosh :: CF n -> CF n
acosh = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_acosh
atanh :: CF n -> CF n
atanh = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_atanh
instance forall n. KnownNat n => Show (CF n) where
show :: CF n -> String
show (CF Acb
x) = IO String -> String
forall a. IO a -> a
unsafePerformIO (IO String -> String) -> IO String -> String
forall a b. (a -> b) -> a -> b
$ do
let prec :: Integer
prec = Integer -> Integer
forall a. Num a => Integer -> a
fromInteger (Integer -> Integer) -> Integer -> Integer
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
digits :: Integer
digits = Double -> Integer
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
prec Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double -> Double -> Double
forall a. Floating a => a -> a -> a
logBase Double
10 Double
2)
(Acb
_, CString
cstr) <- Acb -> (Ptr CAcb -> IO CString) -> IO (Acb, CString)
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
x ((Ptr CAcb -> IO CString) -> IO (Acb, CString))
-> (Ptr CAcb -> IO CString) -> IO (Acb, CString)
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
p ->
Ptr CAcb -> CLong -> CULong -> IO CString
acb_get_strn Ptr CAcb
p (Integer -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
digits) CULong
arb_str_no_radius
String
str <- CString -> IO String
peekCString CString
cstr
String -> IO String
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return String
str
instance forall n. KnownNat n => Special (CF n) where
gamma :: CF n -> CF n
gamma = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_gamma
digamma :: CF n -> CF n
digamma = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_digamma
lgamma :: CF n -> CF n
lgamma = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_hypgeom_lgamma
zeta :: CF n -> CF n
zeta = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_zeta
erf :: CF n -> CF n
erf = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_hypgeom_erf
airy :: CF n -> (CF n, CF n, CF n, CF n)
airy (CF Acb
x) = IO (CF n, CF n, CF n, CF n) -> (CF n, CF n, CF n, CF n)
forall a. IO a -> a
unsafePerformIO (IO (CF n, CF n, CF n, CF n) -> (CF n, CF n, CF n, CF n))
-> IO (CF n, CF n, CF n, CF n) -> (CF n, CF n, CF n, CF n)
forall a b. (a -> b) -> a -> b
$ do
let prec :: CLong
prec = Integer -> CLong
forall a. Num a => Integer -> a
fromInteger (Integer -> CLong) -> Integer -> CLong
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Acb
ai <- IO Acb
newAcb
Acb
ai' <- IO Acb
newAcb
Acb
bi <- IO Acb
newAcb
Acb
bi' <- IO Acb
newAcb
Acb
-> (Ptr CAcb -> IO (Acb, (Acb, (Acb, (Acb, ())))))
-> IO (Acb, (Acb, (Acb, (Acb, (Acb, ())))))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
x ((Ptr CAcb -> IO (Acb, (Acb, (Acb, (Acb, ())))))
-> IO (Acb, (Acb, (Acb, (Acb, (Acb, ()))))))
-> (Ptr CAcb -> IO (Acb, (Acb, (Acb, (Acb, ())))))
-> IO (Acb, (Acb, (Acb, (Acb, (Acb, ())))))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
x ->
Acb
-> (Ptr CAcb -> IO (Acb, (Acb, (Acb, ()))))
-> IO (Acb, (Acb, (Acb, (Acb, ()))))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
ai ((Ptr CAcb -> IO (Acb, (Acb, (Acb, ()))))
-> IO (Acb, (Acb, (Acb, (Acb, ())))))
-> (Ptr CAcb -> IO (Acb, (Acb, (Acb, ()))))
-> IO (Acb, (Acb, (Acb, (Acb, ()))))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
ai ->
Acb
-> (Ptr CAcb -> IO (Acb, (Acb, ()))) -> IO (Acb, (Acb, (Acb, ())))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
ai' ((Ptr CAcb -> IO (Acb, (Acb, ()))) -> IO (Acb, (Acb, (Acb, ()))))
-> (Ptr CAcb -> IO (Acb, (Acb, ()))) -> IO (Acb, (Acb, (Acb, ())))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
ai' ->
Acb -> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
bi ((Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ())))
-> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
bi ->
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
bi' ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
bi' ->
Ptr CAcb -> Ptr CAcb -> Binary
acb_hypgeom_airy Ptr CAcb
ai Ptr CAcb
ai' Ptr CAcb
bi Ptr CAcb
bi' Ptr CAcb
x CLong
prec
(CF n, CF n, CF n, CF n) -> IO (CF n, CF n, CF n, CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ((CF n, CF n, CF n, CF n) -> IO (CF n, CF n, CF n, CF n))
-> (CF n, CF n, CF n, CF n) -> IO (CF n, CF n, CF n, CF n)
forall a b. (a -> b) -> a -> b
$ (Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
ai, Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
ai', Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
bi, Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
bi')
airyZeros :: Fmpz -> (CF n, CF n, CF n, CF n)
airyZeros = Fmpz -> (CF n, CF n, CF n, CF n)
forall a. HasCallStack => a
undefined
besselJ :: CF n -> CF n -> CF n
besselJ = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_hypgeom_bessel_j
besselY :: CF n -> CF n -> CF n
besselY = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_hypgeom_bessel_y
besselI :: CF n -> CF n -> CF n
besselI = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_hypgeom_bessel_i
besselK :: CF n -> CF n -> CF n
besselK = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_hypgeom_bessel_k
modj :: CF n -> CF n
modj = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_modular_j
modjq :: CF n -> CF n
modjq = CF n -> CF n
forall a. HasCallStack => a
undefined
modeta :: CF n -> CF n
modeta = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_modular_eta
modetaq :: CF n -> CF n
modetaq = CF n -> CF n
forall a. HasCallStack => a
undefined
modlambda :: CF n -> CF n
modlambda = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_modular_lambda
modlambdaq :: CF n -> CF n
modlambdaq = CF n -> CF n
forall a. HasCallStack => a
undefined
ellipp :: CF n -> CF n -> CF n
ellipp = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_elliptic_p
ellipzeta :: CF n -> CF n -> CF n
ellipzeta = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_elliptic_zeta
ellipsigma :: CF n -> CF n -> CF n
ellipsigma = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_elliptic_sigma
barnesg :: CF n -> CF n
barnesg = (Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
acb_barnes_g
agm :: CF n -> CF n -> CF n
agm = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_agm
fresnels :: CF n -> CF n
fresnels = CF n -> CF n
forall a. HasCallStack => a
undefined
fresnelc :: CF n -> CF n
fresnelc = CF n -> CF n
forall a. HasCallStack => a
undefined
instance forall n. KnownNat n => RF' (CF n) where
euler :: CF n
euler = (Ptr CArb -> CLong -> IO ()) -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant Ptr CArb -> CLong -> IO ()
arb_const_euler
glaisher :: CF n
glaisher = (Ptr CArb -> CLong -> IO ()) -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant Ptr CArb -> CLong -> IO ()
arb_const_glaisher
catalan :: CF n
catalan = (Ptr CArb -> CLong -> IO ()) -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant Ptr CArb -> CLong -> IO ()
arb_const_catalan
khinchin :: CF n
khinchin = (Ptr CArb -> CLong -> IO ()) -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant Ptr CArb -> CLong -> IO ()
arb_const_khinchin
polylog :: CF n -> CF n -> CF n
polylog = Binary -> CF n -> CF n -> CF n
forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
acb_polylog
midPoint :: CF n -> CF n
midPoint = (Ptr CAcb -> Ptr CAcb -> IO ()) -> CF n -> CF n
forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> IO ()) -> CF n -> CF n
lift1 Ptr CAcb -> Ptr CAcb -> IO ()
acb_get_mid
type Binary = Ptr CAcb -> Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
type Cmp = Ptr CAcb -> Ptr CAcb -> IO CInt
type Function = Ptr CAcb -> Ptr CAcb -> IO ()
lift2 :: forall n. KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 :: forall (n :: Nat). KnownNat n => Binary -> CF n -> CF n -> CF n
lift2 Binary
f (CF Acb
a) (CF Acb
b) = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
let prec :: Int64
prec = Integer -> Int64
forall a. Num a => Integer -> a
fromInteger (Integer -> Int64) -> Integer -> Int64
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Acb
c <- IO Acb
newAcb
Acb
-> (Ptr CAcb -> IO (Acb, (Acb, ()))) -> IO (Acb, (Acb, (Acb, ())))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
a ((Ptr CAcb -> IO (Acb, (Acb, ()))) -> IO (Acb, (Acb, (Acb, ()))))
-> (Ptr CAcb -> IO (Acb, (Acb, ()))) -> IO (Acb, (Acb, (Acb, ())))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
a ->
Acb -> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
b ((Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ())))
-> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
b ->
Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
c ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
c ->
Binary
f Ptr CAcb
c Ptr CAcb
a Ptr CAcb
b (Int64 -> CLong
CLong Int64
prec)
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
c)
lift1 :: forall n. KnownNat n => Function -> CF n -> CF n
lift1 :: forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> IO ()) -> CF n -> CF n
lift1 Ptr CAcb -> Ptr CAcb -> IO ()
f (CF Acb
x) = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
Acb
y <- IO Acb
newAcb
Acb -> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
x ((Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ())))
-> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
x -> Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
y ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
y -> Ptr CAcb -> Ptr CAcb -> IO ()
f Ptr CAcb
y Ptr CAcb
x
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
y)
lift0 :: (Ptr CAcb -> p -> IO b) -> p -> CF n
lift0 Ptr CAcb -> p -> IO b
f p
x = Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF (Acb -> CF n) -> Acb -> CF n
forall a b. (a -> b) -> a -> b
$ IO Acb -> Acb
forall a. IO a -> a
unsafePerformIO (IO Acb -> Acb) -> IO Acb -> Acb
forall a b. (a -> b) -> a -> b
$ (Acb, b) -> Acb
forall a b. (a, b) -> a
fst ((Acb, b) -> Acb) -> IO (Acb, b) -> IO Acb
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Ptr CAcb -> IO b) -> IO (Acb, b)
forall {a}. (Ptr CAcb -> IO a) -> IO (Acb, a)
withNewAcb (Ptr CAcb -> p -> IO b
`f` p
x)
liftF1 :: forall n. KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 :: forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> Ptr CAcb -> CLong -> IO ()) -> CF n -> CF n
liftF1 Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
f (CF Acb
x) = IO (CF n) -> CF n
forall a. IO a -> a
unsafePerformIO (IO (CF n) -> CF n) -> IO (CF n) -> CF n
forall a b. (a -> b) -> a -> b
$ do
let prec :: Int64
prec = Integer -> Int64
forall a. Num a => Integer -> a
fromInteger (Integer -> Int64) -> Integer -> Int64
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Acb
y <- IO Acb
newAcb
Acb -> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
x ((Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ())))
-> (Ptr CAcb -> IO (Acb, ())) -> IO (Acb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
x -> Acb -> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
y ((Ptr CAcb -> IO ()) -> IO (Acb, ()))
-> (Ptr CAcb -> IO ()) -> IO (Acb, ())
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
y -> Ptr CAcb -> Ptr CAcb -> CLong -> IO ()
f Ptr CAcb
y Ptr CAcb
x (Int64 -> CLong
CLong Int64
prec)
CF n -> IO (CF n)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF Acb
y)
liftCmp :: forall n. KnownNat n => Cmp -> CF n -> CF n -> Bool
liftCmp :: forall (n :: Nat). KnownNat n => Cmp -> CF n -> CF n -> Bool
liftCmp Cmp
f (CF Acb
x) (CF Acb
y) = IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$ do
(Acb
_, (Acb
_, CInt
cmp)) <- Acb -> (Ptr CAcb -> IO (Acb, CInt)) -> IO (Acb, (Acb, CInt))
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
x ((Ptr CAcb -> IO (Acb, CInt)) -> IO (Acb, (Acb, CInt)))
-> (Ptr CAcb -> IO (Acb, CInt)) -> IO (Acb, (Acb, CInt))
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
x -> Acb -> (Ptr CAcb -> IO CInt) -> IO (Acb, CInt)
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
y ((Ptr CAcb -> IO CInt) -> IO (Acb, CInt))
-> (Ptr CAcb -> IO CInt) -> IO (Acb, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
y -> Cmp
f Ptr CAcb
x Ptr CAcb
y
Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CInt
cmp CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
1)
liftProp :: forall n. KnownNat n => (Ptr CAcb -> IO CInt) -> CF n -> Bool
liftProp :: forall (n :: Nat).
KnownNat n =>
(Ptr CAcb -> IO CInt) -> CF n -> Bool
liftProp Ptr CAcb -> IO CInt
f (CF Acb
x) = IO Bool -> Bool
forall a. IO a -> a
unsafePerformIO (IO Bool -> Bool) -> IO Bool -> Bool
forall a b. (a -> b) -> a -> b
$ do
(Acb
_, CInt
prop) <- Acb -> (Ptr CAcb -> IO CInt) -> IO (Acb, CInt)
forall {a}. Acb -> (Ptr CAcb -> IO a) -> IO (Acb, a)
withAcb Acb
x ((Ptr CAcb -> IO CInt) -> IO (Acb, CInt))
-> (Ptr CAcb -> IO CInt) -> IO (Acb, CInt)
forall a b. (a -> b) -> a -> b
$ \Ptr CAcb
x -> Ptr CAcb -> IO CInt
f Ptr CAcb
x
Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (CInt
prop CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
== CInt
1)
liftConstant :: forall n. KnownNat n => (Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant :: forall (n :: Nat).
KnownNat n =>
(Ptr CArb -> CLong -> IO ()) -> CF n
liftConstant Ptr CArb -> CLong -> IO ()
f = Acb -> CF n
forall (n :: Nat). Acb -> CF n
CF (Acb -> CF n) -> Acb -> CF n
forall a b. (a -> b) -> a -> b
$ (Acb, ()) -> Acb
forall a b. (a, b) -> a
fst ((Acb, ()) -> Acb) -> (Acb, ()) -> Acb
forall a b. (a -> b) -> a -> b
$ (Arb, (Acb, ())) -> (Acb, ())
forall a b. (a, b) -> b
snd ((Arb, (Acb, ())) -> (Acb, ())) -> (Arb, (Acb, ())) -> (Acb, ())
forall a b. (a -> b) -> a -> b
$ IO (Arb, (Acb, ())) -> (Arb, (Acb, ()))
forall a. IO a -> a
unsafePerformIO (IO (Arb, (Acb, ())) -> (Arb, (Acb, ())))
-> IO (Arb, (Acb, ())) -> (Arb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ do
let prec :: CLong
prec = Integer -> CLong
forall a. Num a => Integer -> a
fromInteger (Integer -> CLong) -> Integer -> CLong
forall a b. (a -> b) -> a -> b
$ Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> *).
KnownNat n =>
proxy n -> Integer
natVal (Proxy n
forall {k} (t :: k). Proxy t
Proxy :: Proxy n)
Arb
tmp <- IO Arb
newArb
Arb -> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall {a}. Arb -> (Ptr CArb -> IO a) -> IO (Arb, a)
withArb Arb
tmp ((Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ())))
-> (Ptr CArb -> IO (Acb, ())) -> IO (Arb, (Acb, ()))
forall a b. (a -> b) -> a -> b
$ \Ptr CArb
tmp -> do
Ptr CArb -> CLong -> IO ()
f Ptr CArb
tmp CLong
prec
(Ptr CAcb -> IO ()) -> IO (Acb, ())
forall {a}. (Ptr CAcb -> IO a) -> IO (Acb, a)
withNewAcb (Ptr CAcb -> Ptr CArb -> IO ()
`acb_set_arb` Ptr CArb
tmp)