Array<double> x; Array<float> t(10); Array<unsigned char> image(1280,1024,1,3);
x is an empty array of type double, t contains 10 floating point number, and image is a 2D color picture array (see section ?).
The size and dimension of the array can be dynamicaly modified at any time in the program.
Array<float> x,y,t; t = findgen(100)/10; x = 3*t; y = sin(t)*sqrt(x); x += 0.8; y -= x;
You can first access element through their index, as in standard C/C++ or Scilab/Matlab,etc...
Array<double> x(10),y(10); x[0] = 1.2; y[1] = x(0)+3.6;
Parenthesis and brackets are equivalent here. However, as we will discuss later, we encourage to use brackets on the left side of the equal sign, and parenthesis on the right size.
Array<double> x,y; x = dindgen(100); y = sin(x); w = where(y>0.5); y[w] = cos( x(w) );
The command where returns an array of long integer containing the indices of all the elements satisfying the condition in paranthesis. "y[w] = cos(x(w))" has to be explained carefully. x(w) extracts all the elements indexed by w: this is a new array. y[w] is a structure pointing to the values to be modified: it is not a new vector and this syntax should only be used on the left of the equal sign. The line "y(w) = cos(x(w))" would not produce the expected result, as y(w) would create a new vector and we would not therefore modifiy the array y.
The following expression could have been used as well. It is however slower here since the test has to be realized twice.
y[y>0.5] = cos(x(y>0.5));