<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2020 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.
*/

/**
* Header file containing strided array macros.
*/
#ifndef STDLIB_STRIDED_BASE_MSKUNARY_MACROS_H
#define STDLIB_STRIDED_BASE_MSKUNARY_MACROS_H

#include <stdint.h>

/**
* Macro containing the preamble for a loop which operates on strided array elements according to a strided mask array.
*
* @example
* STDLIB_STRIDED_MSKUNARY_LOOP_PREMABLE {
*     // Loop body...
* }
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE              \
	uint8_t *ip1 = arrays[ 0 ];                            \
	uint8_t *mp1 = arrays[ 1 ];                            \
	uint8_t *op1 = arrays[ 2 ];                            \
	int64_t is1 = strides[ 0 ];                            \
	int64_t ms1 = strides[ 1 ];                            \
	int64_t os1 = strides[ 2 ];                            \
	int64_t n = shape[ 0 ];                                \
	int64_t i;                                             \
	if ( n <= 0 ) {                                        \
		return;                                            \
	}                                                      \
	if ( is1 < 0 ) {                                       \
		ip1 += (1-n) * is1;                                \
	}                                                      \
	if ( ms1 < 0 ) {                                       \
		mp1 += (1-n) * ms1;                                \
	}                                                      \
	if ( os1 < 0 ) {                                       \
		op1 += (1-n) * os1;                                \
	}                                                      \
	for ( i = 0; i < n; i++, ip1 += is1, mp1 += ms1, op1 += os1 )

/**
* Macro containing the preamble for a loop which operates on strided array elements according to a strided mask array and updates two strided output arrays.
*
* @example
* STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREMABLE {
*     // Loop body...
* }
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREAMBLE      \
	uint8_t *ip1 = arrays[ 0 ];                            \
	uint8_t *mp1 = arrays[ 1 ];                            \
	uint8_t *op1 = arrays[ 2 ];                            \
	uint8_t *op2 = arrays[ 3 ];                            \
	int64_t is1 = strides[ 0 ];                            \
	int64_t ms1 = strides[ 1 ];                            \
	int64_t os1 = strides[ 2 ];                            \
	int64_t os2 = strides[ 3 ];                            \
	int64_t n = shape[ 0 ];                                \
	int64_t i;                                             \
	if ( n <= 0 ) {                                        \
		return;                                            \
	}                                                      \
	if ( is1 < 0 ) {                                       \
		ip1 += (1-n) * is1;                                \
	}                                                      \
	if ( ms1 < 0 ) {                                       \
		mp1 += (1-n) * ms1;                                \
	}                                                      \
	if ( os1 < 0 ) {                                       \
		op1 += (1-n) * os1;                                \
	}                                                      \
	if ( os2 < 0 ) {                                       \
		op2 += (1-n) * os2;                                \
	}                                                      \
	for ( i = 0; i < n; i++, ip1 += os1, mp1 += ms1, op1 += os1, op2 += os2 )

/**
* Macro for a unary loop which inlines an expression.
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via the pointer `ip1` as `in1`.
* -   Creates a pointer `tout *out` to the output strided array element.
* -   Expects a provided expression to operate on `tin in1` and to store the result in `tout *out`.
*
* @param tin   input type
* @param tout  output type
* @param expr  expression to inline
*
* @example
* STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( double, double, *out = in1 * in1 )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( tin, tout, expr )     \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                        \
		if ( *(uint8_t *)mp1 ) {                                   \
			continue;                                              \
		}                                                          \
		const tin in1 = *(tin *)ip1;                               \
		tout *out = (tout *)op1;                                   \
		expr;                                                      \
	}

/**
* Macro for a unary loop which invokes a callback.
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via the pointer `ip1`.
* -   Explicitly casts each function `f` invocation result to `tout`.
* -   Stores the result in an output strided array via the pointer `op1`.
*
* @param tin   input type
* @param tout  output type
*
* @example
* // e.g., d_d
* STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( double, double )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( tin, tout )     \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                \
		if ( *(uint8_t *)mp1 ) {                           \
			continue;                                      \
		}                                                  \
		const tin x = *(tin *)ip1;                         \
		*(tout *)op1 = (tout)f( x );                       \
	}

/**
* Macro for a unary loop which invokes a callback and does not cast the return callback's return value (e.g., a `struct`).
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via a pointer `ip1`.
* -   Stores the result in an output strided array of type `tout` via the pointer `op1`.
*
* @param tin   input type
* @param tout  output type
*
* @example
* #include "stdlib/complex/float64.h"
*
* // e.g., z_z
* STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_RET_NOCAST( stdlib_complex128_t, stdlib_complex128_t )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_RET_NOCAST( tin, tout )           \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                                    \
		if ( *(uint8_t *)mp1 ) {                                               \
			continue;                                                          \
		}                                                                      \
		const tin x = *(tin *)ip1;                                             \
		*(tout *)op1 = f( x );                                                 \
	}

/**
* Macro for a unary loop which invokes a callback requiring arguments be explicitly cast to a different type.
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via the pointer `ip1`.
* -   Explicitly casts each function argument to `fin`.
* -   Explicitly casts each function `f` invocation result to `tout`.
* -   Stores the result in an output strided array via the pointer `op1`.
*
* @param tin   input type
* @param tout  output type
* @param fin   callback argument type
*
* @example
* // e.g., f_f_as_d_d
* STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( float, float, double )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( tin, tout, fin )  \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                           \
		if ( *(uint8_t *)mp1 ) {                                      \<commit_msg>Add spaces to align continuations<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2020 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.
*/

/**
* Header file containing strided array macros.
*/
#ifndef STDLIB_STRIDED_BASE_MSKUNARY_MACROS_H
#define STDLIB_STRIDED_BASE_MSKUNARY_MACROS_H

