10.06.2016 Views

eldo_user

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Eldo Control Language<br />

Statement Overview<br />

set a[] = {1, 2, 4}<br />

set b[-3,3] = {-1, 0, 0, 1, 0, 0, -1}<br />

a[5] = 8 /* a[4] will be 1 because it is the default value. */<br />

b[1, 2] = {0.5, -0.5}<br />

The memory corresponding to a vector is automatically freed upon exit of the task in which it<br />

was allocated.<br />

Multi-dimensional Vectors<br />

Multi-dimensional vectors are created using the ; separator (or alternatively separate brackets)<br />

for the dimensions. The example below creates a 10×10 matrix:<br />

set a[0,9;0,9] = 0<br />

Elements of multi-dimensional vectors are referred to using the notation a[i;j] or a[i][j].<br />

Both notations are equivalent, and a matrix is implemented in ECL as a vector of vectors. mat[i]<br />

yields line i of the matrix (a vector). mat[i][j] yields the matrix element on line i and column j.<br />

A matrix can be declared and initialized using the following equivalent syntaxes:<br />

set a[0,9;0,9] = 0<br />

set b[0,9][0,9] = 0<br />

To declare an empty matrix:<br />

set c[][] = 0<br />

Matrix Attributes<br />

The number of lines of a matrix is the number of elements of vector (of vectors):<br />

mat.size<br />

The number of columns of a matrix is the number of elements of any line, for example the first<br />

line, which is vector mat[mat.imin]:<br />

mat[mat.imin].size<br />

Refer to the example $MGC_AMS_HOME/examples/ecl/12-rc_compounds/rc_compounds.cir<br />

that shows how to loop on all the matrix elements.<br />

Beware, there is no mechanism that forces the lines of the matrix to remain the same size, that<br />

is, line vectors grow independently using the auto-expanding mechanism of ECL. For example,<br />

the following code:<br />

828<br />

Eldo® User's Manual, 15.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!