flintlib / flint

FLINT (Fast Library for Number Theory)
http://www.flintlib.org
GNU Lesser General Public License v3.0
444 stars 245 forks source link

Generic domain closures #1914

Open fredrik-johansson opened 7 months ago

fredrik-johansson commented 7 months ago

For a generic ring $R$ (or other structure, where relevant), we can define:

This is currently only done for ca_t (https://flintlib.org/doc/ca.html#introduction-special-values; see also https://fredrikj.net/blog/2021/01/infinity-in-calcium-and-fungrim/) and less formally for arf_t for arb_t, where NaN stands for Undefined or Unknown depending on context.

It would be better to do this with a generic construction that wraps any given ring R. By default, operations could simply intercept GR_UNABLE (turning them into Unknown) and GR_DOMAIN (turning them into Undefined). This could be refined with infinity handling for special functions like gr_exp over rings where infinities make sense.

Advantages:

Disadvantages:

albinahlback commented 7 months ago

Disadvantages:

  • There would be a performance hit working with $R^{*}$ or $R^$ instead of $R$ (due to needing to wrap and inspect elements). But surely this isn't the use case to optimize for? Normally, you'd want to use $R^{*}$ or $R^$ only where it is convenient, and do your actual number crunching in $R$.

I agree, but it would have to be done case by case, I believe? Otherwise there may be, as you imply, unwanted overhead.