Karim Belabas on Sat, 12 Oct 2013 18:03:48 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: nice undocumented feature |
* Max Alekseyev [2013-10-12 17:45]: > I've just noticed that divisors(X), fordiv(X,...), sumdiv(X,...) > functions accept as an argument the factorization of X instead of X, > e.g.: > > ? divisors([3,1;5,1]) > %1 = [1, 3, 5, 15] > > I found this feature very helpful (for X with known but hard to > compute factorizations) and deserving to be documented. Good to know it's useful, thanks ! :-) As for documentation, cf the official announcement http://pari.math.u-bordeaux1.fr/archives/pari-announce-13/msg00003.html [Elementary Number Theory] - arithmetic functions now accept factorization matrices as input, you can use any of f(N), f(factor(N)) or f([N, factor(N)]). as well as the documentation of Arithmetic functions (\S 3.4 in User's Manual), also available as (18:00) gp > ??4 Arithmetic functions: These functions are by definition functions whose natural domain of definition is either Z (or Z_{ > 0}). The way these functions are used is completely different from transcendental functions in that there are no automatic type conversions: in general only integers are accepted as arguments. An integer argument N can be given in the following alternate formats: * t_MAT: its factorization fa = factor(N), * t_VEC: a pair [N, fa] giving both the integer and its factorization. This allows to compute different arithmetic functions at a given N while factoring the latter only once. ? N = 10!; faN = factor(N); ? eulerphi(N) %2 = 829440 ? eulerphi(faN) %3 = 829440 [...] You'd prefer we add a short note in each individual function ? Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux1.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux1.fr/ [PARI/GP] `