next up previous contents
Next: Array Sections - Visualisation Up: Arrays Previous: Array Conformance

Array Sections

An array can be subscripted by a subscript-triplet (a shorthand notation for a linear function) which will give rise to a sub-array of the original. The general form is:

 
[ tex2html_wrap_inline43037  bound1  tex2html_wrap_inline43039 ]:[ tex2html_wrap_inline43037  bound2  tex2html_wrap_inline43039 ][: tex2html_wrap_inline43037  stride  tex2html_wrap_inline43039 ]

the section starts at tex2html_wrap_inline43037  bound1 tex2html_wrap_inline43039 and ends at or before tex2html_wrap_inline43037  bound2 tex2html_wrap_inline43039 . tex2html_wrap_inline43037  stride tex2html_wrap_inline43039 is the increment by which the locations are selected.

tex2html_wrap_inline43037  bound1 tex2html_wrap_inline43039 , tex2html_wrap_inline43037  bound2 tex2html_wrap_inline43039 and tex2html_wrap_inline43037  stride tex2html_wrap_inline43039 must all be scalar integer expressions. Thus

   A(m:m) = 0     ! m to m 1 elt array
   A(m:n:k) = 0   ! m to n step k
   A(8:3:-1) = 0  ! 8 to 3 backwards
   A(8:3) = 2     ! step 1 => Zero size
   A(M::4) = 1    ! default UPB, step 4
   A(::2) = 1.0   ! default LWB and UPB
   A(m**2:n*k/3) = 1.0
are all valid.

For more information, click here gif


next up previous contents
Next: Array Sections - Visualisation Up: Arrays Previous: Array Conformance

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 18:56:08 GMT 1996
Not for commercial use.