Home Online Manual
Top
Back: Typesetting of help and info strings
Forward: Debugging tools
FastBack: Procedures
FastForward: Debugging tools
Up: Libraries
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

3.8.11 Loading a library

Libraries can be loaded with the LIB or the load command (see LIB and see load).

Syntax:
LIB string_expression ;
load string_expression ;
Type:
none
Purpose:
Reads a library from a file. If the given filename does not start with . or / and if the file cannot be located in the current directory, the SearchPath is checked for a directory containing a file with this name.
Note on SearchPath:
The SearchPath for a library is constructed at SINGULAR start-up time as follows:
  1. the directories contained in the environment variable SINGULARPATH are appended.

  2. the directories $BinDir/LIB, $RootDir/LIB, $RootDir/../LIB, $DefaultDir/LIB, $DefaultDir/../LIB are appended, where
    • $BinDir is the value of the environment variable SINGULAR_BIN_DIR, if set, or, if not set, the directory in which the SINGULAR program resides
    • $RootDir is the value of the environment variable SINGULAR_ROOT_DIR, if set, or, if not set, $BinDir/../.
    • $DefaultDir is the value of the environment variable SINGULAR_DEFAULT_DIR, if set, or /usr/local.

  3. all directories which do not exist are removed from the SearchPath.

For setting environment variables, see system, or consult the manual of your shell.

The library SearchPath can be examined by starting up SINGULAR with the option -v, or by issuing the command system("--version");.

Note on standard.lib:
Unless SINGULAR is started with the --no-stdlib option, the library standard.lib is automatically loaded at start-up time.

Following a LIB or load command, only the names of the procedures in the library are loaded. The body of a particular procedure is only read upon the first call of the procedure. This minimizes memory consumption by unused procedures. Starting a SINGULAR session with the -q or --quiet option unsets the option loadLib and inhibits, thus, the monitoring of library loading (see option).

All libraries loaded in a SINGULAR session are displayed upon entering listvar(package); :

 
 option(loadLib);   // show loading of libraries;
                    // standard.lib is loaded
 listvar(package);
==> // Singmathic                     [0]  package Singmathic (C,singmathic.s\
   o)
==> // Standard                       [0]  package Standard (S,standard.lib)
==> // Top                            [0]  package Top (T)
                    // the names of the procedures of inout.lib
 LIB "inout.lib";   // are now known to Singular
==> // ** loaded inout.lib (4.1.1.0,Dec_2017)
 listvar(package);
==> // Inout                          [0]  package Inout (S,inout.lib)
==> // Singmathic                     [0]  package Singmathic (C,singmathic.s\
   o)
==> // Standard                       [0]  package Standard (S,standard.lib)
==> // Top                            [0]  package Top (T)

See Command line options; LIB; Procedures and libraries; SINGULAR libraries; proc; standard_lib; string; system.