module Sym.Perm.Bijection
(
simionSchmidt
, simionSchmidt'
) where
import Sym.Perm
import Foreign
import Foreign.C.Types
import System.IO.Unsafe
foreign import ccall unsafe "bij.h simion_schmidt" c_simion_schmidt
:: Ptr CLong -> Ptr CLong -> CLong -> IO ()
foreign import ccall unsafe "bij.h simion_schmidt_inverse" c_simion_schmidt'
:: Ptr CLong -> Ptr CLong -> CLong -> IO ()
marshal :: (Ptr CLong -> Ptr CLong -> CLong -> IO ()) -> Perm -> Perm
marshal bij w =
unsafePerformIO . unsafeWith w $ \p -> do
let n = size w
unsafeNew n $ \q -> bij q p (fromIntegral n)
simionSchmidt :: Perm -> Perm
simionSchmidt = marshal c_simion_schmidt
simionSchmidt' :: Perm -> Perm
simionSchmidt' = marshal c_simion_schmidt'