Closed robertwb closed 12 years ago
Attachment: 12195-numerical_approx.patch.gz
Description changed:
---
+++
@@ -1 +1 @@
-#1294 implemented {{n()}} but not {{N()}} or the functional {{numerical_approx}}
+#1294 implemented `n()` but not `N()` or the functional `numerical_approx`
Robert,
Looks good, and very welcome. I should have noticed, and fixed, this omission during my big push last year. Looks ready for a positive review, but I have two questions.
Could this make the .n()
method (immediate prior in source) obsolete?
This does not seem to show up explicitly anywhere in the documentation. Doing v.N?
on an integer vector v
seems to just give the generic documentation for a numerical approximation to a single scalar. For matrices, the approach is different. A bit more code, and not overriding the scalar method: Plus: explicit documentation. Minus: duplication of code, including a really bad approximation of log 10
as discussed recently on sage-devel.
A suggestion - add a doctest in this patch for the generic method exhibiting application to vectors. If that's agreeable, I'll make a ticket to have matrices follow the model of this ticket (and maybe even do it).
Rob
Changed keywords from none to sd40.5
Author: robertwb
Reviewer: Rob Beezer, William Stein
This clearly needs work. Rob's point about there being an n method right before is serious. That should be deleted, and was the result of somebody not understanding the architecture of N...
I fixed the patch by deleting the n function before. Looks great!
Attachment: trac_12195-numerical-approx-v3.patch.gz
Changed author from robertwb to Robert Bradshaw, Rob Beezer, William Stein
Description changed:
---
+++
@@ -1 +1,4 @@
#1294 implemented `n()` but not `N()` or the functional `numerical_approx`
+
+**Apply:**
+1. [attachment: trac_12195-numerical-approx-v3.patch](https://github.com/sagemath/sage-prod/files/10654368/trac_12195-numerical-approx-v3.patch.gz)
Previous patches had the _numerical_approx
function in the generic dense class, and specialized classes (such as rational dense) derive directly from the plain free module element class. Thus the method was invisible to those specialized classes and only "generic" vectors could use this. So I took William's version of the function and moved it up to a higher level.
Removed a pile of n()
methods, but preserved many of their doctests in the new method.
Could not resist poking at the documentation of misc.functional.numerical_approx
, so there was a drive-by upgrade there.
Improved the passing of prec
and digits
in one or two places.
Reworked the sparse case slightly and added a doctest to make sure it was not being clobbered.
Passes all tests.
Seemingly other places to look for removal, almost all outside my expertise. Maybe I should put these on a new ticket for safekeeping? The one for graphs is OK and does not need any inspection.
sage: search_src('def n\(')
modular/abvar/morphism.py:801: def n(self):
modules/vector_mod2_dense.pyx:447: def n(self, *args, **kwargs):
interfaces/qsieve.py:176: def n(self):
schemes/elliptic_curves/heegner.py:4386: def n(self):
schemes/elliptic_curves/ell_curve_isogeny.py:3468: def n(self):
sage: search_src('def N\(')
modular/modsym/p1list.pyx:1165: def N(self):
modular/modsym/p1list_nf.py:261: def N(self):
modular/modsym/p1list_nf.py:642: def N(self):
modular/quatalg/brandt.py:534: def N(self):
graphs/generic_graph_pyx.pyx:356:def N(n):
sage: search_src('def numerical_approx\(')
misc/functional.py:1196:def numerical_approx(x, prec=None, digits=None):
schemes/elliptic_curves/heegner.py:3127: def numerical_approx(self, prec=53):
schemes/elliptic_curves/heegner.py:3979: def numerical_approx(self, prec=53):
sage: search_src('def _numerical_approx\(')
matrix/matrix2.pyx:10332: def _numerical_approx(self,prec=None,digits=None):
modules/free_module_element.pyx:991: def _numerical_approx(self, prec=None, digits=None):
modules/free_module_element.pyx:4361: def _numerical_approx(self, prec=None, digits=None):
symbolic/expression.pyx:4053: def _numerical_approx(self, prec=None, digits=None):
Merged: sage-5.1.beta4
1294 implemented
n()
but notN()
or the functionalnumerical_approx
Apply:
CC: @rbeezer @jasongrout
Component: linear algebra
Keywords: sd40.5
Author: Robert Bradshaw, Rob Beezer, William Stein
Reviewer: Rob Beezer, William Stein, Dan Drake
Merged: sage-5.1.beta4
Issue created by migration from https://trac.sagemath.org/ticket/12195