arb icon indicating copy to clipboard operation
arb copied to clipboard

arb_sqr

Open argriffing opened this issue 9 years ago • 7 comments

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

argriffing avatar Mar 10 '16 01:03 argriffing

Added arb_sqr and acb_sqr as well as documentation in commit:

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

rickyefarr avatar Apr 21 '16 10:04 rickyefarr

Should other types have a squaring method?

rickyefarr avatar Apr 22 '16 02:04 rickyefarr

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.

fredrik-johansson avatar Apr 22 '16 13:04 fredrik-johansson

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 avatar Apr 22 '16 20:04 rickyefarr

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 avatar May 16 '16 12:05 rickyefarr

Any updates on this? Is this worth pursuing further?

rickyefarr avatar Jun 11 '16 17:06 rickyefarr

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...

fredrik-johansson avatar Jun 14 '16 00:06 fredrik-johansson