2.3.3 Procedures and libraries
SINGULAR offers a comfortable programming language, with a syntax
close to C. So it is possible to define procedures which collect several
commands to a new one. Procedures are defined with the keyword
proc followed by a name and an optional parameter list with
specified types. Finally, a procedure may return values using the
command return .
Define the following procedure called Milnor :
| proc Milnor (poly h)
{
return(vdim(groebner(jacob(h))));
}
|
Note: if you have entered the first line of the procedure and pressed
RETURN , SINGULAR prints the prompt . (dot) instead of
the usual prompt > . This shows that the input is incomplete and
SINGULAR expects more lines. After typing the closing curly
bracket, SINGULAR prints the usual prompt indicating that the input
is now complete.
Then call the procedure:
Note that the result may depend on the basering as we will
see in the next chapter.
The distribution of SINGULAR contains several libraries, each of
which is a collection of useful
procedures based on the kernel commands, which extend the functionality
of SINGULAR. The command help "all.lib"; lists all libraries
together with a one-line explanation.
One of these libraries is sing.lib which already contains a
procedure called milnor to calculate the Milnor number not only
for hypersurfaces but more generally for complete intersection
singularities.
Libraries are loaded with the command LIB . Some additional
information during the process of loading is displayed on the screen,
which we omit here.
As all input in SINGULAR is case sensitive, there is no conflict with
the previously defined procedure Milnor , but the result is the same.
The procedures in a library have a help part
which is displayed by typing
as well as some examples, which are executed by
Likewise, the library itself has a help part, to show a list of
all the functions
available for the user which are contained in the library.
The output of the help commands is omitted here.
|