next up previous contents index
Next: String Arrays Up: Arrays Previous: Logical Arrays   Contents   Index


Real Arrays

Real arrays have the following syntax:

array-ref     ::= array-variable |
                  object "->" array-attribute |

table-ref     ::= "ROW" "(" table "," place ")" |
                  "ROW" "(" table "," place "," column-list ")"
                  "COLUMN" "(" table "," column ")" |
                  "COLUMN" "(" table "," column "," range ")"

columns       ::= column |
                  "{" column-list "}"

column-list   ::= column |
                  column-list "," column

column        ::= string

real-list     ::= real-expr |
                  real-list "," real-expr

index-select  ::= integer |
                  integer "," integer |
                  integer "," integer "," integer

array-primary ::= "{" real-list "}" |
                  "TABLE" "(" index-select "," real-expr ")" |
                  array-ref |
                  table-ref |
                  array-function-name "(" arguments ")" |
                  (array-expression)

array-factor  ::= array-primary |
                  array-factor "^" array-primary

array-term    ::= array-factor |
                  array-term "*" array-factor |
                  array-term "/" array-factor

array-expr    ::= array-term |
                  "+" array-term |
                  "-" array-term |
                  array-expr "+" array-term |
                  array-expr "-" array-term |


Table 2.8: Real Array Functions in MAD-9 (acting component-wise)
Function Meaning result type argument type
TRUNC(X) truncate X towards zero (discard fractional part) real array real array
ROUND(X) round X to nearest integer real array real array
FLOOR(X) return largest integer not greater than X real array real array
CEIL(X) return smallest integer not less than X real array real array
SIGN(X) return sign of X (+1 for X positive, -1 for X negative, 0 for X zero) real array real array
SQRT(X) return square root of X real array real array
LOG(X) return natural logarithm of X real array real array
EXP(X) return exponential to the base $e$ of X real array real array
SIN(X) return trigonometric sine of X real array real array
COS(X) return trigonometric cosine of X real array real array
ABS(X) return absolute value of X real array real array
TAN(X) return trigonometric tangent of X real array real array
ASIN(X) return inverse trigonometric sine of X real array real array
ACOS(X) return inverse trigonometric cosine of X real array real array
ATAN(X) return inverse trigonometric tangent of X real array real array
TGAUSS(X) random number, Gaussian distribution with $\sigma$=1, truncated at X real array real array
USER1(X) random number, user-defined distribution with one parameter real array real array
EVAL(X) evaluate the argument immediately and transmit it as a constant real array real array

Example:

{a,a+b,a+2*b}
There are also three functions allowing the generation of real arrays:
TABLE
Generate an array of expressions:

TABLE(n2,expression)       // implies TABLE(1:n2:1,expression)
TABLE(n1:n2,expression)    // implies TABLE(n1:n2:1,expression)
TABLE(n1:n2:n3,expression)
These expressions all generate an array with n2 components. The components selected by n1:n2:n3 are filled from the given expression; a C pseudo-code for filling is

int i;
for (i = n1; i <= n2; i += n3) a[i] = expression(i);
In each generated expression the special character hash sign (#) is replaced by the current value of the index i.

Example:


// an array with 9 components, evaluates to {1,4,7,10,13}:
table(5:9:2,3*#+1) // equivalent to {0,0,0,0,16,0,22,0,28}
ROW
Generate a table row:

ROW(table,place)             // implies all columns
ROW(table,place,column list)
This generates an array containing the named (or all) columns in the selected place.
COLUMN
Generate a table column:

COLUMN(table,column)         // implies all rows
COLUMN(table,column,range)
This generates an array containing the selected (or all) rows of the named column.


next up previous contents index
Next: String Arrays Up: Arrays Previous: Logical Arrays   Contents   Index
MAD User Guide, http://wwwslap.cern.ch/mad/