Function: slice


/* C */
struct sidl_double__array *
sidl_double__array_slice(struct sidl_double__array *src,
                         int32_t                    dimen,
                         const int32_t              numElem[],
                         const int32_t             *srcStart,
                         const int32_t             *srcStride,
                         const int32_t             *newStart);
//
// C++
array<double>
sidl::array<double>::slice(int dimen,
                           const int32_t numElem[],
                           const int32_t *srcStart = 0,
                           const int32_t *srcStride = 0,
                           const int32_t *newStart = 0);
C
C FORTRAN 77
       subroutine sidl_double__array_slice_f(src, dimen, numElem, srcStart,
      $                       srcStride, newStart, result)
       integer*8 src, result
       integer*4 dimen
       integer*4 numElem(srcDimen), srcStart(srcDimen)
       integer*4 srcStride(srcDimen),  newStart(dimen)
!
! FORTRAN 90
subroutine slice(src, dimen, numElem, srcStart, srcStride, newStart, result)
  type(sidl_double_3d), intent(in) :: src     ! type depends on dimension
  type(sidl_double_2d), intent(out) :: result ! type depends on dimension
  integer (selected_int_kind(9)), intent(in) :: dimen
  integer (selected_int_kind(9)), intent(in), dimension(:) :: &
     numElem, srcStart, srcStride, newStart

// Java
  public native Array _slice(int dimen, int[] numElem, int[] srcStart,
			     int[] srcStride, int[] newStart);

This method will create a sub-array of another array. The resulting array shares data with the original array. The new array can be of the same dimension or potentially less than the original array. If you are removing a dimension, indicate the dimensions to remove by setting numElem[i] to zero for any dimension i that should go away in the new array. The meaning of each argument is covered below.

src
the array to be created will be a subset of this array. If this argument is NULL, NULL will be returned. The returned array borrows data from src, so modifying one array modifies both. In C++, the this pointer takes the place of src.
dimen
this argument must be greater than zero and less than or equal to the dimension of src. An illegal value will cause a NULL return value.
numElem
this specifies how many elements from src should be in the new array in each dimension. A zero entry indicates that the dimension should not appear in the new array. This argument should be an array with an entry for each dimension of src. NULL will be returned for src if either
srcStart[i] + numElem[i] * srcStride[i] $>$ upper[i], or
srcStart[i] + numElem[i] * srcStride[i] $<$ lower[i]

srcStart
this parameter specifies which element of src will be the first element of the new array. If this argument is NULL, the first element of src will be the first element of the new array. If non-NULL, this argument provides the coordinates of an element of src, so it must have an entry for each dimension of src. NULL will be returned for src if either
srcStart[i] < lower[i], or srcStart[i] > upper[i].

srcStride
this argument lets you specify the stride between elements of src for each dimension. For example with a stride of 2, you could create a sub-array with only the odd or even elements of src. If this argument is NULL, the stride is taken to be one in each dimension. If non-NULL, this argument should be an array with an entry for each dimension of src. The stride values are relative to the original source array, src, so the default stride of one in each dimension is appropriate for cases where you want a dense subsection of the original array.
newLower
this argument is like the lower argument in a create method. It sets the coordinates for the first element in the new array. If this argument is NULL, the values indicated by srcStart will be used. If non-NULL, this should be an array with dimen elements.
Assuming the method is successful and the return value is named newArray, src[srcStart] refers to the same underlying element as newArray[newStart].

If src is not a borrowed array (i.e., it manages its own data), the returned array can manage its by keeping a reference to src. It is not considered a borrowed array for purposes of smartCopy.



babel-1.4.0
users_guide Last Modified 2008-10-16

http://www.llnl.gov/CASC/components
components@llnl.gov