flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
460 stars 142 forks source link

arb_sqr #113

Open argriffing opened 8 years ago

argriffing commented 8 years ago

This could just be a small wrapper around arb_mul(b, a, a, prec) for now.

rickyefarr commented 8 years ago

Added arb_sqr and acb_sqr as well as documentation in commit:

https://github.com/rickyefarr/arb/commit/73011a5386120dd3fa20215bff4df4c757f06b3e

rickyefarr commented 8 years ago

Should other types have a squaring method?

fredrik-johansson commented 8 years ago

Maybe. There are already squaring methods for matrices. With polynomials, I guess there should also be sqrlow, and for arb_t/acb_t, addsqr, subsqr.

rickyefarr commented 8 years ago

I'll add these when I get the chance, but I do have a question. Are there any particular reason why we wouldn't use the preprocessor to define these functions? For example, instead of using an inlined function, use

define arb_sqr(res, x, prec) arb_mul((res), (x), (x), (prec))

Are there any reasons why this would not be preferable?

rickyefarr commented 8 years ago

I haven't done any tests in awhile, but the last time I did mpfr was faster when squaring. Perhaps the algorithm that is used by mpfr should be implemented?

Does anyone know the algorithm used? I'll try to implement it.

rickyefarr commented 8 years ago

Any updates on this? Is this worth pursuing further?

fredrik-johansson commented 8 years ago

About the preprocessor: the problem is that it doesn't create a linkable function.

Squaring uses mpn_mul and mpfr_mul depending on the precision, so it should be close to optimal. However, there's still some overhead than necessary in arb_mul, which I plan to remove some time...