-
Notifications
You must be signed in to change notification settings - Fork 0
5_things_I_wish_I_knew_IMA2011
-
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.
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].
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".
- Simple but helpful: {* *} turns larger chunks of text into a comment
Return to the Main IMA2011 page
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.
- If you want to see the files that have loaded: peek loadedFiles
-
Home
- Introduction
- Macaulay2 Contribution Guides
- Macaulay2 Workshop Guides
-
Macaulay2 Internals
- Building Macaulay2 from source
- Components of Macaulay2
- Case Studies
- Web servers
- Other
- Frequently Asked Questions
- Road map