ocramz / petsc-hs

Haskell bindings for PETSc and SLEPc
GNU General Public License v3.0
20 stars 4 forks source link

infer types with c2hs macros #1

Closed ocramz closed 8 years ago

ocramz commented 9 years ago

Currently, the elementary types such as PetscInt, PetscBool, PetscScalar ... are hardcoded as type synonyms to CInt, CDouble, Bool respectively (see Raw/Internal.hs).

The problem/feature is that PETSc can be configured with different numerical precisions, or using complex numbers as scalars, etc.

There should be a c2hs macro file that takes care of automatically mapping these types; it should be run before the inline-c step, since these types will be needed to build the inline-c context (see petscContext in Internal).

ocramz commented 8 years ago

IMPORTANT : The main problem is with the interpretation of the PetscScalar_ synonym. It should be CDouble for real-valued PETSc builds (the default), but Complex CDouble if PETSc is configured with --with-scalar-type=complex

ocramz commented 8 years ago

Fixed with generated C2Hs file Numerical.PETSc.Internal.C2HsGen.TypesC2HsGen