@@ -165,7 +165,7 @@ Character codes for data types:
165165Function name suffix naming convention:
166166
167167``` text
168- stdlib_ndarray_ <input_data_type>_<output_data_type>[_as_<callback_arg_data_type>_<callback_return_data_type>]
168+ stdlib_ndarray_every_ <input_data_type>_<output_data_type>[_as_<callback_arg_data_type>_<callback_return_data_type>]
169169```
170170
171171For example,
@@ -176,14 +176,30 @@ For example,
176176void stdlib_ndarray_every_d_x (...) {...}
177177```
178178
179+ is a function which accepts one double-precision floating-point input ndarray and one boolean output ndarray.
180+
181+ Function name suffix naming convention for applying a predicate function:
182+
183+ ```text
184+ stdlib_ndarray_every_by_<input_data_type>_<output_data_type>[_as_<callback_arg_data_type>_<callback_return_data_type>]
185+ ```
186+
187+ For example,
188+
189+ <!-- run-disable -->
190+
191+ ``` c
192+ void stdlib_ndarray_every_by_d_x (...) {...}
193+ ```
194+
179195is a function which accepts one double-precision floating-point input ndarray and one boolean output ndarray. In other words, the suffix encodes the function type signature.
180196
181197To support callbacks whose input arguments are of a different data type than the input ndarray data type, the naming convention supports appending an `as` suffix. For example,
182198
183199<!-- run-disable -->
184200
185201```c
186- void stdlib_ndarray_every_f_x_as_d_x (...) {...}
202+ void stdlib_ndarray_every_by_f_x_as_d_x (...) {...}
187203```
188204
189205is a function which accepts one single-precision floating-point input ndarray and one boolean output ndarray. However, the callback accepts double-precision floating-point numbers. Accordingly, the input values need to be cast using the following conversion sequence
@@ -276,12 +292,13 @@ static bool fcn( const uint8_t x ) {
276292}
277293
278294int main( void ) {
279- // Define the ndarray data type:
280- enum STDLIB_NDARRAY_DTYPE dtype = STDLIB_NDARRAY_UINT8;
295+ // Define the ndarray data types:
296+ enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_UINT8;
297+ enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_BOOL;
281298
282299 // Create underlying byte arrays:
283- uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
284- bool ybuf[] = { false };
300+ uint8_t xbuf[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
301+ uint8_t ybuf[] = { 0 };
285302
286303 // Define the number of input array dimensions:
287304 int64_t ndims = 3;
@@ -309,14 +326,14 @@ int main( void ) {
309326 int64_t nsubmodes = 1;
310327
311328 // Create an input ndarray:
312- struct ndarray *x = stdlib_ndarray_allocate( dtype , xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes );
329+ struct ndarray *x = stdlib_ndarray_allocate( xdtype , xbuf, ndims, shx, sx, ox, order, imode, nsubmodes, submodes );
313330 if ( x == NULL ) {
314331 fprintf( stderr, "Error allocating memory.\n" );
315332 exit( EXIT_FAILURE );
316333 }
317334
318335 // Create an output ndarray:
319- struct ndarray *y = stdlib_ndarray_allocate( dtype , ybuf, 0, shy, sy, oy, order, imode, nsubmodes, submodes );
336+ struct ndarray *y = stdlib_ndarray_allocate( ydtype , ybuf, 0, shy, sy, oy, order, imode, nsubmodes, submodes );
320337 if ( y == NULL ) {
321338 fprintf( stderr, "Error allocating memory.\n" );
322339 exit( EXIT_FAILURE );
@@ -326,7 +343,7 @@ int main( void ) {
326343 struct ndarray *arrays[] = { x, y };
327344
328345 // Test elements:
329- int8_t status = stdlib_ndarray_every_b_x ( arrays, (void *)fcn );
346+ int8_t status = stdlib_ndarray_every_by_b_x ( arrays, (void *)fcn );
330347 if ( status != 0 ) {
331348 fprintf( stderr, "Error during computation.\n" );
332349 exit( EXIT_FAILURE );
0 commit comments