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: 418346<Chapter Label="Examples">1<Heading>Examples of &SCSCP; usage</Heading>23In this chapter we are going to demonstrate some examples of communication4between client and server using the SCSCP.56<Section Label="ProvidingServices">7<Heading>Providing services with the SCSCP package</Heading>89You can try to run the SCSCP server with the configuration file10<File>scscp/example/myserver.g</File>. To do this, go to that directory11and enter <C>gap myserver.g</C>. After this you will see some information12messages and finally the server will start to wait for the connection. The13final part of the startup screen may look as follows:1415<Log>16<![CDATA[17#I Installed SCSCP procedure Factorial18#I Installed SCSCP procedure WS_Factorial19#I Installed SCSCP procedure GroupIdentificationService20#I Installed SCSCP procedure IdGroup512ByCode21#I Installed SCSCP procedure WS_IdGroup22#I Installed SCSCP procedure WS_Karatsuba23#I Installed SCSCP procedure EvaluateOpenMathCode24#I Ready to accept TCP/IP connections at localhost:26133 ...25#I Waiting for new client connection at localhost:26133 ...26]]>27</Log>2829See further self-explanatory comments in the file30<File>scscp/example/myserver.g</File>.31There also some test files in the directory <File>scscp/tst/</File>32supplied with detailed comments. First, you may use demonstration33files, preliminary turning on the demonstration mode as it is34explained in these files, or just executing step by step each command35from <File>scscp/tst/demo.g</File> and <File>scscp/tst/omdemo.g</File>.36Then you can try to use files <File>scscp/tst/id512.g</File>,37<File>scscp/tst/idperm.g</File> and <File>scscp/tst/factor.g</File>38for further tests of &SCSCP; services.39</Section>4041<Section Label="Id512">42<Heading>Identifying groups of order 512</Heading>4344We will give an example guiding you through all steps45of creation of your own &SCSCP; service.46<P/>4748The &GAP; Small Group Library does not provide identification for49groups of order 512 using the function <C>IdGroup</C>:5051<Log>52<![CDATA[53gap> IdGroup( DihedralGroup( 256 ) );54[ 256, 539 ]55gap> IdGroup(DihedralGroup(512));56Error, the group identification for groups of size 512 is not available57called from58<function "unknown">( <arguments> )59called from read-eval loop at line 71 of *stdin*60you can 'quit;' to quit to outer loop, or61you can 'return;' to continue62brk>63]]>64</Log>6566However, the &GAP; package &ANUPQ; <Cite Key="ANUPQ"/> has a function67<C>IdStandardPresented512Group</C> that does this work as demonstrated68below:6970<Example>71<![CDATA[72gap> LoadPackage("anupq");73---------------------------------------------------------------------------74Loading ANUPQ (ANU p-Quotient) 3.1.475GAP code by Greg Gamble <[email protected]> (address for correspondence)76Werner Nickel (http://www.mathematik.tu-darmstadt.de/~nickel/)77[uses ANU pq binary (C code program) version: 1.9]78C code by Eamonn O'Brien (http://www.math.auckland.ac.nz/~obrien)79Co-maintained by Max Horn <[email protected]>8081For help, type: ?ANUPQ82---------------------------------------------------------------------------83true84gap> G := DihedralGroup( 512 );85<pc group of size 512 with 9 generators>86gap> F := PqStandardPresentation( G );87<fp group on the generators [ f1, f2, f3, f4, f5, f6, f7, f8, f9 ]>88gap> H := PcGroupFpGroup( F );89<pc group of size 512 with 9 generators>90gap> IdStandardPresented512Group( H );91[ 512, 2042 ]92]]>93</Example>9495The package &ANUPQ; requires <Package>UNIX</Package> environment96and it is natural to provide an identification service for groups of97order 512 to make it available for other platforms.98<P/>99100Now we need to decide how the client will transmit a group to the server.101Can we encode this group in &OpenMath;? But there is no content dictionary102for PcGroups. Should we convert it to a permutation representation to be103able to use existing content dictionaries? But then the resulting &OpenMath;104code will be not compact. However, the &SCSCP; protocol provides enough105freedom for the user to select its own data representation, and since we106are linking together two copies of the same system, we may use the107<E>pcgs code</E> to pass the data to the server108(see <Ref BookName="ref" Func="CodePcGroup" />.109<P/>110111First we create a function which accepts the integer number that is the code for112pcgs of a group of order 512 and returns the number of this group in the113GAP Small Groups library:114115<Log>116<![CDATA[117IdGroup512ByCode := function( code )118local G, F, H;119G := PcGroupCode( code, 512 );120F := PqStandardPresentation( G );121H := PcGroupFpGroup( F );122return IdStandardPresented512Group( H );123end;124]]>125</Log>126127After such function was created on the server, we need to make it128<Q>visible</Q> as an &SCSCP; procedure:129130<Log>131<![CDATA[132gap> InstallSCSCPprocedure("IdGroup512", IdGroup512ByCode );133InstallSCSCPprocedure : procedure IdGroup512 installed.134]]>135</Log>136137Note that this function assumes that the argument is a valid code138for some group of order 512, and we wish the client to make it139sure that this is the case. To do this, and also for the client's140convenience, we provide the client's counterpart for this141service. Here the group must be a pc-group of order 512, otherwise142an error message will appear.143144<Example>145<![CDATA[146gap> IdGroup512 := function( G )147> local code, result;148> if Size( G ) <> 512 then149> Error( "G must be a group of order 512 \n" );150> fi;151> code := CodePcGroup( G );152> result := EvaluateBySCSCP( "IdGroup512ByCode", [ code ],153> "localhost", 26133 );154> return result.object;155> end;;156]]>157</Example>158159Now the client can call the function <C>IdGroup512</C>, and the procedure160of getting result is as much straightforward as using <C>IdGroup</C> for161those groups where it works:162163<Example>164<![CDATA[165gap> IdGroup512(DihedralGroup(512));166[ 512, 2042 ]167]]>168</Example>169170</Section>171172</Chapter>173174