<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Strided array functions for nullary callbacks.
*
* ## Notes
*
* -   Character codes for data types:
*
*     -   d: float64 (double)
*     -   f: float32 (float)
*     -   b: int8 (signed char)
*     -   B: uint8 (unsigned char)
*     -   h: int16 (signed short)
*     -   H: uint16 (unsigned short)
*     -   i: int32 (signed int)
*     -   I: uint32 (unsigned int)
*
* -   Function name suffix naming convention:
*
*     ```text
*     <base_function_name>[_<input_data_types>]_<output_data_type>[_as_<callback_arg_data_types>_<callback_return_data_type>]
*     ```
*
*     For example,
*
*     ```c
*     void stdlib_strided_dd_d(...) {...}
*     ```
*
*     is a function which accepts two strided input arrays containing double-precision floating-point numbers and whose results are cast as double-precision floating-point numbers. In other words, the suffix encodes the function type signature.
*
* -   To support callbacks whose input arguments and/or return values are of a different data type than the input and/or output strided array data types, the naming convention supports appending an `as` suffix. For example,
*
*     ```c
*     void stdlib_strided_ff_f_as_dd_d(...) {...}
*     ```
*
*     is a function which accepts two strided input arrays containing single-precision floating-point numbers and whose results are cast as single-precision floating-point numbers. However, the callback requires each pair of single-precision floating-point numbers be cast to double-precision floating-point numbers when provided as arguments, and the callback return value is a double-precision floating-point number. Accordingly, the conversion process would be
*
*     ```text
*     float in1 -> double in1
*     float in2 -> double in2
*     double out1 = f( in1, in2 )
*     float out1 <- double out1
*     ```
*
* -   The functions included in this file are **not** exhaustive and that is intentional. Namely, with few exceptions, functions which convert nullary callback return values to a different type are not included (e.g., widening an `int16` to an `int32`). Nullary functions should be simple enough that this can be handled in userland via function wrappers which return the desired types.
*
*/
#include <stdint.h>
#include "stdlib/strided_nullary_typedefs.h"
#include "stdlib/strided_nullary_macros.h"

void stdlib_strided_d( uint8_t *arrays[], int64_t *dims, int64_t *strides, NullaryFcnFloat64 *f ) {
	STDLIB_NULLARY_LOOP_CLBK( double )
}

void stdlib_strided_f( uint8_t *arrays[], int64_t *dims, int64_t *strides, NullaryFcnFloat32 *f ) {
	STDLIB_NULLARY_LOOP_CLBK( float )
}

void stdlib_strided_f_as_d( uint8_t *arrays[], int64_t *dims, int64_t *strides, NullaryFcnFloat64 *f ) {
	STDLIB_NULLARY_LOOP_CLBK( float )
}
<commit_msg>Document function<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Strided array functions for nullary callbacks.
*
* ## Notes
*
* -   Character codes for data types:
*
*     -   d: float64 (double)
*     -   f: float32 (float)
*     -   b: int8 (signed char)
*     -   B: uint8 (unsigned char)
*     -   h: int16 (signed short)
*     -   H: uint16 (unsigned short)
*     -   i: int32 (signed int)
*     -   I: uint32 (unsigned int)
*
* -   Function name suffix naming convention:
*
*     ```text
*     <base_function_name>[_<input_data_types>]_<output_data_type>[_as_<callback_arg_data_types>_<callback_return_data_type>]
*     ```
*
*     For example,
*
*     ```c
*     void stdlib_strided_dd_d(...) {...}
*     ```
*
*     is a function which accepts two strided input arrays containing double-precision floating-point numbers and whose results are cast as double-precision floating-point numbers. In other words, the suffix encodes the function type signature.
*
* -   To support callbacks whose input arguments and/or return values are of a different data type than the input and/or output strided array data types, the naming convention supports appending an `as` suffix. For example,
*
*     ```c
*     void stdlib_strided_ff_f_as_dd_d(...) {...}
*     ```
*
*     is a function which accepts two strided input arrays containing single-precision floating-point numbers and whose results are cast as single-precision floating-point numbers. However, the callback requires each pair of single-precision floating-point numbers be cast to double-precision floating-point numbers when provided as arguments, and the callback return value is a double-precision floating-point number. Accordingly, the conversion process would be
*
*     ```text
*     float in1 -> double in1
*     float in2 -> double in2
*     double out1 = f( in1, in2 )
*     float out1 <- double out1
*     ```
*
* -   The functions included in this file are **not** exhaustive and that is intentional. Namely, with few exceptions, functions which convert nullary callback return values to a different type are not included (e.g., widening an `int16` to an `int32`). Nullary functions should be simple enough that this can be handled in userland via function wrappers which return the desired types.
*/
#include <stdint.h>
#include "stdlib/strided_nullary_typedefs.h"
#include "stdlib/strided_nullary_macros.h"

/**
* Invokes a nullary callback function for each element in a strided output array.
*
* @param arrays   array whose first element is a pointer to the output array
* @param dims     array whose first element is the number of elements over which to iterate
* @param strides  array whose first element is the stride of the output array (in bytes)
* @param f        callback function
*
* @example
* // Assuming little endian...
* uint8_t out[] = { 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 8, 64 };
*
* // Define a pointer to an array containing pointers to strided arrays:
* uint8_t *arrays[] = { out };
*
* // Define the strides:
* int64_t strides[] = { 8 }; // 8 bytes per double
*
* // Define the number of elements over which to iterate:
* int64_t dims[] = { 3 };
*
* // Define a callback function:
* double ones() {
*    return 1.0;
* }
*
* // Fill the output array with ones:
* stdlib_strided_d( arrays, dims, strides, ones );
*/
void stdlib_strided_d( uint8_t *arrays[], int64_t *dims, int64_t *strides, NullaryFcnFloat64 *f ) {
	STDLIB_NULLARY_LOOP_CLBK( double )
}

void stdlib_strided_f( uint8_t *arrays[], int64_t *dims, int64_t *strides, NullaryFcnFloat32 *f ) {
	STDLIB_NULLARY_LOOP_CLBK( float )
}

void stdlib_strided_f_as_d( uint8_t *arrays[], int64_t *dims, int64_t *strides, NullaryFcnFloat64 *f ) {
	STDLIB_NULLARY_LOOP_CLBK( float )
}

{'fraction_non_alphanumeric': 0.0982823195144001, 'fraction_numerical': 0.020147229755908564, 'mean_word_length': 3.7190737355271177, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2490990', 'n_tokens_mistral': 2482, 'n_tokens_neox': 2349, 'n_words': 920}