]>
In this chapter we discuss how to collect Axiom statements and commands into files and then read the contents into the workspace. We also show how to display the results of your computations in several different styles including TeX, FORTRAN and monospace two-dimensional format.TeX is a trademark of the American Mathematical Society.
The printed version of this book uses the Axiom TeX output formatter. When we demonstrate a particular output style, we will need to turn TeX formatting off and the output style on so that the correct output is shown in the text.
In this section we explain what an input file is and file:input why you would want to know about it. We discuss where Axiom looks for input files and how you can direct it to look elsewhere. We also show how to read the contents of an input file into the workspace and how to use the history facility to generate an input file from the statements you have entered directly into the workspace.
An input file contains Axiom expressions and system commands. Anything that you can enter directly to Axiom can be put into an input file. This is how you save input functions and expressions that you wish to read into Axiom more than one time.
To read an input file into Axiom, use the )read system command. read For example, you can read a file in a particular directory by issuing
The `` .input'' is optional; this also works:
What happens if you just enter )read matrix.input or even )read matrix? Axiom looks in your current working directory for input files that are not qualified by a directory name. Typically, this directory is the directory from which you invoked Axiom.
To change the current working directory, use the )cd system command. The command )cd by itself shows the current working directory:default for searching directory. cd To change it to file:input:where found the src/input subdirectory for user ``babar'', issue
Axiom looks first in this directory for an input file. If it is not found, it looks in the system's directories, assuming you meant some input file that was provided with Axiom.
If you have the Axiom history facility turned on (which it is by default), you can save all the lines you have entered into the workspace by entering
)history )write
Axiom tells you what input file to edit to see your statements. The
file is in your home directory or in the directory you specified with
cd )cd.
In ugLangBlocks we discuss using indentation in input files to group statements into blocks.
When Axiom starts up, it tries to read the input file .axiom.input (.axiom.input used to be called axiom.input in the NAG version) from your home start-up profile file directory. file:start-up profile It there is no .axiom.input in your home directory, it reads the copy located in its own src/input directory. file:.axiom.input @ .axiom.input The file usually contains system commands to personalize your Axiom environment. In the remainder of this section we mention a few things that users frequently place in their .axiom.input files.
In order to have FORTRAN output always produced from your computations, place the system command )set output fortran on in .axiom.input. quit If you do not want to be prompted for confirmation when you issue the )quit system command, place )set quit unprotected in .axiom.input. set quit unprotected If you then decide that you do want to be prompted, issue )set quit protected. set quit protected This is the default setting so that new users do not leave Axiom inadvertently.The system command )pquit always prompts you for confirmation.
To see the other system variables you can set, issue )set or use the HyperDoc Settings facility to view and change Axiom system variables.
In this section we discuss how to start and stop the display output formats:common features of the different output formats and how to send the output to the screen or to a file. file:sending output to To fix ideas, we use FORTRAN output format for most of the examples.
You can use the )set output system output formats:starting command to output formats:stopping toggle or redirect the different kinds of output. set output The name of the kind of output follows ``output'' in the command. The names are
fortran | for FORTRAN output. |
algebra | for monospace two-dimensional mathematical output. |
tex | for TeX output. |
script | for IBM Script Formula Format output. |
For example, issue )set output fortran on to turn on FORTRAN format and issue )set output fortran off to turn it off. By default, algebra is on and all others are off. set output fortran When output is started, it is sent to the screen. To send the output to a file, give the file name without output formats:sending to file directory or extension. Axiom appends a file extension depending on the kind of output being produced.
Issue this to redirect FORTRAN output to, for example, the file linalg.sfort.
You must also turn on the creation of FORTRAN output. The above just says where it goes if it is created.
In what directory is this output placed? It goes into the directory from which you started Axiom, or if you have used the )cd system command, the one that you specified with )cd. cd You should use )cd before you send the output to the file.
You can always direct output back to the screen by issuing this. output formats:sending to screen
Let's make sure FORTRAN formatting is off so that nothing we do from now on produces FORTRAN output.
We also delete the demonstrated output file we created.
You can abbreviate the words ``on,'' ``off,'' and ``console'' to the minimal number of characters needed to distinguish them. Because of this, you cannot send output to files called on.sfort, off.sfort, of.sfort, console.sfort, consol.sfort and so on.
The width of the output on the page is set by output formats:line length )set output length for all formats except FORTRAN. set output length Use )set fortran fortlength to change the FORTRAN line length from its default value of .
This is the default output format for Axiom. It is usually on when you start the system. set output algebra output formats:monospace 2D monospace 2D output format
If it is not, issue this.
Since the printed version of this book (as opposed to the HyperDoc version) shows output produced by the TeX output formatter, let us temporarily turn off TeX output.
Here is an example of what it looks like.
Issue this to turn off this kind of formatting.
Turn TeX output on again.
The characters used for the matrix brackets above are rather ugly. You get this character set when you issue character set )set output characters plain. set output characters This character set should be used when you are running on a machine that does not support the IBM extended ASCII character set. If you are running on an IBM workstation, for example, issue )set output characters default to get better looking output.
Axiom can produce TeX output for your output formats:TeX @{TeX} expressions. TeX output format @{TeX} output format The output is produced using macros from the LaTeX document preparation system by Leslie Lamport\cite{1}. The printed version of this book was produced using this formatter.
To turn on TeX output formatting, issue this. set output tex
Here is an example of its output.
This formats as
To turn TeX output formatting off, issue )set output tex off. The LaTeX macros in the output generated by Axiom are all standard except for the following definitions:
Axiom can output formats:IBM Script Formula Format produce IBM Script Formula Format output for your IBM Script Formula Format expressions.
To turn IBM Script Formula Format on, issue this. set output script
Here is an example of its output.
To turn IBM Script Formula Format output formatting off, issue this.
In addition to turning FORTRAN output on and off and stating where the output formats:FORTRAN output should be placed, there are many options that control the FORTRAN output format appearance of the generated code. In this section we describe some of the basic options. Issue )set fortran to see a full list with their current settings.
The output FORTRAN expression usually begins in column 7. If the expression needs more than one line, the ampersand character & is used in column 6. Since some versions of FORTRAN have restrictions on the number of lines per statement, Axiom breaks long expressions into segments with a maximum of 1320 characters (20 lines of 66 characters) per segment. set fortran If you want to change this, say, to 660 characters, issue the system command set fortran explength )set fortran explength 660. FORTRAN output format:breaking into multiple statements You can turn off the line breaking by issuing )set fortran segment off. set fortran segment Various code optimization levels are available.
FORTRAN output is produced after you issue this. set output fortran
For the initial examples, we set the optimization level to 0, which is the lowest level. set fortran optlevel
The output is usually in columns 7 through 72, although fewer columns are used in the following examples so that the output FORTRAN output format:line length fits nicely on the page.
By default, the output goes to the screen and is displayed before the standard Axiom two-dimensional output. In this example, an assignment to the variable was generated because this is the result of step 1.
Here is an example that illustrates the line breaking.
Note in the above examples that integers are generally converted to FORTRAN output format:integers vs. floats floating point numbers, except in exponents. This is the default behavior but can be turned off by issuing )set fortran ints2floats off. set fortran ints2floats The rules governing when the conversion is done are:
These rules only govern integers in expressions. Numbers generated by Axiom for statements are also integers.
To set the type of generated FORTRAN data, FORTRAN output format:data types use one of the following:
When temporaries are created, they are given a default type of REAL. Also, the REAL versions of functions are used by default.
At optimization level 1, Axiom removes common subexpressions. FORTRAN output format:optimization level set fortran optlevel
This changes the precision to DOUBLE. set fortran precision double Substitute single for double FORTRAN output format:precision to return to single precision. set fortran precision single
Complex constants display the precision.
The function names that Axiom generates depend on the chosen precision.
Reset the precision to single and look at these two examples again.
Expressions that look like lists, streams, sets or matrices cause array code to be generated.
A temporary variable is generated to be the name of the array. FORTRAN output format:arrays This may have to be changed in your particular application.
By default, the starting index for generated FORTRAN arrays is .
To change the starting index for generated FORTRAN arrays to be , set fortran startindex issue this. This value can only be or .
Look at the code generated for the matrix again.