![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
All arithmetic is permitted between variables of this type and a variable of any other type. All such operations result in a variable of the type Undefined, with the exception of the TYPE function.
One if the constants is of this type: NILL.
Strings are usually created by enclosing a series of characters in reverse quotes, as illustrated in the examples below.
Strings can be concatenated with the / operator and can be lexically compared with each other using the >, < and = operators. The functions NUMBER and STRING convert Strings to Numbers and vv. There is also a series of procedures that act on Strings: STRING_DELETE, STRING_INDEX, STRING_LENGTH, STRING_LOWER, STRING_MATCH, STRING_PORTION, STRING_REPLACE, STRING_UPPER, STRING_WORD and STRING_WORDS.
Strings are internally stored in a dynamic buffer which has a fixed maximum total size. The buffer remembers the length of each string. One does not declare the length of Strings since the length is implied by the initialisation and operations the string has undergone. The length of a string can vary in time.
There are no constant strings, but there are predefined globals of type String.
Examples:
Global gas_file `gas.dat`Global p=1 Global gas_file `gas_p`/string(p)/`.gas`
The numbers 0, 1, 2 and PI are constants, there are also predefined globals of this type.
Both True and False are stored as constants and there are several predefined globals of this type. Logicals can also be created by applying a comparison operator to variables of other data types:
Global equal `aaa`=`a`/`aa` Global bigger 5>2^2
Logicals can be acted upon with operators, as & (and) and | (or) as well as with the NOT, STRING and TYPE functions.
Logicals are commonly used in the conditions of If_lines, If_blocks and Do loops:
Do Say "Quit ? Please reply with True or False" Parse terminal quit If type(quit)#`Logical` Then Say "Please answer with True or False" Elseif quit Then Say "Quit" Leave Endif Enddo
Logicals in Garfield are not equivalent to numbers, i.e. one can not normally replace True by 1. Similarly, one can not apply mixed arithmetic between Logicals and Numbers.
Garfield histograms are currently 1-dimensional only, and they have adjacent, equal size bins. They come in 2 flavours:
Histograms are usually created with a call to BOOK_HISTOGRAM. Several instructions can generate histograms as part of their output.
Histograms can be subject of most of the ordinary arithmetic operators and functions. Mixed arithmetic between Numbers and histograms is permitted and results in histograms.
Example:
Call get_histogram(part1,`file1.hist`,`delay`) Call get_histogram(part2,`file2,hist`,`delay`) Call get_histogram(part3,`file3,hist`,`delay`) Global delay=(part1+part2+part3)/3Each of a series of jobs, run in parallel, has created an histogram called DELAY, filled it, and written it to a file. The histograms from the 3 files are retrieved and averaged.
Histograms can also be operated on by a series of procedures, For instance, histograms can, by means of the WRITE_HISTOGRAM_RZ procedure, be written out to an RZ file for further processing with PAW.
There are no predefined constant histograms, nor globals of this type.
Matrices can be created in a variety of ways:
The usual arithmetic operators and functions can be applied to matrices as if they were numbers. Mixed arithmetic between Numbers and matrices is permitted and results in matrices.
Parts of matrices can be addressed as illustrated in the following examples. Keep in mind that the number of dimensions does not change, A[;1] is a 2-dimensional matrix ! Use RESHAPE_MATRIX if you wish to transform a 1xn-matrix to an n-matrix, or use the NUMBER function to change a 1x1x...x1-matrix to a number.
1-dimensional matrix:
A = (9 8 7) A[1,2,3,1] = (9 8 7 9)
2-dimensional matrix:
( 1 2 3 ) ( 3 2 ) A = ( 2 4 6 ) A[3,2;] = ( 6 4 ) A[;1] = ( 1 2 3 ) ( 3 6 9 ) ( 9 6 )
One may use a 1-dimensional matrix to index elements of another matrix. This is particularly convenient to extract a large sub-matrix, such as in the following example where one only fits the central portion of a cosine curve with a parabola:
Global x=-pi+2*pi*(row(500)-1)/499 Global y=cos(x) Call fit_polynomial(x[200+row(100)],y[200+row(100)],0.001, ... a0,a1,a2,ea0,ea1,ea2,`plot`)
Notes:
Formatted on 0108-07- at 16:58.