{{{
sage: R.<x,y> = GF(2)[]
sage: f = x*y/(x+y)
sage: f.parent()
Fraction Field of Multivariate Polynomial Ring in x, y over Finite
Field of size 2
}}}
I try to factor it, and get this error:
{{{
sage: f.factor()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/home/masgaj/.sage/temp/host_56_150/17587/_home_masgaj__sage_init_sage_0.py
in <module>()
/local/jec/sage-4.3.rc0/local/lib/python2.6/site-packages/sage/rings/fraction_field_element.so
in sage.rings.fraction_field_element.FractionFieldElement.factor
(sage/rings/fraction_field_element.c:2972)()
/local/jec/sage-4.3.rc0/local/lib/python2.6/site-packages/sage/rings/polynomial/multi_polynomial_libsingular.so
in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.factor
(sage/rings/polynomial/multi_polynomial_libsingular.cpp:22701)()
NotImplementedError: proof = True factorization not implemented. Call
factor with proof=False.
}}}
So I do what I am told, but:
{{{
sage: f.factor(proof=False)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/masgaj/.sage/temp/host_56_150/17587/_home_masgaj__sage_init_sage_0.py
in <module>()
TypeError: factor() takes no keyword arguments
}}}
Worth a ticket, I think?
Also, does anyone know what the proof parameter for this sort of
factorization actually means?
John
I haven't written any of the code involved, so I am not absolutely
sure about this, but after looking at the code for a few minutes, I
think the following is the case:
The "FractionFieldElement" objects have a method "factor", but this
takes no arguments other than "self". This explains the error message
in the second case you describe. On the other hand, the
"MPolynomial_libsingular" objects provide the method "factor(self,
proof=True)". Here, however, the parameter "proof" is only used to
prevent certain inputs (with the option "proof=True" set) from being
passed to Singular, presumably(?) in cases when Singular's results
might not be reliable. There appears to be no further use of the
parameter.
I think this is something that ought to fixed. (N.B. I don't think I
know enough about what kind of factoring methods rings in Sage
typically offer.) If rings often offer further arguments to the
method "factor", then I think the method "factor" for
FractionFieldElement objects should be modified to allow the same
arguments. On the other hand, if "MPolynomial_libsingular" is the
only case where "factor" takes further arguments, perhaps the second
argument ought to be removed?
Sebastian
def factor(self):
return self.numerator().factor()/self.denominator().factor()
to
def factor(self, *args)
return self.numerator().factor(args)/self.denominator().factor
(args)
Moreover, I guess the parameter "proof" should be documented in the
method "factor" for multivariate polynomials.
Sebastian
That looks like a good, simple solution. Can anyone see any
drawbacks? If not, it would be a simple patch (but requiring full
testing!)
John
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
>
I haven't read this thread very carefully, but just from a python
perspective, you probably want something like the following to pass on
all of the arguments.
def factor(self, *args, **kwds)
return self.numerator().factor(*args,**kwds)/self.denominator().factor
(*args,**kwds)
Thanks,
Jason
> I haven't read this thread very carefully, but just from a python
> perspective, you probably want something like the following to pass on all
> of the arguments.
>
> def factor(self, *args, **kwds)
> return self.numerator().factor(*args,**kwds)/self.denominator().factor
> (*args,**kwds)
>
Thanks, Jason -- very helpful.
John
def factor(self, *args, **kwds)
return self.numerator().factor(*args, **kwds) / \
self.denominator().factor(*args, **kwds)
In the meantime, while waiting for further comments, I've put this up
as ticket #7868. I'll test this now and, if nothing fails, upload the
patch later today.
Sebastian
On Jan 7, 4:50 pm, John Cremona <john.crem...@gmail.com> wrote:
> 2010/1/7 Sebastian Pancratz <s...@pancratz.org>:
Sebastian