http://apcocoa.uni-passau.de/wiki/api.php?action=feedcontributions&user=130.251.167.207&feedformat=atom
ApCoCoAWiki - User contributions [en]
2024-03-28T11:55:33Z
User contributions
MediaWiki 1.35.0
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoALib:Contribute&diff=7901
CoCoALib:Contribute
2008-11-24T16:14:55Z
<p>130.251.167.207: /* Contribute a new CoCoAServer function */</p>
<hr />
<div>== Contribute with an example ==<br />
The easiest way to help the CoCoALib project is to have a look at the "example" directory, run the examples, play with them, and send a comment about what can be improved.<br />
<br />
You could also create a new example to be added to the distibution.<br />
<br />
=== How do I run an example? ===<br />
<br />
Download CoCoALib-xxx and compile it: (you will need GMP)<br />
cd CoCoALib-xxx<br />
./configure<br />
make<br />
to run an example do this:<br />
cd examples<br />
make ex-yyyyy<br />
./ex-yyyy<br />
<br />
=== How do I contribute an example? ===<br />
<br />
Let's say you have written an example "ex-MyExample.C". To add your code to the CoCoALib examples follow the instructions below:<br />
<br />
# Put your file into the right place:<br />
#* Copy the example file "ex-MyExample.C" into the subdirectory "CoCoALib-xxx/examples".<br />
# Edit "CoCoALib-xxx/examples/Makefile":<br />
#* Add "ex-MyExample.C" to the variable definition of "SRC".<br />
<br />
Now everything is ready to start a test build. First you have to rebuild the Makefile dependencies:<br />
cd CoCoALib-xxx<br />
cd examples<br />
rm Makefile_dependencies<br />
make dependencies<br />
<br />
Next you should follow the instructions under [[Contribute_to_CoCoALib#How do I run an example?|How do I run an example?]] to test-run your example.<br />
<br />
<br />
== Contibute with a new class ==<br />
Let's say you have written a new class "MyClass". Let "MyClass.C" and "MyClass.H" be the files that contain your source code. To add your code the CoCoALib follow the instructions below:<br />
<br />
# Put your files into the right place:<br />
#* Copy the source file "MyClass.C" into the subdirectory "CoCoALib-xxx/src".<br />
#* Copy the header file "MyClass.H" into the subdirectory "CoCoALib-xxx/include/CoCoA".<br />
# Edit "CoCoALib-xxx/include/CoCoA/library.H":<br />
#* Add an include directive for your header file "MyClass.H".<br />
# Edit "CoCoALib-xxx/src/Makefile":<br />
#* Add "MyClass.C" to the variable definition of "SRC".<br />
<br />
Now everything is ready to start a test build. First you have to rebuild the Makefile dependencies:<br />
cd CoCoALib-xxx<br />
rm src/Makefile_dependencies<br />
make dependencies<br />
<br />
Next you should trigger a full build to see if everything works:<br />
make all<br />
<br />
If the build process terminates without an error you should write an example for your class and check if it works correctly. See [[Contribute_to_CoCoALib#How do I contribute an example?|How do I contribute an example?]] for more information.<br />
<br />
== Contribute a new CoCoAServer function ==<br />
It is assumed that you already have done the steps listed in [[HowTo:Contribute a CoCoA 4 function that calls the CoCoAServer|Contribute a CoCoA 4 function that calls the CoCoAServer]].<br />
<br />
All actions take place in "RegisterServerOp.C".<br />
<br />
The documentation is in RegisterServerOp.txt and ServerOp.txt in the doc/ directory.<br />
<br />
[[Category:CoCoALib]]</div>
130.251.167.207
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoA:Emacs_interface&diff=1489
CoCoA:Emacs interface
2005-11-15T09:51:36Z
<p>130.251.167.207: /* MSWindows */</p>
<hr />
<div>== cocoa-mode == <br />
<br />
The distribution of cocoa-4.5 includes an <code>emacs/</code> directory which contains <code>cocoa.el</code> and <code>cocoa.emacs</code> (the settings to be added to your <code>.emacs</code>).<br />
<br />
* a friendly '''CoCoA''' menu<br />
* automatic indentation <br />
* coloured syntax (in font-lock-mode - default) <br />
* capitalization of keywords (in abbrev-mode - default) <br />
* automatic loading of <code>wordlist.txt</code> for dynamic abbrev expansion (<code>M-/</code> or <code>TAB</code>) <br />
<br />
=== CoCoA menu === <br />
[[Image:CoCoAMenu.jpg|right|CoCoA menu for cocoa-mode]]<br />
From the menu you can <br />
* send lines, regions and files to cocoa<br />
* go to the parse error line (if you had a parse error after sending a file) <br />
* start or restart the CoCoAServer<br />
<br />
<code>Use TAB for Completion</code> (available soon) will allows to toggle this option. It used to be always off up to cocoa-4.4, and always on in cocoa-4.5.<br />
<br />
=== Some key bindings in cocoa-mode ===<br />
<br />
* <code>C-c C-e</code> (like in latex-mode) writes the appropriate "End" (EndIf,...) <br />
* <code>C-c C-c</code> (like in c-mode) comment-region<br />
<br />
If the following features do not work you should customize the variable <code>cocoa-executable</code> in '''cocoa.emacs''': <br />
<br />
=== Calling CoCoA ===<br />
From a buffer in '''cocoa-mode''' you can select things and "send" them to a cocoa buffer (called <code>*cocoa*</code>) to be evaluated:<br />
<br />
; <code>C-c C-l</code> : execute this line (from any point in the line)<br />
; <code>C-c C-r</code> : execute the selected region<br />
; <code>C-c C-f</code> : execute all this file (from any point in thefile)<br />
; <code>C-c C-p</code> : go to the parse error line (if C-c C-f gave a parse error) <br />
; <code>C-c C-m</code> or <code>C-c ?</code> : call the CoCoA manual for this word (from any point in the word)<br />
<br />
They will automatically start CoCoA (if it isn't already running in a <code>*cocoa*</code> buffer).<br />
<br />
; <code>M-x cocoa</code> : opens a buffer (called <code>*cocoa*</code>) with a running CoCoA<br />
<br />
== Installation instructions for experts ==<br />
<br />
Copy the customizations and the settings you like from '''cocoa-4.5/emacs/cocoa.emacs'''<br />
into your '''~/.emacs'''.<br />
<br />
== Installation instructions for non-experts ==<br />
<br />
Following these instructions Emacs will recognise files with a CoCoA extension(<code>.coc, .cocoa, .cpkg</code>): REMEMBER to add one to the name of your files!<br />
<br />
If you used Emacs itself to change some settings you should restart Emacs. (of course you can load them without restarting Emacs, but this is the section for non-experts! ;-) )<br />
<br />
=== Unix/Linux ===<br />
<br />
Open your <code>.emacs</code> file with any editor <br />
(it should be in your home, and it may not exist!):<br />
<br />
Add this line at the end of your '''.emacs''':<br> <code>(load-file "&lt;path&gt;/emacs/cocoa.emacs")</code> <br />
<br />
for example: <br />
<br />
<code>(load-file "/usr/local/cocoa-4.5/emacs/cocoa.emacs")</code><br />
<br />
If you did not install cocoa in <code>/usr/local/</code><br />
then you need to correct the path in the files:<br />
* <code>&lt;path&gt;/cocoa-4.5/emacs/cocoa.emacs</code><br />
* <code>&lt;path&gt;/cocoa-4.5/cocoa</code><br />
<br />
=== MacOSX ===<br />
<br />
NB: MacOSX hides all file whose name start with ".", in particular '''.emacs'''.<br />
<br />
Go to the folder '''emacs''' in <b>CoCoA-4.5</b> and double-click on one of<br />
* <code>set-new-emacs-prefs</code> creates a brand new '''.emacs''' file (and moves the old one, if you had one, into previous.emacs)<br />
* <code>set-add-emacs-prefs</code> adds one line to your current <b>.emacs</b> file (creating it if necessary)<br />
<br />
=== MSWindows ===<br />
<br />
There is a file called "_emacs" in your cocoa-4.5/emacs/ directory which contains all the cocoa-emacs settings.<br />
<br />
You need to set your "HOME" variable to the cocoa-4.5/emacs/ directory. (supposing that the average Windows user does not use the variable "HOME" for anything else)<br />
That is where Emacs looks for its config file, i.e. _emacs. <br />
Your computer evaluates %HOME% when you log in. <br />
<br />
To set it right click on "My Computer", click on "properties" and then on the "Advanced" tab. Then click on the button "Environment Variables". Another dialog pops up and you add HOME by pressing on "new" and filling in the appropriate values. The upper "new" sets HOME for all users and requires admin-rights, the lower "new" sets it just for the current user.<br />
<br />
<br />
[[Category:CoCoA4]]</div>
130.251.167.207
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoA:HowTo:Plot_order_ideals&diff=127
CoCoA:HowTo:Plot order ideals
2005-06-27T16:27:37Z
<p>130.251.167.207: /* POV-Ray Framework */</p>
<hr />
<div>==About==<br />
<br />
At the [[SummerSchool05|CoCoA Summer School 2005]] there was a discussion about the possibility to plot order ideals.<br />
An order ideal is simply the complement of an ideal's leading term ideal, otherwise it could be described as a vector space basis <br />
of the quotient space P/I consisting of monomials (this is exactly the B in [[Macaulay's Basis Theorem]] with respect to the notation of Kreuzer's & Robbiano's book).<br />
<br />
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates. <br />
During the school, [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.<br />
<br />
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com POV-Ray] or Latex. <br />
The code uses CoCoA's [[QuotientBasis]] command, to get a list of all terms to draw and than draws this terms (or selects which of them should be drawn and which are invisible, in case of the latex pictures).<br />
<br />
<br />
The code to plot the order ideals is given in the next sections:<br />
<br />
== CoCoA & Latex Code (1. Version) ==<br />
<br />
Both functions (this and the next one) get as input a zero-dimensional ideal. The output is some text, containing the latex picture enviroment. simply render this to get a picture of your order ideal. You can even change the point of view<br />
of the model, by changing V1, V2, V3 and L1, L2, L3. How this exactly works can be figured out quite easily, having a look at a latex documentation for the picture enviroment.<br />
<br />
Define BorderTeX(I)<br />
String:='\begin{picture}(300,300)';<br />
<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1);<br />
V2 := Vector(0,1); <br />
V3 := Vector(1,0);<br />
L1 := 14;<br />
L2 := 20;<br />
L3 := 20;<br />
<br />
// get the Vectorspace-Basis of P/I:<br />
<br />
B := QuotientBasis(I);<br />
<br />
// check what to paint for what Basis Element:<br />
<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
<br />
EndForEach;<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & Latex Code (2. Version) ==<br />
<br />
I created another version, a little bit more sophisticated. It contains coordinate axis and scales the picture enviroment to the right size. The code for this is:<br />
<br />
Define Border(I)<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1); L1 := 14;<br />
V2 := Vector(0,1); L2 := 20;<br />
V3 := Vector(1,0); L3 := 20;<br />
<br />
Max1 := 0;<br />
Max2 := 0;<br />
Max3 := 0;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// get the Vectorspace-Basis of P/I: <br />
B := QuotientBasis(I);<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute picture's size:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
If L[1] > Max1 Then Max1 := L[1]; EndIf;<br />
If L[2] > Max2 Then Max2 := L[2]; EndIf;<br />
If L[3] > Max3 Then Max3 := L[3]; EndIf;<br />
EndForEach;<br />
<br />
Max1:= Max1 + 1; Max2 := Max2 +1; Max3 := Max3 +1;<br />
<br />
Width := Sum([ Abs(LC((Max1+3)*L1*V1[1])),Abs(LC((Max2+3)*L2*V2[1])),Abs(LC((Max3+3)*L3*V3[1])) ]);<br />
Height := Sum([ Abs(LC((Max1+3)*L1*V1[2])),Abs(LC((Max2+3)*L2*V2[2])),Abs(LC((Max3+3)*L3*V3[2])) ]);<br />
<br />
String:='\begin{picture}('+Sprint(Width)+','+Sprint(Height)+')';<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute Offset / (0,0,0):<br />
Offset:=Vector(Abs(Min([ LC((Max1+3)*L1*V1[1]),LC((Max2+3)*L2*V2[1]),LC((Max3+3)*L3*V3[1])])),<br />
Abs(Min([ LC((Max1+3)*L1*V1[2]),LC((Max2+3)*L2*V2[2]),LC((Max3+3)*L3*V3[2])])));<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
EndForEach;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Draw the three axis and the indeterminates names:<br />
<br />
Start := Offset + Max1 * V1 * L1;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V1[1])+','+Sprint(V1[2])+'){'+Sprint(2*L1)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L1*V1[1])+','+Sprint(Start[2]+3*L1*V1[2])+')<br />
{$\displaystyle ' +Sprint(Indet(1))+'$}';<br />
<br />
Start := Offset + Max2 * V2 * L2;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V2[1])+','+Sprint(V2[2])+'){'+Sprint(2*L2)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L2*V2[1])+','+Sprint(Start[2]+3*L2*V2[2])+')<br />
{$\displaystyle ' +Sprint(Indet(2))+'$}';<br />
<br />
Start := Offset + Max3 * V3 * L3;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V3[1])+','+Sprint(V3[2])+'){'+Sprint(2*L3)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L3*V3[1])+','+Sprint(Start[2]+3*L3*V3[2])+')<br />
{$\displaystyle ' +Sprint(Indet(3))+'$}';<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== Latex Framework ==<br />
<br />
As a framework where to copy&paste the output to, you can use the following latex code:<br />
<br />
\documentclass[12pt,a4paper]{article}<br />
<br />
\usepackage{umlaut,a4wide,amsmath,amssymb,stmaryrd,color,graphicx,fancyhdr,multicol}<br />
\usepackage[latin1]{inputenc}<br />
\setlength{\parindent}{0mm}<br />
<br />
\begin{document}<br />
<br />
% Copy output here!<br />
<br />
\end{document}<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & POV-Ray Code ==<br />
<br />
This function returns some [http://povray.com POV-Ray] code to plot the quotient ideal of the input ideal (not necessarily zero-dimensional).<br />
The output of QuotientBasisPOV should be saved into a file called "monomials.inc" (see the example below), in order to be included by QuotienBasis.pov:<br />
<br />
Define NewLine()<br />
Return "<br />
";<br />
EndDefine; -- NewLine<br />
<br />
Define QuotientBasisPOV(I)<br />
If NumIndets()<>3 Then Error("QuotientBasisPOV: ring must have 3 indeterminates"); EndIf;<br />
String := "";<br />
GENS := Interreduced(Gens(I));<br />
-----<br />
XMax := Max([Deg(T, Indet(1)) | T In GENS]);<br />
YMax := Max([Deg(T, Indet(2)) | T In GENS]);<br />
ZMax := Max([Deg(T, Indet(3)) | T In GENS]);<br />
XYZMax := Max(XMax, YMax, ZMax);<br />
-----<br />
String := String + "#declare CamZoom="<br />
+ Sprint(100/Isqrt(XYZMax)) +";"<br />
+ NewLine();<br />
String := String + "#declare CamEye=<0,"<br />
+ Sprint(ZMax/4) +",0>;"<br />
+ NewLine();<br />
<br />
-----<br />
G1 := [Indet(1)^(XMax+1), Indet(2)^(YMax+1), Indet(3)^(ZMax+1)];<br />
G2 := [G1[1]*Indet(1), G1[2]*Indet(2), G1[3]*Indet(3)];<br />
-- G2 := [Indet(1)^(XYZMax+2), Indet(2)^(XYZMax+2), Indet(3)^(XYZMax+2)];<br />
----- axes<br />
String := String + "#declare AxisTags = union {" + NewLine();<br />
Line := "object {object AxisTag(""x"") translate <"<br />
+Sprint(XMax+3) + ",0,0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""y"") translate <0,"<br />
+Sprint(YMax+3) + ",0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""z"") translate <0,0.1,"<br />
+Sprint(ZMax+3) + "> }" + NewLine();<br />
String := String + Line;<br />
String := String + "}" + NewLine();<br />
----- Generators<br />
String := String + "#declare Generators = union {" + NewLine();<br />
ForEach G In GENS Do<br />
L := Log(G);<br />
Line := "union { object{Generator} ";<br />
String := String + Line;<br />
Line := "object Exponents(""" +<br />
+ Sprint(L[1]) + " " + Sprint(L[2]) + " " + Sprint(L[3])<br />
+ """) translate <"<br />
+Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
----- Monomials<br />
B := QuotientBasis(I+Ideal(G1)); <br />
String := String + "#declare Monomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- InftyMonomials<br />
B := Diff(QuotientBasis(I+Ideal(G2)), QuotientBasis(I+Ideal(G1)));<br />
String := String + "#declare InftyMonomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- <br />
Return String;<br />
EndDefine; -- QuotientBasisPOV<br />
<br />
/*<br />
-- EXAMPLE --<br />
Use Q[x,y,z];<br />
<br />
I := Ideal(x^10yz^6, x^7y^2z^3, xy^3z^4, x^3y^3z^3, xy^4z^4, y^6);<br />
F := OpenOFile("/Users/bigatti/Desktop/POV-Anna/monomials.inc", "w");<br />
PrintLn QuotientBasisPOV(I) On F;<br />
*/<br />
code by [[User:bigatti|bigatti]], 27 Jun 2005<br />
<br />
== POV-Ray Framework ==<br />
<br />
This is the file QuotientBasis.pov, the file including "monomials.inc". You should run it with [http://povray.com POV-Ray] with antialiasing on.<br />
<br />
// Copyright (c) 2005 Anna Bigatti<br />
// You are free to use any part of this example in your own programs.<br />
<br />
// ------------------------------<br />
#include "colors.inc"<br />
#include "functions.inc"<br />
#include "textures.inc"<br />
#include "metals.inc"<br />
#include "glass.inc"<br />
<br />
global_settings{<br />
max_trace_level 50<br />
adc_bailout 0.01<br />
}<br />
<br />
// ------------------------------<br />
// Set settings<br />
// ------------------------------<br />
#declare CamLoc=<500,500,-500>;<br />
#declare AspectRatio=4/3;<br />
<br />
light_source{<500,400,-200> color White*5}<br />
//plane{y,0 texture{pigment{rgbf <0.89, 0.98, 1.0, 0.95>}finish{F_Glass5}} hollow}<br />
<br />
<br />
//------------------------------<br />
// colours<br />
//------------------------------<br />
sky_sphere{ pigment{ color Gray90 } }<br />
<br />
#declare P_X = rgbf <0.04, 0.25, 0, 0>;<br />
#declare P_Y = rgbf <0.30, 0.35, 0, 0>;<br />
#declare P_Z = rgbf <0.05, 0.05, 0.4, 0>;<br />
#declare P_Cube = rgbf <0.01, 0.01, .3, 0>;<br />
#declare P_ClearCube = rgbf <0.4, 0.5, .6, .9>;<br />
#declare P_Exponent = rgbt <.2,1,.2,.0>;<br />
<br />
<br />
#declare Generator = sphere{0, .2 texture {T_Brass_2A} }<br />
<br />
#declare Axes = union {<br />
cylinder { <0, 0, 0>, <500, 0, 0>, 0.05 pigment {color P_X} }<br />
cylinder { <0, 0, 0>, <0, 500, 0>, 0.05 pigment {color P_Y} }<br />
cylinder { <0, 0, 0>, <0, 0, 500>, 0.05 pigment {color P_Z} }<br />
}<br />
<br />
// ------------------------------<br />
// creates the cube<br />
// ------------------------------<br />
#macro SolidCube()<br />
union{<br />
#declare sB=0.48;<br />
#declare rB=0.02;<br />
union{<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,-sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,-sB,0> pigment {color P_Z}}<br />
sphere{0,rB translate <sB,sB,sB>}<br />
sphere{0,rB translate <sB,sB,-sB>}<br />
sphere{0,rB translate <sB,-sB,sB>}<br />
sphere{0,rB translate <sB,-sB,-sB>}<br />
sphere{0,rB translate <-sB,sB,sB>}<br />
sphere{0,rB translate <-sB,sB,-sB>}<br />
sphere{0,rB translate <-sB,-sB,sB>}<br />
sphere{0,rB translate <-sB,-sB,-sB>}<br />
}<br />
<br />
box{-0.45,0.45 interior{ior 1.1} }<br />
<br />
translate <sB-rB, sB-rB, sB-rB><br />
}<br />
#end<br />
<br />
<br />
#macro Exponents(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp, <br />
.03, <br />
<-.1,0,0> <br />
scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
.7, 0, 0.4><br />
pigment {color P_Exponent}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
#macro AxisTag(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp,<br />
.03, <br />
<-.1,0,0> <br />
// scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
0, 0, 0.1><br />
pigment {color Gray20}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
// ------------------------------<br />
// scene<br />
// ------------------------------<br />
#include "monomials.inc" // place the cubes<br />
<br />
camera {<br />
location CamLoc<br />
direction z*CamZoom<br />
right x*AspectRatio<br />
look_at CamEye<br />
}<br />
<br />
union{<br />
object {Generators}<br />
object {Axes}<br />
object {AxisTags}<br />
object {Monomials texture{pigment{color P_Cube}}}<br />
object {InftyMonomials texture{pigment{color P_ClearCube}}}<br />
matrix <<br />
0, 0, -1,<br />
1, 0, 0,<br />
0, 1, 0,<br />
0, 0, 0<br />
><br />
<br />
}<br />
code by [[User:bigatti|bigatti]], 27 Jun 2005<br />
<br />
<br />
[[Category:CoCoA4]][[Category:HowTo]]</div>
130.251.167.207
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoA:HowTo:Plot_order_ideals&diff=95
CoCoA:HowTo:Plot order ideals
2005-06-27T16:26:35Z
<p>130.251.167.207: /* CoCoA & POV-Ray Code */</p>
<hr />
<div>==About==<br />
<br />
At the [[SummerSchool05|CoCoA Summer School 2005]] there was a discussion about the possibility to plot order ideals.<br />
An order ideal is simply the complement of an ideal's leading term ideal, otherwise it could be described as a vector space basis <br />
of the quotient space P/I consisting of monomials (this is exactly the B in [[Macaulay's Basis Theorem]] with respect to the notation of Kreuzer's & Robbiano's book).<br />
<br />
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates. <br />
During the school, [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.<br />
<br />
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com POV-Ray] or Latex. <br />
The code uses CoCoA's [[QuotientBasis]] command, to get a list of all terms to draw and than draws this terms (or selects which of them should be drawn and which are invisible, in case of the latex pictures).<br />
<br />
<br />
The code to plot the order ideals is given in the next sections:<br />
<br />
== CoCoA & Latex Code (1. Version) ==<br />
<br />
Both functions (this and the next one) get as input a zero-dimensional ideal. The output is some text, containing the latex picture enviroment. simply render this to get a picture of your order ideal. You can even change the point of view<br />
of the model, by changing V1, V2, V3 and L1, L2, L3. How this exactly works can be figured out quite easily, having a look at a latex documentation for the picture enviroment.<br />
<br />
Define BorderTeX(I)<br />
String:='\begin{picture}(300,300)';<br />
<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1);<br />
V2 := Vector(0,1); <br />
V3 := Vector(1,0);<br />
L1 := 14;<br />
L2 := 20;<br />
L3 := 20;<br />
<br />
// get the Vectorspace-Basis of P/I:<br />
<br />
B := QuotientBasis(I);<br />
<br />
// check what to paint for what Basis Element:<br />
<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
<br />
EndForEach;<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & Latex Code (2. Version) ==<br />
<br />
I created another version, a little bit more sophisticated. It contains coordinate axis and scales the picture enviroment to the right size. The code for this is:<br />
<br />
Define Border(I)<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1); L1 := 14;<br />
V2 := Vector(0,1); L2 := 20;<br />
V3 := Vector(1,0); L3 := 20;<br />
<br />
Max1 := 0;<br />
Max2 := 0;<br />
Max3 := 0;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// get the Vectorspace-Basis of P/I: <br />
B := QuotientBasis(I);<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute picture's size:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
If L[1] > Max1 Then Max1 := L[1]; EndIf;<br />
If L[2] > Max2 Then Max2 := L[2]; EndIf;<br />
If L[3] > Max3 Then Max3 := L[3]; EndIf;<br />
EndForEach;<br />
<br />
Max1:= Max1 + 1; Max2 := Max2 +1; Max3 := Max3 +1;<br />
<br />
Width := Sum([ Abs(LC((Max1+3)*L1*V1[1])),Abs(LC((Max2+3)*L2*V2[1])),Abs(LC((Max3+3)*L3*V3[1])) ]);<br />
Height := Sum([ Abs(LC((Max1+3)*L1*V1[2])),Abs(LC((Max2+3)*L2*V2[2])),Abs(LC((Max3+3)*L3*V3[2])) ]);<br />
<br />
String:='\begin{picture}('+Sprint(Width)+','+Sprint(Height)+')';<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute Offset / (0,0,0):<br />
Offset:=Vector(Abs(Min([ LC((Max1+3)*L1*V1[1]),LC((Max2+3)*L2*V2[1]),LC((Max3+3)*L3*V3[1])])),<br />
Abs(Min([ LC((Max1+3)*L1*V1[2]),LC((Max2+3)*L2*V2[2]),LC((Max3+3)*L3*V3[2])])));<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
EndForEach;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Draw the three axis and the indeterminates names:<br />
<br />
Start := Offset + Max1 * V1 * L1;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V1[1])+','+Sprint(V1[2])+'){'+Sprint(2*L1)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L1*V1[1])+','+Sprint(Start[2]+3*L1*V1[2])+')<br />
{$\displaystyle ' +Sprint(Indet(1))+'$}';<br />
<br />
Start := Offset + Max2 * V2 * L2;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V2[1])+','+Sprint(V2[2])+'){'+Sprint(2*L2)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L2*V2[1])+','+Sprint(Start[2]+3*L2*V2[2])+')<br />
{$\displaystyle ' +Sprint(Indet(2))+'$}';<br />
<br />
Start := Offset + Max3 * V3 * L3;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V3[1])+','+Sprint(V3[2])+'){'+Sprint(2*L3)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L3*V3[1])+','+Sprint(Start[2]+3*L3*V3[2])+')<br />
{$\displaystyle ' +Sprint(Indet(3))+'$}';<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== Latex Framework ==<br />
<br />
As a framework where to copy&paste the output to, you can use the following latex code:<br />
<br />
\documentclass[12pt,a4paper]{article}<br />
<br />
\usepackage{umlaut,a4wide,amsmath,amssymb,stmaryrd,color,graphicx,fancyhdr,multicol}<br />
\usepackage[latin1]{inputenc}<br />
\setlength{\parindent}{0mm}<br />
<br />
\begin{document}<br />
<br />
% Copy output here!<br />
<br />
\end{document}<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & POV-Ray Code ==<br />
<br />
This function returns some [http://povray.com POV-Ray] code to plot the quotient ideal of the input ideal (not necessarily zero-dimensional).<br />
The output of QuotientBasisPOV should be saved into a file called "monomials.inc" (see the example below), in order to be included by QuotienBasis.pov:<br />
<br />
Define NewLine()<br />
Return "<br />
";<br />
EndDefine; -- NewLine<br />
<br />
Define QuotientBasisPOV(I)<br />
If NumIndets()<>3 Then Error("QuotientBasisPOV: ring must have 3 indeterminates"); EndIf;<br />
String := "";<br />
GENS := Interreduced(Gens(I));<br />
-----<br />
XMax := Max([Deg(T, Indet(1)) | T In GENS]);<br />
YMax := Max([Deg(T, Indet(2)) | T In GENS]);<br />
ZMax := Max([Deg(T, Indet(3)) | T In GENS]);<br />
XYZMax := Max(XMax, YMax, ZMax);<br />
-----<br />
String := String + "#declare CamZoom="<br />
+ Sprint(100/Isqrt(XYZMax)) +";"<br />
+ NewLine();<br />
String := String + "#declare CamEye=<0,"<br />
+ Sprint(ZMax/4) +",0>;"<br />
+ NewLine();<br />
<br />
-----<br />
G1 := [Indet(1)^(XMax+1), Indet(2)^(YMax+1), Indet(3)^(ZMax+1)];<br />
G2 := [G1[1]*Indet(1), G1[2]*Indet(2), G1[3]*Indet(3)];<br />
-- G2 := [Indet(1)^(XYZMax+2), Indet(2)^(XYZMax+2), Indet(3)^(XYZMax+2)];<br />
----- axes<br />
String := String + "#declare AxisTags = union {" + NewLine();<br />
Line := "object {object AxisTag(""x"") translate <"<br />
+Sprint(XMax+3) + ",0,0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""y"") translate <0,"<br />
+Sprint(YMax+3) + ",0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""z"") translate <0,0.1,"<br />
+Sprint(ZMax+3) + "> }" + NewLine();<br />
String := String + Line;<br />
String := String + "}" + NewLine();<br />
----- Generators<br />
String := String + "#declare Generators = union {" + NewLine();<br />
ForEach G In GENS Do<br />
L := Log(G);<br />
Line := "union { object{Generator} ";<br />
String := String + Line;<br />
Line := "object Exponents(""" +<br />
+ Sprint(L[1]) + " " + Sprint(L[2]) + " " + Sprint(L[3])<br />
+ """) translate <"<br />
+Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
----- Monomials<br />
B := QuotientBasis(I+Ideal(G1)); <br />
String := String + "#declare Monomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- InftyMonomials<br />
B := Diff(QuotientBasis(I+Ideal(G2)), QuotientBasis(I+Ideal(G1)));<br />
String := String + "#declare InftyMonomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- <br />
Return String;<br />
EndDefine; -- QuotientBasisPOV<br />
<br />
/*<br />
-- EXAMPLE --<br />
Use Q[x,y,z];<br />
<br />
I := Ideal(x^10yz^6, x^7y^2z^3, xy^3z^4, x^3y^3z^3, xy^4z^4, y^6);<br />
F := OpenOFile("/Users/bigatti/Desktop/POV-Anna/monomials.inc", "w");<br />
PrintLn QuotientBasisPOV(I) On F;<br />
*/<br />
code by [[User:bigatti|bigatti]], 27 Jun 2005<br />
<br />
== POV-Ray Framework ==<br />
<br />
This is the file QuotientBasis.pov, the file including "monomials.inc". You should run it with [http://povray.com POV-Ray] with antialiasing on.<br />
<br />
// Copyright (c) 2005 Anna Bigatti<br />
// You are free to use any part of this example in your own programs.<br />
<br />
// ------------------------------<br />
#include "colors.inc"<br />
#include "functions.inc"<br />
#include "textures.inc"<br />
#include "metals.inc"<br />
#include "glass.inc"<br />
<br />
global_settings{<br />
max_trace_level 50<br />
adc_bailout 0.01<br />
}<br />
<br />
// ------------------------------<br />
// Set settings<br />
// ------------------------------<br />
#declare CamLoc=<500,500,-500>;<br />
#declare AspectRatio=4/3;<br />
<br />
light_source{<500,400,-200> color White*5}<br />
//plane{y,0 texture{pigment{rgbf <0.89, 0.98, 1.0, 0.95>}finish{F_Glass5}} hollow}<br />
<br />
<br />
//------------------------------<br />
// colours<br />
//------------------------------<br />
sky_sphere{ pigment{ color Gray90 } }<br />
<br />
#declare P_X = rgbf <0.04, 0.25, 0, 0>;<br />
#declare P_Y = rgbf <0.30, 0.35, 0, 0>;<br />
#declare P_Z = rgbf <0.05, 0.05, 0.4, 0>;<br />
#declare P_Cube = rgbf <0.01, 0.01, .3, 0>;<br />
#declare P_ClearCube = rgbf <0.4, 0.5, .6, .9>;<br />
#declare P_Exponent = rgbt <.2,1,.2,.0>;<br />
<br />
<br />
#declare Generator = sphere{0, .2 texture {T_Brass_2A} }<br />
<br />
#declare Axes = union {<br />
cylinder { <0, 0, 0>, <500, 0, 0>, 0.05 pigment {color P_X} }<br />
cylinder { <0, 0, 0>, <0, 500, 0>, 0.05 pigment {color P_Y} }<br />
cylinder { <0, 0, 0>, <0, 0, 500>, 0.05 pigment {color P_Z} }<br />
}<br />
<br />
// ------------------------------<br />
// creates the cube<br />
// ------------------------------<br />
#macro SolidCube()<br />
union{<br />
#declare sB=0.48;<br />
#declare rB=0.02;<br />
union{<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,-sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,-sB,0> pigment {color P_Z}}<br />
sphere{0,rB translate <sB,sB,sB>}<br />
sphere{0,rB translate <sB,sB,-sB>}<br />
sphere{0,rB translate <sB,-sB,sB>}<br />
sphere{0,rB translate <sB,-sB,-sB>}<br />
sphere{0,rB translate <-sB,sB,sB>}<br />
sphere{0,rB translate <-sB,sB,-sB>}<br />
sphere{0,rB translate <-sB,-sB,sB>}<br />
sphere{0,rB translate <-sB,-sB,-sB>}<br />
}<br />
<br />
box{-0.45,0.45 interior{ior 1.1} }<br />
<br />
translate <sB-rB, sB-rB, sB-rB><br />
}<br />
#end<br />
<br />
<br />
#macro Exponents(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp, <br />
.03, <br />
<-.1,0,0> <br />
scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
.7, 0, 0.4><br />
pigment {color P_Exponent}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
#macro AxisTag(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp,<br />
.03, <br />
<-.1,0,0> <br />
// scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
0, 0, 0.1><br />
pigment {color Gray20}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
// ------------------------------<br />
// scene<br />
// ------------------------------<br />
#include "monomials.inc" // place the cubes<br />
<br />
camera {<br />
location CamLoc<br />
direction z*CamZoom<br />
right x*AspectRatio<br />
look_at CamEye<br />
}<br />
<br />
union{<br />
object {Generators}<br />
object {Axes}<br />
object {AxisTags}<br />
object {Monomials texture{pigment{color P_Cube}}}<br />
object {InftyMonomials texture{pigment{color P_ClearCube}}}<br />
matrix <<br />
0, 0, -1,<br />
1, 0, 0,<br />
0, 1, 0,<br />
0, 0, 0<br />
><br />
<br />
}<br />
<br />
<br />
[[Category:CoCoA4]][[Category:HowTo]]</div>
130.251.167.207
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoA:HowTo:Plot_order_ideals&diff=94
CoCoA:HowTo:Plot order ideals
2005-06-27T12:35:17Z
<p>130.251.167.207: /* About */</p>
<hr />
<div>==About==<br />
<br />
At the [[SummerSchool05|CoCoA Summer School 2005]] there was a discussion about the possibility to plot order ideals.<br />
An order ideal is simply the complement of an ideal's leading term ideal, otherwise it could be described as a vector space basis <br />
of the quotient space P/I consisting of monomials (this is exactly the B in [[Macaulay's Basis Theorem]] with respect to the notation of Kreuzer's & Robbiano's book).<br />
<br />
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates. <br />
During the school, [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.<br />
<br />
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com POV-Ray] or Latex. <br />
The code uses CoCoA's [[QuotientBasis]] command, to get a list of all terms to draw and than draws this terms (or selects which of them should be drawn and which are invisible, in case of the latex pictures).<br />
<br />
<br />
The code to plot the order ideals is given in the next sections:<br />
<br />
== CoCoA & Latex Code (1. Version) ==<br />
<br />
Both functions (this and the next one) get as input a zero-dimensional ideal. The output is some text, containing the latex picture enviroment. simply render this to get a picture of your order ideal. You can even change the point of view<br />
of the model, by changing V1, V2, V3 and L1, L2, L3. How this exactly works can be figured out quite easily, having a look at a latex documentation for the picture enviroment.<br />
<br />
Define BorderTeX(I)<br />
String:='\begin{picture}(300,300)';<br />
<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1);<br />
V2 := Vector(0,1); <br />
V3 := Vector(1,0);<br />
L1 := 14;<br />
L2 := 20;<br />
L3 := 20;<br />
<br />
// get the Vectorspace-Basis of P/I:<br />
<br />
B := QuotientBasis(I);<br />
<br />
// check what to paint for what Basis Element:<br />
<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
<br />
EndForEach;<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & Latex Code (2. Version) ==<br />
<br />
I created another version, a little bit more sophisticated. It contains coordinate axis and scales the picture enviroment to the right size. The code for this is:<br />
<br />
Define Border(I)<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1); L1 := 14;<br />
V2 := Vector(0,1); L2 := 20;<br />
V3 := Vector(1,0); L3 := 20;<br />
<br />
Max1 := 0;<br />
Max2 := 0;<br />
Max3 := 0;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// get the Vectorspace-Basis of P/I: <br />
B := QuotientBasis(I);<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute picture's size:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
If L[1] > Max1 Then Max1 := L[1]; EndIf;<br />
If L[2] > Max2 Then Max2 := L[2]; EndIf;<br />
If L[3] > Max3 Then Max3 := L[3]; EndIf;<br />
EndForEach;<br />
<br />
Max1:= Max1 + 1; Max2 := Max2 +1; Max3 := Max3 +1;<br />
<br />
Width := Sum([ Abs(LC((Max1+3)*L1*V1[1])),Abs(LC((Max2+3)*L2*V2[1])),Abs(LC((Max3+3)*L3*V3[1])) ]);<br />
Height := Sum([ Abs(LC((Max1+3)*L1*V1[2])),Abs(LC((Max2+3)*L2*V2[2])),Abs(LC((Max3+3)*L3*V3[2])) ]);<br />
<br />
String:='\begin{picture}('+Sprint(Width)+','+Sprint(Height)+')';<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute Offset / (0,0,0):<br />
Offset:=Vector(Abs(Min([ LC((Max1+3)*L1*V1[1]),LC((Max2+3)*L2*V2[1]),LC((Max3+3)*L3*V3[1])])),<br />
Abs(Min([ LC((Max1+3)*L1*V1[2]),LC((Max2+3)*L2*V2[2]),LC((Max3+3)*L3*V3[2])])));<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
EndForEach;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Draw the three axis and the indeterminates names:<br />
<br />
Start := Offset + Max1 * V1 * L1;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V1[1])+','+Sprint(V1[2])+'){'+Sprint(2*L1)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L1*V1[1])+','+Sprint(Start[2]+3*L1*V1[2])+')<br />
{$\displaystyle ' +Sprint(Indet(1))+'$}';<br />
<br />
Start := Offset + Max2 * V2 * L2;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V2[1])+','+Sprint(V2[2])+'){'+Sprint(2*L2)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L2*V2[1])+','+Sprint(Start[2]+3*L2*V2[2])+')<br />
{$\displaystyle ' +Sprint(Indet(2))+'$}';<br />
<br />
Start := Offset + Max3 * V3 * L3;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V3[1])+','+Sprint(V3[2])+'){'+Sprint(2*L3)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L3*V3[1])+','+Sprint(Start[2]+3*L3*V3[2])+')<br />
{$\displaystyle ' +Sprint(Indet(3))+'$}';<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== Latex Framework ==<br />
<br />
As a framework where to copy&paste the output to, you can use the following latex code:<br />
<br />
\documentclass[12pt,a4paper]{article}<br />
<br />
\usepackage{umlaut,a4wide,amsmath,amssymb,stmaryrd,color,graphicx,fancyhdr,multicol}<br />
\usepackage[latin1]{inputenc}<br />
\setlength{\parindent}{0mm}<br />
<br />
\begin{document}<br />
<br />
% Copy output here!<br />
<br />
\end{document}<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & POV-Ray Code ==<br />
<br />
This function returns some [http://povray.com POV-Ray] code to plot the quotient ideal of the input ideal (not necessarily zero-dimensional).<br />
The output of QuotientBasisPOV should be saved into a file called "monomials.inc" (see the example below), in order to be included by QuotienBasis.pov:<br />
<br />
Define NewLine()<br />
Return "<br />
";<br />
EndDefine; -- NewLine<br />
<br />
Define QuotientBasisPOV(I)<br />
If NumIndets()<>3 Then Error("QuotientBasisPOV: ring must have 3 indeterminates"); EndIf;<br />
String := "";<br />
GENS := Interreduced(Gens(I));<br />
-----<br />
XMax := Max([Deg(T, Indet(1)) | T In GENS]);<br />
YMax := Max([Deg(T, Indet(2)) | T In GENS]);<br />
ZMax := Max([Deg(T, Indet(3)) | T In GENS]);<br />
XYZMax := Max(XMax, YMax, ZMax);<br />
-----<br />
String := String + "#declare CamZoom="<br />
+ Sprint(100/Isqrt(XYZMax)) +";"<br />
+ NewLine();<br />
String := String + "#declare CamEye=<0,"<br />
+ Sprint(ZMax/4) +",0>;"<br />
+ NewLine();<br />
<br />
-----<br />
G1 := [Indet(1)^(XMax+1), Indet(2)^(YMax+1), Indet(3)^(ZMax+1)];<br />
G2 := [G1[1]*Indet(1), G1[2]*Indet(2), G1[3]*Indet(3)];<br />
-- G2 := [Indet(1)^(XYZMax+2), Indet(2)^(XYZMax+2), Indet(3)^(XYZMax+2)];<br />
----- axes<br />
String := String + "#declare AxisTags = union {" + NewLine();<br />
Line := "object {object AxisTag(""x"") translate <"<br />
+Sprint(XMax+3) + ",0,0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""y"") translate <0,"<br />
+Sprint(YMax+3) + ",0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""z"") translate <0,0.1,"<br />
+Sprint(ZMax+3) + "> }" + NewLine();<br />
String := String + Line;<br />
String := String + "}" + NewLine();<br />
----- Generators<br />
String := String + "#declare Generators = union {" + NewLine();<br />
ForEach G In GENS Do<br />
L := Log(G);<br />
Line := "union { object{Generator} ";<br />
String := String + Line;<br />
Line := "object Exponents(""" +<br />
+ Sprint(L[1]) + " " + Sprint(L[2]) + " " + Sprint(L[3])<br />
+ """) translate <"<br />
+Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
----- Monomials<br />
B := QuotientBasis(I+Ideal(G1)); <br />
String := String + "#declare Monomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- InftyMonomials<br />
B := Diff(QuotientBasis(I+Ideal(G2)), QuotientBasis(I+Ideal(G1)));<br />
String := String + "#declare InftyMonomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- <br />
Return String;<br />
EndDefine; -- QuotientBasisPOV<br />
<br />
/*<br />
-- EXAMPLE --<br />
Use Q[x,y,z];<br />
<br />
I := Ideal(x^10yz^6, x^7y^2z^3, xy^3z^4, x^3y^3z^3, xy^4z^4, y^6);<br />
F := OpenOFile("/Users/bigatti/Desktop/POV-Anna/monomials.inc", "w");<br />
PrintLn QuotientBasisPOV(I) On F;<br />
*/<br />
<br />
== POV-Ray Framework ==<br />
<br />
This is the file QuotientBasis.pov, the file including "monomials.inc". You should run it with [http://povray.com POV-Ray] with antialiasing on.<br />
<br />
// Copyright (c) 2005 Anna Bigatti<br />
// You are free to use any part of this example in your own programs.<br />
<br />
// ------------------------------<br />
#include "colors.inc"<br />
#include "functions.inc"<br />
#include "textures.inc"<br />
#include "metals.inc"<br />
#include "glass.inc"<br />
<br />
global_settings{<br />
max_trace_level 50<br />
adc_bailout 0.01<br />
}<br />
<br />
// ------------------------------<br />
// Set settings<br />
// ------------------------------<br />
#declare CamLoc=<500,500,-500>;<br />
#declare AspectRatio=4/3;<br />
<br />
light_source{<500,400,-200> color White*5}<br />
//plane{y,0 texture{pigment{rgbf <0.89, 0.98, 1.0, 0.95>}finish{F_Glass5}} hollow}<br />
<br />
<br />
//------------------------------<br />
// colours<br />
//------------------------------<br />
sky_sphere{ pigment{ color Gray90 } }<br />
<br />
#declare P_X = rgbf <0.04, 0.25, 0, 0>;<br />
#declare P_Y = rgbf <0.30, 0.35, 0, 0>;<br />
#declare P_Z = rgbf <0.05, 0.05, 0.4, 0>;<br />
#declare P_Cube = rgbf <0.01, 0.01, .3, 0>;<br />
#declare P_ClearCube = rgbf <0.4, 0.5, .6, .9>;<br />
#declare P_Exponent = rgbt <.2,1,.2,.0>;<br />
<br />
<br />
#declare Generator = sphere{0, .2 texture {T_Brass_2A} }<br />
<br />
#declare Axes = union {<br />
cylinder { <0, 0, 0>, <500, 0, 0>, 0.05 pigment {color P_X} }<br />
cylinder { <0, 0, 0>, <0, 500, 0>, 0.05 pigment {color P_Y} }<br />
cylinder { <0, 0, 0>, <0, 0, 500>, 0.05 pigment {color P_Z} }<br />
}<br />
<br />
// ------------------------------<br />
// creates the cube<br />
// ------------------------------<br />
#macro SolidCube()<br />
union{<br />
#declare sB=0.48;<br />
#declare rB=0.02;<br />
union{<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,-sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,-sB,0> pigment {color P_Z}}<br />
sphere{0,rB translate <sB,sB,sB>}<br />
sphere{0,rB translate <sB,sB,-sB>}<br />
sphere{0,rB translate <sB,-sB,sB>}<br />
sphere{0,rB translate <sB,-sB,-sB>}<br />
sphere{0,rB translate <-sB,sB,sB>}<br />
sphere{0,rB translate <-sB,sB,-sB>}<br />
sphere{0,rB translate <-sB,-sB,sB>}<br />
sphere{0,rB translate <-sB,-sB,-sB>}<br />
}<br />
<br />
box{-0.45,0.45 interior{ior 1.1} }<br />
<br />
translate <sB-rB, sB-rB, sB-rB><br />
}<br />
#end<br />
<br />
<br />
#macro Exponents(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp, <br />
.03, <br />
<-.1,0,0> <br />
scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
.7, 0, 0.4><br />
pigment {color P_Exponent}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
#macro AxisTag(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp,<br />
.03, <br />
<-.1,0,0> <br />
// scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
0, 0, 0.1><br />
pigment {color Gray20}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
// ------------------------------<br />
// scene<br />
// ------------------------------<br />
#include "monomials.inc" // place the cubes<br />
<br />
camera {<br />
location CamLoc<br />
direction z*CamZoom<br />
right x*AspectRatio<br />
look_at CamEye<br />
}<br />
<br />
union{<br />
object {Generators}<br />
object {Axes}<br />
object {AxisTags}<br />
object {Monomials texture{pigment{color P_Cube}}}<br />
object {InftyMonomials texture{pigment{color P_ClearCube}}}<br />
matrix <<br />
0, 0, -1,<br />
1, 0, 0,<br />
0, 1, 0,<br />
0, 0, 0<br />
><br />
<br />
}<br />
<br />
<br />
[[Category:CoCoA4]][[Category:HowTo]]</div>
130.251.167.207
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoA:HowTo:Plot_order_ideals&diff=93
CoCoA:HowTo:Plot order ideals
2005-06-27T12:32:14Z
<p>130.251.167.207: /* CoCoA & POV-Ray Code */</p>
<hr />
<div>==About==<br />
<br />
At the [[SummerSchool05|CoCoA Summer School 2005]] there was a discussion about the possibility to plot order ideals.<br />
An order ideal is simply the complement of an ideal's leading term ideal, otherwise it could be described as a vector space basis <br />
of the quotient space P/I consisting of monomials (this is exactly the B in [[MacCaulys Basis Theorem]] with respect to the notation of Kreuzer's & Robbiano's book).<br />
<br />
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates. <br />
During the school, [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.<br />
<br />
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com Povray] or Latex. <br />
The code uses CoCoA's [[QuotientBasis]] command, to get a list of all terms to draw and than draws this terms (or selects which of them should be drawn and which are invisible, in case of the latex pictures).<br />
<br />
<br />
The code to plot the order ideals is given in the next sections:<br />
<br />
== CoCoA & Latex Code (1. Version) ==<br />
<br />
Both functions (this and the next one) get as input a zero-dimensional ideal. The output is some text, containing the latex picture enviroment. simply render this to get a picture of your order ideal. You can even change the point of view<br />
of the model, by changing V1, V2, V3 and L1, L2, L3. How this exactly works can be figured out quite easily, having a look at a latex documentation for the picture enviroment.<br />
<br />
Define BorderTeX(I)<br />
String:='\begin{picture}(300,300)';<br />
<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1);<br />
V2 := Vector(0,1); <br />
V3 := Vector(1,0);<br />
L1 := 14;<br />
L2 := 20;<br />
L3 := 20;<br />
<br />
// get the Vectorspace-Basis of P/I:<br />
<br />
B := QuotientBasis(I);<br />
<br />
// check what to paint for what Basis Element:<br />
<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
<br />
EndForEach;<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & Latex Code (2. Version) ==<br />
<br />
I created another version, a little bit more sophisticated. It contains coordinate axis and scales the picture enviroment to the right size. The code for this is:<br />
<br />
Define Border(I)<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1); L1 := 14;<br />
V2 := Vector(0,1); L2 := 20;<br />
V3 := Vector(1,0); L3 := 20;<br />
<br />
Max1 := 0;<br />
Max2 := 0;<br />
Max3 := 0;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// get the Vectorspace-Basis of P/I: <br />
B := QuotientBasis(I);<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute picture's size:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
If L[1] > Max1 Then Max1 := L[1]; EndIf;<br />
If L[2] > Max2 Then Max2 := L[2]; EndIf;<br />
If L[3] > Max3 Then Max3 := L[3]; EndIf;<br />
EndForEach;<br />
<br />
Max1:= Max1 + 1; Max2 := Max2 +1; Max3 := Max3 +1;<br />
<br />
Width := Sum([ Abs(LC((Max1+3)*L1*V1[1])),Abs(LC((Max2+3)*L2*V2[1])),Abs(LC((Max3+3)*L3*V3[1])) ]);<br />
Height := Sum([ Abs(LC((Max1+3)*L1*V1[2])),Abs(LC((Max2+3)*L2*V2[2])),Abs(LC((Max3+3)*L3*V3[2])) ]);<br />
<br />
String:='\begin{picture}('+Sprint(Width)+','+Sprint(Height)+')';<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute Offset / (0,0,0):<br />
Offset:=Vector(Abs(Min([ LC((Max1+3)*L1*V1[1]),LC((Max2+3)*L2*V2[1]),LC((Max3+3)*L3*V3[1])])),<br />
Abs(Min([ LC((Max1+3)*L1*V1[2]),LC((Max2+3)*L2*V2[2]),LC((Max3+3)*L3*V3[2])])));<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
EndForEach;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Draw the three axis and the indeterminates names:<br />
<br />
Start := Offset + Max1 * V1 * L1;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V1[1])+','+Sprint(V1[2])+'){'+Sprint(2*L1)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L1*V1[1])+','+Sprint(Start[2]+3*L1*V1[2])+')<br />
{$\displaystyle ' +Sprint(Indet(1))+'$}';<br />
<br />
Start := Offset + Max2 * V2 * L2;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V2[1])+','+Sprint(V2[2])+'){'+Sprint(2*L2)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L2*V2[1])+','+Sprint(Start[2]+3*L2*V2[2])+')<br />
{$\displaystyle ' +Sprint(Indet(2))+'$}';<br />
<br />
Start := Offset + Max3 * V3 * L3;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V3[1])+','+Sprint(V3[2])+'){'+Sprint(2*L3)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L3*V3[1])+','+Sprint(Start[2]+3*L3*V3[2])+')<br />
{$\displaystyle ' +Sprint(Indet(3))+'$}';<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== Latex Framework ==<br />
<br />
As a framework where to copy&paste the output to, you can use the following latex code:<br />
<br />
\documentclass[12pt,a4paper]{article}<br />
<br />
\usepackage{umlaut,a4wide,amsmath,amssymb,stmaryrd,color,graphicx,fancyhdr,multicol}<br />
\usepackage[latin1]{inputenc}<br />
\setlength{\parindent}{0mm}<br />
<br />
\begin{document}<br />
<br />
% Copy output here!<br />
<br />
\end{document}<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & POV-Ray Code ==<br />
<br />
This function returns some [http://povray.com POV-Ray] code to plot the quotient ideal of the input ideal (not necessarily zero-dimensional).<br />
The output of QuotientBasisPOV should be saved into a file called "monomials.inc" (see the example below), in order to be included by QuotienBasis.pov:<br />
<br />
Define NewLine()<br />
Return "<br />
";<br />
EndDefine; -- NewLine<br />
<br />
Define QuotientBasisPOV(I)<br />
If NumIndets()<>3 Then Error("QuotientBasisPOV: ring must have 3 indeterminates"); EndIf;<br />
String := "";<br />
GENS := Interreduced(Gens(I));<br />
-----<br />
XMax := Max([Deg(T, Indet(1)) | T In GENS]);<br />
YMax := Max([Deg(T, Indet(2)) | T In GENS]);<br />
ZMax := Max([Deg(T, Indet(3)) | T In GENS]);<br />
XYZMax := Max(XMax, YMax, ZMax);<br />
-----<br />
String := String + "#declare CamZoom="<br />
+ Sprint(100/Isqrt(XYZMax)) +";"<br />
+ NewLine();<br />
String := String + "#declare CamEye=<0,"<br />
+ Sprint(ZMax/4) +",0>;"<br />
+ NewLine();<br />
<br />
-----<br />
G1 := [Indet(1)^(XMax+1), Indet(2)^(YMax+1), Indet(3)^(ZMax+1)];<br />
G2 := [G1[1]*Indet(1), G1[2]*Indet(2), G1[3]*Indet(3)];<br />
-- G2 := [Indet(1)^(XYZMax+2), Indet(2)^(XYZMax+2), Indet(3)^(XYZMax+2)];<br />
----- axes<br />
String := String + "#declare AxisTags = union {" + NewLine();<br />
Line := "object {object AxisTag(""x"") translate <"<br />
+Sprint(XMax+3) + ",0,0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""y"") translate <0,"<br />
+Sprint(YMax+3) + ",0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""z"") translate <0,0.1,"<br />
+Sprint(ZMax+3) + "> }" + NewLine();<br />
String := String + Line;<br />
String := String + "}" + NewLine();<br />
----- Generators<br />
String := String + "#declare Generators = union {" + NewLine();<br />
ForEach G In GENS Do<br />
L := Log(G);<br />
Line := "union { object{Generator} ";<br />
String := String + Line;<br />
Line := "object Exponents(""" +<br />
+ Sprint(L[1]) + " " + Sprint(L[2]) + " " + Sprint(L[3])<br />
+ """) translate <"<br />
+Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
----- Monomials<br />
B := QuotientBasis(I+Ideal(G1)); <br />
String := String + "#declare Monomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- InftyMonomials<br />
B := Diff(QuotientBasis(I+Ideal(G2)), QuotientBasis(I+Ideal(G1)));<br />
String := String + "#declare InftyMonomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- <br />
Return String;<br />
EndDefine; -- QuotientBasisPOV<br />
<br />
/*<br />
-- EXAMPLE --<br />
Use Q[x,y,z];<br />
<br />
I := Ideal(x^10yz^6, x^7y^2z^3, xy^3z^4, x^3y^3z^3, xy^4z^4, y^6);<br />
F := OpenOFile("/Users/bigatti/Desktop/POV-Anna/monomials.inc", "w");<br />
PrintLn QuotientBasisPOV(I) On F;<br />
*/<br />
<br />
== POV-Ray Framework ==<br />
<br />
This is the file QuotientBasis.pov, the file including "monomials.inc". You should run it with [http://povray.com POV-Ray] with antialiasing on.<br />
<br />
// Copyright (c) 2005 Anna Bigatti<br />
// You are free to use any part of this example in your own programs.<br />
<br />
// ------------------------------<br />
#include "colors.inc"<br />
#include "functions.inc"<br />
#include "textures.inc"<br />
#include "metals.inc"<br />
#include "glass.inc"<br />
<br />
global_settings{<br />
max_trace_level 50<br />
adc_bailout 0.01<br />
}<br />
<br />
// ------------------------------<br />
// Set settings<br />
// ------------------------------<br />
#declare CamLoc=<500,500,-500>;<br />
#declare AspectRatio=4/3;<br />
<br />
light_source{<500,400,-200> color White*5}<br />
//plane{y,0 texture{pigment{rgbf <0.89, 0.98, 1.0, 0.95>}finish{F_Glass5}} hollow}<br />
<br />
<br />
//------------------------------<br />
// colours<br />
//------------------------------<br />
sky_sphere{ pigment{ color Gray90 } }<br />
<br />
#declare P_X = rgbf <0.04, 0.25, 0, 0>;<br />
#declare P_Y = rgbf <0.30, 0.35, 0, 0>;<br />
#declare P_Z = rgbf <0.05, 0.05, 0.4, 0>;<br />
#declare P_Cube = rgbf <0.01, 0.01, .3, 0>;<br />
#declare P_ClearCube = rgbf <0.4, 0.5, .6, .9>;<br />
#declare P_Exponent = rgbt <.2,1,.2,.0>;<br />
<br />
<br />
#declare Generator = sphere{0, .2 texture {T_Brass_2A} }<br />
<br />
#declare Axes = union {<br />
cylinder { <0, 0, 0>, <500, 0, 0>, 0.05 pigment {color P_X} }<br />
cylinder { <0, 0, 0>, <0, 500, 0>, 0.05 pigment {color P_Y} }<br />
cylinder { <0, 0, 0>, <0, 0, 500>, 0.05 pigment {color P_Z} }<br />
}<br />
<br />
// ------------------------------<br />
// creates the cube<br />
// ------------------------------<br />
#macro SolidCube()<br />
union{<br />
#declare sB=0.48;<br />
#declare rB=0.02;<br />
union{<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,-sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,-sB,0> pigment {color P_Z}}<br />
sphere{0,rB translate <sB,sB,sB>}<br />
sphere{0,rB translate <sB,sB,-sB>}<br />
sphere{0,rB translate <sB,-sB,sB>}<br />
sphere{0,rB translate <sB,-sB,-sB>}<br />
sphere{0,rB translate <-sB,sB,sB>}<br />
sphere{0,rB translate <-sB,sB,-sB>}<br />
sphere{0,rB translate <-sB,-sB,sB>}<br />
sphere{0,rB translate <-sB,-sB,-sB>}<br />
}<br />
<br />
box{-0.45,0.45 interior{ior 1.1} }<br />
<br />
translate <sB-rB, sB-rB, sB-rB><br />
}<br />
#end<br />
<br />
<br />
#macro Exponents(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp, <br />
.03, <br />
<-.1,0,0> <br />
scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
.7, 0, 0.4><br />
pigment {color P_Exponent}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
#macro AxisTag(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp,<br />
.03, <br />
<-.1,0,0> <br />
// scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
0, 0, 0.1><br />
pigment {color Gray20}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
// ------------------------------<br />
// scene<br />
// ------------------------------<br />
#include "monomials.inc" // place the cubes<br />
<br />
camera {<br />
location CamLoc<br />
direction z*CamZoom<br />
right x*AspectRatio<br />
look_at CamEye<br />
}<br />
<br />
union{<br />
object {Generators}<br />
object {Axes}<br />
object {AxisTags}<br />
object {Monomials texture{pigment{color P_Cube}}}<br />
object {InftyMonomials texture{pigment{color P_ClearCube}}}<br />
matrix <<br />
0, 0, -1,<br />
1, 0, 0,<br />
0, 1, 0,<br />
0, 0, 0<br />
><br />
<br />
}<br />
<br />
<br />
[[Category:CoCoA4]][[Category:HowTo]]</div>
130.251.167.207
http://apcocoa.uni-passau.de/wiki/index.php?title=CoCoA:HowTo:Plot_order_ideals&diff=92
CoCoA:HowTo:Plot order ideals
2005-06-27T12:31:10Z
<p>130.251.167.207: /* CoCoA & POV-Ray Code */</p>
<hr />
<div>==About==<br />
<br />
At the [[SummerSchool05|CoCoA Summer School 2005]] there was a discussion about the possibility to plot order ideals.<br />
An order ideal is simply the complement of an ideal's leading term ideal, otherwise it could be described as a vector space basis <br />
of the quotient space P/I consisting of monomials (this is exactly the B in [[MacCaulys Basis Theorem]] with respect to the notation of Kreuzer's & Robbiano's book).<br />
<br />
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates. <br />
During the school, [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.<br />
<br />
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com Povray] or Latex. <br />
The code uses CoCoA's [[QuotientBasis]] command, to get a list of all terms to draw and than draws this terms (or selects which of them should be drawn and which are invisible, in case of the latex pictures).<br />
<br />
<br />
The code to plot the order ideals is given in the next sections:<br />
<br />
== CoCoA & Latex Code (1. Version) ==<br />
<br />
Both functions (this and the next one) get as input a zero-dimensional ideal. The output is some text, containing the latex picture enviroment. simply render this to get a picture of your order ideal. You can even change the point of view<br />
of the model, by changing V1, V2, V3 and L1, L2, L3. How this exactly works can be figured out quite easily, having a look at a latex documentation for the picture enviroment.<br />
<br />
Define BorderTeX(I)<br />
String:='\begin{picture}(300,300)';<br />
<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1);<br />
V2 := Vector(0,1); <br />
V3 := Vector(1,0);<br />
L1 := 14;<br />
L2 := 20;<br />
L3 := 20;<br />
<br />
// get the Vectorspace-Basis of P/I:<br />
<br />
B := QuotientBasis(I);<br />
<br />
// check what to paint for what Basis Element:<br />
<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
<br />
EndForEach;<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & Latex Code (2. Version) ==<br />
<br />
I created another version, a little bit more sophisticated. It contains coordinate axis and scales the picture enviroment to the right size. The code for this is:<br />
<br />
Define Border(I)<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// define your coordinate system:<br />
Offset := Vector(150,150);<br />
V1 := Vector(-1,-1); L1 := 14;<br />
V2 := Vector(0,1); L2 := 20;<br />
V3 := Vector(1,0); L3 := 20;<br />
<br />
Max1 := 0;<br />
Max2 := 0;<br />
Max3 := 0;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// get the Vectorspace-Basis of P/I: <br />
B := QuotientBasis(I);<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute picture's size:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
If L[1] > Max1 Then Max1 := L[1]; EndIf;<br />
If L[2] > Max2 Then Max2 := L[2]; EndIf;<br />
If L[3] > Max3 Then Max3 := L[3]; EndIf;<br />
EndForEach;<br />
<br />
Max1:= Max1 + 1; Max2 := Max2 +1; Max3 := Max3 +1;<br />
<br />
Width := Sum([ Abs(LC((Max1+3)*L1*V1[1])),Abs(LC((Max2+3)*L2*V2[1])),Abs(LC((Max3+3)*L3*V3[1])) ]);<br />
Height := Sum([ Abs(LC((Max1+3)*L1*V1[2])),Abs(LC((Max2+3)*L2*V2[2])),Abs(LC((Max3+3)*L3*V3[2])) ]);<br />
<br />
String:='\begin{picture}('+Sprint(Width)+','+Sprint(Height)+')';<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Compute Offset / (0,0,0):<br />
Offset:=Vector(Abs(Min([ LC((Max1+3)*L1*V1[1]),LC((Max2+3)*L2*V2[1]),LC((Max3+3)*L3*V3[1])])),<br />
Abs(Min([ LC((Max1+3)*L1*V1[2]),LC((Max2+3)*L2*V2[2]),LC((Max3+3)*L3*V3[2])])));<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Check for all Elements in Basis what to draw:<br />
ForEach El_B In B Do<br />
L := Log(El_B); <br />
Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;<br />
<br />
If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then<br />
Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';<br />
String := String + Line;<br />
EndIf; <br />
EndForEach;<br />
<br />
//////////////////////////////////////////////////////////////////////////////<br />
// Draw the three axis and the indeterminates names:<br />
<br />
Start := Offset + Max1 * V1 * L1;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V1[1])+','+Sprint(V1[2])+'){'+Sprint(2*L1)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L1*V1[1])+','+Sprint(Start[2]+3*L1*V1[2])+')<br />
{$\displaystyle ' +Sprint(Indet(1))+'$}';<br />
<br />
Start := Offset + Max2 * V2 * L2;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V2[1])+','+Sprint(V2[2])+'){'+Sprint(2*L2)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L2*V2[1])+','+Sprint(Start[2]+3*L2*V2[2])+')<br />
{$\displaystyle ' +Sprint(Indet(2))+'$}';<br />
<br />
Start := Offset + Max3 * V3 * L3;<br />
String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')<br />
{\vector('+Sprint(V3[1])+','+Sprint(V3[2])+'){'+Sprint(2*L3)+'}}';<br />
<br />
String := String + '\put('+Sprint(Start[1]+3*L3*V3[1])+','+Sprint(Start[2]+3*L3*V3[2])+')<br />
{$\displaystyle ' +Sprint(Indet(3))+'$}';<br />
<br />
Return String+'\end{picture}';<br />
EndDefine;<br />
<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== Latex Framework ==<br />
<br />
As a framework where to copy&paste the output to, you can use the following latex code:<br />
<br />
\documentclass[12pt,a4paper]{article}<br />
<br />
\usepackage{umlaut,a4wide,amsmath,amssymb,stmaryrd,color,graphicx,fancyhdr,multicol}<br />
\usepackage[latin1]{inputenc}<br />
\setlength{\parindent}{0mm}<br />
<br />
\begin{document}<br />
<br />
% Copy output here!<br />
<br />
\end{document}<br />
code by [[User:Dheldt|dheldt]] 08:37, 22 Jun 2005 (CEST)<br />
<br />
== CoCoA & POV-Ray Code ==<br />
<br />
This function returns some [http://povray.com POV-Ray] code to plot the quotient ideal of the input ideal (not necessarily zero-dimensional).<br />
The output of QuotientBasisPOV should be saved into a file called "monomials.inc" (see the example below), in order to be included by QuotienBasis.pov:<br />
<br />
Define NewLine()<br />
Return "<br />
";<br />
EndDefine; -- NewLine<br />
<br />
Define QuotientBasisPOV(I)<br />
If NumIndets()<>3 Then Error("QuotientBasisPOV: ring must have 3 indeterminates"); EndIf;<br />
String := "";<br />
GENS := Interreduced(Gens(I));<br />
-----<br />
XMax := Max([Deg(T, Indet(1)) | T In GENS]);<br />
YMax := Max([Deg(T, Indet(2)) | T In GENS]);<br />
ZMax := Max([Deg(T, Indet(3)) | T In GENS]);<br />
XYZMax := Max(XMax, YMax, ZMax);<br />
-----<br />
String := String + "#declare CamZoom="<br />
+ Sprint(100/Isqrt(XYZMax)) +";"<br />
+ NewLine();<br />
String := String + "#declare CamEye=<0,"<br />
+ Sprint(ZMax/4) +",0>;"<br />
+ NewLine();<br />
<br />
-----<br />
G1 := [Indet(1)^(XMax+1), Indet(2)^(YMax+1), Indet(3)^(ZMax+1)];<br />
G2 := [G1[1]*Indet(1), G1[2]*Indet(2), G1[3]*Indet(3)];<br />
-- G2 := [Indet(1)^(XYZMax+2), Indet(2)^(XYZMax+2), Indet(3)^(XYZMax+2)];<br />
----- axes<br />
String := String + "#declare AxisTags = union {" + NewLine();<br />
Line := "object {object AxisTag(""x"") translate <"<br />
+Sprint(XMax+3) + ",0,0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""y"") translate <0,"<br />
+Sprint(YMax+3) + ",0.1> }" + NewLine();<br />
String := String + Line;<br />
Line := "object {object AxisTag(""z"") translate <0,0.1,"<br />
+Sprint(ZMax+3) + "> }" + NewLine();<br />
String := String + Line;<br />
String := String + "}" + NewLine();<br />
----- Generators<br />
String := String + "#declare Generators = union {" + NewLine();<br />
ForEach G In GENS Do<br />
L := Log(G);<br />
Line := "union { object{Generator} ";<br />
String := String + Line;<br />
Line := "object Exponents(""" +<br />
+ Sprint(L[1]) + " " + Sprint(L[2]) + " " + Sprint(L[3])<br />
+ """) translate <"<br />
+Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
----- Monomials<br />
B := QuotientBasis(I+Ideal(G1)); <br />
String := String + "#declare Monomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- InftyMonomials<br />
B := Diff(QuotientBasis(I+Ideal(G2)), QuotientBasis(I+Ideal(G1)));<br />
String := String + "#declare InftyMonomials = union {" + NewLine();<br />
ForEach El_B In B Do<br />
L := Log(El_B);<br />
Line := "object{ SolidCube() translate <"+<br />
Sprint(L[1]) + "," + Sprint(L[2]) + "," + Sprint(L[3])<br />
+"> }" + NewLine();<br />
String := String + Line;<br />
EndForEach;<br />
String := String + "}" + NewLine();<br />
---- <br />
Return String;<br />
EndDefine; -- QuotientBasisPOV<br />
<br />
/*<br />
-- EXAMPLE --<br />
Use Q[x,y,z];<br />
<br />
I := Ideal(x^10yz^6, x^7y^2z^3, xy^3z^4, x^3y^3z^3, xy^4z^4, y^6);<br />
F := OpenOFile("/Users/bigatti/Desktop/POV-Anna/monomials.inc", "w");<br />
PrintLn QuotientBasisPOV(I) On F;<br />
*/<br />
<br />
This is the file QuotientBasis.pov, the file including "monomials.inc". You should run it with [http://povray.com POV-Ray] with antialiasing on.<br />
<br />
// Copyright (c) 2005 Anna Bigatti<br />
// You are free to use any part of this example in your own programs.<br />
<br />
// ------------------------------<br />
#include "colors.inc"<br />
#include "functions.inc"<br />
#include "textures.inc"<br />
#include "metals.inc"<br />
#include "glass.inc"<br />
<br />
global_settings{<br />
max_trace_level 50<br />
adc_bailout 0.01<br />
}<br />
<br />
// ------------------------------<br />
// Set settings<br />
// ------------------------------<br />
#declare CamLoc=<500,500,-500>;<br />
#declare AspectRatio=4/3;<br />
<br />
light_source{<500,400,-200> color White*5}<br />
//plane{y,0 texture{pigment{rgbf <0.89, 0.98, 1.0, 0.95>}finish{F_Glass5}} hollow}<br />
<br />
<br />
//------------------------------<br />
// colours<br />
//------------------------------<br />
sky_sphere{ pigment{ color Gray90 } }<br />
<br />
#declare P_X = rgbf <0.04, 0.25, 0, 0>;<br />
#declare P_Y = rgbf <0.30, 0.35, 0, 0>;<br />
#declare P_Z = rgbf <0.05, 0.05, 0.4, 0>;<br />
#declare P_Cube = rgbf <0.01, 0.01, .3, 0>;<br />
#declare P_ClearCube = rgbf <0.4, 0.5, .6, .9>;<br />
#declare P_Exponent = rgbt <.2,1,.2,.0>;<br />
<br />
<br />
#declare Generator = sphere{0, .2 texture {T_Brass_2A} }<br />
<br />
#declare Axes = union {<br />
cylinder { <0, 0, 0>, <500, 0, 0>, 0.05 pigment {color P_X} }<br />
cylinder { <0, 0, 0>, <0, 500, 0>, 0.05 pigment {color P_Y} }<br />
cylinder { <0, 0, 0>, <0, 0, 500>, 0.05 pigment {color P_Z} }<br />
}<br />
<br />
// ------------------------------<br />
// creates the cube<br />
// ------------------------------<br />
#macro SolidCube()<br />
union{<br />
#declare sB=0.48;<br />
#declare rB=0.02;<br />
union{<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*x,sB*x,rB translate <0,-sB,-sB> pigment {color P_X}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,sB> pigment {color P_Y}}<br />
cylinder{-sB*y,sB*y,rB translate <-sB,0,-sB> pigment {color P_Y}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <sB,-sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,sB,0> pigment {color P_Z}}<br />
cylinder{-sB*z,sB*z,rB translate <-sB,-sB,0> pigment {color P_Z}}<br />
sphere{0,rB translate <sB,sB,sB>}<br />
sphere{0,rB translate <sB,sB,-sB>}<br />
sphere{0,rB translate <sB,-sB,sB>}<br />
sphere{0,rB translate <sB,-sB,-sB>}<br />
sphere{0,rB translate <-sB,sB,sB>}<br />
sphere{0,rB translate <-sB,sB,-sB>}<br />
sphere{0,rB translate <-sB,-sB,sB>}<br />
sphere{0,rB translate <-sB,-sB,-sB>}<br />
}<br />
<br />
box{-0.45,0.45 interior{ior 1.1} }<br />
<br />
translate <sB-rB, sB-rB, sB-rB><br />
}<br />
#end<br />
<br />
<br />
#macro Exponents(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp, <br />
.03, <br />
<-.1,0,0> <br />
scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
.7, 0, 0.4><br />
pigment {color P_Exponent}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
#macro AxisTag(Exp)<br />
{text { <br />
ttf "crystal.ttf", <br />
Exp,<br />
.03, <br />
<-.1,0,0> <br />
// scale < .7, .7,.7> <br />
matrix <<br />
0, 1, 0.7,<br />
0, 0, 0.7,<br />
1, 0, 0,<br />
0, 0, 0.1><br />
pigment {color Gray20}<br />
no_reflection<br />
no_shadow<br />
}} <br />
#end<br />
<br />
// ------------------------------<br />
// scene<br />
// ------------------------------<br />
#include "monomials.inc" // place the cubes<br />
<br />
camera {<br />
location CamLoc<br />
direction z*CamZoom<br />
right x*AspectRatio<br />
look_at CamEye<br />
}<br />
<br />
union{<br />
object {Generators}<br />
object {Axes}<br />
object {AxisTags}<br />
object {Monomials texture{pigment{color P_Cube}}}<br />
object {InftyMonomials texture{pigment{color P_ClearCube}}}<br />
matrix <<br />
0, 0, -1,<br />
1, 0, 0,<br />
0, 1, 0,<br />
0, 0, 0<br />
><br />
<br />
}<br />
<br />
<br />
[[Category:CoCoA4]][[Category:HowTo]]</div>
130.251.167.207