Goto Chapter: Top 1 2 3 4 5 6 Bib Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 The IntPic package main function
 2.1 The main function
 2.2 Producing tables

2 The IntPic package main function

This chapter consists of two sections, the first of which decribes the main function of the package. The second one can be thought just as an example to produce a table where the integers appear ordered in a non standard way.

2.1 The main function

The function IP_TikzArrayOfIntegers (2.1-1) is the main function of the IntPic package. It aims to produce tikz code for displaying arrays of integers.

2.1-1 Tikz code for arrays of integers
‣ IP_TikzArrayOfIntegers( arg )( function )

The arguments (at most 3) are:

  1. (optional)

  2. a record of options. One of the fields of this record, named highlights, is an array whose entries are the numbers to be highlighted: one color per sublist. See details and other options in ChapterĀ 5.

When no list nor table is present, the smallest range containing all the integers to be highlighted is taken.

gap> rg := [81..89];;
gap> len := 10;;
gap> arr := [Filtered(rg,IsPrime),Filtered(rg,u->(u mod 2)=0),
>         Filtered(rg,u->(u mod 3)=0)];;
gap> tkz := IP_TikzArrayOfIntegers(rg,len,rec(highlights:=arr));;

The aspect of the string tkz produced is not very appealing. We show it once, by asking it exlicitly in the next example. In the forthcomming examples we keep using two semicolons to avoid showing this kind of strings.

gap> tkz;
"%tikz\n\\begin{tikzpicture}[every node/.style={draw,scale=1pt,\nminimum width\
=20pt,inner sep=3pt,\nline width=1pt,draw=black}]\n\\matrix[row sep=2pt,column\
d]{82};&\n\\node[fill=red]{83};&\n\\node[left color=-red,right color=green]{84\

This string can be used at the users wish. In particular, it can be sent to the standard output using the command Print (Reference: Print).

gap> Print(tkz);
\begin{tikzpicture}[every node/.style={draw,scale=1pt,
minimum width=20pt,inner sep=3pt,
line width=1pt,draw=black}]
\matrix[row sep=2pt,column sep=2pt]
\node[left color=-red,right color=green]{84};&

It can now be copied and pasted in a LaTeX document (having the appropriate packages in the preamble). See Chapter 4 for details and alternatives.

The next function uses the previous one, but is called with a simpler argument. It will hopefully be useful for simple drawings. The length of each row and the umber of columns varies. A compromise based on some experiments has been established in order to obtain not too large nor too high images.

2.1-2 Tikz code for arrays, in a simplified way
‣ IP_SimpleTikzArrayOfIntegers( arg )( function )

The argument is either a list of integers or a matrix of integers. The integers involved are embeded in a range rg of minimum length and highlighted by using the list of default colors.

gap> d := DivisorsInt(30);
[ 1, 2, 3, 5, 6, 10, 15, 30 ]
gap> IP_SimpleTikzArrayOfIntegers(d);;

gap> d30 := DivisorsInt(30);
[ 1, 2, 3, 5, 6, 10, 15, 30 ]
gap> d40 := DivisorsInt(40);
[ 1, 2, 4, 5, 8, 10, 20, 40 ]
gap> tkz := IP_SimpleTikzArrayOfIntegers([d30,d40]);;

2.2 Producing tables

When the user is interested in tables of a certain kind, it may be a good idea to write some code to produce these tables. The following function (whose code is part of the file in the gap folder of this package) is convenient to deal with numerical semigroups with two generators and has been used to produce the images contained in [DFGSL14].

2.2-1 IP_TableWithModularOrder
‣ IP_TableWithModularOrder( o, a, b, depth, height, rep, pos )( function )

The arguments rep and pos are booleans (true or false). When rep is true there is some repetition: the last column is equal to the first, but pushed down some rows. When pos is true, no rows below 0 are considered, (contradicting depth, if needed).

The first five arguments arguments o, a, b,depth and height are integers. What they represent is described in what follows. There is assigned some kind of a referential on the constructed table and the fist argument, o, stands for the origin. A table with b columns (b+1 columns when rep is true) is constructed as follows. The row containing the origin is

The remaining rows are obtained by adding b (the upper ones) or subtracting b (the others) to these rows.

Note: when a < b are co-prime, this construction provides a representation of the integers as an array.

gap> a := 8;; b := 19;;  
gap> ns := NumericalSemigroup(a,b);;
gap> c := ConductorOfNumericalSemigroup(ns);;
gap> origin := 2*c-1;
gap> ground := [origin..origin+b-1];;
gap> height:=2;;
gap> depth:=8;;
gap>   xaxis := [origin];;
gap>   for n in [1..b-1] do
>     Add(xaxis, origin+n*a);
>   od;
gap>   yaxis := [];;
gap>   for n in [-depth..height] do
>     Add(yaxis, origin+n*b);
>   od;
gap> table := IP_TableWithModularOrder(origin,a,b,depth,height,false,false);;
gap> arr := [xaxis,yaxis,ground];
[ [ 251, 259, 267, 275, 283, 291, 299, 307, 315, 323, 331, 339, 347, 355, 
      363, 371, 379, 387, 395 ], 
  [ 99, 118, 137, 156, 175, 194, 213, 232, 251, 270, 289 ], [ 251 .. 269 ] ]
gap> tkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr));;

The next picture is obtained in the same way. The information that only the shape has interest is given by including the option shape_only:=" ". The variable tkz should be defined in a similar manner to the following one.

gap> tkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr,shape_only:=" ",
>              cell_width := "6",colsep:="1",rowsep:="1",inner_sep:="2",
>              line_color:="black!20"));;

Next, a minimum of changes, just to illustrate the effect of rep and pos.

gap> table := IP_TableWithModularOrder(origin,a,b,depth,50,true,true);;
gap> tkz:=IP_TikzArrayOfIntegers(table,rec(highlights:=arr));;

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 Bib Ind

generated by GAPDoc2HTML