There was a thread on multiple return values coming from Magma,
since renamed to "Integer points on conics"

William pointed out that one can access the multiple return values
using nvals:

 x = magma.XGCD(15, 10)
 x,y,z = magma.XGCD(15, 10, nvals = 3)

The first returns an integer, while the second returns a tuple.

Q1: Is this an acceptable general construction for Python and/or SAGE,
namely to return a different type depending on the values passed into
it?  Is it acceptable when it is controlled by nvals in exactly this
way?

As William pointed out, very different algorithms can be called
depending on the
number of arguments requested in Magma.  The following is an example:

sage: E = magma.EllipticCurve([1,3])
sage: magma.IsIsomorphic(E,E)
true
sage: bool, phi = magma.IsIsomorphic(E,E,nvals=2)
sage: phi
Elliptic curve isomorphism from: Elliptic Curve defined by y^2 = x^3 +
x + 3 over Rational Field to Elliptic Curve defined by y^2 = x^3 + x +
3 over Rational Field
Taking (x : y : 1) to (x : y : 1)

Currently in SAGE we have:

sage: E = EllipticCurve([1,3])
sage: E.is_isomorphic(E)
True

Q2: Would the following be acceptable way of implementing equivalent
functionality in SAGE?:

sage: bool, phi = E.is_isomorphic(E, nvals=2)

Note that often (in many concexts) it more expensive to return an
isomorphism, but only slightly more so compared with recomputing the
isomorphism test.  If the answer to my question is "no, it not
acceptable SAGE/Python syntax", then how should we implement this
functionality?  One possibility is:

sage: phi = E1.isomorphism(E2)

and to trap an error if is_isomorphic returns false.  Is this a
better?

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to