#include <stdint.h>

/**
* Macro containing the preamble for a loop which operates on strided array elements according to a strided mask array.
*
* @example
* STDLIB_STRIDED_MSKUNARY_LOOP_PREMABLE {
*     // Loop body...
* }
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE              \
	uint8_t *ip1 = arrays[ 0 ];                            \
	uint8_t *mp1 = arrays[ 1 ];                            \
	uint8_t *op1 = arrays[ 2 ];                            \
	int64_t is1 = strides[ 0 ];                            \
	int64_t ms1 = strides[ 1 ];                            \
	int64_t os1 = strides[ 2 ];                            \
	int64_t n = shape[ 0 ];                                \
	int64_t i;                                             \
	if ( n <= 0 ) {                                        \
		return;                                            \
	}                                                      \
	if ( is1 < 0 ) {                                       \
		ip1 += (1-n) * is1;                                \
	}                                                      \
	if ( ms1 < 0 ) {                                       \
		mp1 += (1-n) * ms1;                                \
	}                                                      \
	if ( os1 < 0 ) {                                       \
		op1 += (1-n) * os1;                                \
	}                                                      \
	for ( i = 0; i < n; i++, ip1 += is1, mp1 += ms1, op1 += os1 )

/**
* Macro containing the preamble for a loop which operates on strided array elements according to a strided mask array and updates two strided output arrays.
*
* @example
* STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREMABLE {
*     // Loop body...
* }
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREAMBLE      \
	uint8_t *ip1 = arrays[ 0 ];                            \
	uint8_t *mp1 = arrays[ 1 ];                            \
	uint8_t *op1 = arrays[ 2 ];                            \
	uint8_t *op2 = arrays[ 3 ];                            \
	int64_t is1 = strides[ 0 ];                            \
	int64_t ms1 = strides[ 1 ];                            \
	int64_t os1 = strides[ 2 ];                            \
	int64_t os2 = strides[ 3 ];                            \
	int64_t n = shape[ 0 ];                                \
	int64_t i;                                             \
	if ( n <= 0 ) {                                        \
		return;                                            \
	}                                                      \
	if ( is1 < 0 ) {                                       \
		ip1 += (1-n) * is1;                                \
	}                                                      \
	if ( ms1 < 0 ) {                                       \
		mp1 += (1-n) * ms1;                                \
	}                                                      \
	if ( os1 < 0 ) {                                       \
		op1 += (1-n) * os1;                                \
	}                                                      \
	if ( os2 < 0 ) {                                       \
		op2 += (1-n) * os2;                                \
	}                                                      \
	for ( i = 0; i < n; i++, ip1 += os1, mp1 += ms1, op1 += os1, op2 += os2 )

/**
* Macro for a unary loop which inlines an expression.
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via the pointer `ip1` as `in1`.
* -   Creates a pointer `tout *out` to the output strided array element.
* -   Expects a provided expression to operate on `tin in1` and to store the result in `tout *out`.
*
* @param tin   input type
* @param tout  output type
* @param expr  expression to inline
*
* @example
* STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( double, double, *out = in1 * in1 )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( tin, tout, expr )     \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                        \
		if ( *(uint8_t *)mp1 ) {                                   \
			continue;                                              \
		}                                                          \
		const tin in1 = *(tin *)ip1;                               \
		tout *out = (tout *)op1;                                   \
		expr;                                                      \
	}

/**
* Macro for a unary loop which invokes a callback.
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via the pointer `ip1`.
* -   Explicitly casts each function `f` invocation result to `tout`.
* -   Stores the result in an output strided array via the pointer `op1`.
*
* @param tin   input type
* @param tout  output type
*
* @example
* // e.g., d_d
* STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( double, double )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( tin, tout )     \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                \
		if ( *(uint8_t *)mp1 ) {                           \
			continue;                                      \
		}                                                  \
		const tin x = *(tin *)ip1;                         \
		*(tout *)op1 = (tout)f( x );                       \
	}

/**
* Macro for a unary loop which invokes a callback and does not cast the return callback's return value (e.g., a `struct`).
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via a pointer `ip1`.
* -   Stores the result in an output strided array of type `tout` via the pointer `op1`.
*
* @param tin   input type
* @param tout  output type
*
* @example
* #include "stdlib/complex/float64.h"
*
* // e.g., z_z
* STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_RET_NOCAST( stdlib_complex128_t, stdlib_complex128_t )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_RET_NOCAST( tin, tout )              \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                                    \
		if ( *(uint8_t *)mp1 ) {                                               \
			continue;                                                          \
		}                                                                      \
		const tin x = *(tin *)ip1;                                             \
		*(tout *)op1 = f( x );                                                 \
	}

/**
* Macro for a unary loop which invokes a callback requiring arguments be explicitly cast to a different type.
*
* ## Notes
*
* -   Retrieves each strided array element according to type `tin` via the pointer `ip1`.
* -   Explicitly casts each function argument to `fin`.
* -   Explicitly casts each function `f` invocation result to `tout`.
* -   Stores the result in an output strided array via the pointer `op1`.
*
* @param tin   input type
* @param tout  output type
* @param fin   callback argument type
*
* @example
* // e.g., f_f_as_d_d
* STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( float, float, double )
*/
#define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( tin, tout, fin )  \
	STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE {                           \
		if ( *(uint8_t *)mp1 ) {                                      \
{'fraction_non_alphanumeric': 0.08972979813959375, 'fraction_numerical': 0.0197430867556793, 'mean_word_length': 1.070754716981132, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 125, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6022122', 'n_tokens_mistral': 4710, 'n_tokens_neox': 4420, 'n_words': 1286}