{-# LANGUAGE CPP #-} {-# LANGUAGE ForeignFunctionInterface #-} -- | -- Module : Foreign.CUDA.BLAS.Sparse.Matrix.Hybrid -- Copyright : [2017] Trevor L. McDonell -- License : BSD3 -- -- Maintainer : Trevor L. McDonell -- Stability : experimental -- Portability : non-portable (GHC extensions) -- module Foreign.CUDA.BLAS.Sparse.Matrix.Hybrid ( Hybrid(..), HybridPartition(..), createHYB, destroyHYB, ) where -- Friends import Foreign.CUDA.BLAS.Sparse.Error import Foreign.CUDA.BLAS.Sparse.Internal.C2HS -- System import Foreign import Foreign.C import Control.Monad ( liftM ) #include "cbits/stubs.h" {# context lib="cusparse" #} -- | An opaque structure holding the matrix in hybrid (HYB) format. -- -- -- newtype Hybrid = Hybrid { useHYB :: {# type cusparseHybMat_t #}} -- | Indicates how to perform the partitioning of the matrix into regular (ELL) -- and irregular (COO) parts of the HYB format. -- -- -- {# enum cusparseHybPartition_t as HybridPartition { underscoreToCase } with prefix="CUSPARSE_HYB_PARTITION" deriving (Eq, Show) #} -- | Create a new (opaque) hybrid matrix. -- -- -- {-# INLINEABLE createHYB #-} {# fun unsafe cusparseCreateHybMat as createHYB { alloca- `Hybrid' peekHYB* } -> `()' checkStatus*- #} where peekHYB = liftM Hybrid . peek -- | Destroy and release any memory associated with a hybrid matrix. -- -- -- {-# INLINEABLE destroyHYB #-} {# fun unsafe cusparseDestroyHybMat as destroyHYB { useHYB `Hybrid' } -> `()' checkStatus* #}