{-# LINE 1 "src/Data/Number/Flint/Groups/Perm/FFI.hsc" #-}
module Data.Number.Flint.Groups.Perm.FFI (
_perm_init
, _perm_clear
, _perm_set
, _perm_set_one
, _perm_inv
, _perm_compose
, _perm_power
, _perm_randtest
, _perm_print
, _perm_print_pretty
, _perm_fprint_pretty
, _perm_get_str_pretty
, _perm_order
, _perm_parity
, _perm_mat
) where
import Control.Monad
import Foreign.C.String
import Foreign.C.Types
import Foreign.ForeignPtr
import Foreign.Ptr ( Ptr, FunPtr, plusPtr )
import Foreign.Storable
import Foreign.Marshal ( free, peekArray )
import Data.Number.Flint.Flint
import Data.Number.Flint.Fmpz
import Data.Number.Flint.Fmpz.Mat
foreign import ccall "perm.h _perm_init"
_perm_init :: CLong -> IO (Ptr CLong)
foreign import ccall "perm.h _perm_clear"
_perm_clear :: Ptr CLong -> IO ()
foreign import ccall "perm.h _perm_set"
_perm_set :: Ptr CLong -> Ptr CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_set_one"
_perm_set_one :: Ptr CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_inv"
_perm_inv :: Ptr CLong -> Ptr CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_compose"
_perm_compose :: Ptr CLong -> Ptr CLong -> Ptr CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_power"
_perm_power :: Ptr CLong -> Ptr CLong -> CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_parity"
_perm_parity :: Ptr CLong -> CLong -> IO CInt
foreign import ccall "perm.h _perm_order"
_perm_order :: Ptr CFmpz -> Ptr CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_mat"
_perm_mat :: Ptr CFmpzMat -> Ptr CLong -> CLong -> IO ()
foreign import ccall "perm.h _perm_randtest"
_perm_randtest :: Ptr CLong -> CLong -> Ptr CFRandState -> IO CInt
_perm_print :: Ptr CLong -> CLong -> IO CInt
_perm_print :: Ptr CLong -> CLong -> IO CInt
_perm_print Ptr CLong
p CLong
n = do
[CLong]
a <- forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
n) Ptr CLong
p
String -> IO ()
putStr forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show CLong
n forall a. [a] -> [a] -> [a]
++ String
" "
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [CLong]
a forall a b. (a -> b) -> a -> b
$ \CLong
x -> String -> IO ()
putStr forall a b. (a -> b) -> a -> b
$ String
" " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show CLong
x
forall (m :: * -> *) a. Monad m => a -> m a
return CInt
1
foreign import ccall "perm.h _perm_get_str_pretty"
_perm_get_str_pretty :: Ptr CLong -> CLong -> IO CString
_perm_print_pretty :: Ptr CLong -> CLong -> IO CInt
_perm_print_pretty :: Ptr CLong -> CLong -> IO CInt
_perm_print_pretty Ptr CLong
p CLong
n = forall a. (Ptr a -> IO CString) -> Ptr a -> IO CInt
printCStr (forall a b c. (a -> b -> c) -> b -> a -> c
flip Ptr CLong -> CLong -> IO CString
_perm_get_str_pretty CLong
n) Ptr CLong
p
foreign import ccall "perm.h _perm_fprint_pretty"
_perm_fprint_pretty :: Ptr CFile -> Ptr CLong -> CLong -> IO ()