[sage-devel] Re: [sage-edu] Viewpoint Article in Math Intelligencer on open texts

2016-07-02 Thread Volker Braun
Oh the irony...

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Trac workflow and needs_review

2016-07-02 Thread Volker Braun
No I haven't. Really it should be a trac plugin that prevents you from 
setting a ticket to positive review without filling out Author and Reviewer 
fields.

A somewhat orthogonal issue is whether to record plain text names or user 
ids. The advantage of plain text is that anyone can be listed (), without 
requiring an account. The advantage of user ids would be that people 
wouldn't misspell their names all the time. Still, I'd say that this is a 
minor concern right now.



On Saturday, July 2, 2016 at 2:53:10 AM UTC+2, kcrisman wrote:
>
> I think Jeroen *did* automate the posts regarding empty author and/or 
>> reviewer fields when he was release manager. :-) 
>
> I'm pretty sure that Volker automates this too...
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] make giac/giacpy a standard package

2016-07-02 Thread William Stein
On Friday, July 1, 2016, Ralf Stephan  wrote:

> On Wednesday, June 1, 2016 at 10:00:34 AM UTC+2, Ralf Stephan wrote:
>>
>> The giac and giacpy packages are now one year optional (#12375). Since
>> pynac-0.6.6 (#20742) has optional support for giac, and uses it to fix a
>> bug,
>> as well as a much faster GCD, I'm proposing to make the giac/giacpy
>> packages
>> a standard part of Sage. In a recent thread we could also read about the
>> speed of its Gröbner basis implementation.
>>
>
> There were no negative arguments to this. Also meanwhile, a standard
> installation
> would ease Pynac's task of handling potentially different libgiac versions
> with different needs that may be installed system-wide.
>
> So what would be the next step in this procedure?
>

+1.Giac definitely seems to be one of the most innovative pieces of OSS
math software right now, exactly in areas we tend not to focus on, but are
very important for users. Also giac tends to focus on speed and correctness
which is again what we need.   The code is also likely to be good
quality...   I'm curious what the Windows situation is like...

Anyway +1 from me.



>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com
> 
> .
> To post to this group, send email to sage-devel@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Sent from my massive iPhone 6 plus.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: make giac/giacpy a standard package

2016-07-02 Thread mmarco
+1 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Subfield generated by 0: segmentation fault

2016-07-02 Thread Jeroen Sijsling
Hello,

In Sage 7.2 I get the following error:

R. = PolynomialRing(QQ)
pol_rep = [1, -12, 70, -264, 757, -1872, 4258, -8796, 15922, -24900, 33886, 
-40608, 43117, -40608, 33886, -24900, 15922, -8796, 4258, -1872,   757, 
-264, 70, -12, 1]
K. = NumberField(R(pol_rep))
print K.subfield(K(1))

[...]
ValueError: 1 is not a root of the defining polynomial of Number Field in 
r0 with defining polynomial x

Replace the last line by print K.subfield(K(0)) and I get

[...]
SignalError: Segmentation fault

Replace pol_rep by [1, 1, 0, 1] and everything is fine though.

Best,
Jeroen

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: make giac/giacpy a standard package

2016-07-02 Thread leif
Ralf Stephan wrote:
> On Wednesday, June 1, 2016 at 10:00:34 AM UTC+2, Ralf Stephan wrote:
> 
> The giac and giacpy packages are now one year optional (#12375). Since
> pynac-0.6.6 (#20742) has optional support for giac, and uses it to
> fix a bug,
> as well as a much faster GCD, I'm proposing to make the giac/giacpy
> packages
> a standard part of Sage. In a recent thread we could also read about the
> speed of its Gröbner basis implementation.
> 
> 
> There were no negative arguments to this. Also meanwhile, a standard
> installation
> would ease Pynac's task of handling potentially different libgiac versions
> with different needs that may be installed system-wide.
> 
> So what would be the next step in this procedure?

Strip the latest version offered by Sage? ;-)

12M giac-1.2.0.19.tar.gz
44M giac-1.2.2.37.tar.gz
41K giacpy-0.5.6.tar.gz

Haven't examined why it has grown by 300% in a minor version update though.


Otherwise additional ~12 MB to the Sage tarball would IMHO be ok; it
exploded during the last few years anyway...


-leif


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: make giac/giacpy a standard package

2016-07-02 Thread leif
leif wrote:
> Ralf Stephan wrote:
>> On Wednesday, June 1, 2016 at 10:00:34 AM UTC+2, Ralf Stephan wrote:
>>
>> The giac and giacpy packages are now one year optional (#12375). Since
>> pynac-0.6.6 (#20742) has optional support for giac, and uses it to
>> fix a bug,
>> as well as a much faster GCD, I'm proposing to make the giac/giacpy
>> packages
>> a standard part of Sage. In a recent thread we could also read about the
>> speed of its Gröbner basis implementation.
>>
>>
>> There were no negative arguments to this. Also meanwhile, a standard
>> installation
>> would ease Pynac's task of handling potentially different libgiac versions
>> with different needs that may be installed system-wide.
>>
>> So what would be the next step in this procedure?
> 
> Strip the latest version offered by Sage? ;-)
> 
> 12M   giac-1.2.0.19.tar.gz
> 44M   giac-1.2.2.37.tar.gz
> 41K   giacpy-0.5.6.tar.gz
> 
> Haven't examined why it has grown by 300% in a minor version update though.

There's at least

28M giac-1.2.2.37/src/javagiac_linux32.tgz
394Kgiac-1.2.2.37/src/javagiac_linux64.tgz
28M total

which we certainly don't have to ship, besides perhaps some prepared
documentation (dvi, ps, pdf etc.), and documentation on PARI/GP.

I'd also bzip2 the tarball.

With just the two files above removed (but still a lot more than in the
previous version):

11M giac-1.2.2.37.tar.bz2


-leif

> 
> 
> Otherwise additional ~12 MB to the Sage tarball would IMHO be ok; it
> exploded during the last few years anyway...
> 
> 
> -leif


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: [sage-edu] Viewpoint Article in Math Intelligencer on open texts

2016-07-02 Thread Karl-Dieter Crisman




> The paywall *is* discouraging, isn't it? 
>
> My coauthor and I discussed the irony of publishing in a journal of this 
> type, of course, but it seemed to us that when you are in a minority and 
> you want to persuade, then you need to go to where the majority is. 
>
>
Yep. Thanks for writing this careful and comprehensive piece.
 

> I'll also note that it becomes free in a year. 
>

Does it?  But that isn't true of the Intelligencer in general, is it? 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: spkgs assumed for doctesting but not default installed

2016-07-02 Thread leif
Johan S. H. Rosenkilde wrote:
>> Except for the Sage library (and probably docbuilding, not sure), yes.
>> If you explicitly use 'make -j1', then also the Sage library will be
>> built sequentially, still using Python's multi-processing though, as
>> does docbuilding.
> 
> I've done `make distclean && make -j1`. Let's see how that one goes...

If that still omitted standard packages, I'd suggest to experiment with
GNU make's debug options (you can also add '-n' aka '--dry-run').

'-d' (='--debug=a') is far too verbose, but e.g. '--debug=bvjm',
probably also with '--trace' may give you a clue what's happening (or
why 'make' /doesn't/ build some targets).


-leif


>> Forgot to ask:
>>
>> How does at all local/var/lib/sage/installed/ look like?
> 
> See below. It doesn't contain the packages I know are missing. I don't
> know if other packages are also missing.
> 
> alabaster-0.7.8
> arb-2.8.1.p0
> atlas-3.10.2.p2
> babel-2.3.4
> backports_abc-0.4
> backports_shutil_get_terminal_size-1.0.0.p0
> backports_ssl_match_hostname-3.5.0.1
> boost_cropped-1.58.0
> brial-0.8.4.3
> bzip2-1.0.6-20150304
> cephes-2.8.p1
> certifi-2016.2.28
> cliquer-1.21.p3
> conway_polynomials-0.4.p0
> cycler-0.10.0
> cysignals-1.1.1
> cython-0.24.p0
> dateutil-2.2
> decorator-4.0.6
> docutils-0.12
> ecl-16.1.2.p0
> eclib-20150827
> ecm-6.4.4
> fflas_ffpack-1.6.0.p2
> flask-0.10.1
> flask_autoindex-0.6
> flask_babel-0.9
> flask_oldsessions-0.10
> flask_openid-1.2.5
> flask_silk-0.2
> flint-2.5.2.p0
> freetype-2.6.3
> future-0.15.2
> gap-4.8.3
> gc-7.2f.p0
> gf2x-1.1.p1
> givaro-3.7.1
> glpk-4.55.p1
> gsl-2.1
> iconv-1.14
> imagesize-0.7.1
> iml-1.0.4p1.p1
> ipykernel-4.3.1
> ipython-4.2.0
> ipython_genutils-0.1.0
> itsdangerous-0.24
> jinja2-2.8
> jupyter_client-4.2.2
> jupyter_core-4.1.0
> lcalc-1.23.p14
> libfplll-20160331
> libgap-4.8.3
> libgd-2.1.1.1.p0
> libpng-1.2.51.p0
> linbox-1.3.2.p1
> lrcalc-1.2.p0
> m4ri-20140914
> m4rie-20150908
> markupsafe-0.23
> mathjax-2.5
> matplotlib-1.5.1
> maxima-5.35.1.p2
> mpc-1.0.3.p0
> mpfi-1.5.1
> mpfr-3.1.4
> mpir-2.7.2
> mpmath-0.19
> ncurses-5.9.20131221
> networkx-1.11
> ntl-9.8.1.p0
> numpy-1.11.0.p0
> pari-2.8-2771-gb70b447.p0
> pari_galdata-20080411
> pari_seadata_small-20090618
> patch-2.7.5
> pathlib2-2.1.0
> pathpy-7.1
> pexpect-4.0.1.p1
> pickleshare-0.7.2
> pillow-3.2.0
> pip-8.1.2
> pkgconf-0.9.7
> pkgconfig-1.1.0
> planarity-2.2.0
> ppl-1.1
> ptyprocess-0.5.1
> pygments-2.1.3
> pynac-0.6.7
> pyparsing-2.1.4
> python2-2.7.10.p2
> python_openid-2.2.5
> pytz-2016.4
> pyzmq-15.2.0
> ratpoints-2.1.3.p3
> readline-6.3.008
> rw-0.7
> sagenb-0.13
> scipy-0.17.1
> setuptools-21.0.0
> setuptools_scm-1.11.0
> simplegeneric-0.8.1
> singledispatch-3.4.0.3
> singular-3.1.7p1.p1
> six-1.10.0
> snowballstemmer-1.2.1
> speaklater-1.3
> sphinx-1.4.1.p1
> sqlite-autoconf-313
> symmetrica-2.0.p9
> tachyon-0.98.9.p5
> tornado-4.3
> traitlets-4.2.1
> twisted-16.2.0
> werkzeug-0.11.9
> zeromq-4.0.5
> zlib-1.2.8.p0
> zn_poly-0.9.p11
> zope_interface-4.1.3
> 
> 
> Best,
> Johan
> 
> 
> leif writes:
> 
>> Johan S. H. Rosenkilde wrote:
 $ make --version
>>> GNU Make 4.2.1
>>> Built for x86_64-pc-linux-gnu
>>>
 Did you build in parallel, and if so, does probably building
 sequentially fix the problem (such that the missing packages then get
 built)?
>>>
>>> I just did "make"; the default is still sequential build, right? I have
>>> no suspect environment variables.
>>
>> Except for the Sage library (and probably docbuilding, not sure), yes.
>> If you explicitly use 'make -j1', then also the Sage library will be
>> built sequentially, still using Python's multi-processing though, as
>> does docbuilding.
>>
>>
>> Forgot to ask:
>>
>> How does at all local/var/lib/sage/installed/ look like?
>>
>>
>> -leif
> 
> 


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] When factorizing two polynomials: bug in gerepile, significant pointers lost

2016-07-02 Thread Fabian Gundlach
Hello,

I encountered the following error with Sage 7.2 (running Pari 2.8.0 - 
development git 61b65cc) on 64-bit Linux:



sage: 
factor(10168294586031875795858081963666896068309279739028149015822994808470409*x^40
 
+ 54637623902063579051764164063785862273611
227214908262321295448827189084*x^39 + 
70277533614869515097962450874425962549220558005689745585991279744832844*x^38 
- 8376262189094092
345214251474588345374416636909696030473181959426070676*x^37 + 
242436471429285303967664599557556624957448729852485841450904112819960*x
^36 - 
16467308196223131257423201642300320128598078516427018512063667037294*x^35 + 
994670440764331398827492095544600212856465140498468
589958417872072*x^34 + 
1669447355892151599814976161752696223640623068834337285730125664*x^33 + 
4787821180520149095350007584262622
1319502304181118993796382*x^32 - 
11027053324867589949389559654243101141839981063096910359753562*x^31 - 
650300612550426855523171806453
147668269344451836561774976635*x^30 + 
1570684208380806232824734619938834236093091252040919342718*x^29 + 
34145278060467227277351650969
0661978537006252836870160018*x^28 - 
966249275643573722337167379239879222114833277088010990*x^27 - 
11930600081984079242665842322914049
3263927594569597794*x^26 + 
1713994524513493848614719052055059346207593390535634*x^25 + 
423566245411356544950245312909262295898883
3235*x^24 - 996720692002969642895416146776609782878203402522*x^23 - 
13192515526064968724761611985177806405225265171*x^22 + 3432294679
31700304107325597744650482081790788*x^21 + 
2664889270854122998123116283199878096309356*x^20 - 
983892014425892473122607648686510399940
82*x^19 - 150060150030105789105698925850838409429*x^18 + 
25211033715397630291436024039238871516*x^17 - 870382582902471525325447717394
57079*x^16 - 5390615133300676018637015393468804*x^15 + 
29306521731548203900579062036148*x^14 + 898735965174867625096564403276*x^13 
- 
4155515638403008599438631634*x^12 - 111947828289343132957097300*x^11 + 
236978606843233982987143*x^10 + 9962170815201528010504*x^9 + 1
2452485804904321512*x^8 - 546338689137860232*x^7 - 2961407384736921*x^6 + 
7430129362962*x^5 + 136659878406*x^4 + 634377186*x^3 + 1511
809*x^2 + 1898*x + 1)

(100837962028354558549359124161681597*x^20 + 
270917930127842441064021001407727686*x^19 - 
15465362385090532027681012126697308*x^18 + 1
6986375609134831570968842775350*x^17 - 
29476942979162692929636792384016*x^16 + 147550926306681751374468608357*x^15 
+ 1333976962730521
5432298110948*x^14 + 33478195196624326088400980*x^13 - 
3231442293652186023750739*x^12 + 24170655490731720935025*x^11 + 
86595567527548
7498612*x^10 - 20060803083331090107*x^9 - 243338441403803107*x^8 + 
5265846272236422*x^7 + 34263040880952*x^6 - 648382533165*x^5 - 415
1669958*x^4 + 27170397*x^3 + 305604*x^2 + 949*x + 1)^2

sage: factor(256*x^40 + 1024*x^35 + 1792*x^30 + 1792*x^25 + 1120*x^20 + 
448*x^15 + 112*x^10 + 16*x^5 + 1)
--- 
PariError Traceback (most recent call last) 
 in () 
> 1 factor(Integer(256)*x**Integer(40) + Integer(1024)*x**Integer(35) + 
Integer(1792)*x**Integer(30) + Integer(1792)*x**Integer(2
5) + Integer(1120)*x**Integer(20) + Integer(448)*x**Integer(15) + Integer(
112)*x**Integer(10) + Integer(16)*x**Integer(5) + Integer(1
)) 

  
 

/usr/lib/python2.7/site-packages/sage/arith/misc.pyc in factor(n, proof, 
int_, algorithm, verbose, **kwds) 
  2476 # Just in case factor method doesn't have a proof option. 
  2477 try: 
-> 2478 return n.factor(**kwds) 
  2479 except AttributeError: 
  2480 raise TypeError("unable to factor n") 

sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.factor 
(/build/sagemath/src/sage-7.2/src/build/cythonized/sage/sy
mbolic/expression.cpp:50369)() 

  
 

sage/rings/polynomial/polynomial_element.pyx in 
sage.rings.polynomial.polynomial_element.Polynomial.factor 
(/build/sagemath/src/sage-
7.2/src/build/cythonized/sage/rings/polynomial/polynomial_element.c:33493)() 
 

/usr/lib/python2.7/site-packages/sage/rings/rational_field.pyc in 
_factor_univariate_polynomial(self, f) 
  1275  
  1276 """ 
-> 1277 G = list(f._pari_with_name().factor()) 
  1278  
  1279 # normalize the leading coefficients 

sage/libs/pari/gen.pyx in sage.libs.pari.gen.gen.factor 
(/build/sagemath/src/sage-7.2/src/build/cythonized/sage/libs/pari/gen.c:12273
8)() 


 

sage/libs/pari/handle_error.pyx in sage.libs.pari.handle_error._pari_err_handle 
(/build/sagemat

[sage-devel] Re: When factorizing two polynomials: bug in gerepile, significant pointers lost

2016-07-02 Thread Ralf Stephan
I get this on beta5 for the first command:

(100837962028354558549359124161681597*x^20 + 
270917930127842441064021001407727686*x^
19 - 15465362385090532027681012126697308*x^18 + 
16986375609134831570968842775350*x^1
7 - 29476942979162692929636792384016*x^16 + 
147550926306681751374468608357*x^15 + 13
339769627305215432298110948*x^14 + 33478195196624326088400980*x^13 - 
323144229365218
6023750739*x^12 + 24170655490731720935025*x^11 + 865955675275487498612*x^10 
- 200608
03083331090107*x^9 - 243338441403803107*x^8 + 5265846272236422*x^7 + 
34263040880952*
x^6 - 648382533165*x^5 - 4151669958*x^4 + 27170397*x^3 + 305604*x^2 + 949*x 
+ 1)^2

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: When factorizing two polynomials: bug in gerepile, significant pointers lost

2016-07-02 Thread Ralf Stephan
Ah sorry, I confirm the observation on beta5. After both commands
in the given order.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Can't figure out how polynomial conversion works in the M2/Sage interface

2016-07-02 Thread saad khalid
Hey everyone:

I was hoping some of you could provide some insight where my knowledge is 
lacking. I'm trying to add to the M2/Sage interface by adding a conversion 
for the M2 Divide class. Sage can already convert polynomials, so my hope 
was to just have it treat the Divide class as two polynomials, one in the 
numerator and the other in the denominator. Here is an example of an object 
in the divide class:
macaulay2.eval("""
K = toField(QQ[zet]/(zet^8 - zet^7 +zet^5 - zet^4 +zet^3 -zet + 1))
A=matrix{{zet^1,0},{0,zet^13}}
needsPackage "InvariantRing"
G=generateGroup({A},K)
P = molienSeries G
 """)

P is a "Divide" object. Here is an example of Sage converting a polynomial 
from M2 to Sage:
macaulay2.eval(""" 
needsPackage "Points"; 
M = matrix{{1,2,3},{4,5,6}}
R = QQ[x,y,MonomialOrder=>Lex]; 
(Q,inG,G) = points(M,R) 
G#0
ring G#0
""") 
G0 = macaulay2('G#0').to_sage(); G0

G in M2 is a list of polynomials, and G#0 is the first one. Here's what it 
looks like:

 3  2
y  - 15y  + 74y - 120

I convert this to a sage object, G0, and it appears as:

y^3 - 15*y^2 + 74*y - 120

The part that I really need is where Sage changes M2's two-line display for 
exponents on variables to just the standard Sage notation. I'm looking at the 
to_sage()
method in the source code but I can't seem to figure out how it's doing it. Am 
I missing something obvious? G#0 is a polynomial ring I believe, and here 
is the code in the to_sage function for PolynomialRings:
elif cls_str == "PolynomialRing":
from sage.rings.all import PolynomialRing
from sage.rings.polynomial.term_order import 
inv_macaulay2_name_mapping

#Get the base ring
base_ring = self.coefficientRing().to_sage()

#Get a string list of generators
gens = str(self.gens())[1:-1]

# Check that we are dealing with default degrees, i.e. 1's.
if self.degrees().any("x -> x != {1}").to_sage():
raise ValueError("cannot convert Macaulay2 polynomial ring 
with non-default degrees to Sage")
#Handle the term order
external_string = self.external_string()
order = None
if "MonomialOrder" not in external_string:
order = "degrevlex"
else:
for order_name in inv_macaulay2_name_mapping:
if order_name in external_string:
order = inv_macaulay2_name_mapping[order_name]
if len(gens) > 1 and order is None:
raise ValueError("cannot convert Macaulay2's term order to 
a Sage term order")

return PolynomialRing(base_ring, order=order, names=gens)


Where in this code does that conversion happen? It's like parsing ascii 
art...

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Can't figure out how polynomial conversion works in the M2/Sage interface

2016-07-02 Thread Dima Pasechnik


On Saturday, July 2, 2016 at 7:13:41 PM UTC+1, saad khalid wrote:
>
> Hey everyone:
>
> I was hoping some of you could provide some insight where my knowledge is 
> lacking. I'm trying to add to the M2/Sage interface by adding a conversion 
> for the M2 Divide class. Sage can already convert polynomials, so my hope 
> was to just have it treat the Divide class as two polynomials, one in the 
> numerator and the other in the denominator. 
>

Why? Sage can work with multivariate rational functions just fine:

sage: R.=QQ[]
sage: f=x*y
sage: g=x^2+y^2
sage: f/g
x*y/(x^2 + y^2)
sage: type(f/g)

sage: 


 

> Here is an example of an object in the divide class:
> macaulay2.eval("""
> K = toField(QQ[zet]/(zet^8 - zet^7 +zet^5 - zet^4 +zet^3 -zet + 1))
> A=matrix{{zet^1,0},{0,zet^13}}
> needsPackage "InvariantRing"
> G=generateGroup({A},K)
> P = molienSeries G
>  """)
>
> M2 can provide you numerator and denominator of a Divide object, and then
you can use the existing Sage code to convert these two polynomials, and 
then form the fraction.


HTH,
Dmitrii


 

> P is a "Divide" object. Here is an example of Sage converting a polynomial 
> from M2 to Sage:
> macaulay2.eval(""" 
> needsPackage "Points"; 
> M = matrix{{1,2,3},{4,5,6}}
> R = QQ[x,y,MonomialOrder=>Lex]; 
> (Q,inG,G) = points(M,R) 
> G#0
> ring G#0
> """) 
> G0 = macaulay2('G#0').to_sage(); G0
>
> G in M2 is a list of polynomials, and G#0 is the first one. Here's what it 
> looks like:
>
>  3  2
> y  - 15y  + 74y - 120
>
> I convert this to a sage object, G0, and it appears as:
>
> y^3 - 15*y^2 + 74*y - 120
>
> The part that I really need is where Sage changes M2's two-line display for 
> exponents on variables to just the standard Sage notation. I'm looking at the 
> to_sage()
> method in the source code but I can't seem to figure out how it's doing it. 
> Am I missing something obvious? G#0 is a polynomial ring I believe, and here 
> is the code in the to_sage function for PolynomialRings:
> elif cls_str == "PolynomialRing":
> from sage.rings.all import PolynomialRing
> from sage.rings.polynomial.term_order import 
> inv_macaulay2_name_mapping
>
> #Get the base ring
> base_ring = self.coefficientRing().to_sage()
>
> #Get a string list of generators
> gens = str(self.gens())[1:-1]
>
> # Check that we are dealing with default degrees, i.e. 1's.
> if self.degrees().any("x -> x != {1}").to_sage():
> raise ValueError("cannot convert Macaulay2 polynomial 
> ring with non-default degrees to Sage")
> #Handle the term order
> external_string = self.external_string()
> order = None
> if "MonomialOrder" not in external_string:
> order = "degrevlex"
> else:
> for order_name in inv_macaulay2_name_mapping:
> if order_name in external_string:
> order = inv_macaulay2_name_mapping[order_name]
> if len(gens) > 1 and order is None:
> raise ValueError("cannot convert Macaulay2's term order 
> to a Sage term order")
>
> return PolynomialRing(base_ring, order=order, names=gens)
>
>
> Where in this code does that conversion happen? It's like parsing ascii 
> art...
>
> Thanks!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: Can't figure out how polynomial conversion works in the M2/Sage interface

2016-07-02 Thread saad khalid
Well, here's what i tried and it doesn't seem to work after I build sage 
again. I added this code to the to_sage() function, 
elif cls_str == "Divide":
self_Div = self
div_Numerator = macaulay2('numerator self_Div')
div_Denominator = macaulay2('denominator self_Div')
div_Numerator = div_Numerator.sage_polystring()
div_Denominator = div_Denominator.sage_polystring()
sage_Div = div_Numerator/div_Denominator
return sage_Div

 
I added this after the main else statement. The code looks like rubbish to 
me but I didn't know what else to do, so i thought I'd show something and 
ask for improvements, if that's okay... When running the following code now 
in Sage, here is my error message:

sage: macaulay2.eval("""
: K = toField(QQ[zet]/(zet^8 - zet^7 +zet^5 - zet^4 +zet^3 -zet + 1))
: A=matrix{{zet^1,0},{0,zet^14}}
: needsPackage "InvariantRing"
: G=generateGroup({A},K)
: P = molienSeries G
:  """)
K

PolynomialRing

| zet 0|
| 0   -zet^7+zet^6-zet^4+zet^3-zet^2+1 |

2   2
Matrix K  <--- K

InvariantRing

Package

{| 1 0 |, | -zet^7-zet^2 0 |, | zet^7 0 |, | 
zet^7-zet^6-zet^3+zet^2-1 0 |, | -zet^7+zet^6-zet^4+zet^3-zet^2+1 0   |, 
| zet 0|, | -zet^6-zet 0 |, | zet^5 0   
 |, | zet^2 0|, | zet^6 0   
  |, | zet^7-zet^5+zet^4-zet^3+zet-1 0 |, | zet^4 0  |, | -zet^7
+zet^5-zet^4-zet+1 0 |, | zet^3 0|, | -zet^5-1 0 |}
 | 0 1 |  | 0zet^3 |  | 0 zet^7-zet^5+zet^4-zet^3+zet-1 |  | 
0 zet^6 |  | 0zet | 
 | 0   -zet^7+zet^6-zet^4+zet^3-zet^2+1 |  | 0  zet^4 |  | 0 -
zet^5-1 |  | 0 -zet^7+zet^5-zet^4-zet+1 |  | 0 zet^7-zet^6-zet^3+zet
^2-1 |  | 0 zet^7 |  | 0 -zet^6-zet |  | 0 
   zet^2 |  | 0 -zet^7-zet^2 |  | 0zet^5 |

List

 234567891011121314
1 - T + T  - T  + T  - T  + T  - T  + T  - T  + T   - T   + T   - T   + T
---
2  34578   2   234
 (1 - T) (1 - T + T  - T  + T  - T  + T )(1 + T + T )(1 + T + T  + T  + T )

Expression of class Divide

sage: G = macaulay2('P').to_sage()
---
TypeError Traceback (most recent call last)
/home/saad/sage/local/lib/python2.7/site-packages/sage/all_cmdline.pyc in 
()
> 1 G = macaulay2('P').to_sage()

/home/saad/sage/local/lib/python2.7/site-packages/sage/interfaces/macaulay2.pyc 
in to_sage(self)
   1151 elif cls_str == "Divide":
   1152 self_Div = self
-> 1153 div_Numerator = macaulay2('numerator self_Div')
   1154 div_Denominator = macaulay2('denominator self_Div')
   1155 div_Numerator = div_Numerator.sage_polystring()

/home/saad/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc 
in __call__(self, x, name)
241 
242 if isinstance(x, six.string_types):
--> 243 return cls(self, x, name=name)
244 try:
245 return self._coerce_from_special_method(x)

/home/saad/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc 
in __init__(self, parent, value, is_name, name)
   1379 except (RuntimeError, ValueError) as x:
   1380 self._session_number = -1
-> 1381 raise_(TypeError, x, sys.exc_info()[2])
   1382 except BaseException:
   1383 self._session_number = -1

/home/saad/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc 
in __init__(self, parent, value, is_name, name)
   1374 else:
   1375 try:
-> 1376 self._name = parent._create(value, name=name)
   1377 # Convert ValueError and RuntimeError to TypeError for
   1378 # coercion to work properly.

/home/saad/sage/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc 
in _create(self, value, name)
431 def _create(self, value, name=None):
432 name = self._next_var_name() if name is None else name
--> 433 self.set(name, value)
434 return name
435 

/home/saad/sage/local/lib/python2.7/site-packages/sage/interfaces/macaulay2.pyc 
in set(self, var, value)
318 ans = Expect.eval(self, cmd)
319 if ans.find("stdio:") != -1:
--> 320 raise RuntimeError("Error evaluating Macaulay2 
code.\nIN:%s\nOUT:%s"%(cmd, ans))
321 
322 def _object_class(self):

TypeError: Error evaluating