| Karim Belabas on Mon, 15 Jul 2024 23:19:31 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: vector of t_FRAC questions |
* hermann@stamm-wilbrandt.de [2024-07-15 23:00]:
> On 2024-07-15 22:35, Loïc Grenié wrote:
> > > D) how to convert d to [10, 112, -5] in GP simpler?
> >
> > d/2*2, and maybe d*2/2, would probably have the expected
> > effect. d*1 not...
> >
> Thanks, that helps:
>
> ? d
> [81920/1, 917504/1, -40960/1]
> ? d*2/2
> [81920, 917504, -40960]
> ?
>
>
> Despite doc ...
Nope. You're creating invalid GP objects from libpari, doc no longer applies.
There's a big fat warning at the beginning of chapter 5 in User's manual:
We shall now study specialized functions, more efficient than the library
wrappers, but sloppier on argument checking and damage control; besides
speed, their main advantage is to give finer control about the inner
workings of generic routines, offering more options to the programmer.
Important advice. Generic routines eventually call lower level functions.
Optimize your algorithms first, not overhead and conversion costs
between PARI routines. For generic operations, use generic routines
first; do not waste time looking for the most specialized one available
unless you identify a genuine bottleneck, or you need some special
behavior the generic routine does not offer. The PARI source code is
part of the documentation; look for inspiration there.
mkfrac() is a low-level constructors, both very fast and quite unsafe:
user is responsible to check that all preconditions are met. If you want
sanity tests, just use the high level gdiv(x,y) instead of mkfrac(x,y)
Cheers,
K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/