Top
Back: Rings and standard bases
Forward: Change of rings
FastBack: How to use this manual
FastForward: General concepts
Up: Getting started
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

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 bind a sequence of several commands in a new one. Procedures are defined using the keyword proc followed by a name and an optional parameter list with specified types. Finally, a procedure may return a value using the command return.

We may e.g. 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 we can call the procedure:

 
Milnor(f);
==> 12

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 using the command LIB. Some additional information during the process of loading is displayed on the screen, which we omit here.

 
LIB "sing.lib";

As all input in SINGULAR is case sensitive, there is no conflict with the previously defined procedure Milnor, but the result is the same.

 
milnor(f);
==> 12

The procedures in a library have a help part which is displayed by typing

 
help milnor;

as well as some examples, which are executed by

 
example milnor;

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.

 
help sing.lib;

The output of the help commands is omitted here.


Top Back: Rings and standard bases Forward: Change of rings FastBack: How to use this manual FastForward: General concepts Up: Getting started Top: Singular Manual Contents: Table of Contents Index: Index About: About this document
            User manual for Singular version 4-0-3, 2016, generated by texi2html.