Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X2 [33X[0;0YThe [5XIntPic[105X[101X[1X package main function[133X[101X23[33X[0;0YThis chapter consists of two sections, the first of which decribes the main4function of the package. The second one can be thought just as an example to5produce a table where the integers appear ordered in a non standard way.[133X678[1X2.1 [33X[0;0YThe main function[133X[101X910[33X[0;0YThe function [2XIP_TikzArrayOfIntegers[102X ([14X2.1-1[114X) is the main function of the11[5XIntPic[105X package. It aims to produce [10Xtikz[110X code for displaying arrays of12integers.[133X131415[1X2.1-1 [33X[0;0YTikz code for arrays of integers[133X[101X1617[29X[2XIP_TikzArrayOfIntegers[102X( [3Xarg[103X ) [32X function1819[33X[0;0YThe arguments (at most 3) are:[133X2021[31X1[131X [33X[0;6Y(optional)[133X2223[30X [33X[0;12Ya table of integers. In this case, the length of the rows is the24maximum of the lengths of the sublists in the table, [13Xor[113X[133X2526[30X [33X[0;12Ya list of integers and, optionally, an integer which indicates27the length of the rows; when the length of the rows is not28indicated, a compromise between the width and the height is29tried.[133X3031[31X2[131X [33X[0;6Ya record of options. One of the fields of this record, named32[10Xhighlights[110X, is an array whose entries are the numbers to be33highlighted: one color per sublist. See details and other options in34ChapterĀ [14X5[114X.[133X3536[33X[0;0YWhen no list nor table is present, the smallest range containing all the37integers to be highlighted is taken.[133X3839[4X[32X Example [32X[104X40[4X[25Xgap>[125X [27Xrg := [81..89];;[127X[104X41[4X[25Xgap>[125X [27Xlen := 10;;[127X[104X42[4X[25Xgap>[125X [27Xarr := [Filtered(rg,IsPrime),Filtered(rg,u->(u mod 2)=0),[127X[104X43[4X[25X>[125X [27X Filtered(rg,u->(u mod 3)=0)];;[127X[104X44[4X[25Xgap>[125X [27Xtkz := IP_TikzArrayOfIntegers(rg,len,rec(highlights:=arr));;[127X[104X45[4X[32X[104X4647[33X[0;0YThe aspect of the string [3Xtkz[103X produced is not very appealing. We show it48once, by asking it exlicitly in the next example. In the forthcomming49examples we keep using two semicolons to avoid showing this kind of strings.[133X5051[4X[32X The tkz string [32X[104X52[4Xgap> tkz;[104X53[4X"%tikz\n\\begin{tikzpicture}[every node/.style={draw,scale=1pt,\nminimum width\[104X54[4X=20pt,inner sep=3pt,\nline width=1pt,draw=black}]\n\\matrix[row sep=2pt,column\[104X55[4X sep=2pt]\n{\\node[fill=-red]{86};&\n\\node[fill=green]{87};&\n\\node[fill=-re\[104X56[4Xd]{88};&\n\\node[fill=red]{89};\\\\\n\\node[fill=green]{81};&\n\\node[fill=-re\[104X57[4Xd]{82};&\n\\node[fill=red]{83};&\n\\node[left color=-red,right color=green]{84\[104X58[4X};&\n\\node[]{85};\\\\\n};\n\\end{tikzpicture}\n"[104X59[4X[32X[104X6061[33X[0;0YThis string can be used at the users wish. In particular, it can be sent to62the standard output using the command [2XPrint[102X ([14XReference: Print[114X).[133X6364[4X[32X The tikz code [32X[104X65[4Xgap> Print(tkz);[104X66[4X%tikz[104X67[4X\begin{tikzpicture}[every node/.style={draw,scale=1pt,[104X68[4Xminimum width=20pt,inner sep=3pt,[104X69[4Xline width=1pt,draw=black}][104X70[4X\matrix[row sep=2pt,column sep=2pt][104X71[4X{\node[fill=-red]{86};&[104X72[4X\node[fill=green]{87};&[104X73[4X\node[fill=-red]{88};&[104X74[4X\node[fill=red]{89};\\[104X75[4X\node[fill=green]{81};&[104X76[4X\node[fill=-red]{82};&[104X77[4X\node[fill=red]{83};&[104X78[4X\node[left color=-red,right color=green]{84};&[104X79[4X\node[]{85};\\[104X80[4X};[104X81[4X\end{tikzpicture}[104X82[4X[32X[104X8384[33X[0;0YIt can now be copied and pasted in a LaTeX document (having the appropriate85packages in the preamble). See Chapter [14X4[114X for details and alternatives.[133X8687[33X[0;0YThe next function uses the previous one, but is called with a simpler88argument. It will hopefully be useful for simple drawings. The length of89each row and the umber of columns varies. A compromise based on some90experiments has been established in order to obtain not too large nor too91high images.[133X929394[1X2.1-2 [33X[0;0YTikz code for arrays, in a simplified way[133X[101X9596[29X[2XIP_SimpleTikzArrayOfIntegers[102X( [3Xarg[103X ) [32X function9798[33X[0;0YThe argument is either a list of integers or a matrix of integers. The99integers involved are embeded in a range [3Xrg[103X of minimum length and100highlighted by using the list of default colors.[133X101102[4X[32X Example [32X[104X103[4X[25Xgap>[125X [27Xd := DivisorsInt(30);[127X[104X104[4X[28X[ 1, 2, 3, 5, 6, 10, 15, 30 ][128X[104X105[4X[25Xgap>[125X [27XIP_SimpleTikzArrayOfIntegers(d);;[127X[104X106[4X[32X[104X107108[4X[32X Example [32X[104X109[4X[25Xgap>[125X [27Xd30 := DivisorsInt(30);[127X[104X110[4X[28X[ 1, 2, 3, 5, 6, 10, 15, 30 ][128X[104X111[4X[25Xgap>[125X [27Xd40 := DivisorsInt(40);[127X[104X112[4X[28X[ 1, 2, 4, 5, 8, 10, 20, 40 ][128X[104X113[4X[25Xgap>[125X [27Xtkz := IP_SimpleTikzArrayOfIntegers([d30,d40]);;[127X[104X114[4X[32X[104X115116117[1X2.2 [33X[0;0YProducing tables[133X[101X118119[33X[0;0YWhen the user is interested in tables of a certain kind, it may be a good120idea to write some code to produce these tables. The following function121(whose code is part of the file [13Xip_tables.gi[113X in the [13Xgap[113X folder of this122package) is convenient to deal with numerical semigroups with two generators123and has been used to produce the images contained in [DFGSL14].[133X124125[1X2.2-1 IP_TableWithModularOrder[101X126127[29X[2XIP_TableWithModularOrder[102X( [3Xo[103X, [3Xa[103X, [3Xb[103X, [3Xdepth[103X, [3Xheight[103X, [3Xrep[103X, [3Xpos[103X ) [32X function128129[33X[0;0YThe arguments [3Xrep[103X and [3Xpos[103X are booleans ([10Xtrue[110X or [10Xfalse[110X). When [3Xrep[103X is [10Xtrue[110X130there is some repetition: the last column is equal to the first, but pushed131down some rows. When [3Xpos[103X is [10Xtrue[110X, no rows below 0 are considered,132(contradicting [3Xdepth[103X, if needed).[133X133134[33X[0;0YThe first five arguments arguments [3Xo, a, b,depth[103X and [3Xheight[103X are integers.135What they represent is described in what follows. There is assigned some136kind of a referential on the constructed table and the fist argument, [3Xo[103X,137stands for the origin. A table with [3Xb[103X columns ([22X[3Xb[103X+1[122X columns when [3Xrep[103X is [10Xtrue[110X)138is constructed as follows. The row containing the origin is[133X139140[30X [33X[0;6Y[22X[3Xo[103X+ [0..[3Xb[103X-1]*[3Xa[103X[122X, if [3Xrep[103X is [10Xfalse[110X, [13Xor[113X[133X141142[30X [33X[0;6Y[22X[3Xo[103X+ [0..[3Xb[103X]*[3Xa[103X[122X, if [3Xrep[103X is [10Xtrue[110X[133X143144[33X[0;0YThe remaining rows are obtained by adding [3Xb[103X (the upper ones) or subtracting145[3Xb[103X (the others) to these rows.[133X146147[33X[0;0YNote: when [22X[3Xa[103X < [3Xb[103X[122X are co-prime, this construction provides a representation148of the integers as an array.[133X149150[4X[32X Example [32X[104X151[4X[25Xgap>[125X [27Xa := 8;; b := 19;; [127X[104X152[4X[25Xgap>[125X [27Xns := NumericalSemigroup(a,b);;[127X[104X153[4X[25Xgap>[125X [27Xc := ConductorOfNumericalSemigroup(ns);;[127X[104X154[4X[25Xgap>[125X [27Xorigin := 2*c-1;[127X[104X155[4X[28X251[128X[104X156[4X[25Xgap>[125X [27Xground := [origin..origin+b-1];;[127X[104X157[4X[25Xgap>[125X [27X[127X[104X158[4X[25Xgap>[125X [27Xheight:=2;;[127X[104X159[4X[25Xgap>[125X [27Xdepth:=8;;[127X[104X160[4X[25Xgap>[125X [27X xaxis := [origin];;[127X[104X161[4X[25Xgap>[125X [27X for n in [1..b-1] do[127X[104X162[4X[25X>[125X [27X Add(xaxis, origin+n*a);[127X[104X163[4X[25X>[125X [27X od;[127X[104X164[4X[25Xgap>[125X [27X yaxis := [];;[127X[104X165[4X[25Xgap>[125X [27X for n in [-depth..height] do[127X[104X166[4X[25X>[125X [27X Add(yaxis, origin+n*b);[127X[104X167[4X[25X>[125X [27X od;[127X[104X168[4X[25Xgap>[125X [27X[127X[104X169[4X[25Xgap>[125X [27Xtable := IP_TableWithModularOrder(origin,a,b,depth,height,false,false);;[127X[104X170[4X[25Xgap>[125X [27Xarr := [xaxis,yaxis,ground];[127X[104X171[4X[28X[ [ 251, 259, 267, 275, 283, 291, 299, 307, 315, 323, 331, 339, 347, 355, [128X[104X172[4X[28X 363, 371, 379, 387, 395 ], [128X[104X173[4X[28X [ 99, 118, 137, 156, 175, 194, 213, 232, 251, 270, 289 ], [ 251 .. 269 ] ][128X[104X174[4X[25Xgap>[125X [27Xtkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr));;[127X[104X175[4X[32X[104X176177[33X[0;0YThe next picture is obtained in the same way. The information that only the178shape has interest is given by including the option [10Xshape_only:=" "[110X. The179variable [10Xtkz[110X should be defined in a similar manner to the following one.[133X180181[4X[32X Example [32X[104X182[4X[25Xgap>[125X [27Xtkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr,shape_only:=" ",[127X[104X183[4X[25X>[125X [27X cell_width := "6",colsep:="1",rowsep:="1",inner_sep:="2",[127X[104X184[4X[25X>[125X [27X line_color:="black!20"));;[127X[104X185[4X[32X[104X186187[33X[0;0YNext, a minimum of changes, just to illustrate the effect of [3Xrep[103X and [3Xpos[103X.[133X188189[4X[32X Example [32X[104X190[4X[25Xgap>[125X [27Xtable := IP_TableWithModularOrder(origin,a,b,depth,50,true,true);;[127X[104X191[4X[25Xgap>[125X [27Xtkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr));;[127X[104X192[4X[32X[104X193194195196