Skip to content

5_things_I_wish_I_knew_IMA2011

Mahrud Sayrafi edited this page Mar 12, 2021 · 1 revision

title: 5 things I wish I knew IMA2011 permalink: wiki/5_things_I_wish_I_knew_IMA2011/ layout: wiki

Brett

  • If given a rational function field S = frac(R) for some polynomial ring R, one can recover R by using the command last S.baseRings

  • In order to create a new polynomial ring within a method without implicitly invoking a use command (which changes the ring that the user was working with), one can use something of the form R = QQ(monoid [x,y])

  • If you compute something (say a list L of 5000 ideals) that you would like to save for future use, you can use for example print toString L

    to get it all as one line (no text wrapping), which can be selected, saved in a file, then reloaded later with only one execution.

Sonja

Wish I had found the "Defining Rings inside of functions" inside the How-To section of the Gottingen workshop wiki much before this week.

Also I always forget the clever methods for lists: scan, any, all... I also forget the following for Laurent polynomial rings: QQ[x,y,Inverses=>true].

Frank

To get the coefficients involving a single monomial when there are several other variables around, use contract. For example, contract(x^2,x^2+a*x^2+b*x^2*y).

Meta-P and Meta-N are your friends.

Computing grobner bases in lex order often gets faster when providing a hilbert polynomial when computed via grevlex.

===Bits from the 'Ask Dan&Mike' session:===

  • use net for pretty printing.
  • equality: === structural check of equality, without any math; == is for mathematical equality. E.g.: two ideals are === if and only if the generators are exactly the same in the same order. Sometimes it is best to subtract two objects and check if the answer is 0. You can also install your own new method for == to define what equality is between two objects that you have defined..
  • can we use M2 from C and vice versa? -there is no way to treat M2 as a subroutine from C; but a lot of M2 is written in C or C++. there should be a help page on this!
    • Well, for special tasks it is sufficient to call M2 (or Singular, or..) from C++ via 'pstream' (http://pstreams.sourceforge.net/) and then parse the result, for example using 'boost.spirit'. But this approach does not scale. (Jakob Kroeker).
    • Vice versa: it is possible to call an arbitrary process from M2 via openInOut, passing input to pIO := openInOut( ...) object, get and parse pIO output. More detailed advice will follow soon - (Jakob Kroeker).
  • To find out what methods there are for something, say ideal, ask: methods ideal. You can also ask for code for a particular method, e.g.: code tangentSheaf. If this is not illuminating, try code methods tangentSheaf.
  • If you have 2 packages and both export the same symbol (object, method), one overshadows the other. There will be a warning message explaining which one prevails. By the way you can always access method "a" from package "A" by typing A$a.
  • Do not use, say, "use R" for a particular ring R, inside of a method (package). Instead, you can access generators as "gens R" or "vars R".

Christine

  • Simple but helpful: {* *} turns larger chunks of text into a comment

Return to the Main IMA2011 page

Call Macaulay2 from C++

For special tasks it is sufficient to call M2 (or Singular, or..) from C++ via 'pstream' (http://pstreams.sourceforge.net/)
and then parse the result, for example using 'boost.spirit':
Here is a simple out-of-the-box example without the parsing part: Macaulay2CallExampe.cpp
 The header pstream.h   is also required to compile the example.

see the files that have loaded

  • If you want to see the files that have loaded: peek loadedFiles
Clone this wiki locally