From fa9204b9a928205cdf040c1c9d0efcebc8bc7ec1 Mon Sep 17 00:00:00 2001 From: pcpa Date: Tue, 27 May 2014 10:47:12 -0300 Subject: [PATCH] Update to sagemath 6.2 --- .gitignore | 1 + sagemath-cbc.patch | 9 +- sagemath-cryptominisat.patch | 7 +- sagemath-extensions.patch | 6 +- sagemath-fes.patch | 7 +- sagemath-gap-hap.patch | 15 +- sagemath-gmp.patch | 16 +- sagemath-lrcalc.patch | 7 +- sagemath-nauty.patch | 7 +- sagemath-nopari2.6.patch | 25 - sagemath-ntl6.patch | 841 +- sagemath-pari.patch | 12 +- sagemath-pari2.7.patch | 8553 +++++++++++++++++ sagemath-png.patch | 11 +- sagemath-readonly.patch | 7 +- sagemath-rpmbuild.patch | 32 +- sagemath-sagedoc.patch | 27 +- sagemath-scons.patch | 6 +- sagemath-scripts.patch | 52 +- sagemath-sphinx.patch | 139 + sagemath.spec | 131 +- sources | 2 +- ...ranslation_of_a_tour_of_sage_rebase1.patch | 192 - trac_12822_pt_translation_of_tutorial.patch | 6801 ------------- ...2822_pt_translation_of_tutorial_rev1.patch | 468 - 25 files changed, 9618 insertions(+), 7756 deletions(-) delete mode 100644 sagemath-nopari2.6.patch create mode 100644 sagemath-pari2.7.patch create mode 100644 sagemath-sphinx.patch delete mode 100644 trac_12502_pt_translation_of_a_tour_of_sage_rebase1.patch delete mode 100644 trac_12822_pt_translation_of_tutorial.patch delete mode 100644 trac_12822_pt_translation_of_tutorial_rev1.patch diff --git a/.gitignore b/.gitignore index d9f8507..7ecb53f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /sage-5.12.tar /sage-5.13.tar /sage-6.1.1.tar.gz +/sage-6.2.tar.gz diff --git a/sagemath-cbc.patch b/sagemath-cbc.patch index 40bc3e6..27353e5 100644 --- a/sagemath-cbc.patch +++ b/sagemath-cbc.patch @@ -1,8 +1,7 @@ -diff -up src/module_list.py.orig src/module_list.py ---- src/module_list.py.orig 2014-02-07 12:39:09.255844618 -0200 -+++ src/module_list.py 2014-02-07 12:39:20.005845030 -0200 -@@ -2114,7 +2114,7 @@ if (os.path.isfile(SAGE_INC + "/cplex.h" - libraries = ["csage", "stdc++", "cplex"]) +--- src/module_list.py.orig 2014-05-10 16:02:43.371125667 -0300 ++++ src/module_list.py 2014-05-10 16:02:58.362124591 -0300 +@@ -2115,7 +2115,7 @@ if (os.path.isfile(SAGE_INC + "/cplex.h" + libraries = ["stdc++", "cplex"]) ) -if is_package_installed('cbc'): diff --git a/sagemath-cryptominisat.patch b/sagemath-cryptominisat.patch index f580c53..6133d8a 100644 --- a/sagemath-cryptominisat.patch +++ b/sagemath-cryptominisat.patch @@ -1,7 +1,6 @@ -diff -up src/module_list.py.orig src/module_list.py ---- src/module_list.py.orig 2014-02-07 12:47:06.312862886 -0200 -+++ src/module_list.py 2014-02-07 12:49:07.920867543 -0200 -@@ -2124,7 +2124,7 @@ if is_package_installed('cbc'): +--- src/module_list.py.orig 2014-05-10 15:59:50.979138032 -0300 ++++ src/module_list.py 2014-05-10 16:00:00.142137375 -0300 +@@ -2125,7 +2125,7 @@ if is_package_installed('cbc'): ) diff --git a/sagemath-extensions.patch b/sagemath-extensions.patch index 8d6da27..f394699 100644 --- a/sagemath-extensions.patch +++ b/sagemath-extensions.patch @@ -1,7 +1,7 @@ diff -up src/module_list.py.orig src/module_list.py ---- src/module_list.py.orig 2014-02-07 11:27:41.862680439 -0200 -+++ src/module_list.py 2014-02-07 11:27:58.536681078 -0200 -@@ -2069,7 +2069,8 @@ ext_modules = [ +--- src/module_list.py.orig 2014-05-26 13:34:05.597783829 -0300 ++++ src/module_list.py 2014-05-26 13:34:15.908784224 -0300 +@@ -2070,7 +2070,8 @@ ext_modules = [ # These extensions are to be compiled only if the # corresponding packages have been installed diff --git a/sagemath-fes.patch b/sagemath-fes.patch index e774b7c..559d784 100644 --- a/sagemath-fes.patch +++ b/sagemath-fes.patch @@ -1,7 +1,6 @@ -diff -up src/module_list.py.orig src/module_list.py ---- src/module_list.py.orig 2014-02-07 12:46:14.237860892 -0200 -+++ src/module_list.py 2014-02-07 12:46:18.226861045 -0200 -@@ -2073,7 +2073,7 @@ ext_modules = [ +--- src/module_list.py.orig 2014-05-10 15:58:00.155145981 -0300 ++++ src/module_list.py 2014-05-10 15:58:09.742145293 -0300 +@@ -2074,7 +2074,7 @@ ext_modules = [ def is_package_installed(name): return False diff --git a/sagemath-gap-hap.patch b/sagemath-gap-hap.patch index da0fe02..95a545b 100644 --- a/sagemath-gap-hap.patch +++ b/sagemath-gap-hap.patch @@ -1,23 +1,22 @@ -diff -up src/sage/groups/perm_gps/permgroup.py.orig src/sage/groups/perm_gps/permgroup.py ---- src/sage/groups/perm_gps/permgroup.py.orig 2014-02-07 12:37:33.523840952 -0200 -+++ src/sage/groups/perm_gps/permgroup.py 2014-02-07 12:37:42.905841312 -0200 +--- src/sage/groups/perm_gps/permgroup.py.orig 2014-05-10 15:53:23.284165840 -0300 ++++ src/sage/groups/perm_gps/permgroup.py 2014-05-10 15:54:59.829158915 -0300 @@ -180,8 +180,7 @@ def hap_decorator(f): """ @wraps(f) def wrapped(self, n, p=0): - if not is_package_installed('gap_packages'): -- raise RuntimeError, "You must install the optional gap_packages package." -+ raise RuntimeError, "gap-hap package not available." +- raise RuntimeError("You must install the optional gap_packages package.") ++ raise RuntimeError("gap-hap package not available.") load_hap() from sage.rings.arith import is_prime if not (p == 0 or is_prime(p)): -@@ -3934,8 +3933,7 @@ class PermutationGroup_generic(group.Gro +@@ -3933,8 +3932,7 @@ class PermutationGroup_generic(group.Gro - David Joyner and Graham Ellis """ - if not is_package_installed('gap_packages'): -- raise RuntimeError, "You must install the optional gap_packages package." -+ raise RuntimeError, "gap-hap package not available." +- raise RuntimeError("You must install the optional gap_packages package.") ++ raise RuntimeError("gap-hap package not available.") load_hap() from sage.rings.arith import is_prime if not (p == 0 or is_prime(p)): diff --git a/sagemath-gmp.patch b/sagemath-gmp.patch index 99e721b..386e747 100644 --- a/sagemath-gmp.patch +++ b/sagemath-gmp.patch @@ -1,18 +1,6 @@ -diff -up src/c_lib/src/memory.c.orig src/c_lib/src/memory.c ---- src/c_lib/src/memory.c.orig 2014-02-07 11:01:49.674621000 -0200 -+++ src/c_lib/src/memory.c 2014-02-07 11:02:02.046621474 -0200 -@@ -18,7 +18,7 @@ AUTHORS: - ****************************************************************************/ - - #include --#include -+#include - #include "interrupt.h" - #include "memory.h" - diff -up src/sage/modular/arithgroup/farey.cpp.orig src/sage/modular/arithgroup/farey.cpp ---- src/sage/modular/arithgroup/farey.cpp.orig 2014-02-07 16:44:24.474408115 -0200 -+++ src/sage/modular/arithgroup/farey.cpp 2014-02-07 16:44:33.100408446 -0200 +--- src/sage/modular/arithgroup/farey.cpp.orig 2014-05-26 13:28:28.975770939 -0300 ++++ src/sage/modular/arithgroup/farey.cpp 2014-05-26 13:28:45.777771582 -0300 @@ -141,6 +141,7 @@ operator*(const SL2Z& M, const vectorSetDims(nrows, ncols); + /* Returns a *new* ZZ object. + AUTHOR: David Harvey (2008-06-08) */ +-struct ZZ* int_to_ZZ(int value) ++ZZ* int_to_ZZ(int value) + { + ZZ* output = new ZZ(); + conv(*output, value); +@@ -40,7 +40,7 @@ struct ZZ* int_to_ZZ(int value) + Assumes output has been mpz_init'd. + AUTHOR: David Harvey + Joel B. Mohler moved the ZZX_getitem_as_mpz code out to this function (2007-03-13) */ +-void ZZ_to_mpz(mpz_t* output, const struct ZZ* x) ++void ZZ_to_mpz(mpz_t* output, const ZZ* x) + { + unsigned char stack_bytes[4096]; + int use_heap; +@@ -62,7 +62,7 @@ void ZZ_to_mpz(mpz_t* output, const stru + /* Copies the mpz_t into the ZZ + AUTHOR: Joel B. Mohler (2007-03-15) */ + // This should be changed to an mpz_t not an mpz_t* +-void mpz_to_ZZ(struct ZZ* output, const mpz_t *x) ++void mpz_to_ZZ(ZZ* output, const mpz_t *x) + { + unsigned char stack_bytes[4096]; + int use_heap; +@@ -86,7 +86,7 @@ void ZZ_set_from_int(ZZ* x, int value) + conv(*x, value); } --struct mat_ZZ* mat_ZZ_pow(const struct mat_ZZ* x, long e) -+mat_ZZ* mat_ZZ_pow(const mat_ZZ* x, long e) +-long ZZ_remove(struct ZZ &dest, const struct ZZ &src, const struct ZZ &f) ++long ZZ_remove(ZZ &dest, const ZZ &src, const ZZ &f) { - mat_ZZ *z = new mat_ZZ(); + // Based on the code for mpz_remove + ZZ fpow[40]; // inexaustible...until year 2020 or so +@@ -172,12 +172,12 @@ void ZZ_p_set_from_int(ZZ_p* x, int valu + conv(*x, value); + } + +-void ZZ_p_modulus(struct ZZ* mod, const struct ZZ_p* x) ++void ZZ_p_modulus(ZZ* mod, const ZZ_p* x) + { + (*mod) = x->modulus(); + } + +-struct ZZ_p* ZZ_p_pow(const struct ZZ_p* x, long e) ++ZZ_p* ZZ_p_pow(const ZZ_p* x, long e) + { + ZZ_p *z = new ZZ_p(); power(*z, *x, e); +@@ -203,7 +203,7 @@ ZZ_p* ZZ_p_random(void) return z; } --long mat_ZZ_nrows(const struct mat_ZZ* x) -+long mat_ZZ_nrows(const mat_ZZ* x) +-struct ZZ_p* ZZ_p_neg(struct ZZ_p* x) ++ZZ_p* ZZ_p_neg(ZZ_p* x) { - return x->NumRows(); + return new ZZ_p(-(*x)); + } +@@ -214,7 +214,7 @@ struct ZZ_p* ZZ_p_neg(struct ZZ_p* x) + //////// ZZX ////////// + /////////////////////////////////////////////// + +-char* ZZX_repr(struct ZZX* x) ++char* ZZX_repr(ZZX* x) + { + ostringstream instore; + instore << (*x); +@@ -224,13 +224,13 @@ char* ZZX_repr(struct ZZX* x) + return buf; + } + +-struct ZZX* ZZX_copy(struct ZZX* x) { ++ZZX* ZZX_copy(ZZX* x) { + return new ZZX(*x); + } + + /* Sets ith coefficient of x to value. + AUTHOR: David Harvey (2006-06-08) */ +-void ZZX_setitem_from_int(struct ZZX* x, long i, int value) ++void ZZX_setitem_from_int(ZZX* x, long i, int value) + { + SetCoeff(*x, i, value); + } +@@ -238,7 +238,7 @@ void ZZX_setitem_from_int(struct ZZX* x, + /* Returns ith coefficient of x. + Return value is only valid if the result should fit into an int. + AUTHOR: David Harvey (2006-06-08) */ +-int ZZX_getitem_as_int(struct ZZX* x, long i) ++int ZZX_getitem_as_int(ZZX* x, long i) + { + return ZZ_to_int(&coeff(*x, i)); + } +@@ -246,75 +246,75 @@ int ZZX_getitem_as_int(struct ZZX* x, lo + /* Copies ith coefficient of x to output. + Assumes output has been mpz_init'd. + AUTHOR: David Harvey (2007-02) */ +-void ZZX_getitem_as_mpz(mpz_t* output, struct ZZX* x, long i) ++void ZZX_getitem_as_mpz(mpz_t* output, ZZX* x, long i) + { + const ZZ& z = coeff(*x, i); + ZZ_to_mpz(output, &z); + } + +-struct ZZX* ZZX_div(struct ZZX* x, struct ZZX* y, int* divisible) ++ZZX* ZZX_div(ZZX* x, ZZX* y, int* divisible) + { +- struct ZZX* z = new ZZX(); ++ ZZX* z = new ZZX(); + *divisible = divide(*z, *x, *y); + return z; } --long mat_ZZ_ncols(const struct mat_ZZ* x) -+long mat_ZZ_ncols(const mat_ZZ* x) + +-void ZZX_quo_rem(struct ZZX* x, struct ZZX* other, struct ZZX** r, struct ZZX** q) ++void ZZX_quo_rem(ZZX* x, ZZX* other, ZZX** r, ZZX** q) { +- struct ZZX *qq = new ZZX(), *rr = new ZZX(); ++ ZZX *qq = new ZZX(), *rr = new ZZX(); + DivRem(*qq, *rr, *x, *other); + *r = rr; *q = qq; + } + + +-struct ZZX* ZZX_square(struct ZZX* x) ++ZZX* ZZX_square(ZZX* x) + { +- struct ZZX* s = new ZZX(); ++ ZZX* s = new ZZX(); + sqr(*s, *x); + return s; + } + + +-int ZZX_is_monic(struct ZZX* x) ++int ZZX_is_monic(ZZX* x) + { + return IsOne(LeadCoeff(*x)); + } + + +-struct ZZX* ZZX_neg(struct ZZX* x) ++ZZX* ZZX_neg(ZZX* x) + { +- struct ZZX* y = new ZZX(); ++ ZZX* y = new ZZX(); + *y = -*x; + return y; + } + + +-struct ZZX* ZZX_left_shift(struct ZZX* x, long n) ++ZZX* ZZX_left_shift(ZZX* x, long n) + { +- struct ZZX* y = new ZZX(); ++ ZZX* y = new ZZX(); + LeftShift(*y, *x, n); + return y; + } + + +-struct ZZX* ZZX_right_shift(struct ZZX* x, long n) ++ZZX* ZZX_right_shift(ZZX* x, long n) + { +- struct ZZX* y = new ZZX(); ++ ZZX* y = new ZZX(); + RightShift(*y, *x, n); + return y; + } + +-struct ZZX* ZZX_primitive_part(struct ZZX* x) ++ZZX* ZZX_primitive_part(ZZX* x) + { +- struct ZZX* p = new ZZX(); ++ ZZX* p = new ZZX(); + PrimitivePart(*p, *x); + return p; + } + + +-void ZZX_pseudo_quo_rem(struct ZZX* x, struct ZZX* y, struct ZZX** r, struct ZZX** q) ++void ZZX_pseudo_quo_rem(ZZX* x, ZZX* y, ZZX** r, ZZX** q) + { + *r = new ZZX(); + *q = new ZZX(); +@@ -322,16 +322,16 @@ void ZZX_pseudo_quo_rem(struct ZZX* x, s + } + + +-struct ZZX* ZZX_gcd(struct ZZX* x, struct ZZX* y) ++ZZX* ZZX_gcd(ZZX* x, ZZX* y) + { +- struct ZZX* g = new ZZX(); ++ ZZX* g = new ZZX(); + GCD(*g, *x, *y); + return g; + } + + +-void ZZX_xgcd(struct ZZX* x, struct ZZX* y, struct ZZ** r, struct ZZX** s, +- struct ZZX** t, int proof) ++void ZZX_xgcd(ZZX* x, ZZX* y, ZZ** r, ZZX** s, ++ ZZX** t, int proof) + { + *r = new ZZ(); + *s = new ZZX(); +@@ -340,24 +340,24 @@ void ZZX_xgcd(struct ZZX* x, struct ZZX* + } + + +-long ZZX_degree(struct ZZX* x) ++long ZZX_degree(ZZX* x) + { + return deg(*x); + } + +-void ZZX_set_x(struct ZZX* x) ++void ZZX_set_x(ZZX* x) + { + SetX(*x); + } + + +-int ZZX_is_x(struct ZZX* x) ++int ZZX_is_x(ZZX* x) + { + return IsX(*x); + } + + +-struct ZZX* ZZX_derivative(struct ZZX* x) ++ZZX* ZZX_derivative(ZZX* x) + { + ZZX* d = new ZZX(); + diff(*d, *x); +@@ -365,14 +365,14 @@ struct ZZX* ZZX_derivative(struct ZZX* x + } + + +-struct ZZX* ZZX_reverse(struct ZZX* x) ++ZZX* ZZX_reverse(ZZX* x) + { + ZZX* r = new ZZX(); + reverse(*r, *x); + return r; + } + +-struct ZZX* ZZX_reverse_hi(struct ZZX* x, int hi) ++ZZX* ZZX_reverse_hi(ZZX* x, int hi) + { + ZZX* r = new ZZX(); + reverse(*r, *x, hi); +@@ -380,7 +380,7 @@ struct ZZX* ZZX_reverse_hi(struct ZZX* x + } + + +-struct ZZX* ZZX_truncate(struct ZZX* x, long m) ++ZZX* ZZX_truncate(ZZX* x, long m) + { + ZZX* t = new ZZX(); + trunc(*t, *x, m); +@@ -388,7 +388,7 @@ struct ZZX* ZZX_truncate(struct ZZX* x, + } + + +-struct ZZX* ZZX_multiply_and_truncate(struct ZZX* x, struct ZZX* y, long m) ++ZZX* ZZX_multiply_and_truncate(ZZX* x, ZZX* y, long m) + { + ZZX* t = new ZZX(); + MulTrunc(*t, *x, *y, m); +@@ -396,7 +396,7 @@ struct ZZX* ZZX_multiply_and_truncate(st + } + + +-struct ZZX* ZZX_square_and_truncate(struct ZZX* x, long m) ++ZZX* ZZX_square_and_truncate(ZZX* x, long m) + { + ZZX* t = new ZZX(); + SqrTrunc(*t, *x, m); +@@ -404,7 +404,7 @@ struct ZZX* ZZX_square_and_truncate(stru + } + + +-struct ZZX* ZZX_invert_and_truncate(struct ZZX* x, long m) ++ZZX* ZZX_invert_and_truncate(ZZX* x, long m) + { + ZZX* t = new ZZX(); + InvTrunc(*t, *x, m); +@@ -412,7 +412,7 @@ struct ZZX* ZZX_invert_and_truncate(stru + } + + +-struct ZZX* ZZX_multiply_mod(struct ZZX* x, struct ZZX* y, struct ZZX* modulus) ++ZZX* ZZX_multiply_mod(ZZX* x, ZZX* y, ZZX* modulus) + { + ZZX* p = new ZZX(); + MulMod(*p, *x, *y, *modulus); +@@ -420,7 +420,7 @@ struct ZZX* ZZX_multiply_mod(struct ZZX* + } + + +-struct ZZ* ZZX_trace_mod(struct ZZX* x, struct ZZX* y) ++ZZ* ZZX_trace_mod(ZZX* x, ZZX* y) + { + ZZ* p = new ZZ(); + TraceMod(*p, *x, *y); +@@ -428,7 +428,7 @@ struct ZZ* ZZX_trace_mod(struct ZZX* x, + } + + +-char* ZZX_trace_list(struct ZZX* x) ++char* ZZX_trace_list(ZZX* x) + { + vec_ZZ v; + TraceVec(v, *x); +@@ -441,7 +441,7 @@ char* ZZX_trace_list(struct ZZX* x) + } + + +-struct ZZ* ZZX_resultant(struct ZZX* x, struct ZZX* y, int proof) ++ZZ* ZZX_resultant(ZZX* x, ZZX* y, int proof) + { + ZZ* res = new ZZ(); + resultant(*res, *x, *y, proof); +@@ -449,7 +449,7 @@ struct ZZ* ZZX_resultant(struct ZZX* x, + } + + +-struct ZZ* ZZX_norm_mod(struct ZZX* x, struct ZZX* y, int proof) ++ZZ* ZZX_norm_mod(ZZX* x, ZZX* y, int proof) + { + ZZ* res = new ZZ(); + NormMod(*res, *x, *y, proof); +@@ -457,7 +457,7 @@ struct ZZ* ZZX_norm_mod(struct ZZX* x, s + } + + +-struct ZZ* ZZX_discriminant(struct ZZX* x, int proof) ++ZZ* ZZX_discriminant(ZZX* x, int proof) + { + ZZ* d = new ZZ(); + discriminant(*d, *x, proof); +@@ -465,7 +465,7 @@ struct ZZ* ZZX_discriminant(struct ZZX* + } + + +-struct ZZX* ZZX_charpoly_mod(struct ZZX* x, struct ZZX* y, int proof) ++ZZX* ZZX_charpoly_mod(ZZX* x, ZZX* y, int proof) + { + ZZX* f = new ZZX(); + CharPolyMod(*f, *x, *y, proof); +@@ -473,7 +473,7 @@ struct ZZX* ZZX_charpoly_mod(struct ZZX* + } + + +-struct ZZX* ZZX_minpoly_mod(struct ZZX* x, struct ZZX* y) ++ZZX* ZZX_minpoly_mod(ZZX* x, ZZX* y) + { + ZZX* f = new ZZX(); + MinPolyMod(*f, *x, *y); +@@ -481,19 +481,19 @@ struct ZZX* ZZX_minpoly_mod(struct ZZX* + } + + +-void ZZX_clear(struct ZZX* x) ++void ZZX_clear(ZZX* x) + { + clear(*x); + } + + +-void ZZX_preallocate_space(struct ZZX* x, long n) ++void ZZX_preallocate_space(ZZX* x, long n) + { + x->SetMaxLength(n); + } + + /* +-EXTERN struct ZZ* ZZX_polyeval(struct ZZX* f, struct ZZ* a) ++EXTERN ZZ* ZZX_polyeval(ZZX* f, ZZ* a) + { + ZZ* b = new ZZ(); + *b = PolyEval(*f, *a); +@@ -501,7 +501,7 @@ EXTERN struct ZZ* ZZX_polyeval(struct ZZ + } + */ + +-void ZZX_squarefree_decomposition(struct ZZX*** v, long** e, long* n, struct ZZX* x) ++void ZZX_squarefree_decomposition(ZZX*** v, long** e, long* n, ZZX* x) + { + vec_pair_ZZX_long factors; + SquareFreeDecomp(factors, *x); +@@ -518,7 +518,7 @@ void ZZX_squarefree_decomposition(struct + //////// ZZ_pX ////////// + /////////////////////////////////////////////// + +-// char* ZZ_pX_repr(struct ZZ_pX* x) ++// char* ZZ_pX_repr(ZZ_pX* x) + // { + // ostringstream instore; + // instore << (*x); +@@ -528,17 +528,17 @@ void ZZX_squarefree_decomposition(struct + // return buf; + // } + +-// void ZZ_pX_dealloc(struct ZZ_pX* x) { ++// void ZZ_pX_dealloc(ZZ_pX* x) { + // delete x; + // } + +-// struct ZZ_pX* ZZ_pX_copy(struct ZZ_pX* x) { ++// ZZ_pX* ZZ_pX_copy(ZZ_pX* x) { + // return new ZZ_pX(*x); + // } + + // /* Sets ith coefficient of x to value. + // AUTHOR: David Harvey (2008-06-08) */ +-// void ZZ_pX_setitem_from_int(struct ZZ_pX* x, long i, int value) ++// void ZZ_pX_setitem_from_int(ZZ_pX* x, long i, int value) + // { + // SetCoeff(*x, i, value); + // } +@@ -546,26 +546,26 @@ void ZZX_squarefree_decomposition(struct + // /* Returns ith coefficient of x. + // Return value is only valid if the result should fit into an int. + // AUTHOR: David Harvey (2008-06-08) */ +-// int ZZ_pX_getitem_as_int(struct ZZ_pX* x, long i) ++// int ZZ_pX_getitem_as_int(ZZ_pX* x, long i) + // { + // return ZZ_to_int(&rep(coeff(*x, i))); + // } + +-// struct ZZ_pX* ZZ_pX_add(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_add(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_pX *z = new ZZ_pX(); + // add(*z, *x, *y); + // return z; + // } + +-// struct ZZ_pX* ZZ_pX_sub(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_sub(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_pX *z = new ZZ_pX(); + // sub(*z, *x, *y); + // return z; + // } + +-// struct ZZ_pX* ZZ_pX_mul(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_mul(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_pX *z = new ZZ_pX(); + // mul(*z, *x, *y); +@@ -573,24 +573,24 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_div(struct ZZ_pX* x, struct ZZ_pX* y, int* divisible) ++// ZZ_pX* ZZ_pX_div(ZZ_pX* x, ZZ_pX* y, int* divisible) + // { +-// struct ZZ_pX* z = new ZZ_pX(); ++// ZZ_pX* z = new ZZ_pX(); + // *divisible = divide(*z, *x, *y); + // return z; + // } + + +-// struct ZZ_pX* ZZ_pX_mod(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_mod(ZZ_pX* x, ZZ_pX* y) + // { +-// struct ZZ_pX* z = new ZZ_pX(); ++// ZZ_pX* z = new ZZ_pX(); + // rem(*z, *x, *y); + // return z; + // } + + + +-// void ZZ_pX_quo_rem(struct ZZ_pX* x, struct ZZ_pX* y, struct ZZ_pX** r, struct ZZ_pX** q) ++// void ZZ_pX_quo_rem(ZZ_pX* x, ZZ_pX* y, ZZ_pX** r, ZZ_pX** q) + // { + // *r = new ZZ_pX(); + // *q = new ZZ_pX(); +@@ -598,55 +598,55 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_square(struct ZZ_pX* x) ++// ZZ_pX* ZZ_pX_square(ZZ_pX* x) + // { +-// struct ZZ_pX* s = new ZZ_pX(); ++// ZZ_pX* s = new ZZ_pX(); + // sqr(*s, *x); + // return s; + // } + + + +-// int ZZ_pX_is_monic(struct ZZ_pX* x) ++// int ZZ_pX_is_monic(ZZ_pX* x) + // { + // IsOne(LeadCoeff(*x)); + // } + + +-// struct ZZ_pX* ZZ_pX_neg(struct ZZ_pX* x) ++// ZZ_pX* ZZ_pX_neg(ZZ_pX* x) + // { +-// struct ZZ_pX* y = new ZZ_pX(); ++// ZZ_pX* y = new ZZ_pX(); + // *y = -*x; + // return y; + // } + + +-// struct ZZ_pX* ZZ_pX_left_shift(struct ZZ_pX* x, long n) ++// ZZ_pX* ZZ_pX_left_shift(ZZ_pX* x, long n) + // { +-// struct ZZ_pX* y = new ZZ_pX(); ++// ZZ_pX* y = new ZZ_pX(); + // LeftShift(*y, *x, n); + // return y; + // } + + +-// struct ZZ_pX* ZZ_pX_right_shift(struct ZZ_pX* x, long n) ++// ZZ_pX* ZZ_pX_right_shift(ZZ_pX* x, long n) + // { +-// struct ZZ_pX* y = new ZZ_pX(); ++// ZZ_pX* y = new ZZ_pX(); + // RightShift(*y, *x, n); + // return y; + // } + + + +-// struct ZZ_pX* ZZ_pX_gcd(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_gcd(ZZ_pX* x, ZZ_pX* y) + // { +-// struct ZZ_pX* g = new ZZ_pX(); ++// ZZ_pX* g = new ZZ_pX(); + // GCD(*g, *x, *y); + // return g; + // } + + +-// void ZZ_pX_xgcd(struct ZZ_pX** d, struct ZZ_pX** s, struct ZZ_pX** t, struct ZZ_pX* a, struct ZZ_pX* b) ++// void ZZ_pX_xgcd(ZZ_pX** d, ZZ_pX** s, ZZ_pX** t, ZZ_pX* a, ZZ_pX* b) + // { + // *d = new ZZ_pX(); + // *s = new ZZ_pX(); +@@ -654,7 +654,7 @@ void ZZX_squarefree_decomposition(struct + // XGCD(**d, **s, **t, *a, *b); + // } + +-// void ZZ_pX_plain_xgcd(struct ZZ_pX** d, struct ZZ_pX** s, struct ZZ_pX** t, struct ZZ_pX* a, struct ZZ_pX* b) ++// void ZZ_pX_plain_xgcd(ZZ_pX** d, ZZ_pX** s, ZZ_pX** t, ZZ_pX* a, ZZ_pX* b) + // { + // *d = new ZZ_pX(); + // *s = new ZZ_pX(); +@@ -662,25 +662,25 @@ void ZZX_squarefree_decomposition(struct + // PlainXGCD(**d, **s, **t, *a, *b); + // } + +-// ZZ_p* ZZ_pX_leading_coefficient(struct ZZ_pX* x) ++// ZZ_p* ZZ_pX_leading_coefficient(ZZ_pX* x) + // { + // return new ZZ_p(LeadCoeff(*x)); + // } + + +-// void ZZ_pX_set_x(struct ZZ_pX* x) ++// void ZZ_pX_set_x(ZZ_pX* x) + // { + // SetX(*x); + // } + + +-// int ZZ_pX_is_x(struct ZZ_pX* x) ++// int ZZ_pX_is_x(ZZ_pX* x) + // { + // return IsX(*x); + // } + + +-// struct ZZ_pX* ZZ_pX_derivative(struct ZZ_pX* x) ++// ZZ_pX* ZZ_pX_derivative(ZZ_pX* x) + // { + // ZZ_pX* d = new ZZ_pX(); + // diff(*d, *x); +@@ -688,14 +688,14 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_reverse(struct ZZ_pX* x) ++// ZZ_pX* ZZ_pX_reverse(ZZ_pX* x) + // { + // ZZ_pX* r = new ZZ_pX(); + // reverse(*r, *x); + // return r; + // } + +-// struct ZZ_pX* ZZ_pX_reverse_hi(struct ZZ_pX* x, int hi) ++// ZZ_pX* ZZ_pX_reverse_hi(ZZ_pX* x, int hi) + // { + // ZZ_pX* r = new ZZ_pX(); + // reverse(*r, *x, hi); +@@ -703,7 +703,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_truncate(struct ZZ_pX* x, long m) ++// ZZ_pX* ZZ_pX_truncate(ZZ_pX* x, long m) + // { + // ZZ_pX* t = new ZZ_pX(); + // trunc(*t, *x, m); +@@ -711,7 +711,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_multiply_and_truncate(struct ZZ_pX* x, struct ZZ_pX* y, long m) ++// ZZ_pX* ZZ_pX_multiply_and_truncate(ZZ_pX* x, ZZ_pX* y, long m) + // { + // ZZ_pX* t = new ZZ_pX(); + // MulTrunc(*t, *x, *y, m); +@@ -719,7 +719,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_square_and_truncate(struct ZZ_pX* x, long m) ++// ZZ_pX* ZZ_pX_square_and_truncate(ZZ_pX* x, long m) + // { + // ZZ_pX* t = new ZZ_pX(); + // SqrTrunc(*t, *x, m); +@@ -727,7 +727,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_invert_and_truncate(struct ZZ_pX* x, long m) ++// ZZ_pX* ZZ_pX_invert_and_truncate(ZZ_pX* x, long m) + // { + // ZZ_pX* t = new ZZ_pX(); + // InvTrunc(*t, *x, m); +@@ -735,7 +735,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_pX* ZZ_pX_multiply_mod(struct ZZ_pX* x, struct ZZ_pX* y, struct ZZ_pX* modulus) ++// ZZ_pX* ZZ_pX_multiply_mod(ZZ_pX* x, ZZ_pX* y, ZZ_pX* modulus) + // { + // ZZ_pX* p = new ZZ_pX(); + // MulMod(*p, *x, *y, *modulus); +@@ -743,7 +743,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-// struct ZZ_p* ZZ_pX_trace_mod(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_p* ZZ_pX_trace_mod(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_p* p = new ZZ_p(); + // TraceMod(*p, *x, *y); +@@ -751,7 +751,7 @@ void ZZX_squarefree_decomposition(struct + // } + + +-char* ZZ_pX_trace_list(struct ZZ_pX* x) ++char* ZZ_pX_trace_list(ZZ_pX* x) + { + vec_ZZ_p v; + TraceVec(v, *x); +@@ -764,7 +764,7 @@ char* ZZ_pX_trace_list(struct ZZ_pX* x) + } + + +-// struct ZZ_p* ZZ_pX_resultant(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_p* ZZ_pX_resultant(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_p* res = new ZZ_p(); + // resultant(*res, *x, *y); +@@ -772,7 +772,7 @@ char* ZZ_pX_trace_list(struct ZZ_pX* x) + // } + + +-// struct ZZ_p* ZZ_pX_norm_mod(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_p* ZZ_pX_norm_mod(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_p* res = new ZZ_p(); + // NormMod(*res, *x, *y); +@@ -781,7 +781,7 @@ char* ZZ_pX_trace_list(struct ZZ_pX* x) + + + +-// struct ZZ_pX* ZZ_pX_charpoly_mod(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_charpoly_mod(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_pX* f = new ZZ_pX(); + // CharPolyMod(*f, *x, *y); +@@ -789,7 +789,7 @@ char* ZZ_pX_trace_list(struct ZZ_pX* x) + // } + + +-// struct ZZ_pX* ZZ_pX_minpoly_mod(struct ZZ_pX* x, struct ZZ_pX* y) ++// ZZ_pX* ZZ_pX_minpoly_mod(ZZ_pX* x, ZZ_pX* y) + // { + // ZZ_pX* f = new ZZ_pX(); + // MinPolyMod(*f, *x, *y); +@@ -797,18 +797,18 @@ char* ZZ_pX_trace_list(struct ZZ_pX* x) + // } + + +-// void ZZ_pX_clear(struct ZZ_pX* x) ++// void ZZ_pX_clear(ZZ_pX* x) + // { + // clear(*x); + // } + + +-// void ZZ_pX_preallocate_space(struct ZZ_pX* x, long n) ++// void ZZ_pX_preallocate_space(ZZ_pX* x, long n) + // { + // x->SetMaxLength(n); + // } + +-void ZZ_pX_factor(struct ZZ_pX*** v, long** e, long* n, struct ZZ_pX* x, long verbose) ++void ZZ_pX_factor(ZZ_pX*** v, long** e, long* n, ZZ_pX* x, long verbose) + { + long i; + vec_pair_ZZ_pX_long factors; +@@ -822,7 +822,7 @@ void ZZ_pX_factor(struct ZZ_pX*** v, lon + } + } + +-void ZZ_pX_linear_roots(struct ZZ_p*** v, long* n, struct ZZ_pX* f) ++void ZZ_pX_linear_roots(ZZ_p*** v, long* n, ZZ_pX* f) + { + long i; + vec_ZZ_p w; +@@ -836,7 +836,7 @@ void ZZ_pX_linear_roots(struct ZZ_p*** v + + /////////// ZZ_pE ////////////// + +-struct ZZ_pX ZZ_pE_to_ZZ_pX(struct ZZ_pE x) ++ZZ_pX ZZ_pE_to_ZZ_pX(ZZ_pE x) + { + return ZZ_pX(rep(x)); + } +@@ -867,45 +867,45 @@ long mat_ZZ_ncols(const mat_ZZ* x) return x->NumCols(); } --void mat_ZZ_setitem(struct mat_ZZ* x, int i, int j, const struct ZZ* z) +-void mat_ZZ_setitem(mat_ZZ* x, int i, int j, const struct ZZ* z) +void mat_ZZ_setitem(mat_ZZ* x, int i, int j, const ZZ* z) { (*x)[i][j] = *z; } --struct ZZ* mat_ZZ_getitem(const struct mat_ZZ* x, int i, int j) +-struct ZZ* mat_ZZ_getitem(const mat_ZZ* x, int i, int j) +ZZ* mat_ZZ_getitem(const mat_ZZ* x, int i, int j) { return new ZZ((*x)(i,j)); } --struct ZZ* mat_ZZ_determinant(const struct mat_ZZ* x, long deterministic) +-struct ZZ* mat_ZZ_determinant(const mat_ZZ* x, long deterministic) +ZZ* mat_ZZ_determinant(const mat_ZZ* x, long deterministic) { ZZ* d = new ZZ(); @@ -503,23 +1222,22 @@ diff -up src/c_lib/src/ntl_wrap.cpp.orig src/c_lib/src/ntl_wrap.cpp return d; } --struct mat_ZZ* mat_ZZ_HNF(const struct mat_ZZ* A, const struct ZZ* D) +-mat_ZZ* mat_ZZ_HNF(const mat_ZZ* A, const struct ZZ* D) +mat_ZZ* mat_ZZ_HNF(const mat_ZZ* A, const ZZ* D) { -- struct mat_ZZ* W = new mat_ZZ(); -+ mat_ZZ* W = new mat_ZZ(); + mat_ZZ* W = new mat_ZZ(); HNF(*W, *A, *D); return W; } --long mat_ZZ_LLL(struct ZZ **det, struct mat_ZZ *x, long a, long b, long verbose) +-long mat_ZZ_LLL(struct ZZ **det, mat_ZZ *x, long a, long b, long verbose) +long mat_ZZ_LLL(ZZ **det, mat_ZZ *x, long a, long b, long verbose) { *det = new ZZ(); return LLL(**det,*x,a,b,verbose); } --long mat_ZZ_LLL_U(struct ZZ **det, struct mat_ZZ *x, struct mat_ZZ *U, long a, long b, long verbose) +-long mat_ZZ_LLL_U(struct ZZ **det, mat_ZZ *x, mat_ZZ *U, long a, long b, long verbose) +long mat_ZZ_LLL_U(ZZ **det, mat_ZZ *x, mat_ZZ *U, long a, long b, long verbose) { *det = new ZZ(); @@ -527,7 +1245,7 @@ diff -up src/c_lib/src/ntl_wrap.cpp.orig src/c_lib/src/ntl_wrap.cpp } --struct ZZX* mat_ZZ_charpoly(const struct mat_ZZ* A) +-struct ZZX* mat_ZZ_charpoly(const mat_ZZ* A) +ZZX* mat_ZZ_charpoly(const mat_ZZ* A) { ZZX* f = new ZZX(); @@ -536,13 +1254,13 @@ diff -up src/c_lib/src/ntl_wrap.cpp.orig src/c_lib/src/ntl_wrap.cpp } --void mat_GF2E_setitem(struct mat_GF2E* x, int i, int j, const struct GF2E* z) +-void mat_GF2E_setitem(mat_GF2E* x, int i, int j, const struct GF2E* z) +void mat_GF2E_setitem(mat_GF2E* x, int i, int j, const GF2E* z) { (*x)[i][j] = *z; } --void mat_GF2_setitem(struct mat_GF2* x, int i, int j, const struct GF2* z) +-void mat_GF2_setitem(mat_GF2* x, int i, int j, const struct GF2* z) +void mat_GF2_setitem(mat_GF2* x, int i, int j, const GF2* z) { (*x)[i][j] = *z; @@ -601,14 +1319,13 @@ diff -up src/c_lib/src/ntl_wrap.cpp.orig src/c_lib/src/ntl_wrap.cpp { //int j; cpn.restore(); -diff -up src/sage/libs/ntl/decl.pxi.orig src/sage/libs/ntl/decl.pxi ---- src/sage/libs/ntl/decl.pxi.orig 2014-02-07 15:20:57.090216365 -0200 -+++ src/sage/libs/ntl/decl.pxi 2014-02-07 15:21:00.833216508 -0200 +--- src/sage/libs/ntl/decl.pxi.orig 2014-05-13 16:22:05.531912186 -0300 ++++ src/sage/libs/ntl/decl.pxi 2014-05-13 16:29:45.226945150 -0300 @@ -22,7 +22,7 @@ from sage.libs.ntl.ntl_ZZ_pEX_decl cimpo cdef extern from "ntl_wrap.h": #### mat_ZZ_c -- ctypedef struct mat_ZZ_c "struct mat_ZZ": +- cdef cppclass mat_ZZ_c "mat_ZZ": + ctypedef struct mat_ZZ_c "mat_ZZ": pass @@ -680,7 +1397,7 @@ diff -up src/sage/libs/ntl/decl.pxi.orig src/sage/libs/ntl/decl.pxi object vec_GF2E_to_PyString "_to_PyString"(vec_GF2E_c *x) #### mat_GF2E_c -- ctypedef struct mat_GF2E_c "struct mat_GF2E": +- cdef cppclass mat_GF2E_c "mat_GF2E": + ctypedef struct mat_GF2E_c "mat_GF2E": void (*SetDims)(long nrows, long ncols) long (*NumRows)() @@ -698,7 +1415,7 @@ diff -up src/sage/libs/ntl/decl.pxi.orig src/sage/libs/ntl/decl.pxi #### mat_GF2_c -- ctypedef struct mat_GF2_c "struct mat_GF2": +- cdef cppclass mat_GF2_c "mat_GF2": + ctypedef struct mat_GF2_c "mat_GF2": void (*SetDims)(long nrows, long ncols) long (*NumRows)() diff --git a/sagemath-pari.patch b/sagemath-pari.patch index acae29d..ed7c40b 100644 --- a/sagemath-pari.patch +++ b/sagemath-pari.patch @@ -1,6 +1,5 @@ -diff -up src/sage/libs/pari/pari_instance.pxd.orig src/sage/libs/pari/pari_instance.pxd ---- src/sage/libs/pari/pari_instance.pxd.orig 2014-02-07 11:58:23.031750944 -0200 -+++ src/sage/libs/pari/pari_instance.pxd 2014-02-07 11:58:44.805751778 -0200 +--- src/sage/libs/pari/pari_instance.pxd.orig 2014-05-10 15:49:08.954184083 -0300 ++++ src/sage/libs/pari/pari_instance.pxd 2014-05-10 15:49:13.304183771 -0300 @@ -5,6 +5,10 @@ cimport cython from sage.libs.pari.gen cimport gen @@ -12,10 +11,9 @@ diff -up src/sage/libs/pari/pari_instance.pxd.orig src/sage/libs/pari/pari_insta cpdef long prec_bits_to_words(unsigned long prec_in_bits) @cython.final -diff -up src/sage/libs/pari/pari_instance.pyx.orig src/sage/libs/pari/pari_instance.pyx ---- src/sage/libs/pari/pari_instance.pyx.orig 2014-02-07 11:57:54.455749850 -0200 -+++ src/sage/libs/pari/pari_instance.pyx 2014-02-07 11:59:13.119752862 -0200 -@@ -434,7 +434,12 @@ cdef class PariInstance(sage.structure.p +--- src/sage/libs/pari/pari_instance.pyx.orig 2014-05-10 15:49:06.437184263 -0300 ++++ src/sage/libs/pari/pari_instance.pyx 2014-05-10 15:49:13.307183771 -0300 +@@ -437,7 +437,12 @@ cdef class PariInstance(sage.structure.p # The size here doesn't really matter, because we will allocate # our own stack anyway. We ask PARI not to set up signal and # error handlers. diff --git a/sagemath-pari2.7.patch b/sagemath-pari2.7.patch new file mode 100644 index 0000000..4ed8786 --- /dev/null +++ b/sagemath-pari2.7.patch @@ -0,0 +1,8553 @@ +From f26a0a0136b0067e12b05c207e0939ba5654a4ee Mon Sep 17 00:00:00 2001 +From: Jeroen Demeyer +Date: Mon, 05 May 2014 08:27:34 +0000 +Subject: Upgrade to PARI-2.7.1 + +diff --git a/src/doc/de/tutorial/interfaces.rst b/src/doc/de/tutorial/interfaces.rst +index 9ace22d..9f79b8f 100644 +--- a/src/doc/de/tutorial/interfaces.rst ++++ b/src/doc/de/tutorial/interfaces.rst +@@ -135,7 +135,7 @@ Dinge mit ihr berechnen. + sage: e.elltors() + [1, [], []] + sage: e.ellglobalred() +- [10351, [1, -1, 0, -1], 1] ++ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]] + sage: f = e.ellchangecurve([1,-1,0,-1]) + sage: f[:5] + [1, -1, 0, 4, 3] +diff --git a/src/doc/de/tutorial/tour_advanced.rst b/src/doc/de/tutorial/tour_advanced.rst +index b5fff8e..9308ac7 100644 +--- a/src/doc/de/tutorial/tour_advanced.rst ++++ b/src/doc/de/tutorial/tour_advanced.rst +@@ -359,12 +359,12 @@ Nun berechnen wir mehrere Invarianten von ``G``: + + sage: G.gens() + (Dirichlet character modulo 20 of conductor 4 mapping 11 |--> -1, 17 |--> 1, +- Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> -i) ++ Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> i) + + sage: G.unit_gens() + (11, 17) + sage: G.zeta() +- -i ++ i + sage: G.zeta_order() + 4 + +diff --git a/src/doc/en/bordeaux_2008/nf_galois_groups.rst b/src/doc/en/bordeaux_2008/nf_galois_groups.rst +index c67867b..4061d96 100644 +--- a/src/doc/en/bordeaux_2008/nf_galois_groups.rst ++++ b/src/doc/en/bordeaux_2008/nf_galois_groups.rst +@@ -311,7 +311,7 @@ ideal classes containing :math:`(5,\sqrt{-30})` and + sage: category(C) + Category of groups + sage: C.gens() +- (Fractional ideal class (5, a), Fractional ideal class (3, a)) ++ (Fractional ideal class (2, a), Fractional ideal class (3, a)) + + + Arithmetic in the class group +@@ -328,17 +328,17 @@ means "the product of the 0th and 1st generators of the class group + sage: K. = QuadraticField(-30) + sage: C = K.class_group() + sage: C.0 +- Fractional ideal class (5, a) ++ Fractional ideal class (2, a) + sage: C.0.ideal() +- Fractional ideal (5, a) ++ Fractional ideal (2, a) + sage: I = C.0 * C.1 + sage: I +- Fractional ideal class (2, a) ++ Fractional ideal class (5, a) + + + Next we find that the class of the fractional ideal + :math:`(2,\sqrt{-30}+4/3)` is equal to the ideal class +-:math:`I`. ++:math:`C.0`. + + .. link + +@@ -348,7 +348,7 @@ Next we find that the class of the fractional ideal + sage: J = C(A) + sage: J + Fractional ideal class (2/3, 1/3*a) +- sage: J == I ++ sage: J == C.0 + True + + +diff --git a/src/doc/en/tutorial/interfaces.rst b/src/doc/en/tutorial/interfaces.rst +index b1dc175..0d3c598 100644 +--- a/src/doc/en/tutorial/interfaces.rst ++++ b/src/doc/en/tutorial/interfaces.rst +@@ -132,7 +132,7 @@ things about it. + sage: e.elltors() + [1, [], []] + sage: e.ellglobalred() +- [10351, [1, -1, 0, -1], 1] ++ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]] + sage: f = e.ellchangecurve([1,-1,0,-1]) + sage: f[:5] + [1, -1, 0, 4, 3] +diff --git a/src/doc/en/tutorial/tour_advanced.rst b/src/doc/en/tutorial/tour_advanced.rst +index 5069d4b..32717e4 100644 +--- a/src/doc/en/tutorial/tour_advanced.rst ++++ b/src/doc/en/tutorial/tour_advanced.rst +@@ -357,12 +357,12 @@ We next compute several invariants of ``G``: + + sage: G.gens() + (Dirichlet character modulo 20 of conductor 4 mapping 11 |--> -1, 17 |--> 1, +- Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> -i) ++ Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> i) + + sage: G.unit_gens() + (11, 17) + sage: G.zeta() +- -i ++ i + sage: G.zeta_order() + 4 + +diff --git a/src/doc/fr/tutorial/interfaces.rst b/src/doc/fr/tutorial/interfaces.rst +index 147fd49..e420350 100644 +--- a/src/doc/fr/tutorial/interfaces.rst ++++ b/src/doc/fr/tutorial/interfaces.rst +@@ -133,7 +133,7 @@ calculs avec. + sage: e.elltors() + [1, [], []] + sage: e.ellglobalred() +- [10351, [1, -1, 0, -1], 1] ++ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]] + sage: f = e.ellchangecurve([1,-1,0,-1]) + sage: f[:5] + [1, -1, 0, 4, 3] +diff --git a/src/doc/fr/tutorial/tour_advanced.rst b/src/doc/fr/tutorial/tour_advanced.rst +index fbaa3ac..92e300d 100644 +--- a/src/doc/fr/tutorial/tour_advanced.rst ++++ b/src/doc/fr/tutorial/tour_advanced.rst +@@ -357,12 +357,12 @@ Nous calculons ensuite différents invariants de ``G``: + + sage: G.gens() + (Dirichlet character modulo 20 of conductor 4 mapping 11 |--> -1, 17 |--> 1, +- Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> -i) ++ Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> i) + + sage: G.unit_gens() + (11, 17) + sage: G.zeta() +- -i ++ i + sage: G.zeta_order() + 4 + +diff --git a/src/doc/ru/tutorial/interfaces.rst b/src/doc/ru/tutorial/interfaces.rst +index 8baa52c..497707b 100644 +--- a/src/doc/ru/tutorial/interfaces.rst ++++ b/src/doc/ru/tutorial/interfaces.rst +@@ -128,7 +128,7 @@ Sage использует С-библиотеку PARI, чтобы поддер + sage: e.elltors() + [1, [], []] + sage: e.ellglobalred() +- [10351, [1, -1, 0, -1], 1] ++ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]] + sage: f = e.ellchangecurve([1,-1,0,-1]) + sage: f[:5] + [1, -1, 0, 4, 3] +diff --git a/src/doc/ru/tutorial/tour_advanced.rst b/src/doc/ru/tutorial/tour_advanced.rst +index d9ab2c5..b7a64a7 100644 +--- a/src/doc/ru/tutorial/tour_advanced.rst ++++ b/src/doc/ru/tutorial/tour_advanced.rst +@@ -322,12 +322,12 @@ Sage может вычислить тороидальный идеал непл + + sage: G.gens() + (Dirichlet character modulo 20 of conductor 4 mapping 11 |--> -1, 17 |--> 1, +- Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> -i) ++ Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> i) + + sage: G.unit_gens() + (11, 17) + sage: G.zeta() +- -i ++ i + sage: G.zeta_order() + 4 + +diff --git a/src/ext/pari/dokchitser/computel.gp b/src/ext/pari/dokchitser/computel.gp +index f7f5d66..9768874 100644 +--- a/src/ext/pari/dokchitser/computel.gp ++++ b/src/ext/pari/dokchitser/computel.gp +@@ -169,7 +169,7 @@ errprint(x)=if(type(x)=="t_COMPLEX",x=abs(x)); + + { + gammaseries(z0,terms, +- Avec,Bvec,Qvec,n,z,err,res,c0,c1,c2,c3,sinser,reflect,digits,srprec,negint)= ++ Avec,Bvec,Qvec,n,z,err,res,c0,c1,c2,c3,sinser,reflect,digits_,srprec,negint)= + srprec=default(seriesprecision); + if (z0==real(round(z0)),z0=real(round(z0))); \\ you don't want to know + negint=type(z0)=="t_INT" && z0<=0; \\ z0 is a pole +@@ -181,17 +181,17 @@ gammaseries(z0,terms, + if (z0==1, res=gamma(1+x), + if (z0==2, res=gamma(1+x)*(1+x), + \\ otherwise use Luke's rational approximations for psi(x) +- digits=default(realprecision); \\ save working precision +- default(realprecision,digits+3); \\ and work with 3 digits more ++ digits_=default(realprecision); \\ save working precision ++ default(realprecision,digits_+3); \\ and work with 3 digits more + reflect=real(z0)<0.5; \\ left of 1/2 use reflection formula + if (reflect,z0=1-z0); +- z=subst(Ser(precision(1.*z0,digits+3)+X),X,x); ++ z=subst(Ser(precision(1.*z0,digits_+3)+X),X,x); + \\ work with z0+x as a variable gives power series in X as an answer + Avec=[1,(z+6)/2,(z^2+82*z+96)/6,(z^3+387*z^2+2906*z+1920)/12]; + Bvec=[1,4,8*z+28,14*z^2+204*z+310]; + Qvec=[0,0,0,Avec[4]/Bvec[4]]; + n=4; +- until(err<0.1^(digits+1.5), \\ Luke's recursions for psi(x) ++ until(err<0.1^(digits_+1.5), \\ Luke's recursions for psi(x) + c1=(2*n-1)*(3*(n-1)*z+7*n^2-9*n-6); + c2=-(2*n-3)*(z-n-1)*(3*(n-1)*z-7*n^2+19*n-4); + c3=(2*n-1)*(n-3)*(z-n)*(z-n-1)*(z+n-4); +@@ -208,7 +208,7 @@ gammaseries(z0,terms, + if (negint,sinser[1]=0); \\ taking slight care at integers<0 + res=subst(Pi/res/Ser(sinser),x,-x); + ); +- default(realprecision,digits); ++ default(realprecision,digits_); + ))))); + default(seriesprecision,srprec); + res; +@@ -231,10 +231,10 @@ fullgamma(ss) = if(ss!=lastFGs,lastFGs=ss;\ + + { + fullgammaseries(ss,extraterms, +- digits,GSD)= +- digits=default(realprecision); ++ digits_,GSD)= ++ digits_=default(realprecision); + if (lastFGSs!=ss || lastFGSterms!=extraterms, +- GSD=sum(j=1,numpoles,(abs((ss+poles[j])/2-round(real((ss+poles[j])/2)))<10^(2-digits)) * PoleOrders[j] )+extraterms; ++ GSD=sum(j=1,numpoles,(abs((ss+poles[j])/2-round(real((ss+poles[j])/2)))<10^(2-digits_)) * PoleOrders[j] )+extraterms; + lastFGSs=ss; + lastFGSterms=extraterms; + lastFGSval=subst(prod(j=1,length(gammaV),gammaseries((ss+gammaV[j])/2,GSD)),x,S/2); +diff --git a/src/ext/pari/simon/ell.gp b/src/ext/pari/simon/ell.gp +index 0d130f4..acd807c 100644 +--- a/src/ext/pari/simon/ell.gp ++++ b/src/ext/pari/simon/ell.gp +@@ -84,6 +84,11 @@ + + */ + ++ ++nf_scalar_or_multable_to_alg(nf, z) = { ++ if (type(z) == "t_MAT", nfbasistoalg(nf, z[,1]), z); ++} ++ + { + \\ + \\ Usual global variables +@@ -505,7 +510,7 @@ if( DEBUGLEVEL_ell >= 5, print(" end of nfissquaremodp")); + if( DEBUGLEVEL_ell >= 5, print(" end of nfissquaremodp")); + return(0)); + if( valap, +- zlog = ideallog(nf,a*(nfbasistoalg(nf,p[5])/p.p)^valap,zinit) ++ zlog = ideallog(nf,a*(nf_scalar_or_multable_to_alg(nf,p[5])/p.p)^valap,zinit) + , + zlog = ideallog(nf,a,zinit)); + for( i = 1, #zinit[2][2], +@@ -533,7 +538,7 @@ if( DEBUGLEVEL_ell >= 5, print(" end of nfissquaremodpq")); + if( DEBUGLEVEL_ell >= 5, print(" end of nfissquaremodpq")); + return(0)); + zinit = idealstar(nf,idealpow(nf,p,q-vala),2); +- zlog = ideallog(nf,a*nfbasistoalg(nf,p[5]/2)^vala,zinit); ++ zlog = ideallog(nf,a*nf_scalar_or_multable_to_alg(nf,p[5]/2)^vala,zinit); + for( i = 1, #zinit[2][2], + if( !(zinit[2][2][i]%2) && (zlog[i]%2), + if( DEBUGLEVEL_ell >= 5, print(" end of nfissquaremodpq")); +@@ -556,7 +561,7 @@ if( DEBUGLEVEL_ell >= 5, print(" end of nfsqrtmodpq")); + return(0)); + if( f%2, error("nfsqrtmodpq: a is not a square, odd valuation")); + a = nfalgtobasis(nf,a); +- if( f, aaa = nfeltpow(nf,nfeltdiv(nf,a,p[5]/p.p),f), aaa = a); ++ if( f, aaa = nfeltpow(nf,nfeltdiv(nf,a,nf_scalar_or_multable_to_alg(nf,p[5]/p.p)),f), aaa = a); + p_hnf = idealhnf(nf,p); + p_ini = nfmodprinit(nf,p); + if( DEBUGLEVEL_ell >= 5, print(" p_hnf = ",p_hnf)); +@@ -680,7 +685,7 @@ if( DEBUGLEVEL_ell >= 5, print("fin de nflemma7")); + if( q > 2*v, + if( DEBUGLEVEL_ell >= 5, print("fin de nflemma7")); + return(-1)); +- if( nfissquaremodpq(nf,gx*nfbasistoalg(nf,p[5]/2)^lambda,p,q), ++ if( nfissquaremodpq(nf,gx*nf_scalar_or_multable_to_alg(nf,p[5]/2)^lambda,p,q), + if( DEBUGLEVEL_ell >= 5, print("fin de nflemma7")); + return(1)) + , +@@ -694,7 +699,7 @@ if( DEBUGLEVEL_ell >= 5, print("fin de nflemma7")); + if( q > 2*v, + if( DEBUGLEVEL_ell >= 5, print("fin de nflemma7")); + return(-1)); +- if( nfissquaremodpq(nf,gx*nfbasistoalg(nf,p[5]/2)^lambda,p,q), ++ if( nfissquaremodpq(nf,gx*nf_scalar_or_multable_to_alg(nf,p[5]/2)^lambda,p,q), + if( DEBUGLEVEL_ell >= 5, print("fin de nflemma7")); + return(0)) + ); +@@ -772,7 +777,7 @@ if( DEBUGLEVEL_ell >= 4, print(" end of nfqp_solublebig")); + cont = idealval(nf,polcoeff(pol,0),p); + for( i = 1, deg, + if( cont, cont = min(cont,idealval(nf,polcoeff(pol,i),p)))); +- if( cont, pi = nfbasistoalg(nf,p[5]/p.p)); ++ if( cont, pi = nf_scalar_or_multable_to_alg(nf,p[5]/p.p)); + if( cont > 1, pol *= pi^(2*(cont\2))); + + \\ On essaye des valeurs de x au hasard +@@ -984,7 +989,7 @@ if( DEBUGLEVEL_ell >= 2, print(" Algorithm of 2-descent via isogenies")); + if( DEBUGLEVEL_ell >= 3, print(" starting bnfell2descent_viaisog")); + if( variable(bnf.pol) != 'y, + error("bnfell2descent_viaisog: the variable of the number field must be y")); +- ell = ellinit(Mod(lift(ell),bnf.pol),1); ++ ell = ellinit(Mod(lift(ell),bnf.pol)); + + if( ell.disc == 0, + error("bnfell2descent_viaisog: singular curve !!")); +@@ -1231,7 +1236,7 @@ if( DEBUGLEVEL_ell >= 4, print(" bbbnf.clgp = ",bbbnf.clgp)); + SL = idealfactor(bbbnf,SL1)[,1]~; + sunL = bnfsunit(bbbnf,SL); + fondsunL = concat(bbbnf.futu,vector(#sunL[1],i,nfbasistoalg(bbbnf,sunL[1][i]))); +- normfondsunL = norm(rnfeltabstorel( rrrnf,fondsunL)); ++ normfondsunL = vector(#fondsunL, i, norm(rnfeltabstorel(rrrnf,fondsunL[i]))); + SK = idealfactor(bnf,idealnorm(bbbnf,SL1))[,1]~; + sunK = bnfsunit(bnf,SK); + fondsunK = concat(bnf.futu,vector(#sunK[1],i,nfbasistoalg(bnf,sunK[1][i]))); +@@ -1500,7 +1505,7 @@ if( DEBUGLEVEL_ell >= 4, print(" starting bnfell2descent_gen")); + nf = bnf.nf; + unnf = Mod(1,nf.pol); + ellnf = ell*unnf; +- if( #ellnf <= 5, ellnf = ellinit(ellnf,1)); ++ if( #ellnf <= 5, ellnf = ellinit(ellnf)); + + A = ellnf.a2; if( DEBUGLEVEL_ell >= 2, print(" A = ",A)); + B = ellnf.a4; if( DEBUGLEVEL_ell >= 2, print(" B = ",B)); +@@ -1887,7 +1892,8 @@ if( DEBUGLEVEL_ell >= 4, print(" end of bnfell2descent_gen")); + local(urst,urst1,den,factden,eqtheta,rnfeq,bbnf,ext,rang,f); + + if( DEBUGLEVEL_ell >= 3, print(" starting bnfellrank")); +- if( #ell <= 5, ell = ellinit(ell,1)); ++ if( #ell < 5, ell = ellinit(ell)); ++ ell = vector(5, i, ell[i]); + + \\ removes the coefficients a1 and a3 + urst = [1,0,0,0]; +diff --git a/src/ext/pari/simon/ellQ.gp b/src/ext/pari/simon/ellQ.gp +index c114534..6861066 100644 +--- a/src/ext/pari/simon/ellQ.gp ++++ b/src/ext/pari/simon/ellQ.gp +@@ -117,7 +117,7 @@ + Courbes de la forme : k*y^2 = x^3+A*x^2+B*x+C + sans 2-torsion, A,B,C entiers. + gp > bnf = bnfinit(x^3+A*x^2+B*x+C); +- gp > ell = ellinit([0,A,0,B,C],1); ++ gp > ell = ellinit([0,A,0,B,C]); + gp > rank = ell2descent_gen(ell,bnf,k); + + Courbes avec #E[2](Q) >= 2 : +@@ -833,7 +833,7 @@ if( DEBUGLEVEL_ell >= 4, print(" end of LS2localimage")); + \\ returns all the points Q on ell such that 2Q = P. + my(pol2,ratroots,half,x2,y2,P2); + +- if(#ell < 13, ell=ellinit(ell,1)); ++ if(#ell < 13, ell=ellinit(ell)); + + pol2 = Pol([4,ell.b2,2*ell.b4,ell.b6]); \\ 2-division polynomial + +@@ -880,7 +880,7 @@ if( DEBUGLEVEL_ell >= 3, print(" E[2] = ",tors2)); + my(torseven,P2); + + if( DEBUGLEVEL_ell >= 4, print(" computing the 2^n-torsion")); +- if(#ell < 13, ell=ellinit(ell,1)); ++ if(#ell < 13, ell=ellinit(ell)); + torseven = elltors2(ell); + + while( torseven[1] != 1, +@@ -976,7 +976,7 @@ if( DEBUGLEVEL_ell >= 5, print(" ell=",ell)); + d = #listgen; + if( d == 0, return([])); + +- if( #ell < 13, ell = ellinit(ell,1)); ++ if( #ell < 13, ell = ellinit(ell)); + + if( K != 1, + if( ell.a1 != 0 || ell.a3 != 0, error(" ellredgen: a1*a3 != 0")); +@@ -1323,7 +1323,7 @@ my(A,B,C,polrel,polprime,ttheta,badprimes,S,LS2,selmer,rootapprox,p,pp,locimage, + + if( DEBUGLEVEL_ell >= 4, print(" starting ell2descent_gen")); + +- if( #ell < 13, ell = ellinit(ell,1)); ++ if( #ell < 13, ell = ellinit(ell)); + + if( ell.a1 != 0 || ell.a3 != 0, + error(" ell2descent_gen: the curve is not of the form [0,a,0,b,c]")); +@@ -1579,7 +1579,7 @@ if( DEBUGLEVEL_ell >= 4, print(" end of ell2descent_gen")); + my(urst,urst1,den,eqell,tors2,bnf,rang,time1); + + if( DEBUGLEVEL_ell >= 3, print(" starting ellrank")); +- if( #ell < 13, ell = ellinit(ell,1)); ++ if( #ell < 13, ell = ellinit(ell)); + + \\ kill the coefficients a1 and a3 + urst = [1,0,0,0]; +@@ -1915,7 +1915,7 @@ if( DEBUGLEVEL_ell >= 4, print(" end of ellcount")); + my(P,Pfact,tors,listpointstriv,KS2prod,KS2gen,listpoints,pointgen,n1,n2,certain,apinit,bpinit,np1,np2,listpoints2,aux1,aux2,certainp,rang,strange); + + if( DEBUGLEVEL_ell >= 2, print(" Algorithm of 2-descent via isogenies")); +- if( #ell < 13, ell = ellinit(ell,1)); ++ if( #ell < 13, ell = ellinit(ell)); + + if( ell.disc == 0, + error(" ell2descent_viaisog: singular curve !!")); +diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py +index bb6660a..b0f24c0 100644 +--- a/src/sage/calculus/calculus.py ++++ b/src/sage/calculus/calculus.py +@@ -732,13 +732,13 @@ def nintegral(ex, x, a, b, + to high precision:: + + sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))') +- '2.565728500561051482917356396 E-127' # 32-bit +- '2.5657285005610514829173563961304785900 E-127' # 64-bit ++ '2.565728500561051482917356396 E-127' # 32-bit ++ '2.5657285005610514829173563961304785900 E-127' # 64-bit + sage: old_prec = gp.set_real_precision(50) + sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))') + '2.5657285005610514829173563961304785900147709554020 E-127' + sage: gp.set_real_precision(old_prec) +- 50 ++ 57 + + Note that the input function above is a string in PARI syntax. + """ +diff --git a/src/sage/functions/exp_integral.py b/src/sage/functions/exp_integral.py +index 182e80c..69f0e0d 100644 +--- a/src/sage/functions/exp_integral.py ++++ b/src/sage/functions/exp_integral.py +@@ -1493,10 +1493,10 @@ def exponential_integral_1(x, n=0): + + sage: exponential_integral_1(2) + 0.0489005107080611 +- sage: exponential_integral_1(2,4) # abs tol 1e-18 ++ sage: exponential_integral_1(2, 4) # abs tol 1e-18 + [0.0489005107080611, 0.00377935240984891, 0.000360082452162659, 0.0000376656228439245] +- sage: exponential_integral_1(40,5) +- [1.03677326145166e-19, 2.22854325868847e-37, 6.33732515501151e-55, 2.02336191509997e-72, 6.88522610630764e-90] ++ sage: exponential_integral_1(40, 5) ++ [0.000000000000000, 2.22854325868847e-37, 6.33732515501151e-55, 2.02336191509997e-72, 6.88522610630764e-90] + sage: exponential_integral_1(0) + +Infinity + sage: r = exponential_integral_1(RealField(150)(1)) +@@ -1569,7 +1569,7 @@ def exponential_integral_1(x, n=0): + if n <= 0: + # Add extra bits to the input. + # (experimentally verified -- Jeroen Demeyer) +- inprec = prec + math.ceil(math.log(2*prec)) ++ inprec = prec + 5 + math.ceil(math.log(prec)) + x = RealField(inprec)(x)._pari_() + return R(x.eint1()) + else: +diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py +index ff20df8..cde865e 100644 +--- a/src/sage/groups/generic.py ++++ b/src/sage/groups/generic.py +@@ -420,8 +420,7 @@ def bsgs(a, b, bounds, operation='*', identity=None, inverse=None, op=None): + sage: F. = GF(37^5) + sage: E = EllipticCurve(F, [1,1]) + sage: P = E.lift_x(a); P +- (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) # 32-bit +- (a : 9*a^4 + 22*a^3 + 23*a^2 + 30 : 1) # 64-bit ++ (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) + + This will return a multiple of the order of P:: + +@@ -853,8 +852,8 @@ def discrete_log_lambda(a, base, bounds, operation='*', hash_function=hash): + sage: F. = GF(37^5) + sage: E = EllipticCurve(F, [1,1]) + sage: P = E.lift_x(a); P +- (a : 9*a^4 + 22*a^3 + 23*a^2 + 30 : 1) # 32-bit +- (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) # 64-bit ++ (a : 28*a^4 + 15*a^3 + 14*a^2 + 7 : 1) # 32-bit ++ (a : 9*a^4 + 22*a^3 + 23*a^2 + 30 : 1) # 64-bit + + This will return a multiple of the order of P:: + +diff --git a/src/sage/interfaces/gp.py b/src/sage/interfaces/gp.py +index 767c668..6f13f3c 100644 +--- a/src/sage/interfaces/gp.py ++++ b/src/sage/interfaces/gp.py +@@ -24,7 +24,7 @@ PARI interpreter):: + + sage: E = gp.ellinit([1,2,3,4,5]) + sage: E.ellglobalred() +- [10351, [1, -1, 0, -1], 1] ++ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]] + sage: E.ellan(20) + [1, 1, 0, -1, -3, 0, -1, -3, -3, -3, -1, 0, 1, -1, 0, -1, 5, -3, 4, 3] + +@@ -113,7 +113,7 @@ Test error recovery:: + PARI/GP ERROR: + *** at top-level: sage[...]=1/0 + *** ^-- +- *** _/_: division by zero ++ *** _/_: impossible inverse in gdiv: 0. + + AUTHORS: + +@@ -322,9 +322,16 @@ class Gp(Expect): + + get_real_precision = get_precision + +- def set_precision(self, prec=None): ++ def set_precision(self, prec): + """ +- Sets the PARI precision (in decimal digits) for real computations, and returns the old value. ++ Sets the PARI precision (in decimal digits) for real ++ computations, and returns the old value. ++ ++ .. NOTE:: ++ ++ PARI/GP rounds up precisions to the nearest machine word, ++ so the result of :meth:`get_precision` is not always the ++ same as the last value inputted to :meth:`set_precision`. + + EXAMPLES:: + +@@ -332,9 +339,9 @@ class Gp(Expect): + 28 # 32-bit + 38 # 64-bit + sage: gp.get_precision() +- 53 ++ 57 + sage: gp.set_precision(old_prec) +- 53 ++ 57 + sage: gp.get_precision() + 28 # 32-bit + 38 # 64-bit +@@ -436,25 +443,23 @@ class Gp(Expect): + return m - t + return m + +- def set_default(self, var=None, value=None): ++ def set_default(self, var, value): + """ + Set a PARI gp configuration variable, and return the old value. + + INPUT: + +- - ``var`` (string, default None) -- the name of a PARI gp ++ - ``var`` (string) -- the name of a PARI gp + configuration variable. (See ``gp.default()`` for a list.) + - ``value`` -- the value to set the variable to. + + EXAMPLES:: + +- sage: old_prec = gp.set_default('realprecision',100); old_prec +- 28 # 32-bit +- 38 # 64-bit ++ sage: old_prec = gp.set_default('realprecision', 110) + sage: gp.get_default('realprecision') +- 100 +- sage: gp.set_default('realprecision',old_prec) +- 100 ++ 115 ++ sage: gp.set_default('realprecision', old_prec) ++ 115 + sage: gp.get_default('realprecision') + 28 # 32-bit + 38 # 64-bit +@@ -463,13 +468,13 @@ class Gp(Expect): + self._eval_line('default(%s,%s)'%(var,value)) + return old + +- def get_default(self, var=None): ++ def get_default(self, var): + """ + Return the current value of a PARI gp configuration variable. + + INPUT: + +- - ``var`` (string, default None) -- the name of a PARI gp ++ - ``var`` (string) -- the name of a PARI gp + configuration variable. (See ``gp.default()`` for a list.) + + OUTPUT: +@@ -808,13 +813,16 @@ class GpElement(ExpectElement): + + sage: E = gp('ellinit([1,2,3,4,5])') + sage: loads(dumps(E)) == E ++ True ++ sage: x = gp.Pi()/3 ++ sage: loads(dumps(x)) == x + False +- sage: loads(E.dumps()) +- [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.618909932267371342378000940, -0.3155450338663143288109995302 - 2.092547096911958607981689447*I, -0.3155450338663143288109995302 + 2.092547096911958607981689447*I]~, 2.780740013766729771063197627, 1.390370006883364885531598814 - 1.068749776356193066159263548*I, 3.109648242324380328550149122 + 1.009741959000000000000000000 E-28*I, 1.554824121162190164275074561 + 1.064374745210273756943885994*I, 2.971915267817909670771647951] # 32-bit +- [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.6189099322673713423780009396072169751, -0.31554503386631432881099953019639151248 - 2.0925470969119586079816894466366945829*I, -0.31554503386631432881099953019639151248 + 2.0925470969119586079816894466366945829*I]~, 2.7807400137667297710631976271813584994, 1.3903700068833648855315988135906792497 - 1.0687497763561930661592635474375038788*I, 3.1096482423243803285501491221965830079 + 2.3509887016445750160000000000000000000 E-38*I, 1.5548241211621901642750745610982915040 + 1.0643747452102737569438859937299427442*I, 2.9719152678179096707716479509361896060] # 64-bit +- sage: E +- [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.618909932267371342378000940, -0.3155450338663143288109995302 - 2.092547096911958607981689447*I, -0.3155450338663143288109995302 + 2.092547096911958607981689447*I]~, 2.780740013766729771063197627, 1.390370006883364885531598814 - 1.068749776356193066159263548*I, 3.109648242324380328550149122 + 1.009741959 E-28*I, 1.554824121162190164275074561 + 1.064374745210273756943885994*I, 2.971915267817909670771647951] # 32-bit +- [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351, [-1.6189099322673713423780009396072169751, -0.31554503386631432881099953019639151248 - 2.0925470969119586079816894466366945829*I, -0.31554503386631432881099953019639151248 + 2.0925470969119586079816894466366945829*I]~, 2.7807400137667297710631976271813584994, 1.3903700068833648855315988135906792497 - 1.0687497763561930661592635474375038788*I, 3.1096482423243803285501491221965830079 + 2.350988701644575016 E-38*I, 1.5548241211621901642750745610982915040 + 1.0643747452102737569438859937299427442*I, 2.9719152678179096707716479509361896060] # 64-bit ++ sage: x ++ 1.047197551196597746154214461 # 32-bit ++ 1.0471975511965977461542144610931676281 # 64-bit ++ sage: loads(dumps(x)) ++ 1.047197551196597746154214461 # 32-bit ++ 1.0471975511965977461542144610931676281 # 64-bit + + The two elliptic curves look the same, but internally the floating + point numbers are slightly different. +diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py +index da6ae49..12e991f 100644 +--- a/src/sage/lfunctions/dokchitser.py ++++ b/src/sage/lfunctions/dokchitser.py +@@ -108,7 +108,7 @@ class Dokchitser(SageObject): + sage: L.taylor_series(1,4) + 0.000000000000000 + 0.305999773834052*z + 0.186547797268162*z^2 - 0.136791463097188*z^3 + O(z^4) + sage: L.check_functional_equation() +- 6.11218974800000e-18 # 32-bit ++ 6.11218974700000e-18 # 32-bit + 6.04442711160669e-18 # 64-bit + + RANK 2 ELLIPTIC CURVE: +@@ -125,8 +125,8 @@ class Dokchitser(SageObject): + sage: L.derivative(1,E.rank()) + 1.51863300057685 + sage: L.taylor_series(1,4) +- 2.90759778535572e-20 + (-1.64772676916085e-20)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4) # 32-bit +- -3.11623283109075e-21 + (1.76595961125962e-21)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4) # 64-bit ++ 2.90760251490292e-20 + (-1.64772944938078e-20)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4) # 32-bit ++ -3.11661104824958e-21 + (1.76617394576638e-21)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4) # 64-bit + + RAMANUJAN DELTA L-FUNCTION: + +@@ -218,7 +218,9 @@ class Dokchitser(SageObject): + except AttributeError: + logfile = None + # For debugging +- #logfile = os.path.join(DOT_SAGE, 'dokchitser.log') ++ import os ++ from sage.env import DOT_SAGE ++ logfile = os.path.join(DOT_SAGE, 'dokchitser.log') + g = sage.interfaces.gp.Gp(script_subdirectory='dokchitser', logfile=logfile) + g.read('computel.gp') + self.__gp = g +@@ -484,7 +486,7 @@ class Dokchitser(SageObject): + sage: E = EllipticCurve('389a') + sage: L = E.lseries().dokchitser(200) + sage: L.taylor_series(1,3) +- 6.2240188634103774348273446965620801288836328651973234573133e-73 + (-3.527132447498646306292650465494647003849868770...e-73)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3) ++ -9.094...e-82 + (5.1538...e-82)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3) + """ + self.__check_init() + a = self.__CC(a) +diff --git a/src/sage/libs/pari/decl.pxi b/src/sage/libs/pari/decl.pxi +index 41a8e1a..baa03d5 100644 +--- a/src/sage/libs/pari/decl.pxi ++++ b/src/sage/libs/pari/decl.pxi +@@ -16,16 +16,14 @@ AUTHORS: + + - Jeroen Demeyer (2010-08-15): big clean up (#9898) + ++ - Jeroen Demeyer (2014-02-09): upgrade to PARI 2.7 (#15767) ++ + """ + + include 'sage/ext/cdefs.pxi' + +-cdef extern from 'setjmp.h': +- struct __jmp_buf_tag: +- pass +- ctypedef __jmp_buf_tag jmp_buf +- int setjmp (jmp_buf __env) +- int longjmp (jmp_buf __env, int val) ++cdef extern from '': ++ ctypedef void* va_list + + ctypedef unsigned long ulong + +@@ -35,6 +33,46 @@ cdef extern from 'pari/paricfg.h': + + cdef extern from 'pari/pari.h': + ctypedef long* GEN ++ ctypedef char* byteptr ++ ++ # Various structures that we don't use in Sage but which need to be ++ # declared, otherwise Cython complains. ++ struct bb_group: ++ pass ++ struct bb_field: ++ pass ++ struct bb_algebra: ++ pass ++ struct qfr_data: ++ pass ++ struct nfmaxord_t: ++ pass ++ struct forcomposite_t: ++ pass ++ struct forpart_t: ++ pass ++ struct forprime_t: ++ pass ++ struct forvec_t: ++ pass ++ struct entree: ++ pass ++ struct gp_context: ++ pass ++ struct pariFILE: ++ pass ++ struct pari_mt: ++ pass ++ struct pari_thread: ++ pass ++ struct pari_timer: ++ pass ++ struct GENbin: ++ pass ++ struct hashentry: ++ pass ++ struct hashtable: ++ pass + + # PARI types: these are actually an enum type, but that doesn't + # matter for Cython. +@@ -49,13 +87,19 @@ cdef extern from 'pari/pari.h': + + # parierr.h + +- int syntaxer, bugparier, alarmer, openfiler, talker, flagerr, \ +- impl, archer, notfuncer, precer, typeer, consister, user, \ +- errpile, overflower, matinv1, mattype1, arither1, primer1, \ +- invmoder, constpoler, notpoler, redpoler, zeropoler, operi, \ +- operf, gdiver, memer, negexper, sqrter5, noer ++ int e_SYNTAX, e_BUG, \ ++ e_ALARM, e_FILE, \ ++ e_MISC, e_FLAG, e_IMPL, e_ARCH, e_PACKAGE, e_NOTFUNC, \ ++ e_PREC, e_TYPE, e_DIM, e_VAR, e_PRIORITY, e_USER, \ ++ e_STACK, e_OVERFLOW, e_DOMAIN, e_COMPONENT, \ ++ e_MAXPRIME, \ ++ e_CONSTPOL, e_IRREDPOL, e_COPRIME, e_PRIME, e_MODULUS, e_ROOTS0, \ ++ e_OP, e_TYPE2, e_INV, \ ++ e_MEM, \ ++ e_SQRTN, \ ++ e_NONE + +- int warner, warnprec, warnfile, warnmem ++ int warner, warnprec, warnfile, warnmem, warnuser + + # parigen.h + +@@ -93,20 +137,20 @@ cdef extern from 'pari/pari.h': + + # paricast.h + +- long mael2(GEN,long,long) +- long mael3(GEN,long,long,long) +- long mael4(GEN,long,long,long,long) +- long mael5(GEN,long,long,long,long,long) +- long mael(GEN,long,long) +- GEN gmael1(GEN,long) +- GEN gmael2(GEN,long,long) +- GEN gmael3(GEN,long,long,long) +- GEN gmael4(GEN,long,long,long,long) +- GEN gmael5(GEN,long,long,long,long,long) +- GEN gmael(GEN,long,long) +- GEN gel(GEN,long) +- GEN gcoeff(GEN,long,long) +- long coeff(GEN,long,long) ++ long mael2(GEN, long, long) ++ long mael3(GEN, long, long, long) ++ long mael4(GEN, long, long, long, long) ++ long mael5(GEN, long, long, long, long, long) ++ long mael(GEN, long, long) ++ GEN gmael1(GEN, long) ++ GEN gmael2(GEN, long, long) ++ GEN gmael3(GEN, long, long, long) ++ GEN gmael4(GEN, long, long, long, long) ++ GEN gmael5(GEN, long, long, long, long, long) ++ GEN gmael(GEN, long, long) ++ GEN gel(GEN, long) ++ GEN gcoeff(GEN, long, long) ++ long coeff(GEN, long, long) + + # paricom.h + +@@ -131,11 +175,14 @@ cdef extern from 'pari/pari.h': + ulong Fl_add(ulong a, ulong b, ulong p) + long Fl_center(ulong u, ulong p, ulong ps2) + ulong Fl_div(ulong a, ulong b, ulong p) ++ ulong Fl_double(ulong a, ulong p) + ulong Fl_mul(ulong a, ulong b, ulong p) + ulong Fl_neg(ulong x, ulong p) + ulong Fl_sqr(ulong a, ulong p) + ulong Fl_sub(ulong a, ulong b, ulong p) ++ ulong Fl_triple(ulong a, ulong p) + GEN absi(GEN x) ++ GEN absi_shallow(GEN x) + GEN absr(GEN x) + int absrnz_equal1(GEN x) + int absrnz_equal2n(GEN x) +@@ -165,11 +212,13 @@ cdef extern from 'pari/pari.h': + void affui(ulong s, GEN x) + void affur(ulong s, GEN x) + GEN cgetg(long x, long y) ++ GEN cgetg_block(long x, long y) + GEN cgetg_copy(GEN x, long *plx) + GEN cgeti(long x) + GEN cgetineg(long x) + GEN cgetipos(long x) + GEN cgetr(long x) ++ GEN cgetr_block(long prec) + int cmpir(GEN x, GEN y) + int cmpis(GEN x, long y) + int cmpiu(GEN x, ulong y) +@@ -215,19 +264,23 @@ cdef extern from 'pari/pari.h': + int equalui(ulong x, GEN y) + long evalexpo(long x) + long evallg(long x) ++ long evalprecp(long x) + long evalvalp(long x) + long expi(GEN x) + long expu(ulong x) + void fixlg(GEN z, long ly) + GEN fractor(GEN x, long prec) + GEN icopy(GEN x) ++ GEN icopyspec(GEN x, long nx) + GEN icopy_avma(GEN x, pari_sp av) ++ ulong int_bit(GEN x, long n) + GEN itor(GEN x, long prec) + long itos(GEN x) + long itos_or_0(GEN x) + ulong itou(GEN x) + ulong itou_or_0(GEN x) + GEN leafcopy(GEN x) ++ GEN leafcopy_avma(GEN x, pari_sp av) + double maxdd(double x, double y) + long maxss(long x, long y) + long maxuu(ulong x, ulong y) +@@ -248,6 +301,7 @@ cdef extern from 'pari/pari.h': + GEN modss(long x, long y) + void modssz(long s, long y, GEN z) + GEN mpabs(GEN x) ++ GEN mpabs_shallow(GEN x) + GEN mpadd(GEN x, GEN y) + void mpaddz(GEN x, GEN y, GEN z) + void mpaff(GEN x, GEN y) +@@ -262,7 +316,7 @@ cdef extern from 'pari/pari.h': + GEN mpneg(GEN x) + int mpodd(GEN x) + GEN mpround(GEN x) +- GEN mpshift(GEN x,long s) ++ GEN mpshift(GEN x, long s) + GEN mpsqr(GEN x) + GEN mpsub(GEN x, GEN y) + void mpsubz(GEN x, GEN y, GEN z) +@@ -289,6 +343,7 @@ cdef extern from 'pari/pari.h': + GEN rdivsi(long x, GEN y, long prec) + GEN rdivss(long x, long y, long prec) + GEN real2n(long n, long prec) ++ GEN real_m2n(long n, long prec) + GEN real_0(long prec) + GEN real_0_bit(long bitprec) + GEN real_1(long prec) +@@ -305,15 +360,20 @@ cdef extern from 'pari/pari.h': + long sdivsi(long x, GEN y) + long sdivsi_rem(long x, GEN y, long *rem) + long sdivss_rem(long x, long y, long *rem) ++ ulong udiviu_rem(GEN n, ulong d, ulong *r) ++ ulong udivuu_rem(ulong x, ulong y, ulong *r) + void setabssign(GEN x) + void shift_left(GEN z2, GEN z1, long min, long M, ulong f, ulong sh) + void shift_right(GEN z2, GEN z1, long min, long M, ulong f, ulong sh) + ulong shiftl(ulong x, ulong y) + ulong shiftlr(ulong x, ulong y) + GEN shiftr(GEN x, long n) ++ void shiftr_inplace(GEN z, long d) + long smodis(GEN x, long y) + long smodss(long x, long y) + void stackdummy(pari_sp av, pari_sp ltop) ++ char *stack_malloc(size_t N) ++ char *stack_calloc(size_t N) + GEN stoi(long x) + GEN stor(long x, long prec) + GEN subii(GEN x, GEN y) +@@ -338,7 +398,7 @@ cdef extern from 'pari/pari.h': + void togglesign_safe(GEN *px) + void affectsign(GEN x, GEN y) + void affectsign_safe(GEN x, GEN *py) +- GEN truedivii(GEN a,GEN b) ++ GEN truedivii(GEN a, GEN b) + GEN truedivis(GEN a, long b) + GEN truedivsi(long a, GEN b) + ulong udivui_rem(ulong x, GEN y, ulong *rem) +@@ -351,28 +411,51 @@ cdef extern from 'pari/pari.h': + GEN uutoineg(ulong x, ulong y) + long vali(GEN x) + ++ # OBSOLETE ++ ++ GEN bernvec(long nomb) ++ + # F2x.c + ++ GEN F2c_to_Flc(GEN x) + GEN F2c_to_ZC(GEN x) ++ GEN F2c_to_mod(GEN x) ++ GEN F2m_rowslice(GEN x, long a, long b) ++ GEN F2m_to_Flm(GEN z) + GEN F2m_to_ZM(GEN z) ++ GEN F2m_to_mod(GEN z) + void F2v_add_inplace(GEN x, GEN y) ++ ulong F2v_dotproduct(GEN x, GEN y) ++ GEN F2v_slice(GEN x, long a, long b) ++ GEN F2x_F2xq_eval(GEN Q, GEN x, GEN T) ++ GEN F2x_F2xqV_eval(GEN P, GEN V, GEN T) + GEN F2x_1_add(GEN y) + GEN F2x_add(GEN x, GEN y) ++ GEN F2x_deflate(GEN x0, long d) + long F2x_degree(GEN x) + GEN F2x_deriv(GEN x) + GEN F2x_divrem(GEN x, GEN y, GEN *pr) ++ void F2x_even_odd(GEN p, GEN *pe, GEN *po) + GEN F2x_extgcd(GEN a, GEN b, GEN *ptu, GEN *ptv) + GEN F2x_gcd(GEN a, GEN b) ++ GEN F2x_halfgcd(GEN a, GEN b) ++ int F2x_issquare(GEN a) + GEN F2x_mul(GEN x, GEN y) + GEN F2x_rem(GEN x, GEN y) ++ GEN F2x_shift(GEN y, long d) + GEN F2x_sqr(GEN x) ++ GEN F2x_sqrt(GEN x) + GEN F2x_to_F2v(GEN x, long n) + GEN F2x_to_Flx(GEN x) + GEN F2x_to_ZX(GEN x) ++ long F2x_valrem(GEN x, GEN *Z) + GEN F2xC_to_ZXC(GEN x) + GEN F2xV_to_F2m(GEN v, long n) ++ GEN F2xq_Artin_Schreier(GEN a, GEN T) ++ GEN FlxqXQV_autsum(GEN aut, long n, GEN S, GEN T, ulong p) ++ GEN F2xq_autpow(GEN x, long n, GEN T) + GEN F2xq_conjvec(GEN x, GEN T) +- GEN F2xq_div(GEN x,GEN y,GEN T) ++ GEN F2xq_div(GEN x, GEN y, GEN T) + GEN F2xq_inv(GEN x, GEN T) + GEN F2xq_invsafe(GEN x, GEN T) + GEN F2xq_log(GEN a, GEN g, GEN ord, GEN T) +@@ -380,46 +463,86 @@ cdef extern from 'pari/pari.h': + GEN F2xq_mul(GEN x, GEN y, GEN pol) + GEN F2xq_order(GEN a, GEN ord, GEN T) + GEN F2xq_pow(GEN x, GEN n, GEN pol) ++ GEN F2xq_powu(GEN x, ulong n, GEN pol) + GEN F2xq_powers(GEN x, long l, GEN T) +- GEN F2xq_sqr(GEN x,GEN pol) ++ GEN F2xq_sqr(GEN x, GEN pol) + GEN F2xq_sqrt(GEN a, GEN T) ++ GEN F2xq_sqrt_fast(GEN c, GEN sqx, GEN T) + GEN F2xq_sqrtn(GEN a, GEN n, GEN T, GEN *zeta) + ulong F2xq_trace(GEN x, GEN T) + GEN Flm_to_F2m(GEN x) + GEN Flv_to_F2v(GEN x) + GEN Flx_to_F2x(GEN x) +- GEN Z_to_F2x(GEN x, long sv) ++ GEN Rg_to_F2xq(GEN x, GEN T) ++ GEN RgM_to_F2m(GEN x) ++ GEN RgV_to_F2v(GEN x) ++ GEN RgX_to_F2x(GEN x) ++ GEN Z_to_F2x(GEN x, long v) + GEN ZM_to_F2m(GEN x) + GEN ZV_to_F2v(GEN x) + GEN ZX_to_F2x(GEN x) ++ GEN ZXT_to_FlxT(GEN z, ulong p) + GEN ZXX_to_F2xX(GEN B, long v) + GEN gener_F2xq(GEN T, GEN *po) ++ bb_field *get_F2xq_field(void **E, GEN T) + GEN random_F2x(long d, long vs) + ++ # F2xqE.c ++ ++ GEN F2xq_ellcard(GEN a2, GEN a6, GEN T) ++ GEN F2xq_ellgens(GEN a2, GEN a6, GEN ch, GEN D, GEN m, GEN T) ++ GEN F2xq_ellgroup(GEN a2, GEN a6, GEN N, GEN T, GEN *pt_m) ++ GEN F2xqE_add(GEN P, GEN Q, GEN a2, GEN T) ++ GEN F2xqE_changepoint(GEN x, GEN ch, GEN T) ++ GEN F2xqE_changepointinv(GEN x, GEN ch, GEN T) ++ GEN F2xqE_dbl(GEN P, GEN a2, GEN T) ++ GEN F2xqE_log(GEN a, GEN b, GEN o, GEN a2, GEN T) ++ GEN F2xqE_mul(GEN P, GEN n, GEN a2, GEN T) ++ GEN F2xqE_neg(GEN P, GEN a2, GEN T) ++ GEN F2xqE_order(GEN z, GEN o, GEN a2, GEN T) ++ GEN F2xqE_sub(GEN P, GEN Q, GEN a2, GEN T) ++ GEN F2xqE_tatepairing(GEN t, GEN s, GEN m, GEN a2, GEN T) ++ GEN F2xqE_weilpairing(GEN t, GEN s, GEN m, GEN a2, GEN T) ++ bb_group * get_F2xqE_group(void **E, GEN a2, GEN a6, GEN T) ++ GEN RgE_to_F2xqE(GEN x, GEN T) ++ GEN random_F2xqE(GEN a2, GEN a6, GEN T) ++ + # Flx.c + + GEN Fl_to_Flx(ulong x, long sv) ++ GEN Flc_to_ZC(GEN z) + GEN Flm_to_FlxV(GEN x, long sv) +- GEN Flm_to_FlxX(GEN x, long v,long w) ++ GEN Flm_to_FlxX(GEN x, long v, long w) + GEN Flm_to_ZM(GEN z) + GEN Flv_to_Flx(GEN x, long vs) + GEN Flv_to_ZV(GEN z) + GEN Flv_polint(GEN xa, GEN ya, ulong p, long vs) + GEN Flv_roots_to_pol(GEN a, ulong p, long vs) ++ GEN Fly_to_FlxY(GEN B, long v) ++ GEN Flx_Fl_add(GEN y, ulong x, ulong p) + GEN Flx_Fl_mul(GEN y, ulong x, ulong p) +- GEN Flx_to_Flv(GEN x, long N) +- GEN Flx_to_ZX(GEN z) +- GEN Flx_to_ZX_inplace(GEN z) ++ GEN Flx_Fl_mul_to_monic(GEN y, ulong x, ulong p) ++ GEN Flx_Flxq_eval(GEN f, GEN x, GEN T, ulong p) ++ GEN Flx_FlxqV_eval(GEN f, GEN x, GEN T, ulong p) + GEN Flx_add(GEN x, GEN y, ulong p) ++ GEN Flx_deflate(GEN x0, long d) + GEN Flx_deriv(GEN z, ulong p) ++ GEN Flx_double(GEN y, ulong p) + GEN Flx_div_by_X_x(GEN a, ulong x, ulong p, ulong *rem) + GEN Flx_divrem(GEN x, GEN y, ulong p, GEN *pr) ++ int Flx_equal(GEN V, GEN W) + ulong Flx_eval(GEN x, ulong y, ulong p) + GEN Flx_extgcd(GEN a, GEN b, ulong p, GEN *ptu, GEN *ptv) + ulong Flx_extresultant(GEN a, GEN b, ulong p, GEN *ptU, GEN *ptV) + GEN Flx_gcd(GEN a, GEN b, ulong p) +- GEN Flx_gcd_i(GEN a, GEN b, ulong p) ++ GEN Flx_get_red(GEN T, ulong p) ++ GEN Flx_halfgcd(GEN a, GEN b, ulong p) ++ GEN Flx_inflate(GEN x0, long d) ++ GEN Flx_invBarrett(GEN T, ulong p) + int Flx_is_squarefree(GEN z, ulong p) ++ int Flx_is_smooth(GEN g, long r, ulong p) ++ GEN Flx_mod_Xn1(GEN T, ulong n, ulong p) ++ GEN Flx_mod_Xnm1(GEN T, ulong n, ulong p) + GEN Flx_mul(GEN x, GEN y, ulong p) + GEN Flx_neg(GEN x, ulong p) + GEN Flx_neg_inplace(GEN x, ulong p) +@@ -431,380 +554,1409 @@ cdef extern from 'pari/pari.h': + GEN Flx_renormalize(GEN x, long l) + ulong Flx_resultant(GEN a, GEN b, ulong p) + GEN Flx_shift(GEN a, long n) ++ GEN Flx_splitting(GEN p, long k) + GEN Flx_sqr(GEN x, ulong p) + GEN Flx_sub(GEN x, GEN y, ulong p) ++ GEN Flx_to_Flv(GEN x, long N) ++ GEN Flx_to_FlxX(GEN z, long v) ++ GEN Flx_to_ZX(GEN z) ++ GEN Flx_to_ZX_inplace(GEN z) ++ GEN Flx_triple(GEN y, ulong p) ++ long Flx_val(GEN x) ++ long Flx_valrem(GEN x, GEN *Z) ++ GEN FlxC_to_ZXC(GEN x) ++ GEN FlxM_Flx_add_shallow(GEN x, GEN y, ulong p) + GEN FlxM_to_ZXM(GEN z) ++ GEN FlxT_red(GEN z, ulong p) ++ GEN FlxV_to_ZXV(GEN x) ++ GEN FlxV_Flc_mul(GEN V, GEN W, ulong p) ++ GEN FlxV_red(GEN z, ulong p) + GEN FlxV_to_Flm(GEN v, long n) ++ GEN FlxX_Fl_mul(GEN x, ulong y, ulong p) ++ GEN FlxX_Flx_add(GEN y, GEN x, ulong p) ++ GEN FlxX_Flx_mul(GEN x, GEN y, ulong p) + GEN FlxX_add(GEN P, GEN Q, ulong p) ++ GEN FlxX_double(GEN x, ulong p) ++ GEN FlxX_neg(GEN x, ulong p) ++ GEN FlxX_sub(GEN P, GEN Q, ulong p) ++ GEN FlxX_swap(GEN x, long n, long ws) ++ GEN FlxX_renormalize(GEN x, long lx) + GEN FlxX_shift(GEN a, long n) + GEN FlxX_to_Flm(GEN v, long n) + GEN FlxX_to_ZXX(GEN B) +- GEN FlxYqQ_pow(GEN x, GEN n, GEN S, GEN T, ulong p) +- GEN Flxq_inv(GEN x,GEN T,ulong p) ++ GEN FlxX_triple(GEN x, ulong p) ++ GEN FlxY_Flxq_evalx(GEN P, GEN x, GEN T, ulong p) ++ GEN FlxY_Flx_div(GEN x, GEN y, ulong p) ++ GEN FlxY_evalx(GEN Q, ulong x, ulong p) ++ GEN FlxYqq_pow(GEN x, GEN n, GEN S, GEN T, ulong p) ++ GEN Flxq_autpow(GEN x, ulong n, GEN T, ulong p) ++ GEN Flxq_autsum(GEN x, ulong n, GEN T, ulong p) ++ GEN Flxq_charpoly(GEN x, GEN T, ulong p) ++ GEN Flxq_conjvec(GEN x, GEN T, ulong p) ++ GEN Flxq_div(GEN x, GEN y, GEN T, ulong p) ++ GEN Flxq_inv(GEN x, GEN T, ulong p) + GEN Flxq_invsafe(GEN x, GEN T, ulong p) +- GEN Flxq_mul(GEN y,GEN x,GEN T,ulong p) ++ int Flxq_issquare(GEN x, GEN T, ulong p) ++ int Flxq_is2npower(GEN x, long n, GEN T, ulong p) ++ GEN Flxq_log(GEN a, GEN g, GEN ord, GEN T, ulong p) ++ GEN Flxq_lroot(GEN a, GEN T, long p) ++ GEN Flxq_lroot_fast(GEN a, GEN sqx, GEN T, long p) ++ GEN Flxq_matrix_pow(GEN y, long n, long m, GEN P, ulong l) ++ GEN Flxq_minpoly(GEN x, GEN T, ulong p) ++ GEN Flxq_mul(GEN x, GEN y, GEN T, ulong p) ++ ulong Flxq_norm(GEN x, GEN T, ulong p) ++ GEN Flxq_order(GEN a, GEN ord, GEN T, ulong p) + GEN Flxq_pow(GEN x, GEN n, GEN T, ulong p) ++ GEN Flxq_powu(GEN x, ulong n, GEN T, ulong p) + GEN Flxq_powers(GEN x, long l, GEN T, ulong p) +- GEN Flxq_sqr(GEN y,GEN T,ulong p) +- GEN FlxqX_normalize(GEN z, GEN T, ulong p) ++ GEN Flxq_sqr(GEN y, GEN T, ulong p) ++ GEN Flxq_sqrt(GEN a, GEN T, ulong p) ++ GEN Flxq_sqrtn(GEN a, GEN n, GEN T, ulong p, GEN *zetan) ++ ulong Flxq_trace(GEN x, GEN T, ulong p) ++ GEN FlxqV_dotproduct(GEN x, GEN y, GEN T, ulong p) ++ GEN FlxqV_roots_to_pol(GEN V, GEN T, ulong p, long v) ++ GEN FlxqX_FlxqXQ_eval(GEN Q, GEN x, GEN S, GEN T, ulong p) ++ GEN FlxqX_FlxqXQV_eval(GEN P, GEN V, GEN S, GEN T, ulong p) + GEN FlxqX_Flxq_mul(GEN P, GEN U, GEN T, ulong p) +- GEN FlxqX_red(GEN z, GEN T, ulong p) ++ GEN FlxqX_Flxq_mul_to_monic(GEN P, GEN U, GEN T, ulong p) ++ GEN FlxqX_divrem(GEN x, GEN y, GEN T, ulong p, GEN *pr) ++ GEN FlxqX_extgcd(GEN a, GEN b, GEN T, ulong p, GEN *ptu, GEN *ptv) ++ GEN FlxqX_gcd(GEN P, GEN Q, GEN T, ulong p) ++ GEN FlxqX_invBarrett(GEN T, GEN Q, ulong p) + GEN FlxqX_mul(GEN x, GEN y, GEN T, ulong p) ++ GEN FlxqX_normalize(GEN z, GEN T, ulong p) ++ GEN FlxqX_pow(GEN V, long n, GEN T, ulong p) ++ GEN FlxqX_red(GEN z, GEN T, ulong p) ++ GEN FlxqX_rem_Barrett(GEN x, GEN mg, GEN T, GEN Q, ulong p) + GEN FlxqX_safegcd(GEN P, GEN Q, GEN T, ulong p) + GEN FlxqX_sqr(GEN x, GEN T, ulong p) +- GEN FlxqX_divrem(GEN x, GEN y, GEN T, ulong p, GEN *pr) ++ GEN FlxqXQ_div(GEN x, GEN y, GEN S, GEN T, ulong p) ++ GEN FlxqXQ_inv(GEN x, GEN S, GEN T, ulong p) ++ GEN FlxqXQ_invsafe(GEN x, GEN S, GEN T, ulong p) ++ GEN FlxqXQ_matrix_pow(GEN x, long n, long m, GEN S, GEN T, ulong p) ++ GEN FlxqXQ_mul(GEN x, GEN y, GEN S, GEN T, ulong p) + GEN FlxqXQ_pow(GEN x, GEN n, GEN S, GEN T, ulong p) ++ GEN FlxqXQ_powers(GEN x, long n, GEN S, GEN T, ulong p) ++ GEN FlxqXQ_sqr(GEN x, GEN S, GEN T, ulong p) ++ GEN FlxqXQV_autpow(GEN x, long n, GEN S, GEN T, ulong p) ++ GEN FlxqXV_prod(GEN V, GEN T, ulong p) ++ GEN Kronecker_to_FlxqX(GEN z, GEN T, ulong p) ++ ulong Rg_to_F2(GEN x) ++ ulong Rg_to_Fl(GEN x, ulong p) ++ GEN Rg_to_Flxq(GEN x, GEN T, ulong p) ++ GEN RgX_to_Flx(GEN x, ulong p) + GEN Z_to_Flx(GEN x, ulong p, long v) +- GEN ZM_to_Flm(GEN x, ulong p) +- GEN ZV_to_Flv(GEN x, ulong p) + GEN ZX_to_Flx(GEN x, ulong p) + GEN ZXV_to_FlxV(GEN v, ulong p) + GEN ZXX_to_FlxX(GEN B, ulong p, long v) +- GEN polx_Flx(long sv) +- GEN zero_Flx(long sv) ++ GEN ZXXV_to_FlxXV(GEN V, ulong p, long v) ++ GEN gener_Flxq(GEN T, ulong p, GEN *o) ++ long get_Flx_degree(GEN T) ++ GEN get_Flx_mod(GEN T) ++ long get_Flx_var(GEN T) ++ bb_field *get_Flxq_field(void **E, GEN T, ulong p) ++ GEN pol1_FlxX(long v, long sv) ++ GEN random_Flx(long d1, long v, ulong p) ++ GEN zxX_to_Kronecker(GEN P, GEN Q) ++ ++ # FlxqE.c ++ ++ GEN Flxq_ellcard(GEN a4, GEN a6, GEN T, ulong p) ++ GEN Flxq_ellgens(GEN a4, GEN a6, GEN ch, GEN D, GEN m, GEN T, ulong p) ++ GEN Flxq_ellgroup(GEN a4, GEN a6, GEN N, GEN T, ulong p, GEN *pt_m) ++ GEN Flxq_ellj(GEN a4, GEN a6, GEN T, ulong p) ++ GEN FlxqE_add(GEN P, GEN Q, GEN a4, GEN T, ulong p) ++ GEN FlxqE_changepoint(GEN x, GEN ch, GEN T, ulong p) ++ GEN FlxqE_changepointinv(GEN x, GEN ch, GEN T, ulong p) ++ GEN FlxqE_dbl(GEN P, GEN a4, GEN T, ulong p) ++ GEN FlxqE_log(GEN a, GEN b, GEN o, GEN a4, GEN T, ulong p) ++ GEN FlxqE_mul(GEN P, GEN n, GEN a4, GEN T, ulong p) ++ GEN FlxqE_neg(GEN P, GEN T, ulong p) ++ GEN FlxqE_order(GEN z, GEN o, GEN a4, GEN T, ulong p) ++ GEN FlxqE_sub(GEN P, GEN Q, GEN a4, GEN T, ulong p) ++ GEN FlxqE_tatepairing(GEN t, GEN s, GEN m, GEN a4, GEN T, ulong p) ++ GEN FlxqE_weilpairing(GEN t, GEN s, GEN m, GEN a4, GEN T, ulong p) ++ bb_group * get_FlxqE_group(void **E, GEN a4, GEN a6, GEN T, ulong p) ++ GEN RgE_to_FlxqE(GEN x, GEN T, ulong p) ++ GEN random_FlxqE(GEN a4, GEN a6, GEN T, ulong p) ++ ++ # FpE.c ++ ++ long Fl_elltrace(ulong a4, ulong a6, ulong p) ++ GEN Fle_add(GEN P, GEN Q, ulong a4, ulong p) ++ GEN Fle_dbl(GEN P, ulong a4, ulong p) ++ GEN Fle_mul(GEN P, GEN n, ulong a4, ulong p) ++ GEN Fle_mulu(GEN P, ulong n, ulong a4, ulong p) ++ GEN Fle_order(GEN z, GEN o, ulong a4, ulong p) ++ GEN Fle_sub(GEN P, GEN Q, ulong a4, ulong p) ++ GEN Fp_ellcard(GEN a4, GEN a6, GEN p) ++ GEN Fp_elldivpol(GEN a4, GEN a6, long n, GEN p) ++ GEN Fp_ellgens(GEN a4, GEN a6, GEN ch, GEN D, GEN m, GEN p) ++ GEN Fp_ellgroup(GEN a4, GEN a6, GEN N, GEN p, GEN *pt_m) ++ GEN Fp_ellj(GEN a4, GEN a6, GEN p) ++ GEN Fp_ffellcard(GEN a4, GEN a6, GEN q, long n, GEN p) ++ GEN FpE_add(GEN P, GEN Q, GEN a4, GEN p) ++ GEN FpE_changepoint(GEN x, GEN ch, GEN p) ++ GEN FpE_changepointinv(GEN x, GEN ch, GEN p) ++ GEN FpE_dbl(GEN P, GEN a4, GEN p) ++ GEN FpE_log(GEN a, GEN b, GEN o, GEN a4, GEN p) ++ GEN FpE_mul(GEN P, GEN n, GEN a4, GEN p) ++ GEN FpE_neg(GEN P, GEN p) ++ GEN FpE_order(GEN z, GEN o, GEN a4, GEN p) ++ GEN FpE_sub(GEN P, GEN Q, GEN a4, GEN p) ++ GEN FpE_to_mod(GEN P, GEN p) ++ GEN FpE_tatepairing(GEN t, GEN s, GEN m, GEN a4, GEN p) ++ GEN FpE_weilpairing(GEN t, GEN s, GEN m, GEN a4, GEN p) ++ GEN FpXQ_ellcard(GEN a4, GEN a6, GEN T, GEN p) ++ GEN FpXQ_elldivpol(GEN a4, GEN a6, long n, GEN T, GEN p) ++ GEN FpXQ_ellgens(GEN a4, GEN a6, GEN ch, GEN D, GEN m, GEN T, GEN p) ++ GEN FpXQ_ellgroup(GEN a4, GEN a6, GEN N, GEN T, GEN p, GEN *pt_m) ++ GEN FpXQ_ellj(GEN a4, GEN a6, GEN T, GEN p) ++ GEN FpXQE_add(GEN P, GEN Q, GEN a4, GEN T, GEN p) ++ GEN FpXQE_changepoint(GEN x, GEN ch, GEN T, GEN p) ++ GEN FpXQE_changepointinv(GEN x, GEN ch, GEN T, GEN p) ++ GEN FpXQE_dbl(GEN P, GEN a4, GEN T, GEN p) ++ GEN FpXQE_log(GEN a, GEN b, GEN o, GEN a4, GEN T, GEN p) ++ GEN FpXQE_mul(GEN P, GEN n, GEN a4, GEN T, GEN p) ++ GEN FpXQE_neg(GEN P, GEN T, GEN p) ++ GEN FpXQE_order(GEN z, GEN o, GEN a4, GEN T, GEN p) ++ GEN FpXQE_sub(GEN P, GEN Q, GEN a4, GEN T, GEN p) ++ GEN FpXQE_tatepairing(GEN t, GEN s, GEN m, GEN a4, GEN T, GEN p) ++ GEN FpXQE_weilpairing(GEN t, GEN s, GEN m, GEN a4, GEN T, GEN p) ++ GEN Fq_elldivpolmod(GEN a4, GEN a6, long n, GEN h, GEN T, GEN p) ++ GEN RgE_to_FpE(GEN x, GEN p) ++ GEN RgE_to_FpXQE(GEN x, GEN T, GEN p) ++ bb_group * get_FpE_group(void **E, GEN a4, GEN a6, GEN p) ++ bb_group * get_FpXQE_group(void **E, GEN a4, GEN a6, GEN T, GEN p) ++ GEN elltrace_extension(GEN t, long n, GEN p) ++ GEN random_Fle(ulong a4, ulong a6, ulong p) ++ GEN random_FpE(GEN a4, GEN a6, GEN p) ++ GEN random_FpXQE(GEN a4, GEN a6, GEN T, GEN p) ++ ++ # FpX.c ++ ++ int Fp_issquare(GEN x, GEN p) ++ GEN Fp_FpX_sub(GEN x, GEN y, GEN p) ++ GEN Fp_FpXQ_log(GEN a, GEN g, GEN ord, GEN T, GEN p) ++ GEN FpV_inv(GEN x, GEN p) ++ GEN FpV_roots_to_pol(GEN V, GEN p, long v) ++ GEN FpX_Fp_add(GEN x, GEN y, GEN p) ++ GEN FpX_Fp_add_shallow(GEN y, GEN x, GEN p) ++ GEN FpX_Fp_mul(GEN x, GEN y, GEN p) ++ GEN FpX_Fp_mul_to_monic(GEN y, GEN x, GEN p) ++ GEN FpX_Fp_mulspec(GEN y, GEN x, GEN p, long ly) ++ GEN FpX_Fp_sub(GEN x, GEN y, GEN p) ++ GEN FpX_Fp_sub_shallow(GEN y, GEN x, GEN p) ++ GEN FpX_FpXQ_eval(GEN f, GEN x, GEN T, GEN p) ++ GEN FpX_FpXQV_eval(GEN f, GEN x, GEN T, GEN p) ++ GEN FpX_add(GEN x, GEN y, GEN p) ++ GEN FpX_center(GEN x, GEN p, GEN pov2) ++ GEN FpX_chinese_coprime(GEN x, GEN y, GEN Tx, GEN Ty, GEN Tz, GEN p) ++ GEN FpX_deriv(GEN x, GEN p) ++ GEN FpX_disc(GEN x, GEN p) ++ GEN FpX_div_by_X_x(GEN a, GEN x, GEN p, GEN *r) ++ GEN FpX_divrem(GEN x, GEN y, GEN p, GEN *pr) ++ GEN FpX_eval(GEN x, GEN y, GEN p) ++ GEN FpX_extgcd(GEN x, GEN y, GEN p, GEN *ptu, GEN *ptv) ++ GEN FpX_gcd(GEN x, GEN y, GEN p) ++ GEN FpX_get_red(GEN T, GEN p) ++ GEN FpX_halfgcd(GEN x, GEN y, GEN p) ++ GEN FpX_invBarrett(GEN T, GEN p) ++ int FpX_is_squarefree(GEN f, GEN p) ++ GEN FpX_mul(GEN x, GEN y, GEN p) ++ GEN FpX_mulspec(GEN a, GEN b, GEN p, long na, long nb) ++ GEN FpX_mulu(GEN x, ulong y, GEN p) ++ GEN FpX_neg(GEN x, GEN p) ++ GEN FpX_normalize(GEN z, GEN p) ++ GEN FpX_red(GEN z, GEN p) ++ GEN FpX_rem(GEN x, GEN y, GEN p) ++ GEN FpX_rescale(GEN P, GEN h, GEN p) ++ GEN FpX_resultant(GEN a, GEN b, GEN p) ++ GEN FpX_sqr(GEN x, GEN p) ++ GEN FpX_sub(GEN x, GEN y, GEN p) ++ long FpX_valrem(GEN x0, GEN t, GEN p, GEN *py) ++ GEN FpXQ_autpow(GEN x, ulong n, GEN T, GEN p) ++ GEN FpXQ_autpowers(GEN aut, long f, GEN T, GEN p) ++ GEN FpXQ_autsum(GEN x, ulong n, GEN T, GEN p) ++ GEN FpXQ_charpoly(GEN x, GEN T, GEN p) ++ GEN FpXQ_conjvec(GEN x, GEN T, GEN p) ++ GEN FpXQ_div(GEN x, GEN y, GEN T, GEN p) ++ GEN FpXQ_inv(GEN x, GEN T, GEN p) ++ GEN FpXQ_invsafe(GEN x, GEN T, GEN p) ++ int FpXQ_issquare(GEN x, GEN T, GEN p) ++ GEN FpXQ_log(GEN a, GEN g, GEN ord, GEN T, GEN p) ++ GEN FpXQ_matrix_pow(GEN y, long n, long m, GEN P, GEN l) ++ GEN FpXQ_minpoly(GEN x, GEN T, GEN p) ++ GEN FpXQ_mul(GEN y, GEN x, GEN T, GEN p) ++ GEN FpXQ_norm(GEN x, GEN T, GEN p) ++ GEN FpXQ_order(GEN a, GEN ord, GEN T, GEN p) ++ GEN FpXQ_pow(GEN x, GEN n, GEN T, GEN p) ++ GEN FpXQ_powu(GEN x, ulong n, GEN T, GEN p) ++ GEN FpXQ_powers(GEN x, long l, GEN T, GEN p) ++ GEN FpXQ_red(GEN x, GEN T, GEN p) ++ GEN FpXQ_sqr(GEN y, GEN T, GEN p) ++ GEN FpXQ_sqrt(GEN a, GEN T, GEN p) ++ GEN FpXQ_sqrtn(GEN a, GEN n, GEN T, GEN p, GEN *zetan) ++ GEN FpXQ_trace(GEN x, GEN T, GEN p) ++ GEN FpXQC_to_mod(GEN z, GEN T, GEN p) ++ GEN FpXT_red(GEN z, GEN p) ++ GEN FpXV_prod(GEN V, GEN p) ++ GEN FpXV_red(GEN z, GEN p) ++ int Fq_issquare(GEN x, GEN T, GEN p) ++ GEN FqV_inv(GEN x, GEN T, GEN p) ++ GEN Z_to_FpX(GEN a, GEN p, long v) ++ GEN gener_FpXQ(GEN T, GEN p, GEN *o) ++ GEN gener_FpXQ_local(GEN T, GEN p, GEN L) ++ long get_FpX_degree(GEN T) ++ GEN get_FpX_mod(GEN T) ++ long get_FpX_var(GEN T) ++ bb_group *get_FpXQ_star(void **E, GEN T, GEN p) ++ GEN random_FpX(long d, long v, GEN p) + +- # alglin1.c ++ # FpX_factor.c + ++ GEN F2x_factor(GEN f) ++ int F2x_is_irred(GEN f) ++ void F2xV_to_FlxV_inplace(GEN v) ++ void F2xV_to_ZXV_inplace(GEN v) ++ int Flx_is_irred(GEN f, ulong p) ++ GEN Flx_degfact(GEN f, ulong p) ++ GEN Flx_factor(GEN f, ulong p) ++ long Flx_nbfact(GEN z, ulong p) ++ GEN Flx_nbfact_by_degree(GEN z, long *nb, ulong p) ++ long Flx_nbroots(GEN f, ulong p) ++ ulong Flx_oneroot(GEN f, ulong p) ++ GEN Flx_roots(GEN f, ulong p) ++ GEN FlxqX_Frobenius(GEN S, GEN T, ulong p) ++ GEN FlxqXQ_halfFrobenius(GEN a, GEN S, GEN T, ulong p) ++ long FlxqX_nbroots(GEN f, GEN T, ulong p) ++ void FlxV_to_ZXV_inplace(GEN v) ++ GEN FpX_degfact(GEN f, GEN p) ++ int FpX_is_irred(GEN f, GEN p) ++ int FpX_is_totally_split(GEN f, GEN p) ++ GEN FpX_factor(GEN f, GEN p) ++ GEN FpX_factorff(GEN P, GEN T, GEN p) ++ long FpX_nbfact(GEN f, GEN p) ++ long FpX_nbroots(GEN f, GEN p) ++ GEN FpX_oneroot(GEN f, GEN p) ++ GEN FpX_roots(GEN f, GEN p) ++ GEN FpX_rootsff(GEN P, GEN T, GEN p) ++ GEN FpXQX_Frobenius(GEN S, GEN T, GEN p) ++ long FpXQX_nbfact(GEN u, GEN T, GEN p) ++ long FpXQX_nbroots(GEN f, GEN T, GEN p) ++ GEN FpXQXQ_halfFrobenius(GEN a, GEN S, GEN T, GEN p) ++ GEN FqX_deriv(GEN f, GEN T, GEN p) ++ GEN FqX_factor(GEN x, GEN T, GEN p) ++ long FqX_is_squarefree(GEN P, GEN T, GEN p) ++ long FqX_nbfact(GEN u, GEN T, GEN p) ++ long FqX_nbroots(GEN f, GEN T, GEN p) ++ GEN FqX_roots(GEN f, GEN T, GEN p) ++ GEN factcantor(GEN x, GEN p) ++ GEN factorff(GEN f, GEN p, GEN a) ++ GEN factormod0(GEN f, GEN p, long flag) ++ GEN polrootsff(GEN f, GEN p, GEN T) ++ GEN rootmod0(GEN f, GEN p, long flag) ++ ++ # FpXX.c ++ ++ GEN FpXQX_FpXQ_mul(GEN P, GEN U, GEN T, GEN p) ++ GEN FpXQX_FpXQXQV_eval(GEN P, GEN V, GEN S, GEN T, GEN p) ++ GEN FpXQX_FpXQXQ_eval(GEN P, GEN x, GEN S, GEN T, GEN p) ++ GEN FpXQX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *pr) ++ GEN FpXQX_divrem_Barrett(GEN x, GEN B, GEN S, GEN T, GEN p, GEN *pr) ++ GEN FpXQX_extgcd(GEN x, GEN y, GEN T, GEN p, GEN *ptu, GEN *ptv) ++ GEN FpXQX_gcd(GEN P, GEN Q, GEN T, GEN p) ++ GEN FpXQX_invBarrett(GEN S, GEN T, GEN p) ++ GEN FpXQX_mul(GEN x, GEN y, GEN T, GEN p) ++ GEN FpXQX_red(GEN z, GEN T, GEN p) ++ GEN FpXQX_rem(GEN x, GEN S, GEN T, GEN p) ++ GEN FpXQX_rem_Barrett(GEN x, GEN mg, GEN S, GEN T, GEN p) ++ GEN FpXQX_sqr(GEN x, GEN T, GEN p) ++ GEN FpXQXQ_div(GEN x, GEN y, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_inv(GEN x, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_invsafe(GEN x, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_matrix_pow(GEN y, long n, long m, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_mul(GEN x, GEN y, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_powers(GEN x, long n, GEN S, GEN T, GEN p) ++ GEN FpXQXQ_sqr(GEN x, GEN S, GEN T, GEN p) ++ GEN FpXQXQV_autpow(GEN aut, long n, GEN S, GEN T, GEN p) ++ GEN FpXQXQV_autsum(GEN aut, long n, GEN S, GEN T, GEN p) ++ GEN FpXQXV_prod(GEN V, GEN Tp, GEN p) ++ GEN FpXX_Fp_mul(GEN x, GEN y, GEN p) ++ GEN FpXX_FpX_mul(GEN x, GEN y, GEN p) ++ GEN FpXX_add(GEN x, GEN y, GEN p) ++ GEN FpXX_mulu(GEN P, ulong u, GEN p) ++ GEN FpXX_neg(GEN x, GEN p) ++ GEN FpXX_red(GEN z, GEN p) ++ GEN FpXX_sub(GEN x, GEN y, GEN p) ++ GEN FpXY_FpXQ_evalx(GEN P, GEN x, GEN T, GEN p) ++ GEN FpXY_eval(GEN Q, GEN y, GEN x, GEN p) ++ GEN FpXY_evalx(GEN Q, GEN x, GEN p) ++ GEN FpXY_evaly(GEN Q, GEN y, GEN p, long vy) ++ GEN FpXYQQ_pow(GEN x, GEN n, GEN S, GEN T, GEN p) ++ GEN Kronecker_to_FpXQX(GEN z, GEN pol, GEN p) ++ GEN Kronecker_to_ZXX(GEN z, long N, long v) ++ GEN ZXX_mul_Kronecker(GEN x, GEN y, long n) ++ ++ # FpV.c ++ ++ GEN F2m_F2c_mul(GEN x, GEN y) ++ GEN F2m_mul(GEN x, GEN y) ++ GEN F2m_powu(GEN x, ulong n) ++ GEN Flc_Fl_div(GEN x, ulong y, ulong p) ++ void Flc_Fl_div_inplace(GEN x, ulong y, ulong p) ++ GEN Flc_Fl_mul(GEN x, ulong y, ulong p) ++ void Flc_Fl_mul_inplace(GEN x, ulong y, ulong p) ++ void Flc_Fl_mul_part_inplace(GEN x, ulong y, ulong p, long l) ++ GEN Flc_to_mod(GEN z, ulong pp) ++ GEN Flm_Fl_add(GEN x, ulong y, ulong p) ++ GEN Flm_Fl_mul(GEN y, ulong x, ulong p) ++ void Flm_Fl_mul_inplace(GEN y, ulong x, ulong p) ++ GEN Flm_Flc_mul(GEN x, GEN y, ulong p) ++ GEN Flm_center(GEN z, ulong p, ulong ps2) ++ GEN Flm_mul(GEN x, GEN y, ulong p) ++ GEN Flm_neg(GEN y, ulong p) ++ GEN Flm_powu(GEN x, ulong n, ulong p) ++ GEN Flm_to_mod(GEN z, ulong pp) ++ GEN Flm_transpose(GEN x) ++ GEN Flv_add(GEN x, GEN y, ulong p) ++ void Flv_add_inplace(GEN x, GEN y, ulong p) ++ ulong Flv_dotproduct(GEN x, GEN y, ulong p) ++ GEN Flv_center(GEN z, ulong p, ulong ps2) ++ GEN Flv_sub(GEN x, GEN y, ulong p) ++ void Flv_sub_inplace(GEN x, GEN y, ulong p) ++ ulong Flv_sum(GEN x, ulong p) ++ GEN Fp_to_mod(GEN z, GEN p) ++ GEN FpC_FpV_mul(GEN x, GEN y, GEN p) ++ GEN FpC_Fp_mul(GEN x, GEN y, GEN p) ++ GEN FpC_center(GEN z, GEN p, GEN pov2) ++ GEN FpC_red(GEN z, GEN p) ++ GEN FpC_to_mod(GEN z, GEN p) ++ GEN FpM_FpC_mul(GEN x, GEN y, GEN p) ++ GEN FpM_FpC_mul_FpX(GEN x, GEN y, GEN p, long v) ++ GEN FpM_center(GEN z, GEN p, GEN pov2) ++ GEN FpM_mul(GEN x, GEN y, GEN p) ++ GEN FpM_powu(GEN x, ulong n, GEN p) ++ GEN FpM_red(GEN z, GEN p) ++ GEN FpM_to_mod(GEN z, GEN p) ++ GEN FpMs_FpC_mul(GEN M, GEN B, GEN p) ++ GEN FpMs_FpCs_solve(GEN M, GEN B, long nbrow, GEN p) ++ GEN FpMs_FpCs_solve_safe(GEN M, GEN A, long nbrow, GEN p) ++ GEN FpMs_leftkernel_elt(GEN M, long nbrow, GEN p) ++ GEN FpC_add(GEN x, GEN y, GEN p) ++ GEN FpC_sub(GEN x, GEN y, GEN p) ++ GEN FpV_FpMs_mul(GEN B, GEN M, GEN p) ++ GEN FpV_add(GEN x, GEN y, GEN p) ++ GEN FpV_sub(GEN x, GEN y, GEN p) ++ GEN FpV_dotproduct(GEN x, GEN y, GEN p) ++ GEN FpV_dotsquare(GEN x, GEN p) ++ GEN FpV_red(GEN z, GEN p) ++ GEN FpV_to_mod(GEN z, GEN p) ++ GEN FpVV_to_mod(GEN z, GEN p) ++ GEN FpX_to_mod(GEN z, GEN p) ++ GEN ZV_zMs_mul(GEN B, GEN M) ++ GEN ZpMs_ZpCs_solve(GEN M, GEN B, long nbrow, GEN p, long e) ++ GEN gen_FpM_Wiedemann(void *E, GEN (*f)(void*, GEN), GEN B, GEN p) ++ GEN gen_ZpM_Dixon(void *E, GEN (*f)(void*, GEN), GEN B, GEN p, long e) ++ GEN gen_matid(long n, void *E, bb_field *S) ++ GEN matid_F2m(long n) ++ GEN matid_Flm(long n) ++ GEN matid_F2xqM(long n, GEN T) ++ GEN matid_FlxqM(long n, GEN T, ulong p) ++ GEN scalar_Flm(long s, long n) ++ GEN zCs_to_ZC(GEN C, long nbrow) ++ GEN zMs_to_ZM(GEN M, long nbrow) ++ GEN zMs_ZC_mul(GEN M, GEN B) ++ ++ # Hensel.c ++ ++ GEN Zp_sqrtlift(GEN b, GEN a, GEN p, long e) ++ GEN Zp_sqrtnlift(GEN b, GEN n, GEN a, GEN p, long e) ++ GEN ZpX_liftfact(GEN pol, GEN Q, GEN T, GEN p, long e, GEN pe) ++ GEN ZpX_liftroot(GEN f, GEN a, GEN p, long e) ++ GEN ZpX_liftroots(GEN f, GEN S, GEN q, long e) ++ GEN ZpXQ_inv(GEN a, GEN T, GEN p, long e) ++ GEN ZpXQ_invlift(GEN b, GEN a, GEN T, GEN p, long e) ++ GEN ZpXQ_log(GEN a, GEN T, GEN p, long N) ++ GEN ZpXQ_sqrtnlift(GEN b, GEN n, GEN a, GEN T, GEN p, long e) ++ GEN ZpXQX_liftroot(GEN f, GEN a, GEN T, GEN p, long e) ++ GEN ZpXQX_liftroot_vald(GEN f, GEN a, long v, GEN T, GEN p, long e) ++ GEN gen_ZpX_Dixon(GEN F, GEN V, GEN q, GEN p, long N, void *E, ++ GEN lin(void *E, GEN F, GEN d, GEN q), ++ GEN invl(void *E, GEN d)) ++ GEN gen_ZpX_Newton(GEN x, GEN p, long n, void *E, ++ GEN eval(void *E, GEN f, GEN q), ++ GEN invd(void *E, GEN V, GEN v, GEN q, long M)) ++ GEN polhensellift(GEN pol, GEN fct, GEN p, long exp) ++ ulong quadratic_prec_mask(long n) ++ ++ # QX_factor.c ++ ++ GEN QX_factor(GEN x) ++ GEN ZX_factor(GEN x) ++ long ZX_is_irred(GEN x) ++ GEN ZX_squff(GEN f, GEN *ex) ++ GEN polcyclofactors(GEN f) ++ long poliscyclo(GEN f) ++ long poliscycloprod(GEN f) ++ ++ # RgV.c ++ ++ GEN RgC_Rg_add(GEN x, GEN y) ++ GEN RgC_Rg_div(GEN x, GEN y) ++ GEN RgC_Rg_mul(GEN x, GEN y) ++ GEN RgC_RgM_mul(GEN x, GEN y) ++ GEN RgC_RgV_mul(GEN x, GEN y) ++ GEN RgC_add(GEN x, GEN y) ++ GEN RgC_neg(GEN x) ++ GEN RgC_sub(GEN x, GEN y) ++ GEN RgM_Rg_add(GEN x, GEN y) ++ GEN RgM_Rg_add_shallow(GEN x, GEN y) ++ GEN RgM_Rg_div(GEN x, GEN y) ++ GEN RgM_Rg_mul(GEN x, GEN y) ++ GEN RgM_Rg_sub(GEN x, GEN y) ++ GEN RgM_Rg_sub_shallow(GEN x, GEN y) ++ GEN RgM_RgC_mul(GEN x, GEN y) ++ GEN RgM_RgV_mul(GEN x, GEN y) ++ GEN RgM_add(GEN x, GEN y) ++ GEN RgM_det_triangular(GEN x) ++ int RgM_is_ZM(GEN x) ++ int RgM_isdiagonal(GEN x) ++ int RgM_isidentity(GEN x) ++ int RgM_isscalar(GEN x, GEN s) ++ GEN RgM_mul(GEN x, GEN y) ++ GEN RgM_multosym(GEN x, GEN y) ++ GEN RgM_neg(GEN x) ++ GEN RgM_powers(GEN x, long l) ++ GEN RgM_sqr(GEN x) ++ GEN RgM_sub(GEN x, GEN y) ++ GEN RgM_transmul(GEN x, GEN y) ++ GEN RgM_transmultosym(GEN x, GEN y) ++ GEN RgM_zc_mul(GEN x, GEN y) ++ GEN RgM_zm_mul(GEN x, GEN y) ++ GEN RgMrow_RgC_mul(GEN x, GEN y, long i) ++ GEN RgV_RgM_mul(GEN x, GEN y) ++ GEN RgV_RgC_mul(GEN x, GEN y) ++ GEN RgV_Rg_mul(GEN x, GEN y) ++ GEN RgV_add(GEN x, GEN y) ++ GEN RgV_dotproduct(GEN x, GEN y) ++ GEN RgV_dotsquare(GEN x) ++ int RgV_is_ZMV(GEN V) ++ long RgV_isin(GEN v, GEN x) ++ GEN RgV_neg(GEN x) ++ GEN RgV_sub(GEN x, GEN y) ++ GEN RgV_sum(GEN v) ++ GEN RgV_sumpart(GEN v, long n) ++ GEN RgV_sumpart2(GEN v, long m, long n) ++ GEN RgV_zc_mul(GEN x, GEN y) ++ GEN RgV_zm_mul(GEN x, GEN y) ++ GEN RgX_RgM_eval(GEN x, GEN y) ++ GEN RgX_RgMV_eval(GEN x, GEN y) ++ int isdiagonal(GEN x) ++ GEN matid(long n) ++ GEN scalarcol(GEN x, long n) ++ GEN scalarcol_shallow(GEN x, long n) ++ GEN scalarmat(GEN x, long n) ++ GEN scalarmat_shallow(GEN x, long n) ++ GEN scalarmat_s(long x, long n) ++ ++ # RgX.c ++ ++ GEN Kronecker_to_mod(GEN z, GEN pol) ++ GEN QX_ZXQV_eval(GEN P, GEN V, GEN dV) ++ GEN QXQ_powers(GEN a, long n, GEN T) ++ GEN QXQX_to_mod_shallow(GEN z, GEN T) ++ GEN QXQV_to_mod(GEN V, GEN T) ++ GEN QXQXV_to_mod(GEN V, GEN T) ++ GEN QXV_QXQ_eval(GEN v, GEN a, GEN T) ++ GEN QXX_QXQ_eval(GEN v, GEN a, GEN T) ++ GEN Rg_to_RgV(GEN x, long N) ++ GEN RgM_to_RgXV(GEN x, long v) ++ GEN RgM_to_RgXX(GEN x, long v, long w) ++ GEN RgV_to_RgX(GEN x, long v) ++ GEN RgV_to_RgX_reverse(GEN x, long v) ++ GEN RgXQC_red(GEN P, GEN T) ++ GEN RgXQV_red(GEN P, GEN T) ++ GEN RgXQX_RgXQ_mul(GEN x, GEN y, GEN T) ++ GEN RgXQX_divrem(GEN x, GEN y, GEN T, GEN *r) ++ GEN RgXQX_mul(GEN x, GEN y, GEN T) ++ GEN RgXQX_pseudodivrem(GEN x, GEN y, GEN T, GEN *ptr) ++ GEN RgXQX_pseudorem(GEN x, GEN y, GEN T) ++ GEN RgXQX_red(GEN P, GEN T) ++ GEN RgXQX_sqr(GEN x, GEN T) ++ GEN RgXQX_translate(GEN P, GEN c, GEN T) ++ GEN RgXQ_matrix_pow(GEN y, long n, long m, GEN P) ++ GEN RgXQ_norm(GEN x, GEN T) ++ GEN RgXQ_pow(GEN x, GEN n, GEN T) ++ GEN RgXQ_powu(GEN x, ulong n, GEN T) ++ GEN RgXQ_powers(GEN x, long l, GEN T) ++ GEN RgXV_to_RgM(GEN v, long n) ++ GEN RgXV_unscale(GEN v, GEN h) ++ GEN RgXX_to_RgM(GEN v, long n) ++ GEN RgXY_swap(GEN x, long n, long w) ++ GEN RgXY_swapspec(GEN x, long n, long w, long nx) ++ GEN RgX_RgXQ_eval(GEN f, GEN x, GEN T) ++ GEN RgX_RgXQV_eval(GEN P, GEN V, GEN T) ++ GEN RgX_Rg_add(GEN y, GEN x) ++ GEN RgX_Rg_add_shallow(GEN y, GEN x) ++ GEN RgX_Rg_div(GEN y, GEN x) ++ GEN RgX_Rg_divexact(GEN x, GEN y) ++ GEN RgX_Rg_mul(GEN y, GEN x) ++ GEN RgX_Rg_sub(GEN y, GEN x) ++ GEN RgX_add(GEN x, GEN y) ++ GEN RgX_blocks(GEN P, long n, long m) ++ GEN RgX_deflate(GEN x0, long d) ++ GEN RgX_deriv(GEN x) ++ GEN RgX_div_by_X_x(GEN a, GEN x, GEN *r) ++ GEN RgX_divrem(GEN x, GEN y, GEN *r) ++ GEN RgX_divs(GEN y, long x) ++ long RgX_equal(GEN x, GEN y) ++ void RgX_even_odd(GEN p, GEN *pe, GEN *po) ++ GEN RgX_get_0(GEN x) ++ GEN RgX_get_1(GEN x) ++ GEN RgX_inflate(GEN x0, long d) ++ GEN RgX_modXn_shallow(GEN a, long n) ++ GEN RgX_modXn_eval(GEN Q, GEN x, long n) ++ GEN RgX_mul(GEN x, GEN y) ++ GEN RgX_mul_normalized(GEN A, long a, GEN B, long b) ++ GEN RgX_mulXn(GEN x, long d) ++ GEN RgX_mullow(GEN f, GEN g, long n) ++ GEN RgX_muls(GEN y, long x) ++ GEN RgX_mulspec(GEN a, GEN b, long na, long nb) ++ GEN RgX_neg(GEN x) ++ GEN RgX_pseudodivrem(GEN x, GEN y, GEN *ptr) ++ GEN RgX_pseudorem(GEN x, GEN y) ++ GEN RgX_recip(GEN x) ++ GEN RgX_recip_shallow(GEN x) ++ GEN RgX_renormalize_lg(GEN x, long lx) ++ GEN RgX_rescale(GEN P, GEN h) ++ GEN RgX_rotate_shallow(GEN P, long k, long p) ++ GEN RgX_shift(GEN a, long n) ++ GEN RgX_shift_shallow(GEN x, long n) ++ GEN RgX_splitting(GEN p, long k) ++ GEN RgX_sqr(GEN x) ++ GEN RgX_sqrlow(GEN f, long n) ++ GEN RgX_sqrspec(GEN a, long na) ++ GEN RgX_sub(GEN x, GEN y) ++ GEN RgX_to_RgV(GEN x, long N) ++ GEN RgX_translate(GEN P, GEN c) ++ GEN RgX_unscale(GEN P, GEN h) ++ GEN Rg_RgX_sub(GEN x, GEN y) ++ GEN ZX_translate(GEN P, GEN c) ++ GEN ZX_unscale(GEN P, GEN h) ++ GEN ZX_unscale_div(GEN P, GEN h) ++ int ZXQX_dvd(GEN x, GEN y, GEN T) ++ long brent_kung_optpow(long d, long n, long m) ++ GEN gen_bkeval(GEN Q, long d, GEN x, int use_sqr, void *E, ++ bb_algebra *ff, GEN cmul(void *E, GEN P, long a, GEN x)) ++ GEN gen_bkeval_powers(GEN P, long d, GEN V, void *E, ++ bb_algebra *ff, GEN cmul(void *E, GEN P, long a, GEN x)) ++ ++ # ZV.c ++ ++ void Flc_lincomb1_inplace(GEN X, GEN Y, ulong v, ulong q) ++ void RgM_check_ZM(GEN A, const char *s) ++ void RgV_check_ZV(GEN A, const char *s) ++ GEN ZC_ZV_mul(GEN x, GEN y) ++ GEN ZC_Z_add(GEN x, GEN y) ++ GEN ZC_Z_divexact(GEN X, GEN c) ++ GEN ZC_Z_mul(GEN X, GEN c) ++ GEN ZC_Z_sub(GEN x, GEN y) ++ GEN ZC_add(GEN x, GEN y) ++ GEN ZC_copy(GEN x) ++ GEN ZC_hnfremdiv(GEN x, GEN y, GEN *Q) ++ GEN ZC_lincomb(GEN u, GEN v, GEN X, GEN Y) ++ void ZC_lincomb1_inplace(GEN X, GEN Y, GEN v) ++ GEN ZC_neg(GEN M) ++ GEN ZC_reducemodlll(GEN x, GEN y) ++ GEN ZC_reducemodmatrix(GEN v, GEN y) ++ GEN ZC_sub(GEN x, GEN y) ++ GEN ZC_z_mul(GEN X, long c) ++ GEN ZM_ZC_mul(GEN x, GEN y) ++ GEN ZM_Z_divexact(GEN X, GEN c) ++ GEN ZM_Z_mul(GEN X, GEN c) ++ GEN ZM_add(GEN x, GEN y) ++ GEN ZM_copy(GEN x) ++ GEN ZM_det_triangular(GEN mat) ++ int ZM_equal(GEN A, GEN B) ++ GEN ZM_hnfdivrem(GEN x, GEN y, GEN *Q) ++ int ZM_ishnf(GEN x) ++ int ZM_isidentity(GEN x) ++ long ZM_max_lg(GEN x) ++ GEN ZM_mul(GEN x, GEN y) ++ GEN ZM_multosym(GEN x, GEN y) ++ GEN ZM_neg(GEN x) ++ GEN ZM_nm_mul(GEN x, GEN y) ++ GEN ZM_pow(GEN x, GEN n) ++ GEN ZM_powu(GEN x, ulong n) ++ GEN ZM_reducemodlll(GEN x, GEN y) ++ GEN ZM_reducemodmatrix(GEN v, GEN y) ++ GEN ZM_sub(GEN x, GEN y) ++ GEN ZM_supnorm(GEN x) ++ GEN ZM_to_Flm(GEN x, ulong p) ++ GEN ZM_to_zm(GEN z) ++ GEN ZM_transmultosym(GEN x, GEN y) ++ GEN ZMV_to_zmV(GEN z) ++ void ZM_togglesign(GEN M) ++ GEN ZM_zc_mul(GEN x, GEN y) ++ GEN ZM_zm_mul(GEN x, GEN y) ++ GEN ZMrow_ZC_mul(GEN x, GEN y, long i) ++ GEN ZV_ZM_mul(GEN x, GEN y) ++ int ZV_abscmp(GEN x, GEN y) ++ int ZV_cmp(GEN x, GEN y) ++ GEN ZV_content(GEN x) ++ GEN ZV_dotproduct(GEN x, GEN y) ++ GEN ZV_dotsquare(GEN x) ++ int ZV_equal(GEN V, GEN W) ++ int ZV_equal0(GEN V) ++ long ZV_max_lg(GEN x) ++ void ZV_neg_inplace(GEN M) ++ GEN ZV_prod(GEN v) ++ GEN ZV_sum(GEN v) ++ GEN ZV_to_Flv(GEN x, ulong p) ++ GEN ZV_to_nv(GEN z) ++ void ZV_togglesign(GEN M) ++ GEN gram_matrix(GEN M) ++ GEN nm_Z_mul(GEN X, GEN c) ++ GEN zm_mul(GEN x, GEN y) ++ GEN zm_to_Flm(GEN z, ulong p) ++ GEN zm_to_ZM(GEN z) ++ GEN zm_zc_mul(GEN x, GEN y) ++ GEN zmV_to_ZMV(GEN z) ++ long zv_content(GEN x) ++ long zv_dotproduct(GEN x, GEN y) ++ int zv_equal(GEN V, GEN W) ++ int zv_equal0(GEN V) ++ GEN zv_neg(GEN x) ++ GEN zv_neg_inplace(GEN M) ++ long zv_prod(GEN v) ++ GEN zv_prod_Z(GEN v) ++ long zv_sum(GEN v) ++ GEN zv_to_Flv(GEN z, ulong p) ++ GEN zv_z_mul(GEN v, long n) ++ int zvV_equal(GEN V, GEN W) ++ ++ # ZX.c ++ ++ void RgX_check_QX(GEN x, const char *s) ++ void RgX_check_ZX(GEN x, const char *s) ++ void RgX_check_ZXX(GEN x, const char *s) ++ GEN Z_ZX_sub(GEN x, GEN y) ++ GEN ZX_Z_add(GEN y, GEN x) ++ GEN ZX_Z_add_shallow(GEN y, GEN x) ++ GEN ZX_Z_divexact(GEN y, GEN x) ++ GEN ZX_Z_mul(GEN y, GEN x) ++ GEN ZX_Z_sub(GEN y, GEN x) ++ GEN ZX_add(GEN x, GEN y) ++ GEN ZX_copy(GEN x) ++ GEN ZX_deriv(GEN x) ++ int ZX_equal(GEN V, GEN W) ++ GEN ZX_eval1(GEN x) ++ long ZX_max_lg(GEN x) ++ GEN ZX_mod_Xnm1(GEN T, ulong n) ++ GEN ZX_mul(GEN x, GEN y) ++ GEN ZX_mulspec(GEN a, GEN b, long na, long nb) ++ GEN ZX_mulu(GEN y, ulong x) ++ GEN ZX_neg(GEN x) ++ GEN ZX_rem(GEN x, GEN y) ++ GEN ZX_remi2n(GEN y, long n) ++ GEN ZX_rescale(GEN P, GEN h) ++ GEN ZX_rescale_lt(GEN P) ++ GEN ZX_shifti(GEN x, long n) ++ GEN ZX_sqr(GEN x) ++ GEN ZX_sqrspec(GEN a, long na) ++ GEN ZX_sub(GEN x, GEN y) ++ long ZX_val(GEN x) ++ long ZX_valrem(GEN x, GEN *Z) ++ GEN ZXT_remi2n(GEN z, long n) ++ GEN ZXV_Z_mul(GEN y, GEN x) ++ GEN ZXV_dotproduct(GEN V, GEN W) ++ int ZXV_equal(GEN V, GEN W) ++ GEN ZXV_remi2n(GEN x, long n) ++ GEN ZXX_Z_divexact(GEN y, GEN x) ++ long ZXX_max_lg(GEN x) ++ GEN ZXX_renormalize(GEN x, long lx) ++ GEN ZXX_to_Kronecker(GEN P, long n) ++ GEN ZXX_to_Kronecker_spec(GEN P, long lP, long n) ++ GEN scalar_ZX(GEN x, long v) ++ GEN scalar_ZX_shallow(GEN x, long v) ++ GEN zx_to_ZX(GEN z) ++ ++ # alglin1.c ++ ++ GEN F2m_F2c_gauss(GEN a, GEN b) ++ GEN F2m_F2c_invimage(GEN A, GEN y) ++ GEN F2m_deplin(GEN x) ++ ulong F2m_det(GEN x) ++ ulong F2m_det_sp(GEN x) ++ GEN F2m_gauss(GEN a, GEN b) ++ GEN F2m_image(GEN x) ++ GEN F2m_indexrank(GEN x) ++ GEN F2m_inv(GEN x) ++ GEN F2m_invimage(GEN A, GEN B) ++ GEN F2m_ker(GEN x) ++ GEN F2m_ker_sp(GEN x, long deplin) ++ long F2m_rank(GEN x) ++ GEN F2m_suppl(GEN x) ++ GEN F2xqM_F2xqC_mul(GEN a, GEN b, GEN T) ++ GEN F2xqM_det(GEN a, GEN T) ++ GEN F2xqM_ker(GEN x, GEN T) ++ GEN F2xqM_image(GEN x, GEN T) ++ GEN F2xqM_inv(GEN a, GEN T) ++ GEN F2xqM_mul(GEN a, GEN b, GEN T) ++ long F2xqM_rank(GEN x, GEN T) ++ GEN Flm_Flc_gauss(GEN a, GEN b, ulong p) ++ GEN Flm_Flc_invimage(GEN mat, GEN y, ulong p) + GEN Flm_deplin(GEN x, ulong p) ++ ulong Flm_det(GEN x, ulong p) ++ ulong Flm_det_sp(GEN x, ulong p) ++ GEN Flm_gauss(GEN a, GEN b, ulong p) ++ GEN Flm_image(GEN x, ulong p) ++ GEN Flm_invimage(GEN m, GEN v, ulong p) + GEN Flm_indexrank(GEN x, ulong p) + GEN Flm_inv(GEN x, ulong p) + GEN Flm_ker(GEN x, ulong p) + GEN Flm_ker_sp(GEN x, ulong p, long deplin) +- GEN Flm_mul(GEN x, GEN y, ulong p) ++ long Flm_rank(GEN x, ulong p) ++ GEN Flm_suppl(GEN x, ulong p) ++ GEN FlxqM_FlxqC_gauss(GEN a, GEN b, GEN T, ulong p) ++ GEN FlxqM_FlxqC_mul(GEN a, GEN b, GEN T, ulong p) ++ GEN FlxqM_det(GEN a, GEN T, ulong p) ++ GEN FlxqM_gauss(GEN a, GEN b, GEN T, ulong p) + GEN FlxqM_ker(GEN x, GEN T, ulong p) +- GEN FpC_FpV_mul(GEN x, GEN y, GEN p) ++ GEN FlxqM_image(GEN x, GEN T, ulong p) ++ GEN FlxqM_inv(GEN x, GEN T, ulong p) ++ GEN FlxqM_mul(GEN a, GEN b, GEN T, ulong p) ++ long FlxqM_rank(GEN x, GEN T, ulong p) ++ GEN FpM_FpC_gauss(GEN a, GEN b, GEN p) ++ GEN FpM_FpC_invimage(GEN m, GEN v, GEN p) + GEN FpM_deplin(GEN x, GEN p) ++ GEN FpM_det(GEN x, GEN p) ++ GEN FpM_gauss(GEN a, GEN b, GEN p) + GEN FpM_image(GEN x, GEN p) ++ GEN FpM_indexrank(GEN x, GEN p) + GEN FpM_intersect(GEN x, GEN y, GEN p) + GEN FpM_inv(GEN x, GEN p) + GEN FpM_invimage(GEN m, GEN v, GEN p) + GEN FpM_ker(GEN x, GEN p) +- GEN FpM_mul(GEN x, GEN y, GEN p) + long FpM_rank(GEN x, GEN p) +- GEN FpM_indexrank(GEN x, GEN p) + GEN FpM_suppl(GEN x, GEN p) ++ GEN FqM_FqC_gauss(GEN a, GEN b, GEN T, GEN p) ++ GEN FqM_FqC_mul(GEN a, GEN b, GEN T, GEN p) ++ GEN FqM_deplin(GEN x, GEN T, GEN p) ++ GEN FqM_det(GEN x, GEN T, GEN p) + GEN FqM_gauss(GEN a, GEN b, GEN T, GEN p) + GEN FqM_ker(GEN x, GEN T, GEN p) ++ GEN FqM_image(GEN x, GEN T, GEN p) ++ GEN FqM_inv(GEN x, GEN T, GEN p) ++ GEN FqM_mul(GEN a, GEN b, GEN T, GEN p) ++ long FqM_rank(GEN a, GEN T, GEN p) + GEN FqM_suppl(GEN x, GEN T, GEN p) + GEN QM_inv(GEN M, GEN dM) ++ GEN RgM_Fp_init(GEN a, GEN p, ulong *pp) ++ GEN RgM_RgC_invimage(GEN A, GEN B) ++ GEN RgM_diagonal(GEN m) ++ GEN RgM_diagonal_shallow(GEN m) ++ GEN RgM_Hadamard(GEN a) ++ GEN RgM_inv_upper(GEN a) ++ GEN RgM_invimage(GEN A, GEN B) ++ GEN RgM_solve(GEN a, GEN b) ++ GEN RgM_solve_realimag(GEN x, GEN y) ++ void RgMs_structelim(GEN M, long N, GEN A, GEN *p_col, GEN *p_lin) ++ GEN ZM_det(GEN a) ++ GEN ZM_detmult(GEN A) ++ GEN ZM_gauss(GEN a, GEN b) ++ GEN ZM_imagecompl(GEN x) ++ GEN ZM_indeximage(GEN x) + GEN ZM_inv(GEN M, GEN dM) +- GEN concat(GEN x, GEN y) ++ long ZM_rank(GEN x) ++ GEN ZlM_gauss(GEN a, GEN b, ulong p, long e, GEN C) ++ GEN closemodinvertible(GEN x, GEN y) + GEN deplin(GEN x) + GEN det(GEN a) +- GEN det0(GEN a,long flag) ++ GEN det0(GEN a, long flag) + GEN det2(GEN a) + GEN detint(GEN x) +- GEN diagonal(GEN x) + GEN eigen(GEN x, long prec) +- GEN shallowextract(GEN x, GEN l) +- GEN extract0(GEN x, GEN l1, GEN l2) + GEN gauss(GEN a, GEN b) + GEN gaussmodulo(GEN M, GEN D, GEN Y) + GEN gaussmodulo2(GEN M, GEN D, GEN Y) +- GEN scalarmat_s(long x, long n) +- GEN gtomat(GEN x) +- GEN gtrans(GEN x) +- int hnfdivide(GEN A, GEN B) +- GEN matid(long n) ++ GEN gen_Gauss(GEN a, GEN b, void *E, bb_field *ff) ++ GEN gen_Gauss_pivot(GEN x, long *rr, void *E, bb_field *ff) ++ GEN gen_det(GEN a, void *E, bb_field *ff) ++ GEN gen_ker(GEN x, long deplin, void *E, bb_field *ff) ++ GEN gen_matcolmul(GEN a, GEN b, void *E, bb_field *ff) ++ GEN gen_matmul(GEN a, GEN b, void *E, bb_field *ff) + GEN image(GEN x) + GEN image2(GEN x) + GEN imagecompl(GEN x) + GEN indexrank(GEN x) + GEN inverseimage(GEN mat, GEN y) +- long isdiagonal(GEN x) + GEN ker(GEN x) + GEN keri(GEN x) +- GEN matimage0(GEN x,long flag) ++ GEN mateigen(GEN x, long flag, long prec) ++ GEN matimage0(GEN x, long flag) + GEN matker0(GEN x, long flag) +- GEN matmuldiagonal(GEN x, GEN d) +- GEN matmultodiagonal(GEN x, GEN y) +- GEN matsolvemod0(GEN M, GEN D, GEN Y,long flag) ++ GEN matsolvemod0(GEN M, GEN D, GEN Y, long flag) + long rank(GEN x) +- GEN indexrank(GEN x) +- # we rename sum to pari_sum to avoid conflicts with +- # python's sum function +- GEN pari_sum "sum"(GEN v, long a, long b) ++ GEN reducemodinvertible(GEN x, GEN y) ++ GEN reducemodlll(GEN x, GEN y) ++ GEN split_realimag(GEN x, long r1, long r2) + GEN suppl(GEN x) +- GEN vconcat(GEN A, GEN B) + + # alglin2.c + +- GEN ZM_to_zm(GEN z) ++ GEN FpM_charpoly(GEN x, GEN p) ++ GEN FpM_hess(GEN x, GEN p) ++ GEN Flm_charpoly(GEN x, long p) ++ GEN Flm_hess(GEN x, ulong p) ++ GEN QM_minors_coprime(GEN x, GEN pp) ++ GEN QM_ImZ_hnf(GEN x) ++ GEN QM_ImQ_hnf(GEN x) ++ GEN gnorml1_fake(GEN x) ++ GEN ZM_charpoly(GEN x) + GEN adj(GEN x) +- GEN caract(GEN x, int v) ++ GEN adjsafe(GEN x) ++ GEN caract(GEN x, long v) + GEN caradj(GEN x, long v, GEN *py) ++ GEN carberkowitz(GEN x, long v) + GEN carhess(GEN x, long v) +- GEN charpoly0(GEN x, int v,long flag) +- GEN conjvec(GEN x,long prec) +- GEN gconj(GEN x) ++ GEN charpoly(GEN x, long v) ++ GEN charpoly0(GEN x, long v, long flag) + GEN gnorm(GEN x) +- GEN gnorml1(GEN x,long prec) ++ GEN gnorml1(GEN x, long prec) ++ GEN gnormlp(GEN x, GEN p, long prec) + GEN gnorml2(GEN x) ++ GEN gsupnorm(GEN x, long prec) ++ void gsupnorm_aux(GEN x, GEN *m, GEN *msq, long prec) + GEN gtrace(GEN x) + GEN hess(GEN x) +- GEN hnf(GEN x) +- GEN hnfall(GEN x) +- GEN hnflll(GEN x) +- GEN hnfmod(GEN x, GEN detmat) +- GEN hnfmodid(GEN x,GEN p) +- GEN hnfperm(GEN x) + GEN intersect(GEN x, GEN y) + GEN jacobi(GEN a, long prec) +- GEN matfrobenius(GEN M, long flag, long v) +- GEN matrixqz(GEN x, GEN pp) ++ GEN matadjoint0(GEN x, long flag) ++ GEN matcompanion(GEN x) + GEN matrixqz0(GEN x, GEN pp) +- GEN qfsign(GEN a) +- GEN smith(GEN x) +- GEN smithall(GEN x) +- GEN smithclean(GEN z) ++ GEN minpoly(GEN x, long v) + GEN qfgaussred(GEN a) +- GEN zm_to_ZM(GEN z) +- GEN zx_to_ZX(GEN z) ++ GEN qfgaussred_positive(GEN a) ++ GEN qfsign(GEN a) ++ ++ # alglin3.c ++ ++ GEN apply0(GEN f, GEN A) ++ GEN diagonal(GEN x) ++ GEN diagonal_shallow(GEN x) ++ GEN extract0(GEN x, GEN l1, GEN l2) ++ GEN genapply(void *E, GEN (*f)(void *E, GEN x), GEN A) ++ GEN genindexselect(void *E, long (*f)(void *E, GEN x), GEN A) ++ GEN genselect(void *E, long (*f)(void *E, GEN x), GEN A) ++ GEN gtomat(GEN x) ++ GEN gtrans(GEN x) ++ GEN matmuldiagonal(GEN x, GEN d) ++ GEN matmultodiagonal(GEN x, GEN y) ++ GEN matslice0(GEN A, long x1, long x2, long y1, long y2) ++ GEN parapply(GEN V, GEN C) ++ GEN parselect(GEN C, GEN D, long flag) ++ GEN select0(GEN A, GEN f, long flag) ++ GEN shallowextract(GEN x, GEN L) ++ GEN shallowtrans(GEN x) ++ GEN vecapply(void *E, GEN (*f)(void* E, GEN x), GEN x) ++ GEN veccatapply(void *E, GEN (*f)(void* E, GEN x), GEN x) ++ GEN veccatselapply(void *Epred, long (*pred)(void* E, GEN x), void *Efun, ++ GEN (*fun)(void* E, GEN x), GEN A) ++ GEN vecrange(GEN a, GEN b) ++ GEN vecrangess(long a, long b) ++ GEN vecselapply(void *Epred, long (*pred)(void* E, GEN x), void *Efun, ++ GEN (*fun)(void* E, GEN x), GEN A) ++ GEN vecselect(void *E, long (*f)(void* E, GEN x), GEN A) ++ GEN vecslice0(GEN A, long y1, long y2) ++ GEN vecsum(GEN v) + + # anal.c + +- void addhelp(char *e, char *s) ++ void addhelp(const char *e, char *s) ++ void alias0(const char *s, const char *old) ++ GEN compile_str(const char *s) ++ GEN chartoGENstr(char c) + long delete_var() +- long fetch_user_var(char *s) ++ entree* fetch_named_var(const char *s) ++ long fetch_user_var(const char *s) + long fetch_var() +- GEN gp_read_str(char *s) +- void kill0(char *e) +- void name_var(long n, char *s) ++ GEN fetch_var_value(long vx, GEN t) ++ GEN gp_read_str(const char *t) ++ entree* install(void *f, const char *name, const char *code) ++ entree* is_entry(const char *s) ++ void kill0(const char *e) ++ long manage_var(long n, entree *ep) ++ void pari_var_init() ++ long pari_var_next() ++ long pari_var_next_temp() ++ void pari_var_create(entree *ep) ++ void name_var(long n, const char *s) + GEN readseq(char *t) +- GEN strtoGENstr(char *s) ++ GEN* safegel(GEN x, long l) ++ long* safeel(GEN x, long l) ++ GEN* safelistel(GEN x, long l) ++ GEN* safegcoeff(GEN x, long a, long b) ++ GEN strntoGENstr(const char *s, long n0) ++ GEN strtoGENstr(const char *s) ++ GEN strtoi(const char *s) ++ GEN strtor(const char *s, long prec) + GEN type0(GEN x) + ++ # aprcl.c ++ ++ long isprimeAPRCL(GEN N) ++ ++ # Qfb.c ++ ++ GEN Qfb0(GEN x, GEN y, GEN z, GEN d, long prec) ++ void check_quaddisc(GEN x, long *s, long *r, const char *f) ++ void check_quaddisc_imag(GEN x, long *r, const char *f) ++ void check_quaddisc_real(GEN x, long *r, const char *f) ++ long cornacchia(GEN d, GEN p, GEN *px, GEN *py) ++ long cornacchia2(GEN d, GEN p, GEN *px, GEN *py) ++ GEN nucomp(GEN x, GEN y, GEN l) ++ GEN nudupl(GEN x, GEN l) ++ GEN nupow(GEN x, GEN n) ++ GEN primeform(GEN x, GEN p, long prec) ++ GEN primeform_u(GEN x, ulong p) ++ GEN qfbcompraw(GEN x, GEN y) ++ GEN qfbpowraw(GEN x, long n) ++ GEN qfbred0(GEN x, long flag, GEN D, GEN isqrtD, GEN sqrtD) ++ GEN qfbsolve(GEN Q, GEN n) ++ GEN qfi(GEN x, GEN y, GEN z) ++ GEN qfi_1(GEN x) ++ GEN qficomp(GEN x, GEN y) ++ GEN qficompraw(GEN x, GEN y) ++ GEN qfipowraw(GEN x, long n) ++ GEN qfisolvep(GEN Q, GEN p) ++ GEN qfisqr(GEN x) ++ GEN qfisqrraw(GEN x) ++ GEN qfr(GEN x, GEN y, GEN z, GEN d) ++ GEN qfr3_comp(GEN x, GEN y, qfr_data *S) ++ GEN qfr3_pow(GEN x, GEN n, qfr_data *S) ++ GEN qfr3_red(GEN x, qfr_data *S) ++ GEN qfr3_rho(GEN x, qfr_data *S) ++ GEN qfr3_to_qfr(GEN x, GEN z) ++ GEN qfr5_comp(GEN x, GEN y, qfr_data *S) ++ GEN qfr5_dist(GEN e, GEN d, long prec) ++ GEN qfr5_pow(GEN x, GEN n, qfr_data *S) ++ GEN qfr5_red(GEN x, qfr_data *S) ++ GEN qfr5_rho(GEN x, qfr_data *S) ++ GEN qfr5_to_qfr(GEN x, GEN d0) ++ GEN qfr_1(GEN x) ++ void qfr_data_init(GEN D, long prec, qfr_data *S) ++ GEN qfr_to_qfr5(GEN x, long prec) ++ GEN qfrcomp(GEN x, GEN y) ++ GEN qfrcompraw(GEN x, GEN y) ++ GEN qfrpow(GEN x, GEN n) ++ GEN qfrpowraw(GEN x, long n) ++ GEN qfrsolvep(GEN Q, GEN p) ++ GEN qfrsqr(GEN x) ++ GEN qfrsqrraw(GEN x) ++ GEN quadgen(GEN x) ++ GEN quadpoly(GEN x) ++ GEN quadpoly0(GEN x, long v) ++ GEN redimag(GEN x) ++ GEN redreal(GEN x) ++ GEN redrealnod(GEN x, GEN isqrtD) ++ GEN rhoreal(GEN x) ++ GEN rhorealnod(GEN x, GEN isqrtD) ++ + # arith1.c + +- GEN bestappr0(GEN x, GEN a, GEN b) ++ ulong Fl_order(ulong a, ulong o, ulong p) ++ ulong Fl_powu(ulong x, ulong n, ulong p) ++ ulong Fl_sqrt(ulong a, ulong p) ++ GEN Fp_factored_order(GEN a, GEN o, GEN p) ++ int Fp_ispower(GEN x, GEN K, GEN p) ++ GEN Fp_log(GEN a, GEN g, GEN ord, GEN p) ++ GEN Fp_order(GEN a, GEN o, GEN p) ++ GEN Fp_pow(GEN a, GEN n, GEN m) ++ GEN Fp_pows(GEN A, long k, GEN N) ++ GEN Fp_powu(GEN x, ulong k, GEN p) ++ GEN Fp_sqrt(GEN a, GEN p) ++ GEN Fp_sqrtn(GEN a, GEN n, GEN p, GEN *zetan) ++ GEN Z_chinese(GEN a, GEN b, GEN A, GEN B) ++ GEN Z_chinese_all(GEN a, GEN b, GEN A, GEN B, GEN *pC) ++ GEN Z_chinese_coprime(GEN a, GEN b, GEN A, GEN B, GEN C) ++ GEN Z_chinese_post(GEN a, GEN b, GEN C, GEN U, GEN d) ++ void Z_chinese_pre(GEN A, GEN B, GEN *pC, GEN *pU, GEN *pd) ++ GEN Z_factor_listP(GEN N, GEN L) ++ long Z_isanypower(GEN x, GEN *y) ++ long Z_isfundamental(GEN x) ++ long Z_ispow2(GEN x) ++ long Z_ispowerall(GEN x, ulong k, GEN *pt) ++ long Z_issquareall(GEN x, GEN *pt) ++ long Zp_issquare(GEN a, GEN p) + GEN bestappr(GEN x, GEN k) +- long cgcd(long a,long b) +- void check_quaddisc(GEN x, long *s, long *r, char *f) ++ GEN bestapprPade(GEN x, long B) ++ long cgcd(long a, long b) + GEN chinese(GEN x, GEN y) +- GEN classno2(GEN x) ++ GEN chinese1(GEN x) ++ GEN chinese1_coprime_Z(GEN x) + GEN classno(GEN x) +- long clcm(long a,long b) ++ GEN classno2(GEN x) ++ long clcm(long a, long b) + GEN contfrac0(GEN x, GEN b, long flag) ++ GEN contfracpnqn(GEN x, long n) + GEN fibo(long n) + GEN gboundcf(GEN x, long k) +- GEN gissquareall(GEN x, GEN *pt) +- GEN gissquare(GEN x) +- GEN gcf2(GEN b, GEN x) + GEN gcf(GEN x) +- GEN quadunit(GEN x) ++ GEN gcf2(GEN b, GEN x) ++ bb_field *get_Fp_field(void **E, GEN p) ++ ulong pgener_Fl(ulong p) ++ ulong pgener_Fl_local(ulong p, GEN L) ++ GEN pgener_Fp(GEN p) ++ GEN pgener_Fp_local(GEN p, GEN L) ++ ulong pgener_Zl(ulong p) ++ GEN pgener_Zp(GEN p) + long gisanypower(GEN x, GEN *pty) +- GEN gisprime(GEN x, long flag) +- GEN gispseudoprime(GEN x, long flag) +- GEN gkronecker(GEN x, GEN y) +- GEN gnextprime(GEN n) +- GEN gprecprime(GEN n) +- GEN quadregulator(GEN x, long prec) ++ GEN gissquare(GEN x) ++ GEN gissquareall(GEN x, GEN *pt) + GEN hclassno(GEN x) +- long hilbert0 "hilbert"(GEN x, GEN y, GEN p) +- long Z_isfundamental(GEN x) ++ long hilbert(GEN x, GEN y, GEN p) ++ long hilbertii(GEN x, GEN y, GEN p) ++ long isfundamental(GEN x) ++ long ispolygonal(GEN x, GEN S, GEN *N) + long ispower(GEN x, GEN k, GEN *pty) +- long isprimeAPRCL(GEN N) +- long isprime(GEN x) +- long ispseudoprime(GEN x, long flag) ++ long isprimepower(GEN x, GEN *pty) ++ long issquare(GEN x) ++ long issquareall(GEN x, GEN *pt) + long krois(GEN x, long y) ++ long kroiu(GEN x, ulong y) + long kronecker(GEN x, GEN y) + long krosi(long s, GEN x) + long kross(long x, long y) + long krouu(ulong x, ulong y) + GEN lcmii(GEN a, GEN b) ++ long logint(GEN B, GEN y, GEN *ptq) ++ long logint0(GEN B, GEN y, GEN *ptq) + GEN mpfact(long n) +- GEN mpfactr(long n, long prec) +- GEN Fp_pow(GEN a, GEN n, GEN m) +- GEN Fp_sqrt(GEN a, GEN p) +- GEN Fp_sqrtn(GEN a, GEN n, GEN p, GEN *zetan) +- GEN nucomp(GEN x, GEN y, GEN l) +- GEN nudupl(GEN x, GEN l) +- GEN nupow(GEN x, GEN n) ++ GEN mulu_interval(ulong a, ulong b) ++ GEN odd_prime_divisors(GEN q) + GEN order(GEN x) + GEN pnqn(GEN x) +- GEN primeform(GEN x, GEN p, long prec) +- GEN Qfb0(GEN x, GEN y, GEN z, GEN d, long prec) +- GEN qfbclassno0(GEN x,long flag) +- GEN qfbred0(GEN x, long flag, GEN D, GEN isqrtD, GEN sqrtD) +- GEN qfbsolve(GEN Q, GEN n) +- GEN qfi(GEN x, GEN y, GEN z) +- GEN qfr(GEN x, GEN y, GEN z, GEN d) ++ GEN qfbclassno0(GEN x, long flag) + GEN quaddisc(GEN x) +- GEN redimag(GEN x) +- GEN redreal(GEN x) +- GEN redrealnod(GEN x, GEN isqrtD) +- GEN rhoreal(GEN x) +- GEN rhorealnod(GEN x, GEN isqrtD) +- ulong Fl_sqrt(ulong a, ulong p) +- GEN znprimroot0(GEN m) ++ GEN quadregulator(GEN x, long prec) ++ GEN quadunit(GEN x) ++ ulong rootsof1_Fl(ulong n, ulong p) ++ GEN rootsof1_Fp(GEN n, GEN p) ++ GEN rootsof1u_Fp(ulong n, GEN p) ++ GEN sqrtint(GEN a) ++ ulong ugcd(ulong a, ulong b) ++ long uisprimepower(ulong n, ulong *p) ++ long uissquare(ulong A) ++ long uissquareall(ulong A, ulong *sqrtA) ++ long unegisfundamental(ulong x) ++ long uposisfundamental(ulong x) ++ GEN znlog(GEN x, GEN g, GEN o) ++ GEN znorder(GEN x, GEN o) ++ GEN znprimroot(GEN m) + GEN znstar(GEN x) + + # arith2.c + +- GEN addprimes(GEN primes) +- long bigomega(GEN n) +- GEN binaire(GEN x) +- long bittest(GEN x, long n) +- GEN boundfact(GEN n, long lim) +- GEN core(GEN n) ++ GEN Z_smoothen(GEN N, GEN L, GEN *pP, GEN *pe) ++ GEN boundfact(GEN n, ulong lim) ++ GEN check_arith_pos(GEN n, char *f) ++ GEN check_arith_non0(GEN n, char *f) ++ GEN check_arith_all(GEN n, char *f) ++ GEN clean_Z_factor(GEN f) + GEN corepartial(GEN n, long l) +- GEN core0(GEN n,long flag) ++ GEN core0(GEN n, long flag) + GEN core2(GEN n) + GEN core2partial(GEN n, long l) + GEN coredisc(GEN n) +- GEN coredisc0(GEN n,long flag) ++ GEN coredisc0(GEN n, long flag) + GEN coredisc2(GEN n) +- GEN Z_factor(GEN n) ++ GEN digits(GEN N, GEN B) + GEN divisors(GEN n) +- GEN factorint(GEN n, long flag) +- GEN gbigomega(GEN n) +- GEN gbitand(GEN x, GEN y) +- GEN gbitneg(GEN x, long n) +- GEN gbitnegimply(GEN x, GEN y) +- GEN gbitor(GEN x, GEN y) +- GEN gbittest(GEN x, GEN n) +- GEN gbitxor(GEN x, GEN y) +- GEN gissquarefree(GEN x) +- GEN gmoebius(GEN n) +- GEN gnumbdiv(GEN n) +- GEN gomega(GEN n) +- GEN gsumdiv(GEN n) +- GEN gsumdivk(GEN n,long k) +- char* initprimes(ulong maxnum) +- long issquarefree(GEN x) ++ GEN divisorsu(ulong n) ++ GEN factor_pn_1(GEN p, ulong n) ++ GEN factor_pn_1_limit(GEN p, long n, ulong lim) ++ GEN factoru_pow(ulong n) ++ byteptr initprimes(ulong maxnum, long *lenp, ulong *lastp) ++ void initprimetable(ulong maxnum) ++ ulong init_primepointer_geq(ulong a, byteptr *pd) ++ ulong init_primepointer_gt(ulong a, byteptr *pd) ++ ulong init_primepointer_leq(ulong a, byteptr *pd) ++ ulong init_primepointer_lt(ulong a, byteptr *pd) ++ int is_Z_factor(GEN f) ++ int is_Z_factornon0(GEN f) ++ int is_Z_factorpos(GEN f) + ulong maxprime() + void maxprime_check(ulong c) +- GEN numbdiv(GEN n) +- long omega(GEN n) +- GEN geulerphi(GEN n) +- GEN prime(long n) +- GEN primepi(GEN x) +- GEN primes(long n) +- GEN removeprimes(GEN primes) +- GEN sumdiv(GEN n) +- GEN sumdivk(GEN n,long k) ++ GEN sumdigits(GEN n) ++ ulong sumdigitsu(ulong n) ++ ++ # DedekZeta.c ++ ++ GEN glambdak(GEN nfz, GEN s, long prec) ++ GEN gzetak(GEN nfz, GEN s, long prec) ++ GEN gzetakall(GEN nfz, GEN s, long flag, long prec) ++ GEN initzeta(GEN pol, long prec) ++ GEN dirzetak(GEN nf, GEN b) + + # base1.c + +- GEN bnfnewprec(GEN nf, long prec) +- GEN bnrnewprec(GEN bnr, long prec) ++ GEN FpX_FpC_nfpoleval(GEN nf, GEN pol, GEN a, GEN p) ++ GEN embed_T2(GEN x, long r1) ++ GEN embednorm_T2(GEN x, long r1) ++ GEN embed_norm(GEN x, long r1) ++ void check_ZKmodule(GEN x, char *s) + void checkbid(GEN bid) + GEN checkbnf(GEN bnf) + void checkbnr(GEN bnr) + void checkbnrgen(GEN bnr) ++ void checkabgrp(GEN v) ++ void checksqmat(GEN x, long N) + GEN checknf(GEN nf) + GEN checknfelt_mod(GEN nf, GEN x, char *s) ++ void checkprid(GEN bid) + void checkrnf(GEN rnf) ++ GEN factoredpolred(GEN x, GEN fa) ++ GEN factoredpolred2(GEN x, GEN fa) + GEN galoisapply(GEN nf, GEN aut, GEN x) +- GEN polgalois(GEN x, long prec) + GEN get_bnf(GEN x, long *t) + GEN get_bnfpol(GEN x, GEN *bnf, GEN *nf) + GEN get_nf(GEN x, long *t) + GEN get_nfpol(GEN x, GEN *nf) +- GEN glambdak(GEN nfz, GEN s, long prec) +- GEN gsmith(GEN x) +- GEN gsmithall(GEN x) +- GEN gzetak(GEN nfz, GEN s, long prec) +- GEN gzetakall(GEN nfz, GEN s, long flag, long prec) +- GEN mathnf0(GEN x,long flag) +- GEN matsnf0(GEN x,long flag) ++ GEN get_prid(GEN x) ++ GEN idealfrobenius(GEN nf, GEN gal, GEN pr) ++ GEN idealramgroups(GEN nf, GEN gal, GEN pr) ++ GEN nf_get_allroots(GEN nf) ++ long nf_get_prec(GEN x) ++ GEN nfcertify(GEN x) ++ GEN nfgaloismatrix(GEN nf, GEN s) ++ GEN nfinit(GEN x, long prec) + GEN nfinit0(GEN x, long flag, long prec) ++ GEN nfinitall(GEN x, long flag, long prec) ++ GEN nfinitred(GEN x, long prec) ++ GEN nfinitred2(GEN x, long prec) ++ GEN nfisincl(GEN a, GEN b) ++ GEN nfisisom(GEN a, GEN b) + GEN nfnewprec(GEN nf, long prec) +- GEN rootsof1(GEN x) ++ GEN nfnewprec_shallow(GEN nf, long prec) ++ GEN nfpoleval(GEN nf, GEN pol, GEN a) ++ long nftyp(GEN x) ++ GEN polredord(GEN x) ++ GEN polgalois(GEN x, long prec) ++ GEN polred(GEN x) ++ GEN polred0(GEN x, long flag, GEN p) ++ GEN polred2(GEN x) ++ GEN polredabs(GEN x) ++ GEN polredabs0(GEN x, long flag) ++ GEN polredabs2(GEN x) ++ GEN polredabsall(GEN x, long flun) ++ GEN polredbest(GEN x, long flag) ++ GEN rnfpolredabs(GEN nf, GEN pol, long flag) ++ GEN rnfpolredbest(GEN nf, GEN relpol, long flag) ++ GEN smallpolred(GEN x) ++ GEN smallpolred2(GEN x) + GEN tschirnhaus(GEN x) ++ GEN ZX_Q_normalize(GEN pol, GEN *ptlc) ++ GEN ZX_Z_normalize(GEN pol, GEN *ptk) ++ GEN ZX_to_monic(GEN pol, GEN *lead) ++ GEN ZX_primitive_to_monic(GEN pol, GEN *lead) + + # base2.c + +- GEN base(GEN x, GEN *y) +- GEN base2(GEN x, GEN *y) ++ GEN Fq_to_nf(GEN x, GEN modpr) ++ GEN FqM_to_nfM(GEN z, GEN modpr) ++ GEN FqV_to_nfV(GEN z, GEN modpr) ++ GEN FqX_to_nfX(GEN x, GEN modpr) ++ GEN Rg_nffix(const char *f, GEN T, GEN c, int lift) ++ GEN RgV_nffix(const char *f, GEN T, GEN P, int lift) ++ GEN RgX_nffix(const char *s, GEN nf, GEN x, int lift) ++ long ZpX_disc_val(GEN f, GEN p) ++ GEN ZpX_gcd(GEN f1, GEN f2, GEN p, GEN pm) ++ GEN ZpX_reduced_resultant(GEN x, GEN y, GEN p, GEN pm) ++ GEN ZpX_reduced_resultant_fast(GEN f, GEN g, GEN p, long M) ++ long ZpX_resultant_val(GEN f, GEN g, GEN p, long M) + void checkmodpr(GEN modpr) +- GEN compositum(GEN pol1, GEN pol2) +- GEN compositum2(GEN pol1, GEN pol2) +- GEN discf(GEN x) +- long idealval(GEN nf,GEN ix,GEN vp) +- GEN idealprodprime(GEN nf, GEN L) ++ GEN ZX_compositum_disjoint(GEN A, GEN B) ++ GEN compositum(GEN P, GEN Q) ++ GEN compositum2(GEN P, GEN Q) ++ GEN nfdisc(GEN x) + GEN indexpartial(GEN P, GEN DP) +- GEN nfbasis(GEN x, GEN *y,long flag,GEN p) +- GEN nfbasis0(GEN x,long flag,GEN p) +- GEN nfdisc0(GEN x,long flag, GEN p) ++ GEN modpr_genFq(GEN modpr) ++ GEN nf_to_Fq_init(GEN nf, GEN *pr, GEN *T, GEN *p) ++ GEN nf_to_Fq(GEN nf, GEN x, GEN modpr) ++ GEN nfM_to_FqM(GEN z, GEN nf, GEN modpr) ++ GEN nfV_to_FqV(GEN z, GEN nf, GEN modpr) ++ GEN nfX_to_FqX(GEN x, GEN nf, GEN modpr) ++ GEN nfbasis(GEN x, GEN *y, GEN p) ++ GEN nfbasis0(GEN x, long flag, GEN p) ++ GEN nfdisc0(GEN x, long flag, GEN p) ++ void nfmaxord(nfmaxord_t *S, GEN T, long flag) ++ GEN nfmodprinit(GEN nf, GEN pr) + GEN nfreducemodpr(GEN nf, GEN x, GEN modpr) +- GEN polcompositum0(GEN pol1, GEN pol2,long flag) +- GEN idealprimedec(GEN nf,GEN p) ++ GEN polcompositum0(GEN P, GEN Q, long flag) ++ GEN idealprimedec(GEN nf, GEN p) + GEN rnfbasis(GEN bnf, GEN order) ++ GEN rnfdedekind(GEN nf, GEN T, GEN pr, long flag) + GEN rnfdet(GEN nf, GEN order) + GEN rnfdiscf(GEN nf, GEN pol) +- GEN rnfequation(GEN nf, GEN pol2) +- GEN rnfequation0(GEN nf, GEN pol2, long flall) ++ GEN rnfequation(GEN nf, GEN pol) ++ GEN rnfequation0(GEN nf, GEN pol, long flall) + GEN rnfequation2(GEN nf, GEN pol) ++ GEN nf_rnfeq(GEN nf, GEN relpol) ++ GEN nf_rnfeqsimple(GEN nf, GEN relpol) ++ GEN rnfequationall(GEN A, GEN B, long *pk, GEN *pLPRS) + GEN rnfhnfbasis(GEN bnf, GEN order) + long rnfisfree(GEN bnf, GEN order) +- GEN rnflllgram(GEN nf, GEN pol, GEN order,long prec) ++ GEN rnflllgram(GEN nf, GEN pol, GEN order, long prec) + GEN rnfpolred(GEN nf, GEN pol, long prec) +- GEN rnfpolredabs(GEN nf, GEN pol, long flag) + GEN rnfpseudobasis(GEN nf, GEN pol) + GEN rnfsimplifybasis(GEN bnf, GEN order) ++ GEN rnfsteinitz(GEN nf, GEN order) ++ long factorial_lval(ulong n, ulong p) ++ GEN zk_to_Fq_init(GEN nf, GEN *pr, GEN *T, GEN *p) ++ GEN zk_to_Fq(GEN x, GEN modpr) ++ GEN zkmodprinit(GEN nf, GEN pr) + + # base3.c + ++ GEN Idealstar(GEN nf, GEN x, long flun) ++ GEN RgC_to_nfC(GEN nf, GEN x) ++ GEN RgM_to_nfM(GEN nf, GEN x) ++ GEN RgX_to_nfX(GEN nf, GEN pol) + GEN algtobasis(GEN nf, GEN x) + GEN basistoalg(GEN nf, GEN x) +- long nfval(GEN nf, GEN x, GEN vp) +- GEN ideallist(GEN nf,long bound) +- GEN ideallist0(GEN nf,long bound, long flag) ++ GEN ideallist(GEN nf, long bound) ++ GEN ideallist0(GEN nf, long bound, long flag) + GEN ideallistarch(GEN nf, GEN list, GEN arch) +- GEN idealstar0(GEN nf, GEN x,long flag) ++ GEN idealprincipalunits(GEN nf, GEN pr, long e) ++ GEN idealstar0(GEN nf, GEN x, long flag) ++ GEN indices_to_vec01(GEN archp, long r) ++ GEN matalgtobasis(GEN nf, GEN x) ++ GEN matbasistoalg(GEN nf, GEN x) ++ GEN nf_to_scalar_or_alg(GEN nf, GEN x) ++ GEN nf_to_scalar_or_basis(GEN nf, GEN x) ++ GEN nfadd(GEN nf, GEN x, GEN y) ++ GEN nfarchstar(GEN nf, GEN x, GEN arch) ++ GEN nfdiv(GEN nf, GEN x, GEN y) + GEN nfdiveuc(GEN nf, GEN a, GEN b) + GEN nfdivrem(GEN nf, GEN a, GEN b) ++ GEN nfinv(GEN nf, GEN x) ++ GEN nfinvmodideal(GEN nf, GEN x, GEN ideal) + GEN nfmod(GEN nf, GEN a, GEN b) +- GEN reducemodinvertible(GEN x, GEN y) ++ GEN nfmul(GEN nf, GEN x, GEN y) ++ GEN nfmuli(GEN nf, GEN x, GEN y) ++ GEN nfnorm(GEN nf, GEN x) ++ GEN nfpow(GEN nf, GEN x, GEN k) ++ GEN nfpow_u(GEN nf, GEN z, ulong n) ++ GEN nfpowmodideal(GEN nf, GEN x, GEN k, GEN ideal) ++ GEN nfsign(GEN nf, GEN alpha) ++ GEN nfsign_arch(GEN nf, GEN alpha, GEN arch) ++ GEN nfsign_from_logarch(GEN Larch, GEN invpi, GEN archp) ++ GEN nfsqr(GEN nf, GEN x) ++ GEN nfsqri(GEN nf, GEN x) ++ GEN nftrace(GEN nf, GEN x) ++ long nfval(GEN nf, GEN x, GEN vp) ++ GEN polmod_nffix(const char *f, GEN rnf, GEN x, int lift) ++ GEN polmod_nffix2(const char *f, GEN T, GEN relpol, GEN x, int lift) ++ int pr_equal(GEN nf, GEN P, GEN Q) ++ GEN rnfalgtobasis(GEN rnf, GEN x) ++ GEN rnfbasistoalg(GEN rnf, GEN x) ++ GEN rnfeltnorm(GEN rnf, GEN x) ++ GEN rnfelttrace(GEN rnf, GEN x) ++ GEN set_sign_mod_divisor(GEN nf, GEN x, GEN y, GEN idele, GEN sarch) ++ GEN vec01_to_indices(GEN arch) + GEN vecmodii(GEN a, GEN b) +- GEN ideallog(GEN nf,GEN x,GEN bigideal) +- GEN zidealstar(GEN nf, GEN x) +- GEN znlog(GEN x, GEN g) ++ GEN ideallog(GEN nf, GEN x, GEN bigideal) ++ ++ GEN multable(GEN nf, GEN x) ++ GEN tablemul(GEN TAB, GEN x, GEN y) ++ GEN tablemul_ei(GEN M, GEN x, long i) ++ GEN tablemul_ei_ej(GEN M, long i, long j) ++ GEN tablemulvec(GEN M, GEN x, GEN v) ++ GEN tablesqr(GEN tab, GEN x) ++ GEN ei_multable(GEN nf, long i) ++ long ZC_nfval(GEN nf, GEN x, GEN P) ++ long ZC_nfvalrem(GEN nf, GEN x, GEN P, GEN *t) ++ GEN zk_multable(GEN nf, GEN x) ++ GEN zk_scalar_or_multable(GEN, GEN x) ++ int ZC_prdvd(GEN nf, GEN x, GEN P) + + # base4.c + +- GEN nfreduce(GEN nf, GEN x, GEN ideal) ++ GEN RM_round_maxrank(GEN G) ++ GEN ZM_famat_limit(GEN fa, GEN limit) ++ GEN famat_inv(GEN f) ++ GEN famat_inv_shallow(GEN f) ++ GEN famat_makecoprime(GEN nf, GEN g, GEN e, GEN pr, GEN prk, GEN EX) ++ GEN famat_mul(GEN f, GEN g) ++ GEN famat_pow(GEN f, GEN n) ++ GEN famat_sqr(GEN f) ++ GEN famat_reduce(GEN fa) ++ GEN famat_to_nf(GEN nf, GEN f) ++ GEN famat_to_nf_modideal_coprime(GEN nf, GEN g, GEN e, GEN id, GEN EX) ++ GEN famat_to_nf_moddivisor(GEN nf, GEN g, GEN e, GEN bid) ++ GEN famatsmall_reduce(GEN fa) + GEN idealtwoelt(GEN nf, GEN ix) + GEN idealtwoelt0(GEN nf, GEN ix, GEN a) + GEN idealtwoelt2(GEN nf, GEN x, GEN a) + GEN idealadd(GEN nf, GEN x, GEN y) + GEN idealaddmultoone(GEN nf, GEN list) + GEN idealaddtoone(GEN nf, GEN x, GEN y) ++ GEN idealaddtoone_i(GEN nf, GEN x, GEN y) + GEN idealaddtoone0(GEN nf, GEN x, GEN y) + GEN idealappr(GEN nf, GEN x) + GEN idealappr0(GEN nf, GEN x, long fl) + GEN idealapprfact(GEN nf, GEN x) + GEN idealchinese(GEN nf, GEN x, GEN y) + GEN idealcoprime(GEN nf, GEN x, GEN y) ++ GEN idealcoprimefact(GEN nf, GEN x, GEN fy) + GEN idealdiv(GEN nf, GEN x, GEN y) +- GEN idealdiv0(GEN nf, GEN x, GEN y,long flag) ++ GEN idealdiv0(GEN nf, GEN x, GEN y, long flag) + GEN idealdivexact(GEN nf, GEN x, GEN y) + GEN idealdivpowprime(GEN nf, GEN x, GEN vp, GEN n) + GEN idealmulpowprime(GEN nf, GEN x, GEN vp, GEN n) + GEN idealfactor(GEN nf, GEN x) + GEN idealhnf(GEN nf, GEN x) ++ GEN idealhnf_principal(GEN nf, GEN x) ++ GEN idealhnf_shallow(GEN nf, GEN x) ++ GEN idealhnf_two(GEN nf, GEN vp) + GEN idealhnf0(GEN nf, GEN a, GEN b) + GEN idealintersect(GEN nf, GEN x, GEN y) + GEN idealinv(GEN nf, GEN ix) +- GEN idealred0(GEN nf, GEN ix, GEN vdir) ++ GEN idealred0(GEN nf, GEN I, GEN vdir) + GEN idealmul(GEN nf, GEN ix, GEN iy) +- GEN idealmul0(GEN nf, GEN ix, GEN iy, long flag, long prec) ++ GEN idealmul0(GEN nf, GEN ix, GEN iy, long flag) ++ GEN idealmul_HNF(GEN nf, GEN ix, GEN iy) + GEN idealmulred(GEN nf, GEN ix, GEN iy) + GEN idealnorm(GEN nf, GEN x) ++ GEN idealnumden(GEN nf, GEN x) + GEN idealpow(GEN nf, GEN ix, GEN n) +- GEN idealpow0(GEN nf, GEN ix, GEN n, long flag, long prec) +- GEN idealpowred(GEN nf, GEN ix, GEN n,long prec) ++ GEN idealpow0(GEN nf, GEN ix, GEN n, long flag) ++ GEN idealpowred(GEN nf, GEN ix, GEN n) + GEN idealpows(GEN nf, GEN ideal, long iexp) ++ GEN idealprodprime(GEN nf, GEN L) ++ GEN idealsqr(GEN nf, GEN x) + long idealtyp(GEN *ideal, GEN *arch) +- long isideal(GEN nf,GEN x) +- GEN minideal(GEN nf,GEN ix,GEN vdir,long prec) +- GEN mul_content(GEN cx, GEN cy) +- GEN nfdetint(GEN nf,GEN pseudo) ++ long idealval(GEN nf, GEN ix, GEN vp) ++ long isideal(GEN nf, GEN x) ++ GEN idealmin(GEN nf, GEN ix, GEN vdir) ++ GEN nf_get_Gtwist(GEN nf, GEN vdir) ++ GEN nf_get_Gtwist1(GEN nf, long i) ++ GEN nfC_nf_mul(GEN nf, GEN v, GEN x) ++ GEN nfdetint(GEN nf, GEN pseudo) ++ GEN nfdivmodpr(GEN nf, GEN x, GEN y, GEN modpr) + GEN nfhnf(GEN nf, GEN x) ++ GEN nfhnfmod(GEN nf, GEN x, GEN d) + GEN nfkermodpr(GEN nf, GEN x, GEN modpr) ++ GEN nfmulmodpr(GEN nf, GEN x, GEN y, GEN modpr) ++ GEN nfpowmodpr(GEN nf, GEN x, GEN k, GEN modpr) ++ GEN nfreduce(GEN nf, GEN x, GEN ideal) + GEN nfsnf(GEN nf, GEN x) + GEN nfsolvemodpr(GEN nf, GEN a, GEN b, GEN modpr) ++ GEN to_famat(GEN x, GEN y) ++ GEN to_famat_shallow(GEN x, GEN y) + GEN vecdiv(GEN x, GEN y) + GEN vecinv(GEN x) + GEN vecmul(GEN x, GEN y) +@@ -812,169 +1964,225 @@ cdef extern from 'pari/pari.h': + + # base5.c + +- GEN matalgtobasis(GEN nf, GEN x) +- GEN matbasistoalg(GEN nf, GEN x) +- GEN rnfalgtobasis(GEN rnf, GEN x) +- GEN rnfbasistoalg(GEN rnf, GEN x) +- GEN rnfelementabstorel(GEN rnf, GEN x) +- GEN rnfelementdown(GEN rnf, GEN x) +- GEN rnfelementreltoabs(GEN rnf, GEN x) +- GEN rnfelementup(GEN rnf, GEN x) ++ GEN eltreltoabs(GEN rnfeq, GEN x) ++ GEN eltabstorel(GEN eq, GEN P) ++ GEN eltabstorel_lift(GEN rnfeq, GEN P) ++ void nf_nfzk(GEN nf, GEN rnfeq, GEN *zknf, GEN *czknf) ++ GEN nfeltup(GEN nf, GEN x, GEN zknf, GEN czknf) ++ GEN rnfeltabstorel(GEN rnf, GEN x) ++ GEN rnfeltdown(GEN rnf, GEN x) ++ GEN rnfeltreltoabs(GEN rnf, GEN x) ++ GEN rnfeltup(GEN rnf, GEN x) + GEN rnfidealabstorel(GEN rnf, GEN x) + GEN rnfidealdown(GEN rnf, GEN x) +- GEN rnfidealhermite(GEN rnf, GEN x) +- GEN rnfidealmul(GEN rnf,GEN x,GEN y) ++ GEN rnfidealhnf(GEN rnf, GEN x) ++ GEN rnfidealmul(GEN rnf, GEN x, GEN y) + GEN rnfidealnormabs(GEN rnf, GEN x) + GEN rnfidealnormrel(GEN rnf, GEN x) + GEN rnfidealreltoabs(GEN rnf, GEN x) +- GEN rnfidealtwoelement(GEN rnf,GEN x) ++ GEN rnfidealtwoelement(GEN rnf, GEN x) + GEN rnfidealup(GEN rnf, GEN x) + GEN rnfinit(GEN nf, GEN pol) + ++ # bb_group.c ++ ++ GEN dlog_get_ordfa(GEN o) ++ GEN dlog_get_ord(GEN o) ++ GEN gen_PH_log(GEN a, GEN g, GEN ord, void *E, bb_group *grp) ++ GEN gen_Shanks_sqrtn(GEN a, GEN n, GEN q, GEN *zetan, void *E, bb_group *grp) ++ GEN gen_gener(GEN o, void *E, bb_group *grp) ++ GEN gen_ellgens(GEN d1, GEN d2, GEN m, void *E, bb_group *grp, ++ GEN pairorder(void *E, GEN P, GEN Q, GEN m, GEN F)) ++ GEN gen_ellgroup(GEN N, GEN F, GEN *pt_m, void *E, bb_group *grp, ++ GEN pairorder(void *E, GEN P, GEN Q, GEN m, GEN F)) ++ GEN gen_factored_order(GEN a, GEN o, void *E, bb_group *grp) ++ GEN gen_order(GEN x, GEN o, void *E, bb_group *grp) ++ GEN gen_select_order(GEN o, void *E, bb_group *grp) ++ ++ GEN gen_plog(GEN x, GEN g0, GEN q, void *E, bb_group *grp) ++ GEN gen_pow(GEN x, GEN n, void *E, GEN (*sqr)(void*, GEN), GEN (*mul)(void*, GEN, GEN)) ++ GEN gen_pow_i(GEN x, GEN n, void *E, GEN (*sqr)(void*, GEN), GEN (*mul)(void*, GEN, GEN)) ++ GEN gen_pow_fold(GEN x, GEN n, void *E, GEN (*sqr)(void*, GEN), GEN (*msqr)(void*, GEN)) ++ GEN gen_pow_fold_i(GEN x, GEN n, void *E, GEN (*sqr)(void*, GEN), GEN (*msqr)(void*, GEN)) ++ GEN gen_powers(GEN x, long l, int use_sqr, void *E, GEN (*sqr)(void*, GEN), GEN (*mul)(void*, GEN, GEN), GEN (*one)(void*)) ++ GEN gen_powu(GEN x, ulong n, void *E, GEN (*sqr)(void*, GEN), GEN (*mul)(void*, GEN, GEN)) ++ GEN gen_powu_i(GEN x, ulong n, void *E, GEN (*sqr)(void*, GEN), GEN (*mul)(void*, GEN, GEN)) ++ GEN gen_powu_fold(GEN x, ulong n, void *E, GEN (*sqr)(void*, GEN), GEN (*msqr)(void*, GEN)) ++ GEN gen_powu_fold_i(GEN x, ulong n, void *E, GEN (*sqr)(void*, GEN), GEN (*msqr)(void*, GEN)) ++ + # bibli1.c + +- GEN ZM_zc_mul(GEN x, GEN y) +- GEN ZM_zm_mul(GEN x, GEN y) +- GEN T2_from_embed(GEN x, long r1) ++ int QR_init(GEN x, GEN *pB, GEN *pQ, GEN *pL, long prec) ++ GEN R_from_QR(GEN x, long prec) ++ int RgM_QR_init(GEN x, GEN *pB, GEN *pQ, GEN *pL, long prec) ++ GEN Xadic_lindep(GEN x) + GEN algdep(GEN x, long n) + GEN algdep0(GEN x, long n, long bit) +- GEN factoredpolred(GEN x, GEN p) +- GEN factoredpolred2(GEN x, GEN p) +- GEN kerint(GEN x) +- GEN lindep(GEN x) ++ void forqfvec0(GEN a, GEN BORNE, GEN code) ++ GEN gaussred_from_QR(GEN x, long prec) + GEN lindep0(GEN x, long flag) ++ GEN lindep(GEN x) + GEN lindep2(GEN x, long bit) +- GEN lll(GEN x, long prec) +- GEN lllgen(GEN x) +- GEN lllgram(GEN x, long prec) +- GEN lllgramgen(GEN x) +- GEN lllgramint(GEN x) +- GEN lllgramkerim(GEN x) +- GEN lllgramkerimgen(GEN x) +- GEN lllint(GEN x) +- GEN lllintpartial(GEN mat) +- GEN lllkerim(GEN x) +- GEN lllkerimgen(GEN x) +- GEN matkerint0(GEN x,long flag) ++ GEN mathouseholder(GEN Q, GEN v) ++ GEN matqr(GEN x, long flag, long prec) + GEN minim(GEN a, GEN borne, GEN stockmax) +- GEN qfrep0(GEN a, GEN borne, long flag) +- GEN qfminim0(GEN a, GEN borne, GEN stockmax,long flag, long prec) ++ GEN minim_raw(GEN a, GEN borne, GEN stockmax) + GEN minim2(GEN a, GEN borne, GEN stockmax) +- GEN ordred(GEN x) ++ GEN padic_lindep(GEN x) + GEN perf(GEN a) +- GEN polred(GEN x) +- GEN polred0(GEN x, long flag, GEN p) +- GEN polred2(GEN x) +- GEN polredabs(GEN x) +- GEN polredabs0(GEN x, long flag) +- GEN polredabs2(GEN x) +- GEN polredabsall(GEN x, long flun) +- GEN polredbest(GEN x, long flag) +- GEN qflll0(GEN x, long flag) +- GEN qflllgram0(GEN x, long flag) +- GEN smallpolred(GEN x) +- GEN smallpolred2(GEN x) +- char *stackmalloc(size_t N) +- GEN zncoppersmith(GEN P0, GEN N, GEN X, GEN B) ++ GEN qfrep0(GEN a, GEN borne, long flag) ++ GEN qfminim0(GEN a, GEN borne, GEN stockmax, long flag, long prec) ++ GEN seralgdep(GEN s, long p, long r) ++ GEN zncoppersmith(GEN P0, GEN N, GEN X, GEN B) + + # bibli2.c + ++ GEN QXQ_reverse(GEN a, GEN T) ++ GEN RgV_polint(GEN X, GEN Y, long v) ++ GEN RgXQ_reverse(GEN a, GEN T) ++ GEN ZV_indexsort(GEN L) ++ long ZV_search(GEN x, GEN y) ++ GEN ZV_sort(GEN L) ++ GEN ZV_sort_uniq(GEN L) ++ GEN ZV_union_shallow(GEN x, GEN y) + GEN binomial(GEN x, long k) ++ GEN binomialuu(ulong n, ulong k) ++ int cmp_nodata(void *data, GEN x, GEN y) + int cmp_prime_ideal(GEN x, GEN y) + int cmp_prime_over_p(GEN x, GEN y) ++ int cmp_RgX(GEN x, GEN y) ++ int cmp_universal(GEN x, GEN y) + GEN convol(GEN x, GEN y) ++ int gen_cmp_RgX(void *data, GEN x, GEN y) + GEN polcyclo(long n, long v) +- GEN polcyclo_eval(long n, GEN v) ++ GEN polcyclo_eval(long n, GEN x) + GEN dirdiv(GEN x, GEN y) + GEN dirmul(GEN x, GEN y) +- GEN dirzetak(GEN nf, GEN b) +- long gen_search(GEN x, GEN y, int flag, int (*cmp)(GEN,GEN)) +- GEN gen_setminus(GEN set1, GEN set2, int (*cmp)(GEN,GEN)) +- GEN gen_sort(GEN x, int flag, int (*cmp)(GEN,GEN)) +- GEN genrand(GEN N) +- GEN getheap() +- GEN getrand() ++ GEN gen_indexsort(GEN x, void *E, int (*cmp)(void*, GEN, GEN)) ++ GEN gen_indexsort_uniq(GEN x, void *E, int (*cmp)(void*, GEN, GEN)) ++ long gen_search(GEN x, GEN y, long flag, void *data, int (*cmp)(void*, GEN, GEN)) ++ GEN gen_setminus(GEN set1, GEN set2, int (*cmp)(GEN, GEN)) ++ GEN gen_sort(GEN x, void *E, int (*cmp)(void*, GEN, GEN)) ++ void gen_sort_inplace(GEN x, void *E, int (*cmp)(void*, GEN, GEN), GEN *perm) ++ GEN gen_sort_uniq(GEN x, void *E, int (*cmp)(void*, GEN, GEN)) + long getstack() + long gettime() ++ long getabstime() + GEN gprec(GEN x, long l) ++ GEN gprec_wtrunc(GEN x, long pr) + GEN gprec_w(GEN x, long pr) +- GEN ggrando(GEN x, long n) + GEN gtoset(GEN x) + GEN indexlexsort(GEN x) + GEN indexsort(GEN x) ++ GEN indexvecsort(GEN x, GEN k) + GEN laplace(GEN x) +- GEN pollegendre(long n, long v) + GEN lexsort(GEN x) + GEN mathilbert(long n) + GEN matqpascal(long n, GEN q) ++ GEN merge_factor(GEN fx, GEN fy, void *data, int (*cmp)(void *, GEN, GEN)) ++ GEN merge_sort_uniq(GEN x, GEN y, void *data, int (*cmp)(void *, GEN, GEN)) ++ GEN modreverse(GEN x) + GEN numtoperm(long n, GEN x) + GEN permtonum(GEN x) ++ GEN polhermite(long n, long v) ++ GEN polhermite_eval(long n, GEN x) ++ GEN pollegendre(long n, long v) ++ GEN pollegendre_eval(long n, GEN x) + GEN polint(GEN xa, GEN ya, GEN x, GEN *dy) ++ GEN polchebyshev(long n, long kind, long v) ++ GEN polchebyshev_eval(long n, long kind, GEN x) ++ GEN polchebyshev1(long n, long v) ++ GEN polchebyshev2(long n, long v) + GEN polrecip(GEN x) +- GEN modreverse(GEN x) +- GEN roots_to_pol(GEN a, long v) ++ GEN setbinop(GEN f, GEN x, GEN y) + GEN setintersect(GEN x, GEN y) + long setisset(GEN x) + GEN setminus(GEN x, GEN y) +- void setrand(GEN seed) + long setsearch(GEN x, GEN y, long flag) + GEN setunion(GEN x, GEN y) +- GEN indexlexsort(GEN x) +- GEN indexsort(GEN x) + GEN sort(GEN x) +- long tablesearch(GEN T, GEN x, int (*cmp)(GEN,GEN)) +- GEN tayl(GEN x, long v, long precdl) +- GEN polchebyshev1(long n, long v) ++ GEN sort_factor(GEN y, void *data, int (*cmp)(void*, GEN, GEN)) ++ GEN stirling(long n, long m, long flag) ++ GEN stirling1(ulong n, ulong m) ++ GEN stirling2(ulong n, ulong m) ++ long tablesearch(GEN T, GEN x, int (*cmp)(GEN, GEN)) ++ GEN vecbinome(long n) ++ long vecsearch(GEN v, GEN x, GEN k) + GEN vecsort(GEN x, GEN k) + GEN vecsort0(GEN x, GEN k, long flag) ++ long zv_search(GEN x, long y) ++ ++ # bit.c ++ ++ GEN binaire(GEN x) ++ long bittest(GEN x, long n) ++ GEN gbitand(GEN x, GEN y) ++ GEN gbitneg(GEN x, long n) ++ GEN gbitnegimply(GEN x, GEN y) ++ GEN gbitor(GEN x, GEN y) ++ GEN gbittest(GEN x, long n) ++ GEN gbitxor(GEN x, GEN y) ++ long hammingweight(GEN n) ++ GEN ibitand(GEN x, GEN y) ++ GEN ibitnegimply(GEN x, GEN y) ++ GEN ibitor(GEN x, GEN y) ++ GEN ibitxor(GEN x, GEN y) + + # buch1.c + +- GEN buchimag(GEN D, GEN gcbach, GEN gcbach2, GEN gCO) +- GEN buchreal(GEN D, GEN gsens, GEN gcbach, GEN gcbach2, GEN gRELSUP, long prec) +- GEN cgetalloc(long t, size_t l) +- GEN quadclassunit0(GEN x, long flag,GEN data, long prec) ++ GEN Buchquad(GEN D, double c1, double c2, long prec) ++ GEN quadclassunit0(GEN x, long flag, GEN data, long prec) + GEN quadhilbert(GEN D, long prec) +- GEN quadray(GEN bnf, GEN f, GEN flag, long prec) ++ GEN quadray(GEN bnf, GEN f, long prec) + + # buch2.c + +- GEN bnfinit0(GEN P,long flag,GEN data,long prec) +- GEN check_and_build_obj(GEN S, int tag, GEN (*build)(GEN)) +- GEN isprincipal(GEN bignf, GEN x) +- GEN bnfisprincipal0(GEN bignf, GEN x,long flall) +- GEN isprincipalfact(GEN bnf,GEN P, GEN e, GEN C, long flag) +- GEN isprincipalforce(GEN bignf,GEN x) +- GEN isprincipalgen(GEN bignf, GEN x) +- GEN isprincipalgenforce(GEN bignf,GEN x) ++ GEN bnfcompress(GEN bnf) ++ GEN bnfinit0(GEN P, long flag, GEN data, long prec) ++ GEN bnfnewprec(GEN nf, long prec) ++ GEN bnfnewprec_shallow(GEN nf, long prec) ++ GEN bnrnewprec(GEN bnr, long prec) ++ GEN bnrnewprec_shallow(GEN bnr, long prec) ++ GEN Buchall(GEN P, long flag, long prec) ++ GEN Buchall_param(GEN P, double bach, double bach2, long nbrelpid, long flun, long prec) ++ GEN isprincipal(GEN bnf, GEN x) ++ GEN bnfisprincipal0(GEN bnf, GEN x, long flall) ++ GEN isprincipalfact(GEN bnf, GEN C, GEN L, GEN f, long flag) ++ GEN isprincipalfact_or_fail(GEN bnf, GEN C, GEN P, GEN e) + GEN bnfisunit(GEN bignf, GEN x) +- GEN regulator(GEN P,GEN data,long prec) + GEN signunits(GEN bignf) ++ GEN nfsign_units(GEN bnf, GEN archp, int add_zu) + + # buch3.c + +- GEN bnrconductor(GEN arg0,GEN arg1,GEN arg2,GEN flag) +- GEN bnrconductorofchar(GEN bnr,GEN chi) +- GEN bnrdisc0(GEN arg0, GEN arg1, GEN arg2, long flag) +- GEN bnrdisclist0(GEN bnf,GEN borne, GEN arch, long all) +- long bnrisconductor(GEN arg0,GEN arg1,GEN arg2) ++ GEN ABC_to_bnr(GEN A, GEN B, GEN C, GEN *H, int gen) ++ GEN Buchray(GEN bnf, GEN module, long flag) ++ GEN bnrclassno(GEN bignf, GEN ideal) ++ GEN bnrclassno0(GEN A, GEN B, GEN C) ++ GEN bnrclassnolist(GEN bnf, GEN listes) ++ GEN bnrconductor0(GEN A, GEN B, GEN C, long flag) ++ GEN bnrconductor(GEN bnr, GEN H0, long flag) ++ GEN bnrconductorofchar(GEN bnr, GEN chi) ++ GEN bnrdisc0(GEN A, GEN B, GEN C, long flag) ++ GEN bnrdisc(GEN bnr, GEN H, long flag) ++ GEN bnrdisclist0(GEN bnf, GEN borne, GEN arch) ++ GEN bnrinit0(GEN bignf, GEN ideal, long flag) ++ long bnrisconductor0(GEN A, GEN B, GEN C) ++ long bnrisconductor(GEN bnr, GEN H) ++ GEN bnrisprincipal(GEN bnf, GEN x, long flag) ++ GEN bnrsurjection(GEN bnr1, GEN bnr2) + GEN buchnarrow(GEN bignf) + long bnfcertify(GEN bnf) +- GEN conductor(GEN bnr,GEN subgroup,long all) ++ long bnfcertify0(GEN bnf, long flag) + GEN decodemodule(GEN nf, GEN fa) +- GEN discrayabs(GEN bnr,GEN subgroup) +- GEN discrayabscond(GEN bnr,GEN subgroup) +- GEN discrayabslist(GEN bnf,GEN listes) +- GEN discrayabslistarch(GEN bnf, GEN arch, long bound) +- GEN discrayabslistlong(GEN bnf, long bound) +- GEN discrayrel(GEN bnr,GEN subgroup) +- GEN discrayrelcond(GEN bnr,GEN subgroup) +- GEN isprincipalray(GEN bignf, GEN x) +- GEN bnrisprincipal(GEN bignf, GEN x,long flall) +- GEN isprincipalraygen(GEN bignf, GEN x) +- GEN bnrclassno(GEN bignf,GEN ideal) +- GEN bnrclassnolist(GEN bnf,GEN listes) +- GEN rnfconductor(GEN bnf, GEN polrel, long flag) ++ GEN discrayabslist(GEN bnf, GEN listes) ++ GEN discrayabslistarch(GEN bnf, GEN arch, ulong bound) ++ GEN discrayabslistlong(GEN bnf, ulong bound) ++ GEN idealmoddivisor(GEN bnr, GEN x) ++ GEN isprincipalray(GEN bnf, GEN x) ++ GEN isprincipalraygen(GEN bnf, GEN x) ++ GEN rnfconductor(GEN bnf, GEN polrel) ++ long rnfisabelian(GEN nf, GEN pol) + GEN rnfnormgroup(GEN bnr, GEN polrel) + GEN subgrouplist0(GEN bnr, GEN indexbound, long all) + +@@ -982,146 +2190,312 @@ cdef extern from 'pari/pari.h': + + GEN bnfisnorm(GEN bnf, GEN x, long flag) + GEN rnfisnorm(GEN S, GEN x, long flag) +- GEN rnfisnorminit(GEN T, GEN relpol, int galois) +- GEN bnfissunit(GEN bnf,GEN suni,GEN x) +- GEN bnfsunit(GEN bnf,GEN s,long PREC) +- long nfhilbert(GEN bnf,GEN a,GEN b) +- long nfhilbert0(GEN bnf,GEN a,GEN b,GEN p) ++ GEN rnfisnorminit(GEN bnf, GEN relpol, int galois) ++ GEN bnfissunit(GEN bnf, GEN suni, GEN x) ++ GEN bnfsunit(GEN bnf, GEN s, long PREC) ++ long nfhilbert(GEN bnf, GEN a, GEN b) ++ long nfhilbert0(GEN bnf, GEN a, GEN b, GEN p) ++ long hyperell_locally_soluble(GEN pol, GEN p) ++ long nf_hyperell_locally_soluble(GEN nf, GEN pol, GEN p) + + # compile.c + ++ GEN closure_deriv(GEN G) ++ long localvars_find(GEN pack, entree *ep) ++ GEN localvars_read_str(const char *str, GEN pack) ++ GEN snm_closure(entree *ep, GEN data) ++ GEN strtoclosure(const char *s, long n, ...) + GEN strtofunction(const char *s) + ++ # concat.c ++ ++ GEN concat(GEN x, GEN y) ++ GEN concat1(GEN x) ++ GEN matconcat(GEN v) ++ GEN shallowconcat(GEN x, GEN y) ++ GEN shallowconcat1(GEN x) ++ GEN shallowmatconcat(GEN v) ++ GEN vconcat(GEN A, GEN B) ++ + # default.c + + extern int d_SILENT, d_ACKNOWLEDGE, d_INITRC, d_RETURN +- GEN default0(char *a, char *b) +- long getrealprecision() +- GEN sd_TeXstyle(char *v, long flag) +- GEN sd_breakloop(char *v, long flag) +- GEN sd_colors(char *v, long flag) +- GEN sd_compatible(char *v, long flag) +- GEN sd_datadir(char *v, long flag) +- GEN sd_debug(char *v, long flag) +- GEN sd_debugfiles(char *v, long flag) +- GEN sd_debugmem(char *v, long flag) +- GEN sd_echo(char *v, long flag) +- GEN sd_factor_add_primes(char *v, long flag) +- GEN sd_factor_proven(char *v, long flag) +- GEN sd_format(char *v, long flag) +- GEN sd_graphcolormap(char *v, long flag) +- GEN sd_graphcolors(char *v, long flag) +- GEN sd_help(char *v, long flag) +- GEN sd_histsize(char *v, long flag) +- GEN sd_lines(char *v, long flag) +- GEN sd_log(char *v, long flag) +- GEN sd_logfile(char *v, long flag) +- GEN sd_new_galois_format(char *v, long flag) +- GEN sd_output(char *v, long flag) +- GEN sd_parisize(char *v, long flag) +- GEN sd_path(char *v, long flag) +- GEN sd_prettyprinter(char *v, long flag) +- GEN sd_primelimit(char *v, long flag) +- GEN sd_prompt(char *v, long flag) +- GEN sd_prompt_cont(char *v, long flag) +- GEN sd_psfile(char *v, long flag) +- GEN sd_realprecision(char *v, long flag) +- GEN sd_recover(char *v, long flag) +- GEN sd_rl(char *v, long flag) +- GEN sd_secure(char *v, long flag) +- GEN sd_seriesprecision(char *v, long flag) +- GEN sd_simplify(char *v, long flag) +- GEN sd_strictmatch(char *v, long flag) +- GEN sd_timer(char *v, long flag) +- long setrealprecision(long n, long *prec) ++ ++ GEN default0(const char *a, char *b) ++ long getrealprecision() ++ int pari_is_default(const char *s) ++ GEN sd_TeXstyle(const char *v, long flag) ++ GEN sd_colors(const char *v, long flag) ++ GEN sd_compatible(const char *v, long flag) ++ GEN sd_datadir(const char *v, long flag) ++ GEN sd_debug(const char *v, long flag) ++ GEN sd_debugfiles(const char *v, long flag) ++ GEN sd_debugmem(const char *v, long flag) ++ GEN sd_factor_add_primes(const char *v, long flag) ++ GEN sd_factor_proven(const char *v, long flag) ++ GEN sd_format(const char *v, long flag) ++ GEN sd_histsize(const char *v, long flag) ++ GEN sd_log(const char *v, long flag) ++ GEN sd_logfile(const char *v, long flag) ++ GEN sd_nbthreads(const char *v, long flag) ++ GEN sd_new_galois_format(const char *v, long flag) ++ GEN sd_output(const char *v, long flag) ++ GEN sd_parisize(const char *v, long flag) ++ GEN sd_path(const char *v, long flag) ++ GEN sd_prettyprinter(const char *v, long flag) ++ GEN sd_primelimit(const char *v, long flag) ++ GEN sd_realprecision(const char *v, long flag) ++ GEN sd_secure(const char *v, long flag) ++ GEN sd_seriesprecision(const char *v, long flag) ++ GEN sd_simplify(const char *v, long flag) ++ GEN sd_sopath(char *v, int flag) ++ GEN sd_strictargs(const char *v, long flag) ++ GEN sd_strictmatch(const char *v, long flag) ++ GEN sd_string(const char *v, long flag, char *s, char **f) ++ GEN sd_threadsize(const char *v, long flag) ++ GEN sd_toggle(const char *v, long flag, char *s, int *ptn) ++ GEN sd_ulong(const char *v, long flag, char *s, ulong *ptn, ulong Min, ulong Max, char **msg) ++ GEN setdefault(const char *s, char *v, long flag) ++ long setrealprecision(long n, long *prec) + + # ellanal.c + + GEN ellanalyticrank(GEN e, GEN eps, long prec) + GEN ellL1(GEN e, long r, long prec) + ++ # elldata.c ++ ++ GEN ellconvertname(GEN s) ++ GEN elldatagenerators(GEN E) ++ GEN ellidentify(GEN E) ++ GEN ellsearch(GEN A) ++ GEN ellsearchcurve(GEN name) ++ void forell(void *E, long call(void*, GEN), long a, long b) ++ + # elliptic.c + +- GEN addell(GEN e, GEN z1, GEN z2) ++ extern int t_ELL_Rg, t_ELL_Q, t_ELL_Qp, t_ELL_Fp, t_ELL_Fq + GEN akell(GEN e, GEN n) + GEN anell(GEN e, long n) +- GEN ellap(GEN e, GEN p) ++ GEN anellsmall(GEN e, long n) + GEN bilhell(GEN e, GEN z1, GEN z2, long prec) ++ void checkell(GEN e) ++ void checkell_Fq(GEN e) ++ void checkell_Q(GEN e) ++ void checkell_Qp(GEN e) ++ void checkellpt(GEN z) ++ void checkell5(GEN e) ++ GEN ellanal_globalred(GEN e, GEN *gr) ++ GEN ellQ_get_N(GEN e) ++ void ellQ_get_Nfa(GEN e, GEN *N, GEN *faN) ++ GEN ellQp_Tate_uniformization(GEN E, long prec) ++ GEN ellQp_u(GEN E, long prec) ++ GEN ellQp_u2(GEN E, long prec) ++ GEN ellQp_q(GEN E, long prec) ++ GEN ellQp_ab(GEN E, long prec) ++ GEN ellQp_root(GEN E, long prec) ++ GEN ellR_ab(GEN E, long prec) ++ GEN ellR_eta(GEN E, long prec) ++ GEN ellR_omega(GEN x, long prec) ++ GEN ellR_roots(GEN E, long prec) ++ GEN elladd(GEN e, GEN z1, GEN z2) ++ GEN ellap(GEN e, GEN p) ++ GEN ellcard(GEN E, GEN p) + GEN ellchangecurve(GEN e, GEN ch) +- GEN ellap0(GEN e, GEN p, long flag) ++ GEN elldivpol(GEN e, long n, long v) + GEN elleisnum(GEN om, long k, long flag, long prec) + GEN elleta(GEN om, long prec) +- GEN ellheight0(GEN e, GEN a, long flag,long prec) +- GEN ellinit0(GEN x,long flag,long prec) ++ GEN ellff_get_card(GEN E) ++ GEN ellff_get_gens(GEN E) ++ GEN ellff_get_group(GEN E) ++ GEN ellff_get_o(GEN x) ++ GEN ellff_get_p(GEN E) ++ GEN ellfromj(GEN j) ++ GEN ellgenerators(GEN E) ++ GEN ellglobalred(GEN e1) ++ GEN ellgroup(GEN E, GEN p) ++ GEN ellgroup0(GEN E, GEN p, long flag) ++ GEN ellheight0(GEN e, GEN a, long flag, long prec) ++ GEN ellheegner(GEN e) ++ GEN ellinit(GEN x, GEN p, long prec) ++ GEN ellisoncurve(GEN e, GEN z) ++ GEN elllseries(GEN e, GEN s, GEN A, long prec) ++ GEN elllocalred(GEN e, GEN p1) ++ GEN elllog(GEN e, GEN a, GEN g, GEN o) + GEN ellminimalmodel(GEN E, GEN *ptv) ++ GEN ellmul(GEN e, GEN z, GEN n) ++ GEN ellneg(GEN e, GEN z) ++ GEN ellorder(GEN e, GEN p, GEN o) ++ GEN ellordinate(GEN e, GEN x, long prec) ++ GEN ellperiods(GEN w, long flag, long prec) ++ GEN ellrandom(GEN e) + long ellrootno(GEN e, GEN p) ++ long ellrootno_global(GEN e) + GEN ellsigma(GEN om, GEN z, long flag, long prec) ++ GEN ellsub(GEN e, GEN z1, GEN z2) ++ GEN elltaniyama(GEN e, long prec) ++ GEN elltatepairing(GEN E, GEN t, GEN s, GEN m) + GEN elltors0(GEN e, long flag) +- GEN ellwp0(GEN e, GEN z, long flag, long precdl, long prec) ++ GEN ellweilpairing(GEN E, GEN t, GEN s, GEN m) ++ GEN ellwp(GEN w, GEN z, long prec) ++ GEN ellwp0(GEN w, GEN z, long flag, long prec) ++ GEN ellwpseries(GEN e, long v, long PRECDL) + GEN ellzeta(GEN om, GEN z, long prec) ++ GEN ellchangeinvert(GEN w) ++ GEN ellchangepoint(GEN x, GEN ch) ++ GEN ellchangepointinv(GEN x, GEN ch) ++ GEN elltors(GEN e) ++ GEN expIxy(GEN x, GEN y, long prec) ++ GEN genus2red(GEN Q, GEN P, GEN p) + GEN ghell(GEN e, GEN a, long prec) +- GEN ellglobalred(GEN e1) +- GEN elllocalred(GEN e, GEN p1) +- GEN elllseries(GEN e, GEN s, GEN A, long prec) + GEN mathell(GEN e, GEN x, long prec) + int oncurve(GEN e, GEN z) +- GEN ellordinate(GEN e, GEN x, long prec) + GEN orderell(GEN e, GEN p) +- GEN ellchangepoint(GEN x, GEN ch) + GEN pointell(GEN e, GEN z, long prec) +- GEN powell(GEN e, GEN z, GEN n) +- GEN subell(GEN e, GEN z1, GEN z2) +- GEN taniyama(GEN e) +- GEN weipell(GEN e, long precdl) + GEN zell(GEN e, GEN z, long prec) + ++ # ellsea.c ++ ++ GEN Fp_ellcard_SEA(GEN a4, GEN a6, GEN p, long early_abort) ++ GEN Fq_ellcard_SEA(GEN a4, GEN a6, GEN q, GEN T, GEN p, long early_abort) ++ GEN ellmodulareqn(long l, long vx, long vy) ++ GEN ellsea(GEN E, GEN p, long early_abort) ++ + # es.c + ++ GEN GENtoGENstr_nospace(GEN x) + GEN GENtoGENstr(GEN x) + char* GENtoTeXstr(GEN x) + char* GENtostr(GEN x) ++ char* GENtostr_unquoted(GEN x) + GEN Str(GEN g) + GEN Strchr(GEN g) + GEN Strexpand(GEN g) + GEN Strtex(GEN g) + void brute(GEN g, char format, long dec) + void dbgGEN(GEN x, long nb) ++ void error0(GEN g) ++ void dbg_pari_heap() + int file_is_binary(FILE *f) +- void gpwritebin(char *filename, GEN x) +- GEN gp_read_file(char *filename) +- GEN gp_read_str(char *s) +- void killallfiles(int check) ++ void err_flush() ++ void err_printf(const char* pat, ...) ++ GEN gp_getenv(const char *s) ++ GEN gp_read_file(char *s) + GEN gp_read_stream(FILE *f) ++ GEN gp_readvec_file(char *s) ++ GEN gp_readvec_stream(FILE *f) ++ void gpinstall(const char *s, char *code, ++ char *gpname, char *lib) ++ GEN gsprintf(const char *fmt, ...) ++ GEN gvsprintf(const char *fmt, va_list ap) ++ char* itostr(GEN x) + void matbrute(GEN g, char format, long dec) +- char* os_getenv(char *s) ++ char* os_getenv(const char *s) + void (*os_signal(int sig, void (*f)(int)))(int) + void outmat(GEN x) + void output(GEN x) +- char* pari_strdup(char *s) +- char* pari_strndup(char *s, long n) +- char* pari_unique_filename(char *s) +- void pari_unlink(char *s) ++ char* RgV_to_str(GEN g, long flag) ++ void pari_add_hist(GEN z, long t) ++ void pari_ask_confirm(const char *s) ++ void pari_fclose(pariFILE *f) + void pari_flush() +- void pari_putc(char c) +- void pari_puts(char *s) ++ pariFILE* pari_fopen(const char *s, char *mode) ++ pariFILE* pari_fopen_or_fail(const char *s, char *mode) ++ pariFILE* pari_fopengz(const char *s) ++ void pari_fprintf(FILE *file, char *fmt, ...) ++ void pari_fread_chars(void *b, size_t n, FILE *f) ++ GEN pari_get_hist(long p) ++ long pari_get_histtime(long p) ++ char* pari_get_homedir(const char *user) ++ int pari_is_dir(const char *name) ++ int pari_is_file(const char *name) + int pari_last_was_newline() + void pari_set_last_newline(int last) +- #void print(GEN g) # syntax error ++ ulong pari_nb_hist() ++ void pari_printf(const char *fmt, ...) ++ void pari_putc(char c) ++ void pari_puts(const char *s) ++ pariFILE* pari_safefopen(const char *s, char *mode) ++ char* pari_sprintf(const char *fmt, ...) ++ int pari_stdin_isatty() ++ char* pari_strdup(const char *s) ++ char* pari_strndup(const char *s, long n) ++ char* pari_unique_dir(const char *s) ++ char* pari_unique_filename(const char *s) ++ void pari_unlink(const char *s) ++ void pari_vfprintf(FILE *file, char *fmt, va_list ap) ++ void pari_vprintf(const char *fmt, va_list ap) ++ char* pari_vsprintf(const char *fmt, va_list ap) ++ char* path_expand(const char *s) ++ void out_print0(PariOUT *out, char *sep, GEN g, long flag) ++ void out_printf(PariOUT *out, char *fmt, ...) ++ void out_putc(PariOUT *out, char c) ++ void out_puts(PariOUT *out, char *s) ++ void out_term_color(PariOUT *out, long c) ++ void out_vprintf(PariOUT *out, char *fmt, va_list ap) ++ char* pari_sprint0(const char *msg, GEN g, long flag) ++ #void print(GEN g) ++ extern int f_RAW, f_PRETTYMAT, f_PRETTY, f_TEX ++ void print0(GEN g, long flag) + void print1(GEN g) ++ void printf0(const char *fmt, GEN args) ++ void printsep(const char *s, GEN g, long flag) ++ void printsep1(const char *s, GEN g, long flag) + void printtex(GEN g) +- GEN readbin(char *name, FILE *f) +- void switchin(char *name) +- void switchout(char *name) ++ char* stack_sprintf(const char *fmt, ...) ++ char* stack_strcat(const char *s, char *t) ++ char* stack_strdup(const char *s) ++ void strftime_expand(const char *s, char *buf, long max) ++ GEN Strprintf(const char *fmt, GEN args) ++ FILE* switchin(const char *name) ++ void switchout(const char *name) ++ void term_color(long c) ++ char* term_get_color(char *s, long c) + void texe(GEN g, char format, long dec) +- char* type_name(long t) +- void write0(char *s, GEN g) +- void write1(char *s, GEN g) +- void writetex(char *s, GEN g) ++ char* type_name(long t) ++ void warning0(GEN g) ++ void write0(const char *s, GEN g) ++ void write1(const char *s, GEN g) ++ void writebin(const char *name, GEN x) ++ void writetex(const char *s, GEN g) + + # eval.c + ++ extern int br_NONE, br_BREAK, br_NEXT, br_MULTINEXT, br_RETURN ++ void bincopy_relink(GEN C, GEN vi) ++ GEN break0(long n) + GEN closure_callgen1(GEN C, GEN x) ++ GEN closure_callgen2(GEN C, GEN x, GEN y) ++ GEN closure_callgenall(GEN C, long n, ...) + GEN closure_callgenvec(GEN C, GEN args) ++ void closure_callvoid1(GEN C, GEN x) ++ long closure_context(long start, long level) ++ void closure_disassemble(GEN n) ++ void closure_err(long level) ++ GEN closure_evalbrk(GEN C, long *status) ++ GEN closure_evalgen(GEN C) ++ GEN closure_evalnobrk(GEN C) ++ GEN closure_evalres(GEN C) ++ void closure_evalvoid(GEN C) ++ GEN closure_trapgen(GEN C, long numerr) ++ GEN copybin_unlink(GEN C) ++ GEN get_lex(long vn) ++ GEN gp_call(void *E, GEN x) ++ long gp_callbool(void *E, GEN x) ++ long gp_callvoid(void *E, GEN x) ++ GEN gp_eval(void *E, GEN x) ++ long gp_evalbool(void *E, GEN x) ++ GEN gp_evalupto(void *E, GEN x) ++ long gp_evalvoid(void *E, GEN x) ++ long loop_break() ++ GEN next0(long n) ++ GEN pareval(GEN C) ++ GEN parsum(GEN a, GEN b, GEN code, GEN x) ++ GEN parvector(long n, GEN code) ++ void pop_lex(long n) ++ void push_lex(GEN a, GEN C) ++ GEN return0(GEN x) ++ void set_lex(long vn, GEN x) + + # FF.c + +@@ -1132,12 +2506,22 @@ cdef extern from 'pari/pari.h': + GEN FF_Z_mul(GEN a, GEN b) + GEN FF_add(GEN a, GEN b) + GEN FF_charpoly(GEN x) +- int FF_equal0(GEN x) +- int FF_equal1(GEN x) +- int FF_equalm1(GEN x) + GEN FF_conjvec(GEN x) + GEN FF_div(GEN a, GEN b) ++ GEN FF_ellcard(GEN E) ++ GEN FF_ellgens(GEN E) ++ GEN FF_ellgroup(GEN E) ++ GEN FF_elllog(GEN E, GEN P, GEN Q, GEN o) ++ GEN FF_ellmul(GEN E, GEN P, GEN n) ++ GEN FF_ellorder(GEN E, GEN P, GEN o) ++ GEN FF_ellrandom(GEN E) ++ GEN FF_elltatepairing(GEN E, GEN P, GEN Q, GEN m) ++ GEN FF_ellweilpairing(GEN E, GEN P, GEN Q, GEN m) + int FF_equal(GEN a, GEN b) ++ int FF_equal0(GEN x) ++ int FF_equal1(GEN x) ++ int FF_equalm1(GEN x) ++ long FF_f(GEN x) + GEN FF_inv(GEN a) + long FF_issquare(GEN x) + long FF_issquareall(GEN x, GEN *pt) +@@ -1155,15 +2539,27 @@ cdef extern from 'pari/pari.h': + GEN FF_p_i(GEN x) + GEN FF_pow(GEN x, GEN n) + GEN FF_primroot(GEN x, GEN *o) ++ GEN FF_q(GEN x) + int FF_samefield(GEN x, GEN y) + GEN FF_sqr(GEN a) + GEN FF_sqrt(GEN a) + GEN FF_sqrtn(GEN x, GEN n, GEN *zetan) + GEN FF_sub(GEN x, GEN y) ++ GEN FF_to_F2xq(GEN x) ++ GEN FF_to_F2xq_i(GEN x) ++ GEN FF_to_Flxq(GEN x) ++ GEN FF_to_Flxq_i(GEN x) + GEN FF_to_FpXQ(GEN x) + GEN FF_to_FpXQ_i(GEN x) + GEN FF_trace(GEN x) + GEN FF_zero(GEN a) ++ GEN FFM_FFC_mul(GEN M, GEN C, GEN ff) ++ GEN FFM_det(GEN M, GEN ff) ++ GEN FFM_image(GEN M, GEN ff) ++ GEN FFM_inv(GEN M, GEN ff) ++ GEN FFM_ker(GEN M, GEN ff) ++ GEN FFM_mul(GEN M, GEN N, GEN ff) ++ long FFM_rank(GEN M, GEN ff) + GEN FFX_factor(GEN f, GEN x) + GEN FFX_roots(GEN f, GEN x) + GEN Z_FF_div(GEN a, GEN b) +@@ -1172,11 +2568,19 @@ cdef extern from 'pari/pari.h': + GEN fforder(GEN x, GEN o) + GEN ffprimroot(GEN x, GEN *o) + GEN ffrandom(GEN ff) +- int is_Z_factor(GEN f) ++ int Rg_is_FF(GEN c, GEN *ff) ++ int RgC_is_FFC(GEN x, GEN *ff) ++ int RgM_is_FFM(GEN x, GEN *ff) ++ GEN p_to_FF(GEN p, long v) + + # galconj.c + + GEN checkgal(GEN gal) ++ GEN checkgroup(GEN g, GEN *S) ++ GEN embed_disc(GEN r, long r1, long prec) ++ GEN embed_roots(GEN r, long r1) ++ GEN galois_group(GEN gal) ++ GEN galoisconj(GEN nf, GEN d) + GEN galoisconj0(GEN nf, long flag, GEN d, long prec) + GEN galoisexport(GEN gal, long format) + GEN galoisfixedfield(GEN gal, GEN v, long flag, long y) +@@ -1191,113 +2595,174 @@ cdef extern from 'pari/pari.h': + GEN vandermondeinverse(GEN L, GEN T, GEN den, GEN prep) + + # gen1.c +- ++ GEN conjvec(GEN x, long prec) + GEN gadd(GEN x, GEN y) + GEN gaddsg(long x, GEN y) ++ GEN gconj(GEN x) + GEN gdiv(GEN x, GEN y) ++ GEN gdivgs(GEN x, long s) ++ GEN ginv(GEN x) + GEN gmul(GEN x, GEN y) ++ GEN gmul2n(GEN x, long n) ++ GEN gmulsg(long s, GEN y) + GEN gsqr(GEN x) + GEN gsub(GEN x, GEN y) ++ GEN gsubsg(long x, GEN y) ++ GEN inv_ser(GEN b) ++ GEN mulcxI(GEN x) ++ GEN mulcxmI(GEN x) ++ GEN ser_normalize(GEN x) ++ ++ # galpol.c ++ ++ GEN galoisnbpol(long a) ++ GEN galoisgetpol(long a, long b, long s) + + # gen2.c + +- GEN ZX_mul(GEN x, GEN y) ++ GEN gassoc_proto(GEN f(GEN, GEN), GEN, GEN) ++ GEN map_proto_G(GEN f(GEN), GEN x) ++ GEN map_proto_lG(long f(GEN), GEN x) ++ GEN map_proto_lGL(long f(GEN, long), GEN x, long y) ++ ++ long Q_pval(GEN x, GEN p) ++ long Q_pvalrem(GEN x, GEN p, GEN *y) ++ long RgX_val(GEN x) ++ long RgX_valrem(GEN x, GEN *z) ++ long RgX_valrem_inexact(GEN x, GEN *Z) ++ int ZV_Z_dvd(GEN v, GEN p) ++ long ZV_pval(GEN x, GEN p) ++ long ZV_pvalrem(GEN x, GEN p, GEN *px) ++ long ZV_lval(GEN x, ulong p) ++ long ZV_lvalrem(GEN x, ulong p, GEN *px) ++ long ZX_lvalrem(GEN x, ulong p, GEN *px) ++ long ZX_lval(GEN x, ulong p) ++ long ZX_pval(GEN x, GEN p) ++ long ZX_pvalrem(GEN x, GEN p, GEN *px) ++ long Z_lval(GEN n, ulong p) ++ long Z_lvalrem(GEN n, ulong p, GEN *py) ++ long Z_lvalrem_stop(GEN *n, ulong p, int *stop) ++ long Z_pval(GEN n, GEN p) ++ long Z_pvalrem(GEN x, GEN p, GEN *py) + GEN cgetp(GEN x) ++ GEN cvstop2(long s, GEN y) + GEN cvtop(GEN x, GEN p, long l) + GEN cvtop2(GEN x, GEN y) + GEN gabs(GEN x, long prec) + void gaffect(GEN x, GEN y) + void gaffsg(long s, GEN x) +- GEN gclone(GEN x) + int gcmp(GEN x, GEN y) +- int gcmpsg(long x, GEN y) + int gequal0(GEN x) + int gequal1(GEN x) ++ int gequalX(GEN x) + int gequalm1(GEN x) ++ int gcmpsg(long x, GEN y) + GEN gcvtop(GEN x, GEN p, long r) + int gequal(GEN x, GEN y) + int gequalsg(long s, GEN x) + long gexpo(GEN x) +- long ggval(GEN x, GEN p) ++ long gvaluation(GEN x, GEN p) ++ int gidentical(GEN x, GEN y) + long glength(GEN x) + GEN gmax(GEN x, GEN y) ++ GEN gmaxgs(GEN x, long y) + GEN gmin(GEN x, GEN y) ++ GEN gmings(GEN x, long y) + GEN gneg(GEN x) + GEN gneg_i(GEN x) +- GEN greffe(GEN x, long l, long use_stack) ++ GEN RgX_to_ser(GEN x, long l) ++ GEN RgX_to_ser_inexact(GEN x, long l) + int gsigne(GEN x) +- GEN gtofp(GEN z, long prec) + GEN gtolist(GEN x) + long gtolong(GEN x) + int lexcmp(GEN x, GEN y) +- GEN listcreate() + GEN listinsert(GEN list, GEN object, long index) +- void listkill(GEN list) ++ void listpop(GEN L, long index) + GEN listput(GEN list, GEN object, long index) +- GEN listsort(GEN list, long flag) ++ void listsort(GEN list, long flag) + GEN matsize(GEN x) ++ GEN mklistcopy(GEN x) + GEN normalize(GEN x) + GEN normalizepol(GEN x) ++ GEN normalizepol_approx(GEN x, long lx) ++ GEN normalizepol_lg(GEN x, long lx) ++ ulong padic_to_Fl(GEN x, ulong p) ++ GEN padic_to_Fp(GEN x, GEN Y) ++ GEN quadtofp(GEN x, long l) ++ GEN rfrac_to_ser(GEN x, long l) + long sizedigit(GEN x) + long u_lval(ulong x, ulong p) + long u_lvalrem(ulong x, ulong p, ulong *py) ++ long u_lvalrem_stop(ulong *n, ulong p, int *stop) ++ long u_pval(ulong x, GEN p) + long u_pvalrem(ulong x, GEN p, ulong *py) ++ long vecindexmax(GEN x) ++ long vecindexmin(GEN x) ++ GEN vecmax0(GEN x, GEN *pv) + GEN vecmax(GEN x) ++ GEN vecmin0(GEN x, GEN *pv) + GEN vecmin(GEN x) +- long Z_lval(GEN n, ulong p) +- long Z_lvalrem(GEN n, ulong p, GEN *py) ++ long z_lval(long s, ulong p) ++ long z_lvalrem(long s, ulong p, long *py) + long z_pval(long n, GEN p) +- long Z_pval(GEN n, GEN p) +- long Z_pvalrem(GEN x, GEN p, GEN *py) ++ long z_pvalrem(long n, GEN p, long *py) + + # gen3.c + ++ GEN padic_to_Q(GEN x) ++ GEN padic_to_Q_shallow(GEN x) ++ GEN QpV_to_QV(GEN v) ++ GEN RgM_mulreal(GEN x, GEN y) ++ GEN RgX_RgM_eval_col(GEN x, GEN M, long c) ++ GEN RgX_deflate_max(GEN x0, long *m) ++ GEN RgX_integ(GEN x) + GEN ceil_safe(GEN x) + GEN ceilr(GEN x) + GEN centerlift(GEN x) +- GEN centerlift0(GEN x,long v) ++ GEN centerlift0(GEN x, long v) + GEN compo(GEN x, long n) +- GEN deg1pol(GEN x1, GEN x0,long v) ++ GEN deg1pol(GEN x1, GEN x0, long v) ++ GEN deg1pol_shallow(GEN x1, GEN x0, long v) + long degree(GEN x) + GEN denom(GEN x) + GEN deriv(GEN x, long v) +- GEN RgX_deriv(GEN x) + GEN derivser(GEN x) ++ GEN diffop(GEN x, GEN v, GEN dv) ++ GEN diffop0(GEN x, GEN v, GEN dv, long n) + GEN diviiround(GEN x, GEN y) + GEN divrem(GEN x, GEN y, long v) +- GEN gand(GEN x, GEN y) ++ GEN floor_safe(GEN x) + GEN gceil(GEN x) + GEN gcvtoi(GEN x, long *e) ++ GEN gdeflate(GEN x, long v, long d) + GEN gdivent(GEN x, GEN y) ++ GEN gdiventgs(GEN x, long y) ++ GEN gdiventsg(long x, GEN y) + GEN gdiventres(GEN x, GEN y) +- GEN gdivgs(GEN x, long s) + GEN gdivmod(GEN x, GEN y, GEN *pr) + GEN gdivround(GEN x, GEN y) ++ int gdvd(GEN x, GEN y) + GEN geq(GEN x, GEN y) + GEN geval(GEN x) + GEN gfloor(GEN x) ++ GEN gtrunc2n(GEN x, long s) + GEN gfrac(GEN x) + GEN gge(GEN x, GEN y) + GEN ggrando(GEN x, long n) + GEN ggt(GEN x, GEN y) + GEN gimag(GEN x) +- GEN ginv(GEN x) + GEN gle(GEN x, GEN y) + GEN glt(GEN x, GEN y) + GEN gmod(GEN x, GEN y) +- GEN gmodulo(GEN x,GEN y) + GEN gmodgs(GEN x, long y) +- GEN gmodulo(GEN x,GEN y) ++ GEN gmodsg(long x, GEN y) ++ GEN gmodulo(GEN x, GEN y) + GEN gmodulsg(long x, GEN y) + GEN gmodulss(long x, long y) +- GEN gmul2n(GEN x, long n) +- GEN gmulsg(long s, GEN y) + GEN gne(GEN x, GEN y) + GEN gnot(GEN x) +- GEN gor(GEN x, GEN y) + GEN gpolvar(GEN y) + long gprecision(GEN x) +- GEN gram_matrix(GEN M) + GEN greal(GEN x) + GEN grndtoi(GEN x, long *e) + GEN ground(GEN x) +@@ -1307,6 +2772,8 @@ cdef extern from 'pari/pari.h': + GEN gsubstvec(GEN x, GEN v, GEN y) + GEN gtocol(GEN x) + GEN gtocol0(GEN x, long n) ++ GEN gtocolrev(GEN x) ++ GEN gtocolrev0(GEN x, long n) + GEN gtopoly(GEN x, long v) + GEN gtopolyrev(GEN x, long v) + GEN gtoser(GEN x, long v, long precdl) +@@ -1317,106 +2784,288 @@ cdef extern from 'pari/pari.h': + GEN gtovecsmall(GEN x) + GEN gtovecsmall0(GEN x, long n) + GEN gtrunc(GEN x) +- int gvar(GEN x) +- int gvar2(GEN x) ++ long gvar(GEN x) ++ long gvar2(GEN x) + GEN hqfeval(GEN q, GEN x) + GEN imag_i(GEN x) +- GEN int2n(long n) + GEN integ(GEN x, long v) ++ GEN integser(GEN x) + int iscomplex(GEN x) + int isexactzero(GEN g) ++ int isrationalzeroscalar(GEN g) + int isinexact(GEN x) + int isinexactreal(GEN x) +- long isint(GEN n, long *ptk) ++ int isint(GEN n, GEN *ptk) ++ int isrationalzero(GEN g) + int issmall(GEN n, long *ptk) + GEN lift(GEN x) +- GEN lift0(GEN x,long v) +- GEN lift_intern0(GEN x,long v) +- GEN truncr(GEN x) ++ GEN lift0(GEN x, long v) ++ GEN liftall(GEN x) ++ GEN liftall_shallow(GEN x) ++ GEN liftint(GEN x) ++ GEN liftint_shallow(GEN x) ++ GEN liftpol(GEN x) ++ GEN liftpol_shallow(GEN x) + GEN mkcoln(long n, ...) + GEN mkintn(long n, ...) + GEN mkpoln(long n, ...) + GEN mkvecn(long n, ...) ++ GEN mkvecsmalln(long n, ...) ++ GEN mulreal(GEN x, GEN y) + GEN numer(GEN x) +- GEN padicappr(GEN f, GEN a) + long padicprec(GEN x, GEN p) +- GEN polcoeff0(GEN x,long n,long v) ++ long padicprec_relative(GEN x) ++ GEN polcoeff0(GEN x, long n, long v) + GEN polcoeff_i(GEN x, long n, long v) +- long poldegree(GEN x,long v) ++ long poldegree(GEN x, long v) ++ long RgX_degree(GEN x, long v) + GEN poleval(GEN x, GEN y) +- GEN pollead(GEN x,long v) ++ GEN pollead(GEN x, long v) + long precision(GEN x) +- GEN precision0(GEN x,long n) ++ GEN precision0(GEN x, long n) ++ GEN qf_apply_RgM(GEN q, GEN M) ++ GEN qf_apply_ZM(GEN q, GEN M) ++ GEN qfbil(GEN x, GEN y, GEN q) + GEN qfeval(GEN q, GEN x) ++ GEN qfevalb(GEN q, GEN x, GEN y) ++ GEN qfnorm(GEN x, GEN q) + GEN real_i(GEN x) +- GEN real2n(long n, long prec) +- GEN recip(GEN x) + GEN round0(GEN x, GEN *pte) + GEN roundr(GEN x) ++ GEN roundr_safe(GEN x) + GEN scalarpol(GEN x, long v) ++ GEN scalarpol_shallow(GEN x, long v) + GEN scalarser(GEN x, long v, long prec) ++ GEN ser_unscale(GEN P, GEN h) ++ GEN serreverse(GEN x) + GEN simplify(GEN x) ++ GEN simplify_shallow(GEN x) + GEN tayl(GEN x, long v, long precdl) + GEN toser_i(GEN x) + GEN trunc0(GEN x, GEN *pte) ++ GEN uu32toi(ulong a, ulong b) + + # groupid.c + + long group_ident(GEN G, GEN S) ++ long group_ident_trans(GEN G, GEN S) + + # hash.c + +- ulong hash_GEN(GEN x) ++ hashtable *hash_create(ulong minsize, ulong (*hash)(void*), int (*eq)(void*, void*), int use_stack) ++ void hash_insert(hashtable *h, void *k, void *v) ++ hashentry *hash_search(hashtable *h, void *k) ++ hashentry *hash_remove(hashtable *h, void *k) ++ void hash_destroy(hashtable *h) ++ ulong hash_str(const char *str) ++ ulong hash_str2(const char *s) ++ ulong hash_GEN(GEN x) ++ ++ # hnf_snf.c ++ ++ GEN Frobeniusform(GEN V, long n) ++ GEN RgM_hnfall(GEN A, GEN *pB, long remove) ++ GEN ZM_hnf(GEN x) ++ GEN ZM_hnfall(GEN A, GEN *ptB, long remove) ++ GEN ZM_hnfcenter(GEN M) ++ GEN ZM_hnflll(GEN A, GEN *ptB, int remove) ++ GEN ZV_gcdext(GEN A) ++ GEN ZM_hnfmod(GEN x, GEN d) ++ GEN ZM_hnfmodall(GEN x, GEN dm, long flag) ++ GEN ZM_hnfmodid(GEN x, GEN d) ++ GEN ZM_hnfperm(GEN A, GEN *ptU, GEN *ptperm) ++ void ZM_snfclean(GEN d, GEN u, GEN v) ++ GEN ZM_snf(GEN x) ++ GEN ZM_snf_group(GEN H, GEN *newU, GEN *newUi) ++ GEN ZM_snfall(GEN x, GEN *ptU, GEN *ptV) ++ GEN ZM_snfall_i(GEN x, GEN *ptU, GEN *ptV, int return_vec) ++ GEN zlm_echelon(GEN x, long early_abort, ulong p, ulong pm) ++ GEN ZpM_echelon(GEN x, long early_abort, GEN p, GEN pm) ++ GEN gsmith(GEN x) ++ GEN gsmithall(GEN x) ++ GEN hnf(GEN x) ++ GEN hnf_divscale(GEN A, GEN B, GEN t) ++ GEN hnf_solve(GEN A, GEN B) ++ GEN hnf_invimage(GEN A, GEN b) ++ GEN hnfall(GEN x) ++ int hnfdivide(GEN A, GEN B) ++ GEN hnflll(GEN x) ++ GEN hnfmerge_get_1(GEN A, GEN B) ++ GEN hnfmod(GEN x, GEN d) ++ GEN hnfmodid(GEN x, GEN p) ++ GEN hnfperm(GEN x) ++ GEN matfrobenius(GEN M, long flag, long v) ++ GEN mathnf0(GEN x, long flag) ++ GEN matsnf0(GEN x, long flag) ++ GEN smith(GEN x) ++ GEN smithall(GEN x) ++ GEN smithclean(GEN z) + + # ifactor1.c + ++ GEN Z_factor(GEN n) ++ GEN Z_factor_limit(GEN n, ulong all) ++ GEN Z_factor_until(GEN n, GEN limit) ++ long Z_issmooth(GEN m, ulong lim) ++ GEN Z_issmooth_fact(GEN m, ulong lim) ++ long Z_issquarefree(GEN x) ++ GEN absi_factor(GEN n) ++ GEN absi_factor_limit(GEN n, ulong all) ++ long bigomega(GEN n) ++ GEN core(GEN n) ++ ulong coreu(ulong n) ++ GEN eulerphi(GEN n) ++ ulong eulerphiu(ulong n) ++ ulong eulerphiu_fact(GEN f) ++ GEN factorint(GEN n, long flag) ++ GEN factoru(ulong n) ++ int ifac_isprime(GEN x) ++ int ifac_next(GEN *part, GEN *p, long *e) ++ int ifac_read(GEN part, GEN *p, long *e) ++ void ifac_skip(GEN part) ++ GEN ifac_start(GEN n, int moebius) + int is_357_power(GEN x, GEN *pt, ulong *mask) +- int is_pth_power(GEN x, GEN *pt, ulong *curexp, ulong cutoffbits) ++ int is_pth_power(GEN x, GEN *pt, forprime_t *T, ulong cutoffbits) ++ long ispowerful(GEN n) ++ long issquarefree(GEN x) ++ long istotient(GEN n, GEN *px) ++ long moebius(GEN n) ++ long moebiusu(ulong n) + GEN nextprime(GEN n) ++ GEN numdiv(GEN n) ++ long omega(GEN n) + GEN precprime(GEN n) ++ GEN sumdiv(GEN n) ++ GEN sumdivk(GEN n, long k) ++ ulong tridiv_bound(GEN n) ++ int uis_357_power(ulong x, ulong *pt, ulong *mask) ++ int uis_357_powermod(ulong x, ulong *mask) ++ long uissquarefree(ulong n) ++ long uissquarefree_fact(GEN f) ++ ulong unextprime(ulong n) ++ ulong uprecprime(ulong n) ++ GEN usumdivkvec(ulong n, GEN K) + + # init.c + +- long allocatemoremem(size_t newsize) +- GEN changevar(GEN x, GEN y) +- void pari_err(long numerr, ...) +- long err_catch(long errnum, jmp_buf *penv) ++ void allocatemem(ulong newsize) ++ long timer_delay(pari_timer *T) ++ long timer_get(pari_timer *T) ++ void timer_start(pari_timer *T) ++ int chk_gerepileupto(GEN x) ++ GENbin* copy_bin(GEN x) ++ GENbin* copy_bin_canon(GEN x) ++ void dbg_gerepile(pari_sp av) ++ void dbg_gerepileupto(GEN q) ++ GEN errname(GEN err) ++ GEN gclone(GEN x) ++ GEN gcloneref(GEN x) ++ void gclone_refc(GEN x) + GEN gcopy(GEN x) + GEN gcopy_avma(GEN x, pari_sp *AVMA) ++ GEN gcopy_lg(GEN x, long lx) ++ GEN gerepile(pari_sp ltop, pari_sp lbot, GEN q) ++ void gerepileallsp(pari_sp av, pari_sp tetpil, int n, ...) ++ void gerepilecoeffssp(pari_sp av, pari_sp tetpil, long *g, int n) ++ void gerepilemanysp(pari_sp av, pari_sp tetpil, GEN* g[], int n) ++ GEN getheap() ++ void gp_context_save(gp_context* rec) ++ void gp_context_restore(gp_context* rec) ++ long gsizeword(GEN x) ++ long gsizebyte(GEN x) + void gunclone(GEN x) +- void msgtimer(char *format, ...) +- GEN newblock(long n) ++ void gunclone_deep(GEN x) ++ GEN listcopy(GEN x) ++ void timer_printf(pari_timer *T, char *format, ...) ++ void msgtimer(const char *format, ...) ++ long name_numerr(const char *s) ++ GEN newblock(size_t n) ++ char * numerr_name(long errnum) ++ GEN obj_check(GEN S, long K) ++ GEN obj_checkbuild(GEN S, long tag, GEN (*build)(GEN)) ++ GEN obj_checkbuild_padicprec(GEN S, long tag, GEN (*build)(GEN, long), long prec) ++ GEN obj_checkbuild_prec(GEN S, long tag, GEN (*build)(GEN, long), long prec) ++ void obj_free(GEN S) ++ GEN obj_init(long d, long n) ++ GEN obj_insert(GEN S, long K, GEN O) ++ GEN obj_insert_shallow(GEN S, long K, GEN O) ++ void pari_add_function(entree *ep) ++ void pari_add_module(entree *ep) ++ void pari_add_defaults_module(entree *ep) ++ void pari_add_oldmodule(entree *ep) + void pari_close() +- void pari_init(size_t parisize, ulong maxprime) ++ void pari_close_opts(ulong init_opts) ++ int pari_daemon() ++ void pari_err(int numerr, ...) ++ GEN pari_err_last() ++ char * pari_err2str(GEN err) + void pari_init_opts(size_t parisize, ulong maxprime, ulong init_opts) +- long gsizebyte(GEN x) +- long gsizeword(GEN x) ++ void pari_init(size_t parisize, ulong maxprime) ++ void pari_stackcheck_init(void *pari_stack_base) ++ void pari_sig_init(void (*f)(int)) ++ void pari_thread_alloc(pari_thread *t, size_t s, GEN arg) ++ void pari_thread_close() ++ void pari_thread_free(pari_thread *t) ++ void pari_thread_init() ++ GEN pari_thread_start(pari_thread *t) ++ GEN pari_version() ++ void pari_warn(int numerr, ...) ++ GEN trap0(const char *e, GEN f, GEN r) ++ void shiftaddress(GEN x, long dec) ++ void shiftaddress_canon(GEN x, long dec) + long timer() + long timer2() ++ void traverseheap( void(*f)(GEN, void *), void *data ) + + # intnum.c + +- GEN intcirc(void *E, GEN (*eval) (GEN, void *), GEN a, GEN R, GEN tab, long prec) +- GEN intfouriercos(void *E, GEN (*eval) (GEN, void *), GEN a, GEN b, GEN x, GEN tab, long prec) +- GEN intfourierexp(void *E, GEN (*eval)(GEN, void*), GEN a, GEN b, GEN x, GEN tab, long prec) +- GEN intfouriersin(void *E, GEN (*eval) (GEN, void *), GEN a, GEN b, GEN x, GEN tab, long prec) +- GEN intfuncinit(void *E, GEN (*eval) (GEN, void *), GEN a, GEN b, long m, long flag, long prec) +- GEN intlaplaceinv(void *E, GEN (*eval) (GEN, void *), GEN sig, GEN x, GEN tab, long prec) +- GEN intmellininv(void *E, GEN (*eval) (GEN, void *), GEN sig, GEN x, GEN tab, long prec) ++ GEN intcirc(void *E, GEN (*eval) (void *, GEN), GEN a, GEN R, GEN tab, long prec) ++ GEN intfouriercos(void *E, GEN (*eval) (void *, GEN), GEN a, GEN b, GEN x, GEN tab, long prec) ++ GEN intfourierexp(void *E, GEN (*eval)(void *, GEN), GEN a, GEN b, GEN x, GEN tab, long prec) ++ GEN intfouriersin(void *E, GEN (*eval) (void *, GEN), GEN a, GEN b, GEN x, GEN tab, long prec) ++ GEN intfuncinit(void *E, GEN (*eval) (void *, GEN), GEN a, GEN b, long m, long flag, long prec) ++ GEN intlaplaceinv(void *E, GEN (*eval) (void *, GEN), GEN sig, GEN x, GEN tab, long prec) ++ GEN intmellininv(void *E, GEN (*eval) (void *, GEN), GEN sig, GEN x, GEN tab, long prec) + GEN intmellininvshort(GEN sig, GEN x, GEN tab, long prec) +- GEN intnum(void *E, GEN (*eval) (GEN, void *), GEN a, GEN b, GEN tab, long prec) ++ GEN intnum(void *E, GEN (*eval) (void *, GEN), GEN a, GEN b, GEN tab, long prec) + GEN intnuminit(GEN a, GEN b, long m, long prec) +- GEN intnuminitgen(void *E, GEN (*eval) (GEN, void *), GEN a, GEN b, long m, long flext, long prec) +- GEN intnumromb(void *E, GEN (*eval) (GEN, void *), GEN a, GEN b, long flag, long prec) ++ GEN intnuminitgen(void *E, GEN (*eval) (void *, GEN), GEN a, GEN b, long m, long flext, long prec) ++ GEN intnumromb(void *E, GEN (*eval) (void *, GEN), GEN a, GEN b, long flag, long prec) + long intnumstep(long prec) +- GEN sumnum(void *E, GEN (*f) (GEN, void *), GEN a, GEN sig, GEN tab, long flag, long prec) +- GEN sumnumalt(void *E, GEN (*f) (GEN, void *), GEN a, GEN s, GEN tab, long flag, long prec) ++ GEN sumnum(void *E, GEN (*f) (void *, GEN), GEN a, GEN sig, GEN tab, long flag, long prec) ++ GEN sumnumalt(void *E, GEN (*f) (void *, GEN), GEN a, GEN s, GEN tab, long flag, long prec) + GEN sumnuminit(GEN sig, long m, long sgn, long prec) + ++ # krasner.c ++ ++ GEN padicfields0(GEN p, GEN n, long flag) ++ GEN padicfields(GEN p, long m, long d, long flag) ++ + # kummer.c + + GEN rnfkummer(GEN bnr, GEN subgroup, long all, long prec) + ++ # lll.c ++ ++ GEN ZM_lll_norms(GEN x, double D, long flag, GEN *B) ++ GEN kerint(GEN x) ++ GEN lll(GEN x) ++ GEN lllfp(GEN x, double D, long flag) ++ GEN lllgen(GEN x) ++ GEN lllgram(GEN x) ++ GEN lllgramgen(GEN x) ++ GEN lllgramint(GEN x) ++ GEN lllgramkerim(GEN x) ++ GEN lllgramkerimgen(GEN x) ++ GEN lllint(GEN x) ++ GEN lllintpartial(GEN mat) ++ GEN lllintpartial_inplace(GEN mat) ++ GEN lllkerim(GEN x) ++ GEN lllkerimgen(GEN x) ++ GEN matkerint0(GEN x, long flag) ++ GEN qflll0(GEN x, long flag) ++ GEN qflllgram0(GEN x, long flag) ++ + # members.c + + GEN member_a1(GEN x) +@@ -1429,6 +3078,7 @@ cdef extern from 'pari/pari.h': + GEN member_b4(GEN x) + GEN member_b6(GEN x) + GEN member_b8(GEN x) ++ GEN member_bid(GEN x) + GEN member_bnf(GEN x) + GEN member_c4(GEN x) + GEN member_c6(GEN x) +@@ -1453,19 +3103,26 @@ cdef extern from 'pari/pari.h': + GEN member_orders(GEN x) + GEN member_p(GEN x) + GEN member_pol(GEN x) ++ GEN member_polabs(GEN x) + GEN member_reg(GEN x) ++ GEN member_r1(GEN x) ++ GEN member_r2(GEN x) + GEN member_roots(GEN x) + GEN member_sign(GEN x) + GEN member_t2(GEN x) + GEN member_tate(GEN x) + GEN member_tufu(GEN x) + GEN member_tu(GEN x) +- GEN member_w(GEN x) + GEN member_zk(GEN x) + GEN member_zkst(GEN bid) + + # mp.c + ++ GEN addmulii(GEN x, GEN y, GEN z) ++ GEN addmulii_inplace(GEN x, GEN y, GEN z) ++ ulong Fl_inv(ulong x, ulong p) ++ ulong Fl_invsafe(ulong x, ulong p) ++ int Fp_ratlift(GEN x, GEN m, GEN amax, GEN bmax, GEN *a, GEN *b) + int absi_cmp(GEN x, GEN y) + int absi_equal(GEN x, GEN y) + int absr_cmp(GEN x, GEN y) +@@ -1473,35 +3130,44 @@ cdef extern from 'pari/pari.h': + GEN addir_sign(GEN x, long sx, GEN y, long sy) + GEN addrr_sign(GEN x, long sx, GEN y, long sy) + GEN addsi_sign(long x, GEN y, long sy) ++ GEN addui_sign(ulong x, GEN y, long sy) + GEN addsr(long x, GEN y) +- GEN addss(long x, long y) ++ GEN addumului(ulong a, ulong b, GEN Y) + void affir(GEN x, GEN y) + void affrr(GEN x, GEN y) + GEN bezout(GEN a, GEN b, GEN *u, GEN *v) +- long cbezout(long a,long b,long *uu,long *vv) ++ long cbezout(long a, long b, long *uu, long *vv) + int cmpii(GEN x, GEN y) + int cmprr(GEN x, GEN y) +- int cmpsi(long x, GEN y) +- int cmpui(ulong x, GEN y) ++ long dblexpo(double x) ++ ulong dblmantissa(double x) + GEN dbltor(double x) + GEN diviiexact(GEN x, GEN y) +- GEN diviuexact(GEN x, ulong y) + GEN divir(GEN x, GEN y) + GEN divis(GEN y, long x) + GEN divis_rem(GEN x, long y, long *rem) + GEN diviu_rem(GEN y, ulong x, ulong *rem) ++ GEN diviuuexact(GEN x, ulong y, ulong z) ++ GEN diviuexact(GEN x, ulong y) + GEN divri(GEN x, GEN y) + GEN divrr(GEN x, GEN y) + GEN divrs(GEN x, long y) ++ GEN divru(GEN x, ulong y) + GEN divsi(long x, GEN y) + GEN divsr(long x, GEN y) ++ GEN divur(ulong x, GEN y) + GEN dvmdii(GEN x, GEN y, GEN *z) + int equalii(GEN x, GEN y) ++ int equalrr(GEN x, GEN y) + GEN floorr(GEN x) + GEN gcdii(GEN x, GEN y) ++ GEN int2n(long n) ++ GEN int2u(ulong n) + GEN int_normalize(GEN x, long known_zero_words) + int invmod(GEN a, GEN b, GEN *res) +- ulong Fl_inv(ulong x, ulong p) ++ ulong invmod2BIL(ulong b) ++ GEN invr(GEN b) ++ GEN mantissa_real(GEN x, long *e) + GEN modii(GEN x, GEN y) + void modiiz(GEN x, GEN y, GEN z) + GEN mulii(GEN x, GEN y) +@@ -1513,29 +3179,58 @@ cdef extern from 'pari/pari.h': + GEN mului(ulong x, GEN y) + GEN mulur(ulong x, GEN y) + GEN muluu(ulong x, ulong y) +- GEN randomi(GEN x) +- int ratlift(GEN x, GEN m, GEN *a, GEN *b, GEN amax, GEN bmax) ++ GEN muluui(ulong x, ulong y, GEN z) ++ GEN remi2n(GEN x, long n) + double rtodbl(GEN x) + GEN shifti(GEN x, long n) + GEN sqri(GEN x) +- #define sqrti(x) sqrtremi((x),NULL) ++ GEN sqrr(GEN x) ++ GEN sqrs(long x) ++ GEN sqrtr_abs(GEN x) + GEN sqrtremi(GEN S, GEN *R) ++ GEN sqru(ulong x) + GEN subsr(long x, GEN y) + GEN truedvmdii(GEN x, GEN y, GEN *z) ++ GEN truedvmdis(GEN x, long y, GEN *z) ++ GEN truedvmdsi(long x, GEN y, GEN *z) ++ GEN trunc2nr(GEN x, long n) ++ GEN mantissa2nr(GEN x, long n) ++ GEN truncr(GEN x) + ulong umodiu(GEN y, ulong x) + long vals(ulong x) + + # nffactor.c + +- GEN nffactor(GEN nf,GEN x) +- GEN nffactormod(GEN nf,GEN pol,GEN pr) +- GEN nfroots(GEN nf,GEN pol) +- GEN rnfcharpoly(GEN nf,GEN T,GEN alpha,int n) +- GEN rnfdedekind(GEN nf,GEN T,GEN pr) ++ GEN FpC_ratlift(GEN P, GEN mod, GEN amax, GEN bmax, GEN denom) ++ GEN FpM_ratlift(GEN M, GEN mod, GEN amax, GEN bmax, GEN denom) ++ GEN FpX_ratlift(GEN P, GEN mod, GEN amax, GEN bmax, GEN denom) ++ GEN nffactor(GEN nf, GEN x) ++ GEN nffactormod(GEN nf, GEN pol, GEN pr) ++ GEN nfgcd(GEN P, GEN Q, GEN nf, GEN den) ++ GEN nfgcd_all(GEN P, GEN Q, GEN T, GEN den, GEN *Pnew) ++ GEN nfroots(GEN nf, GEN pol) ++ GEN polfnf(GEN a, GEN t) ++ GEN rootsof1(GEN x) ++ GEN rootsof1_kannan(GEN nf) ++ ++ # paricfg.c ++ ++ extern char *paricfg_datadir ++ extern char *paricfg_version ++ extern char *paricfg_buildinfo ++ extern long paricfg_version_code ++ extern char *paricfg_vcsversion ++ extern char *paricfg_compiledate ++ extern char *paricfg_mt_engine + + # part.c + ++ void forpart(void *E, long call(void*, GEN), long k, GEN nbound, GEN abound) ++ void forpart_init(forpart_t *T, long k, GEN abound, GEN nbound) ++ GEN forpart_next(forpart_t *T) ++ GEN forpart_prev(forpart_t *T) + GEN numbpart(GEN x) ++ GEN partitions(long k, GEN nbound, GEN abound) + + # perm.c + +@@ -1556,234 +3251,293 @@ cdef extern from 'pari/pari.h': + long group_perm_normalize(GEN N, GEN g) + GEN group_quotient(GEN G, GEN H) + GEN group_rightcoset(GEN G, GEN g) ++ GEN group_set(GEN G, long n) ++ long group_subgroup_isnormal(GEN G, GEN H) + GEN group_subgroups(GEN G) +- GEN groupelts_center(GEN S) + GEN groupelts_abelian_group(GEN S) ++ GEN groupelts_center(GEN S) ++ GEN groupelts_set(GEN G, long n) + int perm_commute(GEN p, GEN q) + GEN perm_cycles(GEN v) + long perm_order(GEN perm) + GEN perm_pow(GEN perm, long exp) + GEN quotient_group(GEN C, GEN G) + GEN quotient_perm(GEN C, GEN p) ++ GEN quotient_subgroup_lift(GEN C, GEN H, GEN S) ++ GEN subgroups_tableset(GEN S, long n) ++ long tableset_find_index(GEN tbl, GEN set) ++ GEN trivialgroup() + GEN vecperm_orbits(GEN v, long n) ++ GEN vec_insert(GEN v, long n, GEN x) ++ int vec_is1to1(GEN v) ++ int vec_isconst(GEN v) ++ long vecsmall_duplicate(GEN x) ++ long vecsmall_duplicate_sorted(GEN x) ++ GEN vecsmall_indexsort(GEN V) + void vecsmall_sort(GEN V) + GEN vecsmall_uniq(GEN V) ++ GEN vecsmall_uniq_sorted(GEN V) + GEN vecvecsmall_indexsort(GEN x) +- GEN vecvecsmall_sort(GEN x) + long vecvecsmall_search(GEN x, GEN y, long flag) ++ GEN vecvecsmall_sort(GEN x) ++ GEN vecvecsmall_sort_uniq(GEN x) ++ ++ # mt.c ++ ++ void mt_broadcast(GEN code) ++ void mt_sigint_block() ++ void mt_sigint_unblock() ++ void mt_queue_end(pari_mt *pt) ++ GEN mt_queue_get(pari_mt *pt, long *jobid, long *pending) ++ void mt_queue_start(pari_mt *pt, GEN worker) ++ void mt_queue_submit(pari_mt *pt, long jobid, GEN work) ++ void pari_mt_init() ++ void pari_mt_close() + + # polarit1.c + +- long Flx_nbfact(GEN z, ulong p) +- long Flx_nbroots(GEN f, ulong p) +- GEN FpX_degfact(GEN f, GEN p) +- long FpX_is_irred(GEN f, GEN p) +- long FpX_is_squarefree(GEN f, GEN p) +- long FpX_is_totally_split(GEN f, GEN p) +- GEN FpX_factor(GEN f, GEN p) +- long FpX_nbfact(GEN f, GEN p) +- long FpX_nbroots(GEN f, GEN p) +- GEN FpXQX_gcd(GEN P, GEN Q, GEN T, GEN p) +- GEN FqX_factor(GEN x, GEN T, GEN p) +- GEN FqX_gcd(GEN P, GEN Q, GEN T, GEN p) +- long FqX_is_squarefree(GEN P, GEN T, GEN p) +- long FqX_nbfact(GEN u, GEN T, GEN p) +- long FqX_nbroots(GEN f, GEN T, GEN p) +- GEN random_FpX(long d, long v, GEN p) +- GEN FpX_roots(GEN f, GEN p) +- GEN padicappr(GEN f, GEN a) +- GEN factcantor(GEN x, GEN p) +- GEN factmod(GEN f, GEN p) +- GEN factorff(GEN f, GEN p, GEN a) +- GEN factormod0(GEN f, GEN p, long flag) +- GEN factorpadic0(GEN f,GEN p,long r,long flag) ++ GEN ZX_Zp_root(GEN f, GEN a, GEN p, long prec) ++ GEN Zp_appr(GEN f, GEN a) ++ GEN factorpadic0(GEN f, GEN p, long r, long flag) + GEN factorpadic(GEN x, GEN p, long r) +- int gdvd(GEN x, GEN y) ++ GEN gdeuc(GEN x, GEN y) ++ GEN grem(GEN x, GEN y) ++ GEN padicappr(GEN f, GEN a) + GEN poldivrem(GEN x, GEN y, GEN *pr) +- GEN rootmod(GEN f, GEN p) +- GEN rootmod0(GEN f, GEN p,long flag) +- GEN rootmod2(GEN f, GEN p) + GEN rootpadic(GEN f, GEN p, long r) + GEN rootpadicfast(GEN f, GEN p, long e) +- GEN simplefactmod(GEN f, GEN p) + + # polarit2.c + + GEN Q_content(GEN x) + GEN Q_denom(GEN x) + GEN Q_div_to_int(GEN x, GEN c) ++ GEN Q_gcd(GEN x, GEN y) ++ GEN Q_mul_to_int(GEN x, GEN c) + GEN Q_muli_to_int(GEN x, GEN d) + GEN Q_primitive_part(GEN x, GEN *ptc) + GEN Q_primpart(GEN x) + GEN Q_remove_denom(GEN x, GEN *ptd) ++ GEN RgXQ_charpoly(GEN x, GEN T, long v) ++ GEN RgXQ_inv(GEN x, GEN y) ++ GEN RgX_disc(GEN x) + GEN RgX_extgcd(GEN x, GEN y, GEN *U, GEN *V) +- GEN ZX_squff(GEN f, GEN *ex) ++ GEN RgX_extgcd_simple(GEN a, GEN b, GEN *pu, GEN *pv) ++ GEN RgX_gcd(GEN x, GEN y) ++ GEN RgX_gcd_simple(GEN x, GEN y) ++ int RgXQ_ratlift(GEN y, GEN x, long amax, long bmax, GEN *P, GEN *Q) ++ GEN RgX_resultant_all(GEN P, GEN Q, GEN *sol) ++ long RgX_type(GEN x, GEN *ptp, GEN *ptpol, long *ptpa) ++ void RgX_type_decode(long x, long *t1, long *t2) ++ int RgX_type_is_composite(long t) ++ GEN ZX_content(GEN x) + GEN centermod(GEN x, GEN p) + GEN centermod_i(GEN x, GEN p, GEN ps2) + GEN centermodii(GEN x, GEN p, GEN po2) + GEN content(GEN x) + GEN deg1_from_roots(GEN L, long v) +- GEN discsr(GEN x) +- GEN divide_conquer_prod(GEN x, GEN (*mul)(GEN,GEN)) ++ GEN divide_conquer_assoc(GEN x, void *data, GEN (*mul)(void*, GEN, GEN)) ++ GEN divide_conquer_prod(GEN x, GEN (*mul)(GEN, GEN)) + GEN factor(GEN x) +- GEN factor0(GEN x,long flag) +- GEN factorback(GEN fa,GEN nf) ++ GEN factor0(GEN x, long flag) ++ GEN factorback(GEN fa) ++ GEN factorback2(GEN fa, GEN e) ++ GEN famat_mul_shallow(GEN f, GEN g) + GEN gbezout(GEN x, GEN y, GEN *u, GEN *v) +- GEN ggcd0(GEN x, GEN ) +- GEN gdeflate(GEN x, long v, long d) + GEN gdivexact(GEN x, GEN y) ++ GEN gen_factorback(GEN L, GEN e, GEN (*_mul)(void*, GEN, GEN), GEN (*_pow)(void*, GEN, GEN), void *data) + GEN ggcd(GEN x, GEN y) ++ GEN ggcd0(GEN x, GEN y) + GEN ginvmod(GEN x, GEN y) +- GEN gisirreducible(GEN x) + GEN glcm(GEN x, GEN y) + GEN glcm0(GEN x, GEN y) +- GEN gen_pow(GEN,GEN,void*,GEN (*sqr)(void*,GEN),GEN (*mul)(void*,GEN,GEN)) +- GEN gen_pow_u(GEN x, ulong n, void *data, GEN (*sqr)(void*,GEN), GEN (*mul)(void*,GEN,GEN)) +- long logint(GEN B, GEN y, GEN *ptq) ++ GEN gp_factor0(GEN x, GEN flag) ++ GEN idealfactorback(GEN nf, GEN L, GEN e, int red) ++ long isirreducible(GEN x) + GEN newtonpoly(GEN x, GEN p) +- GEN nfgcd(GEN P, GEN Q, GEN nf, GEN den) +- GEN nfisincl(GEN a, GEN b) +- GEN nfisisom(GEN a, GEN b) ++ GEN nffactorback(GEN nf, GEN L, GEN e) + GEN nfrootsQ(GEN x) + GEN poldisc0(GEN x, long v) +- GEN polfnf(GEN a, GEN t) +- GEN polhensellift(GEN pol, GEN fct, GEN p, long exp) +- GEN polresultant0(GEN x, GEN y,long v,long flag) ++ GEN polresultant0(GEN x, GEN y, long v, long flag) + GEN polsym(GEN x, long n) + GEN primitive_part(GEN x, GEN *c) + GEN primpart(GEN x) +- GEN quadgen(GEN x) +- GEN quadpoly(GEN x) +- GEN quadpoly0(GEN x, long v) + GEN reduceddiscsmith(GEN pol) + GEN resultant2(GEN x, GEN y) ++ GEN resultant_all(GEN u, GEN v, GEN *sol) ++ GEN rnfcharpoly(GEN nf, GEN T, GEN alpha, long v) + GEN roots_from_deg1(GEN x) +- GEN sort_factor(GEN y, int (*cmp)(GEN,GEN)) +- GEN sort_factor_gen(GEN y, int (*cmp)(GEN,GEN)) +- GEN sort_vecpol(GEN a, int (*cmp)(GEN,GEN)) +- GEN srgcd(GEN x, GEN y) ++ GEN roots_to_pol(GEN a, long v) ++ GEN roots_to_pol_r1(GEN a, long v, long r1) + long sturmpart(GEN x, GEN a, GEN b) + GEN subresext(GEN x, GEN y, GEN *U, GEN *V) +- GEN sylvestermatrix(GEN x,GEN y) +- GEN vecbezout(GEN x, GEN y) +- GEN vecbezoutres(GEN x, GEN y) ++ GEN sylvestermatrix(GEN x, GEN y) ++ GEN trivial_fact() ++ GEN gcdext0(GEN x, GEN y) ++ GEN polresultantext0(GEN x, GEN y, long v) ++ GEN polresultantext(GEN x, GEN y) ++ GEN prime_fact(GEN x) + + # polarit3.c + +- GEN Fp_pows(GEN A, long k, GEN N) +- GEN Fp_powu(GEN x, ulong k, GEN p) +- GEN FpM_red(GEN z, GEN p) +- GEN FpM_to_mod(GEN z, GEN p) +- GEN FpV_polint(GEN xa, GEN ya, GEN p) +- GEN FpV_red(GEN z, GEN p) +- GEN FpV_roots_to_pol(GEN V, GEN p, long v) +- GEN FpV_to_mod(GEN z, GEN p) +- GEN FpX_Fp_add(GEN y,GEN x,GEN p) +- GEN FpX_Fp_mul(GEN y,GEN x,GEN p) +- GEN FpX_add(GEN x,GEN y,GEN p) +- GEN FpX_center(GEN T,GEN mod) +- GEN FpX_chinese_coprime(GEN x,GEN y,GEN Tx,GEN Ty,GEN Tz,GEN p) +- GEN FpX_divrem(GEN x, GEN y, GEN p, GEN *pr) +- GEN FpX_eval(GEN x,GEN y,GEN p) +- GEN FpX_extgcd(GEN x, GEN y, GEN p, GEN *ptu, GEN *ptv) +- GEN FpX_factorff_irred(GEN P, GEN Q, GEN l) +- void FpX_ffintersect(GEN P,GEN Q,long n,GEN l,GEN *SP,GEN *SQ,GEN MA,GEN MB) +- GEN FpX_ffisom(GEN P,GEN Q,GEN l) +- GEN FpX_gcd(GEN x, GEN y, GEN p) +- GEN FpX_mul(GEN x,GEN y,GEN p) +- GEN FpX_neg(GEN x,GEN p) +- GEN FpX_normalize(GEN z, GEN p) +- GEN FpX_red(GEN z, GEN p) +- GEN FpX_sqr(GEN x,GEN p) +- GEN FpX_sub(GEN x,GEN y,GEN p) +- GEN FpX_to_mod(GEN z, GEN p) +- GEN FpXQ_charpoly(GEN x, GEN T, GEN p) +- GEN FpXQ_div(GEN x,GEN y,GEN T,GEN p) +- GEN FpXQ_ffisom_inv(GEN S,GEN Tp, GEN p) +- GEN FpXQ_inv(GEN x,GEN T,GEN p) +- GEN FpXQ_invsafe(GEN x, GEN T, GEN p) +- GEN FpXQ_matrix_pow(long n, long m, GEN y, GEN P, GEN l) +- GEN FpXQ_minpoly(GEN x, GEN T, GEN p) +- GEN FpXQ_mul(GEN y,GEN x,GEN T,GEN p) +- GEN FpXQ_pow(GEN x, GEN n, GEN T, GEN p) +- GEN FpXQ_powers(GEN x, long l, GEN T, GEN p) +- GEN FpXQ_sqr(GEN y, GEN T, GEN p) +- GEN FpXQ_sqrtn(GEN a, GEN n, GEN T, GEN p, GEN *zetan) +- GEN FpXQX_mul(GEN x, GEN y, GEN T, GEN p) +- GEN FpXQX_red(GEN z, GEN T, GEN p) +- GEN FpXQX_sqr(GEN x, GEN T, GEN p) +- GEN FpXQX_extgcd(GEN x, GEN y, GEN T, GEN p, GEN *ptu, GEN *ptv) +- GEN FpXQX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *pr) +- GEN FpXQXV_prod(GEN V, GEN Tp, GEN p) +- GEN FpXV_prod(GEN V, GEN p) +- GEN FpXV_red(GEN z, GEN p) +- GEN FpXX_red(GEN z, GEN p) +- GEN FpX_rescale(GEN P, GEN h, GEN p) ++ GEN Flx_FlxY_resultant(GEN a, GEN b, ulong pp) ++ GEN Flx_factorff_irred(GEN P, GEN Q, ulong p) ++ void Flx_ffintersect(GEN P, GEN Q, long n, ulong l, GEN *SP, GEN *SQ, GEN MA, GEN MB) ++ GEN Flx_ffisom(GEN P, GEN Q, ulong l) ++ GEN Flx_roots_naive(GEN f, ulong p) ++ GEN FlxX_resultant(GEN u, GEN v, ulong p, long sx) ++ GEN Flxq_ffisom_inv(GEN S, GEN Tp, ulong p) ++ GEN FpV_polint(GEN xa, GEN ya, GEN p, long v) ++ GEN FpX_FpXY_resultant(GEN a, GEN b0, GEN p) ++ GEN FpX_factorff_irred(GEN P, GEN Q, GEN p) ++ void FpX_ffintersect(GEN P, GEN Q, long n, GEN l, GEN *SP, GEN *SQ, GEN MA, GEN MB) ++ GEN FpX_ffisom(GEN P, GEN Q, GEN l) ++ GEN FpX_translate(GEN P, GEN c, GEN p) ++ GEN FpXQ_ffisom_inv(GEN S, GEN Tp, GEN p) ++ GEN FpXV_FpC_mul(GEN V, GEN W, GEN p) ++ GEN FpXY_Fq_evaly(GEN Q, GEN y, GEN T, GEN p, long vx) ++ GEN Fq_Fp_mul(GEN x, GEN y, GEN T, GEN p) ++ GEN Fq_add(GEN x, GEN y, GEN T, GEN p) ++ GEN Fq_div(GEN x, GEN y, GEN T, GEN p) + GEN Fq_inv(GEN x, GEN T, GEN p) + GEN Fq_invsafe(GEN x, GEN T, GEN p) +- GEN Fq_add(GEN x, GEN y, GEN T, GEN p) + GEN Fq_mul(GEN x, GEN y, GEN T, GEN p) ++ GEN Fq_mulu(GEN x, ulong y, GEN T, GEN p) + GEN Fq_neg(GEN x, GEN T, GEN p) + GEN Fq_neg_inv(GEN x, GEN T, GEN p) + GEN Fq_pow(GEN x, GEN n, GEN T, GEN p) +- GEN Fq_red(GEN x, GEN T, GEN p) ++ GEN Fq_powu(GEN x, ulong n, GEN pol, GEN p) + GEN Fq_sub(GEN x, GEN y, GEN T, GEN p) ++ GEN Fq_sqr(GEN x, GEN T, GEN p) ++ GEN Fq_sqrt(GEN x, GEN T, GEN p) ++ GEN Fq_sqrtn(GEN x, GEN n, GEN T, GEN p, GEN *zeta) ++ GEN FqC_add(GEN x, GEN y, GEN T, GEN p) ++ GEN FqC_sub(GEN x, GEN y, GEN T, GEN p) ++ GEN FqC_Fq_mul(GEN x, GEN y, GEN T, GEN p) ++ GEN FqC_to_FlxC(GEN v, GEN T, GEN pp) + GEN FqM_to_FlxM(GEN x, GEN T, GEN pp) + GEN FqV_roots_to_pol(GEN V, GEN T, GEN p, long v) + GEN FqV_red(GEN z, GEN T, GEN p) +- GEN FqX_Fq_mul(GEN P, GEN U, GEN T, GEN p) +- GEN FqX_div(GEN x, GEN y, GEN T, GEN p) +- GEN FqX_divrem(GEN x, GEN y, GEN T, GEN p, GEN *z) ++ GEN FqV_to_FlxV(GEN v, GEN T, GEN pp) ++ GEN FqX_Fq_add(GEN y, GEN x, GEN T, GEN p) ++ GEN FqX_Fq_mul_to_monic(GEN P, GEN U, GEN T, GEN p) ++ GEN FqX_eval(GEN x, GEN y, GEN T, GEN p) + GEN FqX_normalize(GEN z, GEN T, GEN p) +- GEN FqX_red(GEN z, GEN T, GEN p) +- GEN FqX_rem(GEN x, GEN y, GEN T, GEN p) +- GEN FqX_mul(GEN x, GEN y, GEN T, GEN p) +- GEN FqX_sqr(GEN x, GEN T, GEN p) ++ GEN FqX_translate(GEN P, GEN c, GEN T, GEN p) ++ GEN FqXQ_powers(GEN x, long l, GEN S, GEN T, GEN p) ++ GEN FqXQ_matrix_pow(GEN y, long n, long m, GEN S, GEN T, GEN p) ++ GEN FqXY_eval(GEN Q, GEN y, GEN x, GEN T, GEN p) ++ GEN FqXY_evalx(GEN Q, GEN x, GEN T, GEN p) ++ GEN QX_disc(GEN x) ++ GEN QX_gcd(GEN a, GEN b) ++ GEN QX_resultant(GEN A, GEN B) ++ GEN QXQ_intnorm(GEN A, GEN B) + GEN QXQ_inv(GEN A, GEN B) ++ GEN QXQ_norm(GEN A, GEN B) ++ int Rg_is_Fp(GEN x, GEN *p) ++ int Rg_is_FpXQ(GEN x, GEN *pT, GEN *pp) ++ GEN Rg_to_Fp(GEN x, GEN p) ++ GEN Rg_to_FpXQ(GEN x, GEN T, GEN p) ++ GEN RgC_to_Flc(GEN x, ulong p) ++ GEN RgC_to_FpC(GEN x, GEN p) ++ int RgM_is_FpM(GEN x, GEN *p) ++ GEN RgM_to_Flm(GEN x, ulong p) ++ GEN RgM_to_FpM(GEN x, GEN p) ++ int RgV_is_FpV(GEN x, GEN *p) ++ GEN RgV_to_FpV(GEN x, GEN p) ++ int RgX_is_FpX(GEN x, GEN *p) ++ GEN RgX_to_FpX(GEN x, GEN p) ++ int RgX_is_FpXQX(GEN x, GEN *pT, GEN *pp) ++ GEN RgX_to_FpXQX(GEN x, GEN T, GEN p) ++ GEN RgX_to_FqX(GEN x, GEN T, GEN p) ++ GEN ZX_ZXY_rnfequation(GEN A, GEN B, long *Lambda) ++ GEN ZXQ_charpoly(GEN A, GEN T, long v) + GEN ZX_disc(GEN x) + int ZX_is_squarefree(GEN x) ++ GEN ZX_gcd(GEN A, GEN B) ++ GEN ZX_gcd_all(GEN A, GEN B, GEN *Anew) + GEN ZX_resultant(GEN A, GEN B) +- long brent_kung_optpow(long d, long n) ++ int Z_incremental_CRT(GEN *H, ulong Hp, GEN *q, ulong p) ++ GEN Z_init_CRT(ulong Hp, ulong p) ++ int ZM_incremental_CRT(GEN *H, GEN Hp, GEN *q, ulong p) ++ GEN ZM_init_CRT(GEN Hp, ulong p) ++ int ZX_incremental_CRT(GEN *ptH, GEN Hp, GEN *q, ulong p) ++ GEN ZX_init_CRT(GEN Hp, ulong p, long v) ++ GEN characteristic(GEN x) + GEN ffinit(GEN p, long n, long v) ++ GEN ffnbirred(GEN p, long n) ++ GEN ffnbirred0(GEN p, long n, long flag) ++ GEN ffsumnbirred(GEN p, long n) ++ bb_field *get_Fq_field(void **E, GEN T, GEN p) ++ GEN init_Fq(GEN p, long n, long v) ++ GEN pol_x_powers(long N, long v) ++ GEN residual_characteristic(GEN x) ++ ++ # prime.c ++ ++ long BPSW_isprime(GEN x) ++ long BPSW_psp(GEN N) ++ GEN addprimes(GEN primes) ++ GEN gisprime(GEN x, long flag) ++ GEN gispseudoprime(GEN x, long flag) ++ GEN gprimepi_upper_bound(GEN x) ++ GEN gprimepi_lower_bound(GEN x) ++ long isprime(GEN x) ++ long ispseudoprime(GEN x, long flag) ++ long millerrabin(GEN n, long k) ++ GEN prime(long n) ++ GEN primepi(GEN x) ++ double primepi_upper_bound(double x) ++ double primepi_lower_bound(double x) ++ GEN primes(long n) ++ GEN primes_interval(GEN a, GEN b) ++ GEN primes_interval_zv(ulong a, ulong b) ++ GEN primes_upto_zv(ulong b) ++ GEN primes0(GEN n) ++ GEN primes_zv(long m) ++ GEN randomprime(GEN N) ++ GEN removeprimes(GEN primes) ++ int uislucaspsp(ulong n) ++ int uisprime(ulong n) ++ ulong uprime(long n) ++ ulong uprimepi(ulong n) + +- # RgX.c ++ # qfisom.c + +- int RgX_is_rational(GEN x) +- GEN RgM_to_RgXV(GEN x, long v) +- GEN RgM_to_RgXX(GEN x, long v,long w) +- GEN RgM_zc_mul(GEN x, GEN y) +- GEN RgM_zm_mul(GEN x, GEN y) +- GEN RgV_to_RgX(GEN x, long v) +- GEN RgV_zc_mul(GEN x, GEN y) +- GEN RgV_zm_mul(GEN x, GEN y) +- GEN RgX_divrem(GEN x,GEN y,GEN *r) +- GEN RgX_mul(GEN x,GEN y) +- GEN RgX_mulspec(GEN a, GEN b, long na, long nb) +- GEN RgXQX_divrem(GEN x,GEN y,GEN T,GEN *r) +- GEN RgXQX_mul(GEN x,GEN y,GEN T) +- GEN RgXQX_red(GEN P, GEN T) +- GEN RgXQX_RgXQ_mul(GEN x, GEN y, GEN T) +- GEN RgX_Rg_mul(GEN y, GEN x) +- GEN RgX_shift(GEN x, long n) +- GEN RgX_sqr(GEN x) +- GEN RgX_sqrspec(GEN a, long na) +- GEN RgXV_to_RgM(GEN v, long n) +- GEN RgX_to_RgV(GEN x, long N) +- GEN RgXX_to_RgM(GEN v, long n) +- GEN RgXY_swap(GEN x, long n, long w) ++ GEN qfauto(GEN g, GEN flags) ++ GEN qfauto0(GEN g, GEN flags) ++ GEN qfautoexport(GEN g, long flag) ++ GEN qfisom(GEN g, GEN h, GEN flags) ++ GEN qfisom0(GEN g, GEN h, GEN flags) ++ GEN qfisominit(GEN g, GEN flags) ++ GEN qfisominit0(GEN g, GEN flags) ++ ++ # random.c ++ ++ GEN genrand(GEN N) ++ GEN getrand() ++ ulong pari_rand() ++ GEN randomi(GEN x) ++ GEN randomr(long prec) ++ ulong random_Fl(ulong n) ++ void setrand(GEN seed) + + # rootpol.c + +- GEN cleanroots(GEN x,long l) ++ GEN QX_complex_roots(GEN p, long l) ++ GEN ZX_graeffe(GEN p) ++ GEN cleanroots(GEN x, long l) + int isrealappr(GEN x, long l) +- GEN roots(GEN x,long l) +- GEN roots0(GEN x,long flag,long l) ++ GEN polgraeffe(GEN p) ++ GEN polmod_to_embed(GEN x, long prec) ++ GEN roots(GEN x, long l) + + # subcyclo.c + ++ GEN factor_Aurifeuille(GEN p, long n) ++ GEN factor_Aurifeuille_prime(GEN p, long n) + GEN galoissubcyclo(GEN N, GEN sg, long flag, long v) + GEN polsubcyclo(long n, long d, long v) +- GEN znstar_small(GEN zn) + + # subfield.c + +@@ -1792,7 +3546,7 @@ cdef extern from 'pari/pari.h': + # subgroup.c + + GEN subgrouplist(GEN cyc, GEN bound) +- void traversesubgroups(GEN cyc, GEN B, void fun(GEN,void*), void *E) ++ void forsubgroup(void *E, long fun(void*, GEN), GEN cyc, GEN B) + + # stark.c + +@@ -1802,23 +3556,34 @@ cdef extern from 'pari/pari.h': + + # sumiter.c + +- GEN derivnum(void *E, GEN (*eval)(GEN,void*), GEN x, long prec) +- GEN direuler(void *E, GEN (*eval)(GEN,void*), GEN ga, GEN gb, GEN c) +- GEN forvec_start(GEN x, long flag, GEN *d, GEN (**next)(GEN,GEN)) ++ GEN derivnum(void *E, GEN (*eval)(void *, GEN), GEN x, long prec) ++ GEN derivfun(void *E, GEN (*eval)(void *, GEN), GEN x, long prec) ++ GEN direuler(void *E, GEN (*eval)(void *, GEN), GEN ga, GEN gb, GEN c) ++ int forcomposite_init(forcomposite_t *C, GEN a, GEN b) ++ GEN forcomposite_next(forcomposite_t *C) ++ GEN forprime_next(forprime_t *T) ++ int forprime_init(forprime_t *T, GEN a, GEN b) ++ int forvec_init(forvec_t *T, GEN x, long flag) ++ GEN forvec_next(forvec_t *T) + GEN polzag(long n, long m) +- GEN prodeuler(void *E, GEN (*eval)(GEN,void*), GEN ga, GEN gb, long prec) +- GEN prodinf(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN prodinf1(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN sumalt(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN sumalt2(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN sumpos(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN sumpos2(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN suminf(void *E, GEN (*eval)(GEN,void*), GEN a, long prec) +- GEN zbrent(void *E, GEN (*eval)(GEN,void*), GEN a, GEN b, long prec) ++ GEN prodeuler(void *E, GEN (*eval)(void *, GEN), GEN ga, GEN gb, long prec) ++ GEN prodinf(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ GEN prodinf1(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ GEN sumalt(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ GEN sumalt2(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ GEN sumpos(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ GEN sumpos2(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ GEN suminf(void *E, GEN (*eval)(void *, GEN), GEN a, long prec) ++ ulong u_forprime_next(forprime_t *T) ++ int u_forprime_init(forprime_t *T, ulong a, ulong b) ++ void u_forprime_restrict(forprime_t *T, ulong c) ++ int u_forprime_arith_init(forprime_t *T, ulong a, ulong b, ulong c, ulong q) ++ GEN zbrent(void *E, GEN (*eval)(void *, GEN), GEN a, GEN b, long prec) + + # thue.c + + GEN bnfisintnorm(GEN x, GEN y) ++ GEN bnfisintnormabs(GEN bnf, GEN a) + GEN thue(GEN thueres, GEN rhs, GEN ne) + GEN thueinit(GEN pol, long flag, long prec) + +@@ -1827,14 +3592,26 @@ cdef extern from 'pari/pari.h': + GEN Pi2n(long n, long prec) + GEN PiI2(long prec) + GEN PiI2n(long n, long prec) ++ GEN Qp_exp(GEN x) ++ GEN Qp_log(GEN x) ++ GEN Qp_sqrt(GEN x) ++ GEN Qp_sqrtn(GEN x, GEN n, GEN *zetan) ++ long Zn_ispower(GEN a, GEN q, GEN K, GEN *pt) + long Zn_issquare(GEN x, GEN n) + GEN Zn_sqrt(GEN x, GEN n) +- void consteuler(long prec) +- void constpi(long prec) +- GEN exp_Ir(GEN x) ++ GEN Zp_teichmuller(GEN x, GEN p, long n, GEN q) ++ GEN agm(GEN x, GEN y, long prec) ++ GEN constcatalan(long prec) ++ GEN consteuler(long prec) ++ GEN constlog2(long prec) ++ GEN constpi(long prec) ++ GEN cxexpm1(GEN z, long prec) ++ GEN expIr(GEN x) ++ GEN exp1r_abs(GEN x) + GEN gcos(GEN x, long prec) + GEN gcotan(GEN x, long prec) + GEN gexp(GEN x, long prec) ++ GEN gexpm1(GEN x, long prec) + GEN glog(GEN x, long prec) + GEN gpow(GEN x, GEN n, long prec) + GEN gpowgs(GEN x, long n) +@@ -1843,72 +3620,100 @@ cdef extern from 'pari/pari.h': + GEN gsqrt(GEN x, long prec) + GEN gsqrtn(GEN x, GEN n, GEN *zetan, long prec) + GEN gtan(GEN x, long prec) ++ GEN logr_abs(GEN x) + GEN mpcos(GEN x) + GEN mpeuler(long prec) ++ GEN mpcatalan(long prec) ++ void mpsincosm1(GEN x, GEN *s, GEN *c) + GEN mpexp(GEN x) +- GEN mpexp1(GEN x) ++ GEN mpexpm1(GEN x) + GEN mplog(GEN x) + GEN mplog2(long prec) + GEN mppi(long prec) + GEN mpsin(GEN x) + void mpsincos(GEN x, GEN *s, GEN *c) ++ GEN powis(GEN x, long n) ++ GEN powiu(GEN p, ulong k) ++ GEN powrfrac(GEN x, long n, long d) ++ GEN powrs(GEN x, long n) ++ GEN powrshalf(GEN x, long s) ++ GEN powru(GEN x, ulong n) ++ GEN powruhalf(GEN x, ulong s) ++ GEN powuu(ulong p, ulong k) + GEN powgi(GEN x, GEN n) ++ GEN serchop0(GEN s) ++ GEN sqrtnint(GEN a, long n) + GEN teich(GEN x) ++ GEN trans_eval(const char *fun, GEN (*f) (GEN, long), GEN x, long prec) ++ ulong upowuu(ulong p, ulong k) ++ ulong usqrtn(ulong a, ulong n) ++ ulong usqrt(ulong a) + + # trans2.c + ++ GEN Qp_gamma(GEN x) + GEN bernfrac(long n) ++ GEN bernpol(long k, long v) + GEN bernreal(long n, long prec) +- GEN bernvec(long nomb) +- GEN gach(GEN x, long prec) ++ GEN gacosh(GEN x, long prec) + GEN gacos(GEN x, long prec) + GEN garg(GEN x, long prec) +- GEN gash(GEN x, long prec) ++ GEN gasinh(GEN x, long prec) + GEN gasin(GEN x, long prec) + GEN gatan(GEN x, long prec) +- GEN gath(GEN x, long prec) +- GEN gch(GEN x, long prec) +- GEN ggamd(GEN x, long prec) ++ GEN gatanh(GEN x, long prec) ++ GEN gcosh(GEN x, long prec) ++ GEN ggammah(GEN x, long prec) + GEN ggamma(GEN x, long prec) + GEN glngamma(GEN x, long prec) + GEN gpsi(GEN x, long prec) +- GEN gsh(GEN x, long prec) +- GEN gth(GEN x, long prec) ++ GEN gsinh(GEN x, long prec) ++ GEN gtanh(GEN x, long prec) + void mpbern(long nomb, long prec) ++ GEN mpfactr(long n, long prec) ++ GEN sumformal(GEN T, long v) + + # trans3.c + +- GEN agm(GEN x, GEN y, long prec) + GEN dilog(GEN x, long prec) + GEN eint1(GEN x, long prec) + GEN eta(GEN x, long prec) +- GEN eta0(GEN x, long flag,long prec) ++ GEN eta0(GEN x, long flag, long prec) + GEN gerfc(GEN x, long prec) + GEN gpolylog(long m, GEN x, long prec) + GEN gzeta(GEN x, long prec) + GEN hyperu(GEN a, GEN b, GEN gx, long prec) + GEN incgam(GEN a, GEN x, long prec) +- GEN incgam0(GEN a, GEN x, GEN z,long prec) ++ GEN incgam0(GEN a, GEN x, GEN z, long prec) + GEN incgamc(GEN a, GEN x, long prec) + GEN hbessel1(GEN n, GEN z, long prec) + GEN hbessel2(GEN n, GEN z, long prec) + GEN ibessel(GEN n, GEN z, long prec) + GEN jbessel(GEN n, GEN z, long prec) + GEN jbesselh(GEN n, GEN z, long prec) ++ GEN mpeint1(GEN x, GEN expx) ++ GEN mplambertW(GEN y) ++ GEN mpveceint1(GEN C, GEN eC, long n) ++ GEN powruvec(GEN e, ulong n) + GEN nbessel(GEN n, GEN z, long prec) + GEN jell(GEN x, long prec) + GEN kbessel(GEN nu, GEN gx, long prec) +- GEN polylog(long m, GEN x, long prec) + GEN polylog0(long m, GEN x, long flag, long prec) ++ GEN sumdedekind_coprime(GEN h, GEN k) ++ GEN sumdedekind(GEN h, GEN k) + GEN szeta(long x, long prec) + GEN theta(GEN q, GEN z, long prec) + GEN thetanullk(GEN q, long k, long prec) + GEN trueeta(GEN x, long prec) +- GEN veceint1(GEN C, GEN nmax, long prec) ++ GEN u_sumdedekind_coprime(long h, long k) ++ GEN veceint1(GEN nmax, GEN C, long prec) + GEN vecthetanullk(GEN q, long k, long prec) +- GEN weber0(GEN x, long flag,long prec) ++ GEN vecthetanullk_tau(GEN tau, long k, long prec) ++ GEN weber0(GEN x, long flag, long prec) + GEN weberf(GEN x, long prec) ++ GEN weberf1(GEN x, long prec) + GEN weberf2(GEN x, long prec) ++ GEN glambertW(GEN y, long prec) + + # gmp/int.h + long* int_MSW(GEN x) +@@ -1916,8 +3721,15 @@ cdef extern from 'pari/pari.h': + long* int_precW(long * xp) + long* int_nextW(long * xp) + +- # misc... +- extern char* diffptr ++ # paristio.h ++ ++ struct PariOUT: ++ void (*putch)(char) ++ void (*puts)(char*) ++ void (*flush)() ++ extern PariOUT* pariOut ++ extern PariOUT* pariErr ++ extern byteptr diffptr + + cdef extern from 'stdsage.h': + GEN set_gel(GEN x, long n, GEN z) # gel(x,n) = z +@@ -1929,15 +3741,6 @@ cdef extern from 'stdsage.h': + include 'declinl.pxi' + + +-cdef extern from *: # paristio.h +- struct PariOUT: +- void (*putch)(char) +- void (*puts)(char*) +- void (*flush)() +- extern PariOUT* pariOut +- extern PariOUT* pariErr +- +- + cdef extern from 'pari/paripriv.h': + int gpd_QUIET, gpd_TEST, gpd_EMACS, gpd_TEXMACS + +diff --git a/src/sage/libs/pari/gen.pyx b/src/sage/libs/pari/gen.pyx +index 71b3f14..981bd1f 100644 +--- a/src/sage/libs/pari/gen.pyx ++++ b/src/sage/libs/pari/gen.pyx +@@ -23,6 +23,8 @@ AUTHORS: + - Peter Bruin (2013-11-17): move PariInstance to a separate file + (#15185) + ++ - Jeroen Demeyer (2014-02-09): upgrade to PARI 2.7 (#15767) ++ + """ + + #***************************************************************************** +@@ -332,7 +334,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: K.getattr("reg") + Traceback (most recent call last): + ... +- PariError: _.reg: incorrect type in reg ++ PariError: _.reg: incorrect type in reg (t_VEC) + sage: K.getattr("zzz") + Traceback (most recent call last): + ... +@@ -385,14 +387,15 @@ cdef class gen(sage.structure.element.RingElement): + sage: bnr.nf_get_pol() + x^4 - 4*x^2 + 1 + +- For relative extensions, this returns the absolute polynomial, +- not the relative one:: ++ For relative number fields, this returns the relative ++ polynomial. However, beware that ``pari(L)`` returns an absolute ++ number field:: + + sage: L. = K.extension(x^2 - 5) +- sage: pari(L).nf_get_pol() # Absolute polynomial ++ sage: pari(L).nf_get_pol() # Absolute + y^8 - 28*y^6 + 208*y^4 - 408*y^2 + 36 +- sage: L.pari_rnf().nf_get_pol() +- x^8 - 28*x^6 + 208*x^4 - 408*x^2 + 36 ++ sage: L.pari_rnf().nf_get_pol() # Relative ++ x^2 - 5 + + TESTS:: + +@@ -408,7 +411,8 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari("[0]").nf_get_pol() + Traceback (most recent call last): + ... +- PariError: incorrect type in pol ++ PariError: incorrect type in pol (t_VEC) ++ + """ + pari_catch_sig_on() + return P.new_gen(member_pol(self.g)) +@@ -555,7 +559,7 @@ cdef class gen(sage.structure.element.RingElement): + + sage: K. = QuadraticField(-1) + sage: F = pari(K).idealfactor(K.ideal(5)); F +- [[5, [-2, 1]~, 1, 1, [2, 1]~], 1; [5, [2, 1]~, 1, 1, [-2, 1]~], 1] ++ [[5, [-2, 1]~, 1, 1, [2, -1; 1, 2]], 1; [5, [2, 1]~, 1, 1, [-2, -1; 1, -2]], 1] + sage: F[0,0].pr_get_p() + 5 + """ +@@ -1152,9 +1156,11 @@ cdef class gen(sage.structure.element.RingElement): + -36bb1e3929d1a8fe2802f083 + """ + cdef GEN x +- cdef long lx, *xp ++ cdef long lx ++ cdef long *xp + cdef long w +- cdef char *s, *sp ++ cdef char *s ++ cdef char *sp + cdef char *hexdigits + hexdigits = "0123456789abcdef" + cdef int i, j +@@ -1379,7 +1385,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: complex(g) + Traceback (most recent call last): + ... +- PariError: incorrect type in greal/gimag ++ PariError: incorrect type in greal/gimag (t_INTMOD) + """ + cdef double re, im + pari_catch_sig_on() +@@ -1735,7 +1741,9 @@ cdef class gen(sage.structure.element.RingElement): + moebius(x): Moebius function of x. + """ + pari_catch_sig_on() +- return P.new_gen(gmoebius(x.g)) ++ r = moebius(x.g) ++ pari_catch_sig_off() ++ return r + + def sign(gen x): + """ +@@ -1757,7 +1765,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari(I).sign() + Traceback (most recent call last): + ... +- PariError: incorrect type in gsigne ++ PariError: incorrect type in gsigne (t_COMPLEX) + + """ + pari_catch_sig_on() +@@ -2055,7 +2063,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('x+y').Pol('y') + Traceback (most recent call last): + ... +- PariError: variable must have higher priority in gtopoly ++ PariError: incorrect priority in gtopoly: variable x < y + + INPUT: + +@@ -2174,7 +2182,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari(3).Qfb(7, 2) # discriminant is 25 + Traceback (most recent call last): + ... +- PariError: square discriminant in Qfb ++ PariError: domain error in Qfb: issquare(disc) = 1 + """ + cdef gen t0 = objtogen(b) + cdef gen t1 = objtogen(c) +@@ -2281,17 +2289,17 @@ cdef class gen(sage.structure.element.RingElement): + EXAMPLES:: + + sage: pari([1,5,2]).Set() +- ["1", "2", "5"] ++ [1, 2, 5] + sage: pari([]).Set() # the empty set + [] + sage: pari([1,1,-1,-1,3,3]).Set() +- ["-1", "1", "3"] ++ [-1, 1, 3] + sage: pari(1).Set() +- ["1"] ++ [1] + sage: pari('1/(x*y)').Set() +- ["1/(y*x)"] ++ [1/(y*x)] + sage: pari('["bc","ab","bc"]').Set() +- ["\"ab\"", "\"bc\""] ++ ["ab", "bc"] + """ + pari_catch_sig_on() + return P.new_gen(gtoset(x.g)) +@@ -2557,9 +2565,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari(1234).Vecsmall() + Vecsmall([1234]) + sage: pari('x^2 + 2*x + 3').Vecsmall() +- Traceback (most recent call last): +- ... +- PariError: incorrect type in vectosmall ++ Vecsmall([1, 2, 3]) + + We demonstate the `n` argument:: + +@@ -2595,7 +2601,7 @@ cdef class gen(sage.structure.element.RingElement): + EXAMPLES:: + + sage: pari(0).binary() +- [0] ++ [] + sage: pari(-5).binary() + [1, 0, 1] + sage: pari(5).binary() +@@ -2967,7 +2973,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('x').component(0) + Traceback (most recent call last): + ... +- PariError: nonexistent component ++ PariError: non-existent component: index < 1 + """ + pari_catch_sig_on() + return P.new_gen(compo(x.g, n)) +@@ -2999,7 +3005,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('Mod(x,x^3-3)').conj() + Traceback (most recent call last): + ... +- PariError: incorrect type in gconj ++ PariError: incorrect type in gconj (t_POLMOD) + """ + pari_catch_sig_on() + return P.new_gen(gconj(x.g)) +@@ -3023,7 +3029,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('Mod(1+x,x^2-2)').conjvec() + [-0.414213562373095, 2.41421356237310]~ + sage: pari('Mod(x,x^3-3)').conjvec() +- [1.44224957030741, -0.721124785153704 + 1.24902476648341*I, -0.721124785153704 - 1.24902476648341*I]~ ++ [1.44224957030741, -0.721124785153704 - 1.24902476648341*I, -0.721124785153704 + 1.24902476648341*I]~ + sage: pari('Mod(1+x,x^2-2)').conjvec(precision=192)[0].sage() + -0.414213562373095048801688724209698078569671875376948073177 + """ +@@ -3098,7 +3104,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('"hello world"').floor() + Traceback (most recent call last): + ... +- PariError: incorrect type in gfloor ++ PariError: incorrect type in gfloor (t_STR) + """ + pari_catch_sig_on() + return P.new_gen(gfloor(x.g)) +@@ -3124,7 +3130,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('sqrt(-2)').frac() + Traceback (most recent call last): + ... +- PariError: incorrect type in gfloor ++ PariError: incorrect type in gfloor (t_COMPLEX) + """ + pari_catch_sig_on() + return P.new_gen(gfrac(x.g)) +@@ -3281,7 +3287,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: y.padicprec(17) + Traceback (most recent call last): + ... +- PariError: not the same prime in padicprec ++ PariError: inconsistent moduli in padicprec: 11 != 17 + + This works for polynomials too:: + +@@ -3740,7 +3746,7 @@ cdef class gen(sage.structure.element.RingElement): + """ + cdef gen t0 = objtogen(p) + pari_catch_sig_on() +- v = ggval(x.g, t0.g) ++ v = gvaluation(x.g, t0.g) + pari_catch_sig_off() + return v + +@@ -3881,7 +3887,7 @@ cdef class gen(sage.structure.element.RingElement): + 0.881373587019543 + 1.57079632679490*I + """ + pari_catch_sig_on() +- return P.new_gen(gach(x.g, prec_bits_to_words(precision))) ++ return P.new_gen(gacosh(x.g, prec_bits_to_words(precision))) + + def agm(gen x, y, unsigned long precision=0): + r""" +@@ -3972,7 +3978,7 @@ cdef class gen(sage.structure.element.RingElement): + 1.52857091948100 + 0.427078586392476*I + """ + pari_catch_sig_on() +- return P.new_gen(gash(x.g, prec_bits_to_words(precision))) ++ return P.new_gen(gasinh(x.g, prec_bits_to_words(precision))) + + def atan(gen x, unsigned long precision=0): + r""" +@@ -4015,7 +4021,7 @@ cdef class gen(sage.structure.element.RingElement): + 0.549306144334055 - 1.57079632679490*I + """ + pari_catch_sig_on() +- return P.new_gen(gath(x.g, prec_bits_to_words(precision))) ++ return P.new_gen(gatanh(x.g, prec_bits_to_words(precision))) + + def bernfrac(gen x): + r""" +@@ -4064,10 +4070,14 @@ cdef class gen(sage.structure.element.RingElement): + EXAMPLES:: + + sage: pari(8).bernvec() ++ doctest:...: DeprecationWarning: bernvec() is deprecated, use repeated calls to bernfrac() instead ++ See http://trac.sagemath.org/15767 for details. + [1, 1/6, -1/30, 1/42, -1/30, 5/66, -691/2730, 7/6, -3617/510] + sage: [pari(2*n).bernfrac() for n in range(9)] + [1, 1/6, -1/30, 1/42, -1/30, 5/66, -691/2730, 7/6, -3617/510] + """ ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'bernvec() is deprecated, use repeated calls to bernfrac() instead') + pari_catch_sig_on() + return P.new_gen(bernvec(x)) + +@@ -4152,8 +4162,7 @@ cdef class gen(sage.structure.element.RingElement): + EXAMPLES:: + + sage: pari(2).besseljh(3) +- 0.4127100324 # 32-bit +- 0.412710032209716 # 64-bit ++ 0.412710032209716 + """ + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +@@ -4291,7 +4300,7 @@ cdef class gen(sage.structure.element.RingElement): + 1 + 1/2*x^2 + 1/24*x^4 + 1/720*x^6 + O(x^8) + """ + pari_catch_sig_on() +- return P.new_gen(gch(x.g, prec_bits_to_words(precision))) ++ return P.new_gen(gcosh(x.g, prec_bits_to_words(precision))) + + def cotan(gen x, unsigned long precision=0): + """ +@@ -4470,7 +4479,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari(-1).gamma() + Traceback (most recent call last): + ... +- PariError: non-positive integer argument in ggamma ++ PariError: domain error in gamma: argument = non-positive integer + """ + pari_catch_sig_on() + return P.new_gen(ggamma(s.g, prec_bits_to_words(precision))) +@@ -4495,7 +4504,7 @@ cdef class gen(sage.structure.element.RingElement): + 0.575315188063452 + 0.0882106775440939*I + """ + pari_catch_sig_on() +- return P.new_gen(ggamd(s.g, prec_bits_to_words(precision))) ++ return P.new_gen(ggammah(s.g, prec_bits_to_words(precision))) + + def hyperu(gen a, b, x, unsigned long precision=0): + r""" +@@ -4614,19 +4623,13 @@ cdef class gen(sage.structure.element.RingElement): + + def lngamma(gen x, unsigned long precision=0): + r""" +- This method is deprecated, please use :meth:`.log_gamma` instead. +- +- See the :meth:`.log_gamma` method for documentation and examples. ++ Alias for :meth:`log_gamma`. + + EXAMPLES:: + + sage: pari(100).lngamma() +- doctest:...: DeprecationWarning: The method lngamma() is deprecated. Use log_gamma() instead. +- See http://trac.sagemath.org/6992 for details. + 359.134205369575 + """ +- from sage.misc.superseded import deprecation +- deprecation(6992, "The method lngamma() is deprecated. Use log_gamma() instead.") + return x.log_gamma(precision) + + def log_gamma(gen x, unsigned long precision=0): +@@ -4741,7 +4744,7 @@ cdef class gen(sage.structure.element.RingElement): + 0.634963914784736 + 1.29845758141598*I + """ + pari_catch_sig_on() +- return P.new_gen(gsh(x.g, prec_bits_to_words(precision))) ++ return P.new_gen(gsinh(x.g, prec_bits_to_words(precision))) + + def sqr(gen x): + """ +@@ -4834,11 +4837,11 @@ cdef class gen(sage.structure.element.RingElement): + sage: s^5 + 2.00000000000000 + sage: z^5 +- 1.00000000000000 + 5.42101086 E-19*I # 32-bit +- 1.00000000000000 + 5.96311194867027 E-19*I # 64-bit ++ 1.00000000000000 - 2.710505431 E-20*I # 32-bit ++ 1.00000000000000 - 2.71050543121376 E-20*I # 64-bit + sage: (s*z)^5 +- 2.00000000000000 + 1.409462824 E-18*I # 32-bit +- 2.00000000000000 + 9.21571846612679 E-19*I # 64-bit ++ 2.00000000000000 + 0.E-19*I # 32-bit ++ 2.00000000000000 - 1.08420217248550 E-19*I # 64-bit + """ + # TODO: ??? lots of good examples in the PARI docs ??? + cdef GEN zetan +@@ -4890,7 +4893,7 @@ cdef class gen(sage.structure.element.RingElement): + 1.55740772465490 + """ + pari_catch_sig_on() +- return P.new_gen(gth(x.g, prec_bits_to_words(precision))) ++ return P.new_gen(gtanh(x.g, prec_bits_to_words(precision))) + + def teichmuller(gen x): + r""" +@@ -4964,8 +4967,7 @@ cdef class gen(sage.structure.element.RingElement): + + sage: C. = ComplexField() + sage: pari(i).weber() +- 1.18920711500272 + 0.E-19*I # 32-bit +- 1.18920711500272 + 2.71050543121376 E-20*I # 64-bit ++ 1.18920711500272 + sage: pari(i).weber(1) + 1.09050773266526 + sage: pari(i).weber(2) +@@ -5246,17 +5248,19 @@ cdef class gen(sage.structure.element.RingElement): + 4 + """ + pari_catch_sig_on() +- return P.new_gen(gnumbdiv(n.g)) ++ return P.new_gen(numdiv(n.g)) + + def phi(gen n): + """ +- Return the Euler phi function of n. EXAMPLES:: ++ Return the Euler phi function of n. ++ ++ EXAMPLES:: + + sage: pari(10).phi() + 4 + """ + pari_catch_sig_on() +- return P.new_gen(geulerphi(n.g)) ++ return P.new_gen(eulerphi(n.g)) + + def primepi(gen self): + """ +@@ -5390,11 +5394,9 @@ cdef class gen(sage.structure.element.RingElement): + INPUT: + + +- - ``self`` - a list of 5 coefficients ++ - ``self`` -- a list of 5 coefficients + +- - ``flag (optional, default: 0)`` - if 0, ask for a PARI ell +- structure with 19 components; if 1, ask for a shorted PARI +- sell structure with only the first 13 components. ++ - ``flag`` -- ignored (for backwards compatibility) + + - ``precision (optional, default: 0)`` - the real + precision to be used in the computation of the components of the +@@ -5412,80 +5414,62 @@ cdef class gen(sage.structure.element.RingElement): + + OUTPUT: + ++ - ``gen`` - a PARI ell structure. + +- - ``gen`` - either a PARI ell structure with 19 components +- (if flag=0), or a PARI sell structure with 13 components +- (if flag=1). +- +- +- EXAMPLES: An elliptic curve with integer coefficients:: ++ EXAMPLES: ++ ++ An elliptic curve with integer coefficients:: + + sage: e = pari([0,1,0,1,0]).ellinit(); e +- [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, [0.E-28, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~, 3.37150070962519, -1.68575035481260 - 2.15651564749964*I, 1.37451455785745 - 1.084202173 E-19*I, -0.687257278928726 + 0.984434956803824*I, 7.27069403586288] # 32-bit +- [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, [0.E-38, -0.500000000000000 - 0.866025403784439*I, -0.500000000000000 + 0.866025403784439*I]~, 3.37150070962519, -1.68575035481260 - 2.15651564749964*I, 1.37451455785745 - 5.42101086242752 E-19*I, -0.687257278928726 + 0.984434956803824*I, 7.27069403586288] # 64-bit +- +- Its inexact components have the default precision of 53 bits:: +- +- sage: RR(e[14]) +- 3.37150070962519 +- +- We can compute this to higher precision:: +- +- sage: R = RealField(150) +- sage: e = pari([0,1,0,1,0]).ellinit(precision=150) +- sage: R(e[14]) +- 3.3715007096251920857424073155981539790016018 +- +- Using flag=1 returns a short elliptic curve PARI object:: +- +- sage: pari([0,1,0,1,0]).ellinit(flag=1) +- [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3] ++ [0, 1, 0, 1, 0, 4, 2, 0, -1, -32, 224, -48, 2048/3, Vecsmall([1]), [Vecsmall([64, -1])], [0, 0, 0, 0, 0, 0, 0, 0]] + + The coefficients can be any ring elements that convert to PARI:: + +- sage: pari([0,1/2,0,-3/4,0]).ellinit(flag=1) +- [0, 1/2, 0, -3/4, 0, 2, -3/2, 0, -9/16, 40, -116, 117/4, 256000/117] +- sage: pari([0,0.5,0,-0.75,0]).ellinit(flag=1) +- [0, 0.500000000000000, 0, -0.750000000000000, 0, 2.00000000000000, -1.50000000000000, 0, -0.562500000000000, 40.0000000000000, -116.000000000000, 29.2500000000000, 2188.03418803419] +- sage: pari([0,I,0,1,0]).ellinit(flag=1) +- [0, I, 0, 1, 0, 4*I, 2, 0, -1, -64, 352*I, -80, 16384/5] +- sage: pari([0,x,0,2*x,1]).ellinit(flag=1) +- [0, x, 0, 2*x, 1, 4*x, 4*x, 4, -4*x^2 + 4*x, 16*x^2 - 96*x, -64*x^3 + 576*x^2 - 864, 64*x^4 - 576*x^3 + 576*x^2 - 432, (256*x^6 - 4608*x^5 + 27648*x^4 - 55296*x^3)/(4*x^4 - 36*x^3 + 36*x^2 - 27)] ++ sage: pari([0,1/2,0,-3/4,0]).ellinit() ++ [0, 1/2, 0, -3/4, 0, 2, -3/2, 0, -9/16, 40, -116, 117/4, 256000/117, Vecsmall([1]), [Vecsmall([64, 1])], [0, 0, 0, 0, 0, 0, 0, 0]] ++ sage: pari([0,0.5,0,-0.75,0]).ellinit() ++ [0, 0.500000000000000, 0, -0.750000000000000, 0, 2.00000000000000, -1.50000000000000, 0, -0.562500000000000, 40.0000000000000, -116.000000000000, 29.2500000000000, 2188.03418803419, Vecsmall([0]), [Vecsmall([64, 1])], [0, 0, 0, 0]] ++ sage: pari([0,I,0,1,0]).ellinit() ++ [0, I, 0, 1, 0, 4*I, 2, 0, -1, -64, 352*I, -80, 16384/5, Vecsmall([0]), [Vecsmall([64, 0])], [0, 0, 0, 0]] ++ sage: pari([0,x,0,2*x,1]).ellinit() ++ [0, x, 0, 2*x, 1, 4*x, 4*x, 4, -4*x^2 + 4*x, 16*x^2 - 96*x, -64*x^3 + 576*x^2 - 864, 64*x^4 - 576*x^3 + 576*x^2 - 432, (256*x^6 - 4608*x^5 + 27648*x^4 - 55296*x^3)/(4*x^4 - 36*x^3 + 36*x^2 - 27), Vecsmall([0]), [Vecsmall([64, 0])], [0, 0, 0, 0]] + """ ++ if flag: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The flag argument to ellinit() is deprecated and not used anymore') + pari_catch_sig_on() +- return P.new_gen(ellinit0(self.g, flag, prec_bits_to_words(precision))) ++ return P.new_gen(ellinit(self.g, NULL, prec_bits_to_words(precision))) + + def ellglobalred(self): + """ +- e.ellglobalred(): return information related to the global minimal +- model of the elliptic curve e. ++ Return information related to the global minimal model of the ++ elliptic curve e. + + INPUT: + ++ - ``e`` -- elliptic curve (returned by ellinit) + +- - ``e`` - elliptic curve (returned by ellinit) ++ OUTPUT: A vector [N, [u,r,s,t], c, faN, L] with + ++ - ``N`` - the (arithmetic) conductor of `e` + +- OUTPUT: +- +- +- - ``gen`` - the (arithmetic) conductor of e +- +- - ``gen`` - a vector giving the coordinate change over ++ - ``[u,r,s,t]`` - a vector giving the coordinate change over + Q from e to its minimal integral model (see also ellminimalmodel) + +- - ``gen`` - the product of the local Tamagawa numbers +- of e ++ - ``c`` - the product of the local Tamagawa numbers of `e`. + ++ - ``faN`` is the factorization of `N` ++ ++ - ``L[i]`` is ``elllocalred(E, faN[i,1])`` + + EXAMPLES:: + + sage: e = pari([0, 5, 2, -1, 1]).ellinit() + sage: e.ellglobalred() +- [20144, [1, -2, 0, -1], 1] ++ [20144, [1, -2, 0, -1], 1, [2, 4; 1259, 1], [[4, 2, 0, 1], [1, 5, 0, 1]]] + sage: e = pari(EllipticCurve('17a').a_invariants()).ellinit() + sage: e.ellglobalred() +- [17, [1, 0, 0, 0], 4] ++ [17, [1, 0, 0, 0], 4, Mat([17, 1]), [[1, 8, 0, 4]]] + """ + pari_catch_sig_on() + return P.new_gen(ellglobalred(self.g)) +@@ -5507,11 +5491,11 @@ cdef class gen(sage.structure.element.RingElement): + + OUTPUT: point on E + +- EXAMPLES: First we create an elliptic curve:: ++ EXAMPLES: ++ ++ First we create an elliptic curve:: + + sage: e = pari([0, 1, 1, -2, 0]).ellinit() +- sage: str(e)[:65] # first part of output +- '[0, 1, 1, -2, 0, 4, -4, 1, -3, 112, -856, 389, 1404928/389, [0.90' + + Next we add two points on the elliptic curve. Notice that the + Python lists are automatically converted to PARI objects so you +@@ -5525,7 +5509,7 @@ cdef class gen(sage.structure.element.RingElement): + cdef gen t0 = objtogen(z0) + cdef gen t1 = objtogen(z1) + pari_catch_sig_on() +- return P.new_gen(addell(self.g, t0.g, t1.g)) ++ return P.new_gen(elladd(self.g, t0.g, t1.g)) + + def ellak(self, n): + r""" +@@ -5767,18 +5751,16 @@ cdef class gen(sage.structure.element.RingElement): + + INPUT: + +- + - ``e`` - elliptic curve + + - ``ch`` - change of coordinates vector with 4 + entries + +- + EXAMPLES:: + + sage: e = pari([1,2,3,4,5]).ellinit() + sage: e.ellglobalred() +- [10351, [1, -1, 0, -1], 1] ++ [10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]] + sage: f = e.ellchangecurve([1,-1,0,-1]) + sage: f[:5] + [1, -1, 0, 4, 3] +@@ -5804,10 +5786,6 @@ cdef class gen(sage.structure.element.RingElement): + 6.28318530717959*I + sage: w1*eta2-w2*eta1 == pari(2*pi*I) + True +- sage: pari([0,0,0,-82,0]).ellinit(flag=1).elleta() +- Traceback (most recent call last): +- ... +- PariError: incorrect type in elleta + """ + pari_catch_sig_on() + return P.new_gen(elleta(self.g, prec_bits_to_words(precision))) +@@ -5850,7 +5828,8 @@ cdef class gen(sage.structure.element.RingElement): + sage: e.ellheight([1,0], flag=1) + 0.476711659343740 + sage: e.ellheight([1,0], precision=128).sage() +- 0.47671165934373953737948605888465305932 ++ 0.47671165934373953737948605888465305945902294217 # 32-bit ++ 0.476711659343739537379486058884653059459022942211150879336 # 64-bit + """ + cdef gen t0 = objtogen(a) + pari_catch_sig_on() +@@ -5879,13 +5858,6 @@ cdef class gen(sage.structure.element.RingElement): + sage: e = pari([0,1,1,-2,0]).ellinit().ellminimalmodel()[0] + sage: e.ellheightmatrix([[1,0], [-1,1]]) + [0.476711659343740, 0.418188984498861; 0.418188984498861, 0.686667083305587] +- +- It is allowed to call :meth:`ellinit` with ``flag=1``:: +- +- sage: E = pari([0,1,1,-2,0]).ellinit(flag=1) +- sage: E.ellheightmatrix([[1,0], [-1,1]], precision=128).sage() +- [0.47671165934373953737948605888465305932 0.41818898449886058562988945821587638244] +- [0.41818898449886058562988945821587638244 0.68666708330558658572355210295409678904] + """ + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +@@ -6100,9 +6072,9 @@ cdef class gen(sage.structure.element.RingElement): + sage: e.elllseries(2.1) + 0.402838047956645 + sage: e.elllseries(1, precision=128) +- 2.87490929644255 E-38 ++ 2.98766720445395 E-38 + sage: e.elllseries(1, precision=256) +- 3.00282377034977 E-77 ++ 5.48956813891054 E-77 + sage: e.elllseries(-2) + 0 + sage: e.elllseries(2.1, A=1.1) +@@ -6217,8 +6189,6 @@ cdef class gen(sage.structure.element.RingElement): + [] + sage: e.ellordinate(5.0) + [11.3427192823270, -12.3427192823270] +- sage: e.ellordinate(RR(-3)) +- [-1/2 + 3.42782730020052*I, -1/2 - 3.42782730020052*I] + """ + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +@@ -6311,26 +6281,19 @@ cdef class gen(sage.structure.element.RingElement): + cdef gen t0 = objtogen(z) + cdef gen t1 = objtogen(n) + pari_catch_sig_on() +- return P.new_gen(powell(self.g, t0.g, t1.g)) ++ return P.new_gen(ellmul(self.g, t0.g, t1.g)) + +- def ellrootno(self, p=1): ++ def ellrootno(self, p=None): + """ +- e.ellrootno(p): return the (local or global) root number of the +- `L`-series of the elliptic curve e +- +- If p is a prime number, the local root number at p is returned. If +- p is 1, the global root number is returned. Note that the global +- root number is the sign of the functional equation of the +- `L`-series, and therefore conjecturally equal to the parity +- of the rank of e. ++ Return the root number for the L-function of the elliptic curve ++ E/Q at a prime p (including 0, for the infinite place); return ++ the global root number if p is omitted. + + INPUT: + +- + - ``e`` - elliptic curve over `\QQ` + +- - ``p (default = 1)`` - 1 or a prime number +- ++ - ``p`` - a prime number or ``None``. + + OUTPUT: 1 or -1 + +@@ -6344,9 +6307,19 @@ cdef class gen(sage.structure.element.RingElement): + sage: e.ellrootno(1009) + 1 + """ +- cdef gen t0 = objtogen(p) ++ cdef gen t0 ++ cdef GEN g0 ++ if p is None: ++ g0 = NULL ++ elif p == 1: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The argument p=1 in ellrootno() is deprecated, use p=None instead') ++ g0 = NULL ++ else: ++ t0 = objtogen(p) ++ g0 = t0.g + pari_catch_sig_on() +- rootno = ellrootno(self.g, t0.g) ++ rootno = ellrootno(self.g, g0) + pari_catch_sig_off() + return rootno + +@@ -6392,11 +6365,11 @@ cdef class gen(sage.structure.element.RingElement): + cdef gen t0 = objtogen(z0) + cdef gen t1 = objtogen(z1) + pari_catch_sig_on() +- return P.new_gen(subell(self.g, t0.g, t1.g)) ++ return P.new_gen(ellsub(self.g, t0.g, t1.g)) + +- def elltaniyama(self): ++ def elltaniyama(self, long n=16): + pari_catch_sig_on() +- return P.new_gen(taniyama(self.g)) ++ return P.new_gen(elltaniyama(self.g, n)) + + def elltors(self, long flag=0): + """ +@@ -6438,7 +6411,7 @@ cdef class gen(sage.structure.element.RingElement): + + sage: e = pari([1,0,1,-19,26]).ellinit() + sage: e.elltors() +- [12, [6, 2], [[-2, 8], [3, -2]]] ++ [12, [6, 2], [[1, 2], [3, -2]]] + """ + pari_catch_sig_on() + return P.new_gen(elltors0(self.g, flag)) +@@ -6467,8 +6440,7 @@ cdef class gen(sage.structure.element.RingElement): + + sage: e = pari([0,0,0,1,0]).ellinit() + sage: e.ellzeta(1) +- 1.06479841295883 + 0.E-19*I # 32-bit +- 1.06479841295883 + 5.42101086242752 E-20*I # 64-bit ++ 1.06479841295883 + sage: C. = ComplexField() + sage: e.ellzeta(i-1) + -0.350122658523049 - 0.350122658523049*I +@@ -6498,8 +6470,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: e = pari([0,0,0,1,0]).ellinit() + sage: C. = ComplexField() + sage: e.ellztopoint(1+i) +- [0.E-19 - 1.02152286795670*I, -0.149072813701096 - 0.149072813701096*I] # 32-bit +- [7.96075508054992 E-21 - 1.02152286795670*I, -0.149072813701096 - 0.149072813701096*I] # 64-bit ++ [0.E-19 - 1.02152286795670*I, -0.149072813701096 - 0.149072813701096*I] + + Complex numbers belonging to the period lattice of e are of course + sent to the point at infinity on e:: +@@ -6511,7 +6482,7 @@ cdef class gen(sage.structure.element.RingElement): + pari_catch_sig_on() + return P.new_gen(pointell(self.g, t0.g, prec_bits_to_words(precision))) + +- def omega(self): ++ def omega(self, unsigned long precision=0): + """ + e.omega(): return basis for the period lattice of the elliptic + curve e. +@@ -6520,9 +6491,10 @@ cdef class gen(sage.structure.element.RingElement): + + sage: e = pari([0, -1, 1, -10, -20]).ellinit() + sage: e.omega() +- [1.26920930427955, -0.634604652139777 - 1.45881661693850*I] ++ [1.26920930427955, 0.634604652139777 - 1.45881661693850*I] + """ +- return self[14:16] ++ pari_catch_sig_on() ++ return P.new_gen(ellR_omega(self.g, prec_bits_to_words(precision))) + + def disc(self): + """ +@@ -6536,7 +6508,8 @@ cdef class gen(sage.structure.element.RingElement): + sage: _.factor() + [-1, 1; 11, 5] + """ +- return self[11] ++ pari_catch_sig_on() ++ return P.new_gen(member_disc(self.g)) + + def j(self): + """ +@@ -6550,7 +6523,8 @@ cdef class gen(sage.structure.element.RingElement): + sage: _.factor() + [-1, 1; 2, 12; 11, -5; 31, 3] + """ +- return self[12] ++ pari_catch_sig_on() ++ return P.new_gen(member_j(self.g)) + + def ellj(self, unsigned long precision=0): + """ +@@ -6569,7 +6543,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari(-I).ellj() + Traceback (most recent call last): + ... +- PariError: argument '-I' does not belong to upper half-plane ++ PariError: domain error in modular function: Im(argument) <= 0 + """ + pari_catch_sig_on() + return P.new_gen(jell(self.g, prec_bits_to_words(precision))) +@@ -6867,7 +6841,7 @@ cdef class gen(sage.structure.element.RingElement): + + sage: K. = QuadraticField(-1) + sage: F = pari(K).idealprimedec(5); F +- [[5, [-2, 1]~, 1, 1, [2, 1]~], [5, [2, 1]~, 1, 1, [-2, 1]~]] ++ [[5, [-2, 1]~, 1, 1, [2, -1; 1, 2]], [5, [2, 1]~, 1, 1, [-2, -1; 1, -2]]] + sage: F[0].pr_get_p() + 5 + """ +@@ -6909,7 +6883,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: nf = F._pari_() + sage: I = pari('[1, -1, 2]~') + sage: nf.idealstar(I) +- [[[43, 9, 5; 0, 1, 0; 0, 0, 1], [0]], [42, [42]], Mat([[43, [9, 1, 0]~, 1, 1, [-5, -9, 1]~], 1]), [[[[42], [[3, 0, 0]~], [[3, 0, 0]~], [Vecsmall([])], 1]], [[], [], []]], Mat(1)] ++ [[[43, 9, 5; 0, 1, 0; 0, 0, 1], [0]], [42, [42]], Mat([[43, [9, 1, 0]~, 1, 1, [-5, 2, -18; -9, -5, 2; 1, -9, -5]], 1]), [[[[42], [3], [3], [Vecsmall([])], 1]], [[], [], []]], Mat(1)] + """ + cdef gen t0 = objtogen(I) + pari_catch_sig_on() +@@ -6953,18 +6927,30 @@ cdef class gen(sage.structure.element.RingElement): + + def nfbasis(self, long flag=0, fa=None): + """ +- nfbasis(x, flag, fa): integral basis of the field QQ[a], where ``a`` is +- a root of the polynomial x. ++ Integral basis of the field `\QQ[a]`, where ``a`` is a root of ++ the polynomial x. + +- Binary digits of ``flag`` mean: ++ INPUT: ++ ++ - ``flag``: if set to 1 and ``fa`` is not given: assume that no ++ square of a prime > 500000 divides the discriminant of ``x``. ++ ++ - ``fa``: If present, encodes a subset of primes at which to ++ check for maximality. This must be one of the three following ++ things: ++ ++ - an integer: check all primes up to ``fa`` using trial ++ division. + +- - 1: assume that no square of a prime>primelimit divides the +- discriminant of ``x``. +- - 2: use round 2 algorithm instead of round 4. ++ - a vector: a list of primes to check. ++ ++ - a matrix: a partial factorization of the discriminant ++ of ``x``. ++ ++ .. NOTE:: + +- If present, ``fa`` provides the matrix of a partial factorization of +- the discriminant of ``x``, useful if one wants only an order maximal at +- certain primes only. ++ In earlier versions of Sage, other bits in ``flag`` were ++ defined but these are now simply ignored. + + EXAMPLES:: + +@@ -6981,29 +6967,34 @@ cdef class gen(sage.structure.element.RingElement): + [1, x] + sage: pari(f).nfbasis() # Correct result + [1, 1/10000000019*x] +- sage: pari(f).nfbasis(fa = "[2,2; %s,2]"%p) # Correct result and faster ++ sage: pari(f).nfbasis(fa=10^6) # Check primes up to 10^6: wrong result ++ [1, x] ++ sage: pari(f).nfbasis(fa="[2,2; %s,2]"%p) # Correct result and faster ++ [1, 1/10000000019*x] ++ sage: pari(f).nfbasis(fa=[2,p]) # Equivalent with the above + [1, 1/10000000019*x] +- +- TESTS: +- +- ``flag`` = 2 should give the same result:: +- +- sage: pari('x^3 - 17').nfbasis(flag = 2) +- [1, x, 1/3*x^2 - 1/3*x + 1/3] + """ ++ if flag < 0 or flag > 1: ++ flag = flag & 1 ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'In nfbasis(), flag must be 0 or 1, other bits are deprecated and ignored') ++ + cdef gen t0 +- if not fa: +- pari_catch_sig_on() +- return P.new_gen(nfbasis0(self.g, flag, NULL)) +- else: ++ cdef GEN g0 ++ if fa is not None: + t0 = objtogen(fa) +- pari_catch_sig_on() +- return P.new_gen(nfbasis0(self.g, flag, t0.g)) ++ g0 = t0.g ++ elif flag: ++ g0 = utoi(500000) ++ else: ++ g0 = NULL ++ pari_catch_sig_on() ++ return P.new_gen(nfbasis(self.g, NULL, g0)) + + def nfbasis_d(self, long flag=0, fa=None): + """ +- nfbasis_d(x): Return a basis of the number field defined over QQ +- by x and its discriminant. ++ Like :meth:`nfbasis`, but return a tuple ``(B, D)`` where `B` ++ is the integral basis and `D` the discriminant. + + EXAMPLES:: + +@@ -7022,15 +7013,23 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari([-2,0,0,1]).Polrev().nfbasis_d() + ([1, x, x^2], -108) + """ ++ if flag < 0 or flag > 1: ++ flag = flag & 1 ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'In nfbasis_d(), flag must be 0 or 1, other bits are deprecated and ignored') ++ + cdef gen t0 ++ cdef GEN g0 + cdef GEN disc +- if not fa: +- pari_catch_sig_on() +- B = P.new_gen_noclear(nfbasis(self.g, &disc, flag, NULL)) +- else: ++ if fa is not None: + t0 = objtogen(fa) +- pari_catch_sig_on() +- B = P.new_gen_noclear(nfbasis(self.g, &disc, flag, t0.g)) ++ g0 = t0.g ++ elif flag & 1: ++ g0 = utoi(500000) ++ else: ++ g0 = NULL ++ pari_catch_sig_on() ++ B = P.new_gen_noclear(nfbasis(self.g, &disc, g0)) + D = P.new_gen(disc) + return B, D + +@@ -7247,18 +7246,13 @@ cdef class gen(sage.structure.element.RingElement): + sage: A = matrix(F,[[1,2,a,3],[3,0,a+2,0],[0,0,a,2],[3+a,a,0,1]]) + sage: I = [F.ideal(-2*a+1),F.ideal(7), F.ideal(3),F.ideal(1)] + sage: Fp.nfhnf([pari(A),[pari(P) for P in I]]) +- [[1, [-969/5, -1/15]~, [15, -2]~, [-1938, -3]~; 0, 1, 0, 0; 0, 0, 1, 0; +- 0, 0, 0, 1], [[3997, 1911; 0, 7], [15, 6; 0, 3], [1, 0; 0, 1], [1, 0; 0, +- 1]]] ++ [[1, [-969/5, -1/15]~, [15, -2]~, [-1938, -3]~; 0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1], [[3997, 1911; 0, 7], [15, 6; 0, 3], 1, 1]] + sage: K. = NumberField(x^3-2) + sage: Kp = pari(K) + sage: A = matrix(K,[[1,0,0,5*b],[1,2*b^2,b,57],[0,2,1,b^2-3],[2,0,0,b]]) + sage: I = [K.ideal(2),K.ideal(3+b^2),K.ideal(1),K.ideal(1)] + sage: Kp.nfhnf([pari(A),[pari(P) for P in I]]) +- [[1, -225, 72, -31; 0, 1, [0, -1, 0]~, [0, 0, -1/2]~; 0, 0, 1, [0, 0, +- -1/2]~; 0, 0, 0, 1], [[1116, 756, 612; 0, 18, 0; 0, 0, 18], [2, 0, 0; 0, +- 2, 0; 0, 0, 2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [2, 0, 0; 0, 1, 0; 0, 0, +- 1]]] ++ [[1, -225, 72, -31; 0, 1, [0, -1, 0]~, [0, 0, -1/2]~; 0, 0, 1, [0, 0, -1/2]~; 0, 0, 0, 1], [[1116, 756, 612; 0, 18, 0; 0, 0, 18], 2, 1, [2, 0, 0; 0, 1, 0; 0, 0, 1]]] + + An example where the ring of integers of the number field is not a PID:: + +@@ -7267,15 +7261,11 @@ cdef class gen(sage.structure.element.RingElement): + sage: A = matrix(K,[[1,0,0,5*b],[1,2*b^2,b,57],[0,2,1,b^2-3],[2,0,0,b]]) + sage: I = [K.ideal(2),K.ideal(3+b^2),K.ideal(1),K.ideal(1)] + sage: Kp.nfhnf([pari(A),[pari(P) for P in I]]) +- [[1, [15, 6]~, [0, -54]~, [113, 72]~; 0, 1, [-4, -1]~, [0, -1]~; 0, 0, +- 1, 0; 0, 0, 0, 1], [[360, 180; 0, 180], [6, 4; 0, 2], [1, 0; 0, 1], [1, +- 0; 0, 1]]] ++ [[1, [15, 6]~, [0, -54]~, [113, 72]~; 0, 1, [-4, -1]~, [0, -1]~; 0, 0, 1, 0; 0, 0, 0, 1], [[360, 180; 0, 180], [6, 4; 0, 2], 1, 1]] + sage: A = matrix(K,[[1,0,0,5*b],[1,2*b,b,57],[0,2,1,b-3],[2,0,b,b]]) + sage: I = [K.ideal(2).factor()[0][0],K.ideal(3+b),K.ideal(1),K.ideal(1)] + sage: Kp.nfhnf([pari(A),[pari(P) for P in I]]) +- [[1, [7605, 4]~, [5610, 5]~, [7913, -6]~; 0, 1, 0, -1; 0, 0, 1, 0; 0, 0, +- 0, 1], [[19320, 13720; 0, 56], [2, 1; 0, 1], [1, 0; 0, 1], [1, 0; 0, +- 1]]] ++ [[1, [7605, 4]~, [5610, 5]~, [7913, -6]~; 0, 1, 0, -1; 0, 0, 1, 0; 0, 0, 0, 1], [[19320, 13720; 0, 56], [2, 1; 0, 1], 1, 1]] + + AUTHORS: + +@@ -7302,41 +7292,19 @@ cdef class gen(sage.structure.element.RingElement): + EXAMPLES:: + + sage: pari('x^3 - 17').nfinit() +- [x^3 - 17, [1, 1], -867, 3, [[1, 1.68006..., 2.57128...; 1, -0.340034... + 2.65083...*I, -1.28564... - 2.22679...*I], [1, 1.68006..., 2.57128...; 1, 2.31080..., -3.51243...; 1, -2.99087..., 0.941154...], [1, 2, 3; 1, 2, -4; 1, -3, 1], [3, 1, 0; 1, -11, 17; 0, 17, 0], [51, 0, 16; 0, 17, 3; 0, 0, 1], [17, 0, -1; 0, 0, 3; -1, 3, 2], [51, [-17, 6, -1; 0, -18, 3; 1, 0, -16]]], [2.57128..., -1.28564... - 2.22679...*I], [1, 1/3*x^2 - 1/3*x + 1/3, x], [1, 0, -1; 0, 0, 3; 0, 1, 1], [1, 0, 0, 0, -4, 6, 0, 6, -1; 0, 1, 0, 1, 1, -1, 0, -1, 3; 0, 0, 1, 0, 2, 0, 1, 0, 1]] +- +- TESTS: ++ [x^3 - 17, [1, 1], -867, 3, [[1, 1.68006914259990, 2.57128159065824; 1, -0.340034571299952 - 2.65083754153991*I, -1.28564079532912 + 2.22679517779329*I], [1, 1.68006914259990, 2.57128159065824; 1, -2.99087211283986, 0.941154382464174; 1, 2.31080297023995, -3.51243597312241], [1, 2, 3; 1, -3, 1; 1, 2, -4], [3, 1, 0; 1, -11, 17; 0, 17, 0], [51, 0, 16; 0, 17, 3; 0, 0, 1], [17, 0, -1; 0, 0, 3; -1, 3, 2], [51, [-17, 6, -1; 0, -18, 3; 1, 0, -16]], [3, 17]], [2.57128159065824, -1.28564079532912 + 2.22679517779329*I], [1, 1/3*x^2 - 1/3*x + 1/3, x], [1, 0, -1; 0, 0, 3; 0, 1, 1], [1, 0, 0, 0, -4, 6, 0, 6, -1; 0, 1, 0, 1, 1, -1, 0, -1, 3; 0, 0, 1, 0, 2, 0, 1, 0, 1]] + +- This example only works after increasing precision:: ++ TESTS:: + +- sage: pari('x^2 + 10^100 + 1').nfinit(precision=64) +- Traceback (most recent call last): +- ... +- PariError: precision too low in floorr (precision loss in truncation) + sage: pari('x^2 + 10^100 + 1').nfinit() + [...] +- +- Throw a PARI error which is not of type ``precer``:: +- + sage: pari('1.0').nfinit() + Traceback (most recent call last): + ... +- PariError: incorrect type in checknf ++ PariError: incorrect type in checknf [please apply nfinit()] (t_REAL) + """ +- # If explicit precision is given, use only that +- if precision: +- pari_catch_sig_on() +- return P.new_gen(nfinit0(self.g, flag, prec_bits_to_words(precision))) +- +- # Otherwise, start with 64 bits of precision and increase as needed: +- precision = 64 +- while True: +- try: +- return self.nfinit(flag, precision) +- except PariError as err: +- if err.errnum() == precer: +- precision *= 2 +- else: +- raise ++ pari_catch_sig_on() ++ return P.new_gen(nfinit0(self.g, flag, prec_bits_to_words(precision))) + + def nfisisom(self, gen other): + """ +@@ -7389,7 +7357,7 @@ cdef class gen(sage.structure.element.RingElement): + + sage: nf = pari('x^2 + 1').nfinit() + sage: nf.nfrootsof1() +- [4, -x] ++ [4, x] + """ + pari_catch_sig_on() + return P.new_gen(rootsof1(self.g)) +@@ -7427,12 +7395,12 @@ cdef class gen(sage.structure.element.RingElement): + def rnfeltabstorel(self, x): + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +- return P.new_gen(rnfelementabstorel(self.g, t0.g)) ++ return P.new_gen(rnfeltabstorel(self.g, t0.g)) + + def rnfeltreltoabs(self, x): + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +- return P.new_gen(rnfelementreltoabs(self.g, t0.g)) ++ return P.new_gen(rnfeltreltoabs(self.g, t0.g)) + + def rnfequation(self, poly, long flag=0): + cdef gen t0 = objtogen(poly) +@@ -7460,10 +7428,10 @@ cdef class gen(sage.structure.element.RingElement): + + sage: P = pari('[[[1, 0]~, [0, 0]~; [0, 0]~, [1, 0]~], [[2, 0; 0, 2], [2, 0; 0, 1/2]]]') + +- And this is the HNF of the inert ideal (2) in nf: ++ And this is the inert ideal (2) in nf: + + sage: rnf.rnfidealdown(P) +- [2, 0; 0, 2] ++ 2 + """ + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +@@ -7472,7 +7440,7 @@ cdef class gen(sage.structure.element.RingElement): + def rnfidealhnf(self, x): + cdef gen t0 = objtogen(x) + pari_catch_sig_on() +- return P.new_gen(rnfidealhermite(self.g, t0.g)) ++ return P.new_gen(rnfidealhnf(self.g, t0.g)) + + def rnfidealnormrel(self, x): + cdef gen t0 = objtogen(x) +@@ -7523,11 +7491,11 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari(-23).quadhilbert() + x^3 - x^2 + 1 + sage: pari(145).quadhilbert() +- x^4 - x^3 - 3*x^2 + x + 1 ++ x^4 - 6*x^2 - 5*x - 1 + sage: pari(-12).quadhilbert() # Not fundamental + Traceback (most recent call last): + ... +- PariError: quadray needs a fundamental discriminant ++ PariError: domain error in quadray: isfundamental(D) = 0 + """ + pari_catch_sig_on() + # Precision argument is only used for real quadratic extensions +@@ -7612,7 +7580,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('1/x').eval(0) + Traceback (most recent call last): + ... +- PariError: division by zero ++ PariError: impossible inverse in gdiv: 0 + sage: pari('1/x + O(x^2)').eval(0) + Traceback (most recent call last): + ... +@@ -7620,11 +7588,11 @@ cdef class gen(sage.structure.element.RingElement): + sage: pari('1/x + O(x^2)').eval(pari('O(x^3)')) + Traceback (most recent call last): + ... +- PariError: division by zero ++ PariError: impossible inverse in gdiv: O(x^3) + sage: pari('O(x^0)').eval(0) + Traceback (most recent call last): + ... +- PariError: non existent component in truecoeff ++ PariError: domain error in polcoeff: t_SER = O(x^0) + + Evaluating multivariate polynomials:: + +@@ -7690,9 +7658,9 @@ cdef class gen(sage.structure.element.RingElement): + sage: K. = NumberField(x^2 + 1) + sage: nf = K._pari_() + sage: nf +- [y^2 + 1, [0, 1], -4, 1, [Mat([1, 0.E-19 - 1.00000000000000*I]), [1, -1.00000000000000; 1, 1.00000000000000], [1, -1; 1, 1], [2, 0; 0, -2], [2, 0; 0, 2], [1, 0; 0, -1], [1, [0, -1; 1, 0]]], [0.E-19 - 1.00000000000000*I], [1, y], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, 0]] ++ [y^2 + 1, [0, 1], -4, 1, [Mat([1, 0.E-19 + 1.00000000000000*I]), [1, 1.00000000000000; 1, -1.00000000000000], [1, 1; 1, -1], [2, 0; 0, -2], [2, 0; 0, 2], [1, 0; 0, -1], [1, [0, -1; 1, 0]], []], [0.E-19 + 1.00000000000000*I], [1, y], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, 0]] + sage: nf(y='x') +- [x^2 + 1, [0, 1], -4, 1, [Mat([1, 0.E-19 - 1.00000000000000*I]), [1, -1.00000000000000; 1, 1.00000000000000], [1, -1; 1, 1], [2, 0; 0, -2], [2, 0; 0, 2], [1, 0; 0, -1], [1, [0, -1; 1, 0]]], [0.E-19 - 1.00000000000000*I], [1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, 0]] ++ [x^2 + 1, [0, 1], -4, 1, [Mat([1, 0.E-19 + 1.00000000000000*I]), [1, 1.00000000000000; 1, -1.00000000000000], [1, 1; 1, -1], [2, 0; 0, -2], [2, 0; 0, 2], [1, 0; 0, -1], [1, [0, -1; 1, 0]], []], [0.E-19 + 1.00000000000000*I], [1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1, 1, 0]] + """ + cdef long t = typ(self.g) + cdef gen t0 +@@ -7786,7 +7754,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: T(0) + Traceback (most recent call last): + ... +- PariError: _/_: division by zero ++ PariError: _/_: impossible inverse in gdiv: 0 + sage: pari('() -> 42')(1,2,3) + Traceback (most recent call last): + ... +@@ -8012,7 +7980,7 @@ cdef class gen(sage.structure.element.RingElement): + non-constant polynomial, or False if f is reducible or constant. + """ + pari_catch_sig_on() +- cdef long t = itos(gisirreducible(self.g)) ++ t = isirreducible(self.g) + P.clear_stack() + return t != 0 + +@@ -8055,12 +8023,14 @@ cdef class gen(sage.structure.element.RingElement): + + def polroots(self, long flag=0, unsigned long precision=0): + """ +- polroots(x,flag=0): complex roots of the polynomial x. flag is +- optional, and can be 0: default, uses Schonhage's method modified +- by Gourdon, or 1: uses a modified Newton method. ++ Complex roots of the given polynomial using Schonhage's method, ++ as modified by Gourdon. + """ ++ if flag: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The flag argument to polroots() is deprecated and not used anymore') + pari_catch_sig_on() +- return P.new_gen(roots0(self.g, flag, prec_bits_to_words(precision))) ++ return P.new_gen(cleanroots(self.g, prec_bits_to_words(precision))) + + def polrootsmod(self, p, long flag=0): + cdef gen t0 = objtogen(p) +@@ -8128,7 +8098,7 @@ cdef class gen(sage.structure.element.RingElement): + x + O(x^4) + """ + pari_catch_sig_on() +- return P.new_gen(recip(self.g)) ++ return P.new_gen(serreverse(self.g)) + + def thueinit(self, long flag=0, unsigned long precision=0): + pari_catch_sig_on() +@@ -8332,7 +8302,7 @@ cdef class gen(sage.structure.element.RingElement): + [ + [ -5 -10 -2 -7 3] + [ 1 2 1 2 0] +- 10, 5.00000000023283..., [ 1 2 0 1 -1] ++ 10, 5.00000000000000000, [ 1 2 0 1 -1] + ] + + """ +@@ -8354,14 +8324,31 @@ cdef class gen(sage.structure.element.RingElement): + + def qfrep(self, B, long flag=0): + """ +- qfrep(x,B,flag=0): vector of (half) the number of vectors of norms +- from 1 to B for the integral and definite quadratic form x. Binary +- digits of flag mean 1: count vectors of even norm from 1 to 2B, 2: +- return a t_VECSMALL instead of a t_VEC. ++ Vector of (half) the number of vectors of norms from 1 to `B` ++ for the integral and definite quadratic form ``self``. ++ Binary digits of flag mean 1: count vectors of even norm from ++ 1 to `2B`, 2: return a ``t_VECSMALL`` instead of a ``t_VEC`` ++ (which is faster). ++ ++ EXAMPLES:: ++ ++ sage: M = pari("[5,1,1;1,3,1;1,1,1]") ++ sage: M.qfrep(20) ++ [1, 1, 2, 2, 2, 4, 4, 3, 3, 4, 2, 4, 6, 0, 4, 6, 4, 5, 6, 4] ++ sage: M.qfrep(20, flag=1) ++ [1, 2, 4, 3, 4, 4, 0, 6, 5, 4, 12, 4, 4, 8, 0, 3, 8, 6, 12, 12] ++ sage: M.qfrep(20, flag=2) ++ Vecsmall([1, 1, 2, 2, 2, 4, 4, 3, 3, 4, 2, 4, 6, 0, 4, 6, 4, 5, 6, 4]) + """ ++ # PARI 2.7 always returns a t_VECSMALL, but for backwards ++ # compatibility, we keep returning a t_VEC (unless flag & 2) + cdef gen t0 = objtogen(B) ++ cdef GEN r + pari_catch_sig_on() +- return P.new_gen(qfrep0(self.g, t0.g, flag)) ++ r = qfrep0(self.g, t0.g, flag & 1) ++ if (flag & 2) == 0: ++ r = vecsmall_to_vec(r) ++ return P.new_gen(r) + + def matsolve(self, B): + """ +@@ -8745,9 +8732,9 @@ cdef class gen(sage.structure.element.RingElement): + cdef gen t0 = objtogen(y) + cdef gen t1 = objtogen(p) + pari_catch_sig_on() +- ret = hilbert0(x.g, t0.g, t1.g) +- pari_catch_sig_off() +- return ret ++ r = hilbert(x.g, t0.g, t1.g) ++ P.clear_stack() ++ return r + + def chinese(self, y): + cdef gen t0 = objtogen(y) +@@ -8786,7 +8773,7 @@ cdef class gen(sage.structure.element.RingElement): + Mod(236736367459211723407, 473472734918423446802) + """ + pari_catch_sig_on() +- return P.new_gen(znprimroot0(self.g)) ++ return P.new_gen(znprimroot(self.g)) + + def __abs__(self): + return self.abs() +@@ -8814,8 +8801,8 @@ cdef class gen(sage.structure.element.RingElement): + """ + pari_catch_sig_on() + if add_one: +- return P.new_gen(gnextprime(gaddsg(1,self.g))) +- return P.new_gen(gnextprime(self.g)) ++ return P.new_gen(nextprime(gaddsg(1, self.g))) ++ return P.new_gen(nextprime(self.g)) + + def change_variable_name(self, var): + """ +@@ -8957,12 +8944,12 @@ cdef class gen(sage.structure.element.RingElement): + pari_catch_sig_on() + return P.new_gen(charpoly0(self.g, P.get_var(var), flag)) + +- + def kronecker(gen self, y): + cdef gen t0 = objtogen(y) + pari_catch_sig_on() +- return P.new_gen(gkronecker(self.g, t0.g)) +- ++ r = kronecker(self.g, t0.g) ++ P.clear_stack() ++ return r + + def type(gen self): + """ +@@ -9107,7 +9094,7 @@ cdef class gen(sage.structure.element.RingElement): + sage: om = e.omega() + sage: om + [2.49021256085506, -1.97173770155165*I] +- sage: om.elleisnum(2) # was: -5.28864933965426 ++ sage: om.elleisnum(2) + 10.0672605281120 + sage: om.elleisnum(4) + 112.000000000000 +@@ -9151,7 +9138,7 @@ cdef class gen(sage.structure.element.RingElement): + Compute P(1):: + + sage: E.ellwp(1) +- 13.9658695257485 + 0.E-18*I ++ 13.9658695257485 + + Compute P(1+i), where i = sqrt(-1):: + +@@ -9180,11 +9167,18 @@ cdef class gen(sage.structure.element.RingElement): + With flag=1, compute the pair P(z) and P'(z):: + + sage: E.ellwp(1, flag=1) +- [13.9658695257485 + 0.E-18*I, 50.5619300880073 ... E-18*I] ++ [13.9658695257485, 50.5619893875144] + """ + cdef gen t0 = objtogen(z) ++ cdef GEN g0 = t0.g ++ ++ # Emulate toser_i() but with given precision + pari_catch_sig_on() +- return P.new_gen(ellwp0(self.g, t0.g, flag, n+2, prec_bits_to_words(precision))) ++ if typ(g0) == t_POL: ++ g0 = RgX_to_ser(g0, n+4) ++ elif typ(g0) == t_RFRAC: ++ g0 = rfrac_to_ser(g0, n+4) ++ return P.new_gen(ellwp0(self.g, g0, flag, prec_bits_to_words(precision))) + + def ellchangepoint(self, y): + """ +@@ -9368,7 +9362,7 @@ class PariError(RuntimeError): + ....: pari('1/0') + ....: except PariError as err: + ....: print err.errnum() +- 27 ++ 30 + """ + return self.args[0] + +@@ -9414,7 +9408,7 @@ class PariError(RuntimeError): + ....: pari('1/0') + ....: except PariError as err: + ....: print err +- _/_: division by zero ++ _/_: impossible inverse in gdiv: 0 + + A syntax error:: + +@@ -9424,7 +9418,7 @@ class PariError(RuntimeError): + PariError: syntax error, unexpected $undefined: !@#$%^&*() + """ + lines = self.errtext().split('\n') +- if self.errnum() == syntaxer: ++ if self.errnum() == e_SYNTAX: + for line in lines: + if "syntax error" in line: + return line.lstrip(" *").rstrip(" .:") +diff --git a/src/sage/libs/pari/gen_py.py b/src/sage/libs/pari/gen_py.py +index 8ea4e5d..28f05f6 100644 +--- a/src/sage/libs/pari/gen_py.py ++++ b/src/sage/libs/pari/gen_py.py +@@ -73,11 +73,11 @@ def pari(x): + + sage: K. = NumberField(x^3 - 2) + sage: pari(K) +- [y^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 - 1.09112363597172*I, -0.793700525984100 + 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, -1.72108416091916, 0.581029111014503; 1, 0.461163111024285, -2.16843016298270], [1, 1, 2; 1, -2, 1; 1, 0, -2], [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]]], [1.25992104989487, -0.629960524947437 - 1.09112363597172*I], [1, y, y^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]] ++ [y^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 + 1.09112363597172*I, -0.793700525984100 - 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, 0.461163111024285, -2.16843016298270; 1, -1.72108416091916, 0.581029111014503], [1, 1, 2; 1, 0, -2; 1, -2, 1], [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]], []], [1.25992104989487, -0.629960524947437 + 1.09112363597172*I], [1, y, y^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]] + + sage: E = EllipticCurve('37a1') + sage: pari(E) +- [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, [0.837565435283323, 0.269594436405445, -1.10715987168877]~, 2.99345864623196, -2.45138938198679*I, 0.942638555913623, 1.32703057887968*I, 7.33813274078958] ++ [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [0, 0, 0, 0, 0, 0, 0, 0]] + + Conversion from basic Python types:: + +diff --git a/src/sage/libs/pari/handle_error.pyx b/src/sage/libs/pari/handle_error.pyx +index 81472fb..101028b 100644 +--- a/src/sage/libs/pari/handle_error.pyx ++++ b/src/sage/libs/pari/handle_error.pyx +@@ -27,7 +27,7 @@ cdef void _pari_init_error_handling(): + ....: except PariError as e: + ....: print e.errtext() + ....: +- *** argument must be positive in polcyclo. ++ *** domain error in polcyclo: index <= 0 + + """ + global pari_error_string +@@ -73,17 +73,17 @@ cdef int _pari_handle_exception(long err) except 0: + sage: pari(1)/pari(0) + Traceback (most recent call last): + ... +- PariError: division by zero ++ PariError: impossible inverse in gdiv: 0 + + """ +- if err == errpile: ++ if err == e_STACK: + # PARI is out of memory. We double the size of the PARI stack + # and retry the computation. + from sage.libs.pari.all import pari + pari.allocatemem(silent=True) + return 0 + +- if err == user: ++ if err == e_USER: + raise RuntimeError("PARI user exception\n%s" % pari_error_string) + else: + from sage.libs.pari.all import PariError +diff --git a/src/sage/libs/pari/pari_instance.pxd b/src/sage/libs/pari/pari_instance.pxd +index a7242a0..95db20d 100644 +--- a/src/sage/libs/pari/pari_instance.pxd ++++ b/src/sage/libs/pari/pari_instance.pxd +@@ -9,6 +9,7 @@ cpdef long prec_bits_to_words(unsigned long prec_in_bits) + + @cython.final + cdef class PariInstance(sage.structure.parent_base.ParentWithBase): ++ cdef long _real_precision + cdef gen PARI_ZERO, PARI_ONE, PARI_TWO + cdef inline gen new_gen(self, GEN x) + cdef inline gen new_gen_noclear(self, GEN x) +diff --git a/src/sage/libs/pari/pari_instance.pyx b/src/sage/libs/pari/pari_instance.pyx +index 7991a62..21e3b36 100644 +--- a/src/sage/libs/pari/pari_instance.pyx ++++ b/src/sage/libs/pari/pari_instance.pyx +@@ -20,6 +20,8 @@ AUTHORS: + + - Peter Bruin (2013-11-17): split off this file from gen.pyx (#15185) + ++- Jeroen Demeyer (2014-02-09): upgrade to PARI 2.7 (#15767) ++ + + EXAMPLES:: + +@@ -44,7 +46,7 @@ Arithmetic obeys the usual coercion rules:: + + GUIDE TO REAL PRECISION AND THE PARI LIBRARY + +-The default real precision in communicating with the Pari library ++The default real precision in communicating with the PARI library + is the same as the default Sage real precision, which is 53 bits. + Inexact Pari objects are therefore printed by default to 15 decimal + digits (even if they are actually more precise). +@@ -132,14 +134,15 @@ with a precision of 100 bits:: + True + + Elliptic curves and precision: If you are working with elliptic +-curves and want to compute with a precision other than the default +-53 bits, you should use the precision parameter of ellinit():: ++curves, you should set the precision for each method:: + +- sage: R = RealField(150) +- sage: e = pari([0,0,0,-82,0]).ellinit(precision=150) +- sage: eta1 = e.elleta()[0] +- sage: R(eta1) +- 3.6054636014326520859158205642077267748102690 ++ sage: e = pari([0,0,0,-82,0]).ellinit() ++ sage: eta1 = e.elleta(precision=100)[0] ++ sage: eta1.sage() ++ 3.6054636014326520859158205642077267748 ++ sage: eta1 = e.elleta(precision=180)[0] ++ sage: eta1.sage() ++ 3.60546360143265208591582056420772677481026899659802474544 + + Number fields and precision: TODO + +@@ -157,9 +160,6 @@ include 'pari_err.pxi' + include 'sage/ext/stdsage.pxi' + include 'sage/ext/interrupt.pxi' + +-cdef extern from 'c_lib/include/memory.h': +- void init_memory_functions() +- + import sys + + cimport libc.stdlib +@@ -348,8 +348,6 @@ pari_catch_sig_off() + pari = pari_instance + + +-cdef unsigned long num_primes +- + # Callbacks from PARI to print stuff using sys.stdout.write() instead + # of C library functions like puts(). + cdef PariOUT sage_pariOut +@@ -432,7 +430,7 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + if bot: + return # pari already initialized. + +- global num_primes, top, bot ++ global top, bot + + # The size here doesn't really matter, because we will allocate + # our own stack anyway. We ask PARI not to set up signal and +@@ -445,8 +443,6 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + # so we need to reset them. + init_memory_functions() + +- num_primes = maxprime +- + # Free the PARI stack and allocate our own (using Cython) + pari_free(bot); bot = 0 + init_stack(size) +@@ -465,6 +461,7 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + pariErr.flush = sage_pariErr_flush + + # Display only 15 digits ++ self._real_precision = 15 + sd_format("g.15", d_SILENT) + + # Init global prec variable (PARI's precision is always a +@@ -585,11 +582,12 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + sage: pari.set_real_precision(15) + 60 + """ +- prev = self.get_real_precision() ++ prev = self._real_precision + cdef bytes strn = str(n) + pari_catch_sig_on() + sd_realprecision(strn, d_SILENT) + pari_catch_sig_off() ++ self._real_precision = n + return prev + + def get_real_precision(self): +@@ -608,10 +606,7 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + sage: pari.get_real_precision() + 15 + """ +- pari_catch_sig_on() +- cdef long prev = itos(sd_realprecision(NULL, d_RETURN)) +- pari_catch_sig_off() +- return prev ++ return self._real_precision + + def set_series_precision(self, long n): + global precdl +@@ -1147,7 +1142,7 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + def pari_version(self): + return str(PARIVERSION) + +- def init_primes(self, _M): ++ def init_primes(self, unsigned long M): + """ + Recompute the primes table including at least all primes up to M + (but possibly more). +@@ -1156,29 +1151,22 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + + sage: pari.init_primes(200000) + +- We make sure that ticket #11741 has been fixed, and double check to +- make sure that diffptr has not been freed:: ++ We make sure that ticket :trac:`11741` has been fixed:: + +- sage: pari.init_primes(2^62) ++ sage: pari.init_primes(2^30) + Traceback (most recent call last): + ... +- PariError: not enough memory # 64-bit +- OverflowError: long int too large to convert # 32-bit +- sage: pari.init_primes(200000) ++ ValueError: Cannot compute primes beyond 436273290 + """ +- cdef unsigned long M +- cdef char *tmpptr +- M = _M +- global diffptr, num_primes +- if M <= num_primes: ++ # Hardcoded bound in PARI sources ++ if M > 436273290: ++ raise ValueError("Cannot compute primes beyond 436273290") ++ ++ if M <= maxprime(): + return + pari_catch_sig_on() +- tmpptr = initprimes(M) ++ initprimetable(M) + pari_catch_sig_off() +- pari_free( diffptr) +- num_primes = M +- diffptr = tmpptr +- + + ############################################## + ## Support for GP Scripts +@@ -1221,19 +1209,18 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + + def _primelimit(self): + """ +- Return the number of primes already computed +- in this Pari instance. ++ Return the number of primes already computed by PARI. ++ ++ EXAMPLES:: + +- EXAMPLES: + sage: pari._primelimit() +- 500000 ++ 499979 + sage: pari.init_primes(600000) + sage: pari._primelimit() +- 600000 ++ 599999 + """ +- global num_primes + from sage.rings.all import ZZ +- return ZZ(num_primes) ++ return ZZ(maxprime()) + + def prime_list(self, long n): + """ +@@ -1302,8 +1289,6 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + """ + nth_prime(n): returns the n-th prime, where n is a C-int + """ +- global num_primes +- + if n <= 0: + raise ValueError, "nth prime meaningless for non-positive n (=%s)"%n + cdef GEN g +@@ -1311,15 +1296,15 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + g = prime(n) + return self.new_gen(g) + +- + def nth_prime(self, long n): + from sage.libs.pari.all import PariError + try: + return self.__nth_prime(n) + except PariError: +- self.init_primes(max(2*num_primes,20*n)) ++ self.init_primes(max(2*maxprime(), 20*n)) + return self.nth_prime(n) + ++ + def euler(self, unsigned long precision=0): + """ + Return Euler's constant to the requested real precision (in bits). +@@ -1488,16 +1473,16 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + + TESTS: + +- Check that invalid inputs are handled properly (#11825):: ++ Check that invalid inputs are handled properly (:trac:`11825`):: + + sage: pari.setrand(0) + Traceback (most recent call last): + ... +- PariError: incorrect type in setrand ++ PariError: incorrect type in setrand (t_INT) + sage: pari.setrand("foobar") + Traceback (most recent call last): + ... +- PariError: incorrect type in setrand ++ PariError: incorrect type in setrand (t_POL) + """ + cdef gen t0 = self(seed) + pari_catch_sig_on() +@@ -1579,6 +1564,24 @@ cdef class PariInstance(sage.structure.parent_base.ParentWithBase): + k = k + 1 + return A + ++ def genus2red(self, Q, P): ++ """ ++ Let Q,P be polynomials with integer coefficients. Determine ++ the reduction at p > 2 of the (proper, smooth) hyperelliptic ++ curve C/Q: y^2+Qy = P, of genus 2. (The special fiber X_p of ++ the minimal regular model X of C over Z.) ++ ++ EXAMPLES:: ++ ++ sage: x = polygen(QQ) ++ sage: pari.genus2red(x^3 - 2*x^2 - 2*x + 1, -5*x^5) ++ [1416875, [2, -1; 5, 4; 2267, 1], x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855, [[2, [2, [Mod(1, 2)]], []], [5, [1, []], ["[V] page 156", [3]]], [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]] ++ """ ++ cdef gen t0 = objtogen(Q) ++ cdef gen t1 = objtogen(P) ++ pari_catch_sig_on() ++ return self.new_gen(genus2red(t0.g, t1.g, NULL)) ++ + + cdef int init_stack(size_t requested_size) except -1: + r""" +diff --git a/src/sage/matrix/matrix_rational_dense.pyx b/src/sage/matrix/matrix_rational_dense.pyx +index cd1ccda..781db98 100644 +--- a/src/sage/matrix/matrix_rational_dense.pyx ++++ b/src/sage/matrix/matrix_rational_dense.pyx +@@ -2617,7 +2617,7 @@ cdef class Matrix_rational_dense(matrix_dense.Matrix_dense): + sage: matrix(QQ,2,[1,2,2,4])._invert_pari() + Traceback (most recent call last): + ... +- PariError: non invertible matrix in gauss ++ PariError: impossible inverse in ginv: 0 + """ + if self._nrows != self._ncols: + raise ValueError("self must be a square matrix") +diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py +index 214172a..75c4519 100644 +--- a/src/sage/modular/cusps_nf.py ++++ b/src/sage/modular/cusps_nf.py +@@ -41,7 +41,7 @@ Different operations with cusps over a number field: + sage: alpha.ideal() + Fractional ideal (7, a + 3) + sage: alpha.ABmatrix() +- [a + 10, 3*a - 1, 7, 2*a] ++ [a + 10, -3*a + 1, 7, -2*a] + sage: alpha.apply([0, 1, -1,0]) + Cusp [7: -a - 10] of Number Field in a with defining polynomial x^2 + 5 + +@@ -895,7 +895,7 @@ class NFCusp(Element): + Given R a Dedekind domain and A, B ideals of R in inverse classes, an + AB-matrix is a matrix realizing the isomorphism between R+R and A+B. + An AB-matrix associated to a cusp [a1: a2] is an AB-matrix with A the +- ideal associated to the cusp (A=) and first column given by ++ ideal associated to the cusp (A=) and first column given by + the coefficients of the cusp. + + EXAMPLES: +@@ -1295,7 +1295,7 @@ def units_mod_ideal(I): + [1] + sage: I = k.ideal(3) + sage: units_mod_ideal(I) +- [1, -a, -1, a] ++ [1, a, -1, -a] + + :: + +diff --git a/src/sage/modular/modform/constructor.py b/src/sage/modular/modform/constructor.py +index d5e5152..5a2f495 100644 +--- a/src/sage/modular/modform/constructor.py ++++ b/src/sage/modular/modform/constructor.py +@@ -430,7 +430,7 @@ def Newforms(group, weight=2, base_ring=None, names=None): + base field that is not minimal for that character:: + + sage: K. = QuadraticField(-1) +- sage: chi = DirichletGroup(5, K)[3] ++ sage: chi = DirichletGroup(5, K)[1] + sage: len(Newforms(chi, 7, names='a')) + 1 + sage: x = polygen(K); L. = K.extension(x^2 - 402*i) +diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py +index 680df6e..e48729b 100644 +--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py ++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py +@@ -220,18 +220,16 @@ def short_vector_list_up_to_length(self, len_bound, up_to_sign_flag=False): + ... + ValueError: Quadratic form must be positive definite in order to enumerate short vectors + +- Sometimes, PARI does not compute short vectors correctly. It returns too long vectors. +- +- :: ++ Check that PARI doesn't return vectors which are too long:: + + sage: Q = QuadraticForm(matrix(2, [72, 12, 12, 120])) + sage: len_bound_pari = 2*22953421 - 2; len_bound_pari + 45906840 + sage: vs = list(Q._pari_().qfminim(len_bound_pari)[2]) # long time (18s on sage.math, 2014) + sage: v = vs[0]; v # long time +- [-65, 623]~ ++ [-66, 623]~ + sage: v.Vec() * Q._pari_() * v # long time +- 45907800 ++ 45902280 + """ + if not self.is_positive_definite() : + raise ValueError( "Quadratic form must be positive definite in order to enumerate short vectors" ) +@@ -256,11 +254,9 @@ def short_vector_list_up_to_length(self, len_bound, up_to_sign_flag=False): + # Sort the vectors into lists by their length + vec_sorted_list = [list() for i in range(len_bound)] + for i in range(len(parilist)): +- length = ZZ(parilens[i]) +- # PARI can sometimes return longer vectors than requested. +- # E.g. : self.matrix() == matrix(2, [72, 12, 12, 120]) +- # len_bound = 22953421 +- # gives maximal length 22955664 ++ length = int(parilens[i]) ++ # In certain trivial cases, PARI can sometimes return longer ++ # vectors than requested. + if length < len_bound: + v = parilist[i] + sagevec = V(list(parilist[i])) +diff --git a/src/sage/rings/arith.py b/src/sage/rings/arith.py +index b9efb9f..2755682 100644 +--- a/src/sage/rings/arith.py ++++ b/src/sage/rings/arith.py +@@ -2443,7 +2443,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): + + sage: K. = QuadraticField(-1) + sage: factor(122 - 454*i) +- (-1) * (-i - 4) * (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 ++ (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4) + + To access the data in a factorization:: + +@@ -4530,6 +4530,8 @@ def hilbert_symbol(a, b, p, algorithm="pari"): + b = QQ(b).numerator() * QQ(b).denominator() + + if algorithm == "pari": ++ if p == -1: ++ p = 0 + return ZZ(pari(a).hilbert(b,p)) + + elif algorithm == 'direct': +@@ -5386,7 +5388,7 @@ def dedekind_sum(p, q, algorithm='default'): + sage: dedekind_sum(3^54 - 1, 2^93 + 1, algorithm='pari') + 459340694971839990630374299870/29710560942849126597578981379 + +- Pari uses a different definition if the inputs are not coprime:: ++ We check consistency of the results:: + + sage: dedekind_sum(5, 7, algorithm='default') + -1/14 +@@ -5399,7 +5401,7 @@ def dedekind_sum(p, q, algorithm='default'): + sage: dedekind_sum(6, 8, algorithm='flint') + -1/8 + sage: dedekind_sum(6, 8, algorithm='pari') +- -1/24 ++ -1/8 + + REFERENCES: + +diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx +index ebac16f..936044a 100644 +--- a/src/sage/rings/complex_double.pyx ++++ b/src/sage/rings/complex_double.pyx +@@ -2061,8 +2061,8 @@ cdef class ComplexDoubleElement(FieldElement): + + The optional argument allows us to omit the fractional part:: + +- sage: z.eta(omit_frac=True) # abs tol 1e-12 +- 0.998129069926 - 8.12769318782e-22*I ++ sage: z.eta(omit_frac=True) ++ 0.998129069926 + sage: pi = CDF(pi) + sage: prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) # abs tol 1e-12 + 0.998129069926 + 4.59084695545e-19*I +@@ -2140,7 +2140,7 @@ cdef class ComplexDoubleElement(FieldElement): + sage: a.agm(b, algorithm='principal') + 0.338175462986 - 0.0135326969565*I + sage: a.agm(b, algorithm='pari') +- 0.080689185076 + 0.239036532686*I ++ -0.371591652352 + 0.319894660207*I + + Some degenerate cases:: + +diff --git a/src/sage/rings/complex_number.pyx b/src/sage/rings/complex_number.pyx +index 0a8ce5c..5fa15c9 100644 +--- a/src/sage/rings/complex_number.pyx ++++ b/src/sage/rings/complex_number.pyx +@@ -1508,7 +1508,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): + + sage: z = 1 + i + sage: z.eta(omit_frac=True) +- 0.998129069925959 - 8.12769318...e-22*I ++ 0.998129069925959 + sage: prod([1-exp(2*pi*i*n*z) for n in range(1,10)]) + 0.998129069925958 + 4.59099857829247e-19*I + +@@ -1721,13 +1721,13 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): + sage: a.agm(b, algorithm="principal") + 0.338175462986180 - 0.0135326969565405*I + sage: a.agm(b, algorithm="pari") +- 0.0806891850759812 + 0.239036532685557*I ++ -0.371591652351761 + 0.319894660206830*I + sage: a.agm(b, algorithm="optimal").abs() + 0.490319232466314 + sage: a.agm(b, algorithm="principal").abs() + 0.338446122230459 + sage: a.agm(b, algorithm="pari").abs() +- 0.252287947683910 ++ 0.490319232466314 + + TESTS: + +@@ -2021,7 +2021,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): + + sage: C, i = ComplexField(30).objgen() + sage: (1+i).gamma_inc(2 + 3*i) +- 0.0020969149 - 0.059981914*I ++ 0.002096914... - 0.059981914*I + sage: (1+i).gamma_inc(5) + -0.0013781309 + 0.0065198200*I + sage: C(2).gamma_inc(1 + i) +diff --git a/src/sage/rings/fast_arith.pyx b/src/sage/rings/fast_arith.pyx +index 3a0e304..a224775 100644 +--- a/src/sage/rings/fast_arith.pyx ++++ b/src/sage/rings/fast_arith.pyx +@@ -46,7 +46,7 @@ include "sage/ext/stdsage.pxi" + include "sage/libs/pari/decl.pxi" + + cdef extern from "pari/pari.h": +- cdef long NEXT_PRIME_VIADIFF(long, unsigned char*) ++ cdef long NEXT_PRIME_VIADIFF(long, byteptr) + + from sage.rings.integer_ring import ZZ + from sage.libs.pari.gen cimport gen as pari_gen +@@ -84,7 +84,8 @@ cpdef prime_range(start, stop=None, algorithm="pari_primes", bint py_ints=False) + - ``py_ints`` -- boolean (default False), return Python ints rather than Sage Integers (faster) + + +- EXAMPLES: ++ EXAMPLES:: ++ + sage: prime_range(10) + [2, 3, 5, 7] + sage: prime_range(7) +@@ -110,21 +111,31 @@ cpdef prime_range(start, stop=None, algorithm="pari_primes", bint py_ints=False) + sage: type(prime_range(8,algorithm="pari_isprime")[0]) + + +- TESTS: +- sage: len(prime_range(25000,2500000)) ++ TESTS:: ++ ++ sage: prime_range(-1) ++ [] ++ sage: L = prime_range(25000,2500000) ++ sage: len(L) + 180310 +- sage: prime_range(2500000)[-1].is_prime() +- True ++ sage: L[-10:] ++ [2499923, 2499941, 2499943, 2499947, 2499949, 2499953, 2499967, 2499983, 2499989, 2499997] ++ ++ A non-trivial range without primes:: ++ ++ sage: prime_range(4652360, 4652400) ++ [] + + AUTHORS: +- - William Stein (original version) +- - Craig Citro (rewrote for massive speedup) +- - Kevin Stueve (added primes iterator option) 2010-10-16 +- - Robert Bradshaw (speedup using Pari prime table, py_ints option) ++ ++ - William Stein (original version) ++ - Craig Citro (rewrote for massive speedup) ++ - Kevin Stueve (added primes iterator option) 2010-10-16 ++ - Robert Bradshaw (speedup using Pari prime table, py_ints option) + """ + cdef Integer z +- cdef long c_start, c_stop, p +- cdef unsigned char* pari_prime_ptr ++ cdef long c_start, c_stop, p, maxpr ++ cdef byteptr pari_prime_ptr + if algorithm == "pari_primes": + if stop is None: + # In this case, "start" is really stop +@@ -133,13 +144,18 @@ cpdef prime_range(start, stop=None, algorithm="pari_primes", bint py_ints=False) + else: + c_start = start + c_stop = stop +- if c_stop <= c_start: +- return [] + if c_start < 1: + c_start = 1 ++ if c_stop <= c_start: ++ return [] ++ + if maxprime() < c_stop: +- pari.init_primes(c_stop) +- pari_prime_ptr = diffptr ++ # Adding 1500 should be sufficient to guarantee an ++ # additional prime, given that c_stop < 2^63. ++ pari.init_primes(c_stop + 1500) ++ assert maxprime() >= c_stop ++ ++ pari_prime_ptr = diffptr + p = 0 + res = [] + while p < c_start: +diff --git a/src/sage/rings/finite_rings/element_ext_pari.py b/src/sage/rings/finite_rings/element_ext_pari.py +index 074c2c4..cb76e70 100644 +--- a/src/sage/rings/finite_rings/element_ext_pari.py ++++ b/src/sage/rings/finite_rings/element_ext_pari.py +@@ -284,20 +284,20 @@ class FiniteField_ext_pariElement(FinitePolyExtElement): + if not value: + value = [0] + try: +- # First, try the conversion directly in PARI. This +- # should cover the most common cases, like converting +- # from integers or intmods. + # Convert the list to PARI, then mod out the +- # characteristic (PARI can do this directly for lists), +- # convert to a polynomial with variable "a" and finally +- # mod out the field modulus. +- self.__value = pari(value).Mod(parent.characteristic()).Polrev("a").Mod(parent._pari_modulus()) ++ # characteristic (PARI can do this directly for lists). ++ # If we get only INTMODs, we can do the conversion ++ # directly. ++ parilist = pari(value).Mod(parent.characteristic()) ++ if not all(c.type() == "t_INTMOD" for c in parilist): ++ raise RuntimeError + except RuntimeError: + # That didn't work, do it in a more general but also + # slower way: first convert all list elements to the + # prime field. + GFp = parent.prime_subfield() +- self.__value = pari([GFp(c) for c in value]).Polrev("a").Mod(parent._pari_modulus()) ++ parilist = pari([GFp(c) for c in value]) ++ self.__value = parilist.Polrev("a").Mod(parent._pari_modulus()) + elif isinstance(value, str): + raise TypeError("value must not be a string") + else: +diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py +index a3b3044..b66b1e3 100644 +--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py ++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py +@@ -168,7 +168,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin + sage: RF13 = K.residue_field(pp) + sage: RF13.hom([GF(13)(1)]) + Ring morphism: +- From: Residue field of Fractional ideal (w - 18) ++ From: Residue field of Fractional ideal (-w + 18) + To: Finite Field of size 13 + Defn: 1 |--> 1 + """ +diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx +index 943036d..34b5f2c 100644 +--- a/src/sage/rings/integer.pyx ++++ b/src/sage/rings/integer.pyx +@@ -4746,8 +4746,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): + sage: 3._bnfisnorm(QuadraticField(-1, 'i')) + (1, 3) + sage: 7._bnfisnorm(CyclotomicField(7)) +- (-zeta7 + 1, 1) # 64-bit +- (-zeta7^5 + zeta7^4, 1) # 32-bit ++ (zeta7^5 - zeta7, 1) + """ + from sage.rings.rational_field import QQ + return QQ(self)._bnfisnorm(K, proof=proof, extra_primes=extra_primes) +diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py +index a69a3ad..210a28c 100644 +--- a/src/sage/rings/number_field/class_group.py ++++ b/src/sage/rings/number_field/class_group.py +@@ -223,7 +223,7 @@ class FractionalIdealClass(AbelianGroupWithValuesElement): + sage: k. = NumberField(x^2 + 20072); G = k.class_group(); G + Class group of order 76 with structure C38 x C2 + of Number Field in a with defining polynomial x^2 + 20072 +- sage: I = (G.0)^35; I ++ sage: I = (G.0)^11; I + Fractional ideal class (41, 1/2*a + 5) + sage: J = G(I.ideal()^5); J + Fractional ideal class (115856201, 1/2*a + 40407883) +@@ -471,7 +471,7 @@ class ClassGroup(AbelianGroupWithValues_class): + Class group of order 68 with structure C34 x C2 of Number Field + in a with defining polynomial x^2 + x + 23899 + sage: C.gens() +- (Fractional ideal class (23, a + 14), Fractional ideal class (5, a + 3)) ++ (Fractional ideal class (7, a + 5), Fractional ideal class (5, a + 3)) + sage: C.ngens() + 2 + """ +diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py +index fbb4ab0..0189900 100644 +--- a/src/sage/rings/number_field/galois_group.py ++++ b/src/sage/rings/number_field/galois_group.py +@@ -404,10 +404,12 @@ class GaloisGroup_v2(PermutationGroup_generic): + + EXAMPLE:: + +- sage: L = CyclotomicField(7) ++ sage: L. = CyclotomicField(7) + sage: G = L.galois_group() +- sage: G.complex_conjugation() +- (1,6)(2,3)(4,5) ++ sage: conj = G.complex_conjugation(); conj ++ (1,4)(2,5)(3,6) ++ sage: conj(z) ++ -z^5 - z^4 - z^3 - z^2 - z - 1 + + An example where the field is not CM, so complex conjugation really + depends on the choice of embedding:: +diff --git a/src/sage/rings/number_field/maps.py b/src/sage/rings/number_field/maps.py +index 1f59062..d262818 100644 +--- a/src/sage/rings/number_field/maps.py ++++ b/src/sage/rings/number_field/maps.py +@@ -302,12 +302,12 @@ class MapRelativeVectorSpaceToRelativeNumberField(NumberFieldIsomorphism): + # Apply to_B, so now each coefficient is in an absolute field, + # and is expressed in terms of a polynomial in y, then make + # the PARI poly in x. +- w = [pari(to_B(a).polynomial('y')) for a in w] ++ w = [to_B(a)._pari_('y') for a in w] + h = pari(w).Polrev() + + # Next we write the poly in x over a poly in y in terms + # of an absolute polynomial for the rnf. +- g = self.__R(self.__rnf.rnfeltreltoabs(h)) ++ g = self.__rnf.rnfeltreltoabs(h) + return self.__K._element_class(self.__K, g) + + class MapRelativeNumberFieldToRelativeVectorSpace(NumberFieldIsomorphism): +diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py +index 08624f0..86cba05 100644 +--- a/src/sage/rings/number_field/number_field.py ++++ b/src/sage/rings/number_field/number_field.py +@@ -2632,9 +2632,9 @@ class NumberField_generic(number_field_base.NumberField): + sage: K. = NumberField(x^2 + 23) + sage: d = K.ideals_of_bdd_norm(10) + sage: for n in d: +- ... print n +- ... for I in d[n]: +- ... print I ++ ....: print n ++ ....: for I in d[n]: ++ ....: print I + 1 + Fractional ideal (1) + 2 +@@ -2649,13 +2649,13 @@ class NumberField_generic(number_field_base.NumberField): + Fractional ideal (4, 1/2*a + 5/2) + 5 + 6 +- Fractional ideal (-1/2*a + 1/2) ++ Fractional ideal (1/2*a - 1/2) + Fractional ideal (6, 1/2*a + 5/2) + Fractional ideal (6, 1/2*a + 7/2) + Fractional ideal (1/2*a + 1/2) + 7 + 8 +- Fractional ideal (-1/2*a - 3/2) ++ Fractional ideal (1/2*a + 3/2) + Fractional ideal (4, a - 1) + Fractional ideal (4, a + 1) + Fractional ideal (1/2*a - 3/2) +@@ -3101,7 +3101,9 @@ class NumberField_generic(number_field_base.NumberField): + return self.__pari_nf + except AttributeError: + f = self.pari_polynomial("y") +- self.__pari_nf = pari([f, self._pari_integral_basis(important=important)]).nfinit() ++ if f.poldegree() > 1: ++ f = pari([f, self._pari_integral_basis(important=important)]) ++ self.__pari_nf = f.nfinit() + return self.__pari_nf + + def pari_zk(self): +@@ -3184,7 +3186,7 @@ class NumberField_generic(number_field_base.NumberField): + sage: len(k.pari_bnf()) + 10 + sage: k.pari_bnf()[:4] +- [[;], matrix(0,7), [;], ...] ++ [[;], matrix(0,3), [;], ...] + sage: len(k.pari_nf()) + 9 + sage: k. = NumberField(x^7 + 7); k +@@ -3545,8 +3547,8 @@ class NumberField_generic(number_field_base.NumberField): + 14/13*a^2 + 267/13*a - 85/13, + 7/13*a^2 + 127/13*a - 49/13, + -1, +- 1/13*a^2 + 20/13*a - 7/13, +- 1/13*a^2 - 19/13*a + 6/13], ++ 1/13*a^2 - 19/13*a + 6/13, ++ 1/13*a^2 - 19/13*a - 7/13], + [(Fractional ideal (11, a - 2), 2), + (Fractional ideal (19, 1/13*a^2 - 45/13*a - 332/13), 2)]) + """ +@@ -3645,7 +3647,7 @@ class NumberField_generic(number_field_base.NumberField): + + sage: K. = NumberField(x^3 - 381 * x + 127) + sage: K.selmer_group(K.primes_above(13), 2) +- [-7/13*a^2 - 140/13*a + 36/13, 14/13*a^2 + 267/13*a - 85/13, 7/13*a^2 + 127/13*a - 49/13, -1, 1/13*a^2 + 20/13*a - 7/13, 1/13*a^2 - 19/13*a + 6/13, -2/13*a^2 - 53/13*a + 92/13, 10/13*a^2 + 44/13*a - 4555/13] ++ [-7/13*a^2 - 140/13*a + 36/13, 14/13*a^2 + 267/13*a - 85/13, 7/13*a^2 + 127/13*a - 49/13, -1, 1/13*a^2 - 19/13*a + 6/13, 1/13*a^2 - 19/13*a - 7/13, 2/13*a^2 + 53/13*a - 92/13, 10/13*a^2 + 44/13*a - 4555/13] + """ + units, clgp_gens = self._S_class_group_and_units(tuple(S), proof=proof) + gens = [] +@@ -4197,19 +4199,19 @@ class NumberField_generic(number_field_base.NumberField): + Here are the factors:: + + sage: fi, fj = K.factor(17); fi,fj +- ((Fractional ideal (4*I + 1), 1), (Fractional ideal (-I - 4), 1)) ++ ((Fractional ideal (I - 4), 1), (Fractional ideal (I + 4), 1)) + + Now we extract the reduced form of the generators:: + + sage: zi = fi[0].gens_reduced()[0]; zi +- 4*I + 1 ++ I - 4 + sage: zj = fj[0].gens_reduced()[0]; zj +- -I - 4 ++ I + 4 + + We recover the integer that was factored in `\ZZ[i]` (up to a unit):: + + sage: zi*zj +- -17*I ++ -17 + + One can also factor elements or ideals of the number field:: + +@@ -4219,15 +4221,14 @@ class NumberField_generic(number_field_base.NumberField): + sage: K.factor(1+a) + Fractional ideal (a + 1) + sage: K.factor(1+a/5) +- (Fractional ideal (-3*a - 2)) * (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (a - 2))^-1 ++ (Fractional ideal (-3*a - 2)) * (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 + + An example over a relative number field:: + + sage: pari('setrand(2)') + sage: L. = K.extension(x^2 - 7) + sage: f = L.factor(a + 1); f +- (Fractional ideal (-1/2*a*b - a - 1/2)) * (Fractional ideal (1/2*b + 1/2*a - 1)) # 32-bit +- (Fractional ideal (1/2*a*b + a + 1/2)) * (Fractional ideal (-1/2*b - 1/2*a + 1)) # 64-bit ++ (Fractional ideal (1/2*a*b - a + 1/2)) * (Fractional ideal (-1/2*a*b - a + 1/2)) + sage: f.value() == a+1 + True + +@@ -4553,8 +4554,7 @@ class NumberField_generic(number_field_base.NumberField): + except (AttributeError, KeyError): + f = self.pari_polynomial("y") + if len(v) > 0: +- m = self._pari_disc_factorization_matrix(v) +- B = f.nfbasis(fa = m) ++ B = f.nfbasis(fa=v) + elif self._assume_disc_small: + B = f.nfbasis(1) + elif not important: +@@ -4575,34 +4575,6 @@ class NumberField_generic(number_field_base.NumberField): + self._integral_basis_dict[v] = B + return B + +- def _pari_disc_factorization_matrix(self, v): +- """ +- Returns a PARI matrix representation for the partial +- factorization of the discriminant of the defining polynomial +- of self, defined by the list of primes in the Python list v. +- This function is used internally by the number fields code. +- +- EXAMPLES:: +- +- sage: x = polygen(QQ,'x') +- sage: f = x^3 + 17*x + 393; f.discriminant().factor() +- -1 * 5^2 * 29 * 5779 +- sage: K. = NumberField(f) +- sage: fa = K._pari_disc_factorization_matrix([5,29]); fa +- [5, 2; 29, 1] +- sage: fa.type() +- 't_MAT' +- """ +- f = self.pari_polynomial() +- m = pari.matrix(len(v), 2) +- d = f.poldisc() +- for i in range(len(v)): +- p = pari(ZZ(v[i])) +- m[i,0] = p +- m[i,1] = d.valuation(p) +- return m +- +- + def reduced_basis(self, prec=None): + r""" + This function returns an LLL-reduced basis for the +@@ -5299,7 +5271,14 @@ class NumberField_generic(number_field_base.NumberField): + sage: K.units(proof=True) # takes forever, not tested + ... + sage: K.units(proof=False) # result not independently verified +- (a^9 + a - 1, a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, a^16 + a^15 + a^14 + a^13 + a^12 + a^11 + a^10 + a^9 + a^8 + a^7 + a^6 + a^5 + a^4 + a^3 + a^2 - 2, 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7) ++ (a^9 + a - 1, ++ a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, ++ a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, ++ 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, ++ 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, ++ a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 + 5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7, ++ a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, ++ 5*a^16 - 6*a^14 + a^13 + 7*a^12 - 2*a^11 - 7*a^10 + 4*a^9 + 7*a^8 - 6*a^7 - 7*a^6 + 8*a^5 + 6*a^4 - 11*a^3 - 5*a^2 + 13*a + 4) + """ + proof = proof_flag(proof) + +@@ -5371,7 +5350,7 @@ class NumberField_generic(number_field_base.NumberField): + sage: U.gens() + (u0, u1, u2, u3, u4, u5, u6, u7, u8) + sage: U.gens_values() # result not independently verified +- [-1, a^9 + a - 1, a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, a^16 + a^15 + a^14 + a^13 + a^12 + a^11 + a^10 + a^9 + a^8 + a^7 + a^6 + a^5 + a^4 + a^3 + a^2 - 2, 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7] ++ [-1, a^9 + a - 1, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 + 5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, 5*a^16 - 6*a^14 + a^13 + 7*a^12 - 2*a^11 - 7*a^10 + 4*a^9 + 7*a^8 - 6*a^7 - 7*a^6 + 8*a^5 + 6*a^4 - 11*a^3 - 5*a^2 + 13*a + 4] + """ + proof = proof_flag(proof) + +@@ -5421,8 +5400,7 @@ class NumberField_generic(number_field_base.NumberField): + sage: U.gens() + (u0, u1, u2, u3) + sage: U.gens_values() +- [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2, 14/275*a^3 - 21/55*a^2 + 29/11*a - 6, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5] # 32-bit +- [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2, -14/275*a^3 + 21/55*a^2 - 29/11*a + 6, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5] # 64-bit ++ [-7/275*a^3 + 1/11*a^2 - 9/11*a - 1, 6/275*a^3 - 9/55*a^2 + 14/11*a - 2, -14/275*a^3 + 21/55*a^2 - 29/11*a + 6, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5] + sage: U.invariants() + (10, 0, 0, 0) + sage: [u.multiplicative_order() for u in U.gens()] +@@ -5566,9 +5544,9 @@ class NumberField_generic(number_field_base.NumberField): + sage: r. = QQ[] + sage: K. = NumberField(x^2+1) + sage: K.zeta(4) +- -b ++ b + sage: K.zeta(4,all=True) +- [-b, b] ++ [b, -b] + sage: K.zeta(3) + Traceback (most recent call last): + ... +@@ -5666,7 +5644,7 @@ class NumberField_generic(number_field_base.NumberField): + + sage: K. = NumberField(x^2+1) + sage: z = K.primitive_root_of_unity(); z +- -i ++ i + sage: z.multiplicative_order() + 4 + +@@ -5692,11 +5670,11 @@ class NumberField_generic(number_field_base.NumberField): + sage: z.multiplicative_order() + 6 + +- sage: K = CyclotomicField(7) ++ sage: K = CyclotomicField(3) + sage: z = K.primitive_root_of_unity(); z +- zeta7^5 + zeta7^4 + zeta7^3 + zeta7^2 + zeta7 + 1 ++ zeta3 + 1 + sage: z.multiplicative_order() +- 14 ++ 6 + + TESTS: + +@@ -5730,7 +5708,7 @@ class NumberField_generic(number_field_base.NumberField): + + sage: K. = NumberField(x^2+1) + sage: zs = K.roots_of_unity(); zs +- [-b, -1, b, 1] ++ [b, -1, -b, 1] + sage: [ z**K.number_of_roots_of_unity() for z in zs ] + [1, 1, 1, 1] + """ +@@ -7795,8 +7773,7 @@ class NumberField_absolute(NumberField_generic): + sage: K.hilbert_conductor(K(2),K(-2)) + Fractional ideal (1) + sage: K.hilbert_conductor(K(2*b),K(-2)) +- Fractional ideal (-b^2 - b + 2) +- ++ Fractional ideal (b^2 + b - 2) + + AUTHOR: + +diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx +index 91c4d1b..a8dcbeb 100644 +--- a/src/sage/rings/number_field/number_field_element.pyx ++++ b/src/sage/rings/number_field/number_field_element.pyx +@@ -329,9 +329,11 @@ cdef class NumberFieldElement(FieldElement): + fmod = f.mod() + for i from 0 <= i <= fmod.poldegree(): + if fmod.polcoeff(i).type() in ["t_POL", "t_POLMOD"]: +- # Convert relative element to absolute +- # This returns a polynomial, not a polmod +- f = parent.pari_rnf().rnfeltreltoabs(f) ++ # Convert relative element to absolute. ++ # Sometimes the result is a polynomial, ++ # sometimed a polmod. Lift to convert to a ++ # polynomial in all cases. ++ f = parent.pari_rnf().rnfeltreltoabs(f).lift() + break + # Check that the modulus is actually the defining polynomial + # of the number field. +@@ -1188,7 +1190,7 @@ cdef class NumberFieldElement(FieldElement): + sage: Q. = K[] + sage: L. = NumberField(X^4 + a) + sage: t = (-a).is_norm(L, element=True); t +- (True, -b^3 + 1) ++ (True, b^3 + 1) + sage: t[1].norm(K) + -a + +@@ -1289,11 +1291,11 @@ cdef class NumberFieldElement(FieldElement): + sage: Q. = K[] + sage: L. = NumberField(X^4 + a) + sage: t = (-a)._rnfisnorm(L); t +- (-b^3 + 1, 1) ++ (b^3 + 1, 1) + sage: t[0].norm(K) + -a + sage: t = K(3)._rnfisnorm(L); t +- ((a^2 + 1)*b^3 + b^2 - a*b + a^2 + 1, -3*a) ++ ((a^2 + 1)*b^3 - b^2 - a*b - a^2, -3*a^2 + 3*a - 3) + sage: t[0].norm(K)*t[1] + 3 + +@@ -1323,6 +1325,9 @@ cdef class NumberFieldElement(FieldElement): + + rnf_data = K.pari_rnfnorm_data(L, proof=proof) + x, q = self._pari_().rnfisnorm(rnf_data) ++ ++ # Convert x to an absolute element ++ x = L.pari_rnf().rnfeltreltoabs(x) + return L(x), K(q) + + def _mpfr_(self, R): +@@ -1339,7 +1344,7 @@ cdef class NumberFieldElement(FieldElement): + sage: (a^2)._mpfr_(RR) + -1.00000000000000 + +- Verify that :trac:`#13005` has been fixed:: ++ Verify that :trac:`13005` has been fixed:: + + sage: K. = NumberField(x^2-5) + sage: RR(K(1)) +@@ -3813,12 +3818,12 @@ cdef class NumberFieldElement_relative(NumberFieldElement): + sage: K. = NumberField(y^2 + y + 1) + sage: x = polygen(K) + sage: L. = NumberField(x^4 + a*x + 2) +- sage: e = pari(a*b); e +- Mod(-y^4 - 2, y^8 - y^5 + 4*y^4 + y^2 - 2*y + 4) ++ sage: e = (a*b)._pari_('x'); e ++ Mod(-x^4 - 2, x^8 - x^5 + 4*x^4 + x^2 - 2*x + 4) + sage: L(e) # Conversion from PARI absolute number field element + a*b + sage: e = L.pari_rnf().rnfeltabstorel(e); e +- Mod(Mod(y, y^2 + y + 1)*x, x^4 + y*x + 2) ++ Mod(Mod(y, y^2 + y + 1)*x, x^4 + Mod(y, y^2 + y + 1)*x + 2) + sage: L(e) # Conversion from PARI relative number field element + a*b + sage: e = pari('Mod(0, x^8 + 1)'); L(e) # Wrong modulus +@@ -3832,10 +3837,12 @@ cdef class NumberFieldElement_relative(NumberFieldElement): + sage: L(e) + a*b^2 + 1 + +- Currently, conversions of PARI relative number fields are not checked:: ++ This wrong modulus yields a PARI error:: + +- sage: e = pari('Mod(y*x, x^4 + y^2*x + 2)'); L(e) # Wrong modulus, but succeeds anyway +- a*b ++ sage: e = pari('Mod(y*x, x^4 + y^2*x + 2)'); L(e) ++ Traceback (most recent call last): ++ ... ++ PariError: inconsistent moduli in rnfeltreltoabs: x^4 + y^2*x + 2 != y^2 + y + 1 + """ + NumberFieldElement.__init__(self, parent, f) + +diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py +index 51dadd8..2092543 100644 +--- a/src/sage/rings/number_field/number_field_ideal.py ++++ b/src/sage/rings/number_field/number_field_ideal.py +@@ -83,14 +83,17 @@ def convert_from_idealprimedec_form(field, ideal): + sage: K_bnf = gp(K.pari_bnf()) + sage: ideal = K_bnf.idealprimedec(3)[1] + sage: convert_from_idealprimedec_form(K, ideal) ++ doctest:...: DeprecationWarning: convert_from_idealprimedec_form() is deprecated ++ See http://trac.sagemath.org/15767 for details. + Fractional ideal (-a) + sage: K.factor(3) + (Fractional ideal (-a))^2 +- + """ +- # This indexation is very ugly and should be dealt with in #10002 ++ from sage.misc.superseded import deprecation ++ deprecation(15767, "convert_from_idealprimedec_form() is deprecated") ++ + p = ZZ(ideal[1]) +- alpha = field(field.pari_nf().getattr('zk') * ideal[2]) ++ alpha = field(field.pari_zk() * ideal[2]) + return field.ideal(p, alpha) + + def convert_to_idealprimedec_form(field, ideal): +@@ -116,16 +119,13 @@ def convert_to_idealprimedec_form(field, ideal): + sage: K. = NumberField(x^2 + 3) + sage: P = K.ideal(a/2-3/2) + sage: convert_to_idealprimedec_form(K, P) +- [3, [1, 2]~, 2, 1, [1, -1]~] +- ++ doctest:...: DeprecationWarning: convert_to_idealprimedec_form() is deprecated, use ideal.pari_prime() instead ++ See http://trac.sagemath.org/15767 for details. ++ [3, [1, 2]~, 2, 1, [1, 1; -1, 2]] + """ +- p = ideal.residue_field().characteristic() +- from sage.interfaces.gp import gp +- K_bnf = gp(field.pari_bnf()) +- for primedecform in K_bnf.idealprimedec(p): +- if convert_from_idealprimedec_form(field, primedecform) == ideal: +- return primedecform +- raise RuntimeError ++ from sage.misc.superseded import deprecation ++ deprecation(15767, "convert_to_idealprimedec_form() is deprecated, use ideal.pari_prime() instead") ++ return field.ideal(ideal).pari_prime() + + class NumberFieldIdeal(Ideal_generic): + """ +@@ -157,7 +157,7 @@ class NumberFieldIdeal(Ideal_generic): + Fractional ideal (3) + sage: F = pari(K).idealprimedec(5) + sage: K.ideal(F[0]) +- Fractional ideal (i - 2) ++ Fractional ideal (2*i + 1) + + TESTS: + +@@ -165,7 +165,7 @@ class NumberFieldIdeal(Ideal_generic): + prime ideal:: + + sage: K.ideal(pari(K).idealprimedec(5)[0])._pari_prime +- [5, [-2, 1]~, 1, 1, [2, 1]~] ++ [5, [-2, 1]~, 1, 1, [2, -1; 1, 2]] + """ + if not isinstance(field, number_field.NumberField_generic): + raise TypeError("field (=%s) must be a number field."%field) +@@ -195,8 +195,8 @@ class NumberFieldIdeal(Ideal_generic): + EXAMPLES:: + + sage: NumberField(x^2 + 1, 'a').ideal(7).__hash__() +- -9223372036854775779 # 64-bit +- -2147483619 # 32-bit ++ 848642427 # 32-bit ++ 3643975048496365947 # 64-bit + """ + try: + return self._hash +@@ -313,7 +313,7 @@ class NumberFieldIdeal(Ideal_generic): + sage: A = K.ideal([5, 2 + I]) + sage: B = K.ideal([13, 5 + 12*I]) + sage: A*B +- Fractional ideal (-4*I + 7) ++ Fractional ideal (4*I - 7) + sage: (K.ideal(3 + I) * K.ideal(7 + I)).gens() + (10*I + 20,) + +@@ -1060,7 +1060,7 @@ class NumberFieldIdeal(Ideal_generic): + sage: K.ideal(3).pari_prime() + [3, [3, 0]~, 1, 2, 1] + sage: K.ideal(2+i).pari_prime() +- [5, [2, 1]~, 1, 1, [-2, 1]~] ++ [5, [2, 1]~, 1, 1, [-2, -1; 1, -2]] + sage: K.ideal(2).pari_prime() + Traceback (most recent call last): + ... +@@ -2238,7 +2238,7 @@ class NumberFieldFractionalIdeal(NumberFieldIdeal): + sage: I = K.ideal((3+4*i)/5); I + Fractional ideal (4/5*i + 3/5) + sage: I.denominator() +- Fractional ideal (i - 2) ++ Fractional ideal (2*i + 1) + sage: I.numerator() + Fractional ideal (-i - 2) + sage: I.numerator().is_integral() and I.denominator().is_integral() +@@ -2268,7 +2268,7 @@ class NumberFieldFractionalIdeal(NumberFieldIdeal): + sage: I = K.ideal((3+4*i)/5); I + Fractional ideal (4/5*i + 3/5) + sage: I.denominator() +- Fractional ideal (i - 2) ++ Fractional ideal (2*i + 1) + sage: I.numerator() + Fractional ideal (-i - 2) + sage: I.numerator().is_integral() and I.denominator().is_integral() +@@ -2999,15 +2999,15 @@ class NumberFieldFractionalIdeal(NumberFieldIdeal): + An example of reduction maps to the residue field: these are + defined on the whole valuation ring, i.e. the subring of the + number field consisting of elements with non-negative +- valuation. This shows that the issue raised in trac \#1951 ++ valuation. This shows that the issue raised in :trac:`1951` + has been fixed:: + + sage: K. = NumberField(x^2 + 1) + sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2) +- (Fractional ideal (-i - 2), Fractional ideal (i - 2)) ++ (Fractional ideal (-i - 2), Fractional ideal (2*i + 1)) + sage: a = 1/(1+2*i) + sage: F1, F2 = [g.residue_field() for g in [P1,P2]]; (F1,F2) +- (Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (i - 2)) ++ (Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (2*i + 1)) + sage: a.valuation(P1) + 0 + sage: F1(i/7) +@@ -3018,7 +3018,7 @@ class NumberFieldFractionalIdeal(NumberFieldIdeal): + -1 + sage: F2(a) + Traceback (most recent call last): +- ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (i - 2): it has negative valuation ++ ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (2*i + 1): it has negative valuation + + An example with a relative number field:: + +@@ -3058,7 +3058,7 @@ class NumberFieldFractionalIdeal(NumberFieldIdeal): + sage: K. = NumberField(x^5 + 2); K + Number Field in a with defining polynomial x^5 + 2 + sage: f = K.factor(19); f +- (Fractional ideal (a^2 + a - 3)) * (Fractional ideal (-2*a^4 - a^2 + 2*a - 1)) * (Fractional ideal (-a^2 - a + 1)) ++ (Fractional ideal (a^2 + a - 3)) * (Fractional ideal (-2*a^4 - a^2 + 2*a - 1)) * (Fractional ideal (a^2 + a - 1)) + sage: [i.residue_class_degree() for i, _ in f] + [2, 2, 1] + """ +diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py +index ba6fab5..6f50855 100644 +--- a/src/sage/rings/number_field/number_field_ideal_rel.py ++++ b/src/sage/rings/number_field/number_field_ideal_rel.py +@@ -114,12 +114,12 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal): + sage: K. = NumberField([x^2 + 23, x^2 - 7]) + sage: I = K.ideal(2, (a + 2*b + 3)/2) + sage: I.pari_rhnf() +- [[1, -2; 0, 1], [[2, 1; 0, 1], [1/2, 0; 0, 1/2]]] ++ [[1, -2; 0, 1], [[2, 1; 0, 1], 1/2]] + """ + try: + return self.__pari_rhnf + except AttributeError: +- nfzk = self.number_field().absolute_field('a').pari_zk() ++ nfzk = self.number_field().pari_nf().nf_subst('x').nf_get_zk() + rnf = self.number_field().pari_rnf() + L_hnf = self.absolute_ideal().pari_hnf() + self.__pari_rhnf = rnf.rnfidealabstorel(nfzk * L_hnf) +@@ -485,7 +485,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal): + sage: K. = F.extension(Y^2 - (1 + a)*(a + b)*a*b) + sage: I = K.ideal(3, c) + sage: J = I.ideal_below(); J +- Fractional ideal (-b) ++ Fractional ideal (b) + sage: J.number_field() == F + True + """ +diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py +index 3fb70f7..98435fe 100644 +--- a/src/sage/rings/number_field/number_field_rel.py ++++ b/src/sage/rings/number_field/number_field_rel.py +@@ -207,7 +207,7 @@ class NumberField_relative(NumberField_generic): + sage: b + Traceback (most recent call last): + ... +- PariError: incorrect type in core2partial ++ PariError: incorrect type in core2partial (t_FRAC) + + However, if the polynomial is linear, rational coefficients should work:: + +@@ -1060,7 +1060,7 @@ class NumberField_relative(NumberField_generic): + pol = element.polynomial('y') + t2 = pol(a).lift() + if check: +- t1 = self.pari_rnf().rnfeltreltoabs(pol._pari_()) ++ t1 = self.pari_rnf().rnfeltreltoabs(pol).lift() + assert t1 == t2 + return t2 + +@@ -1145,7 +1145,7 @@ class NumberField_relative(NumberField_generic): + + sage: k. = NumberField([x^3 + 2, x^2 + 2]) + sage: k._pari_base_bnf() +- [[;], matrix(0,9), [;], ... 0] ++ [[;], matrix(0,3), [;], ...] + """ + abs_base, from_abs_base, to_abs_base = self.absolute_base_field() + return abs_base.pari_bnf(proof, units) +@@ -1283,10 +1283,10 @@ class NumberField_relative(NumberField_generic): + Galois conjugate:: + + sage: for g in G: +- ... if L1.is_isomorphic_relative(L2, g.as_hom()): +- ... print g.as_hom() ++ ....: if L1.is_isomorphic_relative(L2, g.as_hom()): ++ ....: print g.as_hom() + Ring endomorphism of Number Field in z9 with defining polynomial x^6 + x^3 + 1 +- Defn: z9 |--> -z9^4 - z9 ++ Defn: z9 |--> z9^4 + """ + if is_RelativeNumberField(other): + s_base_field = self.base_field() +@@ -1575,7 +1575,7 @@ class NumberField_relative(NumberField_generic): + + sage: k. = NumberField([x^4 + 3, x^2 + 2]) + sage: k.pari_rnf() +- [x^4 + 3, [], [[108, 0; 0, 108], 3], [8, 0; 0, 8], [], [], [[1, x - 1, x^2 - 1, x^3 - x^2 - x - 3], ..., 0] ++ [x^4 + 3, [[364, -10*x^7 - 87*x^5 - 370*x^3 - 41*x], 1/364], [[108, 0; 0, 108], 3], ...] + """ + return self._pari_base_nf().rnfinit(self.pari_relative_polynomial()) + +@@ -2317,7 +2317,7 @@ class NumberField_relative(NumberField_generic): + ... + ValueError: The element b is not in the base field + """ +- polmodmod_xy = self.pari_rnf().rnfeltabstorel( self(element)._pari_() ) ++ polmodmod_xy = self.pari_rnf().rnfeltabstorel( self(element)._pari_('x') ) + # polmodmod_xy is a POLMOD with POLMOD coefficients in general. + # These POLMOD coefficients represent elements of the base field K. + # We do two lifts so we get a polynomial. We need the simplify() to +diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py +index 99fe015..43d2e25 100644 +--- a/src/sage/rings/number_field/order.py ++++ b/src/sage/rings/number_field/order.py +@@ -245,7 +245,7 @@ class Order(IntegralDomain): + + sage: k. = NumberField(x^2 + 5077); G = k.class_group(); G + Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077 +- sage: G.0 ++ sage: G.0 ^ -9 + Fractional ideal class (11, a + 7) + sage: Ok = k.maximal_order(); Ok + Maximal Order in Number Field in a with defining polynomial x^2 + 5077 +diff --git a/src/sage/rings/number_field/unit_group.py b/src/sage/rings/number_field/unit_group.py +index 6029b83..a8fcc15 100644 +--- a/src/sage/rings/number_field/unit_group.py ++++ b/src/sage/rings/number_field/unit_group.py +@@ -173,18 +173,10 @@ class UnitGroup(AbelianGroupWithValues_class): + sage: UK = K.unit_group() + sage: UK.ngens() + 6 +- sage: UK.gen(0) # random +- -z^11 +- sage: UK.gen(1) # random +- z^5 + z^3 +- sage: UK.gen(2) # random +- z^6 + z^5 +- sage: UK.gen(3) # random +- z^9 + z^7 + z^5 +- sage: UK.gen(4) # random +- z^9 + z^5 + z^4 + 1 +- sage: UK.gen(5) # random +- z^5 + z ++ sage: UK.gen(5) ++ u5 ++ sage: UK.gen(5).value() ++ z^6 + z^4 + + An S-unit group:: + +@@ -195,7 +187,7 @@ class UnitGroup(AbelianGroupWithValues_class): + sage: SUK.zeta_order() + 26 + sage: SUK.log(21*z) +- (6, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1) ++ (13, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1) + """ + # This structure is not a parent in the usual sense. The + # "elements" are NumberFieldElement_absolute. Instead, they should +@@ -427,7 +419,7 @@ class UnitGroup(AbelianGroupWithValues_class): + sage: K. = NumberField(x^2+1) + sage: U = UnitGroup(K) + sage: zs = U.roots_of_unity(); zs +- [-b, -1, b, 1] ++ [b, -1, -b, 1] + sage: [ z**U.zeta_order() for z in zs ] + [1, 1, 1, 1] + """ +@@ -493,9 +485,9 @@ class UnitGroup(AbelianGroupWithValues_class): + sage: K. = NumberField(x^2+1) + sage: U = UnitGroup(K) + sage: U.zeta(4) +- -b ++ b + sage: U.zeta(4,all=True) +- [-b, b] ++ [b, -b] + sage: U.zeta(3) + Traceback (most recent call last): + ... +@@ -599,7 +591,7 @@ class UnitGroup(AbelianGroupWithValues_class): + sage: SUK = UnitGroup(K,S=2) + sage: v = (3,1,4,1,5,9,2) + sage: u = SUK.exp(v); u +- -997204*z^11 - 2419728*z^10 - 413812*z^9 - 413812*z^8 - 2419728*z^7 - 997204*z^6 - 2129888*z^4 - 1616524*z^3 + 149364*z^2 - 1616524*z - 2129888 ++ 180*z^10 - 280*z^9 + 580*z^8 - 720*z^7 + 948*z^6 - 924*z^5 + 948*z^4 - 720*z^3 + 580*z^2 - 280*z + 180 + sage: SUK.log(u) + (3, 1, 4, 1, 5, 9, 2) + sage: SUK.log(u) == v +@@ -645,7 +637,7 @@ class UnitGroup(AbelianGroupWithValues_class): + sage: SUK = UnitGroup(K,S=2) + sage: v = (3,1,4,1,5,9,2) + sage: u = SUK.exp(v); u +- -997204*z^11 - 2419728*z^10 - 413812*z^9 - 413812*z^8 - 2419728*z^7 - 997204*z^6 - 2129888*z^4 - 1616524*z^3 + 149364*z^2 - 1616524*z - 2129888 ++ 180*z^10 - 280*z^9 + 580*z^8 - 720*z^7 + 948*z^6 - 924*z^5 + 948*z^4 - 720*z^3 + 580*z^2 - 280*z + 180 + sage: SUK.log(u) + (3, 1, 4, 1, 5, 9, 2) + sage: SUK.log(u) == v +diff --git a/src/sage/rings/polynomial/cyclotomic.pyx b/src/sage/rings/polynomial/cyclotomic.pyx +index 8c5adb8..571c9d2 100644 +--- a/src/sage/rings/polynomial/cyclotomic.pyx ++++ b/src/sage/rings/polynomial/cyclotomic.pyx +@@ -247,13 +247,16 @@ def cyclotomic_value(n, x): + + TESTS:: + +- sage: K. = NumberField(polygen(QQ)^2 + 1) + sage: R. = QQ[] +- sage: for y in [-1, 0, 1, 2, 1/2, mod(3, 8), GF(9,'a').gen(), Zp(3)(54), i, x^2+2]: +- ... for n in range(1, 61): +- ... val1 = cyclotomic_value(n, y) +- ... val2 = cyclotomic_polynomial(n)(y) +- ... assert val1 == val2 and val1.parent() is val2.parent() ++ sage: K. = NumberField(x^2 + 1) ++ sage: for y in [-1, 0, 1, 2, 1/2, Mod(3, 8), Mod(3,11), GF(9,'a').gen(), Zp(3)(54), i, x^2+2]: ++ ....: for n in [1..60]: ++ ....: val1 = cyclotomic_value(n, y) ++ ....: val2 = cyclotomic_polynomial(n)(y) ++ ....: if val1 != val2: ++ ....: print "Wrong value for cyclotomic_value(%s, %s) in %s"%(n,y,parent(y)) ++ ....: if val1.parent() is not val2.parent(): ++ ....: print "Wrong parent for cyclotomic_value(%s, %s) in %s"%(n,y,parent(y)) + + sage: cyclotomic_value(20, I) + 5 +@@ -275,15 +278,25 @@ def cyclotomic_value(n, x): + 1 + """ + n = int(n) +- if n == 1: +- return x - 1 +- if n <= 0: +- raise ValueError, "n must be positive" ++ if n < 3: ++ if n == 1: ++ return x - 1 ++ if n == 2: ++ return x + 1 ++ raise ValueError("n must be positive") ++ + try: +- return x.parent()(pari.polcyclo_eval(n, x._pari_())) ++ return x.parent()(pari.polcyclo_eval(n, x)) + except Exception: + pass +- # The following is modeled on the implementation in Pari ++ ++ # The following is modeled on the implementation in PARI and is ++ # used for cases for which PARI doesn't work. These are in ++ # particular: ++ # - n does not fit in a C long; ++ # - x is some Sage type which cannot be converted to PARI; ++ # - PARI's algorithm encounters a zero-divisor which is not zero. ++ + factors = factor(n) + cdef Py_ssize_t i, j, ti, L, root_of_unity = -1 + primes = [p for p, e in factors] +diff --git a/src/sage/rings/polynomial/padics/polynomial_padic.py b/src/sage/rings/polynomial/padics/polynomial_padic.py +index c8cae05..c99fe1e 100644 +--- a/src/sage/rings/polynomial/padics/polynomial_padic.py ++++ b/src/sage/rings/polynomial/padics/polynomial_padic.py +@@ -86,7 +86,7 @@ class Polynomial_padic(Polynomial): + 1 (1 + O(3^3))*t + (-1 + O(3^3)) + 1 (1 + O(3^3))*t^2 + (5 + O(3^3))*t + (-1 + O(3^3)) + 1 (1 + O(3^3))*t^2 + (-5 + O(3^3))*t + (-1 + O(3^3)) +- 1 (1 + O(3^3))*t^2 + (1 + O(3^3)) ++ 1 (1 + O(3^3))*t^2 + (0 + O(3^3))*t + (1 + O(3^3)) + sage: R. = PolynomialRing(Qp(5,6,print_mode='terse',print_pos=False)) + sage: pol = 100 * (5*t - 1) * (t - 5) + sage: pol +diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx +index b81a919..14173df 100644 +--- a/src/sage/rings/polynomial/polynomial_element.pyx ++++ b/src/sage/rings/polynomial/polynomial_element.pyx +@@ -3244,9 +3244,7 @@ cdef class Polynomial(CommutativeAlgebraElement): + sage: K. = QuadraticField(p*q) + sage: R. = PolynomialRing(K) + sage: K.pari_polynomial('a').nffactor("x^2+1") +- Traceback (most recent call last): +- ... +- PariError: precision too low in floorr (precision loss in truncation) ++ Mat([x^2 + 1, 1]) + sage: factor(x^2 + 1) + x^2 + 1 + sage: factor( (x - a) * (x + 2*a) ) +@@ -4614,7 +4612,7 @@ cdef class Polynomial(CommutativeAlgebraElement): + sage: pari(f) + Traceback (most recent call last): + ... +- PariError: variable must have higher priority in gtopoly ++ PariError: incorrect priority in gtopoly: variable x <= a + + Stacked polynomial rings, first with a univariate ring on the + bottom:: +diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py +index 8d9975d..99bec5a 100644 +--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py ++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py +@@ -1234,11 +1234,11 @@ class PolynomialQuotientRing_generic(sage.rings.commutative_ring.CommutativeRing + sage: L. = K['y'].quotient(y^3 + 5); L + Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5 + sage: L.S_units([]) +- [(-1/2*a + 1/2, 6), ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)] ++ [(-1/2*a + 1/2, 6), ((1/3*a - 1)*b^2 + 4/3*a*b + 5/6*a + 7/2, +Infinity), ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity)] + sage: L.S_units([K.ideal(1/2*a - 3/2)]) +- [((-1/6*a - 1/2)*b^2 + (1/3*a + 1)*b - 2/3*a - 2, +Infinity), (-1/2*a + 1/2, 6), ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)] ++ [((-1/6*a - 1/2)*b^2 + (1/3*a - 1)*b + 4/3*a, +Infinity), (-1/2*a + 1/2, 6), ((1/3*a - 1)*b^2 + 4/3*a*b + 5/6*a + 7/2, +Infinity), ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity)] + sage: L.S_units([K.ideal(2)]) +- [((1/6*a + 1/2)*b^2 + (-1/3*a - 1)*b + 2/3*a + 1, +Infinity), ((-1/6*a - 1/2)*b^2 + (1/3*a + 1)*b - 1/6*a - 3/2, +Infinity), ((-1/2*a + 1/2)*b^2 + (a - 1)*b - 3/2*a + 3/2, +Infinity), (-1/2*a + 1/2, 6), ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)] ++ [((-1/2*a + 1/2)*b^2 + (-a - 1)*b - 3, +Infinity), ((-1/6*a - 1/2)*b^2 + (1/3*a - 1)*b + 5/6*a - 1/2, +Infinity), ((1/6*a + 1/2)*b^2 + (-1/3*a + 1)*b - 5/6*a - 1/2, +Infinity), (-1/2*a + 1/2, 6), ((1/3*a - 1)*b^2 + 4/3*a*b + 5/6*a + 7/2, +Infinity), ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity)] + + Note that all the returned values live where we expect them to:: + +@@ -1314,14 +1314,14 @@ class PolynomialQuotientRing_generic(sage.rings.commutative_ring.CommutativeRing + sage: L. = K['y'].quotient(y^3 + 5); L + Univariate Quotient Polynomial Ring in b over Number Field in a with defining polynomial x^2 + 3 with modulus y^3 + 5 + sage: L.units() +- [(-1/2*a + 1/2, 6), ((-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, +Infinity), (2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3, +Infinity)] ++ [(-1/2*a + 1/2, 6), ((1/3*a - 1)*b^2 + 4/3*a*b + 5/6*a + 7/2, +Infinity), ((-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2, +Infinity)] + sage: L. = K.extension(y^3 + 5) + sage: L.unit_group() + Unit group with structure C6 x Z x Z of Number Field in b with defining polynomial x^3 + 5 over its base field + sage: L.unit_group().gens() # abstract generators + (u0, u1, u2) + sage: L.unit_group().gens_values() +- [-1/2*a + 1/2, (-1/3*a + 1)*b^2 - 4/3*a*b - 4/3*a - 3, 2/3*a*b^2 + (2/3*a + 2)*b - 4/3*a + 3] ++ [-1/2*a + 1/2, (1/3*a - 1)*b^2 + 4/3*a*b + 5/6*a + 7/2, (-1/3*a + 1)*b^2 + (2/3*a - 2)*b - 5/6*a + 7/2] + + Note that all the returned values live where we expect them to:: + +diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx +index 0c13ffe..e84e148 100644 +--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx ++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx +@@ -1568,9 +1568,9 @@ cdef class Polynomial_rational_flint(Polynomial): + sage: R. = QQ[] + sage: f = x^3 - 2 + sage: f.factor_padic(2) +- (1 + O(2^10))*x^3 + (2 + 2^2 + 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9 + O(2^10)) ++ (1 + O(2^10))*x^3 + (O(2^10))*x^2 + (O(2^10))*x + (2 + 2^2 + 2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9 + O(2^10)) + sage: f.factor_padic(3) +- (1 + O(3^10))*x^3 + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + O(3^10)) ++ (1 + O(3^10))*x^3 + (O(3^10))*x^2 + (O(3^10))*x + (1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + O(3^10)) + sage: f.factor_padic(5) + ((1 + O(5^10))*x + (2 + 4*5 + 2*5^2 + 2*5^3 + 5^4 + 3*5^5 + 4*5^7 + 2*5^8 + 5^9 + O(5^10))) * ((1 + O(5^10))*x^2 + (3 + 2*5^2 + 2*5^3 + 3*5^4 + 5^5 + 4*5^6 + 2*5^8 + 3*5^9 + O(5^10))*x + (4 + 5 + 2*5^2 + 4*5^3 + 4*5^4 + 3*5^5 + 3*5^6 + 4*5^7 + 4*5^9 + O(5^10))) + +diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py +index 7f5653e..1038bcb 100644 +--- a/src/sage/rings/qqbar.py ++++ b/src/sage/rings/qqbar.py +@@ -1635,7 +1635,7 @@ def do_polred(poly): + sage: do_polred(x^2 - x - 11) + (1/3*x + 1/3, 3*x - 1, x^2 - x - 1) + sage: do_polred(x^3 + 123456) +- (-1/4*x, -4*x, x^3 - 1929) ++ (1/4*x, 4*x, x^3 + 1929) + + This shows that :trac:`13054` has been fixed:: + +@@ -1887,11 +1887,11 @@ def number_field_elements_from_algebraics(numbers, minimal=False): + elements, and then mapping them back into ``QQbar``:: + + sage: (fld,nums,hom) = number_field_elements_from_algebraics((rt2, rt3, qqI, z3)) +- sage: fld,nums,hom +- (Number Field in a with defining polynomial y^8 - y^4 + 1, [-a^5 + a^3 + a, a^6 - 2*a^2, -a^6, a^4 - 1], Ring morphism: +- From: Number Field in a with defining polynomial y^8 - y^4 + 1 +- To: Algebraic Field +- Defn: a |--> -0.2588190451025208? + 0.9659258262890683?*I) ++ sage: fld,nums,hom # random ++ (Number Field in a with defining polynomial y^8 - y^4 + 1, [-a^5 + a^3 + a, a^6 - 2*a^2, a^6, -a^4], Ring morphism: ++ From: Number Field in a with defining polynomial y^8 - y^4 + 1 ++ To: Algebraic Field ++ Defn: a |--> -0.2588190451025208? - 0.9659258262890683?*I) + sage: (nfrt2, nfrt3, nfI, nfz3) = nums + sage: hom(nfrt2) + 1.414213562373095? + 0.?e-18*I +@@ -1904,7 +1904,8 @@ def number_field_elements_from_algebraics(numbers, minimal=False): + sage: nfI^2 + -1 + sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum +- -a^5 + a^4 + a^3 - 2*a^2 + a - 1 ++ -a^5 + a^4 + a^3 - 2*a^2 + a - 1 # 32-bit ++ 2*a^6 - a^5 - a^4 + a^3 - 2*a^2 + a # 64-bit + sage: hom(sum) + 2.646264369941973? + 1.866025403784439?*I + sage: hom(sum) == rt2 + rt3 + qqI + z3 +diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx +index d4e65c8..51ca79a 100644 +--- a/src/sage/rings/rational.pyx ++++ b/src/sage/rings/rational.pyx +@@ -1193,7 +1193,7 @@ cdef class Rational(sage.structure.element.FieldElement): + sage: 0.is_norm(K) + True + sage: (1/7).is_norm(K, element=True) +- (True, -1/7*beta - 3/7) ++ (True, 1/7*beta + 3/7) + sage: (1/10).is_norm(K, element=True) + (False, None) + sage: (1/691).is_norm(QQ, element=True) +diff --git a/src/sage/rings/residue_field.pyx b/src/sage/rings/residue_field.pyx +index 828b638..884ff93 100644 +--- a/src/sage/rings/residue_field.pyx ++++ b/src/sage/rings/residue_field.pyx +@@ -19,13 +19,13 @@ monogenic (i.e., 2 is an essential discriminant divisor):: + + sage: K. = NumberField(x^3 + x^2 - 2*x + 8) + sage: F = K.factor(2); F +- (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4)) ++ (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4)) + sage: F[0][0].residue_field() +- Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1) ++ Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1) + sage: F[1][0].residue_field() + Residue field of Fractional ideal (-a^2 + 2*a - 3) + sage: F[2][0].residue_field() +- Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4) ++ Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4) + + We can also form residue fields from `\ZZ`:: + +@@ -254,9 +254,9 @@ class ResidueFieldFactory(UniqueFactory): + the index of ``ZZ[a]`` in the maximal order for all ``a``:: + + sage: K. = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P +- Fractional ideal (-1/2*a^2 + 1/2*a - 1) ++ Fractional ideal (1/2*a^2 - 1/2*a + 1) + sage: F = K.residue_field(P); F +- Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1) ++ Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1) + sage: F(a) + 0 + sage: B = K.maximal_order().basis(); B +@@ -266,7 +266,7 @@ class ResidueFieldFactory(UniqueFactory): + sage: F(B[2]) + 0 + sage: F +- Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1) ++ Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1) + sage: F.degree() + 1 + +@@ -692,15 +692,15 @@ class ResidueField_generic(Field): + EXAMPLES:: + + sage: I = QQ[3^(1/3)].factor(5)[1][0]; I +- Fractional ideal (a - 2) ++ Fractional ideal (-a + 2) + sage: k = I.residue_field(); k +- Residue field of Fractional ideal (a - 2) ++ Residue field of Fractional ideal (-a + 2) + sage: f = k.lift_map(); f + Lifting map: +- From: Residue field of Fractional ideal (a - 2) ++ From: Residue field of Fractional ideal (-a + 2) + To: Maximal Order in Number Field in a with defining polynomial x^3 - 3 + sage: f.domain() +- Residue field of Fractional ideal (a - 2) ++ Residue field of Fractional ideal (-a + 2) + sage: f.codomain() + Maximal Order in Number Field in a with defining polynomial x^3 - 3 + sage: f(k.0) +@@ -728,7 +728,7 @@ class ResidueField_generic(Field): + + sage: K. = NumberField(x^3-11) + sage: F = K.ideal(37).factor(); F +- (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5)) * (Fractional ideal (37, a + 9)) ++ (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5)) * (Fractional ideal (37, a + 9)) + sage: k = K.residue_field(F[0][0]) + sage: l = K.residue_field(F[1][0]) + sage: k == l +@@ -805,7 +805,7 @@ cdef class ReductionMap(Map): + sage: F.reduction_map() + Partially defined reduction map: + From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8 +- To: Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1) ++ To: Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1) + + sage: K. = CyclotomicField(5) + sage: F = K.factor(7)[0][0].residue_field() +@@ -933,10 +933,10 @@ cdef class ReductionMap(Map): + + sage: K. = NumberField(x^2 + 1) + sage: P1, P2 = [g[0] for g in K.factor(5)]; (P1,P2) +- (Fractional ideal (-i - 2), Fractional ideal (i - 2)) ++ (Fractional ideal (-i - 2), Fractional ideal (2*i + 1)) + sage: a = 1/(1+2*i) + sage: F1, F2 = [g.residue_field() for g in [P1,P2]]; (F1,F2) +- (Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (i - 2)) ++ (Residue field of Fractional ideal (-i - 2), Residue field of Fractional ideal (2*i + 1)) + sage: a.valuation(P1) + 0 + sage: F1(i/7) +@@ -948,7 +948,7 @@ cdef class ReductionMap(Map): + sage: F2(a) + Traceback (most recent call last): + ... +- ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (i - 2): it has negative valuation ++ ZeroDivisionError: Cannot reduce field element -2/5*i + 1/5 modulo Fractional ideal (2*i + 1): it has negative valuation + """ + # The reduction map is just x |--> F(to_vs(x) * (PB**(-1))) if + # either x is integral or the denominator of x is coprime to +@@ -1012,7 +1012,7 @@ cdef class ReductionMap(Map): + sage: f = k.convert_map_from(K) + sage: s = f.section(); s + Lifting map: +- From: Residue field in abar of Fractional ideal (-14*a^4 + 24*a^3 + 26*a^2 - 58*a + 15) ++ From: Residue field in abar of Fractional ideal (14*a^4 - 24*a^3 - 26*a^2 + 58*a - 15) + To: Number Field in a with defining polynomial x^5 - 5*x + 2 + sage: s(k.gen()) + a +@@ -1223,7 +1223,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism): + sage: f = k.coerce_map_from(K.ring_of_integers()) + sage: s = f.section(); s + Lifting map: +- From: Residue field in abar of Fractional ideal (-14*a^4 + 24*a^3 + 26*a^2 - 58*a + 15) ++ From: Residue field in abar of Fractional ideal (14*a^4 - 24*a^3 - 26*a^2 + 58*a - 15) + To: Maximal Order in Number Field in a with defining polynomial x^5 - 5*x + 2 + sage: s(k.gen()) + a +diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py +index 1c3b2bb..be2fd62 100644 +--- a/src/sage/schemes/elliptic_curves/ell_generic.py ++++ b/src/sage/schemes/elliptic_curves/ell_generic.py +@@ -565,7 +565,7 @@ class EllipticCurve_generic(plane_curve.ProjectiveCurve_generic): + sage: E = EllipticCurve([0,0,0,-49,0]) + sage: T = E.torsion_subgroup() + sage: [E(t) for t in T] +- [(0 : 1 : 0), (7 : 0 : 1), (0 : 0 : 1), (-7 : 0 : 1)] ++ [(0 : 1 : 0), (-7 : 0 : 1), (0 : 0 : 1), (7 : 0 : 1)] + + :: + +@@ -2923,26 +2923,24 @@ class EllipticCurve_generic(plane_curve.ProjectiveCurve_generic): + Over a finite field:: + + sage: EllipticCurve(GF(41),[2,5]).pari_curve() +- [Mod(0, 41), Mod(0, 41), Mod(0, 41), Mod(2, 41), Mod(5, 41), Mod(0, 41), Mod(4, 41), Mod(20, 41), Mod(37, 41), Mod(27, 41), Mod(26, 41), Mod(4, 41), Mod(11, 41), 0, 0, 0, 0, 0, 0] ++ [Mod(0, 41), Mod(0, 41), Mod(0, 41), Mod(2, 41), Mod(5, 41), Mod(0, 41), Mod(4, 41), Mod(20, 41), Mod(37, 41), Mod(27, 41), Mod(26, 41), Mod(4, 41), Mod(11, 41), Vecsmall([3]), [41, [9, 31, [6, 0, 0, 0]]], [0, 0, 0, 0]] + + Over a `p`-adic field:: + + sage: Qp = pAdicField(5, prec=3) + sage: E = EllipticCurve(Qp,[3, 4]) + sage: E.pari_curve() +- [O(5^3), O(5^3), O(5^3), 3 + O(5^3), 4 + O(5^3), O(5^3), 1 + 5 + O(5^3), 1 + 3*5 + O(5^3), 1 + 3*5 + 4*5^2 + O(5^3), 1 + 5 + 4*5^2 + O(5^3), 4 + 3*5 + 5^2 + O(5^3), 2*5 + 4*5^2 + O(5^3), 3*5^-1 + O(5), [4 + 4*5 + 4*5^2 + O(5^3)], 1 + 2*5 + 4*5^2 + O(5^3), 1 + 5 + 4*5^2 + O(5^3), 2*5 + 4*5^2 + O(5^3), 3 + 3*5 + 3*5^2 + O(5^3), 0] ++ [0, 0, 0, 3, 4, 0, 6, 16, -9, -144, -3456, -8640, 1728/5, Vecsmall([2]), [O(5^3)], [0, 0]] + sage: E.j_invariant() + 3*5^-1 + O(5) + +- The `j`-invariant must have negative `p`-adic valuation:: ++ PARI no longer requires that the `j`-invariant has negative `p`-adic valuation:: + + sage: E = EllipticCurve(Qp,[1, 1]) + sage: E.j_invariant() # the j-invariant is a p-adic integer + 2 + 4*5^2 + O(5^3) + sage: E.pari_curve() +- Traceback (most recent call last): +- ... +- PariError: valuation of j must be negative in p-adic ellinit ++ [0, 0, 0, 1, 1, 0, 2, 4, -1, -48, -864, -496, 6912/31, Vecsmall([2]), [O(5^3)], [0, 0]] + """ + try: + return self._pari_curve +@@ -2965,13 +2963,11 @@ class EllipticCurve_generic(plane_curve.ProjectiveCurve_generic): + + sage: E = EllipticCurve('11a1') + sage: pari(E) +- [0, -1, 1, -10, -20, -4, -20, -79, -21, 496, 20008, -161051, -122023936/161051, [4.34630815820539, -1.67315407910270 + 1.32084892226908*I, -1.67315407910270 - 1.32084892226908*I]~, ...] +- sage: E.pari_curve(prec=64) +- [0, -1, 1, -10, -20, -4, -20, -79, -21, 496, 20008, -161051, -122023936/161051, [4.34630815820539, -1.67315407910270 + 1.32084892226908*I, -1.67315407910270 - 1.32084892226908*I]~, ...] ++ [0, -1, 1, -10, -20, -4, -20, -79, -21, 496, 20008, -161051, -122023936/161051, Vecsmall([1]), [Vecsmall([64, -1])], [0, 0, 0, 0, 0, 0, 0, 0]] + + Over a finite field:: + + sage: EllipticCurve(GF(2), [0,0,1,1,1])._pari_() +- [Mod(0, 2), Mod(0, 2), Mod(1, 2), Mod(1, 2), Mod(1, 2), Mod(0, 2), Mod(0, 2), Mod(1, 2), Mod(1, 2), Mod(0, 2), Mod(0, 2), Mod(1, 2), Mod(0, 2), 0, 0, 0, 0, 0, 0] ++ [0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, Vecsmall([4]), [1, [[Vecsmall([0, 1]), Vecsmall([0, 1]), Vecsmall([0, 1])], Vecsmall([0, 1]), [Vecsmall([0, 1]), Vecsmall([0]), Vecsmall([0]), Vecsmall([0])]]], [0, 0, 0, 0]] + """ + return self.pari_curve() +diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py +index eff2c0a..c8a23be 100644 +--- a/src/sage/schemes/elliptic_curves/ell_number_field.py ++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py +@@ -281,8 +281,10 @@ class EllipticCurve_number_field(EllipticCurve_field): + A = 0 + B = Mod(1, y^2 + 7) + C = Mod(y, y^2 + 7) ++ + Computing L(S,2) +- L(S,2) = [Mod(Mod(-1, y^2 + 7)*x^2 + Mod(-1/2*y + 1/2, y^2 + 7)*x + 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(-1, y^2 + 7)*x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(-1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1/2*y - 1/2, y^2 + 7)*x + Mod(1/2*y - 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x + Mod(1/2*y + 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(-1, y^2 + 7)*x + Mod(-1/2*y + 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))] ++ L(S,2) = [Mod(Mod(-1, y^2 + 7)*x^2 + Mod(-1/2*y + 1/2, y^2 + 7)*x + 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(-1, y^2 + 7)*x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(-1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x^2 + 2, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x + Mod(1/2*y + 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x + Mod(1/2*y - 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))] ++ + Computing the Selmer group + #LS2gen = 2 + LS2gen = [Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y - 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))] +@@ -296,7 +298,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + zc*z1^2 = Mod(Mod(2*y - 2, y^2 + 7)*x + Mod(2*y + 10, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)) + quartic: (-1/2*y + 1/2)*Y^2 = x^4 + (-3*y - 15)*x^2 + (-8*y - 16)*x + (-11/2*y - 15/2) + reduced: Y^2 = (-1/2*y + 1/2)*x^4 - 4*x^3 + (-3*y + 3)*x^2 + (2*y - 2)*x + (1/2*y + 3/2) +- not ELS at [2, [0, 1]~, 1, 1, [1, 1]~] ++ not ELS at [2, [0, 1]~, 1, 1, [1, -2; 1, 0]] + zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)) + comes from the trivial point [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7)] + m1 = 1 +@@ -336,8 +338,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + sage: K = CyclotomicField(43).subfields(3)[0][0] + sage: E = EllipticCurve(K, '37') + sage: E.simon_two_descent() # long time (4s on sage.math, 2013) +- (3, 3, [(0 : 0 : 1), (1/2*zeta43_0^2 + 3/2*zeta43_0 - 2 : -zeta43_0^2 - 4*zeta43_0 + 3 : 1)]) +- ++ (3, 3, [(0 : 0 : 1), (-1/4*zeta43_0^2 - 1/2*zeta43_0 + 3 : -3/8*zeta43_0^2 - 3/4*zeta43_0 + 4 : 1)]) + """ + verbose = int(verbose) + if known_points is None: +@@ -380,7 +381,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + - ``map`` -- (default: ``False``) also return an embedding of + the :meth:`base_field` into the resulting field. + +- - ``kwds`` -- additional keywords passed to ++ - ``kwds`` -- additional keywords passed to + :func:`sage.rings.number_field.splitting_field.splitting_field`. + + OUTPUT: +@@ -840,7 +841,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + sage: K. = NumberField(x^2 + 161*x - 150) + sage: E = EllipticCurve([25105/216*v - 3839/36, 634768555/7776*v - 98002625/1296, 634768555/7776*v - 98002625/1296, 0, 0]) + sage: E.global_integral_model() +- Elliptic Curve defined by y^2 + (-502639783*v+465618899)*x*y + (-6603604211463489399460860*v+6117229527723443603191500)*y = x^3 + (1526887622075335620*v-1414427901517840500)*x^2 over Number Field in v with defining polynomial x^2 + 161*x - 150 ++ Elliptic Curve defined by y^2 + (2094779518028859*v-1940492905300351)*x*y + (477997268472544193101178234454165304071127500*v-442791377441346852919930773849502871958097500)*y = x^3 + (26519784690047674853185542622500*v-24566525306469707225840460652500)*x^2 over Number Field in v with defining polynomial x^2 + 161*x - 150 + + :trac:`14476`:: + +@@ -970,7 +971,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + sage: K. = NumberField(x^2+1) + sage: E = EllipticCurve([1 + i, 0, 1, 0, 0]) + sage: E.local_data() +- [Local data at Fractional ideal (i - 2): ++ [Local data at Fractional ideal (2*i + 1): + Reduction type: bad non-split multiplicative + Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1 + Minimal discriminant valuation: 1 +@@ -1530,7 +1531,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + Fractional ideal (21*i - 3) + sage: K.=NumberField(x^2-x+3) + sage: EllipticCurve([1 + a , -1 + a , 1 + a , -11 + a , 5 -9*a ]).conductor() +- Fractional ideal (6*a) ++ Fractional ideal (-6*a) + + A not so well known curve with everywhere good reduction:: + +@@ -2139,7 +2140,7 @@ class EllipticCurve_number_field(EllipticCurve_field): + sage: E.gens(lim1=1, lim3=1) + [] + sage: E.rank(), E.gens() # long time (about 3 s) +- (1, [(-369/25*y^3 + 539/25*y^2 - 1178/25*y + 1718/25 : -27193/125*y^3 + 39683/125*y^2 - 86816/125*y + 126696/125 : 1)]) ++ (1, [(9/25*y^2 + 26/25 : -229/125*y^3 - 67/25*y^2 - 731/125*y - 213/25 : 1)]) + + Here is a curve of rank 2, yet the list contains many points:: + +@@ -2315,10 +2316,10 @@ class EllipticCurve_number_field(EllipticCurve_field): + sage: K. = QuadraticField(-1) + sage: E1 = EllipticCurve([i + 1, 0, 1, -240*i - 400, -2869*i - 2627]) + sage: E1.conductor() +- Fractional ideal (4*i + 7) ++ Fractional ideal (-4*i - 7) + sage: E2 = EllipticCurve([1+i,0,1,0,0]) + sage: E2.conductor() +- Fractional ideal (4*i + 7) ++ Fractional ideal (-4*i - 7) + sage: E1.is_isogenous(E2) # long time (2s on sage.math, 2014) + Traceback (most recent call last): + ... +diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py +index 78b99fa..33fc802 100644 +--- a/src/sage/schemes/elliptic_curves/ell_point.py ++++ b/src/sage/schemes/elliptic_curves/ell_point.py +@@ -2266,7 +2266,7 @@ class EllipticCurvePoint_number_field(EllipticCurvePoint_field): + sage: E.discriminant().support() + [Fractional ideal (i + 1), + Fractional ideal (-i - 2), +- Fractional ideal (i - 2), ++ Fractional ideal (2*i + 1), + Fractional ideal (3)] + sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()] + [1, 4, 4, 4] +@@ -2651,7 +2651,7 @@ class EllipticCurvePoint_number_field(EllipticCurvePoint_field): + Emin = E.minimal_model() + iso = E.isomorphism_to(Emin) + P = iso(self) +- h = Emin.pari_curve(prec=precision).ellheight(P, precision=precision) ++ h = Emin.pari_curve().ellheight(P, precision=precision) + height = rings.RealField(precision)(h) + else: + height = (self.non_archimedean_local_height(prec=precision) +@@ -3192,7 +3192,7 @@ class EllipticCurvePoint_number_field(EllipticCurvePoint_field): + E_work = EllipticCurve(ai) # defined over RR + pt_pari = pari([emb(x), emb(y)]) + working_prec = precision +- E_pari = E_work.pari_curve(prec=working_prec) ++ E_pari = E_work.pari_curve() + log_pari = E_pari.ellpointtoz(pt_pari, precision=working_prec) + + while prec_words_to_bits(log_pari.precision()) < precision: +@@ -3206,7 +3206,7 @@ class EllipticCurvePoint_number_field(EllipticCurvePoint_field): + ai = [emb(a) for a in E.a_invariants()] + E_work = EllipticCurve(ai) # defined over RR + pt_pari = pari([emb(x), emb(y)]) +- E_pari = E_work.pari_curve(prec=working_prec) ++ E_pari = E_work.pari_curve() + log_pari = E_pari.ellpointtoz(pt_pari, precision=working_prec) + + # normalization step +diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py +index c831c7f..913d408 100644 +--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py ++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py +@@ -592,17 +592,9 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + + INPUT: + ++ - ``prec`` -- Deprecated + +- - ``prec`` - The precision of quantities calculated for the +- returned curve, in bits. If None, defaults to factor +- multiplied by the precision of the largest cached curve (or +- a small default precision depending on the curve if none yet +- computed). +- +- - ``factor`` - The factor by which to increase the +- precision over the maximum previously computed precision. Only used +- if prec (which gives an explicit precision) is None. +- ++ - ``factor`` -- Deprecated + + EXAMPLES:: + +@@ -618,84 +610,57 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + :: + + sage: E = EllipticCurve(RationalField(), ['1/3', '2/3']) +- sage: e = E.pari_curve(prec=100) +- sage: 100 in E._pari_curve +- True +- sage: e.type() +- 't_VEC' ++ sage: e = E.pari_curve() + sage: e[:5] + [0, 0, 0, 1/3, 2/3] + +- This shows that the bug uncovered by trac:`3954` is fixed:: +- +- sage: 100 in E._pari_curve +- True +- +- :: ++ When doing certain computations, PARI caches the results:: + + sage: E = EllipticCurve('37a1') + sage: Epari = E.pari_curve() +- sage: Epari[14].python().prec() +- 64 +- sage: [a.precision() for a in Epari] +- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4] # 32-bit +- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3] # 64-bit +- sage: Epari = E.pari_curve(factor=2) +- sage: Epari[14].python().prec() +- 128 ++ sage: Epari ++ [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [0, 0, 0, 0, 0, 0, 0, 0]] ++ sage: Epari.omega() ++ [2.99345864623196, -2.45138938198679*I] ++ sage: Epari ++ [0, 0, 1, -1, 0, 0, -2, 1, -1, 48, -216, 37, 110592/37, Vecsmall([1]), [Vecsmall([64, 1])], [[2.99345864623196, -2.45138938198679*I], 0, [0.837565435283323, 0.269594436405445, -1.10715987168877]~, 0, 0, 0, 0, 0]] + +- This shows that the bug uncovered by trac`4715` is fixed:: ++ This shows that the bug uncovered by :trac:`4715` is fixed:: + + sage: Ep = EllipticCurve('903b3').pari_curve() + +- When the curve coefficients are large, a larger precision is +- required (see :trac:`13163`):: ++ This still works, even When the curve coefficients are large ++ (see :trac:`13163`):: + + sage: E = EllipticCurve([4382696457564794691603442338788106497, 28, 3992, 16777216, 298]) +- sage: E.pari_curve(prec=64) +- Traceback (most recent call last): +- ... +- PariError: precision too low in ellinit +- sage: E.pari_curve() # automatically choose the right precision ++ sage: E.pari_curve() + [4382696457564794691603442338788106497, 28, 3992, 16777216, 298, ...] + sage: E.minimal_model() + Elliptic Curve defined by y^2 + x*y + y = x^3 + x^2 - 7686423934083797390675981169229171907674183588326184511391146727143672423167091484392497987721106542488224058921302964259990799229848935835464702*x + 8202280443553761483773108648734271851215988504820214784899752662100459663011709992446860978259617135893103951840830254045837355547141096270521198994389833928471736723050112419004202643591202131091441454709193394358885 over Rational Field +- """ +- try: +- # if the PARI curve has already been computed to this +- # precision, returned the cached copy +- return self._pari_curve[prec] +- except AttributeError: +- self._pari_curve = {} +- except KeyError: +- pass + +- # Double the precision if needed? +- retry_prec = False ++ The arguments ``prec`` and ``factor`` are deprecated:: + +- if prec is None: +- if len(self._pari_curve) == 0: +- # No curves computed yet +- prec = 64 +- retry_prec = True +- else: +- # Take largest cached precision +- prec = max(self._pari_curve.keys()) +- if factor == 1: +- return self._pari_curve[prec] +- prec = int(prec * factor) ++ sage: E.pari_curve(prec=128) ++ doctest:...: DeprecationWarning: The prec argument to pari_curve() is deprecated and no longer used ++ See http://trac.sagemath.org/15767 for details. ++ [4382696457564794691603442338788106497, 28, 3992, 16777216, 298, ...] ++ sage: E.pari_curve(factor=2) ++ doctest:...: DeprecationWarning: The factor argument to pari_curve() is deprecated and no longer used ++ See http://trac.sagemath.org/15767 for details. ++ [4382696457564794691603442338788106497, 28, 3992, 16777216, 298, ...] ++ """ ++ if prec is not None: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The prec argument to pari_curve() is deprecated and no longer used') ++ if factor != 1: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The factor argument to pari_curve() is deprecated and no longer used') + +- pari_invariants = pari(self.a_invariants()) +- while True: +- try: +- self._pari_curve[prec] = pari_invariants.ellinit(precision=prec) +- return self._pari_curve[prec] +- except PariError as e: +- if retry_prec and 'precision too low' in str(e): +- # Retry with double precision +- prec *= 2 +- else: +- raise ++ try: ++ return self._pari_curve ++ except AttributeError: ++ self._pari_curve = pari(self.a_invariants()).ellinit() ++ return self._pari_curve + + def pari_mincurve(self, prec=None, factor=1): + """ +@@ -704,16 +669,9 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + + INPUT: + ++ - ``prec`` -- Deprecated + +- - ``prec`` - The precision of quantities calculated for the +- returned curve, in bits. If None, defaults to factor +- multiplied by the precision of the largest cached curve (or +- the default real precision if none yet computed). +- +- - ``factor`` - The factor by which to increase the +- precision over the maximum previously computed precision. Only used +- if prec (which gives an explicit precision) is None. +- ++ - ``factor`` -- Deprecated + + EXAMPLES:: + +@@ -724,29 +682,21 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + sage: E.conductor() + 47232 + sage: e.ellglobalred() +- [47232, [1, 0, 0, 0], 2] ++ [47232, [1, 0, 0, 0], 2, [2, 7; 3, 2; 41, 1], [[7, 2, 0, 1], [2, -3, 0, 2], [1, 5, 0, 1]]] + """ ++ if prec is not None: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The prec argument to pari_mincurve() is deprecated and no longer used') ++ if factor != 1: ++ from sage.misc.superseded import deprecation ++ deprecation(15767, 'The factor argument to pari_mincurve() is deprecated and no longer used') ++ + try: +- # if the PARI curve has already been computed to this +- # precision, returned the cached copy +- return self._pari_mincurve[prec] ++ return self._pari_mincurve + except AttributeError: +- # no PARI curves have been computed for this elliptic curve +- self._pari_mincurve = {} +- except KeyError: +- # PARI curves are cached for this elliptic curve, but they +- # are not of the requested precision (or prec = None) +- if prec is None: +- L = sorted(self._pari_mincurve.keys()) +- if factor == 1: +- return self._pari_mincurve[L[-1]] +- else: +- prec = int(factor * L[-1]) +- e = self.pari_curve(prec) +- mc, change = e.ellminimalmodel() +- self._pari_mincurve[prec] = mc +- # self.__min_transform = change +- return mc ++ mc, change = self.pari_curve().ellminimalmodel() ++ self._pari_mincurve = mc ++ return self._pari_mincurve + + def database_curve(self): + """ +@@ -3705,12 +3655,12 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + Torsion Subgroup isomorphic to Z/2 + Z/8 associated to the Elliptic + Curve defined by y^2 = x^3 - 1386747*x + 368636886 over + Rational Field +- sage: G.0 ++ sage: G.0*3 + G.1 + (1227 : 22680 : 1) + sage: G.1 + (282 : 0 : 1) + sage: list(G) +- [(0 : 1 : 0), (1227 : 22680 : 1), (2307 : -97200 : 1), (8787 : 816480 : 1), (1011 : 0 : 1), (8787 : -816480 : 1), (2307 : 97200 : 1), (1227 : -22680 : 1), (282 : 0 : 1), (-933 : 29160 : 1), (-285 : -27216 : 1), (147 : 12960 : 1), (-1293 : 0 : 1), (147 : -12960 : 1), (-285 : 27216 : 1), (-933 : -29160 : 1)] ++ [(0 : 1 : 0), (147 : 12960 : 1), (2307 : 97200 : 1), (-933 : 29160 : 1), (1011 : 0 : 1), (-933 : -29160 : 1), (2307 : -97200 : 1), (147 : -12960 : 1), (282 : 0 : 1), (8787 : 816480 : 1), (-285 : 27216 : 1), (1227 : 22680 : 1), (-1293 : 0 : 1), (1227 : -22680 : 1), (-285 : -27216 : 1), (8787 : -816480 : 1)] + """ + try: + return self.__torsion_subgroup +@@ -3745,10 +3695,10 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + sage: EllipticCurve('37b').torsion_points() + [(0 : 1 : 0), (8 : -19 : 1), (8 : 18 : 1)] + +- :: ++ Some curves with large torsion groups:: + +- sage: E=EllipticCurve([-1386747,368636886]) +- sage: T=E.torsion_subgroup(); T ++ sage: E = EllipticCurve([-1386747,368636886]) ++ sage: T = E.torsion_subgroup(); T + Torsion Subgroup isomorphic to Z/2 + Z/8 associated to the Elliptic Curve defined by y^2 = x^3 - 1386747*x + 368636886 over Rational Field + sage: T == E.torsion_subgroup(algorithm="doud") + True +@@ -3756,33 +3706,54 @@ class EllipticCurve_rational_field(EllipticCurve_number_field): + True + sage: E.torsion_points() + [(-1293 : 0 : 1), +- (-933 : -29160 : 1), +- (-933 : 29160 : 1), +- (-285 : -27216 : 1), +- (-285 : 27216 : 1), +- (0 : 1 : 0), +- (147 : -12960 : 1), +- (147 : 12960 : 1), +- (282 : 0 : 1), +- (1011 : 0 : 1), +- (1227 : -22680 : 1), +- (1227 : 22680 : 1), +- (2307 : -97200 : 1), +- (2307 : 97200 : 1), +- (8787 : -816480 : 1), +- (8787 : 816480 : 1)] ++ (-933 : -29160 : 1), ++ (-933 : 29160 : 1), ++ (-285 : -27216 : 1), ++ (-285 : 27216 : 1), ++ (0 : 1 : 0), ++ (147 : -12960 : 1), ++ (147 : 12960 : 1), ++ (282 : 0 : 1), ++ (1011 : 0 : 1), ++ (1227 : -22680 : 1), ++ (1227 : 22680 : 1), ++ (2307 : -97200 : 1), ++ (2307 : 97200 : 1), ++ (8787 : -816480 : 1), ++ (8787 : 816480 : 1)] ++ sage: EllipticCurve('210b5').torsion_points() ++ [(-41/4 : 37/8 : 1), ++ (-5 : -103 : 1), ++ (-5 : 107 : 1), ++ (0 : 1 : 0), ++ (10 : -208 : 1), ++ (10 : 197 : 1), ++ (37 : -397 : 1), ++ (37 : 359 : 1), ++ (100 : -1153 : 1), ++ (100 : 1052 : 1), ++ (415 : -8713 : 1), ++ (415 : 8297 : 1)] ++ sage: EllipticCurve('210e2').torsion_points() ++ [(-36 : 18 : 1), ++ (-26 : -122 : 1), ++ (-26 : 148 : 1), ++ (-8 : -122 : 1), ++ (-8 : 130 : 1), ++ (0 : 1 : 0), ++ (4 : -62 : 1), ++ (4 : 58 : 1), ++ (31/4 : -31/8 : 1), ++ (28 : -14 : 1), ++ (34 : -122 : 1), ++ (34 : 88 : 1), ++ (64 : -482 : 1), ++ (64 : 418 : 1), ++ (244 : -3902 : 1), ++ (244 : 3658 : 1)] + """ + return sorted(self.torsion_subgroup(algorithm).points()) + +- ## def newform_eval(self, z, prec): +-## """ +-## The value of the newform attached to this elliptic curve at +-## the point z in the complex upper half plane, computed using +-## prec terms of the power series expansion. Note that the power +-## series need not converge well near the real axis. +-## """ +-## raise NotImplementedError +- + @cached_method + def root_number(self, p=None): + """ +diff --git a/src/sage/schemes/elliptic_curves/ell_torsion.py b/src/sage/schemes/elliptic_curves/ell_torsion.py +index 050b7fa..6cac604 100644 +--- a/src/sage/schemes/elliptic_curves/ell_torsion.py ++++ b/src/sage/schemes/elliptic_curves/ell_torsion.py +@@ -44,7 +44,7 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): + sage: G.order() + 4 + sage: G.gen(0) +- (2 : 0 : 1) ++ (-2 : 0 : 1) + sage: G.gen(1) + (0 : 0 : 1) + sage: G.ngens() +@@ -81,7 +81,7 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): + sage: E = EllipticCurve([0,0,0,-49,0]) + sage: T = E.torsion_subgroup() + sage: [E(t) for t in T] +- [(0 : 1 : 0), (7 : 0 : 1), (0 : 0 : 1), (-7 : 0 : 1)] ++ [(0 : 1 : 0), (-7 : 0 : 1), (0 : 0 : 1), (7 : 0 : 1)] + + An example where the torsion subgroup is trivial:: + +@@ -166,23 +166,15 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): + if self.__K is RationalField() and algorithm in pari_torsion_algorithms: + flag = pari_torsion_algorithms.index(algorithm) + +- G = None +- loop = 0 +- while G is None and loop < 3: +- loop += 1 +- try: +- G = self.__E.pari_curve(prec = 400).elltors(flag) # pari_curve will return the curve of maximum known precision +- except RuntimeError: +- self.__E.pari_curve(factor = 2) # caches a curve of twice the precision +- if G is not None: +- order = G[0].python() +- structure = G[1].python() +- gens = G[2].python() +- +- self.__torsion_gens = [ self.__E(P) for P in gens ] +- from sage.groups.additive_abelian.additive_abelian_group import cover_and_relations_from_invariants +- groups.AdditiveAbelianGroupWrapper.__init__(self, self.__E(0).parent(), self.__torsion_gens, structure) +- return ++ G = self.__E.pari_curve().elltors(flag) ++ order = G[0].python() ++ structure = G[1].python() ++ gens = G[2].python() ++ ++ self.__torsion_gens = [ self.__E(P) for P in gens ] ++ from sage.groups.additive_abelian.additive_abelian_group import cover_and_relations_from_invariants ++ groups.AdditiveAbelianGroupWrapper.__init__(self, self.__E(0).parent(), self.__torsion_gens, structure) ++ return + + T1 = E(0) # these will be the two generators + T2 = E(0) +diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py +index d1a114d..5af7988 100644 +--- a/src/sage/schemes/elliptic_curves/heegner.py ++++ b/src/sage/schemes/elliptic_curves/heegner.py +@@ -22,7 +22,7 @@ EXAMPLES:: + 1 + sage: K. = QuadraticField(-8) + sage: K.factor(3) +- (Fractional ideal (1/2*a + 1)) * (Fractional ideal (1/2*a - 1)) ++ (Fractional ideal (1/2*a + 1)) * (Fractional ideal (-1/2*a + 1)) + + Next try an inert prime:: + +diff --git a/src/sage/schemes/elliptic_curves/lseries_ell.py b/src/sage/schemes/elliptic_curves/lseries_ell.py +index 1f4905d..02b1358 100644 +--- a/src/sage/schemes/elliptic_curves/lseries_ell.py ++++ b/src/sage/schemes/elliptic_curves/lseries_ell.py +@@ -67,8 +67,8 @@ class Lseries_ell(SageObject): + sage: E = EllipticCurve('389a') + sage: L = E.lseries() + sage: L.taylor_series(series_prec=3) +- -1.28158145675273e-23 + (7.26268290541182e-24)*z + 0.759316500288427*z^2 + O(z^3) # 32-bit +- -2.69129566562797e-23 + (1.52514901968783e-23)*z + 0.759316500288427*z^2 + O(z^3) # 64-bit ++ -1.27685190980159e-23 + (7.23588070754027e-24)*z + 0.759316500288427*z^2 + O(z^3) # 32-bit ++ -2.72911738151096e-23 + (1.54658247036311e-23)*z + 0.759316500288427*z^2 + O(z^3) # 64-bit + sage: L.taylor_series(series_prec=3)[2:] + 0.000000000000000 + 0.000000000000000*z + 0.759316500288427*z^2 + O(z^3) + """ +@@ -602,7 +602,7 @@ class Lseries_ell(SageObject): + sage: E.lseries().deriv_at1() + (-0.00010911444, 0.142428) + sage: E.lseries().deriv_at1(4000) +- (6.9902290...e-50, 1.31318e-43) ++ (6.990...e-50, 1.31318e-43) + """ + sqrtN = sqrt(self.__E.conductor()) + if k: +diff --git a/src/sage/schemes/elliptic_curves/modular_parametrization.py b/src/sage/schemes/elliptic_curves/modular_parametrization.py +index 91833f8..a5ea060 100644 +--- a/src/sage/schemes/elliptic_curves/modular_parametrization.py ++++ b/src/sage/schemes/elliptic_curves/modular_parametrization.py +@@ -245,9 +245,9 @@ class ModularParameterization: + + EXAMPLES:: + +- sage: E=EllipticCurve('389a1') ++ sage: E = EllipticCurve('389a1') + sage: phi = E.modular_parametrization() +- sage: X,Y = phi.power_series(prec = 10) ++ sage: X,Y = phi.power_series(prec=10) + sage: X + q^-2 + 2*q^-1 + 4 + 7*q + 13*q^2 + 18*q^3 + 31*q^4 + 49*q^5 + 74*q^6 + 111*q^7 + O(q^8) + sage: Y +@@ -264,21 +264,16 @@ class ModularParameterization: + sage: E.defining_polynomial()(X,Y,1) + O(q^11) == 0 + True + +- Note that below we have to change variable from x to q:: ++ Note that below we have to change variable from `x` to `q`:: + +- sage: a1,_,a3,_,_=E.a_invariants() +- sage: f=E.q_expansion(17) +- sage: q=f.parent().gen() ++ sage: a1,_,a3,_,_ = E.a_invariants() ++ sage: f = E.q_expansion(17) ++ sage: q = f.parent().gen() + sage: f/q == (X.derivative()/(2*Y+a1*X+a3)) + True + """ + R = LaurentSeriesRing(RationalField(),'q') + if not self._E.is_minimal(): +- raise NotImplementedError("Only implemented for minimal curves.") +- from sage.libs.all import pari +- old_prec = pari.get_series_precision() +- pari.set_series_precision(prec-1) +- XY = self._E.pari_mincurve().elltaniyama() +- pari.set_series_precision(old_prec) ++ raise NotImplementedError("only implemented for minimal curves") ++ XY = self._E.pari_mincurve().elltaniyama(prec-1) + return R(XY[0]),R(XY[1]) +- +diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py +index 227b32f..ef66865 100644 +--- a/src/sage/schemes/elliptic_curves/period_lattice.py ++++ b/src/sage/schemes/elliptic_curves/period_lattice.py +@@ -530,12 +530,12 @@ class PeriodLattice_ell(PeriodLattice): + + if algorithm=='pari': + if self.E.base_field() is QQ: +- periods = self.E.pari_curve(prec).omega().python() ++ periods = self.E.pari_curve().omega(prec).python() + return (R(periods[0]), C(periods[1])) + + from sage.libs.pari.all import pari +- E_pari = pari([R(self.embedding(ai).real()) for ai in self.E.a_invariants()]).ellinit(precision=prec) +- periods = E_pari.omega().python() ++ E_pari = pari([R(self.embedding(ai).real()) for ai in self.E.a_invariants()]).ellinit() ++ periods = E_pari.omega(prec).python() + return (R(periods[0]), C(periods[1])) + + if algorithm!='sage': +@@ -937,9 +937,9 @@ class PeriodLattice_ell(PeriodLattice): + if prec is None: + prec = RealField().precision() + try: +- return self.E.pari_curve(prec).ellsigma(z, flag) ++ return self.E.pari_curve().ellsigma(z, flag, precision=prec) + except AttributeError: +- raise NotImplementedError("sigma function not yet implemented for period lattices of curves not defined over Q.") ++ raise NotImplementedError("sigma function not yet implemented for period lattices of curves not defined over Q") + + def curve(self): + r""" +diff --git a/src/sage/schemes/plane_conics/con_number_field.py b/src/sage/schemes/plane_conics/con_number_field.py +index 4ae48d8..b241d81 100644 +--- a/src/sage/schemes/plane_conics/con_number_field.py ++++ b/src/sage/schemes/plane_conics/con_number_field.py +@@ -124,7 +124,7 @@ class ProjectiveConic_number_field(ProjectiveConic_field): + sage: C.has_rational_point(algorithm = 'local', read_cache = False) + True + +- Examples over number fields :: ++ Examples over number fields:: + + sage: K. = QuadraticField(-1) + sage: C = Conic(K, [1, 3, -5]) +diff --git a/src/sage/symbolic/constants.py b/src/sage/symbolic/constants.py +index 6f76834..a91c008 100644 +--- a/src/sage/symbolic/constants.py ++++ b/src/sage/symbolic/constants.py +@@ -851,7 +851,7 @@ class Log2(Constant): + .6931471805599453 + sage: gp(log2) + 0.6931471805599453094172321215 # 32-bit +- 0.69314718055994530941723212145817656808 # 64-bit ++ 0.69314718055994530941723212145817656807 # 64-bit + sage: RealField(150)(2).log() + 0.69314718055994530941723212145817656807550013 + """ +diff --git a/src/sage/symbolic/integration/integral.py b/src/sage/symbolic/integration/integral.py +index d092529..901acf0 100644 +--- a/src/sage/symbolic/integration/integral.py ++++ b/src/sage/symbolic/integration/integral.py +@@ -677,7 +677,7 @@ def integrate(expression, v=None, a=None, b=None, algorithm=None): + Check that :trac:`11737` is fixed:: + + sage: N(integrate(sin(x^2)/(x^2), x, 1, infinity)) +- 0.285736646322858 ++ 0.285736646322853 + + """ + expression, v, a, b = _normalize_integral_input(expression, v, a, b) +diff --git a/src/sage/tests/parigp.py b/src/sage/tests/parigp.py +index e58d427..6077db3 100644 +--- a/src/sage/tests/parigp.py ++++ b/src/sage/tests/parigp.py +@@ -6,7 +6,7 @@ Check that :trac:`9876` has been fixed, this test comes from PARI's + self-test "rnfkummer":: + + sage: pari('setrand(1); lift(rnfkummer(bnrinit(bnfinit(y^4-52*y^2+26,1),3,1),Mat(5)))') # long time (4s on sage.math, 2011) +- x^5 + (-12490585381661544359255403301035053110061910*y^3 + 8875378520404561472503422910872004290197460*y^2 + 643203912732761873050292808675549433737179610*y - 457038484130159980782436350930533714409061170)*x^3 + (-134027514281645340620300162483056350640850689292892267066826165512*y^3 + 95235243030030469814112992330493778292557062830362488860799262053*y^2 + 6901759924725033375901003506523314713919218011682438894990413482822*y - 4904148131739972327284545793455166015180538153351582525198684659988)*x^2 + (-47397957557570888155708856849994683849365520972511563824369572802678417823703951003630*y^3 + 33679323468496441220407209890566679520252152888549909181980050360738580514765560899830*y^2 + 2440762448949326006691055037485233408803108189791110990339027554592708168372793653934980*y - 1734320048033240933678067521047553381449799255523887315704756124974424249211251806055445)*x + (88847913213212543643724914281374137431466584547137800780754135469698376356168903046151157223082894732483818/5*y^3 - 63132205749445286461822170095386361952302057584137825393349862937480952856334509099209369622841067534904427/5*y^2 - 4575231959624371057665356018310756876851369587901000773265750996233180145132238920504044583057371848969400608/5*y + 3250999094748458040342075570309205473235256099747294466325048378505864671503910959921397017511503388596960342/5) ++ x^5 + (677308732982301944730030845266716201702837696162187325328/5*y^3 + 481271319660811460139352501916644558975058261230836596652/5*y^2 - 34878079733048511269299413306183851642254427026365686673888/5*y - 24783137893632185532697291886880720222932490781434136563942/5)*x^3 + (3121825424585613564828729670704559492032765858876683224121119983801219547643890505070*y^3 + 2218259473949490736667831079912338956828105689590705243343986337391928943383709808005*y^2 - 160758704836112475349193472119432636971334139776148581364333958289434482806877560648970*y - 114229487928172801039731551289054638597376141715926648946031483976252167029243247022480)*x^2 + (-166692999053535356002572927874917139211874871730209960830468398970597547702137238176414705764356470658863661934844/5*y^3 - 118446188915971905087412803032726595730394344242831753676734791550346393669679117451359918013807557809143042588696/5*y^2 + 8583872250159852857479162156889677342550132950704205078118190632176525884150800135006242479797595396229858998666474/5*y + 6099398054781102460046012340322433264871600802691098946100231203424708988718659688581036467351459717869466864403491/5)*x + (-3761942859516698460017771578887550299728643548425212623644925442305118051299870709569967640457662697840860989973276516003636843449764721490044/5*y^3 - 2673104432455463952284352656647109245231103663592899118247897745294025980581570350460813923435311458682114748384710825808171997155877533243621/5*y^2 + 193721614595917576607166927238849546114076202473503220710707213556396586084964322202670927424345172110316287310450443586757567876756951302594424/5*y + 137651773558650909762864388498297831958827163349141150095186154867116600261791580542516653158613689676015829782898702530873665348851222173825666/5) + + Check that :trac:`10195` (PARI bug 1153) has been fixed:: + +@@ -48,7 +48,7 @@ Check that the optional PARI databases work:: + [x^212 + (-y^7 + 5207*y^6 - 10241606*y^5 + 9430560101*y^4 - 4074860204015*y^3 + 718868274900397*y^2 - 34897101275826114*y + 104096378056356968)*x^211... + + The following requires the modular polynomials up to degree 223, while +-only those up to degree 199 come standard in Sage: ++only those up to degree 199 come standard in Sage:: + + sage: p = next_prime(2^328) + sage: E = EllipticCurve(GF(p), [6,1]) +@@ -56,7 +56,7 @@ only those up to degree 199 come standard in Sage: + 546812681195752981093125556779405341338292357723293496548601032930284335897180749997402596957976244 + + Create a number field with Galois group `A4`. Group `A4` corresponds to +-transitive group `(12,3)` in GAP. ++transitive group `(12,3)` in GAP:: + + sage: R. = PolynomialRing(ZZ) + sage: pol = pari("galoisgetpol(12,3)[1]") # optional -- database_pari +-- +cgit v0.9.2 diff --git a/sagemath-png.patch b/sagemath-png.patch index 7ece22f..4ea39c1 100644 --- a/sagemath-png.patch +++ b/sagemath-png.patch @@ -1,7 +1,6 @@ -diff -up src/module_list.py.orig src/module_list.py ---- src/module_list.py.orig 2014-02-07 11:50:03.665731821 -0200 -+++ src/module_list.py 2014-02-07 11:50:13.454732196 -0200 -@@ -1066,7 +1066,7 @@ ext_modules = [ +--- src/module_list.py.orig 2014-05-10 15:46:32.570195300 -0300 ++++ src/module_list.py 2014-05-10 15:46:44.964194411 -0300 +@@ -1058,7 +1058,7 @@ ext_modules = [ Extension('sage.matrix.matrix_mod2_dense', sources = ['sage/matrix/matrix_mod2_dense.pyx'], @@ -10,7 +9,7 @@ diff -up src/module_list.py.orig src/module_list.py extra_compile_args = m4ri_extra_compile_args, depends = [SAGE_INC + "/png.h", SAGE_INC + "/m4ri/m4ri.h"]), -@@ -1369,7 +1369,7 @@ ext_modules = [ +@@ -1354,7 +1354,7 @@ ext_modules = [ Extension('sage.modules.vector_mod2_dense', sources = ['sage/modules/vector_mod2_dense.pyx'], @@ -19,7 +18,7 @@ diff -up src/module_list.py.orig src/module_list.py extra_compile_args = m4ri_extra_compile_args, depends = [SAGE_INC + "/png.h", SAGE_INC + "/m4ri/m4ri.h"]), -@@ -1859,7 +1859,7 @@ ext_modules = [ +@@ -1860,7 +1860,7 @@ ext_modules = [ Extension('sage.rings.polynomial.pbori', sources = ['sage/rings/polynomial/pbori.pyx'], libraries=['polybori-' + polybori_major_version, diff --git a/sagemath-readonly.patch b/sagemath-readonly.patch index b47b7f8..df83765 100644 --- a/sagemath-readonly.patch +++ b/sagemath-readonly.patch @@ -1,7 +1,6 @@ -diff -up src/sage/all.py.orig src/sage/all.py ---- src/sage/all.py.orig 2014-02-07 12:43:35.244854804 -0200 -+++ src/sage/all.py 2014-02-07 12:44:11.798856204 -0200 -@@ -325,11 +325,11 @@ def _write_started_file(): +--- src/sage/all.py.orig 2014-05-10 15:45:46.934198573 -0300 ++++ src/sage/all.py 2014-05-10 15:45:58.395197751 -0300 +@@ -327,11 +327,11 @@ def _write_started_file(): Check that the file exists when Sage is running:: diff --git a/sagemath-rpmbuild.patch b/sagemath-rpmbuild.patch index 5a8354a..cceaf36 100644 --- a/sagemath-rpmbuild.patch +++ b/sagemath-rpmbuild.patch @@ -1,6 +1,5 @@ -diff -up src/module_list.py.orig src/module_list.py ---- src/module_list.py.orig 2014-02-07 11:31:05.355688232 -0200 -+++ src/module_list.py 2014-02-07 11:32:21.239691137 -0200 +--- src/module_list.py.orig 2014-05-10 15:38:39.635229222 -0300 ++++ src/module_list.py 2014-05-10 15:40:06.410222998 -0300 @@ -5,7 +5,7 @@ from distutils.core import setup from distutils.extension import Extension from sage.env import * @@ -36,15 +35,14 @@ diff -up src/module_list.py.orig src/module_list.py @@ -702,7 +703,7 @@ ext_modules = [ sources = ['sage/libs/lcalc/lcalc_Lfunction.pyx'], libraries = ['m', 'ntl', 'mpfr', 'gmp', 'gmpxx', - 'Lfunction', 'stdc++'], + 'Lfunction'], - include_dirs = [SAGE_INC + "/libLfunction"], + include_dirs = [SAGE_INC + "/Lfunction"], extra_compile_args=["-O3", "-ffast-math"], language = 'c++'), -diff -up src/setup.py.orig src/setup.py ---- src/setup.py.orig 2014-02-07 11:32:35.278691675 -0200 -+++ src/setup.py 2014-02-07 11:34:40.589696474 -0200 +--- src/setup.py.orig 2014-05-10 15:40:24.650221690 -0300 ++++ src/setup.py 2014-05-10 15:43:52.993206746 -0300 @@ -36,11 +36,11 @@ except KeyError: compile_result_dir = None keep_going = False @@ -59,17 +57,17 @@ diff -up src/setup.py.orig src/setup.py SAGE_SRC, os.path.join(SAGE_SRC, 'sage', 'ext')] -@@ -161,11 +161,11 @@ for m in ext_modules: +@@ -171,10 +171,12 @@ for m in ext_modules: + m.libraries = ['csage'] + m.libraries + if m.language == 'c++': + m.libraries.append('stdc++') ++ m.libraries.append('ntl') ++ m.libraries = m.libraries + ['gmp', 'm', 'dl'] - # FIMXE: Do NOT link the following libraries to each and - # every module (regardless of the language btw.): -- m.libraries = ['csage'] + m.libraries + ['stdc++', 'ntl'] -+ m.libraries = ['csage'] + m.libraries + ['stdc++', 'ntl', 'gmp', 'm', 'dl'] - - m.extra_compile_args += extra_compile_args - m.extra_link_args += extra_link_args -- m.library_dirs += ['%s/lib' % SAGE_LOCAL] + m.extra_compile_args = m.extra_compile_args + extra_compile_args + m.extra_link_args = m.extra_link_args + extra_link_args +- m.library_dirs = m.library_dirs + [os.path.join(SAGE_LOCAL, "lib")] + m.library_dirs += ['c_lib', '%s/lib' % SAGE_LOCAL] - + ############################################# diff --git a/sagemath-sagedoc.patch b/sagemath-sagedoc.patch index 549324a..cc1339e 100644 --- a/sagemath-sagedoc.patch +++ b/sagemath-sagedoc.patch @@ -1,6 +1,5 @@ -diff -up src/doc/common/builder.py.orig src/doc/common/builder.py ---- src/doc/common/builder.py.orig 2014-02-07 11:35:55.574699345 -0200 -+++ src/doc/common/builder.py 2014-02-07 11:35:58.192699445 -0200 +--- src/doc/common/builder.py.orig 2014-05-10 15:44:39.046203443 -0300 ++++ src/doc/common/builder.py 2014-05-10 15:45:03.225201708 -0300 @@ -32,7 +32,7 @@ from sage.env import SAGE_DOC, SAGE_SRC # SAGE_DOC, LANGUAGES, SPHINXOPTS, PAPER, OMIT, # PAPEROPTS, ALLSPHINXOPTS, NUM_THREADS, WEBSITESPHINXOPTS @@ -9,10 +8,9 @@ diff -up src/doc/common/builder.py.orig src/doc/common/builder.py +execfile(os.path.join(os.getenv('SAGE_ROOT'), 'src', 'doc', 'common' , 'build_options.py')) - ########################################## -diff -up src/doc/common/conf.py.orig src/doc/common/conf.py ---- src/doc/common/conf.py.orig 2014-02-07 11:35:55.584699345 -0200 -+++ src/doc/common/conf.py 2014-02-07 11:35:58.194699445 -0200 + def print_build_error(): +--- src/doc/common/conf.py.orig 2014-05-10 15:44:59.936201944 -0300 ++++ src/doc/common/conf.py 2014-05-10 15:45:03.229201708 -0300 @@ -1,5 +1,5 @@ import sys, os, sphinx -from sage.env import SAGE_DOC @@ -30,9 +28,8 @@ diff -up src/doc/common/conf.py.orig src/doc/common/conf.py mathjax_relative = os.path.join('sagenb','data','mathjax') # It would be really nice if sphinx would copy the entire mathjax directory, -diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py ---- src/sage/doctest/control.py.orig 2014-02-07 11:35:29.138698333 -0200 -+++ src/sage/doctest/control.py 2014-02-07 11:35:58.196699445 -0200 +--- src/sage/doctest/control.py.orig 2014-05-10 15:44:59.940201944 -0300 ++++ src/sage/doctest/control.py 2014-05-10 15:45:03.230201708 -0300 @@ -89,7 +89,6 @@ class DocTestDefaults(SageObject): self.valgrind = False self.massif = False @@ -77,9 +74,8 @@ diff -up src/sage/doctest/control.py.orig src/sage/doctest/control.py return 2 return self.run_val_gdb() else: -diff -up src/sage/interfaces/singular.py.orig src/sage/interfaces/singular.py ---- src/sage/interfaces/singular.py.orig 2014-02-07 11:35:55.605699346 -0200 -+++ src/sage/interfaces/singular.py 2014-02-07 11:35:58.198699446 -0200 +--- src/sage/interfaces/singular.py.orig 2014-05-10 15:44:59.940201944 -0300 ++++ src/sage/interfaces/singular.py 2014-05-10 15:45:03.230201708 -0300 @@ -2149,7 +2149,7 @@ def generate_docstring_dictionary(): nodes.clear() node_names.clear() @@ -89,9 +85,8 @@ diff -up src/sage/interfaces/singular.py.orig src/sage/interfaces/singular.py new_node = re.compile("File: singular\.hlp, Node: ([^,]*),.*") new_lookup = re.compile("\* ([^:]*):*([^.]*)\..*") -diff -up src/sage/misc/latex_macros.py.orig src/sage/misc/latex_macros.py ---- src/sage/misc/latex_macros.py.orig 2014-02-07 11:35:55.614699347 -0200 -+++ src/sage/misc/latex_macros.py 2014-02-07 11:35:58.199699446 -0200 +--- src/sage/misc/latex_macros.py.orig 2014-05-10 15:44:59.940201944 -0300 ++++ src/sage/misc/latex_macros.py 2014-05-10 15:45:03.232201708 -0300 @@ -142,7 +142,7 @@ def convert_latex_macro_to_mathjax(macro return name + ': ["' + defn + '",' + str(num_args) + ']' diff --git a/sagemath-scons.patch b/sagemath-scons.patch index 9eb0e83..6e254fa 100644 --- a/sagemath-scons.patch +++ b/sagemath-scons.patch @@ -1,6 +1,6 @@ diff -up src/c_lib/SConstruct.orig src/c_lib/SConstruct ---- src/c_lib/SConstruct.orig 2014-02-07 10:59:45.462616244 -0200 -+++ src/c_lib/SConstruct 2014-02-07 11:00:41.900618405 -0200 +--- src/c_lib/SConstruct.orig 2014-05-26 13:24:15.242761223 -0300 ++++ src/c_lib/SConstruct 2014-05-26 13:25:26.593763955 -0300 @@ -126,8 +126,8 @@ env['PYV']=platform.python_version().rsp # The SCons convenience function Split is the only strange thing # to python programmers. It just makes a list by splitting on @@ -14,7 +14,7 @@ diff -up src/c_lib/SConstruct.orig src/c_lib/SConstruct cppFiles = Split( "ZZ_pylong.cpp ntl_wrap.cpp" ) @@ -136,9 +136,22 @@ incFiles = Split( "ccobject.h convert.h Split( "interrupt.h memory.h mpn_pylong.h mpz_longlong.h" ) + \ - Split( "mpz_pylong.h ntl_wrap.h pb_wrap.h stdsage.h ZZ_pylong.h" ) + Split( "mpz_pylong.h ntl_wrap.h stdsage.h ZZ_pylong.h" ) +env.Append(CFLAGS='@@optflags@@') +env.Append(CXXFLAGS='@@optflags@@') diff --git a/sagemath-scripts.patch b/sagemath-scripts.patch index a35d336..9cc19a5 100644 --- a/sagemath-scripts.patch +++ b/sagemath-scripts.patch @@ -1,7 +1,7 @@ diff -up src/bin/sage.orig src/bin/sage ---- src/bin/sage.orig 2014-02-07 11:02:57.653623604 -0200 -+++ src/bin/sage 2014-02-07 11:08:54.765637279 -0200 -@@ -11,17 +11,14 @@ usage() { +--- src/bin/sage.orig 2014-05-26 13:29:30.741773304 -0300 ++++ src/bin/sage 2014-05-26 13:29:50.173774048 -0300 +@@ -13,17 +13,14 @@ usage() { echo " file. -- run given .sage, .py or .spyx files" echo " -advanced -- list all command line options" echo " -c -- Evaluates cmd as sage code" @@ -19,7 +19,7 @@ diff -up src/bin/sage.orig src/bin/sage echo " -python [...] -- run the Python interpreter" echo " -R [...] -- run Sage's R with given arguments" echo " -singular [...] -- run Sage's singular with given arguments" -@@ -37,10 +34,6 @@ usage() { +@@ -39,10 +36,6 @@ usage() { echo " --optional - controls which optional tests are run" echo " --sagenb - test all sagenb files" echo " --help - show all testing options" @@ -30,7 +30,7 @@ diff -up src/bin/sage.orig src/bin/sage echo " -v, -version -- print the Sage version" exit 0 } -@@ -64,14 +57,14 @@ usage_advanced() { +@@ -63,14 +56,14 @@ usage_advanced() { echo " -root -- print the Sage root directory" echo " -gthread, -qthread, -q4thread, -wthread, -pylab" echo " -- pass the option through to ipython" @@ -47,7 +47,7 @@ diff -up src/bin/sage.orig src/bin/sage echo " -inotebook [...] -- start the *insecure* Sage notebook" echo " -n, -notebook [...] -- start the Sage notebook (options are the same" echo " as for the notebook command in Sage)" -@@ -88,13 +81,9 @@ usage_advanced() { +@@ -87,13 +80,9 @@ usage_advanced() { echo " -gp [...] -- run Sage's PARI/GP calculator with given arguments" echo " -ipython [...] -- run Sage's IPython using the default environment (not" echo " Sage), passing additional options to IPython" @@ -61,7 +61,7 @@ diff -up src/bin/sage.orig src/bin/sage echo " -maxima [...] -- run Sage's Maxima with given arguments" echo " -mwrank [...] -- run Sage's mwrank with given arguments" echo " -python [...] -- run the Python interpreter" -@@ -108,80 +97,10 @@ usage_advanced() { +@@ -107,80 +96,10 @@ usage_advanced() { echo #### 1.......................26..................................................78 #### |.....................--.|...................................................| @@ -142,7 +142,7 @@ diff -up src/bin/sage.orig src/bin/sage echo " -search_src -- search through all the Sage library code for string" echo " -search_doc -- search through the Sage documentation for string" echo " -grep -- same as -search_src" -@@ -201,17 +120,6 @@ usage_advanced() { +@@ -200,17 +119,6 @@ usage_advanced() { echo #### 1.......................26..................................................78 #### |.....................--.|...................................................| @@ -160,7 +160,7 @@ diff -up src/bin/sage.orig src/bin/sage echo "Valgrind memory debugging:" echo " -cachegrind -- run Sage using Valgrind's cachegrind tool. The log" echo " files are named sage-cachegrind.PID can be found in" -@@ -225,9 +133,6 @@ usage_advanced() { +@@ -224,9 +132,6 @@ usage_advanced() { echo " -memcheck -- run Sage using Valgrind's memcheck tool. The log" echo " files are named sage-memcheck.PID can be found in" echo " $DOT_SAGE" @@ -170,7 +170,7 @@ diff -up src/bin/sage.orig src/bin/sage echo " -valgrind -- this is an alias for -memcheck" echo echo "You can also use -- before a long option, e.g., 'sage --optional'." -@@ -256,17 +161,6 @@ if [ "$1" = '-upgrade' -o "$1" = "--upgr +@@ -255,17 +160,6 @@ if [ "$1" = '-upgrade' -o "$1" = "--upgr fi @@ -188,7 +188,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ $# -gt 0 ]; then if [ "$1" = '-h' -o "$1" = '-?' -o "$1" = '-help' -o "$1" = '--help' ]; then usage -@@ -279,25 +173,11 @@ fi +@@ -278,25 +172,11 @@ fi # Prepare for running Sage, either interactively or non-interactively. sage_setup() { @@ -214,7 +214,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ ! -d "$IPYTHONDIR" ]; then # make sure that $DOT_SAGE exists so that ipython will happily # create its config directories there. If DOT_SAGE doesn't -@@ -308,20 +188,6 @@ sage_setup() { +@@ -307,20 +187,6 @@ sage_setup() { } @@ -235,7 +235,7 @@ diff -up src/bin/sage.orig src/bin/sage # Start an interactive Sage session, this function never returns. interactive_sage() { sage_setup -@@ -371,11 +237,6 @@ if [ "$1" = '-axiom' -o "$1" = '--axiom' +@@ -370,11 +236,6 @@ if [ "$1" = '-axiom' -o "$1" = '--axiom' exec axiom "$@" fi @@ -247,7 +247,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ "$1" = '-gap' -o "$1" = '--gap' ]; then shift exec gap "$@" -@@ -388,7 +249,7 @@ fi +@@ -387,7 +248,7 @@ fi if [ "$1" = '-singular' -o "$1" = '--singular' ]; then shift @@ -256,7 +256,7 @@ diff -up src/bin/sage.orig src/bin/sage fi if [ "$1" = '-sqlite3' -o "$1" = '--sqlite3' ]; then -@@ -416,16 +277,6 @@ if [ "$1" = '-lisp' -o "$1" = '--lisp' ] +@@ -415,16 +276,6 @@ if [ "$1" = '-lisp' -o "$1" = '--lisp' ] exec ecl "$@" fi @@ -273,7 +273,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ "$1" = '-maxima' -o "$1" = '--maxima' ]; then shift exec maxima "$@" -@@ -585,20 +436,6 @@ EOF +@@ -584,20 +435,6 @@ EOF fi ##################################################################### @@ -294,7 +294,7 @@ diff -up src/bin/sage.orig src/bin/sage # File conversion ##################################################################### -@@ -613,36 +450,15 @@ if [ "$1" = '-rst2sws' -o "$1" = '--rst2 +@@ -612,36 +449,15 @@ if [ "$1" = '-rst2sws' -o "$1" = '--rst2 fi ##################################################################### @@ -331,7 +331,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ "$1" = "-inotebook" -o "$1" = '--inotebook' ]; then shift sage-cleaner &>/dev/null & -@@ -661,58 +477,12 @@ if [ "$1" = '-grepdoc' -o "$1" = "--grep +@@ -660,58 +476,12 @@ if [ "$1" = '-grepdoc' -o "$1" = "--grep exit 0 fi @@ -391,7 +391,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ ! -f "$DOT_SAGE"/init.sage ]; then echo >&2 "init.sage does not exist ... creating" touch "$DOT_SAGE"/init.sage -@@ -728,10 +498,7 @@ if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" +@@ -727,10 +497,7 @@ if [ "$1" = '-t' -o "$1" = '-bt' -o "$1" fi fi @@ -403,7 +403,7 @@ diff -up src/bin/sage.orig src/bin/sage shift SAGE_BANNER="no" sage_setup -@@ -745,12 +512,6 @@ if [ "$1" = '-testall' -o "$1" = "--test +@@ -744,12 +511,6 @@ if [ "$1" = '-testall' -o "$1" = "--test exec sage-runtests -a "$@" fi @@ -416,7 +416,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ "$1" = '-c' ]; then shift SAGE_BANNER="no" -@@ -759,124 +520,6 @@ if [ "$1" = '-c' ]; then +@@ -758,124 +519,6 @@ if [ "$1" = '-c' ]; then exec sage-eval "$@" fi @@ -541,7 +541,7 @@ diff -up src/bin/sage.orig src/bin/sage if [ "$1" = '-gdb' -o "$1" = "--gdb" ]; then shift sage_setup -@@ -925,12 +568,6 @@ if [ "$1" = '-callgrind' -o "$1" = "--ca +@@ -924,12 +567,6 @@ if [ "$1" = '-callgrind' -o "$1" = "--ca exec sage-callgrind "$@" fi @@ -555,8 +555,8 @@ diff -up src/bin/sage.orig src/bin/sage exec sage-startuptime.py "$@" fi diff -up src/bin/sage-runtests.orig src/bin/sage-runtests ---- src/bin/sage-runtests.orig 2014-02-07 11:09:24.776638428 -0200 -+++ src/bin/sage-runtests 2014-02-07 11:09:41.780639079 -0200 +--- src/bin/sage-runtests.orig 2014-05-26 13:29:46.150773894 -0300 ++++ src/bin/sage-runtests 2014-05-26 13:29:50.174774048 -0300 @@ -54,10 +54,6 @@ if __name__ == "__main__": help="run doctests using Valgrind's cachegrind tool. The log " "files are named sage-cachegrind.PID and can be found in " + @@ -569,8 +569,8 @@ diff -up src/bin/sage-runtests.orig src/bin/sage-runtests parser.add_option("-f", "--failed", action="store_true", default=False, help="doctest only those files that failed in the previous run") diff -up src/bin/sage-valgrind.orig src/bin/sage-valgrind ---- src/bin/sage-valgrind.orig 2014-02-07 11:09:56.469639641 -0200 -+++ src/bin/sage-valgrind 2014-02-07 11:10:06.804640037 -0200 +--- src/bin/sage-valgrind.orig 2014-05-26 13:29:46.152773894 -0300 ++++ src/bin/sage-valgrind 2014-05-26 13:29:50.174774048 -0300 @@ -11,7 +11,7 @@ fi LOG="$DOT_SAGE"/valgrind/sage-memcheck.%p echo "Log file is $LOG" diff --git a/sagemath-sphinx.patch b/sagemath-sphinx.patch new file mode 100644 index 0000000..9ba1429 --- /dev/null +++ b/sagemath-sphinx.patch @@ -0,0 +1,139 @@ +diff -up src/sage/graphs/generic_graph.py.orig src/sage/graphs/generic_graph.py +--- src/sage/graphs/generic_graph.py.orig 2014-05-26 15:38:33.169069789 -0300 ++++ src/sage/graphs/generic_graph.py 2014-05-26 15:41:55.071077520 -0300 +@@ -9222,7 +9222,7 @@ class GenericGraph(GenericGraph_pyx): + + .. SEEALSO:: + +- - :meth:`subdivide_edge` -- subdivides one edge ++ - :meth:`subdivide_edge` -- subdivides one edge + """ + for e in edges: + self.subdivide_edge(e, k) +@@ -11504,10 +11504,10 @@ class GenericGraph(GenericGraph_pyx): + + .. SEEALSO:: + +- - :mod:`Interval Graph Recognition `. ++ - :mod:`Interval Graph Recognition `. + +- - :meth:`PQ ` +- -- Implementation of PQ-Trees. ++ - :meth:`PQ ` ++ -- Implementation of PQ-Trees. + + """ + self._scream_if_not_simple() +@@ -13369,13 +13369,13 @@ class GenericGraph(GenericGraph_pyx): + + .. SEEALSO:: + +- - :meth:`breadth_first_search ` +- -- breadth-first search for fast compiled graphs. ++ - :meth:`breadth_first_search ` ++ -- breadth-first search for fast compiled graphs. + +- - :meth:`depth_first_search ` +- -- depth-first search for fast compiled graphs. ++ - :meth:`depth_first_search ` ++ -- depth-first search for fast compiled graphs. + +- - :meth:`depth_first_search` -- depth-first search for generic graphs. ++ - :meth:`depth_first_search` -- depth-first search for generic graphs. + + EXAMPLES:: + +@@ -13494,13 +13494,13 @@ class GenericGraph(GenericGraph_pyx): + + .. SEEALSO:: + +- - :meth:`breadth_first_search` ++ - :meth:`breadth_first_search` + +- - :meth:`breadth_first_search ` +- -- breadth-first search for fast compiled graphs. ++ - :meth:`breadth_first_search ` ++ -- breadth-first search for fast compiled graphs. + +- - :meth:`depth_first_search ` +- -- depth-first search for fast compiled graphs. ++ - :meth:`depth_first_search ` ++ -- depth-first search for fast compiled graphs. + + EXAMPLES:: + +diff -up src/sage/graphs/graph.py.orig src/sage/graphs/graph.py +--- src/sage/graphs/graph.py.orig 2014-05-26 15:42:17.579078382 -0300 ++++ src/sage/graphs/graph.py 2014-05-26 16:04:45.519129999 -0300 +@@ -2704,9 +2704,9 @@ class Graph(GenericGraph): + + .. SEEALSO:: + +- - :meth:`~Graph.is_arc_transitive` +- - :meth:`~Graph.is_half_transitive` +- - :meth:`~Graph.is_semi_symmetric` ++ - :meth:`~Graph.is_arc_transitive` ++ - :meth:`~Graph.is_half_transitive` ++ - :meth:`~Graph.is_semi_symmetric` + + EXAMPLES:: + +@@ -2751,9 +2751,9 @@ class Graph(GenericGraph): + + .. SEEALSO:: + +- - :meth:`~Graph.is_edge_transitive` +- - :meth:`~Graph.is_half_transitive` +- - :meth:`~Graph.is_semi_symmetric` ++ - :meth:`~Graph.is_edge_transitive` ++ - :meth:`~Graph.is_half_transitive` ++ - :meth:`~Graph.is_semi_symmetric` + + EXAMPLES:: + +@@ -2788,9 +2788,9 @@ class Graph(GenericGraph): + + .. SEEALSO:: + +- - :meth:`~Graph.is_edge_transitive` +- - :meth:`~Graph.is_arc_transitive` +- - :meth:`~Graph.is_semi_symmetric` ++ - :meth:`~Graph.is_edge_transitive` ++ - :meth:`~Graph.is_arc_transitive` ++ - :meth:`~Graph.is_semi_symmetric` + + EXAMPLES: + +@@ -2827,9 +2827,9 @@ class Graph(GenericGraph): + + .. SEEALSO:: + +- - :meth:`~Graph.is_edge_transitive` +- - :meth:`~Graph.is_arc_transitive` +- - :meth:`~Graph.is_half_transitive` ++ - :meth:`~Graph.is_edge_transitive` ++ - :meth:`~Graph.is_arc_transitive` ++ - :meth:`~Graph.is_half_transitive` + + EXAMPLES: + +@@ -5751,8 +5751,8 @@ class Graph(GenericGraph): + + .. SEEALSO:: + +- * Graph cores is also a notion related to graph homomorphisms. For +- this second meaning, see :meth:`Graph.has_homomorphism_to`. ++ * Graph cores is also a notion related to graph homomorphisms. For ++ this second meaning, see :meth:`Graph.has_homomorphism_to`. + + REFERENCE: + +@@ -5937,7 +5937,7 @@ class Graph(GenericGraph): + + .. SEEALSO:: + +- - :meth:`is_prime` -- Tests whether a graph is prime. ++ - :meth:`is_prime` -- Tests whether a graph is prime. + + REFERENCE: + diff --git a/sagemath.spec b/sagemath.spec index 84fe86b..a7ba822 100644 --- a/sagemath.spec +++ b/sagemath.spec @@ -1,34 +1,11 @@ -# of a system package %global __provides_exclude_from .*/site-packages/.*\\.so -# for quicker test with packages not yet in fedora -%global packager_debug 0 - # not functional due to missing jar dependencies %global with_sage3d 0 # use an workaround to match upstream sagemath patched sphinx %global with_sphinx_hack 1 -# https://bugzilla.redhat.com/show_bug.cgi?id=909510 -%global have_lrcalc 1 - -# Cbc dependency under review is as follow: -# first need coin-or-CoinUtils -# https://bugzilla.redhat.com/show_bug.cgi?id=894585 -# then coin-or-Osi (that requires coin-or-CoinUtils) -# https://bugzilla.redhat.com/show_bug.cgi?id=894586 -# then coin-or-Clp (that requires coin-or-Osi) -# https://bugzilla.redhat.com/show_bug.cgi?id=894587 -# then coin-or-Cgl (that requires coin-or-Clp) -# https://bugzilla.redhat.com/show_bug.cgi?id=894588 -# and finally coin-or-Cbc (that requires coin-or-Cgl) -# https://bugzilla.redhat.com/show_bug.cgi?id=894597 -# other coin-or-* packages under review are not required by sagemath -# but are required to have the "basic" set of coin-or packages -%global have_coin_or_Cbc %{packager_debug} - -# https://bugzilla.redhat.com/show_bug.cgi?id=914936 %ifarch x86_64 %global have_fes 1 %else @@ -61,8 +38,8 @@ Name: sagemath Group: Applications/Engineering Summary: A free open-source mathematics software system -Version: 6.1.1 -Release: 5%{?dist} +Version: 6.2 +Release: 1%{?dist} # The file ${SAGE_ROOT}/COPYING.txt is the upstream license breakdown file # Additionally, every $files section has a comment with the license name # before files with that license @@ -134,62 +111,59 @@ Patch12: %{name}-4ti2.patch # http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1317 Patch13: %{name}-pari.patch -# Portuguese translations: http://trac.sagemath.org/sage_trac/ticket/12822 -Patch14: trac_12502_pt_translation_of_a_tour_of_sage_rebase1.patch -Patch15: trac_12822_pt_translation_of_tutorial.patch -Patch16: trac_12822_pt_translation_of_tutorial_rev1.patch - # use jmol itself to export preview images # FIXME besides not using X and told so, fails if DISPLAY is not set -Patch17: %{name}-jmol.patch +Patch14: %{name}-jmol.patch # only cremona mini database built and installed # FIXME add a package with the full cremona database # FIXME actually it should be already available in pari-elldata -Patch18: %{name}-cremona.patch +Patch15: %{name}-cremona.patch # lrslib is a requires -Patch19: %{name}-lrslib.patch +Patch16: %{name}-lrslib.patch # nauty cannot be packaged due to license restrictions # http://cs.anu.edu.au/~bdm/nauty/ # http://pallini.di.uniroma1.it/ -Patch20: %{name}-nauty.patch +Patch17: %{name}-nauty.patch # gap hap package not (yet) available # http://www-gap.mcs.st-and.ac.uk/Packages/hap.html -Patch21: %{name}-gap-hap.patch +Patch18: %{name}-gap-hap.patch -# Patch to enable lrcalc once review request is done in Fedora -Patch22: %{name}-lrcalc.patch +# enable lrcalc +Patch19: %{name}-lrcalc.patch -# Patch to enable cbc once review requests are done in Fedora -Patch23: %{name}-cbc.patch +# enable cbc +Patch20: %{name}-cbc.patch # Use system gap directories -Patch24: %{name}-libgap.patch +Patch21: %{name}-libgap.patch -# Patch to enable fes once review requests are done in Fedora -Patch25: %{name}-fes.patch +# enable fes +Patch22: %{name}-fes.patch -# Get package to build with known problem if not yet updated to pari 2.6. -Patch26: %{name}-nopari2.6.patch - -# sagemath 5.8 (optionally) requires cryptominisat 2.9.6 (in >= f19) -# and does not work with cryptominisat 2.9.5 (in f18) -Patch27: %{name}-cryptominisat.patch +# enable cryptominisat +Patch23: %{name}-cryptominisat.patch # Side effect of using distro packages # https://bugzilla.redhat.com/show_bug.cgi?id=974769 -Patch28: %{name}-sympy.patch +Patch24: %{name}-sympy.patch + +# Correct some warnings of newer sphinx that are treatead as errors +# by default as of sagemath 6.2; other problems were fixed using +# -k (keep-going) +Patch25: %{name}-sphinx.patch + +# Edited latest version from http://trac.sagemath.org/ticket/15767 +Patch26: %{name}-pari2.7.patch BuildRequires: 4ti2 BuildRequires: atlas-devel BuildRequires: cddlib-tools BuildRequires: cliquer-devel -%if %{have_coin_or_Cbc} BuildRequires: coin-or-Cbc-devel -%endif BuildRequires: cryptominisat-devel BuildRequires: Cython BuildRequires: desktop-file-utils @@ -222,9 +196,7 @@ BuildRequires: libfplll-devel BuildRequires: libgap-devel BuildRequires: libmpc-devel BuildRequires: linbox-devel -%if %{have_lrcalc} BuildRequires: lrcalc-devel -%endif BuildRequires: m4ri-devel BuildRequires: m4rie-devel BuildRequires: maxima-runtime-ecl @@ -625,40 +597,24 @@ popd %patch11 %patch12 %patch13 - -pushd src -mkdir -p doc/pt/a_tour_of_sage/ -cp -fa doc/en/a_tour_of_sage/*.png doc/pt/a_tour_of_sage/ -%patch14 -p1 -%patch15 -p1 -%patch16 -p1 -popd - +%patch14 +%patch15 +%patch16 %patch17 %patch18 %patch19 - %patch20 %patch21 -%if %{have_lrcalc} +%if %{have_fes} %patch22 %endif -# other coin-or packages are build requires or coin-or-Cbc -%if %{have_coin_or_Cbc} %patch23 -%endif - %patch24 - -%if %{have_fes} %patch25 -%endif -%patch26 -%patch27 -%patch28 +%patch26 -p1 sed -e 's|@@SAGE_ROOT@@|%{SAGE_ROOT}|' \ -e 's|@@SAGE_DOC@@|%{SAGE_DOC}|' \ @@ -898,6 +854,12 @@ popd #------------------------------------------------------------------------ pushd build/pkgs/elliptic_curves + # --short-circuit -bi debug build helper + if [ ! -e src/ellcurves ]; then + rm -fr src + tar jxf ../../../upstream/%{elliptic_curves_pkg}.tar.bz2 + mv %{elliptic_curves_pkg} src + fi %__python2 ./spkg-install popd @@ -961,19 +923,13 @@ export SAGE_ETC="$SAGE_ETC" export SAGE_SRC="$SAGE_SRC" ##export SAGE_DOC="$SAGE_DOC" module load 4ti2-%{_arch} -%if %{have_lrcalc} module load lrcalc-%{_arch} -%endif module load surf-geometry-%{_arch} export PATH=$SAGE_LOCAL/bin:\$PATH export SINGULARPATH=%{_libdir}/Singular/LIB export SINGULAR_BIN_DIR=%{_libdir}/Singular ##export PYTHONPATH="$SAGE_PYTHONPATH:\$SAGE_LOCAL/bin" -%if 0%{?fedora} export SAGE_CBLAS=blas -%else -export SAGE_CBLAS=cblas -%endif export SAGE_FORTRAN=%{_bindir}/gfortran export SAGE_FORTRAN_LIB=\`gfortran --print-file-name=libgfortran.so\` export SYMPOW_DIR="\$DOT_SAGE/sympow" @@ -1011,7 +967,7 @@ pushd src popd #------------------------------------------------------------------------ - cp -f $SAGE_PYTHONPATH/{ANSI,FSM,pexpect,pxssh,screen}.py %{buildroot}%{python_sitearch} +cp -f $SAGE_PYTHONPATH/{ANSI,FSM,pexpect,pxssh,screen}.py %{buildroot}%{python_sitearch} # Build documentation, using %#{buildroot} environment pushd src/doc @@ -1030,7 +986,7 @@ pushd src/doc # there we go ln -sf %{buildroot}%{SAGE_DOC} $SAGE_SRC/doc - python common/builder.py all html + python common/builder.py -k all html export SAGE_DOC=%{buildroot}%{SAGE_DOC} cp -far output $SAGE_DOC @@ -1371,6 +1327,17 @@ exit 0 ######################################################################## %changelog +* Mon May 26 2014 pcpa - 6.2-1 +- Update to sagemath 6.2 (#1095282) +- Rebuild with Singular 3.1.6 (#1074597) +- Add missing python-docutils requires (#1056374) +- Correct uninstall of sagemath-notebook (#1097428) +- Enable coin-or-Cbc interface +- Make coin-or-Cbc not optional +- Make lrcalc not optional +- Use upstream patch to support pari 2.7 +- Rediff ntl6 patch + * Wed Apr 2 2014 Jerry James - 6.1.1-5 - Rebuild for ntl 6.1.0 - Fix ld ignoring __global_ldflags due to embedded trailing space diff --git a/sources b/sources index dabc724..c5fdbdb 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -800c59f7cfa32c012f358ae240cdb2e6 sage-6.1.1.tar.gz +71aa49875797c001ce0a31409f5a1762 sage-6.2.tar.gz diff --git a/trac_12502_pt_translation_of_a_tour_of_sage_rebase1.patch b/trac_12502_pt_translation_of_a_tour_of_sage_rebase1.patch deleted file mode 100644 index 65fec93..0000000 --- a/trac_12502_pt_translation_of_a_tour_of_sage_rebase1.patch +++ /dev/null @@ -1,192 +0,0 @@ -# HG changeset patch -# User Gustavo de Oliveira -# Date 1331804234 -3600 -# Node ID 94a5dead34f6c05d91a1ea6746cc171a7248e905 -# Parent 05f00d34acbd7a4340a322d3752461edbae46fd0 -Trac 12502: Portuguese translation of "A Tour of Sage". - -diff --git a/doc/pt/a_tour_of_sage/conf.py b/doc/pt/a_tour_of_sage/conf.py -new file mode 100644 ---- /dev/null -+++ b/doc/pt/a_tour_of_sage/conf.py -@@ -0,0 +1,36 @@ -+# -*- coding: utf-8 -*- -+# -+# Numerical Sage documentation build configuration file, created by -+# sphinx-quickstart on Sat Dec 6 11:08:04 2008. -+# -+# This file is execfile()d with the current directory set to its containing dir. -+# -+# The contents of this file are pickled, so don't put values in the namespace -+# that aren't pickleable (module imports are okay, they're removed automatically). -+# -+# All configuration values have a default; values that are commented out -+# serve to show the default. -+ -+import sys, os -+sys.path.append(os.environ['SAGE_DOC']) -+from common.conf import * -+ -+# General information about the project. -+project = u'Uma Turnê pelo Sage' -+name = 'a_tour_of_sage' -+language = 'pt_BR' -+ -+# The name for this set of Sphinx documents. If None, it defaults to -+# " v documentation". -+html_title = project + " v" + release -+html_short_title = project + " v" + release -+ -+# Output file base name for HTML help builder. -+htmlhelp_basename = name -+ -+# Grouping the document tree into LaTeX files. List of tuples -+# (source start file, target name, title, author, document class [howto/manual]). -+latex_documents = [ -+ ('index', name+'.tex', u'A Tour Of Sage', -+ u'The Sage Development Team', 'manual'), -+] -diff --git a/doc/pt/a_tour_of_sage/index.rst b/doc/pt/a_tour_of_sage/index.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/a_tour_of_sage/index.rst -@@ -0,0 +1,139 @@ -+=================== -+Uma Turnê pelo Sage -+=================== -+ -+Esta apresentação ao Sage segue de perto o "tour do Mathematica" que -+se encontra no começo do "manual do Mathematica". -+ -+ -+Sage como uma Calculadora -+========================= -+ -+A linha de comando do Sage possui o prompt ``sage:``; você não precisa -+digitar essa palavra. Se você usar o Sage Notebook, então você deve -+copiar todo o comando após o prompt ``sage:`` em uma célula, e -+pressionar shift-enter para calcular o resultado. -+ -+:: -+ -+ sage: 3 + 5 -+ 8 -+ -+O acento circunflexo significa "elevar à potência". -+ -+:: -+ -+ sage: 57.1 ^ 100 -+ 4.60904368661396e175 -+ -+Pode-se calcular a inversa de uma matrix :math:`2 \times 2` com o Sage. -+ -+:: -+ -+ sage: matrix([[1,2], [3,4]])^(-1) -+ [ -2 1] -+ [ 3/2 -1/2] -+ -+A seguir, calculamos a integral de uma função simples. -+ -+:: -+ -+ sage: x = var('x') # create a symbolic variable -+ sage: integrate(sqrt(x)*sqrt(1+x), x) -+ 1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1) - 1/8*log(sqrt(x + 1)/sqrt(x) + 1) -+ -+Agora vamos resolver uma equação quadrática com o Sage. O símbolo -+``==`` representa igualdade no Sage. -+ -+:: -+ -+ sage: a = var('a') -+ sage: S = solve(x^2 + x == a, x); S -+ [x == -1/2*sqrt(4*a + 1) - 1/2, x == 1/2*sqrt(4*a + 1) - 1/2] -+ -+O resultado é uma lista de igualdades. -+ -+.. link -+ -+:: -+ -+ sage: S[0].rhs() -+ -1/2*sqrt(4*a + 1) - 1/2 -+ sage: show(plot(sin(x) + sin(1.6*x), 0, 40)) -+ -+.. image:: sin_plot.* -+ -+ -+Cálculo Numérico com o Sage -+=========================== -+ -+Primeiro vamos criar uma matriz :math:`500 \times 500` de números aleatórios. -+ -+:: -+ -+ sage: m = random_matrix(RDF,500) -+ -+Leva alguns segundos para calcular os autovalores dessa matriz e -+representá-los em um gráfico. -+ -+.. link -+ -+:: -+ -+ sage: e = m.eigenvalues() #about 2 seconds -+ sage: w = [(i, abs(e[i])) for i in range(len(e))] -+ sage: show(points(w)) -+ -+.. image:: eigen_plot.* -+ -+ -+Graças à biblioteca GMP (GNU Multiprecision Library), o Sage pode -+efetuar cálculos com números muito grandes, até mesmo com números com -+milhões de dígitos. -+ -+:: -+ -+ sage: factorial(100) -+ 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 -+ sage: n = factorial(1000000) #about 2.5 seconds -+ -+Vamos calcular :math:`\pi` com 100 algarismos decimais. -+ -+:: -+ -+ sage: N(pi, digits=100) -+ 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 -+ -+Agora o Sage vai fatorar um polinômio em duas variáveis. -+ -+:: -+ -+ sage: R. = QQ[] -+ sage: F = factor(x^99 + y^99) -+ sage: F -+ (x + y) * (x^2 - x*y + y^2) * (x^6 - x^3*y^3 + y^6) * -+ (x^10 - x^9*y + x^8*y^2 - x^7*y^3 + x^6*y^4 - x^5*y^5 + -+ x^4*y^6 - x^3*y^7 + x^2*y^8 - x*y^9 + y^10) * -+ (x^20 + x^19*y - x^17*y^3 - x^16*y^4 + x^14*y^6 + x^13*y^7 - -+ x^11*y^9 - x^10*y^10 - x^9*y^11 + x^7*y^13 + x^6*y^14 - -+ x^4*y^16 - x^3*y^17 + x*y^19 + y^20) * (x^60 + x^57*y^3 - -+ x^51*y^9 - x^48*y^12 + x^42*y^18 + x^39*y^21 - x^33*y^27 - -+ x^30*y^30 - x^27*y^33 + x^21*y^39 + x^18*y^42 - x^12*y^48 - -+ x^9*y^51 + x^3*y^57 + y^60) -+ sage: F.expand() -+ x^99 + y^99 -+ -+O Sage leva menos de 5 segundos para calcular de quantas maneiras pode-se -+particionar :math:`10^8` como uma soma de inteiros positivos. -+ -+:: -+ -+ sage: z = Partitions(10^8).cardinality() #about 4.5 seconds -+ sage: str(z)[:40] -+ '1760517045946249141360373894679135204009' -+ -+Algoritmos incluídos no Sage -+============================ -+ -+Quando você usa o Sage, você acessa uma das maiores coleções -+disponíveis de algoritmos computacionais de código aberto. diff --git a/trac_12822_pt_translation_of_tutorial.patch b/trac_12822_pt_translation_of_tutorial.patch deleted file mode 100644 index 4907306..0000000 --- a/trac_12822_pt_translation_of_tutorial.patch +++ /dev/null @@ -1,6801 +0,0 @@ -# HG changeset patch -# User Gustavo de Oliveira -# Date 1334006083 -7200 -# Node ID ad8e41651a3187a45f087335cb048418bf545506 -# Parent bbd101e6eaa8de241270aa8063dc8380a6d983e3 -Trac 12822: Portuguese translation of "Tutorial". - -diff --git a/doc/pt/tutorial/afterword.rst b/doc/pt/tutorial/afterword.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/afterword.rst -@@ -0,0 +1,181 @@ -+******** -+Posfacio -+******** -+ -+Por quê o Python? -+================= -+ -+Vantagens do Python -+------------------- -+ -+A primeira linguagem de implementação do Sage é o Python (veja [Py]_), -+embora rotinas que precisam ser muito rápidas são implementadas em uma -+linguagem compilada. O Python possui várias vantagens: -+ -+- **Salvar objetos** é bem suportado em Python. Existe suporte -+ extenso em Python para salvar (na grande maioria dos casos) objetos -+ arbitrários em arquivos em disco ou em uma base de dados. -+ -+- Suporte excelente para **documentação** de funções e pacotes no -+ código fonte, incluindo extração automática de documentação e teste -+ automático de todos os exemplos. Os exemplos são automaticamente -+ testados regularmente para garantir que funcionam como indicado. -+ -+- **Gerenciamento de memória:** O Python agora possui um sistema de -+ gerenciamento de memória e "garbage collector" muito bem pensados e -+ robustos que lidam corretamente com referências circulares, e -+ permitem variáveis locais em arquivos. -+ -+- O Python possui **diversos pacotes** disponíveis que podem ser de -+ grande interesse para os usuários do Sage: análise numérica e -+ álgebra linear, visualização 2D e 3D, comunicação via rede (para -+ computação distribuída e servidores, por exemplo, via twisted), -+ suporte a base de dados, etc. -+ -+- **Portabilidade:** O Python é fácil de compilar a partir do código -+ fonte em poucos minutos na maioria das arquiteturas. -+ -+- **Manuseamento de exceções:** O Python possui um sofisticado e bem -+ pensado sistema de manuseamento de exceções, através do qual -+ programas podem facilmente se recuperar mesmo se ocorrerem erros no -+ código que está sendo executado. -+ -+- **Debugador:** O Python inclui um debugador, de modo que quando -+ alguma rotina falha por algum motivo, o usuário pode acessar -+ extensiva informação sobre a pilha de cálculos e inspecionar o -+ estado de todas as variáveis relevantes. -+ -+- **Profiler:** Existe um profiler para o Python, o qual executa -+ programas e cria um relatório detalhando quantas vezes e por quando -+ tempo cada função foi executada. -+ -+- **Uma Linguagem:** Em vez de escrever uma **nova linguagem** para -+ matemática como foi feito para o Magma, Maple, Mathematica, Matlab, -+ GP/PARI, GAP, Macaulay 2, Simath, etc., nós usamos a linguagem -+ Python, que é uma linguagem de programação popular que está -+ sendo desenvolvida e otimizada ativamente por centenas de -+ engenheiros de software qualificados. O Python é uma grande -+ história de sucesso em desenvolvimento com código aberto com um -+ processo de desenvolvimento maduro (veja [PyDev]_). -+ -+.. _section-mathannoy: -+ -+O Pré-Processador: Diferenças entre o Sage e o Python -+----------------------------------------------------- -+ -+Alguns aspectos matemáticos do Python podem ser confusos, logo o Sage -+se comporta diferentemente do Python em diversas situações. -+ -+- **Notação para exponenciação:** ``**`` versus ``^``. Em Python, -+ ``^`` significa "xor", não exponenciação, logo em Python temos -+ -+ :: -+ -+ >>> 2^8 -+ 10 -+ >>> 3^2 -+ 1 -+ >>> 3**2 -+ 9 -+ -+ Esse uso de ``^`` pode parecer estranho, e é ineficiente para -+ pesquisa em matemática pura, pois a função "ou exclusivo" é -+ raramente usada. Por conveniência, o Sage pre-processa todos as -+ linhas de comandos antes de passá-las para o Python, substituindo -+ ocorrências de ``^`` que não estão em strings por ``**``: -+ -+ :: -+ -+ sage: 2^8 -+ 256 -+ sage: 3^2 -+ 9 -+ sage: "3^2" -+ '3^2' -+ -+- **Divisão por inteiros:** A expressão em Python ``2/3`` não se -+ comporta da forma que um matemático esperaria. Em Python, se ``m`` -+ e ``n`` são inteiros (int), então ``m/n`` também é um inteiro -+ (int), a saber, o quociente de ``m`` dividido por ``n``. Portanto -+ ``2/3=0``. Tem havido discussões na comunidade do Python para -+ modificar o Python de modo que ``2/3`` retorne um número de -+ precisão flutuante (float) ``0.6666...``, e ``2//3`` retorne ``0``. -+ -+ Nós lidamos com isso no interpretador Sage, encapsulando inteiros -+ literais em ``Integer()`` e fazendo a divisão um construtor para -+ números racionais. Por exemplo: -+ -+ :: -+ -+ sage: 2/3 -+ 2/3 -+ sage: (2/3).parent() -+ Rational Field -+ sage: 2//3 -+ 0 -+ sage: int(2)/int(3) -+ 0 -+ -+- **Inteiros longos:** O Python possui suporte nativo para inteiros -+ com precisão arbitrária, além de int's do C. Esses são -+ significantemente mais lentos do que os fornecidos pela biblioteca -+ GMP, e têm a propriedade que eles são impressos com o sufixo ``L`` -+ para distingui-los de int's (e isso não será modificado no futuro -+ próximo). O Sage implementa inteiros com precisão arbitrária usando -+ a biblioteca C do GMP, e esses são impressos sem o sufixo ``L``. -+ -+Em vez de modificar o interpretador Python (como algumas pessoas -+fizeram para projetos internos), nós usamos a linguagem Python -+exatamente com ela é, e escrevemos um pré-processador para o IPython de -+modo que o comportamento da linha de comando seja o que um matemático -+espera. Isso significa que qualquer programa existente em Python pode -+ser usado no Sage. Todavia, deve-se obedecer as regras padrão do -+Python para escrever programas que serão importados no Sage. -+ -+(Para instalar uma biblioteca do Python, por exemplo uma que você -+tenha encontrado na internet, siga as instruções, mas execute ``sage -+-python`` em vez de ``python``. Frequentemente isso significa digitar -+``sage -python setup.py install``.) -+ -+Eu gostaria de contribuir de alguma forma. Como eu posso? -+========================================================= -+ -+Se você quiser contribuir para o Sage, a sua ajuda será muito bem -+vinda! Ela pode variar desde substancial quantidade de código, até -+contribuições com respeito à documentação ou notificação de defeitos -+(bugs). -+ -+Explore a página na web do Sage para informações para desenvolvedores; -+entre outras coisas, você pode encontrar uma lista longa de projetos -+relacionados ao Sage ordenados por prioridade e categoria. O `Guia -+para desenvolvedores do Sage -+`_ (em inglês) também possui -+informações úteis, e você pode também visitar o grupo de discussões -+``sage-devel`` no Google Groups. -+ -+Como eu faço referência ao Sage? -+================================ -+ -+Se você escrever um artigo usando o Sage, por favor faça referência -+aos cálculos feitos com o Sage incluindo -+ -+:: -+ -+ [Sage] William A. Stein et al., Sage Mathematics Software (Version 4.3). -+ The Sage Development Team, 2009, http://www.sagemath.org. -+ -+na sua bibliografia (substituindo 4.3 pela versão do Sage que você -+está usando). Além disso, procure observar quais componentes do Sage -+você está usando em seus cálculos, por exemplo, PARI, Singular, GAP, -+Maxima, e também site esses sistemas. Se você está em dúvida sobre -+qual software está sendo usado em seus cálculos, fique à vontade para -+perguntar no grupo ``sage-devel`` do Google Groups. Veja -+:ref:`section-univariate` para mais discussões sobre esse aspecto. -+ -+------------ -+ -+Se por acaso você leu este tutorial do começo ao fim em uma só vez, e -+faz idéia de quanto tempo você levou, por favor nos informe no grupo -+``sage-devel`` do Google Groups. -+ -+Divirta-se com o Sage! -diff --git a/doc/pt/tutorial/appendix.rst b/doc/pt/tutorial/appendix.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/appendix.rst -@@ -0,0 +1,33 @@ -+******** -+Apêndice -+******** -+ -+.. _section-precedence: -+ -+Precedência de operações aritméticas binárias -+============================================= -+ -+Quanto é ``3^2*4 + 2%5``? A resposta (38) é determinada pela "tabela -+de precedência" abaixo. A tabela abaixo é baseada na tabela em § 5.14 -+do *Python Language Reference Manual* by G. Rossum and F. Drake. As -+operações estão listadas aqui em ordem crescente de precedência. -+ -+ -+========================== ================= -+Operadores Descrição -+========================== ================= -+or "ou" booleano -+and "e" booleano -+not "não" booleano -+in, not in pertence -+is, is not teste de identidade -+>, <=, >, >=, ==, !=, <> comparação -++, - adição, subtração -+\*, /, % multiplicação, divisão, resto -+\*\*, ^ exponenciação -+========================== ================= -+ -+Portanto, para calcular ``3^2*4 + 2%5``, O Sage inclui parenteses de -+precedência da seguinte forma: ``((3^2)*4) + (2%5)``. Logo, primeiro -+calcula ``3^2``, que é ``9``, então calcula ``(3^2)*4`` e ``2%5``, e -+finalmente soma os dois. -diff --git a/doc/pt/tutorial/bibliography.rst b/doc/pt/tutorial/bibliography.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/bibliography.rst -@@ -0,0 +1,52 @@ -+************ -+Bibliografia -+************ -+ -+.. [Cyt] Cython, http://www.cython.org. -+ -+.. [Dive] Dive into Python, disponível gratuitamente na internet em -+ http://diveintopython.org. -+ -+.. [GAP] The GAP Group, GAP - Groups, Algorithms, and -+ Programming, Version 4.4; 2005, http://www.gap-system.org -+ -+.. [GAPkg] GAP Packages, -+ http://www.gap-system.org/Packages/packages.html -+ -+.. [GP] PARI/GP http://pari.math.u-bordeaux.fr/. -+ -+.. [Ip] The IPython shell http://ipython.scipy.org. -+ -+.. [Jmol] Jmol: an open-source Java viewer for chemical -+ structures in 3D http://www.jmol.org/. -+ -+.. [Mag] Magma http://magma.maths.usyd.edu.au/magma/. -+ -+.. [Max] Maxima http://maxima.sf.net/ -+ -+.. [NagleEtAl2004] Nagle, Saff, and Snider. -+ *Fundamentals of Differential Equations*. 6th edition, Addison-Wesley, -+ 2004. -+ -+.. [Py] The Python language http://www.python.org/ -+ Reference Manual http://docs.python.org/ref/ref.html. -+ -+.. [PyDev] Guido, Some Guys, and a Mailing List: How Python is -+ Developed, -+ http://www.python.org/dev/dev_intro.html. -+ -+.. [Pyr] Pyrex, -+ http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/. -+ -+.. [PyT] The Python Tutorial http://www.python.org/. -+ -+.. [SA] Sage web site http://www.sagemath.org/. -+ -+.. [Si] G.-M. Greuel, G. Pfister, and H. Schönemann. Singular -+ 3.0. A Computer Algebra System for Polynomial Computations. Center -+ for Computer Algebra, University of Kaiserslautern (2005). -+ http://www.singular.uni-kl.de. -+ -+.. [SJ] William Stein, David Joyner, Sage: System for Algebra and -+ Geometry Experimentation, Comm. Computer Algebra {39}(2005)61-64. -+ -diff --git a/doc/pt/tutorial/conf.py b/doc/pt/tutorial/conf.py -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/conf.py -@@ -0,0 +1,35 @@ -+# -*- coding: utf-8 -*- -+# -+# Sage documentation build configuration file, based on the file created by -+# sphinx-quickstart on Thu Aug 21 20:15:55 2008. -+# -+# This file is execfile()d with the current directory set to its containing dir. -+# -+# The contents of this file are pickled, so don't put values in the namespace -+# that aren't pickleable (module imports are okay, they're removed automatically). -+# -+# All configuration values have a default; values that are commented out -+# serve to show the default. -+ -+import sys, os -+sys.path.append(os.environ['SAGE_DOC']) -+from common.conf import * -+ -+# General information about the project. -+project = u"Tutorial Sage" -+name = u'tutorial-pt' -+language = "pt_BR" -+ -+# The name for this set of Sphinx documents. If None, it defaults to -+# " v documentation". -+html_title = project + " v"+release -+ -+# Output file base name for HTML help builder. -+htmlhelp_basename = name -+ -+# Grouping the document tree into LaTeX files. List of tuples -+# (source start file, target name, title, author, document class [howto/manual]). -+latex_documents = [ -+ ('index', name+'.tex', project, -+ u'The Sage Group', 'manual'), -+] -diff --git a/doc/pt/tutorial/index.rst b/doc/pt/tutorial/index.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/index.rst -@@ -0,0 +1,46 @@ -+.. Sage documentation master file, created by sphinx-quickstart on Thu Aug 21 20:15:55 2008. -+ You can adapt this file completely to your liking, but it should at least -+ contain the root `toctree` directive. -+ -+Bem-vindo ao Tutorial Sage! -+=========================== -+ -+Sage é um software de matemática gratuito, de código aberto, para uso -+em ensino e pesquisa em álgebra, geometria, teoria de números, -+criptografia, computação numérica, e áreas relacionadas. Tanto o -+modelo de desenvolvimento como a tecnologia empregada no Sage se -+distinguem pela forte ênfase em transparência, cooperação, e -+colaboração: estamos desenvolvendo o carro, não reinventando a roda. O -+objetivo maior do Sage é criar uma alternativa viável, gratuita, e de -+código aberto aos programas Maple, Mathematica, Magma e MATLAB. -+ -+Este tutorial é a melhor forma de se familiarizar com o Sage em apenas -+algumas horas. Você pode lê-lo em versão HTML ou PDF, ou diretamente -+no Notebook Sage (clique em ``Help``, e então clique em ``Tutorial`` -+para percorrer o tutorial de forma iterativa diretamente do Sage). -+ -+Este documento está sob a licença `Creative Commons CompartilhaIgual -+3.0`__. -+ -+__ http://creativecommons.org/licenses/by-sa/3.0/deed.pt -+ -+.. toctree:: -+ :maxdepth: 2 -+ -+ introduction -+ tour -+ interactive_shell -+ interfaces -+ latex -+ programming -+ sagetex -+ afterword -+ appendix -+ bibliography -+ -+Índices e tabelas -+================= -+ -+* :ref:`genindex` -+* :ref:`modindex` -+* :ref:`search` -diff --git a/doc/pt/tutorial/interactive_shell.rst b/doc/pt/tutorial/interactive_shell.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/interactive_shell.rst -@@ -0,0 +1,1024 @@ -+.. _chapter-interactive_shell: -+ -+***************************** -+A Linha de Comando Interativa -+***************************** -+Na maior parte deste tutorial, assumimos que você iniciou o -+interpretador Sage usando o comando ``sage``. Isso inicia uma versão -+personalizada da linha de comando IPython, e importa diversas funções -+e classes de modo que elas fiquem prontas para serem usadas a partir -+da linha de comando. Configuração adicional é possível editando o -+arquivo ``$SAGE_ROOT/ipythonrc``. Assim que você inicia o Sage, você -+obtém o seguinte: -+ -+.. skip -+ -+:: -+ -+ ---------------------------------------------------------------------- -+ | SAGE Version 3.1.1, Release Date: 2008-05-24 | -+ | Type notebook() for the GUI, and license() for information. | -+ ---------------------------------------------------------------------- -+ sage: -+ -+Para sair do Sage pressione Ctrl-D ou digite ``quit`` ou ``exit``. -+ -+.. skip -+ -+:: -+ -+ sage: quit -+ Exiting SAGE (CPU time 0m0.00s, Wall time 0m0.89s) -+ -+O wall time é o tempo que passou no relógio "pendurado na sua parede". -+Isso é relevante, pois o tempo CPU não conta o tempo usado por -+subprocessos como GAP ou Singular. -+ -+(Evite terminar um processo do Sage usando ``kill -9`` a partir de um -+terminal, pois o Sage pode não terminal seus subprocessos, por -+exemplo, subprocessos do Maple, ou limpeza de arquivos temporários em -+``$HOME/.sage/tmp``.) -+ -+A Sua Sessão no Sage -+==================== -+ -+A sessão é a sequência de entradas e saídas de dados desde o momento em -+que você inicia até o momento em que você termina o Sage. O Sage grava -+todas as entradas de dados, através do IPython. De fato, se você está -+usando a linha de comando (não o Notebook), então a qualquer momento -+você pode digitar ``%history`` (ou ``%hist``) para obter uma lista de -+todas as linhas digitadas até então. Você pode digitar ``?`` no prompt -+do Sage para aprender mais sobre o IPython, por exemplo, "IPython -+offers numbered prompts ... with input and output caching. All input -+is saved and can be retrieved as variables (besides the usual arrow -+key recall). The following GLOBAL variables always exist (so don't -+overwrite them!)": -+ -+:: -+ -+ _: previous input (interactive shell and notebook) -+ __: next previous input (interactive shell only) -+ _oh : list of all inputs (interactive shell only) -+ -+Aqui vai um exemplo: -+ -+.. skip -+ -+:: -+ -+ sage: factor(100) -+ _1 = 2^2 * 5^2 -+ sage: kronecker_symbol(3,5) -+ _2 = -1 -+ sage: %hist #This only works from the interactive shell, not the notebook. -+ 1: factor(100) -+ 2: kronecker_symbol(3,5) -+ 3: %hist -+ sage: _oh -+ _4 = {1: 2^2 * 5^2, 2: -1} -+ sage: _i1 -+ _5 = 'factor(ZZ(100))\n' -+ sage: eval(_i1) -+ _6 = 2^2 * 5^2 -+ sage: %hist -+ 1: factor(100) -+ 2: kronecker_symbol(3,5) -+ 3: %hist -+ 4: _oh -+ 5: _i1 -+ 6: eval(_i1) -+ 7: %hist -+ -+Vamos omitir a numeração das linhas no restante deste tutorial e em -+outras documentações do Sage. -+ -+Você também pode salvar uma lista de comandos em uma macro. -+ -+.. skip -+ -+:: -+ -+ sage: E = EllipticCurve([1,2,3,4,5]) -+ sage: M = ModularSymbols(37) -+ sage: %hist -+ 1: E = EllipticCurve([1,2,3,4,5]) -+ 2: M = ModularSymbols(37) -+ 3: %hist -+ sage: %macro em 1-2 -+ Macro `em` created. To execute, type its name (without quotes). -+ -+ -+.. skip -+ -+:: -+ -+ sage: E -+ Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over -+ Rational Field -+ sage: E = 5 -+ sage: M = None -+ sage: em -+ Executing Macro... -+ sage: E -+ Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over -+ Rational Field -+ -+Quando se usa a linha de comando, qualquer comando UNIX pode ser -+executado a partir do Sage inserindo um ponto de exclamação ``!`` como -+prefixo. Por exemplo, -+ -+.. skip -+ -+:: -+ -+ sage: !ls -+ auto example.sage glossary.tex t tmp tut.log tut.tex -+ -+fornece a lista de arquivos do atual diretório. -+ -+O ``PATH`` possui o diretório bin do Sage em primeiro, portanto se -+você digitar ``p``, ``gap``, ``singular``, ``maxima``, etc., você -+executa a versão incluída no Sage. -+ -+.. skip -+ -+:: -+ -+ sage: !gp -+ Reading GPRC: /etc/gprc ...Done. -+ -+ GP/PARI CALCULATOR Version 2.2.11 (alpha) -+ i686 running linux (ix86/GMP-4.1.4 kernel) 32-bit version -+ ... -+ sage: !singular -+ SINGULAR / Development -+ A Computer Algebra System for Polynomial Computations / version 3-0-1 -+ 0< -+ by: G.-M. Greuel, G. Pfister, H. Schoenemann \ October 2005 -+ FB Mathematik der Universitaet, D-67653 Kaiserslautern \ -+ -+Gravando Entradas e Saídas de dados -+=================================== -+ -+Gravar a sua sessão no Sage não é o mesmo que salvá-la (veja -+:ref:`section-save`). Para gravar a entrada de dados (e opcionalmente -+a saída) use o comando ``logstart``. Digite ``logstart?`` para mais -+detalhes. Você pode usar esse comando para gravar tudo o que você -+digita, toda a saída de dados, e até mesmo usar essa entrada de dados -+que você guardou em uma sessão futura (simplesmente importando o -+arquivo log). -+ -+.. skip -+ -+:: -+ -+ was@form:~$ sage -+ ---------------------------------------------------------------------- -+ | SAGE Version 3.0.2, Release Date: 2008-05-24 | -+ | Type notebook() for the GUI, and license() for information. | -+ ---------------------------------------------------------------------- -+ -+ sage: logstart setup -+ Activating auto-logging. Current session state plus future input saved. -+ Filename : setup -+ Mode : backup -+ Output logging : False -+ Timestamping : False -+ State : active -+ sage: E = EllipticCurve([1,2,3,4,5]).minimal_model() -+ sage: F = QQ^3 -+ sage: x,y = QQ['x,y'].gens() -+ sage: G = E.gens() -+ sage: -+ Exiting SAGE (CPU time 0m0.61s, Wall time 0m50.39s). -+ was@form:~$ sage -+ ---------------------------------------------------------------------- -+ | SAGE Version 3.0.2, Release Date: 2008-05-24 | -+ | Type notebook() for the GUI, and license() for information. | -+ ---------------------------------------------------------------------- -+ -+ sage: load "setup" -+ Loading log file one line at a time... -+ Finished replaying log file -+ sage: E -+ Elliptic Curve defined by y^2 + x*y = x^3 - x^2 + 4*x + 3 over Rational -+ Field -+ sage: x*y -+ x*y -+ sage: G -+ [(2 : 3 : 1)] -+ -+Se você usa o Sage no terminal ``konsole`` do Linux KDE, então você -+pode gravar a sessão da seguinte forma: após iniciar o Sage no -+``konsole``, selecione "settings", então "history...", então "set -+unlimited". Quando você estiver pronto para guardar a sua sessão, -+selecione "edit" e então "save history as..." e digite um nome para -+salvar o texto de sua sessão em seu computador. Após salvar esse -+arquivo, você poderia abri-lô em um editor, tal como o xemacs, e -+imprimi-lo. -+ -+Colar Texto Ignora Prompts -+========================== -+ -+Suponha que você está lendo uma sequência de comandos em Sage ou -+Python e quer copiá-los no Sage. Mas eles têm os irritantes prompts -+``>>>`` ou ``sage:`` para te aborrecer. De fato, você pode copiar e -+colar um exemplo, incluindo os prompts se você quiser, no Sage. Em -+outras palavras, automaticamente o Sage remove os caracteres ``>>>`` -+ou ``sage:`` antes de colar o conteúdo no Python. Por exemplo, -+ -+.. skip -+ -+:: -+ -+ sage: 2^10 -+ 1024 -+ sage: sage: sage: 2^10 -+ 1024 -+ sage: >>> 2^10 -+ 1024 -+ -+Comandos de Tempo -+================= -+ -+Se você colocar o comando ``%time`` no começo de uma linha de comando, -+o tempo que o comando leva para ser executado vai aparecer após a -+saída de dados. Por exemplo, nós podemos comparar o tempo de execução -+para certas operações de exponenciação de várias formas. Os tempos -+abaixo vão ser provavelmente muito diferentes para o seu computador, -+ou até mesmo para versões diferentes do Sage. Primeiro, usando o -+Python -+ -+.. skip -+ -+:: -+ -+ sage: %time a = int(1938)^int(99484) -+ CPU times: user 0.66 s, sys: 0.00 s, total: 0.66 s -+ Wall time: 0.66 -+ -+Isso significa que levou 0.66 segundos no total, e o wall time, isto -+é, a quantidade de tempo que passou no seu relógio de parede, é também -+0.66 segundos. Se o seu computador está executado outros programas o -+wall time pode ser muito maior do que o tempo de CPU. -+ -+A seguir verificamos o tempo de exponenciação usando o tipo Integer do -+Sage, o qual é implementado (em Cython) usando a biblioteca GMP: -+ -+.. skip -+ -+:: -+ -+ sage: %time a = 1938^99484 -+ CPU times: user 0.04 s, sys: 0.00 s, total: 0.04 s -+ Wall time: 0.04 -+ -+Usando a biblioteca C do PARI: -+ -+.. skip -+ -+:: -+ -+ sage: %time a = pari(1938)^pari(99484) -+ CPU times: user 0.05 s, sys: 0.00 s, total: 0.05 s -+ Wall time: 0.05 -+ -+A GMP é melhor, mas por pouco (como esperado, pois a versão do PARI -+contida no Sage usa a GMP para aritmética de inteiros). -+ -+Você pode também contar o tempo de um bloco de comandos usado o -+comando ``cputime``, como ilustrado abaixo: -+ -+:: -+ -+ sage: t = cputime() -+ sage: a = int(1938)^int(99484) -+ sage: b = 1938^99484 -+ sage: c = pari(1938)^pari(99484) -+ sage: cputime(t) # somewhat random output -+ 0.64 -+ -+.. skip -+ -+:: -+ -+ sage: cputime? -+ ... -+ Return the time in CPU second since SAGE started, or with optional -+ argument t, return the time since time t. -+ INPUT: -+ t -- (optional) float, time in CPU seconds -+ OUTPUT: -+ float -- time in CPU seconds -+ -+O comando ``walltime`` se comporta como o comando ``cputime``, exceto -+que ele conta o tempo do relógio. -+ -+Nós podemos também calcular a potência acima em alguns softwares de -+álgebra incluídos no Sage. Em cada caso executamos um comando trivial -+no sistema de modo a inicializar o servidor para aquele programa. O -+tempo mais relevante é o tempo do relógio. Todavia, se houver uma -+diferença significativa entre o wall time e o CPU time então isso pode -+indicar algum problema de performance que vale a pena investigar. -+ -+.. skip -+ -+:: -+ -+ sage: time 1938^99484; -+ CPU times: user 0.01 s, sys: 0.00 s, total: 0.01 s -+ Wall time: 0.01 -+ sage: gp(0) -+ 0 -+ sage: time g = gp('1938^99484') -+ CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s -+ Wall time: 0.04 -+ sage: maxima(0) -+ 0 -+ sage: time g = maxima('1938^99484') -+ CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s -+ Wall time: 0.30 -+ sage: kash(0) -+ 0 -+ sage: time g = kash('1938^99484') -+ CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s -+ Wall time: 0.04 -+ sage: mathematica(0) -+ 0 -+ sage: time g = mathematica('1938^99484') -+ CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s -+ Wall time: 0.03 -+ sage: maple(0) -+ 0 -+ sage: time g = maple('1938^99484') -+ CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s -+ Wall time: 0.11 -+ sage: gap(0) -+ 0 -+ sage: time g = gap.eval('1938^99484;;') -+ CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s -+ Wall time: 1.02 -+ -+Note que o GAP e o Maxima são os mais lentos neste teste (isso foi -+executado no computador ``sage.math.washington.edu``). Devido ao -+"overhead" da interface pexpect, talvez não seja apropriado comparar -+esses resultados com o Sage, que é o mais rápido. -+ -+Outras Dicas para o IPython -+=========================== -+ -+Como observado acima, o Sage usa o IPython como interface, logo você -+pode usar quaisquer comandos e recursos do IPython. Você pode ler a -+`Documentação completa do IPython -+`_ (em inglês). -+ -+- Você pode usar ``%bg`` para executar um comando no background, e -+ então usar ``jobs`` para acessar os resultados, da seguinte forma. -+ (Os comentários ``not tested`` estão aqui porque a sintaxe ``%bg`` -+ não funciona bem com o sistema de testes automáticos do Sage. Se -+ você digitar esses comandos, eles devem funcionar. Isso é obviamente -+ mais útil com comandos que demoram para serem completados.) -+ -+ :: -+ -+ sage: def quick(m): return 2*m -+ sage: %bg quick(20) # not tested -+ Starting job # 0 in a separate thread. -+ sage: jobs.status() # not tested -+ Completed jobs: -+ 0 : quick(20) -+ sage: jobs[0].result # the actual answer, not tested -+ 40 -+ -+ Note que os comandos executados no background não usam o -+ pre-processador (preparser) do Sage -- veja :ref:`section-mathannoy` -+ para mais informações. Uma forma (estranha talvez) de contornar esse -+ problema seria executar :: -+ -+ sage: %bg eval(preparse('quick(20)')) # not tested -+ -+ É mais seguro e simples, todavia, usar ``%bg`` apenas em comandos -+ que não requerem o pre-processador (preparser). -+ -+- Você pode usar ``%edit`` (ou ``%ed`` ou ``ed``) para abrir um -+ editor, se você desejar digitar algum código mais complexo. Antes de -+ iniciar o Sage, certifique-se de que a variável de environment -+ :envvar:`EDITOR` está definida com o seu editor favorito (colocando -+ ``export EDITOR=/usr/bin/emacs`` ou ``export EDITOR=/usr/bin/vim`` -+ or algo similar no lugar apropriado, como um arquivo ``.profile``). -+ A partir do prompt do Sage, o comando ``%edit`` irá abrir o editor -+ escolhido. Então usando o editor você pode definir uma função:: -+ -+ def some_function(n): -+ return n**2 + 3*n + 2 -+ -+ Salve e feche o editor. No restante da sua sessão do Sage, você pode -+ usar então a função ``some_function``. Se você quiser modificá-la, -+ digite ``%edit some_function`` no prompt do Sage. -+ -+- Se você for calcular algo e quiser modificar o resultado para outro -+ uso, execute o cálculo e então digite ``%rep``: isso irá colocar o -+ resultado do comando anterior no prompt do Sage, pronto para ser -+ editado.:: -+ -+ sage: f(x) = cos(x) -+ sage: f(x).derivative(x) -+ -sin(x) -+ -+ A esta altura, se você digitar ``%rep`` no prompt do Sage, você irá -+ obter um novo prompt, seguido de ``-sin(x)``, com o cursor no final -+ da linha. -+ -+Para mais informações, digite ``%quickref`` para ver um guia rápido de -+referência do IPython. Quando este tutorial foi escrito (April 2011), -+o Sage usa a versão 0.9.1 do IPython, e a `documentation for its magic -+commands `_ -+está disponível na internet. -+ -+ -+Erros e Exceções -+================ -+ -+Quando algo errado ocorre, você usualmente verá uma "exceção" do -+Python. O Python até mesmo tenta sugerir o que ocasionou a exceção, -+por exemplo, ``NameError`` ou ``ValueError`` (veja o Manual de -+Referência do Python [Py]_ para uma lista completa de exceções). Por -+exemplo, -+ -+.. skip -+ -+:: -+ -+ sage: 3_2 -+ ------------------------------------------------------------ -+ File "", line 1 -+ ZZ(3)_2 -+ ^ -+ SyntaxError: invalid syntax -+ -+ sage: EllipticCurve([0,infinity]) -+ ------------------------------------------------------------ -+ Traceback (most recent call last): -+ ... -+ TypeError: Unable to coerce Infinity () to Rational -+ -+O debugador interativo é as vezes útil para entender o que houve de -+errado. Você pode ativá-lo e desativá-lo usando ``%pdb`` (o padrão é -+desativado). O prompt ``ipdb>`` aparece se uma exceção é levantada e o -+debugador está ativado. A partir do debugador, você pode imprimir o -+estado de qualquer variável local, e mover a pilha de execução para -+cima e para baixo. Por exemplo, -+ -+.. skip -+ -+:: -+ -+ sage: %pdb -+ Automatic pdb calling has been turned ON -+ sage: EllipticCurve([1,infinity]) -+ --------------------------------------------------------------------------- -+ Traceback (most recent call last) -+ ... -+ -+ ipdb> -+ -+Para uma lista de comandos do debugador, digite ``?`` no prompt -+``ipbd>``: -+ -+:: -+ -+ ipdb> ? -+ -+ Documented commands (type help ): -+ ======================================== -+ EOF break commands debug h l pdef quit tbreak -+ a bt condition disable help list pdoc r u -+ alias c cont down ignore n pinfo return unalias -+ args cl continue enable j next pp s up -+ b clear d exit jump p q step w -+ whatis where -+ -+ Miscellaneous help topics: -+ ========================== -+ exec pdb -+ -+ Undocumented commands: -+ ====================== -+ retval rv -+ -+Digite Ctrl-D ou ``quit`` para retornar ao Sage. -+ -+.. _section-tabcompletion: -+ -+Busca Reversa e Completamento Tab -+================================== -+ -+Busca reversa: Digite o começo de um comando, e então ``Ctrl-p`` (ou -+tecle a seta para cima) para voltar para cada linha que você digitou -+que começa daquela forma. Isso funciona mesmo se você encerrou o Sage -+e iniciou novamente mais tarde. Você também pode fazer uma busca -+reversa ao longo da história usando ``Ctrl-r``. Todos esses recursos -+usam o pacote ``readline``, que está disponível no Linux. -+ -+Para ilustrar a busca reversa, primeiro crie o e espaço vetorial -+tri-dimensional :math:`V=\QQ^3` da seguinte forma: -+ -+:: -+ -+ sage: V = VectorSpace(QQ,3) -+ sage: V -+ Vector space of dimension 3 over Rational Field -+ -+Você pode usar a seguinte notação mais compacta: -+ -+:: -+ -+ sage: V = QQ^3 -+ -+Então é fácil listar todas as funções para :math:`V` usando -+completamento. Digite ``V``, e então pressione a tecla ``[tab]`` no -+seu teclado: -+ -+.. skip -+ -+:: -+ -+ sage: V.[tab key] -+ V._VectorSpace_generic__base_field -+ ... -+ V.ambient_space -+ V.base_field -+ V.base_ring -+ V.basis -+ V.coordinates -+ ... -+ V.zero_vector -+ -+Se você digitar as primeiras letras de uma função, e então a tecla -+``[tab]``, você obtém apenas funções que começam conforme indicado. -+ -+.. skip -+ -+:: -+ -+ sage: V.i[tab key] -+ V.is_ambient V.is_dense V.is_full V.is_sparse -+ -+Se você gostaria de saber o que uma função faz, por exemplo, a função -+coordinates, digite ``V.coordinates?`` para ajuda ou -+``V.coordinates??`` para ver o código fonte, como explicado na próxima -+sessão. -+ -+ -+ -+Sistema de Ajuda Integrado -+========================== -+ -+O Sage possui um sistema de ajuda integrado. Digite o nome da função -+seguido de ? para ver informações sobre a função. -+ -+.. skip -+ -+:: -+ -+ sage: V = QQ^3 -+ sage: V.coordinates? -+ Type: instancemethod -+ Base Class: -+ String Form: -+ Namespace: Interactive -+ File: /home/was/s/local/lib/python2.4/site-packages/sage/modules/f -+ ree_module.py -+ Definition: V.coordinates(self, v) -+ Docstring: -+ Write v in terms of the basis for self. -+ -+ Returns a list c such that if B is the basis for self, then -+ -+ sum c_i B_i = v. -+ -+ If v is not in self, raises an ArithmeticError exception. -+ -+ EXAMPLES: -+ sage: M = FreeModule(IntegerRing(), 2); M0,M1=M.gens() -+ sage: W = M.submodule([M0 + M1, M0 - 2*M1]) -+ sage: W.coordinates(2*M0-M1) -+ [2, -1] -+ -+Como mostrado acima, o comando de ajuda mostra o tipo do objeto, o -+arquivo no qual ele é definido, e uma descrição útil da função com -+exemplos que você pode colar na sua sessão atual. Quase todos esses -+exemplos são regularmente testados automaticamente para certificar que -+eles se comportam exatamente como esperado. -+ -+Outro recurso que vai muito na direção do espírito de código aberto do -+Sage é que se ``f`` é uma função do Python, então o comando ``f??`` -+mostra o código fonte que define ``f``. Por exemplo, -+ -+.. skip -+ -+:: -+ -+ sage: V = QQ^3 -+ sage: V.coordinates?? -+ Type: instancemethod -+ ... -+ Source: -+ def coordinates(self, v): -+ """ -+ Write $v$ in terms of the basis for self. -+ ... -+ """ -+ return self.coordinate_vector(v).list() -+ -+Isso nos diz que tudo que a função ``coordinates`` faz é chamar a -+função ``coordinate_vector`` e converter o resultado para uma lista. O -+que a função ``coordinate_vector`` faz? -+ -+.. skip -+ -+:: -+ -+ sage: V = QQ^3 -+ sage: V.coordinate_vector?? -+ ... -+ def coordinate_vector(self, v): -+ ... -+ return self.ambient_vector_space()(v) -+ -+A função ``coordinate_vector`` coage a sua entrada em um espaço -+ambiente, o que tem o efeito de calcular o vetor de coeficientes de -+:math:`v` em termos de :math:`V`. O espaço :math:`V` já é o espaço -+ambiente pois é simplesmente :math:`\QQ^3`. Existe também uma função -+``coordinate_vector`` para subespaços, que é diferente. Vamos criar um -+subespaço e ver: -+ -+.. skip -+ -+:: -+ -+ sage: V = QQ^3; W = V.span_of_basis([V.0, V.1]) -+ sage: W.coordinate_vector?? -+ ... -+ def coordinate_vector(self, v): -+ """ -+ ... -+ """ -+ # First find the coordinates of v wrt echelon basis. -+ w = self.echelon_coordinate_vector(v) -+ # Next use transformation matrix from echelon basis to -+ # user basis. -+ T = self.echelon_to_user_matrix() -+ return T.linear_combination_of_rows(w) -+ -+(Se você acha que a implementação é ineficiente, por favor junte-se a -+nós para ajudar a optimizar as funções de álgebra linear.) -+ -+Você também pode digitar ``help(command_name)`` ou ``help(class)`` -+para ler um arquivo de ajuda sobre determinada classe. -+ -+.. skip -+ -+:: -+ -+ sage: help(VectorSpace) -+ Help on class VectorSpace ... -+ -+ class VectorSpace(__builtin__.object) -+ | Create a Vector Space. -+ | -+ | To create an ambient space over a field with given dimension -+ | using the calling syntax ... -+ : -+ : -+ -+Quando você digita ``q`` para sair do sistema de ajuda, a sua sessão -+aparece na tela da mesma forma que anteriormente. O texto de ajuda não -+fica permanentemente em sua tela, ao contrário da saída de -+``function_name?`` que as vezes fica. É partircularmente útil digitar -+``help(module_name)``. Por exemplo, espaços vetoriais são definidos em -+``sage.modules.free_module``, então digite -+``help(sage.modules.free_module)`` para obter documentação sobre esse -+módulo. Quando visualizando documentação usando a ajuda, você pode -+procurar no texto digitando ``/`` e na ordem reversa digitando ``?``. -+ -+Salvando e Carregando Objetos Individuais -+========================================= -+ -+Suponha que você calcule uma matriz, ou pior ainda, um espaço -+complicado de símbolos, e gostaria de salvá-los para uso posterior. O -+que você pode fazer? Existem várias estratégias que os sistemas -+computacionais de álgebra adotam para salvar objetos individuais. -+ -+#. **Salve seus cálculos:** Suportam apenas salvar e carregar uma -+ sessão completa (por exemplo, GAP, Magma). -+ -+#. **Entrada e Saída Unificadas:** Faz com que cada objeto seja -+ impresso de uma forma que possa ser lido novamente (GP/PARI). -+ -+#. **Eval:** Torna fácil processar um código arbitrário no -+ interpretador (por exemplo, Singular, PARI). -+ -+ -+ -+Como o Sage usa o Python, ele adota uma estratégia diferente, que se -+baseia no fato de que qualquer objeto pode ser "serializado", isto é, -+transformado em uma string a partir da qual o objeto pode ser -+recuperado. Isso segue o espírito da estratégia unificada de entrada e -+saída do PARI, exceto que não possue a desvantagem que os objetos são -+impressos na tela em uma forma muito complicada. Além disso, o suporte -+para salvar e recuperar é (na maior parte dos casos) completamente -+automática, não requerendo nenhuma programação extra; é simplesmente um -+recurso do Python que foi implementado na linguagem desde o início de -+seu desenvolvimento. -+ -+Quase todos os objetos ``x`` podem ser armazenados em disco de forma -+comprimida usando ``save(x, filename)`` (ou em muitos casos -+``x.save(filename)``). Para carregar o objeto de volta no Sage use -+``load(filename)``. -+ -+.. skip -+ -+:: -+ -+ sage: A = MatrixSpace(QQ,3)(range(9))^2 -+ sage: A -+ [ 15 18 21] -+ [ 42 54 66] -+ [ 69 90 111] -+ sage: save(A, 'A') -+ -+Você deve agora sair do Sage e reiniciá-lo. Então você pode obter -+``A`` de volta: -+ -+.. skip -+ -+:: -+ -+ sage: A = load('A') -+ sage: A -+ [ 15 18 21] -+ [ 42 54 66] -+ [ 69 90 111] -+ -+Você pode fazer o mesmo com objetos mais complicados, por exemplo, -+curvas elípticas. Todos os dados sobre o objeto são guardados e -+restaurados com o objeto. Por exemplo, -+ -+.. skip -+ -+:: -+ -+ sage: E = EllipticCurve('11a') -+ sage: v = E.anlist(100000) # takes a while -+ sage: save(E, 'E') -+ sage: quit -+ -+A versão em disco de ``E`` ocupa 153 kilobytes, pois ela guarda os -+primeiros 1000000 :math:`a_n` com ela. -+ -+.. skip -+ -+:: -+ -+ ~/tmp$ ls -l E.sobj -+ -rw-r--r-- 1 was was 153500 2006-01-28 19:23 E.sobj -+ ~/tmp$ sage [...] -+ sage: E = load('E') -+ sage: v = E.anlist(100000) # instant! -+ -+(Em Python, salvar e restaurar é feito usando o módulo ``cPickle``. Em -+particular, um objeto ``x`` do Sage pode ser salvado usando -+``cPickle.dumps(x, 2)``. Note o ``2``!) -+ -+O sage não pode salvar e carregar objetos criados em algum outro -+sistema computacional de álgebra, por exemplo, GAP, Singular, Maxima, -+etc. Eles são carregados em um estado "inválido". Em GAP, embora -+muitos objetos podem ser impressos de uma forma que eles podem ser -+reconstruídos, muitos não, logo reconstrução a partir de suas -+representações impressas não é permitido. -+ -+.. skip -+ -+:: -+ -+ sage: a = gap(2) -+ sage: a.save('a') -+ sage: load('a') -+ Traceback (most recent call last): -+ ... -+ ValueError: The session in which this object was defined is no longer -+ running. -+ -+Objetos do GP/PARI também podem ser salvados e carregados pois suas -+representações em forma impressa são suficientes para reconstruí-los. -+ -+.. skip -+ -+:: -+ -+ sage: a = gp(2) -+ sage: a.save('a') -+ sage: load('a') -+ 2 -+ -+Objetos que foram salvados podem ser abertos posteriormente em -+computadores com arquiteturas e sistemas operacionais diferentes, por -+exemplo, você poderia salvar uma matriz muito grande em um OS X de -+32-bits e abri-lo em um Linux de 64-bits, encontrar a forma reduzida, -+e movê-lo de volta. Além disso, em muitos casos você pode até mesmo -+abrir objetos em versões do Sage diferentes daquela no qual o objeto -+foi salvo, desde que o código para aquele objeto não seja muito -+diferente. Todos os atributos do objetos são armazendos, assim como a -+classe (mas não o código fonte) que define o objeto. Se aquela classe -+não existir mais em uma nova versão do Sage, então o objeto não pode -+ser reaberto nessa versão. Mas você poderia abri-lo em uma versão mais -+antiga, obter o dicionário do objeto (com ``x.__dict__``), salvar o -+dicionário, e abri-lo em uma versão mais nova. -+ -+Salvando como Texto -+------------------- -+ -+Você também pode salvar a representação em texto (ASCII) de objetos em -+um arquivo, simplesmente abrindo um arquivo em modo de escrita, e -+escrevendo a string que representa o objeto no arquivo (você pode -+salvar mais de um objeto dessa forma). Quando você terminar de -+escrever os objetos, feche o arquivo. -+ -+.. skip -+ -+:: -+ -+ sage: R. = PolynomialRing(QQ,2) -+ sage: f = (x+y)^7 -+ sage: o = open('file.txt','w') -+ sage: o.write(str(f)) -+ sage: o.close() -+ -+.. _section-save: -+ -+Salvando e Abrindo Sessões Completas -+==================================== -+ -+O Sage é flexível para salvar e abrir sessões completas. -+ -+O comando ``save_session(sessionname)`` salva todas as variáveis que -+você definiu na sessão atual como um dicionário com o nome -+``sessionname``. (No caso raro de uma variável não poder ser salva, -+ela simplesmente não aparece no dicionário.) O resultado é um arquivo -+``.sobj`` que pode ser aberto como qualquer outro objeto que foi -+salvado. Quando você abre os objetos que foram salvados em uma sessão, -+você obtém um dicionário cujas chaves (keys) são os nomes das -+variáveis e os valores são os objetos. -+ -+Você pode usar o comando ``load_session(sessionname)`` para carregar -+na presente sessão as variáveis definidas em ``sessioname``. Note que -+isso não remove as variáveis já definidas na presente sessão; em vez -+disso, as duas sessões são combinadas. -+ -+Primeiro iniciamos o Sage e definimos algumas variáveis. -+ -+.. skip -+ -+:: -+ -+ sage: E = EllipticCurve('11a') -+ sage: M = ModularSymbols(37) -+ sage: a = 389 -+ sage: t = M.T(2003).matrix(); t.charpoly().factor() -+ _4 = (x - 2004) * (x - 12)^2 * (x + 54)^2 -+ -+A seguir nós salvamos a nossa sessão, o que armazena cada uma das -+variáveis acima em um arquivo. Então visualizamos o arquivo, que tem -+por volta de 3K bytes. -+ -+.. skip -+ -+:: -+ -+ sage: save_session('misc') -+ Saving a -+ Saving M -+ Saving t -+ Saving E -+ sage: quit -+ was@form:~/tmp$ ls -l misc.sobj -+ -rw-r--r-- 1 was was 2979 2006-01-28 19:47 misc.sobj -+ -+Por fim reiniciamos o Sage, definimos algumas variáveis extra, e -+carregamos a sessão que foi salva anteriormente. -+ -+.. skip -+ -+:: -+ -+ sage: b = 19 -+ sage: load_session('misc') -+ Loading a -+ Loading M -+ Loading E -+ Loading t -+ -+Cada variável que foi salva está de novo disponível. Além disso, a -+variável ``b`` não foi redefinida. -+ -+.. skip -+ -+:: -+ -+ sage: M -+ Full Modular Symbols space for Gamma_0(37) of weight 2 with sign 0 -+ and dimension 5 over Rational Field -+ sage: E -+ Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational -+ Field -+ sage: b -+ 19 -+ sage: a -+ 389 -+ -+ -+ -+.. _section-notebook: -+ -+A Interface do Notebook -+======================= -+ -+O Sage Notebook é iniciado digitando -+ -+.. skip -+ -+:: -+ -+ sage: notebook() -+ -+na linha de comando do Sage. Isso inicia o Notebook e abre o seu -+browser padrão para visualizá-lo. Os arquivos de estado do servidor -+são armazenados em ``$HOME/.sage/sage\_notebook``. -+ -+Outras opções incluem: -+ -+.. skip -+ -+:: -+ -+ sage: notebook("directory") -+ -+a qual inicia um novo servidor para o Notebook usando arquivos em um -+dado diretório, em vez do diretório padrão -+``$HOME/.sage/sage_notebook``. Isso pode ser útil se você quiser ter -+uma coleção de folhas de trabalho (worksheets) associadas com um -+projeto específico, ou executar vários Notebooks separadamente ao -+mesmo tempo. -+ -+Quando você inicia o Notebook, ele primeiro cria os seguintes arquivos -+em ``$HOME/.sage/sage_notebook``: -+ -+:: -+ -+ nb.sobj (the notebook SAGE object file) -+ objects/ (a directory containing SAGE objects) -+ worksheets/ (a directory containing SAGE worksheets). -+ -+Após criar os arquivos acima, o Notebook inicia o servidor web. -+ -+Um "Notebook" é uma coleção de contas de usuário, cada qual pode ter -+várias folhas de trabalho (worksheets). Quando você cria uma nova -+folha de trabalho, os dados dela são armazenados no diretórios -+``worksheets/username/number``. Em cada diretório desse há um arquivo -+texto ``worksheet.txt`` - se algum problema ocorrer com as suas -+folhas de trabalho, ou com o Sage, esse arquivo texto contém toda -+informação necessária para reconstruir a folha de trabalho. -+ -+A partir do Sage, digite ``notebook?`` para mais informações sobre -+como iniciar um servidor. -+ -+O seguinte diagrama ilustra a arquitetura do Notebook Sage: -+ -+:: -+ -+ ---------------------- -+ | | -+ | | -+ | firefox/safari | -+ | | -+ | javascript | -+ | program | -+ | | -+ | | -+ ---------------------- -+ | ^ -+ | AJAX | -+ V | -+ ---------------------- -+ | | -+ | sage | SAGE process 1 -+ | web | ------------> SAGE process 2 (Python processes) -+ | server | pexpect SAGE process 3 -+ | | . -+ | | . -+ ---------------------- . -+ -+Para ajuda sobre as teclas de atalho disponíveis no Notebook, clique -+no link ``Help``. -diff --git a/doc/pt/tutorial/interfaces.rst b/doc/pt/tutorial/interfaces.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/interfaces.rst -@@ -0,0 +1,341 @@ -+.. linkall -+ -+********** -+Interfaces -+********** -+ -+Uma característica central do Sage é que ele permite fazer cálculos -+com objetos em vários sistemas de álgebra computacional usando uma -+interface comum e uma linguagem de programação clara. -+ -+Os métodos console e interact de uma interface executam tarefas bem -+diferentes. Por exemplo, usando GAP: -+ -+#. ``gap.console()``: Isso abre um console do GAP - o controle é -+ transferido para o GAP. Aqui o Sage não é nada mais do que uma -+ forma conveniente de executar um programa, similar à shell Bash do -+ Linux. -+ -+#. ``gap.interact()``: Essa é uma forma de interagir com uma instância -+ do GAP que pode estar cheia de objetos do Sage. Você pode -+ importar objetos nessa seção do GAP (até mesmo a partir da -+ interface interativa), etc. -+ -+ -+.. index: PARI; GP -+ -+GP/PARI -+======= -+ -+O PARI é um programa em C muito compacto, maduro, e extremamente -+otimizado cujo foco primário é teoria de números. Existem duas -+interfaces distintas que podem ser usadas no Sage: -+ -+ -+- ``gp`` - o "**G** do **P** ARI" interpretador, e -+ -+- ``pari`` - a biblioteca C do PARI. -+ -+Por exemplo, os seguintes comandos são duas formas de realizar a mesma -+coisa. Eles parecem idênticos, mas o resultado é na verdade -+diferente, e o que acontece por trás da cena é bastante diferente. -+ -+:: -+ -+ sage: gp('znprimroot(10007)') -+ Mod(5, 10007) -+ sage: pari('znprimroot(10007)') -+ Mod(5, 10007) -+ -+No primeiro caso, uma cópia separada do interpretador GP é iniciada -+como um servidor, e a string ``´znprimroot(10007)'`` é enviada, -+calculada pelo GP, e o resultado é armazenado em uma variável no GP -+(que ocupa espaço na memória dos processos do GP que não serão -+liberados). Então o valor dessa variável é exibido. No segundo caso, -+nenhum programa separado é iniciado, e a string -+``´znprimroot(10007)'`` é calculada por uma certa função da biblioteca -+C do PARI. O resultado é armazenado na memória em uso pelo Python, que -+é liberada quando a variável não for mais referenciada. Os objetos -+possuem tipos diferentes: -+ -+:: -+ -+ sage: type(gp('znprimroot(10007)')) -+ -+ sage: type(pari('znprimroot(10007)')) -+ -+ -+Então qual eu devo usar? Depende do que você está fazendo. A interface -+GP pode fazer absolutamente tudo o que você poderia fazer na linha de -+comando do GP/PARI, pois está simplesmente executando esse programa. -+Em particular, você pode carregar programas complicados em PARI e -+executá-los. Por outro lado, a interface do PARI (via a biblioteca C) -+é muito mais restritiva. Primeiro, nem todas as funções foram -+implementadas. Segundo, bastante código, por exemplo, envolvendo -+integração numérica, não irá funcionar através da interface PARI. -+Todavia, a interface PARI pode ser significamente mais rápida e mais -+robusta do que a interface GP. -+ -+(Se a interface GP ficar sem memória para calcular algum comando, ela -+irá silenciosamente e automaticamente duplicar a memória alocada e -+repetir o comando solicitado. Então os seus cálculos não irão ser -+interrompidos se você não antecipou corretamente a quantidade de -+memória que seria necessária. Esse é um truque útil que a interface -+usual do GP não parece fornecer. Com respeito à interface da -+biblioteca C do PARI, ela imediatamente copia cada objeto criado para -+fora da pilha de memória, logo essa pilha nunca irá crescer. Contudo, -+cada objeto não deve exceder 100MB de tamanho, ou a pilha irá estourar -+quando o objeto for criado. Essa procedimento de cópia impõe uma leve -+pena sobre a performace.) -+ -+Em resumo, o Sage usa a biblioteca C do pari para fornecer -+funcionalidade similar à fornecida pelo interpretador GP/PARI, exceto -+que com um gerenciamento sofisticado de memória e a linguagem de -+programação Python. -+ -+Primeiro criamos uma lista do PARI a partir de uma lista do Python. -+ -+:: -+ -+ sage: v = pari([1,2,3,4,5]) -+ sage: v -+ [1, 2, 3, 4, 5] -+ sage: type(v) -+ -+ -+Cada objeto do PARI é do tipo ``py_pari_gem``. O tipo PARI do objeto -+subjacente pode ser obtido usando a função ``type``. -+ -+:: -+ -+ sage: v.type() -+ 't_VEC' -+ -+Em PARI, para criar uma curva elíptica digitamos -+``ellinit([1,2,3,4,5])``. Em Sage é similar, exceto que ``ellnint`` é -+um método que pode ser chamado em qualquer objeto do PARI, por -+exemplo, ``t\_VEC v``. -+ -+:: -+ -+ sage: e = v.ellinit() -+ sage: e.type() -+ 't_VEC' -+ sage: pari(e)[:13] -+ [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351] -+ -+Agora que temos um objeto de curva elíptica, podemos calcular algumas -+coisas a respeito dele. -+ -+:: -+ -+ sage: e.elltors() -+ [1, [], []] -+ sage: e.ellglobalred() -+ [10351, [1, -1, 0, -1], 1] -+ sage: f = e.ellchangecurve([1,-1,0,-1]) -+ sage: f[:5] -+ [1, -1, 0, 4, 3] -+ -+.. index: GAP -+ -+.. _section-gap: -+ -+GAP -+=== -+ -+O Sage vem com o GAP 4.4.10 para matemática discreta computacional, -+especialmente teoria de grupos. -+ -+Aqui está um exemplo com a função ``IdGroup`` do GAP, a qual usa a -+base de dados opcional sobre grupos que precisa ser instalada -+separadamente, como explicado abaixo. -+ -+:: -+ -+ sage: G = gap('Group((1,2,3)(4,5), (3,4))') -+ sage: G -+ Group( [ (1,2,3)(4,5), (3,4) ] ) -+ sage: G.Center() -+ Group( () ) -+ sage: G.IdGroup() # requires optional database_gap package -+ [ 120, 34 ] -+ sage: G.Order() -+ 120 -+ -+Podemos realizar os mesmos cálculos no Sage sem explicitamente evocar -+a interface do GAP da seguinte forma: -+ -+:: -+ -+ sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) -+ sage: G.center() -+ Subgroup of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) generated by [()] -+ sage: G.group_id() # requires optional database_gap package -+ [120, 34] -+ sage: n = G.order(); n -+ 120 -+ -+(Para alguns recursos adicionais do GAP, você deve instalar dois -+pacotes opcionais. Digite ``sage -optional`` para uma lista e escolha -+o pacote da forma ``gap\_packages-x.y.z``, então digite ``sage -i -+gap\_packages-x.y.z``. Faça o mesmo para ``database\_gap-x.y.z``. -+Alguns pacotes do GAP sem licensa GPL podem ser obtidos no site do GAP -+[GAPkg]_, e copiados em ``$SAGE_ROOT/local/lib/gap-4.4.10/pkg``.) -+ -+Singular -+======== -+ -+O Singular fornece uma biblioteca massiva e madura para bases de -+Gröbner, máximo divisor comum para poliômios em várias variaveis, -+bases de espaços de Riemann-Roch de uma curva plana, e fatorização, -+entre outras coisas. Vamos ilustrar a fatorização de polinômios em -+várias variáveis usando a interface do Sage para o Singular (não -+digite ``...``): -+ -+:: -+ -+ sage: R1 = singular.ring(0, '(x,y)', 'dp') -+ sage: R1 -+ // characteristic : 0 -+ // number of vars : 2 -+ // block 1 : ordering dp -+ // : names x y -+ // block 2 : ordering C -+ sage: f = singular('9*y^8 - 9*x^2*y^7 - 18*x^3*y^6 - 18*x^5*y^6 + \ -+ ... 9*x^6*y^4 + 18*x^7*y^5 + 36*x^8*y^4 + 9*x^10*y^4 - 18*x^11*y^2 - \ -+ ... 9*x^12*y^3 - 18*x^13*y^2 + 9*x^16') -+ -+Agora que definimos :math:`f`, vamos imprimi-lo e fatorá-lo. -+ -+:: -+ -+ sage: f -+ 9*x^16-18*x^13*y^2-9*x^12*y^3+9*x^10*y^4-18*x^11*y^2+36*x^8*y^4+18*x^7*y^5-18*x^5*y^6+9*x^6*y^4-18*x^3*y^6-9*x^2*y^7+9*y^8 -+ sage: f.parent() -+ Singular -+ sage: F = f.factorize(); F -+ [1]: -+ _[1]=9 -+ _[2]=x^6-2*x^3*y^2-x^2*y^3+y^4 -+ _[3]=-x^5+y^2 -+ [2]: -+ 1,1,2 -+ sage: F[1][2] -+ x^6-2*x^3*y^2-x^2*y^3+y^4 -+ -+Como com o exemplo para o GAP em :ref:`section-gap`, podemos calcular -+a fatorização acima sem explicitamente usar a inteface do Singular -+(todavia, implicitamente o Sage usa a interface do Singular para os -+cálculos). Não digite ``...``: -+ -+:: -+ -+ sage: x, y = QQ['x, y'].gens() -+ sage: f = 9*y^8 - 9*x^2*y^7 - 18*x^3*y^6 - 18*x^5*y^6 + 9*x^6*y^4\ -+ ... + 18*x^7*y^5 + 36*x^8*y^4 + 9*x^10*y^4 - 18*x^11*y^2 - 9*x^12*y^3\ -+ ... - 18*x^13*y^2 + 9*x^16 -+ sage: factor(f) -+ (9) * (-x^5 + y^2)^2 * (x^6 - 2*x^3*y^2 - x^2*y^3 + y^4) -+ -+.. _section-maxima: -+ -+Maxima -+====== -+ -+O Maxima está incluido no Sage, assim como uma implementação do Lisp. -+O pacote gnuplot (que o Maxima usa para criar gráficos) é distribuído -+como um pacote adicional do Sage. Entre outras coisas, o Maxima -+executa manipulações simbólicas. Ele pode integrar e diferenciar -+funções simbolicamente, resolver EDOs de primeira ordem, grande parte -+das EDOs lineares de segunda ordem, e tem implementado o método da -+transformada de Laplace para EDOs lineares de qualquer ordem. O Maxima -+também suporta uma série de funções especiais, é capaz de criar -+gráficos via gnuplot, e possui métodos para resolver equações -+polinômiais e manipular matrizes (por exemplo, escalonar e calcular -+autovalores e autovetores). -+ -+Nós ilustramos a interface Sage/Maxima construíndo uma matriz cuja -+entrada :math:`i,j` é :math:`i/j`, para :math:`i,j=1,\ldots,4`. -+ -+:: -+ -+ sage: f = maxima.eval('ij_entry[i,j] := i/j') -+ sage: A = maxima('genmatrix(ij_entry,4,4)'); A -+ matrix([1,1/2,1/3,1/4],[2,1,2/3,1/2],[3,3/2,1,3/4],[4,2,4/3,1]) -+ sage: A.determinant() -+ 0 -+ sage: A.echelon() -+ matrix([1,1/2,1/3,1/4],[0,0,0,0],[0,0,0,0],[0,0,0,0]) -+ sage: A.eigenvalues() -+ [[0,4],[3,1]] -+ sage: A.eigenvectors() -+ [[[0,4],[3,1]],[[[1,0,0,-4],[0,1,0,-2],[0,0,1,-4/3]],[[1,2,3,4]]]] -+ -+Aqui vai outro exemplo: -+ -+:: -+ -+ sage: A = maxima("matrix ([1, 0, 0], [1, -1, 0], [1, 3, -2])") -+ sage: eigA = A.eigenvectors() -+ sage: V = VectorSpace(QQ,3) -+ sage: eigA -+ [[[-2,-1,1],[1,1,1]],[[[0,0,1]],[[0,1,3]],[[1,1/2,5/6]]]] -+ sage: v1 = V(sage_eval(repr(eigA[1][0][0]))); lambda1 = eigA[0][0][0] -+ sage: v2 = V(sage_eval(repr(eigA[1][1][0]))); lambda2 = eigA[0][0][1] -+ sage: v3 = V(sage_eval(repr(eigA[1][2][0]))); lambda3 = eigA[0][0][2] -+ -+ sage: M = MatrixSpace(QQ,3,3) -+ sage: AA = M([[1,0,0],[1, - 1,0],[1,3, - 2]]) -+ sage: b1 = v1.base_ring() -+ sage: AA*v1 == b1(lambda1)*v1 -+ True -+ sage: b2 = v2.base_ring() -+ sage: AA*v2 == b2(lambda2)*v2 -+ True -+ sage: b3 = v3.base_ring() -+ sage: AA*v3 == b3(lambda3)*v3 -+ True -+ -+Por fim, apresentamos um exemplo de como usar o Sage para criar -+gráficos usando ``openmath``. Alguns desses exemplos são modificações -+de exemplos do manual de referência do Maxima. -+ -+Um gráfico em duas dimensões de diversas funções (não digite ``...``): -+ -+:: -+ -+ sage: maxima.plot2d('[cos(7*x),cos(23*x)^4,sin(13*x)^3]','[x,0,1]',\ -+ ... '[plot_format,openmath]') # not tested -+ -+Um gráfico em 3D que você pode mover com o seu mouse: -+ -+:: -+ -+ sage: maxima.plot3d ("2^(-u^2 + v^2)", "[u, -3, 3]", "[v, -2, 2]",\ -+ ... '[plot_format, openmath]') # not tested -+ sage: maxima.plot3d("atan(-x^2 + y^3/4)", "[x, -4, 4]", "[y, -4, 4]",\ -+ ... "[grid, 50, 50]",'[plot_format, openmath]') # not tested -+ -+O próximo gráfico é a famosa faixa de Möbious: -+ -+:: -+ -+ sage: maxima.plot3d("[cos(x)*(3 + y*cos(x/2)), sin(x)*(3 + y*cos(x/2)),\ -+ ... y*sin(x/2)]", "[x, -4, 4]", "[y, -4, 4]",\ -+ ... '[plot_format, openmath]') # not tested -+ -+E agora a famosa garrafa de Klein: -+ -+:: -+ -+ sage: maxima("expr_1: 5*cos(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y)+ 3.0)\ -+ ... - 10.0") -+ 5*cos(x)*(sin(x/2)*sin(2*y)+cos(x/2)*cos(y)+3.0)-10.0 -+ sage: maxima("expr_2: -5*sin(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y)+ 3.0)") -+ -5*sin(x)*(sin(x/2)*sin(2*y)+cos(x/2)*cos(y)+3.0) -+ sage: maxima("expr_3: 5*(-sin(x/2)*cos(y) + cos(x/2)*sin(2*y))") -+ 5*(cos(x/2)*sin(2*y)-sin(x/2)*cos(y)) -+ sage: maxima.plot3d ("[expr_1, expr_2, expr_3]", "[x, -%pi, %pi]",\ -+ ... "[y, -%pi, %pi]", "['grid, 40, 40]",\ -+ ... '[plot_format, openmath]') # not tested -diff --git a/doc/pt/tutorial/introduction.rst b/doc/pt/tutorial/introduction.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/introduction.rst -@@ -0,0 +1,165 @@ -+********** -+Introdução -+********** -+ -+Este tutorial leva no máximo de 3 a 4 horas para ser percorrido. Você -+pode lê-lo em versão HTML ou PDF, ou a partir do Notebook Sage (clique -+em ``Help``, então clique em ``Tutorial`` para percorrer o tutorial de -+forma interativa). -+ -+Embora grande parte do Sage seja implementado em Python, nenhum -+conhecimento de Python é necessário para a leitura deste tutorial. -+Você vai querer aprender Python (uma linguagem muito divertida!) em -+algum momento, e existem diversas opções gratuitas disponíveis para -+isso, entre elas [PyT]_ e [Dive]_ (em inglês). Se você quiser -+experimentar o Sage rapidamente, este tutorial é o lugar certo para -+começar. Por exemplo: -+ -+:: -+ -+ sage: 2 + 2 -+ 4 -+ sage: factor(-2007) -+ -1 * 3^2 * 223 -+ -+ sage: A = matrix(4,4, range(16)); A -+ [ 0 1 2 3] -+ [ 4 5 6 7] -+ [ 8 9 10 11] -+ [12 13 14 15] -+ -+ sage: factor(A.charpoly()) -+ x^2 * (x^2 - 30*x - 80) -+ -+ sage: m = matrix(ZZ,2, range(4)) -+ sage: m[0,0] = m[0,0] - 3 -+ sage: m -+ [-3 1] -+ [ 2 3] -+ -+ sage: E = EllipticCurve([1,2,3,4,5]); -+ sage: E -+ Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 -+ over Rational Field -+ sage: E.anlist(10) -+ [0, 1, 1, 0, -1, -3, 0, -1, -3, -3, -3] -+ sage: E.rank() -+ 1 -+ -+ sage: k = 1/(sqrt(3)*I + 3/4 + sqrt(73)*5/9); k -+ 1/(I*sqrt(3) + 5/9*sqrt(73) + 3/4) -+ sage: N(k) -+ 0.165495678130644 - 0.0521492082074256*I -+ sage: N(k,30) # 30 "bits" -+ 0.16549568 - 0.052149208*I -+ sage: latex(k) -+ \frac{1}{i \, \sqrt{3} + \frac{5}{9} \, \sqrt{73} + \frac{3}{4}} -+ -+.. _installation: -+ -+Instalação -+========== -+ -+Se você não tem o Sage instalado em um computador e quer apenas -+experimentar alguns comandos, use o Sage através do site -+http://www.sagenb.org. -+ -+Veja o guia de instalação do Sage na seção de documentação na página -+principal do Sage [SA]_ para instruções de como instalar o Sage no seu -+computador. Aqui faremos apenas alguns comentários. -+ -+#. O arquivo para download do Sage vem com "baterias incluídas". Em -+ outras palavras, embora o Sage use o Python, IPython, PARI, GAP, -+ Singular, Maxima, NTL, GMP, e uma série de outros programas, você -+ não precisa instalá-los separadamente pois eles estão incluídos no -+ Sage. Todavia, para usar alguns recursos, por exemplo, o Macaulay -+ ou o KASH, você precisa instalar pacotes de software adicionais ou -+ ter os programas necessários já instalados no seu computador. O -+ Macaulay e o KASH estão disponíveis como pacotes adicionais do Sage -+ (para uma lista de pacotes adicionais, digite ``sage -optional``, -+ ou visite a seção "Download" na página do Sage na internet). -+ -+#. A versão pré-compilada do Sage (disponível na página do Sage na -+ internet) pode ser mais fácil e rápida para instalar do que a -+ versão obtida compilando o código fonte. -+ -+#. Se você quiser usar o pacote SageTeX (que permite inserir -+ cálculos do Sage em um arquivo LaTeX), você deve tornar -+ o SageTex disponível para a sua distribuição TeX. Para fazer isso, -+ consulte a seção "Make SageTex known to TeX" no `Sage installation -+ guide `_. O procedimento é bem -+ simples; você precisa apenas definir algumas variáveis no seu -+ sistema ou copiar um arquivo para um diretório onde o TeX poderá -+ encontrá-lo. -+ -+ A documentação para usar o SageTex está disponível em -+ ``$SAGE_ROOT/local/share/texmf/tex/generic/sagetex/``, onde -+ ``$SAGE_ROOT`` refere-se ao diretório onde você instalou o Sage -+ -- por exemplo, ``/opt/sage-4.2.1``. -+ -+Formas de usar o Sage -+===================== -+ -+Você pode usar o Sage de diversas formas. -+ -+ -+- **Interface gráfica Notebook:** veja a seção sobre o Notebook em -+ :ref:`section-notebook`, -+ -+- **Linha de comando interativa:** veja -+ :ref:`chapter-interactive_shell`, -+ -+- **Programas:** escrevendo programas interpretados e compilados em -+ Sage (veja :ref:`section-loadattach` e :ref:`section-compile`), e -+ -+- **Scripts:** escrevendo scripts em Python que usam a biblioteca do -+ Sage (veja :ref:`section-standalone`). -+ -+ -+Objetivos do Sage a longo prazo -+=============================== -+ -+- **Útil**: O público alvo do Sage são estudantes de matemática -+ (desde o ensino médio até a pós-graduação), professores, e -+ pesquisadores em matemática. O objetivo é fornecer um software que -+ possa ser usado para explorar e experimentar construções matemáticas -+ em álgebra, geometria, teoria de números, cálculo, computação -+ numérica, etc. O Sage torna mais fácil a experimentação com objetos -+ matemáticos de forma interativa. -+ -+- **Eficiente:** Ser rápido. O Sage usa software bastante otimizado -+ como o GMP, PARI, GAP, e NTL, e portanto é muito rápido em certas -+ operações. -+ -+- **Gratuito e de código aberto:** O código fonte deve ser amplamente -+ disponível e legível, de modo que os usuários possam entender o que -+ o software realmente faz e possam facilmente estendê-lo. Da mesma -+ forma que matemáticos ganham entendimento sobre um teorema lendo -+ cuidadosamente a sua demonstração, as pessoas que fazem cálculos -+ deveriam poder entender como os cálculos são feitos lendo o código -+ fonte e seus comentários. Se você usar o Sage para fazer cálculos em -+ um artigo que seja publicado, você pode ter certeza que os leitores -+ sempre terão livre acesso ao Sage e seu código fonte, e você tem até -+ mesmo permissão para arquivar e redistribuir a versão do Sage que -+ você utilizou. -+ -+- **Fácil de compilar:** O Sage deve ser fácil de compilar a partir -+ do código fonte para usuários de Linux, OS X e Windows. Isso -+ fornece mais flexibilidade para os usuários modificarem o sistema. -+ -+- **Cooperação:** Fornecer uma interface robusta para outros sistemas -+ computacionais, incluindo PARI, GAP, Singular, Maxima, KASH, Magma, -+ Maple e Mathematica. O Sage foi concebido para unificar e estender -+ outros softwares de matemática existentes. -+ -+- **Bem documentado:** Tutorial, guia de programação, manual de -+ referência, e how-to, com inúmeros exemplos e discussão sobre -+ conceitos matemáticos relacionados. -+ -+- **Estensível:** Ser capaz de definir novos tipos de dados ou -+ derivá-los a partir dos tipos de dados existentes, e usar programas -+ escritos em diversas outras linguagens. -+ -+- **Fácil de usar:** Deve ser fácil entender quais recursos estão -+ disponíveis para um determinado objeto e consultar a documentação e -+ o código fonte. -diff --git a/doc/pt/tutorial/latex.rst b/doc/pt/tutorial/latex.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/latex.rst -@@ -0,0 +1,515 @@ -+********************************* -+Sage, LaTeX e Companheiros -+********************************* -+ -+AUTOR: Rob Beezer (2010-05-23) -+ -+O Sage e o dialeto LaTeX do TeX tem um relacionamento sinergético -+intenso. Esta seção tem como objetivo introduzir as diversas formas de -+interação entre eles, começado pelas mais básicas e indo até as menos -+usuais. (Logo você pode não querer ler esta seção inteira na sua -+primeira passagem por este tutorial.) -+ -+Panorama Geral -+============== -+ -+Pode ser mais fácil entender os vários usos do LaTeX com um panorama -+geral sobre os três principais métodos usados pelo Sage. -+ -+#. Todo objeto no Sage possui uma representação em LaTeX. Você -+ pode acessar essa representação executando, no Notebook ou na -+ linha de comando do Sage, ``latex(foo)`` where ``foo`` é algum -+ objeto no Sage. O resultado é uma string que deve fornecer uma -+ representação razoável de ``foo`` no modo matemático em LaTeX -+ (por exemplo, quando cercado por um par de símbolos $). Alguns -+ exemplos disso seguem abaixo. -+ -+ Dessa forma, o Sage pode ser usado efetivamente para construir -+ partes de um documento LaTeX: crie ou calcule um objeto no -+ Sage, imprima ``latex()`` do objeto e copie-e-cole o resultado -+ no seu documento. -+ -+#. A interface Notebook é configurada para usar o `jsMath -+ `_ para representar -+ fórmulas matemáticas de forma clara em um web browser. O jsMath é -+ uma coleção de rotinas em JavaScript e fontes associadas. -+ Tipicamente esses fontes ficam armazenadas em um servidor e são -+ enviadas para o browser juntamente com a página onde elas estão -+ sendo usadas. No caso do Sage, o Notebook está sempre conectado a -+ um servidor usado para executar os comando do Sage, e esse servidor -+ também fornece as fontes do jsMath necessárias. Logo não é -+ necessário configurar nada mais para ter formulas matemáticas -+ representadas no seu browser quando você usa o Notebook do Sage. -+ -+ O jsMath é implementado para representar um subconjunto grande, -+ mas não completo, do TeX. Ele não suporta objetos como, por -+ exemplo, tabelas complicadas e seções, e é focado para -+ representar acuradamente pequenas fórmulas em TeX. A -+ representação automática de fórmulas matemáticas no Notebook é -+ obtida convertendo a representação ``latex()`` de um objeto -+ (como descrito acima) em uma forma de HTML mais adequada ao -+ jsMath. -+ -+ Como o jsMath usa as suas próprias fontes de tamanho variável, -+ ele é superior a outros métodos que convertem equações, ou -+ outros pequenos trechos de TeX, em imagens estáticas. -+ -+ O jsMath muito provavelmente vai ser substituído pelo MathJAX, -+ uma tecnologia similar do mesmo autor, que possui suporte -+ extenso de editoras técnicas e sociedades profissionais. -+ -+#. Na linha de comando do Sage, ou no Notebook quando o código em -+ LaTeX é complicado demais para o jsMath processar, uma -+ instalação local do LaTeX pode ser usada. O Sage inclui quase -+ tudo que você precisa para compilar e usar o Sage, mas uma -+ exceção significativa é o TeX. Então nessas situações você -+ precisa ter o TeX instalado, juntamente com algumas ferramentas -+ de conversão, para usar os recursos completos. -+ -+Aqui nós demonstramos alguns usos básicos da função ``latex()``. :: -+ -+ sage: var('z') -+ z -+ sage: latex(z^12) -+ z^{12} -+ sage: latex(integrate(z^4, z)) -+ \frac{1}{5} \, z^{5} -+ sage: latex('a string') -+ \verb|a|\phantom{x}\verb|string| -+ sage: latex(QQ) -+ \Bold{Q} -+ sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]])) -+ \left(\begin{array}{rrr} -+ 2 & 4 & 6 \\ -+ -1 & -1 & -1 -+ \end{array}\right) -+ -+A funcionalidade básica do jsMath é em sua maior parte automática no -+Notebook, mas nós podemos demonstrar esse suporte parcialmente com a -+classe ``jsMath``. A função ``eval`` dessa classe converte um objeto -+do Sage em sua representação LaTeX e adiciona HTML que por sua vez -+evoca a classe "matemática" do CSS, a qual então emprega o jsMath. :: -+ -+ sage: from sage.misc.latex import JSMath -+ sage: js = JSMath() -+ sage: var('z') -+ z -+ sage: js(z^12) -+
\newcommand{\Bold}[1]{\mathbf{#1}}z^{12}
-+ sage: js(QQ) -+
\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}
-+ sage: js(ZZ[x]) -+
\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]
-+ sage: js(integrate(z^4, z)) -+
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{5} \, z^{5}
-+ -+Uso Básico -+========== -+ -+Como indicado acima, a forma mais simples de explorar o suporte do -+Sage para o LaTeX é usando a função ``latex()`` para criar código -+LaTeX para representar objetos matemáticos. Essas strings podem então -+ser incorporadas em documentos LaTeX. Isso funciona igualmente no -+Notebook ou na linha de comando do Sage. -+ -+No outro extremo está o comando ``view()``. Na linha de comando do -+Sage o comando ``view(foo)`` irá criar a representação em LaTeX de -+``foo``, incorporar isso em um documento simples em LaTeX, e então -+processar o documento usando o LaTeX em seu sistema. Por fim, o -+visualizador apropriado será aberto para apresentar o documento -+gerado. Qual versão do TeX é usada, e portanto as opções para a saída -+e visualizador, podem ser personalizados (veja -+:ref:`sec-custom-processing`). -+ -+No Notebook, o comando ``view(foo)`` cria uma combinação apropriada de -+HTML e CSS para que o jsMath mostre a representação em LaTeX na folha -+de trabalho. Para o usuário, ele simplesmente cria uma versão -+cuidadosamente formatada do resultado, distinta da saída padrão em -+modo texto do Sage. Nem todo objeto no Sage possui uma representação -+em LaTeX adequada às capacidades limitadas do jsMath. Nesses casos, a -+interpretação pelo jsMath pode ser deixada de lado, e com isso o LaTeX -+do sistema é chamado, e o resultado dessa chamada é convertido em uma -+imagem que é inserida na folha de trabalho. Como alterar e controlar -+esse processo é discutido abaixo na seção -+:ref:`sec-custom-generation`. -+ -+O comando interno ``pretty_print()`` ilustra a conversão de objetos do -+Sage para HTML que emprega o jsMath no Notebook. :: -+ -+ sage: from sage.misc.latex import pretty_print -+ sage: pretty_print(x^12) -+ \newcommand{\Bold}[1]{\mathbf{#1}}x^{12} -+ sage: pretty_print(integrate(sin(x), x)) -+ \newcommand{\Bold}[1]{\mathbf{#1}}-\cos\left(x\right) -+ -+O Notebook tem outros dois recursos para empregar o TeX. O primeiro é -+o botão "Typeset" bem acima da primeira célula da folha de trabalho, à -+direita dos quatro menus de opções. Quando selecionado, o resultado de -+qualquer cálculo vai ser interpretado pelo jsMath. Note que esse -+efeito não é retroativo -- células calculadas anteriormente precisam -+ser recalculadas para ter o resultado representado pelo jsMath. -+Essencialmente, selecionar o botão "Typeset" é equivalente a aplicar o -+comando ``view()`` ao resultado de cada célula. -+ -+Um segundo recurso disponível no Notebook é possibilidade de inserir -+código TeX para fazer anotações na folha de trabalho. Quando o cursos -+esta posicionado entre células de modo que uma barra azul fica -+visível, então shift-click irá abrir um mini processador de texto, -+TinyMCE. Isso permite digitar texto, usando um editor WSISYG para -+criar HTML e CSS. Logo é possível inserir texto formatado para -+complementar a folha de trabalho. Todavia, texto entre símbolos $, ou -+$$, é interpretado pelo jsMath como "inline" ou "display math" -+espectivamente. -+ -+.. _sec-custom-generation: -+ -+Personalizando a Criação de Código LaTeX -+======================================== -+ -+Exitem várias formas de personalizar o código LaTeX gerado pelo -+comando ``latex()``. No Notebook e na linha de comando existe um -+objeto pré-definido chamado ``latex`` que possui diversos métodos, os -+quais você pode listar digitando ``latex.``, seguido da tecla tab -+(note a presença do ponto). -+ -+Um bom exemplo é o método ``latex.matrix_delimiters``. Ele pode ser -+usado para alterar a notação de matrizes -- parênteses grandes, -+colchetes, barras verticais. Nenhuma noção de estilo é enfatizada, -+você pode configurar como desejado. Observe como as barras invertidas -+usadas em LaTeX requerem uma barra adicional de modo que elas possam -+ser interpretadas (escaped) corretamente em uma string do Python. :: -+ -+ sage: A = matrix(ZZ, 2, 2, range(4)) -+ sage: latex(A) -+ \left(\begin{array}{rr} -+ 0 & 1 \\ -+ 2 & 3 -+ \end{array}\right) -+ sage: latex.matrix_delimiters(left='[', right=']') -+ sage: latex(A) -+ \left[\begin{array}{rr} -+ 0 & 1 \\ -+ 2 & 3 -+ \end{array}\right] -+ sage: latex.matrix_delimiters(left='\\{', right='\\}') -+ sage: latex(A) -+ \left\{\begin{array}{rr} -+ 0 & 1 \\ -+ 2 & 3 -+ \end{array}\right\} -+ -+O método ``latex.vector_delimiters`` funciona de forma similar. -+ -+A forma como anéis e corpos comuns podem ser representados pode ser -+controlada pelo método ``latex.blackboard_bold``. Esses conjuntos são -+representados por padrão em negrito, mas podem opcionalmente ser -+escritos em letras duplas como é comum em trabalhos escritos. Isso é -+obtido redefinindo a macro ``\Bold{}`` que faz parte do Sage. :: -+ -+ sage: latex(QQ) -+ \Bold{Q} -+ sage: from sage.misc.latex import JSMath -+ sage: js=JSMath() -+ sage: js(QQ) -+
\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}
-+ sage: latex.blackboard_bold(True) -+ sage: js(QQ) -+
\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}
-+ sage: latex.blackboard_bold(False) -+ -+É possível aproveitar os recursos do TeX adicionando novas macros e -+novos pacotes. Primeiro, macros individuais podem ser adicionadas para -+serem usadas quando o jsMath interpreta pequenos trechos de códigos -+TeX no Notebook. :: -+ -+ sage: latex.extra_macros() -+ '' -+ sage: latex.add_macro("\\newcommand{\\foo}{bar}") -+ sage: latex.extra_macros() -+ '\\newcommand{\\foo}{bar}' -+ sage: var('x y') -+ (x, y) -+ sage: latex(x+y) -+ x + y -+ sage: from sage.misc.latex import JSMath -+ sage: js=JSMath() -+ sage: js(x+y) -+
\newcommand{\Bold}[1]{\mathbf{#1}}\newcommand{\foo}{bar}x + y
-+ -+Macros adicionais usadas dessa forma serão também usadas eventualmente -+se a versão do TeX no seu sistema for usada para lidar com algo muito -+complicado para o jsMath. O comando ``latex_extra_preamble`` é usado -+para construir o preambulo de um documento completo em LaTeX. -+Ilustramos a seguir como fazer isso. Novamente note a necessidade de -+barras invertidas duplas nas strings do Python. :: -+ -+ -+ sage: latex.extra_macros('') -+ sage: latex.extra_preamble('') -+ sage: from sage.misc.latex import latex_extra_preamble -+ sage: print latex_extra_preamble() -+ \newcommand{\ZZ}{\Bold{Z}} -+ ... -+ \newcommand{\Bold}[1]{\mathbf{#1}} -+ sage: latex.add_macro("\\newcommand{\\foo}{bar}") -+ sage: print latex_extra_preamble() -+ \newcommand{\ZZ}{\Bold{Z}} -+ ... -+ \newcommand{\Bold}[1]{\mathbf{#1}} -+ \newcommand{\foo}{bar} -+ -+Novamente, para expressões grandes ou mais complicadas do LaTeX, é -+possível adicionar pacotes (ou qualquer outra coisa) ao preambulo do -+arquivo LaTeX. Qualquer coisa pode ser incorporada no preambulo com o -+comando ``latex.add_to_preamble``, e o comando mais especializado -+``latex.add_package_to_preamble_if_available`` irá primeiro verificar -+se certo pacote está realmente disponível antes de adicioná-lo ao -+preambulo -+ -+Agora adicionamos o pacote geometry ao preambulo e usamos ele para -+definir o tamanho da região na página que o TeX vai usar -+(efetivamente definido as margens). Novamente, observe a necessidade -+de barras duplas nas strings do Python. :: -+ -+ -+ sage: from sage.misc.latex import latex_extra_preamble -+ sage: latex.extra_macros('') -+ sage: latex.extra_preamble('') -+ sage: latex.add_to_preamble('\\usepackage{geometry}') -+ sage: latex.add_to_preamble('\\geometry{letterpaper,total={8in,10in}}') -+ sage: latex.extra_preamble() -+ '\\usepackage{geometry}\\geometry{letterpaper,total={8in,10in}}' -+ sage: print latex_extra_preamble() -+ \usepackage{geometry}\geometry{letterpaper,total={8in,10in}} -+ \newcommand{\ZZ}{\Bold{Z}} -+ ... -+ \newcommand{\Bold}[1]{\mathbf{#1}} -+ -+Um pacote pode ser adicionado juntamente com a verificação de sua -+existência, da seguinte forma. Como um exemplo, nós ilustramos uma -+tentativa de adicionar ao preambulo um pacote que supostamente não -+existe. :: -+ -+ sage: latex.extra_preamble('') -+ sage: latex.extra_preamble() -+ '' -+ sage: latex.add_to_preamble('\\usepackage{foo-bar-unchecked}') -+ sage: latex.extra_preamble() -+ '\\usepackage{foo-bar-unchecked}' -+ sage: latex.add_package_to_preamble_if_available('foo-bar-checked') -+ sage: latex.extra_preamble() -+ '\\usepackage{foo-bar-unchecked}' -+ -+.. _sec-custom-processing: -+ -+Personalizando o Processamento em LaTeX -+======================================= -+ -+É também possível controlar qual variação do TeX é usada quando a -+versão do sistema for evocada, logo influenciando também o resultado. -+De forma similar, é também possível controlar quando o Notebook irá -+usar o jsMath (trechos simples em TeX) ou a versão do TeX do sistema -+(expressões mais complicadas). -+ -+O comando ``latex.engine()`` pode ser usado para controlar de os -+executáveis ``latex``, ``pdflatex`` ou ``xelatex`` do sistema são -+usados para processar expressões mais complicadas. Quando ``view()`` é -+chamado na linha de comando do Sage e o processador é definido como -+``latex``, um arquivo dvi é produzido e o Sage vai usar um -+visualizador de dvi (como o xdvi) para apresentar o resultado. Por -+outro lado, usando ``view()`` na linha de comando do Sage, quando o -+processador é definido como ``pdflatex``, irá produzir um PDF e o Sage vai -+executar o programa disponível no seu sistema para visualizar arquivos -+PDF (acrobat, okular, evince, etc.). -+ -+No Notebook, é necessário interver na decisão de se o jsMath vai -+interpretar trechos em TeX, ou se o LaTeX do sistema deve fazer o -+trabalho se o código em LaTeX for complicado demais. O dispositivo é -+uma lista de strings, que se forem encontradas em um trecho de código -+LaTeX sinalizam para o Notebook usar o LaTeX (ou qualquer executável -+que for definido pelo comando ``latex.engine()``). Essa lista é -+gerenciada pelos comandos ``latex.add_to_jsmath_avoid_list`` e -+``latex.jsmath_avoid_list``. :: -+ -+ sage: latex.jsmath_avoid_list([]) -+ sage: latex.jsmath_avoid_list() -+ [] -+ sage: latex.jsmath_avoid_list(['foo', 'bar']) -+ sage: latex.jsmath_avoid_list() -+ ['foo', 'bar'] -+ sage: latex.add_to_jsmath_avoid_list('tikzpicture') -+ sage: latex.jsmath_avoid_list() -+ ['foo', 'bar', 'tikzpicture'] -+ sage: latex.jsmath_avoid_list([]) -+ sage: latex.jsmath_avoid_list() -+ [] -+ -+Suponha que uma expressão em LaTeX é produzida no Notebook com o -+comando ``view()`` ou enquanto o botão "Typeset" está selecionado, e -+então reconhecida, através da "lista de comandos a serem evitados no -+jsMath", como necessitando a versão do LaTeX no sistema. Então o -+executável selecionado (como especificado por ``latex.engine()``) irá -+processar o código em LaTeX. Todavia, em vez de então abrir um -+visualizador externo (o que é o comportamento na linha de comando), o -+Sage irá tentar converter o resultado em uma imagem, que então é -+inserida na folha de trabalho como o resultado da célula. -+ -+Exatamente como essa conversão é feita depende de vários fatores -- -+qual executável você especificou como processador e quais utilitários -+de conversão estão disponíveis no seu sistema. Quatro conversores -+usuais que irão cobrir todas as ocorrências são o ``dvips``, -+``ps2pdf``, e ``dvipng``, e do pacote ``ImageMagick``, o ``convert``. -+O objetivo é produzir um arquivo PNG para ser inserido de volta na -+folha de trabalho. Quando uma expressão em LaTeX pode ser convertida -+com sucesso em um arquivo dvi pelo processador LaTeX, então o dvipng -+deve dar conta da conversão. Se a expressão em LaTeX e o processador -+especificado criarem um arquivo dvi com conteúdo especial que o dvipng -+não pode converter, então o dvips vai criar um arquivo PostScript. -+Esse arquivo PostScript, ou um PDF criado por pelo processador -+``pdflatex``, é então convertido em um arquivo dvi pelo programa -+``convert``. A presença de dois desses conversores pode ser testado -+com as rotinas ``have_dvipng()`` e ``have_convert()``. -+ -+Essas conversões são feitas automaticamente se você tiver os -+conversores necessários instalados; se não, então uma mensagem de erro -+é impressa dizendo o que está faltando e onde obter. -+ -+Para um exemplo concreto de como expressões complicadas em LaTeX podem -+ser processadas, veja o exemplo na próxima seção -+(:ref:`sec-tkz-graph`) para usar o pacote ``tkz-graph`` para produzir -+ilustrações de grafos combinatoriais de alta qualidade. Para outros -+exemplos, existem alguns casos teste incluídos no Sage. Para usá-los, -+é necessário importar o objeto ``sage.misc.latex.latex_examples``, que -+é uma instância da classe ``sage.misc.latex.LatexExamples``, como -+mostrado abaixo. Essa classe possui exemplos de diagramas comutativos, -+grafos combinatoriais, teoria de nós e pstricks, os quais -+respectivamente testam os seguintes pacotes: xy, tkz-graph, xypic, -+pstricks. Após importar o objeto, use completamento tab em -+``latex_examples`` para ver os exemplos disponíveis. Ao carregar um -+exemplo você irá obter explicações sobre o que é necessário para fazer -+o conteúdo do exemplo ser exibido corretamente. Para de fato ver os -+exemplos, é necessário usar ``view()`` (uma vez que o preambulo, -+processador, etc. estão configurados corretamente). -+ -+:: -+ -+ sage: from sage.misc.latex import latex_examples -+ sage: latex_examples.diagram() -+ LaTeX example for testing display of a commutative diagram produced -+ by xypic. -+ -+ To use, try to view this object -- it won't work. Now try -+ 'latex.add_to_preamble("\\usepackage[matrix,arrow,curve,cmtip]{xy}")', -+ and try viewing again -- it should work in the command line but not -+ from the notebook. In the notebook, run -+ 'latex.add_to_jsmath_avoid_list("xymatrix")' and try again -- you -+ should get a picture (a part of the diagram arising from a filtered -+ chain complex). -+ -+.. _sec-tkz-graph: -+ -+Exemplo: Grafos Combinatoriais com tkz-graph -+============================================ -+ -+Ilustrações de alta qualidade de grafos combinatoriais (daqui por -+diante, simplesmente grafos) são possíveis com o pacote ``tkz-graph``. -+Esse pacote baseia-se no ``tikz`` front-end da biblioteca ``pgf``. -+Logo todos esses componentes precisam ser parte de uma instalação -+completa do LaTeX em seu sistema, e pode acontecer que alguns desses -+componentes não estejam em sua versão mais recente em algumas -+distribuições do TeX. Logo, para melhores resultados, seria necessário -+ou recomendável instalar esses pacotes como parte do seu diretório -+texmf pessoal. Criar, manter e personalizar uma instalação do TeX no -+sistema ou em um diretório pessoal vai além do escopo deste documento, -+mas deve ser fácil encontrar instruções para isso. Os arquivos -+necessários estão listados em :ref:`sec-system-wide-tex`. -+ -+Portanto, para começar precisamos nos certificar que os pacotes -+relevantes estão incluídos adicionando-os ao preambulo do eventual -+documento LaTeX. As imagens dos grafos não são formadas corretamente -+quando um arquivo dvi é usando como formato intermediário, logo é -+melhor definir o processador do LaTeX como ``pdflatex``. A esta altura -+um comando como ``view(graphs.CompleteGraph(4))`` deve funcionar na -+linha de comando do Sage e produzir um PDF com a imagem completa do -+grafo `K_4`. -+ -+Para uma experiência semelhante no Notebook, é necessário desabilitar -+o processador jsMath para o código LaTeX do grafo usando a "lista de -+comandos a serem evitados pelo jsMath". Grafos são criados usando o -+environment ``tikzpicture``, logo essa uma boa escolha para uma string -+a ser incluída na lista que acabamos de mencionar. Agora, -+``view(graphs.CompleteGraph(4))`` em uma folha de trabalho deve -+executar o pdflatex para criar um PDF e então o programa ``convert`` -+para obter um gráfico PNG que vai ser inserido na folha de trabalho. -+Os seguintes comandos ilustram os passos para obter grafos processados -+pelo LaTeX no Notebook. :: -+ -+ sage: from sage.graphs.graph_latex import setup_latex_preamble -+ sage: setup_latex_preamble() -+ sage: latex.extra_preamble() # random - depends on system's TeX installation -+ '\\usepackage{tikz}\n\\usepackage{tkz-graph}\n\\usepackage{tkz-berge}\n' -+ sage: latex.engine('pdflatex') -+ sage: latex.add_to_jsmath_avoid_list('tikzpicture') -+ sage: latex.jsmath_avoid_list() -+ ['tikzpicture'] -+ -+Agora, um comando como ``view(graphs.CompleteGraph(4))`` deve produzir -+um gráfico do grafo no Notebook, tendo usado ``pdflatex`` para -+processar os comandos do ``tkz-graph`` para construir o grafo. Note -+que há diversas opções que afetam o resultado do gráfico obtido usando -+o LaTeX via ``tkz-graph``, o que mais uma vez está além do escopo -+desta seção (veja a seção do Manual de Referência com título "Opções -+do LaTeX para Grafos" para instruções e detalhes). -+ -+.. _sec-system-wide-tex: -+ -+Uma Instalação Completa do TeX -+============================== -+Vários dos recursos avançados de integração do TeX com o Sage requerem -+uma instalação do TeX em seu sistema. Várias versões do Linux possuem -+pacotes do TeX baseados no TeX-live, para o OSX existe o TeXshop e -+para o windows existe o MikTex. O utilitário ``convert`` é parte do -+`ImageMagick `_ (que deve ser um pacote -+na sua versão do Linux ou ser fácil de instalar), e os três programas -+``dvipng``, ``ps2pdf``, e ``dvips`` podem estar incluídos na sua -+distribuição do TeX. Os dois primeiros podem também ser obtidos em, -+respectivamente, http://sourceforge.net/projects/dvipng/ e como parte -+do `Ghostscript `_. -+ -+A criação de grafos combinatoriais requer uma versão recente da -+biblioteca PGF, e os arquivos ``tkz-graph.sty``, ``tkz-arith.sty`` e -+talvez ``tkz-berge.sty``, que estão disponíveis em `Altermundus site -+`_. -+ -+Programas Externos -+================== -+ -+Existem três programas disponíveis para integrar ainda mais o TeX e o -+Sage. O primeiro é o sagetex. Uma descrição concisa do sagetex é que -+ele é uma coleção de macros do TeX que permitem incluir em um -+documento LaTeX instruções para usar o Sage para calcular vários -+objetos, e/ou formatar objetos usando o comando ``latex()`` existente -+no Sage. Logo, como um passo intermediário para compilar um documento -+LaTeX, todos os recursos computacionais e de formatação do Sage podem -+ser executados automaticamente. Como um exemplo, um exame matemático -+pode manter uma correspondência entre questões e respostas usando o -+sagetex para fazer cálculos com o Sage. Veja :ref:`sec-sagetex` para -+mais informações. -+ -+O tex2sws começa com um documento LaTeX, mas define environments -+adicionais para inserir código em Sage. Quando processado com as -+ferramentas adequadas, o resultado é uma folha de trabalho do Sage, -+com conteúdo apropriadamente formatado para o jsMath e com código em -+Sage incorporado como células de entrada. Então um livro texto ou -+artigo pode ser criado em LaTeX, ter blocos de código em Sage -+incluídos, e o documento todo pode ser transformado em uma folha de -+trabalho do Sage onde o texto matemático é bem formatado e os blocos -+de código em Sage podem ser facilmente executados. Atualmente em -+desenvolvimento, veja `tex2sws @ BitBucket -+`_ para mais informações. -+ -+O sws2tex reverte o processo partindo de uma folha de trabalho do Sage -+e convertendo o conteúdo para LaTeX para ser posteriormente processado -+com as ferramentas disponíveis para documentos em LaTeX. Atualmente em -+desenvolvimento, veja `sws2tex @ BitBucket -+`_ para mais informações. -diff --git a/doc/pt/tutorial/programming.rst b/doc/pt/tutorial/programming.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/programming.rst -@@ -0,0 +1,850 @@ -+*********** -+Programação -+*********** -+ -+.. _section-loadattach: -+ -+Carregando e Anexando Arquivos do Sage -+====================================== -+ -+A seguir ilustramos como carregar no Sage programas escritos em um -+arquivo separado. Crie um arquivo chamado ``example.sage`` com o -+seguinte conteúdo: -+ -+.. skip -+ -+:: -+ -+ print "Hello World" -+ print 2^3 -+ -+Você pode ler e executar o arquivo ``example.sage`` usando o comando -+``load``. -+ -+.. skip -+ -+:: -+ -+ sage: load "example.sage" -+ Hello World -+ 8 -+ -+Você também pode anexar um arquivo em Sage à sessão em execução usando -+o comando ``attach``. -+ -+.. skip -+ -+:: -+ -+ sage: attach "example.sage" -+ Hello World -+ 8 -+ -+Agora se você alterar ``example.sage`` e adicionar uma linha em branco -+(por exemplo), então o conteúdo de ``example.sage`` será -+automaticamente recarregado no Sage. -+ -+Em particular, ``attach`` automaticamente recarrega um arquivo toda -+vez que ele for modificado, o que é útil para desenvolver e testar um -+programa, enquanto ``load`` carrega o arquivo apenas uma vez. -+ -+Quando o Sage carrega ``example.sage`` ele converte esse arquivo para -+o Python, o qual é então executado pelo interpretador do Python. Essa -+conversão é mínima; ela essencialmente consiste em encapsular inteiros -+em ``Integer()``, números float em ``RealNumber()``, substituir ``^`` -+por ``**``, e substituir, por exemplo, ``R.2`` por ``R.gen(2)``. A -+versão convertida de ``example.sage`` é armazenada no mesmo diretório -+de ``example.sage`` e é chamada ``example.sage.py``. Esse arquivo -+contém o seguinte código: -+ -+:: -+ -+ print "Hello World" -+ print Integer(2)**Integer(3) -+ -+Inteiros literais são encapsulados e ``^`` é substituído por ``**``. -+(Em Python, ``^`` significa "ou exclusivo" e ``**`` significa -+"exponenciação".) -+ -+Esse "preparsing" está implementado em ``sage/misc/interpreter.py``.) -+ -+Você pode colar código tabulado com muitas linhas no Sage desde que -+existam linhas em branco separando blocos de código (isso não é -+necessário em arquivos). Todavia, a melhor forma de adicionar tal -+código a uma sessão do Sage é salvá-lo em um arquivo e usar -+``attach``, como descrito anteriormente. -+ -+ -+.. _section-compile: -+ -+Criando Código Compilado -+======================== -+ -+Velocidade é crucial em cálculos matemáticos. Embora o Python seja uma -+linguagem conveniente de alto nível, certos cálculos podem ser várias -+vezes mais rápidos do que em Python se eles forem implementados usando -+tipos estáticos em uma linguagem compilada. Alguns aspectos do Sage -+seriam muito lentos se eles fossem escritos inteiramente em Python. -+Para lidar com isso, o Sage suporta uma "versão" compilada do Python -+chamada Cython ([Cyt]_ and [Pyr]_). O Cython é simultaneamente similar -+ao Python e ao C. A maior parte das construções em Python, incluindo -+"list comprehensions", expressões condicionais, código como ``+=`` são -+permitidos; você também pode importar código que você escreveu em -+outros módulos em Python. Além disso, você pode declarar variáveis em -+C arbitrárias, e qualquer chamada de bibliotecas em C pode ser feita -+diretamente. O código resultante é convertido para C e compilado -+usando um compilador para C. -+ -+Para criar o seu próprio código compilado em Sage, nomeie o arquivo -+com uma extensão ``.spyx`` (em vez de ``.sage``). Se você está -+trabalhando na linha de comando, você pode anexar e carregar código -+compilado exatamente como se faz com código interpretado (no momento, -+anexar e carregar código em Cython não é suportado no Notebook). A -+compilação é realizada implicitamente sem que você tenha que fazer -+qualquer coisa explicitamente. Veja -+``$SAGE_ROOT/examples/programming/sagex/factorial.spyx`` para um -+exemplo de uma implementação compilada para a função fatorial que usa -+diretamente a biblioteca GMP em C. Experimente o seguinte, usando cd, -+vá para o diretório ``$SAGE_ROOT/examples/programming/sagex/``, e -+então faça o seguinte: -+ -+.. skip -+ -+:: -+ -+ sage: load "factorial.spyx" -+ *************************************************** -+ Recompiling factorial.spyx -+ *************************************************** -+ sage: factorial(50) -+ 30414093201713378043612608166064768844377641568960512000000000000L -+ sage: time n = factorial(10000) -+ CPU times: user 0.03 s, sys: 0.00 s, total: 0.03 s -+ Wall time: 0.03 -+ -+Aqui o sufixo L indica um "long integer" do Python (veja -+:ref:`section-mathannoy`). -+ -+Note que o Sage vai recompilar ``factorial.spyx`` se você encerrar e -+reiniciar o Sage. A biblioteca compilada e compartilhada é armazenada -+em ``$HOME/.sage/temp/hostname/pid/spyx``. Esses arquivos são -+excluídos quando você encerra o Sage. -+ -+Nenhum pré-processador (preparsing) é aplicado em arquivos spyx, por -+exemplo, ``1/3`` vai resultar em 0 em um arquivo spyx em vez do número -+racional :math:`1/3`. Se ``foo`` é uma função da biblioteca Sage, para -+usá-la em um arquivo spyx importe ``sage.all`` e use ``sage.all.foo``. -+ -+:: -+ -+ import sage.all -+ def foo(n): -+ return sage.all.factorial(n) -+ -+Acessando Funções em C em Arquivos Separados -+-------------------------------------------- -+ -+É fácil também acessar funções em C definidas em arquivos \*.c -+separados. Aqui vai um exemplo. Crie os arquivos ``test.c`` e -+``test.spyx`` no mesmo diretório contendo: -+ -+Código C puro: ``test.c`` -+ -+:: -+ -+ int add_one(int n) { -+ return n + 1; -+ } -+ -+Código Cython: ``test.spyx``: -+ -+:: -+ -+ cdef extern from "test.c": -+ int add_one(int n) -+ -+ def test(n): -+ return add_one(n) -+ -+Então o seguinte funciona: -+ -+.. skip -+ -+:: -+ -+ sage: attach "test.spyx" -+ Compiling (...)/test.spyx... -+ sage: test(10) -+ 11 -+ -+Se uma biblioteca ``foo`` adicional é necessária para compilar código -+em C gerado a partir de um arquivo em Cython, adicione a linha ``clib -+foo`` no arquivo fonte em Cython. De forma similar, um arquivo em C -+adicional ``bar`` pode ser incluído na compilação declarando ``cfile -+bar``. -+ -+.. _section-standalone: -+ -+Scripts Independentes em Python/Sage -+==================================== -+ -+O seguinte script em Sage fatora inteiros, polinômios, etc: -+ -+:: -+ -+ #!/usr/bin/env sage -python -+ -+ import sys -+ from sage.all import * -+ -+ if len(sys.argv) != 2: -+ print "Usage: %s "%sys.argv[0] -+ print "Outputs the prime factorization of n." -+ sys.exit(1) -+ -+ print factor(sage_eval(sys.argv[1])) -+ -+Para usar esse script, sua ``SAGE_ROOT`` precisa estar na sua variável -+PATH. Se o script acima for chamado ``factor``, aqui está um exemplo -+de como usá-lo: -+ -+:: -+ -+ bash $ ./factor 2006 -+ 2 * 17 * 59 -+ bash $ ./factor "32*x^5-1" -+ (2*x - 1) * (16*x^4 + 8*x^3 + 4*x^2 + 2*x + 1) -+ -+Tipo de Dados -+============= -+ -+Cada objeto em Sage possui um tipo bem definido. O Python possui -+diversos tipos de dados, e a biblioteca do Sage adiciona ainda mais. -+Os tipos de dados de Python incluem strings, listas, tuplas, inteiros -+e floats, como ilustrado: -+ -+:: -+ -+ sage: s = "sage"; type(s) -+ -+ sage: s = 'sage'; type(s) # you can use either single or double quotes -+ -+ sage: s = [1,2,3,4]; type(s) -+ -+ sage: s = (1,2,3,4); type(s) -+ -+ sage: s = int(2006); type(s) -+ -+ sage: s = float(2006); type(s) -+ -+ -+Além disso, o Sage acrescenta vários outros tipos. Por exemplo, -+espaços vetoriais: -+ -+:: -+ -+ sage: V = VectorSpace(QQ, 1000000); V -+ Vector space of dimension 1000000 over Rational Field -+ sage: type(V) -+ -+ -+Apenas certas funções podem ser aplicadas sobre ``V``. Em outros -+softwares de matemática, essas seriam chamadas usando a notação -+"funcional" ``foo(V,...)``. Em Sage, algumas funções estão anexadas ao -+tipo (ou classe) de ``V``, e são chamadas usando uma sintaxe orientada -+a objetos como em Java ou C++, por exemplo, ``V.foo()``. Isso ajuda a -+manter o espaço de variáveis global sem milhares de funções, e permite -+que várias funções diferentes com comportamento diferente possam ser -+chamadas foo, sem a necessidade de usar um mecanismo de identificação -+de tipos (ou casos) para decidir qual chamar. Além disso, se você -+reutilizar o nome de uma função, essa função continua ainda disponível -+(por exemplo, se você chamar algo ``zeta``, e então quiser calcular o -+valor da função zeta de Riemann em 0.5, você continua podendo digitar -+``s=.5; s.zeta()``). -+ -+:: -+ -+ sage: zeta = -1 -+ sage: s=.5; s.zeta() -+ -1.46035450880959 -+ -+Em alguns casos muito comuns, a notação funcional usual é também -+suportada por conveniência e porque expressões matemáticas podem -+parecer confusas usando a notação orientada a objetos. Aqui vão alguns -+exemplos. -+ -+:: -+ -+ sage: n = 2; n.sqrt() -+ sqrt(2) -+ sage: sqrt(2) -+ sqrt(2) -+ sage: V = VectorSpace(QQ,2) -+ sage: V.basis() -+ [ -+ (1, 0), -+ (0, 1) -+ ] -+ sage: basis(V) -+ [ -+ (1, 0), -+ (0, 1) -+ ] -+ sage: M = MatrixSpace(GF(7), 2); M -+ Full MatrixSpace of 2 by 2 dense matrices over Finite Field of size 7 -+ sage: A = M([1,2,3,4]); A -+ [1 2] -+ [3 4] -+ sage: A.charpoly('x') -+ x^2 + 2*x + 5 -+ sage: charpoly(A, 'x') -+ x^2 + 2*x + 5 -+ -+Para listar todas as funções para :math:`A`, use completamento tab. -+Simplesmente digite ``A.``, então tecle ``[tab]`` no seu teclado, como -+descrito em :ref:`section-tabcompletion`. -+ -+Listas, Tuplas e Sequências -+=========================== -+ -+O tipo de dados lista armazena elementos de um tipo arbitrário. Como -+em C, C++, etc. (mas diferentemente da maioria dos sistemas de álgebra -+computacional), os elementos da lista são indexados a partir do -+:math:`0`: -+ -+:: -+ -+ sage: v = [2, 3, 5, 'x', SymmetricGroup(3)]; v -+ [2, 3, 5, 'x', Symmetric group of order 3! as a permutation group] -+ sage: type(v) -+ -+ sage: v[0] -+ 2 -+ sage: v[2] -+ 5 -+ -+(Quando se indexa uma lista, é permitido que o índice não seja um int -+do Python!) Um Inteiro do Sage (ou Racional, ou qualquer objeto que -+possua um método ``__index__``) também ira funcionar. -+ -+:: -+ -+ sage: v = [1,2,3] -+ sage: v[2] -+ 3 -+ sage: n = 2 # SAGE Integer -+ sage: v[n] # Perfectly OK! -+ 3 -+ sage: v[int(n)] # Also OK. -+ 3 -+ -+A função ``range`` cria uma lista de int's do Python (não Inteiros do -+Sage): -+ -+:: -+ -+ sage: range(1, 15) -+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] -+ -+Isso é útil quando se usa "list comprehensions" para construir listas: -+ -+:: -+ -+ sage: L = [factor(n) for n in range(1, 15)] -+ sage: print L -+ [1, 2, 3, 2^2, 5, 2 * 3, 7, 2^3, 3^2, 2 * 5, 11, 2^2 * 3, 13, 2 * 7] -+ sage: L[12] -+ 13 -+ sage: type(L[12]) -+ -+ sage: [factor(n) for n in range(1, 15) if is_odd(n)] -+ [1, 3, 5, 7, 3^2, 11, 13] -+ -+Para mais sobre como criar listas usando "list comprehensions", veja -+[PyT]_. -+ -+Fatiamento de lista (list slicing) é um recurso fantástico. Se ``L`` é -+uma lista, então ``L[m:n]`` retorna uma sub-lista de ``L`` obtida -+começando do :math:`m`-ésimo elemento e terminando no -+:math:`(n-1)`-ésimo elemento, como ilustrado abaixo. -+ -+:: -+ -+ sage: L = [factor(n) for n in range(1, 20)] -+ sage: L[4:9] -+ [5, 2 * 3, 7, 2^3, 3^2] -+ sage: print L[:4] -+ [1, 2, 3, 2^2] -+ sage: L[14:4] -+ [] -+ sage: L[14:] -+ [3 * 5, 2^4, 17, 2 * 3^2, 19] -+ -+Tuplas são semelhantes à listas, exceto que elas são imutáveis: uma -+vez criadas elas não podem ser alteradas. -+ -+:: -+ -+ sage: v = (1,2,3,4); v -+ (1, 2, 3, 4) -+ sage: type(v) -+ -+ sage: v[1] = 5 -+ Traceback (most recent call last): -+ ... -+ TypeError: 'tuple' object does not support item assignment -+ -+Sequências são um terceiro tipo de dados do Sage semelhante a listas. -+Diferentemente de listas e tuplas, Sequence não é um tipo de dados -+nativo do Python. Por definição, uma sequência é mutável, mas usando o -+método ``set_immutable`` da classe ``Sequence`` elas podem ser feitas -+imutáveis, como mostra o exemplo a seguir. Todos os elementos da -+sequência possuem um parente comum, chamado o universo da sequência. -+ -+:: -+ -+ sage: v = Sequence([1,2,3,4/5]) -+ sage: v -+ [1, 2, 3, 4/5] -+ sage: type(v) -+ -+ sage: type(v[1]) -+ -+ sage: v.universe() -+ Rational Field -+ sage: v.is_immutable() -+ False -+ sage: v.set_immutable() -+ sage: v[0] = 3 -+ Traceback (most recent call last): -+ ... -+ ValueError: object is immutable; please change a copy instead. -+ -+Sequências são derivadas de listas e podem ser usadas em qualquer -+lugar que listas são usadas. -+ -+:: -+ -+ sage: v = Sequence([1,2,3,4/5]) -+ sage: isinstance(v, list) -+ True -+ sage: list(v) -+ [1, 2, 3, 4/5] -+ sage: type(list(v)) -+ -+ -+Como um outro exemplo, bases para espaços vetoriais são sequências -+imutáveis, pois é importante que elas não sejam modificadas. -+ -+:: -+ -+ sage: V = QQ^3; B = V.basis(); B -+ [ -+ (1, 0, 0), -+ (0, 1, 0), -+ (0, 0, 1) -+ ] -+ sage: type(B) -+ -+ sage: B[0] = B[1] -+ Traceback (most recent call last): -+ ... -+ ValueError: object is immutable; please change a copy instead. -+ sage: B.universe() -+ Vector space of dimension 3 over Rational Field -+ -+Dicionários -+=========== -+ -+Um dicionário (também chamado as vezes de lista associativa) é um -+mapeamento de objetos "hashable" em objetos arbitrários. (Exemplos de -+objetos "hashable" são strings e números; veja a documentação Python -+em http://docs.python.org/tut/node7.html e -+http://docs.python.org/lib/typesmapping.html para detalhes). -+ -+:: -+ -+ sage: d = {1:5, 'sage':17, ZZ:GF(7)} -+ sage: type(d) -+ -+ sage: d.keys() -+ [1, 'sage', Integer Ring] -+ sage: d['sage'] -+ 17 -+ sage: d[ZZ] -+ Finite Field of size 7 -+ sage: d[1] -+ 5 -+ -+A terceira chave (key) ilustra como os índices de um dicionário podem -+ser complicados, por exemplo, um anel de inteiros. -+ -+Você pode transformar o dicionário acima em uma lista com os mesmos -+dados: -+ -+.. link -+ -+:: -+ -+ sage: d.items() -+ [(1, 5), ('sage', 17), (Integer Ring, Finite Field of size 7)] -+ -+É comum iterar sobre os pares em um dicionário: -+ -+:: -+ -+ sage: d = {2:4, 3:9, 4:16} -+ sage: [a*b for a, b in d.iteritems()] -+ [8, 27, 64] -+ -+Um dicionário não possui ordem, como o exemplo acima mostra. -+ -+Conjuntos -+========= -+ -+O Python possui um tipo set (conjuntos) nativo. O principal recurso -+que ele oferece é a rápida verificação se um objeto está ou não em um -+conjunto, juntamente com as operações comuns em conjuntos. -+ -+:: -+ -+ sage: X = set([1,19,'a']); Y = set([1,1,1, 2/3]) -+ sage: X -+ set(['a', 1, 19]) -+ sage: Y -+ set([1, 2/3]) -+ sage: 'a' in X -+ True -+ sage: 'a' in Y -+ False -+ sage: X.intersection(Y) -+ set([1]) -+ -+O Sage também possui o seu próprio tipo de dados para conjuntos que é -+(em alguns casos) implementado usando o tipo nativo do Python, mas -+possuir algumas funcionalidades adicionais. Crie um conjunto em Sage -+usando ``Set(...)``. Por exemplo, -+ -+:: -+ -+ sage: X = Set([1,19,'a']); Y = Set([1,1,1, 2/3]) -+ sage: X -+ {'a', 1, 19} -+ sage: Y -+ {1, 2/3} -+ sage: X.intersection(Y) -+ {1} -+ sage: print latex(Y) -+ \left\{1, \frac{2}{3}\right\} -+ sage: Set(ZZ) -+ Set of elements of Integer Ring -+ -+Iteradores -+========== -+ -+Iteradores foram adicionados recentemente ao Python e são -+particularmente úteis em aplicações matemáticas. Aqui estão vários -+exemplos; veja [PyT]_ para mais detalhes. Vamos criar um iterador -+sobre o quadrados dos números inteiros até :math:`10000000`. -+ -+:: -+ -+ sage: v = (n^2 for n in xrange(10000000)) -+ sage: v.next() -+ 0 -+ sage: v.next() -+ 1 -+ sage: v.next() -+ 4 -+ -+Criamos agora um iterador sobre os primos da forma :math:`4p+1` com -+:math:`p` também primo, e observamos os primeiros valores. -+ -+:: -+ -+ sage: w = (4*p + 1 for p in Primes() if is_prime(4*p+1)) -+ sage: w # in the next line, 0xb0853d6c is a random 0x number -+ -+ sage: w.next() -+ 13 -+ sage: w.next() -+ 29 -+ sage: w.next() -+ 53 -+ -+Certos anéis, por exemplo, corpos finitos e os inteiros possuem -+iteradores associados a eles: -+ -+:: -+ -+ sage: [x for x in GF(7)] -+ [0, 1, 2, 3, 4, 5, 6] -+ sage: W = ((x,y) for x in ZZ for y in ZZ) -+ sage: W.next() -+ (0, 0) -+ sage: W.next() -+ (0, 1) -+ sage: W.next() -+ (0, -1) -+ -+Laços, Funções, Enunciados de Controle e Comparações -+==================================================== -+ -+Nós já vimos alguns exemplos de alguns usos comuns de laços (loops) -+``for``. Em Python, um laço ``for`` possui uma estrutura tabulada, tal -+como -+ -+:: -+ -+ >>> for i in range(5): -+ print(i) -+ -+ 0 -+ 1 -+ 2 -+ 3 -+ 4 -+ -+Note que os dois pontos no final do enunciado (não existe "do" ou "od" -+como no GAP ou Maple), e a identação antes dos comandos dentro do -+laço, isto é, ``print(i)``. A tabulação é importante. No Sage, a -+tabulação é automaticamente adicionada quando você digita ``enter`` -+após ":", como ilustrado abaixo. -+ -+:: -+ -+ sage: for i in range(5): -+ ... print(i) # now hit enter twice -+ 0 -+ 1 -+ 2 -+ 3 -+ 4 -+ -+O símbolo ``=`` é usado para atribuição. -+O símbolo ``==`` é usado para verificar igualdade: -+ -+:: -+ -+ sage: for i in range(15): -+ ... if gcd(i,15) == 1: -+ ... print(i) -+ 1 -+ 2 -+ 4 -+ 7 -+ 8 -+ 11 -+ 13 -+ 14 -+ -+Tenha em mente como a tabulação determina a estrutura de blocos para -+enunciados ``if``, ``for``, e ``while``: -+ -+:: -+ -+ sage: def legendre(a,p): -+ ... is_sqr_modp=-1 -+ ... for i in range(p): -+ ... if a % p == i^2 % p: -+ ... is_sqr_modp=1 -+ ... return is_sqr_modp -+ -+ sage: legendre(2,7) -+ 1 -+ sage: legendre(3,7) -+ -1 -+ -+Obviamente essa não é uma implementação eficiente do símbolo de -+Legendre! O objetivo é ilustrar vários aspectos da programação em -+Python/Sage. A função {kronecker}, que já vem com o Sage, calcula o -+símbolo de Legendre eficientemente usando uma biblioteca em C do PARI. -+ -+Finalmente, observamos que comparações, tais como ``==``, ``!=``, -+``<=``, ``>=``, ``>``, ``<``, entre números irão automaticamente -+converter ambos os números para o mesmo tipo, se possível: -+ -+:: -+ -+ sage: 2 < 3.1; 3.1 <= 1 -+ True -+ False -+ sage: 2/3 < 3/2; 3/2 < 3/1 -+ True -+ True -+ -+Quase todos pares de objetos podem ser comparados; não se supõe que os -+objetos estejam equipados com uma ordem total. -+ -+:: -+ -+ sage: 2 < CC(3.1,1) -+ True -+ sage: 5 < VectorSpace(QQ,3) # output can be somewhat random -+ True -+ -+Use bool para desigualdades simbólicas: -+ -+:: -+ -+ sage: x < x + 1 -+ x < x + 1 -+ sage: bool(x < x + 1) -+ True -+ -+Quando se compara objetos de tipos diferentes no Sage, na maior parte -+dos casos o Sage tenta encontrar uma coação canônica para ambos os -+objetos em um parente comum (veja :ref:`section-coercion` para mais -+detalhes). Se isso for bem sucedido, a comparação é realizada entre os -+objetos que foram coagidos; se não for bem sucedido, os objetos são -+considerados diferentes. Para testar se duas variáveis fazem -+referência ao mesmo objeto use ``is``. Como se vê no próximo exemplo, -+o int ``1`` do Python é único, mas o Inteiro ``1`` do Sage não é. -+ -+:: -+ -+ sage: 1 is 2/2 -+ False -+ sage: int(1) is int(2)/int(2) -+ True -+ sage: 1 is 1 -+ False -+ sage: 1 == 2/2 -+ True -+ -+Nas duas linhas seguintes, a primeira igualdade é falsa (``False``) -+porque não existe um morfismo canônico :math:`QQ\to \GF{5}`, logo -+não há uma forma de comparar o :math:`1` em :math:`\GF{5}` com o -+:math:`1 \in \QQ`. Em contraste, existe um mapa canônico entre -+:math:`\ZZ \to \GF{5}`, logo a segunda comparação é verdadeira -+(``True``) -+ -+:: -+ -+ sage: GF(5)(1) == QQ(1); QQ(1) == GF(5)(1) -+ False -+ False -+ sage: GF(5)(1) == ZZ(1); ZZ(1) == GF(5)(1) -+ True -+ True -+ sage: ZZ(1) == QQ(1) -+ True -+ -+ATENÇÃO: Comparação no Sage é mais restritiva do que no Magma, o qual -+declara :math:`1 \in \GF{5}` igual a :math:`1 \in \QQ`. -+ -+:: -+ -+ sage: magma('GF(5)!1 eq Rationals()!1') # optional magma required -+ true -+ -+Otimização (Profiling) -+====================== -+ -+Autor desta seção: Martin Albrecht (malb@informatik.uni-bremen.de) -+ -+ "Premature optimization is the root of all evil." - Donald Knuth -+ -+As vezes é útil procurar por gargalos em programas para entender quais -+partes gastam maior tempo computacional; isso pode dar uma boa ideia -+sobre quais partes otimizar. Python e portanto Sage fornecem várias -+opções de "profiling" (esse é o nome que se dá ao processo de -+otimização). -+ -+O mais simples de usar é o comando ``prun`` na linha de comando -+interativa. Ele retorna um sumário sobre o tempo computacional -+utilizado por cada função. Para analisar (a atualmente lenta! -- na -+versão 1.0) multiplicação de matrizes sobre corpos finitos, por -+exemplo, faça o seguinte: -+ -+:: -+ -+ sage: k,a = GF(2**8, 'a').objgen() -+ sage: A = Matrix(k,10,10,[k.random_element() for _ in range(10*10)]) -+ -+.. skip -+ -+:: -+ -+ sage: %prun B = A*A -+ 32893 function calls in 1.100 CPU seconds -+ -+ Ordered by: internal time -+ -+ ncalls tottime percall cumtime percall filename:lineno(function) -+ 12127 0.160 0.000 0.160 0.000 :0(isinstance) -+ 2000 0.150 0.000 0.280 0.000 matrix.py:2235(__getitem__) -+ 1000 0.120 0.000 0.370 0.000 finite_field_element.py:392(__mul__) -+ 1903 0.120 0.000 0.200 0.000 finite_field_element.py:47(__init__) -+ 1900 0.090 0.000 0.220 0.000 finite_field_element.py:376(__compat) -+ 900 0.080 0.000 0.260 0.000 finite_field_element.py:380(__add__) -+ 1 0.070 0.070 1.100 1.100 matrix.py:864(__mul__) -+ 2105 0.070 0.000 0.070 0.000 matrix.py:282(ncols) -+ ... -+ -+Aqui ``ncalls`` é o números de chamadas, ``tottime`` é o tempo total -+gasto por uma determinada função (excluíndo o tempo gasto em chamadas -+de subfunções), ``percall`` é o quociente de ``tottime`` dividido por -+``ncalls``. ``cumtime`` é o tempo total gasto nessa e em todas as -+subfunções (isto é, desde o início até o término da execução da -+função), ``percall`` é o quociente de ``cumtime`` dividido pelas -+chamadas primitivas, e ``filename:lineno(function)`` fornece os dados -+respectivos para cada função. A regra prática aqui é: Quanto mais no -+topo uma função aparece nessa lista, mais custo computacional ela -+acarreta. Logo é mais interessante para ser optimizada. -+ -+Como usual, ``prun?`` fornece detalhes sobre como usar o "profiler" e -+como entender a saída de dados. -+ -+A saída de dados pode ser escrita em um objeto para permitir uma -+análise mais detalhada: -+ -+.. skip -+ -+:: -+ -+ sage: %prun -r A*A -+ sage: stats = _ -+ sage: stats? -+ -+Note: digitando ``stats = prun -r A\*A`` obtém-se um erro de sintaxe -+porque prun é um comando do IPython, não uma função comum. -+ -+Para uma representação gráfica dos dados do "profiling", você pode -+usar o "hotspot profiler", um pequeno script chamado -+``hotshot2cachetree`` e o programa ``kcachegrind`` (apenas no Unix). O -+mesmo exemplo agora com o "hotspot profiler": -+ -+.. skip -+ -+:: -+ -+ sage: k,a = GF(2**8, 'a').objgen() -+ sage: A = Matrix(k,10,10,[k.random_element() for _ in range(10*10)]) -+ sage: import hotshot -+ sage: filename = "pythongrind.prof" -+ sage: prof = hotshot.Profile(filename, lineevents=1) -+ -+.. skip -+ -+:: -+ -+ sage: prof.run("A*A") -+ -+ sage: prof.close() -+ -+Isso resulta em um arquivo ``pythongrind.prof`` no diretório de -+trabalho atual. Ele pode ser convertido para o formato cachegrind para -+visualização. -+ -+Em uma linha de comando do sistema, digite -+ -+.. skip -+ -+:: -+ -+ hotshot2calltree -o cachegrind.out.42 pythongrind.prof -+ -+O arquivo de saída ``cachegrind.out.42`` pode ser examinado com -+``kcachegrind``. Note que a convenção de nomes ``cachegrind.out.XX`` -+precisa ser obedecida. -diff --git a/doc/pt/tutorial/sagetex.rst b/doc/pt/tutorial/sagetex.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/sagetex.rst -@@ -0,0 +1,112 @@ -+.. _sec-sagetex: -+ -+**************** -+Usando o SageTeX -+**************** -+ -+O pacote SageTeX permite que você insira resultados de cálculos feitos -+com o Sage em um documento LaTeX. Esse pacote já vem com o Sage. Para -+usá-lo, você precisa "instalá-lo" em seu sistema LaTeX local; aqui -+instalar significa copiar um simples arquivo. Veja :ref:`installation` -+neste tutorial e a seção "Make SageTeX known to TeX" do `Guia de -+instalação do Sage `_ -+(em inglês) (`este link <../installation/index.html>`_ deve levá-lo a -+uma cópia local do guia de instalação para mais informações de como -+proceder. -+ -+Aqui vai um breve exemplo de como usar o SageTeX. A documentação -+completa pode ser encontrada em -+``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``, onde -+``SAGE_ROOT`` é o diretório onde se encontra a sua instalação. Esse -+diretório contém a documentação, um arquivo de exemplo, e alguns -+scripts em Python possivelmente úteis. -+ -+Para ver como o SageTeX funciona, siga as instruções para instalar o -+SageTeX (em :ref:`installation`) e copie o seguinte texto em um -+arquivo chamado ``st_example.tex``, por exemplo. -+ -+.. warning:: -+ -+ O texto abaixo vai apresentar diversos erros sobre "unknown control -+ sequences" se você está visualizando isto na ajuda "live". Use a -+ versão estática para ver o texto corretamente. -+ -+.. code-block:: latex -+ -+ \documentclass{article} -+ \usepackage{sagetex} -+ -+ \begin{document} -+ -+ Using Sage\TeX, one can use Sage to compute things and put them into -+ your \LaTeX{} document. For example, there are -+ $\sage{number_of_partitions(1269)}$ integer partitions of $1269$. -+ You don't need to compute the number yourself, or even cut and paste -+ it from somewhere. -+ -+ Here's some Sage code: -+ -+ \begin{sageblock} -+ f(x) = exp(x) * sin(2*x) -+ \end{sageblock} -+ -+ The second derivative of $f$ is -+ -+ \[ -+ \frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} = -+ \sage{diff(f, x, 2)(x)}. -+ \] -+ -+ Here's a plot of $f$ from $-1$ to $1$: -+ -+ \sageplot{plot(f, -1, 1)} -+ -+ \end{document} -+ -+Execute o LaTeX em ``st_example.tex`` da forma usual. Note que o LaTeX -+vai reclamar sobre algumas coisas, entre elas:: -+ -+ Package sagetex Warning: Graphics file -+ sage-plots-for-st_example.tex/plot-0.eps on page 1 does not exist. Plot -+ command is on input line 25. -+ -+ Package sagetex Warning: There were undefined Sage formulas and/or -+ plots. Run Sage on st_example.sage, and then run LaTeX on -+ st_example.tex again. -+ -+Observe que, além dos arquivos usuais produzidos pelo LaTeX, existe um -+arquivo chamado ``st_example.sage``. Esse é um script em Sage -+produzido quando você executa o LaTeX em ``st_example.tex``. A -+mensagem de alerta pede para você executar o LaTeX em -+``st_example.sage``, então siga essa sugestão e faça isso. Você vai -+receber uma mensagem para executar o LaTeX em ``st_example.tex`` -+novamente, mas antes que você faça isso, observe que um novo arquivo -+foi criado: ``st_example.sout``. Esse arquivo contém os resultados dos -+cálculos feitos pelo Sage, em um formato que o LaTeX pode usar para -+inserir em seu texto. Um novo diretório contendo um arquivo EPS do seu -+gráfico também foi criado. Execute o LaTeX novamente e você vai ver -+que tudo que foi calculado, incluindo os gráficos, foi incluído em seu -+documento. -+ -+As macros utilizadas acima devem ser fáceis de entender. Um -+environment ``sageblock`` insere código "verbatim" (exatamente como é -+digitado) e também executa o código quando você executa o Sage. Quando -+você insere ``\sage{foo}``, é incluído em seu documento o resultado -+que você obteria executando ``latex(foo)`` no Sage. Comandos para -+fazer gráficos são um pouco mais complicados, mas em sua forma mais -+simples, ``\sageplot{foo}`` insere a imagem que você obtêm usando -+``foo.save('filename.eps')``. -+ -+Em geral, a rotina é a seguinte: -+ -+ - execute o LaTeX no seu arquivo .tex; -+ - execute o Sage no arquivo .sage que foi gerado; -+ - execute o LaTeX novamente. -+ -+Você pode omitir a execução do Sage desde que você não tenha alterado -+os comandos em Sage em seu documento. -+ -+Há muito mais sobre o SageTeX, e como tanto o Sage como o LaTeX são -+ferramentas complexas e poderosas, é uma boa idéia ler a documentação -+para o SageTeX que se encontra em -+``SAGE_ROOT/local/share/texmf/tex/generic/sagetex``. -diff --git a/doc/pt/tutorial/tour.rst b/doc/pt/tutorial/tour.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour.rst -@@ -0,0 +1,31 @@ -+***************** -+Um passeio guiado -+***************** -+ -+Esta seção é um passeio guiado pelo que está disponível no Sage. Para -+diversos outros exemplos, veja "Construções em Sage", que tem como -+objetivo responder à questão geral "Como eu construo ...?". Veja -+também o "Sage Reference Manual", que possui centenas de outros -+exemplos. Note que é também possível percorrer este tutorial no Sage -+Notebook clicando no link ``Help``. -+ -+(Se você está acessando este tutorial no Sage Notebook, pressione -+``shift-enter`` para processar qualquer célula de entrada. Você pode -+até editar a célula antes de pressionar ``shift-enter``. Em alguns -+Macs pode ser necessário pressionar ``shift-return`` em vez de -+``shift-enter``.) -+ -+.. toctree:: -+ -+ tour_assignment -+ tour_help -+ tour_algebra -+ tour_plotting -+ tour_functions -+ tour_rings -+ tour_linalg -+ tour_polynomial -+ tour_coercion -+ tour_groups -+ tour_numtheory -+ tour_advanced -diff --git a/doc/pt/tutorial/tour_advanced.rst b/doc/pt/tutorial/tour_advanced.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_advanced.rst -@@ -0,0 +1,548 @@ -+Um Pouco Mais de Matemática Avançada -+==================================== -+ -+Geometria Algébrica -+------------------- -+ -+Você pode definir variedades algébricas arbitrárias no Sage, mas as -+vezes alguma funcionalidade não-trivial é limitada a anéis sobre -+:math:`\QQ` ou corpos finitos. Por exemplo, vamos calcular a união de -+duas curvas planas afim, e então recuperar as curvas como as -+componentes irredutíveis da união. -+ -+:: -+ -+ sage: x, y = AffineSpace(2, QQ, 'xy').gens() -+ sage: C2 = Curve(x^2 + y^2 - 1) -+ sage: C3 = Curve(x^3 + y^3 - 1) -+ sage: D = C2 + C3 -+ sage: D -+ Affine Curve over Rational Field defined by -+ x^5 + x^3*y^2 + x^2*y^3 + y^5 - x^3 - y^3 - x^2 - y^2 + 1 -+ sage: D.irreducible_components() -+ [ -+ Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -+ x^2 + y^2 - 1, -+ Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -+ x^3 + y^3 - 1 -+ ] -+ -+Você também pode encontrar todos os pontos de interseção das duas -+curvas, intersectando-as, e então calculando as componentes -+irredutíveis. -+ -+.. link -+ -+:: -+ -+ sage: V = C2.intersection(C3) -+ sage: V.irreducible_components() -+ [ -+ Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -+ y - 1, -+ x, -+ Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -+ y, -+ x - 1, -+ Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -+ x + y + 2, -+ 2*y^2 + 4*y + 3 -+ ] -+ -+Portanto, por exemplo, :math:`(1,0)` e :math:`(0,1)` estão em ambas as -+curvas (o que é claramente visível), como também estão certos pontos -+(quadráticos) cuja coordenada :math:`y` satisfaz :math:`2y^2 + 4y + -+3=0`. -+ -+O Sage pode calcular o ideal toroidal da cúbica torcida no espaço-3 -+projetivo: -+ -+:: -+ -+ sage: R. = PolynomialRing(QQ, 4) -+ sage: I = ideal(b^2-a*c, c^2-b*d, a*d-b*c) -+ sage: F = I.groebner_fan(); F -+ Groebner fan of the ideal: -+ Ideal (b^2 - a*c, c^2 - b*d, -b*c + a*d) of Multivariate Polynomial Ring -+ in a, b, c, d over Rational Field -+ sage: F.reduced_groebner_bases () -+ [[-c^2 + b*d, -b*c + a*d, -b^2 + a*c], -+ [c^2 - b*d, -b*c + a*d, -b^2 + a*c], -+ [c^2 - b*d, b*c - a*d, -b^2 + a*c, -b^3 + a^2*d], -+ [c^2 - b*d, b*c - a*d, b^3 - a^2*d, -b^2 + a*c], -+ [c^2 - b*d, b*c - a*d, b^2 - a*c], -+ [-c^2 + b*d, b^2 - a*c, -b*c + a*d], -+ [-c^2 + b*d, b*c - a*d, b^2 - a*c, -c^3 + a*d^2], -+ [c^3 - a*d^2, -c^2 + b*d, b*c - a*d, b^2 - a*c]] -+ sage: F.polyhedralfan() -+ Polyhedral fan in 4 dimensions of dimension 4 -+ -+Curvas Elípticas -+---------------- -+ -+A funcionalidade para curvas elípticas inclui a maior parte da -+funcionalidade para curvas elípticas do PARI, acesso aos dados da base -+de dados Cremona (isso requer um pacote adicional), os recursos do -+mwrank, isto é, "2-descends" com cálculos do grupo de Mordell-Weil -+completo, o algoritmo SEA (singla em inglês), cálculo de todas as -+isogenias, bastante código novo para curvas sobre :math:`\QQ`, e parte -+do software "algebraic descent" de Denis Simons. -+ -+O comando ``EllipticCurve`` para criar curvas elípticas possui várias -+formas: -+ -+ -+- EllipticCurve([:math:`a_1`, :math:`a_2`, :math:`a_3`, :math:`a_4`, :math:`a_6`]): -+ Fornece a curva elíptica -+ -+ .. math:: y^2+a_1xy+a_3y=x^3+a_2x^2+a_4x+a_6, -+ -+ -+ onde os :math:`a_i`'s são coagidos para os parentes de :math:`a_1`. -+ Se todos os :math:`a_i` possuem parente :math:`\ZZ`, então eles são -+ coagidos para :math:`\QQ`. -+ -+- EllipticCurve([:math:`a_4`, :math:`a_6`]): Conforme acima, mas -+ :math:`a_1=a_2=a_3=0`. -+ -+- EllipticCurve(label): Fornece a curva elíptica da base de dados -+ Cremona com o "label" (novo) dado. O label é uma string, tal como -+ ``"11a"`` ou ``"37b2"``. As letras devem ser minúsculas (para -+ distinguir dos labels antigos). -+ -+- EllipticCurve(j): Fornece uma curva elíptica com invariante -+ :math:`j`. -+ -+- EllipticCurve(R, -+ [:math:`a_1`, :math:`a_2`, :math:`a_3`, :math:`a_4`, :math:`a_6`]): -+ Cria uma curva elíptica sobre um anel :math:`R` com os -+ :math:`a_i`'s. -+ -+ -+Agora ilustramos cada uma dessas construções: -+ -+:: -+ -+ sage: EllipticCurve([0,0,1,-1,0]) -+ Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field -+ -+ sage: EllipticCurve([GF(5)(0),0,1,-1,0]) -+ Elliptic Curve defined by y^2 + y = x^3 + 4*x over Finite Field of size 5 -+ -+ sage: EllipticCurve([1,2]) -+ Elliptic Curve defined by y^2 = x^3 + x + 2 over Rational Field -+ -+ sage: EllipticCurve('37a') -+ Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field -+ -+ sage: EllipticCurve_from_j(1) -+ Elliptic Curve defined by y^2 + x*y = x^3 + 36*x + 3455 over Rational Field -+ -+ sage: EllipticCurve(GF(5), [0,0,1,-1,0]) -+ Elliptic Curve defined by y^2 + y = x^3 + 4*x over Finite Field of size 5 -+ -+O par :math:`(0,0)` é um ponto na curva elíptica :math:`E` definida -+por :math:`y^2 + y = x^3 - x`. Para criar esse ponto digite -+``E([0,0])``. O Sage pode somar pontos em uma curva elíptica -+(lembre-se que é possível definir uma estrutura de grupo aditivo em -+curvas elípticas onde o ponto no infinito é o elemento nulo, e a some -+de três pontos colineares sobre a curva é zero): -+ -+:: -+ -+ sage: E = EllipticCurve([0,0,1,-1,0]) -+ sage: E -+ Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field -+ sage: P = E([0,0]) -+ sage: P + P -+ (1 : 0 : 1) -+ sage: 10*P -+ (161/16 : -2065/64 : 1) -+ sage: 20*P -+ (683916417/264517696 : -18784454671297/4302115807744 : 1) -+ sage: E.conductor() -+ 37 -+ -+As curvas elípticas sobre os números complexos são parametrizadas -+pelo invariante :math:`j`. O Sage calcula o invariante :math:`j` da -+seguinte forma: -+ -+:: -+ -+ sage: E = EllipticCurve([0,0,0,-4,2]); E -+ Elliptic Curve defined by y^2 = x^3 - 4*x + 2 over Rational Field -+ sage: E.conductor() -+ 2368 -+ sage: E.j_invariant() -+ 110592/37 -+ -+Se criarmos uma curva com o mesmo invariante :math:`j` que a curva -+:math:`E`, ela não precisa ser isomórfica a :math:`E`. No seguinte -+exemplo, as curvas não são isomórficas porque os seus condutores são -+diferentes. -+ -+:: -+ -+ sage: F = EllipticCurve_from_j(110592/37) -+ sage: F.conductor() -+ 37 -+ -+Todavia, uma torção de :math:`F` por um fator 2 resulta em uma curva -+isomórfica. -+ -+.. link -+ -+:: -+ -+ sage: G = F.quadratic_twist(2); G -+ Elliptic Curve defined by y^2 = x^3 - 4*x + 2 over Rational Field -+ sage: G.conductor() -+ 2368 -+ sage: G.j_invariant() -+ 110592/37 -+ -+Nós podemos calcular os coeficientes :math:`a_n` de uma -+série-:math:`L` ou forma modular :math:`\sum_{n=0}^\infty -+a_nq^n` associada à curva elíptica. Esse cálculo usa a biblioteca C do -+PARI. -+ -+:: -+ -+ sage: E = EllipticCurve([0,0,1,-1,0]) -+ sage: print E.anlist(30) -+ [0, 1, -2, -3, 2, -2, 6, -1, 0, 6, 4, -5, -6, -2, 2, 6, -4, 0, -12, 0, -4, -+ 3, 10, 2, 0, -1, 4, -9, -2, 6, -12] -+ sage: v = E.anlist(10000) -+ -+Leva apenas um segundo para calcular todos os :math:`a_n` para -+:math:`n\leq 10^5`: -+ -+.. skip -+ -+:: -+ -+ sage: %time v = E.anlist(100000) -+ CPU times: user 0.98 s, sys: 0.06 s, total: 1.04 s -+ Wall time: 1.06 -+ -+Curvas elípticas podem ser construídas usando o "label" da base de -+dados Cremona. Isso importa a curva elíptica com informações prévias -+sobre o seu posto, números de Tomagawa, regulador, etc. -+ -+:: -+ -+ sage: E = EllipticCurve("37b2") -+ sage: E -+ Elliptic Curve defined by y^2 + y = x^3 + x^2 - 1873*x - 31833 over Rational -+ Field -+ sage: E = EllipticCurve("389a") -+ sage: E -+ Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field -+ sage: E.rank() -+ 2 -+ sage: E = EllipticCurve("5077a") -+ sage: E.rank() -+ 3 -+ -+Nós também podemos acessar a base de dados Cremona diretamente. -+ -+:: -+ -+ sage: db = sage.databases.cremona.CremonaDatabase() -+ sage: db.curves(37) -+ {'a1': [[0, 0, 1, -1, 0], 1, 1], 'b1': [[0, 1, 1, -23, -50], 0, 3]} -+ sage: db.allcurves(37) -+ {'a1': [[0, 0, 1, -1, 0], 1, 1], -+ 'b1': [[0, 1, 1, -23, -50], 0, 3], -+ 'b2': [[0, 1, 1, -1873, -31833], 0, 1], -+ 'b3': [[0, 1, 1, -3, 1], 0, 3]} -+ -+Os objetos obtidos pela base de dados não são do tipo -+``EllipticCurve``. Eles são elementos de uma base de dados e possuem -+alguns campos, e apenas isso. Existe uma versão básica da base de -+dados Cremona, que já é distribuída na versão padrão do Sage, e contém -+informações limitadas sobre curvas elípticas de condutor :math:`\leq -+10000`. Existe também uma versão estendida opcional, que contém -+informações extensas sobre curvas elípticas de condutor :math:`\leq -+120000` (em outubro de 2005). Por fim, existe ainda uma versão (2GB) -+opcional de uma base de dados para o Sage que contém centenas de -+milhares de curvas elípticas na base de dados Stein-Watkins. -+ -+Caracteres de Dirichlet -+----------------------- -+ -+Um *caractere de Dirichlet* é a extensão de um homomorfismo -+:math:`(\ZZ/N\ZZ)* \to R^*`, para algum anel :math:`R`, para o mapa -+:math:`\ZZ \to R` obtido mapeando os inteiros :math:`x` tais que -+:math:`\gcd(N,x)>1` em 0. -+ -+:: -+ -+ sage: G = DirichletGroup(12) -+ sage: G.list() -+ [Dirichlet character modulo 12 of conductor 1 mapping 7 |--> 1, 5 |--> 1, -+ Dirichlet character modulo 12 of conductor 4 mapping 7 |--> -1, 5 |--> 1, -+ Dirichlet character modulo 12 of conductor 3 mapping 7 |--> 1, 5 |--> -1, -+ Dirichlet character modulo 12 of conductor 12 mapping 7 |--> -1, 5 |--> -1] -+ sage: G.gens() -+ (Dirichlet character modulo 12 of conductor 4 mapping 7 |--> -1, 5 |--> 1, -+ Dirichlet character modulo 12 of conductor 3 mapping 7 |--> 1, 5 |--> -1) -+ sage: len(G) -+ 4 -+ -+Tendo criado o grupo, a seguir calculamos um elemento e fazemos -+cálculos com ele. -+ -+.. link -+ -+:: -+ -+ sage: G = DirichletGroup(21) -+ sage: chi = G.1; chi -+ Dirichlet character modulo 21 of conductor 7 mapping 8 |--> 1, 10 |--> zeta6 -+ sage: chi.values() -+ [0, 1, zeta6 - 1, 0, -zeta6, -zeta6 + 1, 0, 0, 1, 0, zeta6, -zeta6, 0, -1, -+ 0, 0, zeta6 - 1, zeta6, 0, -zeta6 + 1, -1] -+ sage: chi.conductor() -+ 7 -+ sage: chi.modulus() -+ 21 -+ sage: chi.order() -+ 6 -+ sage: chi(19) -+ -zeta6 + 1 -+ sage: chi(40) -+ -zeta6 + 1 -+ -+É também possível calcular a ação do grupo de Galois -+:math:`\text{Gal}(\QQ(\zeta_N)/\QQ)` sobre esses caracteres, bem como -+a decomposição em produto direto correspondente à fatorização do -+módulo. -+ -+.. link -+ -+:: -+ -+ sage: chi.galois_orbit() -+ [Dirichlet character modulo 21 of conductor 7 mapping 8 |--> 1, 10 |--> zeta6, -+ Dirichlet character modulo 21 of conductor 7 mapping 8 |--> 1, 10 |--> -zeta6 + 1] -+ -+ sage: go = G.galois_orbits() -+ sage: [len(orbit) for orbit in go] -+ [1, 2, 2, 1, 1, 2, 2, 1] -+ -+ sage: G.decomposition() -+ [ -+ Group of Dirichlet characters of modulus 3 over Cyclotomic Field of order -+ 6 and degree 2, -+ Group of Dirichlet characters of modulus 7 over Cyclotomic Field of order -+ 6 and degree 2 -+ ] -+ -+A seguir, construímos o grupo de caracteres de Dirichlet mod 20, mas -+com valores em :math:`\QQ(i)`: -+ -+:: -+ -+ sage: K. = NumberField(x^2+1) -+ sage: G = DirichletGroup(20,K) -+ sage: G -+ Group of Dirichlet characters of modulus 20 over Number Field in i with defining polynomial x^2 + 1 -+ -+Agora calculamos diversos invariantes de ``G``: -+ -+.. link -+ -+:: -+ -+ sage: G.gens() -+ (Dirichlet character modulo 20 of conductor 4 mapping 11 |--> -1, 17 |--> 1, -+ Dirichlet character modulo 20 of conductor 5 mapping 11 |--> 1, 17 |--> i) -+ -+ sage: G.unit_gens() -+ [11, 17] -+ sage: G.zeta() -+ i -+ sage: G.zeta_order() -+ 4 -+ -+No próximo exemplo criamos um caractere de Dirichlet com valores em um -+corpo numérico. Nós especificamos explicitamente a escolha da raiz da -+unidade no terceiro argumento do comando ``DirichletGroup`` abaixo. -+ -+:: -+ -+ sage: x = polygen(QQ, 'x') -+ sage: K = NumberField(x^4 + 1, 'a'); a = K.0 -+ sage: b = K.gen(); a == b -+ True -+ sage: K -+ Number Field in a with defining polynomial x^4 + 1 -+ sage: G = DirichletGroup(5, K, a); G -+ Group of Dirichlet characters of modulus 5 over Number Field in a with -+ defining polynomial x^4 + 1 -+ sage: chi = G.0; chi -+ Dirichlet character modulo 5 of conductor 5 mapping 2 |--> a^2 -+ sage: [(chi^i)(2) for i in range(4)] -+ [1, a^2, -1, -a^2] -+ -+Aqui ``NumberField(x^4 + 1, 'a')`` diz para o Sage usar o símbolo "a" -+quando imprimir o que é ``K`` (um corpo numérico definido pelo -+polinômio :math:`x^4 + 1`). O nome "a" não está declarado até então. -+Uma vez que ``a = K.0`` (ou equivalentemente ``a = K.gen()``) é -+calculado, o símbolo "a" representa a raiz do polinômio gerador -+:math:`x^4+1`. -+ -+Formas Modulares -+---------------- -+ -+O Sage pode fazer alguns cálculos relacionados a formas modulares, -+incluindo dimensões, calcular espaços de símbolos modulares, -+operadores de Hecke, e decomposições. -+ -+Existem várias funções disponíveis para calcular dimensões de espaços -+de formas modulares. Por exemplo, -+ -+:: -+ -+ sage: dimension_cusp_forms(Gamma0(11),2) -+ 1 -+ sage: dimension_cusp_forms(Gamma0(1),12) -+ 1 -+ sage: dimension_cusp_forms(Gamma1(389),2) -+ 6112 -+ -+A seguir ilustramos o cálculo dos operadores de Hecke em um espaço de -+símbolos modulares de nível :math:`1` e peso :math:`12`. -+ -+:: -+ -+ sage: M = ModularSymbols(1,12) -+ sage: M.basis() -+ ([X^8*Y^2,(0,0)], [X^9*Y,(0,0)], [X^10,(0,0)]) -+ sage: t2 = M.T(2) -+ sage: t2 -+ Hecke operator T_2 on Modular Symbols space of dimension 3 for Gamma_0(1) -+ of weight 12 with sign 0 over Rational Field -+ sage: t2.matrix() -+ [ -24 0 0] -+ [ 0 -24 0] -+ [4860 0 2049] -+ sage: f = t2.charpoly('x'); f -+ x^3 - 2001*x^2 - 97776*x - 1180224 -+ sage: factor(f) -+ (x - 2049) * (x + 24)^2 -+ sage: M.T(11).charpoly('x').factor() -+ (x - 285311670612) * (x - 534612)^2 -+ -+Podemos também criar espaços para :math:`\Gamma_0(N)` e -+:math:`\Gamma_1(N)`. -+ -+ -+:: -+ -+ sage: ModularSymbols(11,2) -+ Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign -+ 0 over Rational Field -+ sage: ModularSymbols(Gamma1(11),2) -+ Modular Symbols space of dimension 11 for Gamma_1(11) of weight 2 with -+ sign 0 and over Rational Field -+ -+Vamos calcular alguns polinômios característicos e expansões -+:math:`q`. -+ -+:: -+ -+ sage: M = ModularSymbols(Gamma1(11),2) -+ sage: M.T(2).charpoly('x') -+ x^11 - 8*x^10 + 20*x^9 + 10*x^8 - 145*x^7 + 229*x^6 + 58*x^5 - 360*x^4 -+ + 70*x^3 - 515*x^2 + 1804*x - 1452 -+ sage: M.T(2).charpoly('x').factor() -+ (x - 3) * (x + 2)^2 * (x^4 - 7*x^3 + 19*x^2 - 23*x + 11) -+ * (x^4 - 2*x^3 + 4*x^2 + 2*x + 11) -+ sage: S = M.cuspidal_submodule() -+ sage: S.T(2).matrix() -+ [-2 0] -+ [ 0 -2] -+ sage: S.q_expansion_basis(10) -+ [ -+ q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 - 2*q^9 + O(q^10) -+ ] -+ -+Podemos até mesmo calcular espaços de símbolos modulares com carácter. -+ -+:: -+ -+ sage: G = DirichletGroup(13) -+ sage: e = G.0^2 -+ sage: M = ModularSymbols(e,2); M -+ Modular Symbols space of dimension 4 and level 13, weight 2, character -+ [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 -+ sage: M.T(2).charpoly('x').factor() -+ (x - 2*zeta6 - 1) * (x - zeta6 - 2) * (x + zeta6 + 1)^2 -+ sage: S = M.cuspidal_submodule(); S -+ Modular Symbols subspace of dimension 2 of Modular Symbols space of -+ dimension 4 and level 13, weight 2, character [zeta6], sign 0, over -+ Cyclotomic Field of order 6 and degree 2 -+ sage: S.T(2).charpoly('x').factor() -+ (x + zeta6 + 1)^2 -+ sage: S.q_expansion_basis(10) -+ [ -+ q + (-zeta6 - 1)*q^2 + (2*zeta6 - 2)*q^3 + zeta6*q^4 + (-2*zeta6 + 1)*q^5 -+ + (-2*zeta6 + 4)*q^6 + (2*zeta6 - 1)*q^8 - zeta6*q^9 + O(q^10) -+ ] -+ -+Aqui está um outro exemplo de como o Sage pode calcular a ação de -+operadores de Hecke em um espaço de formas modulares. -+ -+:: -+ -+ sage: T = ModularForms(Gamma0(11),2) -+ sage: T -+ Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of -+ weight 2 over Rational Field -+ sage: T.degree() -+ 2 -+ sage: T.level() -+ 11 -+ sage: T.group() -+ Congruence Subgroup Gamma0(11) -+ sage: T.dimension() -+ 2 -+ sage: T.cuspidal_subspace() -+ Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for -+ Congruence Subgroup Gamma0(11) of weight 2 over Rational Field -+ sage: T.eisenstein_subspace() -+ Eisenstein subspace of dimension 1 of Modular Forms space of dimension 2 -+ for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field -+ sage: M = ModularSymbols(11); M -+ Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign -+ 0 over Rational Field -+ sage: M.weight() -+ 2 -+ sage: M.basis() -+ ((1,0), (1,8), (1,9)) -+ sage: M.sign() -+ 0 -+ -+Denote por :math:`T_p` os operadores de Hecke usuais (:math:`p` -+primo). Como os operadores de Hecke :math:`T_2`, :math:`T_3`, -+e :math:`T_5` agem sobre o espaço de símbolos modulares? -+ -+ -+.. link -+ -+:: -+ -+ sage: M.T(2).matrix() -+ [ 3 0 -1] -+ [ 0 -2 0] -+ [ 0 0 -2] -+ sage: M.T(3).matrix() -+ [ 4 0 -1] -+ [ 0 -1 0] -+ [ 0 0 -1] -+ sage: M.T(5).matrix() -+ [ 6 0 -1] -+ [ 0 1 0] -+ [ 0 0 1] -diff --git a/doc/pt/tutorial/tour_algebra.rst b/doc/pt/tutorial/tour_algebra.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_algebra.rst -@@ -0,0 +1,414 @@ -+Álgebra Elementar e Cálculo -+=========================== -+ -+O Sage pode realizar diversos cálculos em álgebra elementar e cálculo -+diferencial e integral: por exemplo, encontrar soluções de equações, -+diferenciar, integrar, e calcular a transformada de Laplace. Veja a -+documentação em `Sage Constructions -+`_ para mais exemplos. -+ -+Resolvendo equações -+------------------- -+ -+Resolvendo equações exatamente -+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ -+A função ``solve`` resolve equações. Para usá-la, primeiro especifique -+algumas variáveis; então os argumentos de ``solve`` são uma equação -+(ou um sistema de equações), juntamente com as variáveis para as -+quais resolver: -+ -+:: -+ -+ sage: x = var('x') -+ sage: solve(x^2 + 3*x + 2, x) -+ [x == -2, x == -1] -+ -+Você pode resolver equações para uma variável em termos das outras: -+ -+:: -+ -+ sage: x, b, c = var('x b c') -+ sage: solve([x^2 + b*x + c == 0],x) -+ [x == -1/2*b - 1/2*sqrt(b^2 - 4*c), x == -1/2*b + 1/2*sqrt(b^2 - 4*c)] -+ -+Você pode resolver para diversas variáveis: -+ -+:: -+ -+ sage: x, y = var('x, y') -+ sage: solve([x+y==6, x-y==4], x, y) -+ [[x == 5, y == 1]] -+ -+O seguinte exemplo, que mostra como usar o Sage para resolver um -+sistema de equações não-lineares, foi sugerido por Jason Grout: -+primeiro, resolvemos o sistemas simbolicamente: -+ -+:: -+ -+ sage: var('x y p q') -+ (x, y, p, q) -+ sage: eq1 = p+q==9 -+ sage: eq2 = q*y+p*x==-6 -+ sage: eq3 = q*y^2+p*x^2==24 -+ sage: solve([eq1,eq2,eq3,p==1],p,q,x,y) -+ [[p == 1, q == 8, x == -4/3*sqrt(10) - 2/3, y == 1/6*sqrt(2)*sqrt(5) - 2/3], -+ [p == 1, q == 8, x == 4/3*sqrt(10) - 2/3, y == -1/6*sqrt(2)*sqrt(5) - 2/3]] -+ -+Para obter soluções numéricas aproximadas, podemos usar: -+ -+.. link -+ -+:: -+ -+ sage: solns = solve([eq1,eq2,eq3,p==1],p,q,x,y, solution_dict=True) -+ sage: [[s[p].n(30), s[q].n(30), s[x].n(30), s[y].n(30)] for s in solns] -+ [[1.0000000, 8.0000000, -4.8830369, -0.13962039], -+ [1.0000000, 8.0000000, 3.5497035, -1.1937129]] -+ -+(A função ``n`` imprime uma aproximação numérica, e o argumento é o -+número de bits de precisão.) -+ -+Resolvendo Equações Numericamente -+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ -+Frequentemente, ``solve`` não será capaz de encontrar uma solução -+exata para uma equação ou sistema de equações. Nesse caso, você pode -+usar ``find_root`` para encontrar uma solução numérica. Por exemplo, -+``solve`` não encontra uma solução para a equação abaixo:: -+ -+ sage: theta = var('theta') -+ sage: solve(cos(theta)==sin(theta), theta) -+ [sin(theta) == cos(theta)] -+ -+Por outro lado, podemos usar ``find_root`` para encontrar uma solução -+para a equação acima no intervalo :math:`0 < \phi < \pi/2`:: -+ -+ sage: phi = var('phi') -+ sage: find_root(cos(phi)==sin(phi),0,pi/2) -+ 0.785398163397448... -+ -+Diferenciação, Integração, etc. -+------------------------------- -+ -+O Sage é capaz de diferenciar e integrar diversas funções. Por -+exemplo, para diferenciar :math:`\sin(u)` com respeito a :math:`u`, -+faça o seguinte: -+ -+:: -+ -+ sage: u = var('u') -+ sage: diff(sin(u), u) -+ cos(u) -+ -+Para calcular a quarta derivada de :math:`\sin(x^2)`: -+ -+:: -+ -+ sage: diff(sin(x^2), x, 4) -+ 16*x^4*sin(x^2) - 48*x^2*cos(x^2) - 12*sin(x^2) -+ -+Para calcular as derivadas parciais de :math:`x^2+17y^2` com respeito -+a *x* e *y*, respectivamente: -+ -+:: -+ -+ sage: x, y = var('x,y') -+ sage: f = x^2 + 17*y^2 -+ sage: f.diff(x) -+ 2*x -+ sage: f.diff(y) -+ 34*y -+ -+Passamos agora para integrais, tanto indefinidas como definidas. Para -+calcular :math:`\int x\sin(x^2)\, dx` e :math:`\int_0^1 -+\frac{x}{x^2+1}\, dx`: -+ -+:: -+ -+ sage: integral(x*sin(x^2), x) -+ -1/2*cos(x^2) -+ sage: integral(x/(x^2+1), x, 0, 1) -+ 1/2*log(2) -+ -+Para calcular a decomposição em frações parciais de -+:math:`\frac{1}{x^2-1}`: -+ -+:: -+ -+ sage: f = 1/((1+x)*(x-1)) -+ sage: f.partial_fraction(x) -+ 1/2/(x - 1) - 1/2/(x + 1) -+ -+.. _section-systems: -+ -+Resolvendo Equações Diferenciais -+-------------------------------- -+ -+Você pode usar o Sage para investigar equações diferenciais -+ordinárias. Para resolver a equação :math:`x'+x-1=0`: -+ -+:: -+ -+ sage: t = var('t') # define a variable t -+ sage: x = function('x',t) # define x to be a function of that variable -+ sage: DE = diff(x, t) + x - 1 -+ sage: desolve(DE, [x,t]) -+ (c + e^t)*e^(-t) -+ -+Esse método usa a interface do Sage para o Maxima [Max]_. Logo, o -+formato dos resultados é um pouco diferente de outros cálculos -+realizados no Sage. Nesse caso, o resultado diz que a solução geral da -+equação diferencial é :math:`x(t) = e^{-t}(e^{t}+c)`. -+ -+Você pode calcular a transformada de Laplace também; a transformada de -+Laplace de :math:`t^2e^t -\sin(t)` é calculada da seguinte forma: -+ -+:: -+ -+ sage: s = var("s") -+ sage: t = var("t") -+ sage: f = t^2*exp(t) - sin(t) -+ sage: f.laplace(t,s) -+ 2/(s - 1)^3 - 1/(s^2 + 1) -+ -+A seguir, um exemplo mais complicado. O deslocamento, com respeito à -+posição de equilíbrio, de duas massas presas a uma parede através de -+molas, conforme a figura abaixo, -+ -+:: -+ -+ |------\/\/\/\/\---|massa1|----\/\/\/\/\/----|massa2| -+ mola1 mola2 -+ -+é modelado pelo sistema de equações diferenciais de segunda ordem -+ -+.. math:: -+ -+ m_1 x_1'' + (k_1+k_2) x_1 - k_2 x_2 = 0 -+ -+ m_2 x_2''+ k_2 (x_2-x_1) = 0, -+ -+ -+ -+onde, para :math:`i=1,2`, :math:`m_{i}` é a massa do objeto *i*, -+:math:`x_{i}` é o deslocamento com respeito à posição de equilíbrio da -+massa *i*, e :math:`k_{i}` é a constante de mola para a mola *i*. -+ -+**Exemplo:** Use o Sage para resolver o problema acima com -+:math:`m_{1}=2`, :math:`m_{2}=1`, :math:`k_{1}=4`, -+:math:`k_{2}=2`, :math:`x_{1}(0)=3`, :math:`x_{1}'(0)=0`, -+:math:`x_{2}(0)=3`, :math:`x_{2}'(0)=0`. -+ -+Solução: Primeiramente, calcule a transformada de Laplace da primeira -+equação (usando a notação :math:`x=x_{1}`, :math:`y=x_{2}`): -+ -+:: -+ -+ sage: de1 = maxima("2*diff(x(t),t, 2) + 6*x(t) - 2*y(t)") -+ sage: lde1 = de1.laplace("t","s"); lde1 -+ 2*(-?%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s)-2*'laplace(y(t),t,s)+6*'laplace(x(t),t,s) -+ -+O resultado é um pouco difícil de ler, mas diz que -+ -+.. math:: -2x'(0) + 2s^2*X(s) - 2sx(0) - 2Y(s) + 6X(s) = 0 -+ -+ -+(onde a transformada de Laplace de uma função em letra minúscula -+:math:`x(t)` é a função em letra maiúscula :math:`X(s)`). Agora, -+calcule a transformada de Laplace da segunda equação: -+ -+:: -+ -+ sage: de2 = maxima("diff(y(t),t, 2) + 2*y(t) - 2*x(t)") -+ sage: lde2 = de2.laplace("t","s"); lde2 -+ -?%at('diff(y(t),t,1),t=0)+s^2*'laplace(y(t),t,s)+2*'laplace(y(t),t,s)-2*'laplace(x(t),t,s)-y(0)*s -+ -+O resultado significa que -+ -+.. math:: -Y'(0) + s^2Y(s) + 2Y(s) - 2X(s) - sy(0) = 0. -+ -+ -+Em seguida, substitua a condição inicial para :math:`x(0)`, -+:math:`x'(0)`, :math:`y(0)`, e :math:`y'(0)`, e resolva as equações -+resultantes: -+ -+:: -+ -+ sage: var('s X Y') -+ (s, X, Y) -+ sage: eqns = [(2*s^2+6)*X-2*Y == 6*s, -2*X +(s^2+2)*Y == 3*s] -+ sage: solve(eqns, X,Y) -+ [[X == 3*(s^3 + 3*s)/(s^4 + 5*s^2 + 4), -+ Y == 3*(s^3 + 5*s)/(s^4 + 5*s^2 + 4)]] -+ -+Agora calcule a transformada de Laplace inversa para obter a resposta: -+ -+:: -+ -+ sage: var('s t') -+ (s, t) -+ sage: inverse_laplace((3*s^3 + 9*s)/(s^4 + 5*s^2 + 4),s,t) -+ cos(2*t) + 2*cos(t) -+ sage: inverse_laplace((3*s^3 + 15*s)/(s^4 + 5*s^2 + 4),s,t) -+ -cos(2*t) + 4*cos(t) -+ -+Portanto, a solução é -+ -+.. math:: x_1(t) = \cos(2t) + 2\cos(t), \quad x_2(t) = 4\cos(t) - \cos(2t). -+ -+ -+Ela pode ser representada em um gráfico parametricamente usando os -+comandos -+ -+:: -+ -+ sage: t = var('t') -+ sage: P = parametric_plot((cos(2*t) + 2*cos(t), 4*cos(t) - cos(2*t) ),\ -+ ... (t, 0, 2*pi), rgbcolor=hue(0.9)) -+ sage: show(P) -+ -+As componentes individuais podem ser representadas em gráfico usando -+ -+:: -+ -+ sage: t = var('t') -+ sage: p1 = plot(cos(2*t) + 2*cos(t), (t,0, 2*pi), rgbcolor=hue(0.3)) -+ sage: p2 = plot(4*cos(t) - cos(2*t), (t,0, 2*pi), rgbcolor=hue(0.6)) -+ sage: show(p1 + p2) -+ -+Leia mais sobre gráficos em :ref:`section-plot`. Veja a seção 5.5 de -+[NagleEtAl2004]_ (em inglês) para mais informações sobre equações -+diferenciais. -+ -+ -+Método de Euler para Sistemas de Equações Diferenciais -+------------------------------------------------------ -+ -+No próximo exemplo, vamos ilustrar o método de Euler para EDOs de -+primeira e segunda ordem. Primeiro, relembramos a ideia básica para -+equações de primeira ordem. Dado um problema de valor inicial da forma -+ -+.. math:: -+ -+ y'=f(x,y), \quad y(a)=c, -+ -+queremos encontrar o valor aproximado da solução em :math:`x=b` com -+:math:`b>a`. -+ -+Da definição de derivada segue que -+ -+.. math:: y'(x) \approx \frac{y(x+h)-y(x)}{h}, -+ -+ -+onde :math:`h>0` é um número pequeno. Isso, juntamente com a equação -+diferencial, implica que :math:`f(x,y(x))\approx -+\frac{y(x+h)-y(x)}{h}`. Agora resolvemos para :math:`y(x+h)`: -+ -+.. math:: y(x+h) \approx y(x) + h*f(x,y(x)). -+ -+ -+Se chamarmos :math:`h f(x,y(x))` de "termo de correção", :math:`y(x)` -+de "valor antigo de *y*", e :math:`y(x+h)` de "novo valor de *y*", -+então essa aproximação pode ser reescrita como -+ -+.. math:: y_{novo} \approx y_{antigo} + h*f(x,y_{antigo}). -+ -+ -+Se dividirmos o intervalo de *a* até *b* em *n* partes, de modo que -+:math:`h=\frac{b-a}{n}`, então podemos construir a seguinte tabela. -+ -+============== ================== ================ -+:math:`x` :math:`y` :math:`hf(x,y)` -+============== ================== ================ -+:math:`a` :math:`c` :math:`hf(a,c)` -+:math:`a+h` :math:`c+hf(a,c)` ... -+:math:`a+2h` ... -+... -+:math:`b=a+nh` ??? ... -+============== ================== ================ -+ -+ -+O objetivo é completar os espaços em branco na tabela, em uma linha -+por vez, até atingirmos ???, que é a aproximação para :math:`y(b)` -+usando o método de Euler. -+ -+A ideia para sistemas de EDOs é semelhante. -+ -+**Exemplo:** Aproxime numericamente :math:`z(t)` em :math:`t=1` usando -+4 passos do método de Euler, onde :math:`z''+tz'+z=0`, :math:`z(0)=1`, -+:math:`z'(0)=0`. -+ -+Devemos reduzir a EDO de segunda ordem a um sistema de duas EDOs de -+primeira ordem (usando :math:`x=z`, :math:`y=z'`) e aplicar o método -+de Euler: -+ -+:: -+ -+ sage: t,x,y = PolynomialRing(RealField(10),3,"txy").gens() -+ sage: f = y; g = -x - y * t -+ sage: eulers_method_2x2(f,g, 0, 1, 0, 1/4, 1) -+ t x h*f(t,x,y) y h*g(t,x,y) -+ 0 1 0.00 0 -0.25 -+ 1/4 1.0 -0.062 -0.25 -0.23 -+ 1/2 0.94 -0.12 -0.48 -0.17 -+ 3/4 0.82 -0.16 -0.66 -0.081 -+ 1 0.65 -0.18 -0.74 0.022 -+ -+Portanto, :math:`z(1)\approx 0.65`. -+ -+Podemos também representar em um gráfico os pontos :math:`(x,y)` para -+obter uma figura da solução aproximada. A função -+``eulers_method_2x2_plot`` fará isso; para usá-la, precisamos definir -+funções *f* e *g* que recebam um argumento com três coordenadas (*t*, -+*x*, *y*). -+ -+:: -+ -+ sage: f = lambda z: z[2] # f(t,x,y) = y -+ sage: g = lambda z: -sin(z[1]) # g(t,x,y) = -sin(x) -+ sage: P = eulers_method_2x2_plot(f,g, 0.0, 0.75, 0.0, 0.1, 1.0) -+ -+A esta altura, ``P`` armazena dois gráficos: ``P[0]``, o gráfico de -+*x* versus *t*, e ``P[1]``, o gráfico de *y* versus *t*. Podemos -+visualizar os dois gráficos da seguinte forma: -+ -+.. link -+ -+:: -+ -+ sage: show(P[0] + P[1]) -+ -+(Para mais sobre gráficos, veja :ref:`section-plot`.) -+ -+Funções Especiais -+----------------- -+ -+Diversos polinômios ortogonais e funções especiais estão -+implementadas, usando tanto o PARI [GP]_ como o Maxima [Max]_. Isso -+está documentado nas seções apropriadas ("Orthogonal polynomials" and -+"Special functions", respectivamente) do manual de referência do Sage -+(em inglês). -+ -+:: -+ -+ sage: x = polygen(QQ, 'x') -+ sage: chebyshev_U(2,x) -+ 4*x^2 - 1 -+ sage: bessel_I(1,1,"pari",250) -+ 0.56515910399248502720769602760986330732889962162109200948029448947925564096 -+ sage: bessel_I(1,1) -+ 0.565159103992485 -+ sage: bessel_I(2,1.1,"maxima") # last few digits are random -+ 0.16708949925104899 -+ -+No momento, essas funções estão disponíveis na interface do Sage -+apenas para uso numérico. Para uso simbólico, use a interface do -+Maxima diretamente, como no seguinte exemplo: -+ -+:: -+ -+ sage: maxima.eval("f:bessel_y(v, w)") -+ 'bessel_y(v,w)' -+ sage: maxima.eval("diff(f,w)") -+ '(bessel_y(v-1,w)-bessel_y(v+1,w))/2' -diff --git a/doc/pt/tutorial/tour_assignment.rst b/doc/pt/tutorial/tour_assignment.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_assignment.rst -@@ -0,0 +1,119 @@ -+Atribuição, Igualdade, e Aritmética -+=================================== -+ -+Com pequenas exceções, o Sage utiliza a linguagem de programação -+Python, logo a maioria dos livros de introdução ao Python vão ajudá-lo -+a aprender Sage. -+ -+O Sage usa ``=`` para atribuição, e usa ``==``, ``<=``, ``>=``, ``<`` -+e ``>`` para comparação: -+ -+:: -+ -+ sage: a = 5 -+ sage: a -+ 5 -+ sage: 2 == 2 -+ True -+ sage: 2 == 3 -+ False -+ sage: 2 < 3 -+ True -+ sage: a == 5 -+ True -+ -+O Sage fornece todas as operações matemáticas básicas: -+ -+:: -+ -+ sage: 2**3 # ** means exponent -+ 8 -+ sage: 2^3 # ^ is a synonym for ** (unlike in Python) -+ 8 -+ sage: 10 % 3 # for integer arguments, % means mod, i.e., remainder -+ 1 -+ sage: 10/4 -+ 5/2 -+ sage: 10//4 # for integer arguments, // returns the integer quotient -+ 2 -+ sage: 4 * (10 // 4) + 10 % 4 == 10 -+ True -+ sage: 3^2*4 + 2%5 -+ 38 -+ -+O cálculo de uma expressão como ``3^2*4 + 2%5`` depende da ordem em -+que as operações são aplicadas; isso é especificado na "tabela de -+precedência" em :ref:`section-precedence`. -+ -+O Sage também fornece várias funções matemáticas básicas; aqui estão -+apenas alguns exemplos: -+ -+:: -+ -+ sage: sqrt(3.4) -+ 1.84390889145858 -+ sage: sin(5.135) -+ -0.912021158525540 -+ sage: sin(pi/3) -+ 1/2*sqrt(3) -+ -+Como o último exemplo mostra, algumas expressões matemáticas retornam -+valores 'exatos' em vez de aproximações numéricas. Para obter uma -+aproximação numérica, use a função ``n`` ou o método ``n`` (ambos -+possuem um nome longo, ``numerical_approx``, e a função ``N`` é o -+mesma que ``n``). Essas funções aceitam o argumento opcional -+``prec``, que é o número de bits de precisão requisitado, e -+``digits``, que é o número de dígitos decimais de precisão -+requisitado; o padrão é 53 bits de precisão. -+ -+:: -+ -+ sage: exp(2) -+ e^2 -+ sage: n(exp(2)) -+ 7.38905609893065 -+ sage: sqrt(pi).numerical_approx() -+ 1.77245385090552 -+ sage: sin(10).n(digits=5) -+ -0.54402 -+ sage: N(sin(10),digits=10) -+ -0.5440211109 -+ sage: numerical_approx(pi, prec=200) -+ 3.1415926535897932384626433832795028841971693993751058209749 -+ -+O Python é uma linguagem "dinâmicamente digitada" (dynamically typed), -+portanto o valor referido por cada variável possui um tipo associado a -+ele, mas uma variável pode possuir valores de qualquer tipo em -+determinado escopo: -+ -+:: -+ -+ sage: a = 5 # a is an integer -+ sage: type(a) -+ -+ sage: a = 5/3 # now a is a rational number -+ sage: type(a) -+ -+ sage: a = 'hello' # now a is a string -+ sage: type(a) -+ -+ -+A linguagem de programação C, que é "estaticamente digitada" -+(statically typed), é muito diferente; uma variável que foi declarada -+como int pode apenas armazenar um int em seu escopo. -+ -+Uma potencial fonte de confusão em Python é que um inteiro literal que -+começa com zero é tratado como um número octal, isto é, um número na -+base 8. -+ -+:: -+ -+ sage: 011 -+ 9 -+ sage: 8 + 1 -+ 9 -+ sage: n = 011 -+ sage: n.str(8) # string representation of n in base 8 -+ '11' -+ -+Isso é consistente com a linguagem de programação C. -diff --git a/doc/pt/tutorial/tour_coercion.rst b/doc/pt/tutorial/tour_coercion.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_coercion.rst -@@ -0,0 +1,405 @@ -+.. -*- coding: utf-8 -*- -+ -+.. _section-coercion: -+ -+============================ -+Parentes, Conversão e Coação -+============================ -+ -+Esta seção pode parecer mais técnica do que as anteriores, mas -+acreditamos que é importante entender o significado de parentes e -+coação de modo a usar anéis e outras estruturas algébricas no Sage de -+forma efetiva e eficiente. -+ -+Note que vamos explicar algumas noções, mas não vamos mostrar aqui -+como implementá-las. Um tutorial voltado à implementação está -+disponível (em inglês) como um -+`arquivo Sage `_. -+ -+Elementos -+--------- -+ -+Caso se queira implementar um anel em Python, uma primeira aproximação -+seria criar uma classe para os elementos ``X`` do anel e adicionar os -+requeridos métodos (com underscores duplos) ``__add__``, ``__sub``, -+``__mul__``, obviamente garantindo que os axiomas de anel são -+verificados. -+ -+Como o Python é uma linguagem "strongly typed" (ainda que "dynamically -+typed"), poderia-se, pelo menos a princípio, esperar-se que fosse -+implementado em Python uma classe para cada anel. No final das contas, -+o Python contém um tipo ```` para os inteiros, um tipo -+```` para os reais, e assim por diante. Mas essa estratégia -+logo encontra uma limitação: Existe um número infinito de anéis, e não -+se pode implementar um número infinito de classes. -+ -+Em vez disso, poderia-se criar uma hierarquia de classes projetada -+para implementar elementos de estruturas algébricas ubíquas, tais como -+grupos, anéis, anéis comutativos, corpos, álgebras, e assim por -+diante. -+ -+Mas isso significa que elementos de anéis bastante diferentes podem -+ter o mesmo tipo. -+ -+:: -+ -+ sage: P. = GF(3)[] -+ sage: Q. = GF(4,'z')[] -+ sage: type(x)==type(a) -+ True -+ -+Por outro lado, poderia-se ter também classes diferentes em Python -+fornecendo implementações diferentes da mesma estrutura matemática -+(por exemplo, matrizes densas versus matrizes esparsas). -+ -+:: -+ -+ sage: P.
= PolynomialRing(ZZ) -+ sage: Q. = PolynomialRing(ZZ, sparse=True) -+ sage: R. = PolynomialRing(ZZ, implementation='NTL') -+ sage: type(a); type(b); type(c) -+ -+ -+ -+ -+Isso apresenta dois problemas: Por um lado, se tivéssemos elementos -+que são duas instancias da mesma classe, então poderia-se esperar que -+o método ``__add__`` dessas classes permitisse somá-los; mas não -+se deseja isso, se os elementos pertencem a anéis bastante diferentes. -+Por outro lado, se possui-se elementos que pertencem a implementações -+diferentes do mesmo anel, então gostaria-se de somá-los, mas isso não -+pode ser feito diretamente se eles pertencem a classes diferentes em -+Python. -+ -+A solução para esses problemas é chamada coação e será explicada a -+seguir. -+ -+Todavia, é essencial que cada elemento saiba a qual pertence. Isso -+está disponível através método ``parent()``: -+ -+.. link -+ -+:: -+ -+ sage: a.parent(); b.parent(); c.parent() -+ Univariate Polynomial Ring in a over Integer Ring -+ Sparse Univariate Polynomial Ring in b over Integer Ring -+ Univariate Polynomial Ring in c over Integer Ring (using NTL) -+ -+ -+Parentes e Categorias -+--------------------- -+ -+De forma similar à hierarquia de classes em Python voltada para -+elementos de estruturas algébricas, o Sage também fornece classes para -+as estruturas algébricas que contém esses elementos. Estruturas -+contendo elementos são chamadas "estruturas parente" no Sage, e existe -+uma classe básica para elas. Paralelamente à hierarquia de noções -+matemáticas, tem-se uma hierarquia de classes, a saber, para -+conjuntos, anéis, corpos e assim por diante: -+ -+:: -+ -+ sage: isinstance(QQ,Field) -+ True -+ sage: isinstance(QQ, Ring) -+ True -+ sage: isinstance(ZZ,Field) -+ False -+ sage: isinstance(ZZ, Ring) -+ True -+ -+Em álgebra, objetos que compartilham o mesmo tipo de estruturas -+algébricas são agrupados nas assim chamadas "categorias". Logo, existe -+uma analogia aproximada entre a hierarquia de classes em Sage e a -+hierarquia de categorias. Todavia, essa analogia de classes em Python -+e categorias não deve ser enfatizada demais. No final das contas, -+categorias matemáticas também são implementadas no Sage: -+ -+:: -+ -+ sage: Rings() -+ Category of rings -+ sage: ZZ.category() -+ Category of euclidean domains -+ sage: ZZ.category().is_subcategory(Rings()) -+ True -+ sage: ZZ in Rings() -+ True -+ sage: ZZ in Fields() -+ False -+ sage: QQ in Fields() -+ True -+ -+Enquanto a hierarquia de classes no Sage é centrada nos detalhes de -+implementação, a construção de categorias em Sage é mais centrada -+na estrutura matemática. É possível implementar métodos e testes -+gerais independentemente de uma implementação específica nas -+categorias. -+ -+Estruturas parentes em Sage são supostamente objetos únicos em Python. -+Por exemplo, uma vez que um anel de polinômios sobre um certo anel -+base e com uma certa lista de geradores é criada, o resultado é -+arquivado: -+ -+:: -+ -+ sage: RR['x','y'] is RR['x','y'] -+ True -+ -+ -+Tipos versus Parentes -+--------------------- -+ -+O tipo ``RingElement`` não deve ser confundido com a noção matemática -+de elemento de anel; por razões práticas, as vezes um objeto é uma -+instancia de ``RingElement`` embora ele não pertence a um anel: -+ -+:: -+ -+ sage: M = Matrix(ZZ,2,3); M -+ [0 0 0] -+ [0 0 0] -+ sage: isinstance(M, RingElement) -+ True -+ -+Enquanto *parentes* são únicos, elementos iguais de um parente em Sage -+não são necessariamente idênticos. Isso contrasta com o comportamento -+do Python para alguns (embora não todos) inteiros: -+ -+:: -+ -+ sage: int(1) is int(1) # Python int -+ True -+ sage: int(-15) is int(-15) -+ False -+ sage: 1 is 1 # Sage Integer -+ False -+ -+É importante observar que elementos de anéis diferentes em geral não -+podem ser distinguidos pelos seus tipos, mas sim por seus parentes: -+ -+:: -+ -+ sage: a = GF(2)(1) -+ sage: b = GF(5)(1) -+ sage: type(a) is type(b) -+ True -+ sage: parent(a) -+ Finite Field of size 2 -+ sage: parent(b) -+ Finite Field of size 5 -+ -+Logo, de um ponto de vista algébrico, **o parente de um elemento é -+mais importante do que seu tipo.** -+ -+Conversão versus Coação -+----------------------- -+ -+Em alguns casos é possível converter um elemento de uma estrutura -+parente em um elemento de uma outra estrutura parente. Tal conversão -+pode ser tanto explícita como implícita (essa é chamada *coação*). -+ -+O leitor pode conhecer as noções de *conversão de tipo* e *coação de -+tipo* como na linguagem C, por exemplo. Existem noções de *conversão* -+e *coação* em Sage também. Mas as noções em Sage são centradas em -+*parentes*, não em tipos. Então, por favor não confunda conversão de -+tipo em C com conversão em Sage! -+ -+Aqui se encontra uma breve apresentação. Para uma descrição detalhada -+e informações sobre a implementação, referimos à seção sobre coação no -+manual de referência e para o `arquivo tutorial -+`_. -+ -+Existem duas possibilidades extremas com respeito à possibilidade de -+fazer aritmética com elementos de *anéis diferentes*: -+ -+* Anéis diferentes são mundos diferentes, e não faz nenhum sentido -+ somar ou multiplicar elementos de anéis diferentes; mesmo ``1 + -+ 1/2`` não faz sentido, pois o primeiro somando é um inteiro e o -+ segundo um racional. -+ -+Ou -+ -+* Se um elemento ``r1`` de uma aner ``R1`` pode de alguma forma ser -+ interpretado em um outro anel ``R2``, então todas as operações -+ aritméticas envolvendo ``r1`` e qualquer elemento de ``R2`` são -+ permitidas. O elemento neutro da multiplicação existe em todos os -+ corpos e em vários anéis, e eles devem ser todos iguais. -+ -+O Sage faz uma concessão. Se ``P1`` e ``P2`` são estruturas parentes e -+``p1`` é um elemento de ``P1``, então o usuário pode explicitamente -+perguntar por uma interpretação de ``p1`` em ``P2``. Isso pode não -+fazer sentido em todos os casos ou não estar definido para todos os -+elementos de ``P1``, e fica a cargo do usuário assegurar que isso faz -+sentido. Nos referimos a isso como **conversão**: -+ -+:: -+ -+ sage: a = GF(2)(1) -+ sage: b = GF(5)(1) -+ sage: GF(5)(a) == b -+ True -+ sage: GF(2)(b) == a -+ True -+ -+Todavia, uma conversão *implícita* (ou automática) ocorrerá apenas se -+puder ser feita *completamente* e *consistentemente*. Rigor matemático -+é essencial nesse ponto. -+ -+Uma tal conversão implícita é chamada **coação**. Se coação for -+definida, então deve coincidir com conversão. Duas condições devem ser -+satisfeitas para uma coação ser definida: -+ -+#. Uma coação de ``P1`` para ``P2`` deve ser dada por uma estrutura -+ que preserva mapeamentos (por exemplo, um homomorfismo de anéis). -+ Não é suficiente que *alguns* elementos de ``P1`` possam ser -+ mapeados em ``P2``, e o mapa deve respeitar a estrutura algébrica -+ de ``P1``. -+#. A escolha desses mapas de coação deve ser consistente: Se ``P3`` é -+ uma terceira estrutura parente, então a composição da coação -+ adotada de ``P1`` para ``P2`` com a coação de ``P2`` para ``P3`` -+ deve coincidir com a coação adotada de ``P1`` para ``P3``. Em -+ particular, se existir uma coação de ``P1`` para ``P2`` e ``P2`` -+ para ``P1``, a composição deve ser o mapa identidade em ``P1``. -+ -+Logo, embora é possível converter cada elemento de ``GF(2)`` para -+``GF(5)``, não há coação, pois não existe homomorfismo de anel entre -+``GF(2)`` e ``GF(5)``. -+ -+O segundo aspecto - consistência - é um pouco mais difícil de -+explicar. Vamos ilustrá-lo usando anéis de polinômios em mais de uma -+variável. Em aplicações, certamente faz mais sentido ter coações que -+preservam nomes. Então temos: -+ -+:: -+ -+ sage: R1. = ZZ[] -+ sage: R2 = ZZ['y','x'] -+ sage: R2.has_coerce_map_from(R1) -+ True -+ sage: R2(x) -+ x -+ sage: R2(y) -+ y -+ -+Se não existir homomorfismo de anel que preserve nomes, coerção não é -+definida. Todavia, conversão pode ainda ser possível, a saber, -+mapeando geradores de anel de acordo com sua posição da lista de -+geradores: -+ -+.. link -+ -+:: -+ -+ sage: R3 = ZZ['z','x'] -+ sage: R3.has_coerce_map_from(R1) -+ False -+ sage: R3(x) -+ z -+ sage: R3(y) -+ x -+ -+Mas essas conversões que preservam a posição não se qualificam como -+coação: Compondo um mapa que preserva nomes de ``ZZ['x','y']`` para -+``ZZ['y','x']``, com um mapa que preserva nomes de ``ZZ['y','x']`` -+para ``ZZ['a','b']``, resultaria em um mapa que não preserva nomes nem -+posição, violando a consistência. -+ -+Se houver coação, ela será usada para comparar elementos de anéis -+diferentes ou fazer aritmética. Isso é frequentemente conveniente, mas -+o usuário deve estar ciente que estender a relação ``==`` além das -+fronteiras de parentes diferentes pode facilmente resultar em -+problemas. Por exemplo, enquanto ``==`` é supostamente uma relação de -+equivalência sobre os elementos de *um* anel, isso não é -+necessariamente o caso se anéis *diferentes* estão envolvidos. Por -+exemplo, ``1`` em ``ZZ`` e em um corpo finito são considerados iguais, -+pois existe uma coação canônica dos inteiros em qualquer corpo finito. -+Todavia, em geral não existe coação entre dois corpos finitos -+diferentes. Portanto temos -+ -+.. link -+ -+:: -+ -+ sage: GF(5)(1) == 1 -+ True -+ sage: 1 == GF(2)(1) -+ True -+ sage: GF(5)(1) == GF(2)(1) -+ False -+ sage: GF(5)(1) != GF(2)(1) -+ True -+ -+Similarmente, -+ -+.. link -+ -+:: -+ -+ sage: R3(R1.1) == R3.1 -+ True -+ sage: R1.1 == R3.1 -+ False -+ sage: R1.1 != R3.1 -+ True -+ -+Uma outra consequência da condição de consistência é que coação pode -+apenas ir de anéis exatos (por exemplo, os racionais ``QQ``) para -+anéis não-exatos (por exemplo, os números reais com uma precisão fixa -+``RR``), mas não na outra direção. A razão é que a composição da -+coação de ``QQ`` em ``RR`` com a conversão de ``RR`` para ``QQ`` -+deveria ser a identidade em ``QQ``. Mas isso é impossível, pois alguns -+números racionais distintos podem ser tratados como iguais em ``RR``, -+como no seguinte exemplo: -+ -+:: -+ -+ sage: RR(1/10^200+1/10^100) == RR(1/10^100) -+ True -+ sage: 1/10^200+1/10^100 == 1/10^100 -+ False -+ -+Quando se compara elementos de dois parentes ``P1`` e ``P2``, é -+possível que não haja coação entre os dois anéis, mas existe uma -+escolha canônica de um parente ``P3`` de modo que tanto ``P1`` como -+``P2`` são coagidos em ``P3``. Nesse caso, coação vai ocorrer também. -+Um caso de uso típico é na soma de um número racional com um polinômio -+com coeficientes inteiros, resultando em um polinômio com coeficientes -+racionais: -+ -+:: -+ -+ sage: P1. = ZZ[] -+ sage: p = 2*x+3 -+ sage: q = 1/2 -+ sage: parent(p) -+ Univariate Polynomial Ring in x over Integer Ring -+ sage: parent(p+q) -+ Univariate Polynomial Ring in x over Rational Field -+ -+Note que a princípio o resultado deveria também fazer sentido no -+corpo de frações de ``ZZ['x']``. Todavia, o Sage tenta escolher um -+parente *canônico* comum que parece ser o mais natural (``QQ['x']`` no -+nosso exemplo). Se vários potenciais parentes comuns parecem -+igualmente naturais, o Sage *não* vai escolher um deles -+aleatoriamente. Os mecanismos sobre os quais essa escolha se baseia é -+explicado em um `arquivo tutorial -+`_ -+ -+Nenhuma coação para um parente comum vai ocorrer no seguinte exemplo: -+ -+:: -+ -+ sage: R. = QQ[] -+ sage: S. = QQ[] -+ sage: x+y -+ Traceback (most recent call last): -+ ... -+ TypeError: unsupported operand parent(s) for '+': 'Univariate Polynomial Ring in x over Rational Field' and 'Univariate Polynomial Ring in y over Rational Field' -+ -+A razão é que o Sage não escolhe um dos potenciais candidatos -+``QQ['x']['y']``, ``QQ['y']['x']``, ``QQ['x','y']`` ou -+``QQ['y','x']``, porque todas essas estruturas combinadas em pares -+diferentes parecem ser parentes comuns naturais, e não existe escolha -+canônica aparente. -diff --git a/doc/pt/tutorial/tour_functions.rst b/doc/pt/tutorial/tour_functions.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_functions.rst -@@ -0,0 +1,236 @@ -+.. _section-functions-issues: -+ -+Algumas Questões Frequentes sobre Funções -+========================================= -+ -+Alguns aspectos sobre definição de funções (por exemplo, para -+diferenciação, ou para criar gráficos) podem se tornar confusos. Nesta -+seção, procuramos tratar algumas questões relevantes. -+ -+Aqui estão várias formas de definir objetos que merecem ser chamamos -+de "funções": -+ -+1. Defina uma função em Python, como descrito em -+:ref:`section-functions`. Essas funções podem ser usadas para criar -+gráficos, mas não podem ser diferenciadas ou integradas. -+ -+:: -+ -+ sage: def f(z): return z^2 -+ sage: type(f) -+ -+ sage: f(3) -+ 9 -+ sage: plot(f, 0, 2) -+ -+Na última linha, observe a sintaxe. Se fosse usado ``plot(f(z), 0, -+2)`` ocorreria um erro, porque ``z`` é uma variável muda na definição -+de ``f`` e não está definida fora do contexto da função. De fato, -+somente ``f(z)`` já provoca um erro. Os seguintes comandos vão -+funcionar neste caso, embora em geral eles devam ser evitados pois -+podem ocasionar erros (veja o item 4 abaixo). -+ -+.. link -+ -+:: -+ -+ sage: var('z') # define z to be a variable -+ z -+ sage: f(z) -+ z^2 -+ sage: plot(f(z), 0, 2) -+ -+Acima, ``f(z)`` é uma expressão simbólica, o próximo item na nossa -+lista. -+ -+2. Defina um "expressão simbólica que pode ser evocada". Essas podem -+ser usadas para criar gráficos, e podem ser diferenciadas ou -+integradas. -+ -+:: -+ -+ sage: g(x) = x^2 -+ sage: g # g sends x to x^2 -+ x |--> x^2 -+ sage: g(3) -+ 9 -+ sage: Dg = g.derivative(); Dg -+ x |--> 2*x -+ sage: Dg(3) -+ 6 -+ sage: type(g) -+ -+ sage: plot(g, 0, 2) -+ -+Note que enquanto ``g`` é uma expressão simbólica que pode ser -+evocada, ``g(x)`` é um objeto diferente, embora relacionado, que pode -+ser usado para criar gráficos, ou ser diferenciado, integrado, etc., -+embora com algumas ressalvas: veja o item 5 abaixo. -+ -+.. link -+ -+:: -+ -+ sage: g(x) -+ x^2 -+ sage: type(g(x)) -+ -+ sage: g(x).derivative() -+ 2*x -+ sage: plot(g(x), 0, 2) -+ -+3. Use uma função pré-definida. Essas podem ser representadas em -+gráfico, e com uma pequena ajuda, diferenciadas e integradas. -+ -+:: -+ -+ sage: type(sin) -+ -+ sage: plot(sin, 0, 2) -+ sage: type(sin(x)) -+ -+ sage: plot(sin(x), 0, 2) -+ -+Por si só, ``sin`` não pode ser diferenciado, pelo menos não para -+produzir ``cos``. -+ -+:: -+ -+ sage: f = sin -+ sage: f.derivative() -+ Traceback (most recent call last): -+ ... -+ AttributeError: ... -+ -+Usando ``f = sin(x)`` no lugar de ``sin`` funciona, mas é ainda melhor -+usar ``f(x) = sin(x)`` para definir uma expressão simbólica que pode -+ser evocada. -+ -+:: -+ -+ sage: S(x) = sin(x) -+ sage: S.derivative() -+ x |--> cos(x) -+ -+Aqui estão alguns problemas comuns, com explicações: -+ -+\4. Cálculo acidental. -+ -+:: -+ -+ sage: def h(x): -+ ... if x<2: -+ ... return 0 -+ ... else: -+ ... return x-2 -+ -+O problema: ``plot(h(x), 0, 4)`` cria o gráfico da reta `y=x-2`, não -+da função definida por ``h``. O motivo? No comando ``plot(h(x), 0, -+4)``, primeiro ``h(x)`` é calculada: isso significa substituir ``x`` -+na função ``h``, o que significa que ``x<2`` é calculado. -+ -+.. link -+ -+:: -+ -+ sage: type(x<2) -+ -+ -+Quando uma equação simbólica é calculada, como na definição de ``h``, -+se ela não é obviamente verdadeira, então ela retorna False. Logo -+``h(x)`` é calculada como ``x-2``, e essa é a função que será -+representada no gráfico. -+ -+A solução: não use ``plot(h(x), 0, 4)``; em vez disso, use -+ -+.. link -+ -+:: -+ -+ sage: plot(h, 0, 4) -+ -+\5. Acidentalmente produzindo uma constante em vez de uma função. -+ -+:: -+ -+ sage: f = x -+ sage: g = f.derivative() -+ sage: g -+ 1 -+ -+O problema: ``g(3)``, por exemplo, retorna o erro "ValueError: the -+number of arguments must be less than or equal to 0." -+ -+.. link -+ -+:: -+ -+ sage: type(f) -+ -+ sage: type(g) -+ -+ -+``g`` não é uma função, é uma constante, logo não possui variáveis -+associadas, e você não pode substituir nenhum valor em ``g``. -+ -+Solução: existem vária opções. -+ -+- Defina ``f`` inicialmente como uma expressão simbólica. -+ -+:: -+ -+ sage: f(x) = x # instead of 'f = x' -+ sage: g = f.derivative() -+ sage: g -+ x |--> 1 -+ sage: g(3) -+ 1 -+ sage: type(g) -+ -+ -+- Ou com ``f`` como definida originalmente, defina ``g`` como uma -+ expressão simbólica. -+ -+:: -+ -+ sage: f = x -+ sage: g(x) = f.derivative() # instead of 'g = f.derivative()' -+ sage: g -+ x |--> 1 -+ sage: g(3) -+ 1 -+ sage: type(g) -+ -+ -+- Ou com ``f`` e ``g`` como definidas originalmente, especifique a -+ variável para a qual você está substituindo. -+ -+:: -+ -+ sage: f = x -+ sage: g = f.derivative() -+ sage: g -+ 1 -+ sage: g(x=3) # instead of 'g(3)' -+ 1 -+ -+Finalmente, aqui vai mais uma forma de saber a diferença entre as -+derivadas de ``f = x`` e ``f(x) = x``. -+ -+:: -+ -+ sage: f(x) = x -+ sage: g = f.derivative() -+ sage: g.variables() # the variables present in g -+ () -+ sage: g.arguments() # the arguments which can be plugged into g -+ (x,) -+ sage: f = x -+ sage: h = f.derivative() -+ sage: h.variables() -+ () -+ sage: h.arguments() -+ () -+ -+Como esse exemplo procura ilustrar, ``h`` não aceita argumentos, e é -+por isso que ``h(3)`` retorna um erro. -diff --git a/doc/pt/tutorial/tour_groups.rst b/doc/pt/tutorial/tour_groups.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_groups.rst -@@ -0,0 +1,92 @@ -+Grupos Finitos, Grupos Abelianos -+================================ -+ -+O Sage possui suporte para fazer cálculos com grupos de permutação, -+grupos finitos clássicos (tais como :math:`SU(n,q)`), grupos -+matriciais finitos (com os seus próprios geradores), e grupos -+abelianos (até mesmo infinitos). A maior parte disso é implementada -+usando a interface com o GAP. -+ -+Por exemplo, para criar um grupo de permutação, forneça uma lista de -+geradores, como no seguinte exemplo. -+ -+:: -+ -+ sage: G = PermutationGroup(['(1,2,3)(4,5)', '(3,4)']) -+ sage: G -+ Permutation Group with generators [(3,4), (1,2,3)(4,5)] -+ sage: G.order() -+ 120 -+ sage: G.is_abelian() -+ False -+ sage: G.derived_series() # random-ish output -+ [Permutation Group with generators [(1,2,3)(4,5), (3,4)], -+ Permutation Group with generators [(1,5)(3,4), (1,5)(2,4), (1,3,5)]] -+ sage: G.center() -+ Subgroup of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) generated by [()] -+ sage: G.random_element() # random output -+ (1,5,3)(2,4) -+ sage: print latex(G) -+ \langle (3,4), (1,2,3)(4,5) \rangle -+ -+Você pode também obter a tabela de caracteres (em formato LaTeX) no -+Sage: -+ -+:: -+ -+ sage: G = PermutationGroup([[(1,2),(3,4)], [(1,2,3)]]) -+ sage: latex(G.character_table()) -+ \left(\begin{array}{rrrr} -+ 1 & 1 & 1 & 1 \\ -+ 1 & 1 & -\zeta_{3} - 1 & \zeta_{3} \\ -+ 1 & 1 & \zeta_{3} & -\zeta_{3} - 1 \\ -+ 3 & -1 & 0 & 0 -+ \end{array}\right) -+ -+O Sage também inclui grupos clássicos matriciais sobre corpos finitos: -+ -+:: -+ -+ sage: MS = MatrixSpace(GF(7), 2) -+ sage: gens = [MS([[1,0],[-1,1]]),MS([[1,1],[0,1]])] -+ sage: G = MatrixGroup(gens) -+ sage: G.conjugacy_class_representatives() -+ [ -+ [1 0] -+ [0 1], -+ [0 1] -+ [6 1], -+ ... -+ [6 0] -+ [0 6] -+ ] -+ sage: G = Sp(4,GF(7)) -+ sage: G._gap_init_() -+ 'Sp(4, 7)' -+ sage: G -+ Symplectic Group of rank 2 over Finite Field of size 7 -+ sage: G.random_element() # random output -+ [5 5 5 1] -+ [0 2 6 3] -+ [5 0 1 0] -+ [4 6 3 4] -+ sage: G.order() -+ 276595200 -+ -+Você também pode fazer cálculos usando grupos abelianos (finitos ou -+infinitos): -+ -+:: -+ -+ sage: F = AbelianGroup(5, [5,5,7,8,9], names='abcde') -+ sage: (a, b, c, d, e) = F.gens() -+ sage: d * b**2 * c**3 -+ b^2*c^3*d -+ sage: F = AbelianGroup(3,[2]*3); F -+ Multiplicative Abelian Group isomorphic to C2 x C2 x C2 -+ sage: H = AbelianGroup([2,3], names="xy"); H -+ Multiplicative Abelian Group isomorphic to C2 x C3 -+ sage: AbelianGroup(5) -+ Multiplicative Abelian Group isomorphic to Z x Z x Z x Z x Z -+ sage: AbelianGroup(5).order() -+ +Infinity -diff --git a/doc/pt/tutorial/tour_help.rst b/doc/pt/tutorial/tour_help.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_help.rst -@@ -0,0 +1,363 @@ -+.. _chapter-help: -+ -+Obtendo ajuda -+============= -+ -+O Sage possui vasta documentação, acessível digitando o nome de uma -+função ou constante (por exemplo), seguido pelo ponto de interrogação: -+ -+.. skip -+ -+:: -+ -+ sage: tan? -+ Type: -+ Definition: tan( [noargspec] ) -+ Docstring: -+ -+ The tangent function -+ -+ EXAMPLES: -+ sage: tan(pi) -+ 0 -+ sage: tan(3.1415) -+ -0.0000926535900581913 -+ sage: tan(3.1415/4) -+ 0.999953674278156 -+ sage: tan(pi/4) -+ 1 -+ sage: tan(1/2) -+ tan(1/2) -+ sage: RR(tan(1/2)) -+ 0.546302489843790 -+ sage: log2? -+ Type: -+ Definition: log2( [noargspec] ) -+ Docstring: -+ -+ The natural logarithm of the real number 2. -+ -+ EXAMPLES: -+ sage: log2 -+ log2 -+ sage: float(log2) -+ 0.69314718055994529 -+ sage: RR(log2) -+ 0.693147180559945 -+ sage: R = RealField(200); R -+ Real Field with 200 bits of precision -+ sage: R(log2) -+ 0.69314718055994530941723212145817656807550013436025525412068 -+ sage: l = (1-log2)/(1+log2); l -+ (1 - log(2))/(log(2) + 1) -+ sage: R(l) -+ 0.18123221829928249948761381864650311423330609774776013488056 -+ sage: maxima(log2) -+ log(2) -+ sage: maxima(log2).float() -+ .6931471805599453 -+ sage: gp(log2) -+ 0.6931471805599453094172321215 # 32-bit -+ 0.69314718055994530941723212145817656807 # 64-bit -+ sage: sudoku? -+ File: sage/local/lib/python2.5/site-packages/sage/games/sudoku.py -+ Type: -+ Definition: sudoku(A) -+ Docstring: -+ -+ Solve the 9x9 Sudoku puzzle defined by the matrix A. -+ -+ EXAMPLE: -+ sage: A = matrix(ZZ,9,[5,0,0, 0,8,0, 0,4,9, 0,0,0, 5,0,0, -+ 0,3,0, 0,6,7, 3,0,0, 0,0,1, 1,5,0, 0,0,0, 0,0,0, 0,0,0, 2,0,8, 0,0,0, -+ 0,0,0, 0,0,0, 0,1,8, 7,0,0, 0,0,4, 1,5,0, 0,3,0, 0,0,2, -+ 0,0,0, 4,9,0, 0,5,0, 0,0,3]) -+ sage: A -+ [5 0 0 0 8 0 0 4 9] -+ [0 0 0 5 0 0 0 3 0] -+ [0 6 7 3 0 0 0 0 1] -+ [1 5 0 0 0 0 0 0 0] -+ [0 0 0 2 0 8 0 0 0] -+ [0 0 0 0 0 0 0 1 8] -+ [7 0 0 0 0 4 1 5 0] -+ [0 3 0 0 0 2 0 0 0] -+ [4 9 0 0 5 0 0 0 3] -+ sage: sudoku(A) -+ [5 1 3 6 8 7 2 4 9] -+ [8 4 9 5 2 1 6 3 7] -+ [2 6 7 3 4 9 5 8 1] -+ [1 5 8 4 6 3 9 7 2] -+ [9 7 4 2 1 8 3 6 5] -+ [3 2 6 7 9 5 4 1 8] -+ [7 8 2 9 3 4 1 5 6] -+ [6 3 5 1 7 2 8 9 4] -+ [4 9 1 8 5 6 7 2 3] -+ -+O Sage também fornece completamento tab: digite as primeiras letras de -+uma função e então pressione a tecla tab. Por exemplo, se você digitar -+``ta`` seguido de ``TAB``, o Sage vai imprimir ``tachyon, tan, tanh, -+taylor``. Essa é uma boa forma de encontrar nomes de funções e outras -+estruturas no Sage. -+ -+ -+.. _section-functions: -+ -+Funções, Tabulação, e Contagem -+=============================== -+ -+Para definir uma nova função no Sage, use o comando ``def`` e dois -+pontos após a lista de nomes das variáveis. Por exemplo: -+ -+:: -+ -+ sage: def is_even(n): -+ ... return n%2 == 0 -+ ... -+ sage: is_even(2) -+ True -+ sage: is_even(3) -+ False -+ -+Observação: Dependendo da versão do tutorial que você está lendo, -+você pode ver três pontos ``...`` na segunda linha desse exemplo. Não -+digite esses pontos; eles são apenas para enfatizar que o código está -+tabulado. Se for esse o caso, pressione [Enter] uma vez após o fim do -+bloco de código para inserir uma linha em branco e concluir a -+definição da função. -+ -+Você não especifica o tipo de dado de nenhum dos argumentos da função. -+É possível especificar argumentos múltiplos, cada um dos quais pode -+ter um valor opcional padrão. Por exemplo, a função abaixo usa o valor -+padrão ``divisor=2`` se ``divisor`` não é especificado. -+ -+:: -+ -+ sage: def is_divisible_by(number, divisor=2): -+ ... return number%divisor == 0 -+ sage: is_divisible_by(6,2) -+ True -+ sage: is_divisible_by(6) -+ True -+ sage: is_divisible_by(6, 5) -+ False -+ -+Você também pode especificar explicitamente um ou mais argumentos -+quando evocar uma função; se você especificar os argumentos -+explicitamente, você pode fazê-lo em qualquer ordem: -+ -+.. link -+ -+:: -+ -+ sage: is_divisible_by(6, divisor=5) -+ False -+ sage: is_divisible_by(divisor=2, number=6) -+ True -+ -+Em Python, blocos de código não são indicados por colchetes ou blocos -+de início e fim, como em outras linguagens. Em vez disso, blocos de -+código são indicados por tabulação, que devem estar alinhadas -+exatamente. Por exemplo, o seguinte código possui um erro de sintaxe -+porque o comando ``return`` não possui a mesma tabulação da linha que -+inicia o seu bloco de código. -+ -+.. skip -+ -+:: -+ -+ sage: def even(n): -+ ... v = [] -+ ... for i in range(3,n): -+ ... if i % 2 == 0: -+ ... v.append(i) -+ ... return v -+ Syntax Error: -+ return v -+ -+Se você corrigir a tabulação, a função fica correta: -+ -+:: -+ -+ sage: def even(n): -+ ... v = [] -+ ... for i in range(3,n): -+ ... if i % 2 == 0: -+ ... v.append(i) -+ ... return v -+ sage: even(10) -+ [4, 6, 8] -+ -+Não é necessário inserir ponto-e-vírgula no final da linha. Todavia, -+você pode inserir múltiplos comandos em uma mesma linha separados por -+ponto-e-vírgula: -+ -+:: -+ -+ sage: a = 5; b = a + 3; c = b^2; c -+ 64 -+ -+Se você quiser que uma única linha de comando seja escrita em mais de -+uma linha, use a barra invertida para quebrar a linha: -+ -+:: -+ -+ sage: 2 + \ -+ ... 3 -+ 5 -+ -+Em Sage, a contagem é feita iterando sobre um intervalo de inteiros. -+Por exemplo, a primeira linha abaixo é equivalente a ``for(i=0; i<3; -+i++)`` em C++ ou Java: -+ -+:: -+ -+ sage: for i in range(3): -+ ... print i -+ 0 -+ 1 -+ 2 -+ -+A primeira linha abaixo é equivalente a ``for(i=2; i<5; i++)``. -+ -+:: -+ -+ sage: for i in range(2,5): -+ ... print i -+ 2 -+ 3 -+ 4 -+ -+O Terceiro argumento controla o passo. O comando abaixo é equivalente -+a ``for(i=1; i<6; i+=2)``. -+ -+:: -+ -+ sage: for i in range(1,6,2): -+ ... print i -+ 1 -+ 3 -+ 5 -+ -+Frequentemente deseja-se criar uma tabela para visualizar resultados -+calculados com o Sage. Uma forma fácil de fazer isso é utilizando -+formatação de strings. Abaixo, criamos três colunas cada uma com -+largura exatamente 6, e fazemos uma tabela com quadrados e cubos de -+alguns números. -+ -+:: -+ -+ sage: for i in range(5): -+ ... print '%6s %6s %6s'%(i, i^2, i^3) -+ 0 0 0 -+ 1 1 1 -+ 2 4 8 -+ 3 9 27 -+ 4 16 64 -+ -+A estrutura de dados mais básica em Sage é a lista, que é -- como o -+nome sugere -- simplesmente uma lista de objetos arbitrários. Por -+exemplo, o comando ``range`` que usamos acima cria uma lista: -+ -+:: -+ -+ sage: range(2,10) -+ [2, 3, 4, 5, 6, 7, 8, 9] -+ -+Abaixo segue uma lista mais complicada: -+ -+:: -+ -+ sage: v = [1, "hello", 2/3, sin(x^3)] -+ sage: v -+ [1, 'hello', 2/3, sin(x^3)] -+ -+Listas são indexadas começando do 0, como em várias linguagens de -+programação. -+ -+.. link -+ -+:: -+ -+ sage: v[0] -+ 1 -+ sage: v[3] -+ sin(x^3) -+ -+Use ``len(v)`` para obter o comprimento de ``v``, use -+``v.append(obj)`` para inserir um novo objeto no final de ``v``, e use -+``del v[i]`` para remover o :math:`i`-ésimo elemento de ``v``: -+ -+.. link -+ -+:: -+ -+ sage: len(v) -+ 4 -+ sage: v.append(1.5) -+ sage: v -+ [1, 'hello', 2/3, sin(x^3), 1.50000000000000] -+ sage: del v[1] -+ sage: v -+ [1, 2/3, sin(x^3), 1.50000000000000] -+ -+Outra importante estrutura de dados é o dicionário (ou lista -+associativa). Ele funciona como uma lista, exceto que pode ser -+indexado por vários tipos de objeto (os índices devem ser imutáveis): -+ -+:: -+ -+ sage: d = {'hi':-2, 3/8:pi, e:pi} -+ sage: d['hi'] -+ -2 -+ sage: d[e] -+ pi -+ -+Você pode também definir novos tipos de dados usando classes. -+Encapsular objetos matemáticos usando classes é uma técnica poderosa -+que pode ajudar a simplificar e organizar os seus programas em Sage. -+Abaixo, definimos uma nova classe que representa a lista de inteiros -+pares positivos até *n*; essa classe é derivada do tipo ``list``. -+ -+:: -+ -+ sage: class Evens(list): -+ ... def __init__(self, n): -+ ... self.n = n -+ ... list.__init__(self, range(2, n+1, 2)) -+ ... def __repr__(self): -+ ... return "Even positive numbers up to n." -+ -+O método ``__init__`` é evocado para inicializar o objeto quando ele é -+criado; o método ``__repr__`` imprime o objeto. Nós evocamos o -+construtor ``__init__`` do tipo ``list`` na segunda linha do método -+``__init__``. Criamos um objeto da classe ``Evens`` da seguinte forma: -+ -+.. link -+ -+:: -+ -+ sage: e = Evens(10) -+ sage: e -+ Even positive numbers up to n. -+ -+Note que ``e`` imprime usando o método ``__repr__`` que nós -+definimos. Para ver a lista de números, use a função ``list``: -+ -+.. link -+ -+:: -+ -+ sage: list(e) -+ [2, 4, 6, 8, 10] -+ -+Podemos também acessar o atributo ``n`` ou tratar ``e`` como uma -+lista. -+ -+.. link -+ -+:: -+ -+ sage: e.n -+ 10 -+ sage: e[2] -+ 6 -diff --git a/doc/pt/tutorial/tour_linalg.rst b/doc/pt/tutorial/tour_linalg.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_linalg.rst -@@ -0,0 +1,233 @@ -+.. _section-linalg: -+ -+Álgebra Linear -+============== -+ -+O Sage fornece os objetos usuais em álgebra linear, por exemplo, o -+polinômio característico, matriz escalonada, traço, decomposição, -+etc., de uma matriz. -+ -+Criar e multiplicar matrizes é fácil e natural: -+ -+:: -+ -+ sage: A = Matrix([[1,2,3],[3,2,1],[1,1,1]]) -+ sage: w = vector([1,1,-4]) -+ sage: w*A -+ (0, 0, 0) -+ sage: A*w -+ (-9, 1, -2) -+ sage: kernel(A) -+ Free module of degree 3 and rank 1 over Integer Ring -+ Echelon basis matrix: -+ [ 1 1 -4] -+ -+Note que no Sage, o núcleo de uma matriz :math:`A` é o núcleo à -+esquerda, i.e., o conjunto de vetores :math:`w` tal que :math:`wA=0`. -+ -+Resolver equações matriciais é fácil usando o método ``solve_right``. -+Calculando ``A.solve_right(Y)`` obtém-se uma matrix (ou vetor) -+:math:`X` tal que :math:`AX=Y`: -+ -+.. link -+ -+:: -+ -+ sage: Y = vector([0, -4, -1]) -+ sage: X = A.solve_right(Y) -+ sage: X -+ (-2, 1, 0) -+ sage: A * X # checking our answer... -+ (0, -4, -1) -+ -+Uma barra invertida ``\`` pode ser usada no lugar de ``solve_right``; -+use ``A \ Y`` no lugar de ``A.solve_right(Y)``. -+ -+.. link -+ -+:: -+ -+ sage: A \ Y -+ (-2, 1, 0) -+ -+Se não existir solução, o Sage retorna um erro: -+ -+.. skip -+ -+:: -+ -+ sage: A.solve_right(w) -+ Traceback (most recent call last): -+ ... -+ ValueError: matrix equation has no solutions -+ -+Similarmente, use ``A.solve_left(Y)`` para resolver para :math:`X` em -+:math:`XA=Y`. -+ -+O Sage também pode calcular autovalores e autovetores:: -+ -+ sage: A = matrix([[0, 4], [-1, 0]]) -+ sage: A.eigenvalues () -+ [-2*I, 2*I] -+ sage: B = matrix([[1, 3], [3, 1]]) -+ sage: B.eigenvectors_left() -+ [(4, [ -+ (1, 1) -+ ], 1), (-2, [ -+ (1, -1) -+ ], 1)] -+ -+(A sintaxe para a resposta de ``eigenvectors_left`` é uma lista com -+três componentes: (autovalor, autovetor, multiplicidade).) Autovalores -+e autovetores sobre ``QQ`` ou ``RR`` também podem ser calculados -+usando o Maxima (veja :ref:`section-maxima`). -+ -+Como observado em :ref:`section-rings`, o anel sobre o qual a matriz -+esta definida afeta alguma de suas propriedades. A seguir, o primeiro -+argumento do comando ``matrix`` diz para o Sage considerar a matriz -+como uma matriz de inteiros (o caso ``ZZ``), uma matriz de números -+racionais (``QQ``), ou uma matriz de números reais (``RR``):: -+ -+ sage: AZ = matrix(ZZ, [[2,0], [0,1]]) -+ sage: AQ = matrix(QQ, [[2,0], [0,1]]) -+ sage: AR = matrix(RR, [[2,0], [0,1]]) -+ sage: AZ.echelon_form() -+ [2 0] -+ [0 1] -+ sage: AQ.echelon_form() -+ [1 0] -+ [0 1] -+ sage: AR.echelon_form() -+ [ 1.00000000000000 0.000000000000000] -+ [0.000000000000000 1.00000000000000] -+ -+Espaços de Matrizes -+------------------- -+ -+Agora criamos o espaço :math:`\text{Mat}_{3\times 3}(\QQ)` de matrizes -+`3 \times 3` com entradas racionais:: -+ -+ sage: M = MatrixSpace(QQ,3) -+ sage: M -+ Full MatrixSpace of 3 by 3 dense matrices over Rational Field -+ -+(Para especificar o espaço de matrizes 3 por 4, você usaria -+``MatrixSpace(QQ,3,4)``. Se o número de colunas é omitido, ele é -+considerado como igual ao número de linhas, portanto, -+``MatrixSpace(QQ,3)`` é sinônimo de ``MatrixSpace(QQ,3,3)``.) O espaço -+de matrizes possui uma base que o Sage armazena como uma lista: -+ -+.. link -+ -+:: -+ -+ sage: B = M.basis() -+ sage: len(B) -+ 9 -+ sage: B[1] -+ [0 1 0] -+ [0 0 0] -+ [0 0 0] -+ -+Vamos criar uma matriz como um elemento de ``M``. -+ -+.. link -+ -+:: -+ -+ sage: A = M(range(9)); A -+ [0 1 2] -+ [3 4 5] -+ [6 7 8] -+ -+A seguir calculamos a sua forma escalonada e o núcleo. -+ -+.. link -+ -+:: -+ -+ sage: A.echelon_form() -+ [ 1 0 -1] -+ [ 0 1 2] -+ [ 0 0 0] -+ sage: A.kernel() -+ Vector space of degree 3 and dimension 1 over Rational Field -+ Basis matrix: -+ [ 1 -2 1] -+ -+Agora ilustramos o cálculo com matrizes definidas sobre um corpo -+finito: -+ -+:: -+ -+ sage: M = MatrixSpace(GF(2),4,8) -+ sage: A = M([1,1,0,0, 1,1,1,1, 0,1,0,0, 1,0,1,1, -+ ... 0,0,1,0, 1,1,0,1, 0,0,1,1, 1,1,1,0]) -+ sage: A -+ [1 1 0 0 1 1 1 1] -+ [0 1 0 0 1 0 1 1] -+ [0 0 1 0 1 1 0 1] -+ [0 0 1 1 1 1 1 0] -+ sage: rows = A.rows() -+ sage: A.columns() -+ [(1, 0, 0, 0), (1, 1, 0, 0), (0, 0, 1, 1), (0, 0, 0, 1), -+ (1, 1, 1, 1), (1, 0, 1, 1), (1, 1, 0, 1), (1, 1, 1, 0)] -+ sage: rows -+ [(1, 1, 0, 0, 1, 1, 1, 1), (0, 1, 0, 0, 1, 0, 1, 1), -+ (0, 0, 1, 0, 1, 1, 0, 1), (0, 0, 1, 1, 1, 1, 1, 0)] -+ -+Criamos o subespaço sobre `\GF{2}` gerado pelas linhas acima. -+ -+.. link -+ -+:: -+ -+ sage: V = VectorSpace(GF(2),8) -+ sage: S = V.subspace(rows) -+ sage: S -+ Vector space of degree 8 and dimension 4 over Finite Field of size 2 -+ Basis matrix: -+ [1 0 0 0 0 1 0 0] -+ [0 1 0 0 1 0 1 1] -+ [0 0 1 0 1 1 0 1] -+ [0 0 0 1 0 0 1 1] -+ sage: A.echelon_form() -+ [1 0 0 0 0 1 0 0] -+ [0 1 0 0 1 0 1 1] -+ [0 0 1 0 1 1 0 1] -+ [0 0 0 1 0 0 1 1] -+ -+A base de `S` usada pelo Sage é obtida a partir das linhas não-nulas -+da forma escalonada da matriz de geradores de `S`. -+ -+Álgebra Linear Esparsa -+---------------------- -+ -+O Sage fornece suporte para álgebra linear esparsa. -+ -+:: -+ -+ sage: M = MatrixSpace(QQ, 100, sparse=True) -+ sage: A = M.random_element(density = 0.05) -+ sage: E = A.echelon_form() -+ -+O algoritmo multi-modular no Sage é bom para matrizes quadradas (mas -+não muito bom para matrizes que não são quadradas): -+ -+:: -+ -+ sage: M = MatrixSpace(QQ, 50, 100, sparse=True) -+ sage: A = M.random_element(density = 0.05) -+ sage: E = A.echelon_form() -+ sage: M = MatrixSpace(GF(2), 20, 40, sparse=True) -+ sage: A = M.random_element() -+ sage: E = A.echelon_form() -+ -+Note que o Python é sensível a maiúsculas e minúsculas: -+ -+:: -+ -+ sage: M = MatrixSpace(QQ, 10,10, Sparse=True) -+ Traceback (most recent call last): -+ ... -+ TypeError: MatrixSpace() got an unexpected keyword argument 'Sparse' -diff --git a/doc/pt/tutorial/tour_numtheory.rst b/doc/pt/tutorial/tour_numtheory.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_numtheory.rst -@@ -0,0 +1,168 @@ -+Teoria de Números -+================= -+ -+O Sage possui extensa funcionalidade para teoria de números. Por -+exemplo, podemos fazer aritmética em :math:`\ZZ/N\ZZ` da seguinte -+forma: -+ -+:: -+ -+ sage: R = IntegerModRing(97) -+ sage: a = R(2) / R(3) -+ sage: a -+ 33 -+ sage: a.rational_reconstruction() -+ 2/3 -+ sage: b = R(47) -+ sage: b^20052005 -+ 50 -+ sage: b.modulus() -+ 97 -+ sage: b.is_square() -+ True -+ -+O Sage contém funções comuns em teoria de números. Por exemplo, -+ -+:: -+ -+ sage: gcd(515,2005) -+ 5 -+ sage: factor(2005) -+ 5 * 401 -+ sage: c = factorial(25); c -+ 15511210043330985984000000 -+ sage: [valuation(c,p) for p in prime_range(2,23)] -+ [22, 10, 6, 3, 2, 1, 1, 1] -+ sage: next_prime(2005) -+ 2011 -+ sage: previous_prime(2005) -+ 2003 -+ sage: divisors(28); sum(divisors(28)); 2*28 -+ [1, 2, 4, 7, 14, 28] -+ 56 -+ 56 -+ -+Perfeito! -+ -+A função ``sigma(n,k)`` do Sage soma as :math:`k`-ésimas potências dos -+divisores de ``n``: -+ -+:: -+ -+ sage: sigma(28,0); sigma(28,1); sigma(28,2) -+ 6 -+ 56 -+ 1050 -+ -+A seguir ilustramos o algoritmo de Euclides estendido, a função -+:math:`\phi` de Euler, e o teorema do resto Chinês: -+ -+:: -+ -+ sage: d,u,v = xgcd(12,15) -+ sage: d == u*12 + v*15 -+ True -+ sage: n = 2005 -+ sage: inverse_mod(3,n) -+ 1337 -+ sage: 3 * 1337 -+ 4011 -+ sage: prime_divisors(n) -+ [5, 401] -+ sage: phi = n*prod([1 - 1/p for p in prime_divisors(n)]); phi -+ 1600 -+ sage: euler_phi(n) -+ 1600 -+ sage: prime_to_m_part(n, 5) -+ 401 -+ -+Agora verificamos algo sobre o problema :math:`3n+1`. -+ -+:: -+ -+ sage: n = 2005 -+ sage: for i in range(1000): -+ ... n = 3*odd_part(n) + 1 -+ ... if odd_part(n)==1: -+ ... print i -+ ... break -+ 38 -+ -+Por fim, ilustramos o teorema do resto Chinês. -+ -+:: -+ -+ sage: x = crt(2, 1, 3, 5); x -+ 11 -+ sage: x % 3 # x mod 3 = 2 -+ 2 -+ sage: x % 5 # x mod 5 = 1 -+ 1 -+ sage: [binomial(13,m) for m in range(14)] -+ [1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1] -+ sage: [binomial(13,m)%2 for m in range(14)] -+ [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1] -+ sage: [kronecker(m,13) for m in range(1,13)] -+ [1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1] -+ sage: n = 10000; sum([moebius(m) for m in range(1,n)]) -+ -23 -+ sage: list(partitions(4)) -+ [(1, 1, 1, 1), (1, 1, 2), (2, 2), (1, 3), (4,)] -+ -+Números :math:`p`-ádicos -+------------------------ -+ -+O corpo dos números :math:`p`-ádicos está implementado em Sage. Note -+que uma vez que um corpo :math:`p`-ádico é criado, você não pode -+alterar a sua precisão. -+ -+:: -+ -+ sage: K = Qp(11); K -+ 11-adic Field with capped relative precision 20 -+ sage: a = K(211/17); a -+ 4 + 4*11 + 11^2 + 7*11^3 + 9*11^5 + 5*11^6 + 4*11^7 + 8*11^8 + 7*11^9 -+ + 9*11^10 + 3*11^11 + 10*11^12 + 11^13 + 5*11^14 + 6*11^15 + 2*11^16 -+ + 3*11^17 + 11^18 + 7*11^19 + O(11^20) -+ sage: b = K(3211/11^2); b -+ 10*11^-2 + 5*11^-1 + 4 + 2*11 + O(11^18) -+ -+Muito trabalho foi feito implementando anéis de inteiros em corpos -+:math:`p`-ádicos ou corpos numéricos além de `Z`. O leitor -+interessado é convidado a perguntar mais detalhes aos especialistas na -+lista ``sage-support`` no Google Groups. -+ -+Diversos métodos relacionados já estão implementados na classe -+NumberField. -+ -+:: -+ -+ sage: R. = PolynomialRing(QQ) -+ sage: K = NumberField(x^3 + x^2 - 2*x + 8, 'a') -+ sage: K.integral_basis() -+ [1, 1/2*a^2 + 1/2*a, a^2] -+ -+.. link -+ -+:: -+ -+ sage: K.galois_group(type="pari") -+ Galois group PARI group [6, -1, 2, "S3"] of degree 3 of the Number Field -+ in a with defining polynomial x^3 + x^2 - 2*x + 8 -+ -+.. link -+ -+:: -+ -+ sage: K.polynomial_quotient_ring() -+ Univariate Quotient Polynomial Ring in a over Rational Field with modulus -+ x^3 + x^2 - 2*x + 8 -+ sage: K.units() -+ [3*a^2 + 13*a + 13] -+ sage: K.discriminant() -+ -503 -+ sage: K.class_group() -+ Class group of order 1 of Number Field in a with -+ defining polynomial x^3 + x^2 - 2*x + 8 -+ sage: K.class_number() -+ 1 -diff --git a/doc/pt/tutorial/tour_plotting.rst b/doc/pt/tutorial/tour_plotting.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_plotting.rst -@@ -0,0 +1,231 @@ -+.. _section-plot: -+ -+Gráficos -+======== -+ -+O Sage pode produzir gráficos bidimensionais e tridimensionais. -+ -+Gráficos Bidimensionais -+----------------------- -+ -+Em duas dimensões, o Sage pode desenhar círculos, linhas, e polígonos; -+gráficos de funções em coordenadas retangulares, e também coordenadas -+polares; gráficos de contorno e gráficos de campos vetoriais. -+Apresentamos alguns exemplos desses gráficos aqui. Para mais exemplos -+de gráficos com o Sage, veja :ref:`section-systems` e -+:ref:`section-maxima`, e também a documentação `Sage Constructions -+`_. -+ -+Este comando produz um círculo amarelo de raio 1, centrado na origem. -+ -+:: -+ -+ sage: circle((0,0), 1, rgbcolor=(1,1,0)) -+ -+Você pode também produzir um círculo preenchido: -+ -+:: -+ -+ sage: circle((0,0), 1, rgbcolor=(1,1,0), fill=True) -+ -+Outra possibilidade é criar um círculo atribuindo-o a uma variável; -+isso não cria um gráfico: -+ -+:: -+ -+ sage: c = circle((0,0), 1, rgbcolor=(1,1,0)) -+ -+Para criar o gráfico, use ``c.show()`` ou ``show(c)``, da seguinte -+forma: -+ -+.. link -+ -+:: -+ -+ sage: c.show() -+ -+Alternativamente, o comando ``c.save('filename.png')`` salva o gráfico -+no arquivo citado. -+ -+Agora, esses 'círculos' parecem mais elipses porque os eixos estão em -+escalas diferentes. Você pode alterar isso: -+ -+.. link -+ -+:: -+ -+ sage: c.show(aspect_ratio=1) -+ -+O comando ``show(c, aspect_ratio=1)`` produz o mesmo resultado, ou -+você pode salvar a figura usando ``c.save('filename.png', -+aspect_ratio=1)``. -+ -+É fácil criar o gráfico de funções simples: -+ -+:: -+ -+ sage: plot(cos, (-5,5)) -+ -+Após especificar uma variável, você também pode criar gráficos -+paramétricos: -+ -+:: -+ -+ sage: x = var('x') -+ sage: parametric_plot((cos(x),sin(x)^3),(x,0,2*pi),rgbcolor=hue(0.6)) -+ -+É importante notar que os eixos dos gráficos vão se intersectar apenas -+se a origem estiver no escopo do gráfico, e que valores grandes podem -+ser representados usando notação científica. -+ -+:: -+ -+ sage: plot(x^2,(x,300,500)) -+ -+Você pode combinar vários gráficos somando-os: -+ -+:: -+ -+ sage: x = var('x') -+ sage: p1 = parametric_plot((cos(x),sin(x)),(x,0,2*pi),rgbcolor=hue(0.2)) -+ sage: p2 = parametric_plot((cos(x),sin(x)^2),(x,0,2*pi),rgbcolor=hue(0.4)) -+ sage: p3 = parametric_plot((cos(x),sin(x)^3),(x,0,2*pi),rgbcolor=hue(0.6)) -+ sage: show(p1+p2+p3, axes=false) -+ -+Uma boa forma de produzir figuras preenchidas é criar uma lista de -+pontos (``L`` no exemplo abaixo) e então usar o comando ``polygon`` -+para fazer o gráfico do polígono formado por esses pontos. Por -+exemplo, aqui está um "deltoid" verde: -+ -+:: -+ -+ sage: L = [[-1+cos(pi*i/100)*(1+cos(pi*i/100)),\ -+ ... 2*sin(pi*i/100)*(1-cos(pi*i/100))] for i in range(200)] -+ sage: p = polygon(L, rgbcolor=(1/8,3/4,1/2)) -+ sage: p -+ -+Digite ``show(p, axes=false)`` para visualizar isso sem os eixos. -+ -+Você pode adicionar texto ao gráfico: -+ -+:: -+ -+ sage: L = [[6*cos(pi*i/100)+5*cos((6/2)*pi*i/100),\ -+ ... 6*sin(pi*i/100)-5*sin((6/2)*pi*i/100)] for i in range(200)] -+ sage: p = polygon(L, rgbcolor=(1/8,1/4,1/2)) -+ sage: t = text("hypotrochoid", (5,4), rgbcolor=(1,0,0)) -+ sage: show(p+t) -+ -+Professores de cálculo frequentemente desenham o seguinte gráfico na -+lousa: não apenas um ramo do arco-seno, mas vários deles: isto é, o -+gráfico de :math:`y=\sin(x)` para :math:`x` entre :math:`-2\pi` e -+:math:`2\pi`, refletido com respeito a reta :math:`x=y`. Os seguintes -+comandos fazem isso: -+ -+:: -+ -+ sage: v = [(sin(x),x) for x in srange(-2*float(pi),2*float(pi),0.1)] -+ sage: line(v) -+ -+Como a função tangente possui imagem maior do que o seno, se você usar -+o mesmo método para fazer o gráfico da função inversa da função -+tangente, você deve alterar as coordenadas mínima e máxima para o eixo -+*x*: -+ -+:: -+ -+ sage: v = [(tan(x),x) for x in srange(-2*float(pi),2*float(pi),0.01)] -+ sage: show(line(v), xmin=-20, xmax=20) -+ -+O Sage também cria gráficos usando coordenadas polares, gráficos de -+contorno e gráficos de campos vetoriais (para tipos especiais de -+funções). Aqui está um exemplo de gráfico de contorno: -+ -+:: -+ -+ sage: f = lambda x,y: cos(x*y) -+ sage: contour_plot(f, (-4, 4), (-4, 4)) -+ -+Gráficos Tridimensionais -+------------------------ -+ -+O Sage pode ser usado para criar gráficos tridimensionais. Tanto no -+Sage Notebook, como no console (linha de comando), esses gráficos serão -+exibidos usando o software de código aberto [Jmol]_, que permite girar -+e ampliar a figura usando o mouse. -+ -+Use ``plot3d`` para criar o gráfico de uma função da forma `f(x, y) = -+z`: -+ -+:: -+ -+ sage: x, y = var('x,y') -+ sage: plot3d(x^2 + y^2, (x,-2,2), (y,-2,2)) -+ -+Alternativamente, você pode usar ``parametric_plot3d`` para criar o -+gráfico de uma superfície onde cada coordenada `x, y, z` é determinada -+por uma função de uma ou duas variáveis (os parâmetros, tipicamente -+`u` e `v`). O gráfico anterior pode ser representado parametricamente -+na forma: -+ -+:: -+ -+ sage: u, v = var('u, v') -+ sage: f_x(u, v) = u -+ sage: f_y(u, v) = v -+ sage: f_z(u, v) = u^2 + v^2 -+ sage: parametric_plot3d([f_x, f_y, f_z], (u, -2, 2), (v, -2, 2)) -+ -+A terceira forma de fazer um gráfico de uma superfície no Sage é -+usando o comando ``implicit_plot3d``, que cria um gráfico de uma -+superfície definida por uma equação `f(x, y, z) = 0` (isso define um -+conjunto de pontos). Vamos fazer o gráfico de uma esfera usando a -+expressão usual: -+ -+:: -+ -+ sage: x, y, z = var('x, y, z') -+ sage: implicit_plot3d(x^2 + y^2 + z^2 - 4, (x,-2, 2), (y,-2, 2), (z,-2, 2)) -+ -+Aqui estão mais alguns exemplos: -+ -+`Yellow Whitney's umbrella `__: -+ -+:: -+ -+ sage: u, v = var('u,v') -+ sage: fx = u*v -+ sage: fy = u -+ sage: fz = v^2 -+ sage: parametric_plot3d([fx, fy, fz], (u, -1, 1), (v, -1, 1), -+ ... frame=False, color="yellow") -+ -+`Cross cap `__: -+ -+:: -+ -+ sage: u, v = var('u,v') -+ sage: fx = (1+cos(v))*cos(u) -+ sage: fy = (1+cos(v))*sin(u) -+ sage: fz = -tanh((2/3)*(u-pi))*sin(v) -+ sage: parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi), -+ ... frame=False, color="red") -+ -+Toro retorcido: -+ -+:: -+ -+ sage: u, v = var('u,v') -+ sage: fx = (3+sin(v)+cos(u))*cos(2*v) -+ sage: fy = (3+sin(v)+cos(u))*sin(2*v) -+ sage: fz = sin(u)+2*cos(v) -+ sage: parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi), -+ ... frame=False, color="red") -+ -+Lemniscata: -+ -+:: -+ -+ sage: x, y, z = var('x,y,z') -+ sage: f(x, y, z) = 4*x^2 * (x^2 + y^2 + z^2 + z) + y^2 * (y^2 + z^2 - 1) -+ sage: implicit_plot3d(f, (x, -0.5, 0.5), (y, -1, 1), (z, -1, 1)) -diff --git a/doc/pt/tutorial/tour_polynomial.rst b/doc/pt/tutorial/tour_polynomial.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_polynomial.rst -@@ -0,0 +1,332 @@ -+.. _section-poly: -+ -+Polinômios -+========== -+ -+Nesta seção vamos ilustrar como criar e usar polinômios no Sage. -+ -+ -+.. _section-univariate: -+ -+Polinômios em Uma Variável -+-------------------------- -+ -+Existem três formas de criar anéis de polinômios. -+ -+:: -+ -+ sage: R = PolynomialRing(QQ, 't') -+ sage: R -+ Univariate Polynomial Ring in t over Rational Field -+ -+Esse comando cria um anel de polinômios e diz para o Sage usar a letra -+'t' para representar a variável indeterminada quando imprimir na tela. -+Todavia, isso não define o símbolo ``t`` para uso no Sage, logo você -+não pode usá-lo para definir um polinômio (como :math:`t^2+1`) -+pertencente a ``R``. -+ -+Uma forma alternativa é -+ -+.. link -+ -+:: -+ -+ sage: S = QQ['t'] -+ sage: S == R -+ True -+ -+As mesmas observações com respeito a ``t`` valem também nesse caso. -+ -+Uma terceira e conveniente forma de definir polinômios é -+ -+:: -+ -+ sage: R. = PolynomialRing(QQ) -+ -+ou -+ -+:: -+ -+ sage: R. = QQ['t'] -+ -+ou ainda -+ -+:: -+ -+ sage: R. = QQ[] -+ -+Isso tem o efeito colateral de definir a variável ``t`` como a -+variável indeterminada do anel de polinômios, logo você pode -+facilmente construir elementos de ``R`` da seguinte forma. (Note que -+essa terceira alternativa é muito semelhante à notação usada em Magma, -+e da mesma forma que no Magma ela pode ser usada para diversos tipos -+de objetos.) -+ -+.. link -+ -+:: -+ -+ sage: poly = (t+1) * (t+2); poly -+ t^2 + 3*t + 2 -+ sage: poly in R -+ True -+ -+Qualquer que seja o método usado para definir um anel de polinômios, -+você pode recuperar a variável indeterminada como o :math:`0`-ésimo -+gerador: -+ -+:: -+ -+ sage: R = PolynomialRing(QQ, 't') -+ sage: t = R.0 -+ sage: t in R -+ True -+ -+Note que uma construção similar funciona com os números complexos: os -+números complexos podem ser vistos como sendo gerados pelo símbolo -+``i`` sobre os números reais; logo temos o seguinte: -+ -+:: -+ -+ sage: CC -+ Complex Field with 53 bits of precision -+ sage: CC.0 # 0th generator of CC -+ 1.00000000000000*I -+ -+Para anel de polinômios, você pode obter tanto o anel como o seu -+gerador, ou somente o gerador, no momento em que o anel for criado, da -+seguinte forma: -+ -+:: -+ -+ sage: R, t = QQ['t'].objgen() -+ sage: t = QQ['t'].gen() -+ sage: R, t = objgen(QQ['t']) -+ sage: t = gen(QQ['t']) -+ -+Finalmente apresentamos um pouco de aritmética em :math:`\QQ[t]`. -+ -+:: -+ -+ sage: R, t = QQ['t'].objgen() -+ sage: f = 2*t^7 + 3*t^2 - 15/19 -+ sage: f^2 -+ 4*t^14 + 12*t^9 - 60/19*t^7 + 9*t^4 - 90/19*t^2 + 225/361 -+ sage: cyclo = R.cyclotomic_polynomial(7); cyclo -+ t^6 + t^5 + t^4 + t^3 + t^2 + t + 1 -+ sage: g = 7 * cyclo * t^5 * (t^5 + 10*t + 2) -+ sage: g -+ 7*t^16 + 7*t^15 + 7*t^14 + 7*t^13 + 77*t^12 + 91*t^11 + 91*t^10 + 84*t^9 -+ + 84*t^8 + 84*t^7 + 84*t^6 + 14*t^5 -+ sage: F = factor(g); F -+ (7) * t^5 * (t^5 + 10*t + 2) * (t^6 + t^5 + t^4 + t^3 + t^2 + t + 1) -+ sage: F.unit() -+ 7 -+ sage: list(F) -+ [(t, 5), (t^5 + 10*t + 2, 1), (t^6 + t^5 + t^4 + t^3 + t^2 + t + 1, 1)] -+ -+Note que a fatorização corretamente leva em conta e armazena a parte -+unitária. -+ -+Se você fosse usar, por exemplo, a função ``R.cyclotomic_polynomial`` -+intensamente para algum projeto de pesquisa, além de citar o Sage, -+você deveria tentar descobrir qual componente do Sage é de fato usado -+para calcular esses polinômios, e citá-lo também. Nesse caso, se você -+digitar ``R.cyclotomic_polynomial??`` para ver o código fonte, você -+irá facilmente ver uma linha ``f = pari.polcyclo(n)`` o que significa -+que o PARI é usado para o cálculo dos polinômios ciclotrômicos. Cite o -+PARI também no seu trabalho. -+ -+Dividindo dois polinômios cria-se um elemento do corpo de frações (o -+qual o Sage cria automaticamente). -+ -+:: -+ -+ sage: x = QQ['x'].0 -+ sage: f = x^3 + 1; g = x^2 - 17 -+ sage: h = f/g; h -+ (x^3 + 1)/(x^2 - 17) -+ sage: h.parent() -+ Fraction Field of Univariate Polynomial Ring in x over Rational Field -+ -+Usando-se a série de Laurent, pode-se calcular a expansão em série no -+corpo de frações de ``QQ[x]``: -+ -+:: -+ -+ sage: R. = LaurentSeriesRing(QQ); R -+ Laurent Series Ring in x over Rational Field -+ sage: 1/(1-x) + O(x^10) -+ 1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + O(x^10) -+ -+Se nomearmos a variável de outra forma, obtemos um anel de polinômios -+em uma variável diferente. -+ -+:: -+ -+ sage: R. = PolynomialRing(QQ) -+ sage: S. = PolynomialRing(QQ) -+ sage: x == y -+ False -+ sage: R == S -+ False -+ sage: R(y) -+ x -+ sage: R(y^2 - 17) -+ x^2 - 17 -+ -+O anel é determinado pela variável. Note que criar um outro anel com -+variável indeterminada ``x`` não retorna um anel diferente. -+ -+:: -+ -+ sage: R = PolynomialRing(QQ, "x") -+ sage: T = PolynomialRing(QQ, "x") -+ sage: R == T -+ True -+ sage: R is T -+ True -+ sage: R.0 == T.0 -+ True -+ -+O Sage também possui suporte para séries de potências e séries de -+Laurent sobre um anel arbitrário. No seguinte exemplo, nós criamos um -+elemento de :math:`\GF{7}[[T]]` e dividimos para criar um elemento de -+:math:`\GF{7}((T))`. -+ -+:: -+ -+ sage: R. = PowerSeriesRing(GF(7)); R -+ Power Series Ring in T over Finite Field of size 7 -+ sage: f = T + 3*T^2 + T^3 + O(T^4) -+ sage: f^3 -+ T^3 + 2*T^4 + 2*T^5 + O(T^6) -+ sage: 1/f -+ T^-1 + 4 + T + O(T^2) -+ sage: parent(1/f) -+ Laurent Series Ring in T over Finite Field of size 7 -+ -+Você também pode criar anéis de polinômios usando a notação de -+colchetes duplos: -+ -+:: -+ -+ sage: GF(7)[['T']] -+ Power Series Ring in T over Finite Field of size 7 -+ -+Polinômios em Mais De Uma Variável -+---------------------------------- -+ -+Para trabalhar com polinômios em várias variáveis, nós primeiro -+declaramos o anel de polinômios e as variáveis. -+ -+:: -+ -+ sage: R = PolynomialRing(GF(5),3,"z") # here, 3 = number of variables -+ sage: R -+ Multivariate Polynomial Ring in z0, z1, z2 over Finite Field of size 5 -+ -+Da mesma forma como ocorre com polinômios em uma variável, existem -+três maneiras de fazer isso: -+ -+:: -+ -+ sage: GF(5)['z0, z1, z2'] -+ Multivariate Polynomial Ring in z0, z1, z2 over Finite Field of size 5 -+ sage: R. = GF(5)[]; R -+ Multivariate Polynomial Ring in z0, z1, z2 over Finite Field of size 5 -+ -+Se você quiser usar os nomes das variáveis com apenas uma letra, então -+você pode usar os seguinte comando: -+ -+:: -+ -+ sage: PolynomialRing(GF(5), 3, 'xyz') -+ Multivariate Polynomial Ring in x, y, z over Finite Field of size 5 -+ -+A seguir fazemos um pouco de aritmética. -+ -+:: -+ -+ sage: z = GF(5)['z0, z1, z2'].gens() -+ sage: z -+ (z0, z1, z2) -+ sage: (z[0]+z[1]+z[2])^2 -+ z0^2 + 2*z0*z1 + z1^2 + 2*z0*z2 + 2*z1*z2 + z2^2 -+ -+Você também pode usar uma notação mais matemática para criar um anel -+de polinômios. -+ -+:: -+ -+ sage: R = GF(5)['x,y,z'] -+ sage: x,y,z = R.gens() -+ sage: QQ['x'] -+ Univariate Polynomial Ring in x over Rational Field -+ sage: QQ['x,y'].gens() -+ (x, y) -+ sage: QQ['x'].objgens() -+ (Univariate Polynomial Ring in x over Rational Field, (x,)) -+ -+Polinômios em mais de uma variável são implementados no Sage usando -+dicionários em Python e a "representação distribuída" de um polinômio. -+O Sage usa o Singular [Si]_, por exemplo, para o cálculo do maior -+divisor comum e bases de Gröbner para ideais algébricos. -+ -+:: -+ -+ sage: R, (x, y) = PolynomialRing(RationalField(), 2, 'xy').objgens() -+ sage: f = (x^3 + 2*y^2*x)^2 -+ sage: g = x^2*y^2 -+ sage: f.gcd(g) -+ x^2 -+ -+A seguir criamos o ideal :math:`(f,g)` gerado por :math:`f` e -+:math:`g`, simplesmente multiplicando ``(f,g)`` por ``R`` (nós -+poderíamos também escrever ``ideal([f,g])`` ou ``ideal(f,g)``). -+ -+.. link -+ -+:: -+ -+ sage: I = (f, g)*R; I -+ Ideal (x^6 + 4*x^4*y^2 + 4*x^2*y^4, x^2*y^2) of Multivariate Polynomial -+ Ring in x, y over Rational Field -+ sage: B = I.groebner_basis(); B -+ [x^6, x^2*y^2] -+ sage: x^2 in I -+ False -+ -+A base de Gröbner acima não é uma lista mas sim uma sequência -+imutável. Isso implica que ela possui universo (universe) e parente -+(parent), e não pode ser modificada (o que é bom pois ocasionaria -+erros em outras rotinas que usam bases de Gröbner). -+ -+.. link -+ -+:: -+ -+ sage: B.parent() -+ Category of sequences in Multivariate Polynomial Ring in x, y over Rational -+ Field -+ sage: B.universe() -+ Multivariate Polynomial Ring in x, y over Rational Field -+ sage: B[1] = x -+ Traceback (most recent call last): -+ ... -+ ValueError: object is immutable; please change a copy instead. -+ -+Um pouco (não tanto quanto gostaríamos) de álgebra comutativa está -+disponível no Sage, implementado via Singular. Por exemplo, podemos -+calcular a decomposição primaria e primos associados de :math:`I`: -+ -+.. link -+ -+:: -+ -+ sage: I.primary_decomposition() -+ [Ideal (x^2) of Multivariate Polynomial Ring in x, y over Rational Field, -+ Ideal (y^2, x^6) of Multivariate Polynomial Ring in x, y over Rational Field] -+ sage: I.associated_primes() -+ [Ideal (x) of Multivariate Polynomial Ring in x, y over Rational Field, -+ Ideal (y, x) of Multivariate Polynomial Ring in x, y over Rational Field] -diff --git a/doc/pt/tutorial/tour_rings.rst b/doc/pt/tutorial/tour_rings.rst -new file mode 100644 ---- /dev/null -+++ b/doc/pt/tutorial/tour_rings.rst -@@ -0,0 +1,148 @@ -+.. _section-rings: -+ -+Anéis Básicos -+============= -+ -+Quando se define matrizes, vetores, ou polinômios, é as vezes útil, e -+as vezes necessário, especificar o "anel" sobre o qual o objeto será -+definido. Um *anel* é uma estrutura matemática na qual se tem noções -+de adição e multiplicação bem definidas; se você nunca ouviu falar -+sobre anéis, você provavelmente só precisa saber a respeito dos -+seguintes exemplos: -+ -+* os inteiros `\{..., -1, 0, 1, 2,... \}`, que são chamados ``ZZ`` no -+ Sage. -+* os números racionais -- i. e., frações, ou razões, de inteiros -- -+ que são chamados ``QQ`` no Sage. -+* os números reais, chamados de ``RR`` no Sage. -+* os números complexos, chamados de ``CC`` no Sage. -+ -+Você pode precisar saber sobre essas distinções porque o mesmo -+polinômio, por exemplo, pode ser tratado diferentemente dependendo do -+anel sobre o qual está definido. A propósito, o polinômio `x^2-2` -+possui duas raízes, `\pm \sqrt{2}`. Essas raízes não são racionais, -+logo, se você esta lidando com polinômios com coeficientes racionais, -+os polinômios não serão fatorados. Com coeficientes reais, eles serão. -+Portanto você pode querer especificar o anel para garantir que você -+vai obter a informação que deseja. Os dois comandos a seguir definem -+os conjuntos de polinômios com coeficientes racionais e coeficientes -+reais, respectivamente. Os conjuntos são chamados "ratpoly" e -+"realpoly", mas esses nomes não são importantes aqui; todavia, note -+que as strings "." e "." especificam o nome das variáveis -+usadas em cada caso. -+ -+:: -+ -+ sage: ratpoly. = PolynomialRing(QQ) -+ sage: realpoly. = PolynomialRing(RR) -+ -+Agora ilustramos a nossa discussão sobre fatorar `x^2-2`: -+ -+.. link -+ -+:: -+ -+ sage: factor(t^2-2) -+ t^2 - 2 -+ sage: factor(z^2-2) -+ (z - 1.41421356237310) * (z + 1.41421356237310) -+ -+Comentários similares também se aplicam a matrizes: a forma reduzida -+de uma matriz pode depender do anel sobre o qual ela esta definida, -+como também pode os seus autovalores e autovetores. Para mais sobre -+polinômios, veja :ref:`section-poly`, para mais sobre matrizes, veja -+:ref:`section-linalg`. -+ -+O símbolo ``I`` representa a raiz quadrada de :math:`-1`; ``i`` é um -+sinônimo de ``I``. Obviamente, isso não é um número racional:: -+ -+ sage: i # square root of -1 -+ I -+ sage: i in QQ -+ False -+ -+Nota: O código acima pode não funcionar como esperado se a variável -+``i`` estiver atribuída a um outro valor, por exemplo, se ela for -+usada como a variável de um laço (loop). Nesse caso, digite:: -+ -+ sage: reset('i') -+ -+para restabelecer o valor original de ``i``. -+ -+Há uma sutileza ao definir números complexos: como mencionado acima, -+o símbolo ``i`` representa a raiz quadrada de `-1`, mas é uma raiz -+quadrada de `-1` *formal* ou *simbólica*. Evocando ``CC(i)`` ou -+``CC.0`` obtém-se a raiz de `-1` complexa. Aritmética envolvendo tipos -+diferentes de números é possível graças ao que se chama de coação, -+veja :ref:`section-coercion`. -+ -+:: -+ -+ sage: i = CC(i) # floating point complex number -+ sage: i == CC.0 -+ True -+ sage: a, b = 4/3, 2/3 -+ sage: z = a + b*i -+ sage: z -+ 1.33333333333333 + 0.666666666666667*I -+ sage: z.imag() # imaginary part -+ 0.666666666666667 -+ sage: z.real() == a # automatic coercion before comparison -+ True -+ sage: a + b -+ 2 -+ sage: 2*b == a -+ True -+ sage: parent(2/3) -+ Rational Field -+ sage: parent(4/2) -+ Rational Field -+ sage: 2/3 + 0.1 # automatic coercion before addition -+ 0.766666666666667 -+ sage: 0.1 + 2/3 # coercion rules are symmetric in SAGE -+ 0.766666666666667 -+ -+Aqui estão mais exemplos de anéis básicos em Sage. Como observado -+acima, o anel dos números racionais pode ser referido usando ``QQ``, -+ou também ``RationalField()`` (um *corpo*, ou *field* em inglês, é um -+anel no qual a operação de multiplicação é comutativa, e todo elemento -+não-nulo possui um elemento inverso com respeito à operação de -+multiplicação. Logo, os racionais formam um corpo, mas os inteiros -+não):: -+ -+ sage: RationalField() -+ Rational Field -+ sage: QQ -+ Rational Field -+ sage: 1/2 in QQ -+ True -+ -+O número decimal ``1.2`` é considerado como um elemento de ``QQ``: -+número decimais que são também racionais podem ser coagidos ao conjunto de -+números racionais (veja :ref:`section-coercion`). Os números `\pi` e -+`\sqrt{2}` não são racionais, todavia:: -+ -+ sage: 1.2 in QQ -+ True -+ sage: pi in QQ -+ False -+ sage: pi in RR -+ True -+ sage: sqrt(2) in QQ -+ False -+ sage: sqrt(2) in CC -+ True -+ -+Para uso em matemática mais avançada, o Sage também pode especificar -+outros anéis, como corpos finitos, inteiros `p`-ádicos, o anel dos -+números algébricos, anéis de polinômios, e anéis de matrizes. Aqui -+está a construção de alguns deles:: -+ -+ sage: GF(3) -+ Finite Field of size 3 -+ sage: GF(27, 'a') # need to name the generator if not a prime field -+ Finite Field in a of size 3^3 -+ sage: Zp(5) -+ 5-adic Ring with capped relative precision 20 -+ sage: sqrt(3) in QQbar # algebraic closure of QQ -+ True diff --git a/trac_12822_pt_translation_of_tutorial_rev1.patch b/trac_12822_pt_translation_of_tutorial_rev1.patch deleted file mode 100644 index 145cc9d..0000000 --- a/trac_12822_pt_translation_of_tutorial_rev1.patch +++ /dev/null @@ -1,468 +0,0 @@ -# HG changeset patch -# User Gustavo de Oliveira -# Date 1336320704 -7200 -# Node ID f35ca5dd36d8ccfeba96947e9e10402f6e6ed79b -# Parent ad8e41651a3187a45f087335cb048418bf545506 -Trac 12822: Portuguese translation of "Tutorial" (revision 1). - -diff --git a/doc/pt/tutorial/interactive_shell.rst b/doc/pt/tutorial/interactive_shell.rst ---- a/doc/pt/tutorial/interactive_shell.rst -+++ b/doc/pt/tutorial/interactive_shell.rst -@@ -361,8 +361,8 @@ - - Note que o GAP e o Maxima são os mais lentos neste teste (isso foi - executado no computador ``sage.math.washington.edu``). Devido ao --"overhead" da interface pexpect, talvez não seja apropriado comparar --esses resultados com o Sage, que é o mais rápido. -+processamento extra (overhead) da interface pexpect, talvez não seja -+apropriado comparar esses resultados com o Sage, que é o mais rápido. - - Outras Dicas para o IPython - =========================== -@@ -402,7 +402,7 @@ - - - Você pode usar ``%edit`` (ou ``%ed`` ou ``ed``) para abrir um - editor, se você desejar digitar algum código mais complexo. Antes de -- iniciar o Sage, certifique-se de que a variável de environment -+ iniciar o Sage, certifique-se de que a variável de ambiente - :envvar:`EDITOR` está definida com o seu editor favorito (colocando - ``export EDITOR=/usr/bin/emacs`` ou ``export EDITOR=/usr/bin/vim`` - or algo similar no lugar apropriado, como um arquivo ``.profile``). -@@ -789,7 +789,7 @@ - sage: v = E.anlist(100000) # instant! - - (Em Python, salvar e restaurar é feito usando o módulo ``cPickle``. Em --particular, um objeto ``x`` do Sage pode ser salvado usando -+particular, um objeto ``x`` do Sage pode ser salvo usando - ``cPickle.dumps(x, 2)``. Note o ``2``!) - - O sage não pode salvar e carregar objetos criados em algum outro -@@ -811,7 +811,7 @@ - ValueError: The session in which this object was defined is no longer - running. - --Objetos do GP/PARI também podem ser salvados e carregados pois suas -+Objetos do GP/PARI também podem ser salvos e carregados pois suas - representações em forma impressa são suficientes para reconstruí-los. - - .. skip -@@ -823,7 +823,7 @@ - sage: load('a') - 2 - --Objetos que foram salvados podem ser abertos posteriormente em -+Objetos que foram salvos podem ser abertos posteriormente em - computadores com arquiteturas e sistemas operacionais diferentes, por - exemplo, você poderia salvar uma matriz muito grande em um OS X de - 32-bits e abri-lo em um Linux de 64-bits, encontrar a forma reduzida, -@@ -868,7 +868,7 @@ - ``sessionname``. (No caso raro de uma variável não poder ser salva, - ela simplesmente não aparece no dicionário.) O resultado é um arquivo - ``.sobj`` que pode ser aberto como qualquer outro objeto que foi --salvado. Quando você abre os objetos que foram salvados em uma sessão, -+salvo. Quando você abre os objetos que foram salvos em uma sessão, - você obtém um dicionário cujas chaves (keys) são os nomes das - variáveis e os valores são os objetos. - -@@ -954,7 +954,7 @@ - sage: notebook() - - na linha de comando do Sage. Isso inicia o Notebook e abre o seu --browser padrão para visualizá-lo. Os arquivos de estado do servidor -+navegador padrão para visualizá-lo. Os arquivos de estado do servidor - são armazenados em ``$HOME/.sage/sage\_notebook``. - - Outras opções incluem: -diff --git a/doc/pt/tutorial/interfaces.rst b/doc/pt/tutorial/interfaces.rst ---- a/doc/pt/tutorial/interfaces.rst -+++ b/doc/pt/tutorial/interfaces.rst -@@ -48,15 +48,15 @@ - Mod(5, 10007) - - No primeiro caso, uma cópia separada do interpretador GP é iniciada --como um servidor, e a string ``´znprimroot(10007)'`` é enviada, -+como um servidor, e a string ``znprimroot(10007)`` é enviada, - calculada pelo GP, e o resultado é armazenado em uma variável no GP - (que ocupa espaço na memória dos processos do GP que não serão - liberados). Então o valor dessa variável é exibido. No segundo caso, --nenhum programa separado é iniciado, e a string --``´znprimroot(10007)'`` é calculada por uma certa função da biblioteca --C do PARI. O resultado é armazenado na memória em uso pelo Python, que --é liberada quando a variável não for mais referenciada. Os objetos --possuem tipos diferentes: -+nenhum programa separado é iniciado, e a string ``znprimroot(10007)`` -+é calculada por uma certa função da biblioteca C do PARI. O resultado -+é armazenado na memória em uso pelo Python, que é liberada quando a -+variável não for mais referenciada. Os objetos possuem tipos -+diferentes: - - :: - -@@ -187,7 +187,7 @@ - ======== - - O Singular fornece uma biblioteca massiva e madura para bases de --Gröbner, máximo divisor comum para poliômios em várias variaveis, -+Gröbner, máximo divisor comum para polinômios em várias variáveis, - bases de espaços de Riemann-Roch de uma curva plana, e fatorização, - entre outras coisas. Vamos ilustrar a fatorização de polinômios em - várias variáveis usando a interface do Sage para o Singular (não -diff --git a/doc/pt/tutorial/introduction.rst b/doc/pt/tutorial/introduction.rst ---- a/doc/pt/tutorial/introduction.rst -+++ b/doc/pt/tutorial/introduction.rst -@@ -68,7 +68,7 @@ - principal do Sage [SA]_ para instruções de como instalar o Sage no seu - computador. Aqui faremos apenas alguns comentários. - --#. O arquivo para download do Sage vem com "baterias incluídas". Em -+#. O arquivo para instalação do Sage vem com "baterias incluídas". Em - outras palavras, embora o Sage use o Python, IPython, PARI, GAP, - Singular, Maxima, NTL, GMP, e uma série de outros programas, você - não precisa instalá-los separadamente pois eles estão incluídos no -diff --git a/doc/pt/tutorial/latex.rst b/doc/pt/tutorial/latex.rst ---- a/doc/pt/tutorial/latex.rst -+++ b/doc/pt/tutorial/latex.rst -@@ -31,15 +31,15 @@ - - #. A interface Notebook é configurada para usar o `jsMath - `_ para representar -- fórmulas matemáticas de forma clara em um web browser. O jsMath é -+ fórmulas matemáticas de forma clara em um web navegador. O jsMath é - uma coleção de rotinas em JavaScript e fontes associadas. - Tipicamente esses fontes ficam armazenadas em um servidor e são -- enviadas para o browser juntamente com a página onde elas estão -+ enviadas para o navegador juntamente com a página onde elas estão - sendo usadas. No caso do Sage, o Notebook está sempre conectado a - um servidor usado para executar os comando do Sage, e esse servidor - também fornece as fontes do jsMath necessárias. Logo não é - necessário configurar nada mais para ter formulas matemáticas -- representadas no seu browser quando você usa o Notebook do Sage. -+ representadas no seu navegador quando você usa o Notebook do Sage. - - O jsMath é implementado para representar um subconjunto grande, - mas não completo, do TeX. Ele não suporta objetos como, por -@@ -154,7 +154,7 @@ - Um segundo recurso disponível no Notebook é possibilidade de inserir - código TeX para fazer anotações na folha de trabalho. Quando o cursos - esta posicionado entre células de modo que uma barra azul fica --visível, então shift-click irá abrir um mini processador de texto, -+visível, então shift+clique irá abrir um mini processador de texto, - TinyMCE. Isso permite digitar texto, usando um editor WSISYG para - criar HTML e CSS. Logo é possível inserir texto formatado para - complementar a folha de trabalho. Todavia, texto entre símbolos $, ou -@@ -176,8 +176,9 @@ - usado para alterar a notação de matrizes -- parênteses grandes, - colchetes, barras verticais. Nenhuma noção de estilo é enfatizada, - você pode configurar como desejado. Observe como as barras invertidas --usadas em LaTeX requerem uma barra adicional de modo que elas possam --ser interpretadas (escaped) corretamente em uma string do Python. :: -+usadas em LaTeX requerem uma barra adicional para que elas não sejam -+interpretadas pelo Python como um comando (ou seja, sejam implementadas -+simplesmente como parte de uma string. :: - - sage: A = matrix(ZZ, 2, 2, range(4)) - sage: latex(A) -@@ -217,10 +218,10 @@ -
\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}
- sage: latex.blackboard_bold(False) - --É possível aproveitar os recursos do TeX adicionando novas macros e --novos pacotes. Primeiro, macros individuais podem ser adicionadas para --serem usadas quando o jsMath interpreta pequenos trechos de códigos --TeX no Notebook. :: -+É possível aproveitar os recursos do TeX adicionando novas funções -+(macros em inglês) e novos pacotes. Primeiro, funções individuais podem -+ser adicionadas para serem usadas quando o jsMath interpreta pequenos -+trechos de códigos TeX no Notebook. :: - - sage: latex.extra_macros() - '' -@@ -436,7 +437,7 @@ - Para uma experiência semelhante no Notebook, é necessário desabilitar - o processador jsMath para o código LaTeX do grafo usando a "lista de - comandos a serem evitados pelo jsMath". Grafos são criados usando o --environment ``tikzpicture``, logo essa uma boa escolha para uma string -+ambiente ``tikzpicture``, logo essa uma boa escolha para uma string - a ser incluída na lista que acabamos de mencionar. Agora, - ``view(graphs.CompleteGraph(4))`` em uma folha de trabalho deve - executar o pdflatex para criar um PDF e então o programa ``convert`` -@@ -486,7 +487,7 @@ - - Existem três programas disponíveis para integrar ainda mais o TeX e o - Sage. O primeiro é o sagetex. Uma descrição concisa do sagetex é que --ele é uma coleção de macros do TeX que permitem incluir em um -+ele é uma coleção de funções do TeX que permitem incluir em um - documento LaTeX instruções para usar o Sage para calcular vários - objetos, e/ou formatar objetos usando o comando ``latex()`` existente - no Sage. Logo, como um passo intermediário para compilar um documento -@@ -496,7 +497,7 @@ - sagetex para fazer cálculos com o Sage. Veja :ref:`sec-sagetex` para - mais informações. - --O tex2sws começa com um documento LaTeX, mas define environments -+O tex2sws começa com um documento LaTeX, mas define ambientes - adicionais para inserir código em Sage. Quando processado com as - ferramentas adequadas, o resultado é uma folha de trabalho do Sage, - com conteúdo apropriadamente formatado para o jsMath e com código em -diff --git a/doc/pt/tutorial/programming.rst b/doc/pt/tutorial/programming.rst ---- a/doc/pt/tutorial/programming.rst -+++ b/doc/pt/tutorial/programming.rst -@@ -66,7 +66,7 @@ - (Em Python, ``^`` significa "ou exclusivo" e ``**`` significa - "exponenciação".) - --Esse "preparsing" está implementado em ``sage/misc/interpreter.py``.) -+Esse "" está implementado em ``sage/misc/interpreter.py``.) - - Você pode colar código tabulado com muitas linhas no Sage desde que - existam linhas em branco separando blocos de código (isso não é -@@ -130,7 +130,7 @@ - em ``$HOME/.sage/temp/hostname/pid/spyx``. Esses arquivos são - excluídos quando você encerra o Sage. - --Nenhum pré-processador (preparsing) é aplicado em arquivos spyx, por -+Nenhum pré-processamento (preparsing) é aplicado em arquivos spyx, por - exemplo, ``1/3`` vai resultar em 0 em um arquivo spyx em vez do número - racional :math:`1/3`. Se ``foo`` é uma função da biblioteca Sage, para - usá-la em um arquivo spyx importe ``sage.all`` e use ``sage.all.foo``. -@@ -456,10 +456,10 @@ - Dicionários - =========== - --Um dicionário (também chamado as vezes de lista associativa) é um --mapeamento de objetos "hashable" em objetos arbitrários. (Exemplos de --objetos "hashable" são strings e números; veja a documentação Python --em http://docs.python.org/tut/node7.html e -+Um dicionário (também chamado as vezes de lista associativa ou "hash -+table") é um mapeamento de objetos em objetos arbitrários. (Exemplos -+de objetos que admitem uma lista associativa são strings e números; -+veja a documentação Python em http://docs.python.org/tut/node7.html e - http://docs.python.org/lib/typesmapping.html para detalhes). - - :: -@@ -502,7 +502,7 @@ - Conjuntos - ========= - --O Python possui um tipo set (conjuntos) nativo. O principal recurso -+O Python possui um tipo de conjuntos (set) nativo. O principal recurso - que ele oferece é a rápida verificação se um objeto está ou não em um - conjunto, juntamente com as operações comuns em conjuntos. - -diff --git a/doc/pt/tutorial/sagetex.rst b/doc/pt/tutorial/sagetex.rst ---- a/doc/pt/tutorial/sagetex.rst -+++ b/doc/pt/tutorial/sagetex.rst -@@ -88,14 +88,14 @@ - que tudo que foi calculado, incluindo os gráficos, foi incluído em seu - documento. - --As macros utilizadas acima devem ser fáceis de entender. Um --environment ``sageblock`` insere código "verbatim" (exatamente como é --digitado) e também executa o código quando você executa o Sage. Quando --você insere ``\sage{foo}``, é incluído em seu documento o resultado --que você obteria executando ``latex(foo)`` no Sage. Comandos para --fazer gráficos são um pouco mais complicados, mas em sua forma mais --simples, ``\sageplot{foo}`` insere a imagem que você obtêm usando --``foo.save('filename.eps')``. -+As funções (macros em inglês) utilizadas acima devem ser fáceis de -+entender. Um ambiente ``sageblock`` insere código "verbatim" -+(exatamente como é digitado) e também executa o código quando você -+executa o Sage. Quando você insere ``\sage{foo}``, é incluído em seu -+documento o resultado que você obteria executando ``latex(foo)`` no -+Sage. Comandos para fazer gráficos são um pouco mais complicados, mas -+em sua forma mais simples, ``\sageplot{foo}`` insere a imagem que você -+obtêm usando ``foo.save('filename.eps')``. - - Em geral, a rotina é a seguinte: - -diff --git a/doc/pt/tutorial/tour_advanced.rst b/doc/pt/tutorial/tour_advanced.rst ---- a/doc/pt/tutorial/tour_advanced.rst -+++ b/doc/pt/tutorial/tour_advanced.rst -@@ -84,7 +84,7 @@ - funcionalidade para curvas elípticas do PARI, acesso aos dados da base - de dados Cremona (isso requer um pacote adicional), os recursos do - mwrank, isto é, "2-descends" com cálculos do grupo de Mordell-Weil --completo, o algoritmo SEA (singla em inglês), cálculo de todas as -+completo, o algoritmo SEA (sigla em inglês), cálculo de todas as - isogenias, bastante código novo para curvas sobre :math:`\QQ`, e parte - do software "algebraic descent" de Denis Simons. - -@@ -98,7 +98,7 @@ - .. math:: y^2+a_1xy+a_3y=x^3+a_2x^2+a_4x+a_6, - - -- onde os :math:`a_i`'s são coagidos para os parentes de :math:`a_1`. -+ onde os :math:`a_i`'s são coagidos para a família de :math:`a_1`. - Se todos os :math:`a_i` possuem parente :math:`\ZZ`, então eles são - coagidos para :math:`\QQ`. - -diff --git a/doc/pt/tutorial/tour_assignment.rst b/doc/pt/tutorial/tour_assignment.rst ---- a/doc/pt/tutorial/tour_assignment.rst -+++ b/doc/pt/tutorial/tour_assignment.rst -@@ -81,10 +81,9 @@ - sage: numerical_approx(pi, prec=200) - 3.1415926535897932384626433832795028841971693993751058209749 - --O Python é uma linguagem "dinâmicamente digitada" (dynamically typed), --portanto o valor referido por cada variável possui um tipo associado a --ele, mas uma variável pode possuir valores de qualquer tipo em --determinado escopo: -+O Python é uma linguagem de tipagem dinâmica, portanto o valor -+referido por cada variável possui um tipo associado a ele, mas uma -+variável pode possuir valores de qualquer tipo em determinado escopo: - - :: - -@@ -98,9 +97,9 @@ - sage: type(a) - - --A linguagem de programação C, que é "estaticamente digitada" --(statically typed), é muito diferente; uma variável que foi declarada --como int pode apenas armazenar um int em seu escopo. -+A linguagem de programação C, que é de tipagem estática , é muito -+diferente; uma variável que foi declarada como int pode apenas -+armazenar um int em seu escopo. - - Uma potencial fonte de confusão em Python é que um inteiro literal que - começa com zero é tratado como um número octal, isto é, um número na -diff --git a/doc/pt/tutorial/tour_coercion.rst b/doc/pt/tutorial/tour_coercion.rst ---- a/doc/pt/tutorial/tour_coercion.rst -+++ b/doc/pt/tutorial/tour_coercion.rst -@@ -3,11 +3,11 @@ - .. _section-coercion: - - ============================ --Parentes, Conversão e Coação -+Famílias, Conversão e Coação - ============================ - - Esta seção pode parecer mais técnica do que as anteriores, mas --acreditamos que é importante entender o significado de parentes e -+acreditamos que é importante entender o significado de famílias e - coação de modo a usar anéis e outras estruturas algébricas no Sage de - forma efetiva e eficiente. - -@@ -25,8 +25,8 @@ - ``__mul__``, obviamente garantindo que os axiomas de anel são - verificados. - --Como o Python é uma linguagem "strongly typed" (ainda que "dynamically --typed"), poderia-se, pelo menos a princípio, esperar-se que fosse -+Como o Python é uma linguagem de tipagem forte (ainda que de tipagem -+dinâmica), poderia-se, pelo menos a princípio, esperar-se que fosse - implementado em Python uma classe para cada anel. No final das contas, - o Python contém um tipo ```` para os inteiros, um tipo - ```` para os reais, e assim por diante. Mas essa estratégia -@@ -87,7 +87,7 @@ - Univariate Polynomial Ring in c over Integer Ring (using NTL) - - --Parentes e Categorias -+Famílias e Categorias - --------------------- - - De forma similar à hierarquia de classes em Python voltada para -@@ -137,10 +137,9 @@ - gerais independentemente de uma implementação específica nas - categorias. - --Estruturas parentes em Sage são supostamente objetos únicos em Python. --Por exemplo, uma vez que um anel de polinômios sobre um certo anel --base e com uma certa lista de geradores é criada, o resultado é --arquivado: -+Estruturas da mesma família em Sage são supostamente objetos únicos em -+Python. Por exemplo, uma vez que um anel de polinômios sobre um certo anel -+base e com uma certa lista de geradores é criada, o resultado é arquivado: - - :: - -@@ -163,7 +162,7 @@ - sage: isinstance(M, RingElement) - True - --Enquanto *parentes* são únicos, elementos iguais de um parente em Sage -+Enquanto *famílias* são únicas, elementos iguais de uma família em Sage - não são necessariamente idênticos. Isso contrasta com o comportamento - do Python para alguns (embora não todos) inteiros: - -@@ -177,7 +176,7 @@ - False - - É importante observar que elementos de anéis diferentes em geral não --podem ser distinguidos pelos seus tipos, mas sim por seus parentes: -+podem ser distinguidos pelos seus tipos, mas sim por sua família: - - :: - -@@ -203,7 +202,7 @@ - O leitor pode conhecer as noções de *conversão de tipo* e *coação de - tipo* como na linguagem C, por exemplo. Existem noções de *conversão* - e *coação* em Sage também. Mas as noções em Sage são centradas em --*parentes*, não em tipos. Então, por favor não confunda conversão de -+*família*, não em tipos. Então, por favor não confunda conversão de - tipo em C com conversão em Sage! - - Aqui se encontra uma breve apresentação. Para uma descrição detalhada -@@ -227,12 +226,12 @@ - permitidas. O elemento neutro da multiplicação existe em todos os - corpos e em vários anéis, e eles devem ser todos iguais. - --O Sage faz uma concessão. Se ``P1`` e ``P2`` são estruturas parentes e --``p1`` é um elemento de ``P1``, então o usuário pode explicitamente --perguntar por uma interpretação de ``p1`` em ``P2``. Isso pode não --fazer sentido em todos os casos ou não estar definido para todos os --elementos de ``P1``, e fica a cargo do usuário assegurar que isso faz --sentido. Nos referimos a isso como **conversão**: -+O Sage faz uma concessão. Se ``P1`` e ``P2`` são estruturas da mesma família -+e ``p1`` é um elemento de ``P1``, então o usuário pode explicitamente -+perguntar por uma interpretação de ``p1`` em ``P2``. Isso pode não fazer -+sentido em todos os casos ou não estar definido para todos os elementos de -+``P1``, e fica a cargo do usuário assegurar que isso faz sentido. Nos -+referimos a isso como **conversão**: - - :: - -@@ -283,7 +282,7 @@ - sage: R2(y) - y - --Se não existir homomorfismo de anel que preserve nomes, coerção não é -+Se não existir homomorfismo de anel que preserve nomes, coação não é - definida. Todavia, conversão pode ainda ser possível, a saber, - mapeando geradores de anel de acordo com sua posição da lista de - geradores: -@@ -309,7 +308,7 @@ - Se houver coação, ela será usada para comparar elementos de anéis - diferentes ou fazer aritmética. Isso é frequentemente conveniente, mas - o usuário deve estar ciente que estender a relação ``==`` além das --fronteiras de parentes diferentes pode facilmente resultar em -+fronteiras de famílias diferentes pode facilmente resultar em - problemas. Por exemplo, enquanto ``==`` é supostamente uma relação de - equivalência sobre os elementos de *um* anel, isso não é - necessariamente o caso se anéis *diferentes* estão envolvidos. Por -@@ -360,7 +359,7 @@ - sage: 1/10^200+1/10^100 == 1/10^100 - False - --Quando se compara elementos de dois parentes ``P1`` e ``P2``, é -+Quando se compara elementos de duas famílias ``P1`` e ``P2``, é - possível que não haja coação entre os dois anéis, mas existe uma - escolha canônica de um parente ``P3`` de modo que tanto ``P1`` como - ``P2`` são coagidos em ``P3``. Nesse caso, coação vai ocorrer também. -@@ -381,7 +380,7 @@ - Note que a princípio o resultado deveria também fazer sentido no - corpo de frações de ``ZZ['x']``. Todavia, o Sage tenta escolher um - parente *canônico* comum que parece ser o mais natural (``QQ['x']`` no --nosso exemplo). Se vários potenciais parentes comuns parecem -+nosso exemplo). Se várias famílias potencialmente comuns parecem - igualmente naturais, o Sage *não* vai escolher um deles - aleatoriamente. Os mecanismos sobre os quais essa escolha se baseia é - explicado em um `arquivo tutorial -@@ -401,5 +400,5 @@ - A razão é que o Sage não escolhe um dos potenciais candidatos - ``QQ['x']['y']``, ``QQ['y']['x']``, ``QQ['x','y']`` ou - ``QQ['y','x']``, porque todas essas estruturas combinadas em pares --diferentes parecem ser parentes comuns naturais, e não existe escolha -+diferentes parecem ser de famílias comuns naturais, e não existe escolha - canônica aparente.