Some remarks on the environment.
If Magma has been installed properly, it can be activated by typing `magma'.
magma -s filename
When starting up Magma, it is possible to specify a start-up file with the -s option. A search for the specified file is conducted, starting in the current directory, and in directories specified by the environment variable MAGMA_PATH after that if necessary. If the file is not found, an empty start-up file is used; if the file has been found it will be loaded before the `prompt' appears.
If the -d option is supplied to Magma, the licence for the current magmapassfile is dumped. That is, the expiry date and the valid hostids are displayed. Magma then exits.
When starting up Magma, it is possible to specify a seed for the generation of pseudo-random numbers. (Pseudo-random quantities are used in several Magma algorithms, and may also be generated explicitly by some intrinsics.) The seed should be in the range 1 to (2 ^ (31) - 2) inclusive. If the integer supplied to the -S option is zero, or if the -S option is not used, Magma selects the seed itself.
Terminate the current Magma-session.
Immediately quit Magma.
Interrupt Magma while it is performing some task (that is, while the user does not have a `prompt'). Magma will try to interrupt at a convenient point (this may take some time).
Input the file with the name specified by the string. The file will be read in, and the text will be treated as Magma input. `Tilde expansion' of file names is allowed.
Copy all information present in the current Magma workspace onto a file specified by the string "filename". The workspace is left intact, so executing this command does not interfere with the current computation.
Copy a previously stored Magma workspace from the file specified by the string "filename" into central memory. Information present in the current workspace prior to the execution of this command will be lost. The computation can now proceed from the point it was at when the corresponding save-command was executed.
This statement will cause Magma to assign to the given identifier the string of characters appearing (at run-time) on the following line. This allows the user to provide an input string at run-time. If the optional prompt is given (a string), that is printed first.
This statement will cause Magma to assign to the given identifier the literal integer appearing (at run-time) on the following line. This allows the user to specify integer input at run-time. If the optional prompt is given (a string), that is printed first.
Function that returns the contents of the text-file with name indicated by the string F. Here F may be an expression returning a string.
Print the value of the expression. Some limited ways of formatting output are described in the Chapter on strings. Four levels of printing (that may in specific cases coincide) exist, and may be indicated after the colon: Default (which is the same as the level obtained if no level is indicated), Minimal, Maximal, and Magma. The last of these produces output representing the value of the identifier as valid Magma-input (when possible).
Overwrite: BoolElt Default: false
Procedure. Print x to the file specified by the string F. If this file already exists, the output will be appended, unless the optional parameter Overwrite is set to true, in which case the file is overwritten.
Overwrite: BoolElt Default: false
Procedure. Print x in format defined by the string L to the file specified by the string F. If this file already exists, the output will be appendedunless the optional parameter Overwrite is set to true, in which case the file is overwritten. The level L can be any of the print levels on the print command above (i.e., it must be one of the strings "Default", "Minimal", "Maximal", or "Magma").
Overwrite: BoolElt Default: false
Procedure. Print x in Magma format to the file specified by the string F. If this file already exists, the output will be appended, unless the optional parameter Overwrite is set to true, in which case the file is overwritten.
Overwrite: BoolElt Default: false
Procedure. Set the log file to be the file specified by the string F: all output will be sent to this log file as well as to the terminal. If a log file is already in use, it is closed and F is used instead. By using SetLogFile(F: Overwrite := true) the file F is emptied before output is written onto it.
Procedure. Stop logging Magma's output.
Procedure. Set to true or false according to whether or not input from external files should also be sent to standard output.
Overwrite: BoolElt Default: false
Procedure. Redirect all Magma output to the file specified by the string F. By using SetOutputFile(F: Overwrite := true) the file F is emptied before output is written onto it.
Close the output file, so that output will be directed to standard output again.
> print Read("mystery.c");
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
{
int n, i;
n = atoi(argv[1]);
for (i = 1; i <= n; i++)
printf("%d\n", i * i);
return 0;
}
> System("cc mystery.c -o mystery");
> mysteryMagma := function(n)
> System("./mystery " cat IntegerToString(n) cat " >outfile");
> output := Read("outfile");
> return StringToIntegerSequence(output);
> end function;
> print mysteryMagma(5);
[ 1, 4, 9, 16, 25 ]
Print the values of the expressions and stop execution of Magma. Useful when some incorrect input is given to a function, etc.
If the given boolean expression evaluates to true, print the values of the expressions and stop execution of Magma. Useful when checking that certain conditions must be met, etc.
Return the CPU time (as a real number of default precision) used since the beginning of a Magma session.
Return the CPU time (as a real number of default precision) used since time t (as a real number). Time starts at 0.0 at the beginning of a Magma session.
Executes the statement and prints the time taken.
> n := 2^109-1; > time print Factorization(n); [<745988807, 1>, <870035986098720987332873, 1>] Time: 5.300Alternatively, we can extract the current time t and use Cputime. This method can be used to time the execution of several statements.
> m := 2^111-1; > n := 2^113-1; > t := Cputime(); > print Factorization(m); [<7, 1>, <223, 1>, <321679, 1>, <26295457, 1>, <319020217, 1>, <616318177, 1>] > print Factorization(n); [<3391, 1>, <23279, 1>, <65993, 1>, <1868569, 1>, <1066818132868207, 1>] > print Cputime(t); 11.881
Procedure. On UNIX systems, send the signal SIGALRM to the Magma process after s seconds. This is a way of making a Magma-process self-destruct after a certain period.
We list some environment variables. The following are
not Magma statements, but are to be used by the operating system.
MAGMA_STARTUP_FILE
The name of the default start-up file. It can be overridden by the magma -s command.
Search path for files that are loaded (a colon separated list of directories). It need not include directories for the libraries, just personal directories. This path is searched before the library directories.
Limit on the size of the memory that may be used by a Magma-session (in bytes).
The size of the memory extension allocated by Magma when more space is needed (in bytes).
The root directory for the Magma libraries (by supplying an absolute path name). From within Magma SetLibraryRoot and GetLibraryRoot can be used to change and view the value.
Give a list of Magma libraries (as a colon separated list of sub-directories of the library root directory). From within Magma SetLibraries and GetLibraries can be used to change and view the value.[Next] [Prev] [Right] [Left] [Up] [Index] [Root]