Karim Belabas on Sun, 11 Nov 2007 01:00:58 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Sorting output of factor() |
* Jeroen Demeyer [2007-11-08 23:15]: > This is a rather technical question. After PARI finishes factoring, the > output is sorted in some way (for example, integers are in increasing > order). I would like to sort factorisations the way PARI does. Is there a > seperate function in PARI for this? There is no universal sorting function. You have a general template: 1) GEN sort_factor(GEN fa, void *data, int (*cmp)(void *,GEN,GEN)) to sort (in place) an arbitrary factorization matrix using comparison routine cmp to order irreducible factors (using auxiliary 'data'). This is for instance used with cmp = gauss_cmp (over Z[i]) or cmp = cmp_prime_ideal (providing a total ordering on maximal ideals in a given number field, with given basis for its ring of integers) 2) GEN sort_factor_pol(GEN fa, int (*cmp)(GEN,GEN)) a very common special case, which sorts (in place) a polynomial factorization matrix. Irreducible (polynomial) factors are sorted by increasing degree; factors of equal degree are sorted lexicographically, using cmp() to compare coefficients. Throughout the source code, depending on the precise function, we have cmp = gcmp ( or cmpii, but gcmp would sort in the same way here, over Q) cmp = cmp_padic (over Qp) cmp = cmp_RgX (over Q[y] and its quotients) What do you have in mind ? Cheers, K.B. -- Karim Belabas 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-bordeaux.fr/~belabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `