Skip to content

Wrapping nfloat in Arblib.jl #2184

Closed
Closed
@Joel-Dahne

Description

@Joel-Dahne

I started an attempt of wrapping the new nfloat module in Arblib.jl. I thought I would create this issue to collect some of the issues and decisions encountered along the way. I'm creating the issue here on the Flint page instead of the Arblib.jl page since the discussions could be relevant for Flint itself.

It is relevant to know that the way Arblib.jl works is that it parses the Flint documentation and automatically generates the low level wrapping of the functions. In particular this means that having enough information in the function signatures to automatically generate the wrappers is important, otherwise a lot of manual work is required.

So far I have two comments:

  1. The functions nfloat_ctx_set_real_prec and nfloat_ctx_set_real_prec have different names in the documentation and the code. In the code they have a leading underscore. I'm not sure which one is the intended one?
  2. Many Flint types (such as arb) have a _t-suffix version that is used for scalar values and the _ptr and _srcptr-suffix version that is used for vectors of that type (e.g. arb_t, arb_ptr and arb_srcptr). In Arblib.jl the _t version is mapped to the scalar type and the _ptr and _srcptr versions are mapped to vectors of that type (arb_t is mapped to Arb, and arb_ptr and arb_srcptr are mapped to ArbVector). I don't think this approach is used in all of Flint, but at least for the types coming from Arb it is mostly followed. For nfloat this approach is not followed, it uses nfloat_ptr and nfloat_srcptr for everything. This is problematic for the automatic wrapping because we don't have enough information to determine if the argument is a scalar or a vector. My understanding is that the reason for this is that nfloat is not actually a single type, but each precision is technically its own type, is that correct? One possible solution to this issue (from the point of view of Arblib.jl) could maybe be to define typedef void * nfloat_t (which is exactly the same definition as for nfloat_ptr) and use that type whenever a scalar value is intended. Would this be technically possible? I'm however not so fond of forcing Flint to structure it's code in a certain way just to make the life for Arblib.jl easier (though of course it could also help any other attempt of automatically generating wrappers). In this case it could however maybe be beneficial in terms of the Flint documentation as well, the type signature nfloat_ptr doesn't tell the user if the function expects a scalar value or a vector so using nfloat_t for scalar values could be helpful for that reason. The could be some other reason for the choice to use nfloat_ptr instead of nfloat_t that I'm missing though?

If I encounter any more issues in my wrapping attempt I'll update you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions