alibPutRangeS
Replaces values in a contiguous subarray with a scalar. To replace the values with variable values, see
alibPutRange. The PV-WAVE API for this routine is
array indexing that uses any combination of scalars and range operators.
Prototypes
void alibPutRangeSb( wvlong n, wvlong *d, wvlong *b, wvlong *e, UCHAR *p, UCHAR q )
void alibPutRangeSs( wvlong n, wvlong *d, wvlong *b, wvlong *e, short *p, short q )
void alibPutRangeSi( wvlong n, wvlong *d, wvlong *b, wvlong *e, int *p, int q )
void alibPutRangeSl( wvlong n, wvlong *d, wvlong *b, wvlong *e, wvlong *p, wvlong q )
void alibPutRangeSf( wvlong n, wvlong *d, wvlong *b, wvlong *e, float *p, float q )
void alibPutRangeSd( wvlong n, wvlong *d, wvlong *b, wvlong *e, double *p, double q )
void alibPutRangeSc( wvlong n, wvlong *d, wvlong *b, wvlong *e, COMPLEX *p, COMPLEX q )
void alibPutRangeSz( wvlong n, wvlong *d, wvlong *b, wvlong *e, DCOMPLEX *p, DCOMPLEX q )
Parameters
n — (Input) The number of dimensions in the array containing the subarray to be replaced.
*d — (Input) The n-element array of dimensions for the array containing the subarray to be replaced.
*b — (Input) The n-element array of beginning subscripts defining the "lower-left" corner of the subarray to be replaced.
*e — (Input) The n-element array of ending subscripts defining the "upper-right" corner of the subarray to be replaced. Note that subarrays of dimensionality less than n are prescribed if b[i] = e[i] for some i.
*p — (Input/Output) The array containing the subarray to be replaced. On output, the subarray defined by corners b and e has been replaced.
q — (Input) The scalar value which replaces each value in the subarray.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
/* array of dimensions to use for one-dimensional, two-dimensional, three-dimensional, and four-dimensional
examples */
wvlong dims[4] = {2,3,4,5};
/* array of beginning subscripts to use for one-dimensional, two-dimensional, three-dimensional,
four-dimensional examples */
wvlong begs[4] = {0,1,1,1};
/* array of ending subscripts to use for one-dimensional, two-dimensional, three-dimensional, four-dimensional
examples */
wvlong ends[4] = {1,2,2,3};
/* allocate array big enough for one-dimensional, two-dimensional, three-dimensional, and four-dimensional
examples */
UCHAR *b;
b = (UCHAR*)malloc(120*sizeof(UCHAR));
printf( "\n\n initialize and print one-dimensional array b" );
alibinit( NULL, NULL, NULL, NULL );
alibRepb( 5, 0, b );
alibPrintArrayb( 1, 1, 1, 5, b, NULL );
printf( "\n\n replace each value in b's interior with a 1" );
alibPutRangeSb( 1, &dims[3], &begs[3], &ends[3], b, 1 );
alibPrintArrayb( 1, 1, 1, 5, b, NULL );
printf( "\n\n initalize and print two-dimensional array b" );
alibRepb( 20, 0, b );
alibPrintArrayb( 1, 1, 4, 5, b, NULL );
printf( "\n\n replace each value in b's interior with a 1" );
alibPutRangeSb( 2, &dims[2], &begs[2], &ends[2], b, 1 );
alibPrintArrayb( 1, 1, 4, 5, b, NULL );
printf( "\n\n initialize and print three-dimensional array b" );
alibRepb( 60, 0, b );
alibPrintArrayb( 1, 3, 4, 5, b, NULL );
printf( "\n\n replace each value in the interior of each of the last\n");
printf( " two two-dimensional slices through b's leading dimension with a 1" );
alibPutRangeSb( 3, &dims[1], &begs[1], &ends[1], b, 1 );
alibPrintArrayb( 1, 3, 4, 5, b, NULL );
printf( "\n\n initialize and print four-dimensional array b" );
alibRepb( 120, 0, b );
alibPrintArrayb( 2, 3, 4, 5, b, NULL );
printf( "\n\n repeat the three-dimensional example on each \n" );
printf( " three-dimensional slice of b's leading dimension" );
alibPutRangeSb( 4, dims, begs, ends, b, 1 );
alibPrintArrayb( 2, 3, 4, 5, b, NULL );
}
Output:
initialize and print one-dimensional array b
0 0 0 0 0
replace each value in b's interior with a 1
0 1 1 1 0
initalize and print two-dimensional array b
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
replace each value in b's interior with a 1
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
initialize and print three-dimensional array b
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
replace each value in the interior of each of the last
two two-dimensional slices through b's leading dimension with a 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
initialize and print four-dimensional array b
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
repeat the three-dimensional example on each
three-dimensional slice of b's leading dimension
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.