Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Using Strides

When you instruct print to stride across a slice of an array, dbx evaluates certain elements in the slice only, skipping over a fixed number of elements between each one it evaluates.

The third expression in the array slicing syntax, stride-expression, specifies the length of the stride. The value of stride-expression specifies the elements to print. The default stride value is 1, meaning: evaluate all of the elements in the specified slices.

The following example is the same array used in the previous example of a slice. This time, the print command includes a stride of 2 for the slice in the second dimension.

print arr(201:203, 101:105:2)

As shown in the diagram, a stride of 2 prints every second element, skipping every other element.

image:Diagram of an array with columns 100 through 106 and rows 200 through 205.             Elements in columns 101, 103, and 105 of rows 201 through 203 are shaded.

For any expression you omit, print takes a default value equal to the declared size of the array. The following examples show how to use the shorthand syntax.

For a one-dimensional array, use the following commands:

print arr

Prints the entire array with default boundaries.

print arr(:)

Prints the entire array with default boundaries and default stride of 1.

print arr(::stride-expression)

Prints the entire array with a stride of stride-expression.

For a two-dimensional array, the following command prints the entire array.

print arr

The following command prints every third element in the second dimension of a two-dimensional array:

print arr (:,::3)