<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.
*/

/**
* Copy values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.
*
* This add-on provides an interface to the BLAS Level 1 routine `ccopy`.
*
* @see <a href="http://www.netlib.org/lapack/explore-html/da/df6/group__complex__blas__level1.html">ccopy</a>
*/
#include "stdlib/blas/base/ccopy.h"
#include <node_api.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

/**
* Add-on namespace.
*/
namespace stdlib_blas_base_ccopy {

	/**
	* Copies values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.
	*
	* ## Notes
	*
	* -   When called from JavaScript, the function expects five arguments:
	*
	*     -   `N`: number of indexed elements
	*     -   `X`: input array
	*     -   `strideX`: `X` stride length
	*     -   `Y`: destination array
	*     -   `strideY`: `Y` stride length
	*/
	napi_value node_ccopy( napi_env env, napi_callback_info info ) {
		napi_status status;

		size_t argc = 5;
		napi_value argv[ 5 ];
		status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
		assert( status == napi_ok );

		if ( argc < 5 ) {
			napi_throw_error( env, nullptr, "invalid invocation. Must provide 5 arguments." );
			return nullptr;
		}

		napi_valuetype vtype0;
		status = napi_typeof( env, argv[ 0 ], &vtype0 );
		assert( status == napi_ok );
		if ( vtype0 != napi_number ) {
			napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
			return nullptr;
		}

		bool res1;
		status = napi_is_typedarray( env, argv[ 1 ], &res1 );
		assert( status == napi_ok );
		if ( res1 == false ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
			return nullptr;
		}

		napi_valuetype vtype2;
		status = napi_typeof( env, argv[ 2 ], &vtype2 );
		assert( status == napi_ok );
		if ( vtype2 != napi_number ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." );
			return nullptr;
		}

		bool res3;
		status = napi_is_typedarray( env, argv[ 3 ], &res3 );
		assert( status == napi_ok );
		if ( res3 == false ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float32Array." );
			return nullptr;
		}

		napi_valuetype vtype4;
		status = napi_typeof( env, argv[ 4 ], &vtype4 );
		assert( status == napi_ok );
		if ( vtype4 != napi_number ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a number." );
			return nullptr;
		}

		int64_t N;
		status = napi_get_value_int64( env, argv[ 0 ], &N );
		assert( status == napi_ok );

		int64_t strideX;
		status = napi_get_value_int64( env, argv[ 2 ], &strideX );
		assert( status == napi_ok );

		int64_t strideY;
		status = napi_get_value_int64( env, argv[ 4 ], &strideY );
		assert( status == napi_ok );

		napi_typedarray_type vtype1;
		size_t xlen;
		void *X;
		status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr );
		assert( status == napi_ok );
		if ( vtype1 != napi_float32_array ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
			return nullptr;
		}
		if ( 2*(N-1)*llabs(strideX) > (int64_t)xlen ) {
			napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." );
			return nullptr;
		}

		napi_typedarray_type vtype3;
		size_t ylen;
		void *Y;
		status = napi_get_typedarray_info( env, argv[ 3 ], &vtype3, &ylen, &Y, nullptr, nullptr );
		assert( status == napi_ok );
		if ( vtype3 != napi_float32_array ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float32Array." );
			return nullptr;
		}
		if ( 2*(N-1)*llabs(strideY) > (int64_t)ylen ) {
			napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." );
			return nullptr;
		}

		c_ccopy( N, X, strideX, Y, strideY );

		return nullptr;
	}

	napi_value Init( napi_env env, napi_value exports ) {
		napi_status status;
		napi_value fcn;
		status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_ccopy, NULL, &fcn );
		assert( status == napi_ok );
		return fcn;
	}

	NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
} // end namespace stdlib_blas_base_ccopy
<commit_msg>Fix error messages<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.
*/

/**
* Copy values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.
*
* This add-on provides an interface to the BLAS Level 1 routine `ccopy`.
*
* @see <a href="http://www.netlib.org/lapack/explore-html/da/df6/group__complex__blas__level1.html">ccopy</a>
*/
#include "stdlib/blas/base/ccopy.h"
#include <node_api.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

/**
* Add-on namespace.
*/
namespace stdlib_blas_base_ccopy {

	/**
	* Copies values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.
	*
	* ## Notes
	*
	* -   When called from JavaScript, the function expects five arguments:
	*
	*     -   `N`: number of indexed elements
	*     -   `X`: input array
	*     -   `strideX`: `X` stride length
	*     -   `Y`: destination array
	*     -   `strideY`: `Y` stride length
	*/
	napi_value node_ccopy( napi_env env, napi_callback_info info ) {
		napi_status status;

		size_t argc = 5;
		napi_value argv[ 5 ];
		status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
		assert( status == napi_ok );

		if ( argc < 5 ) {
			napi_throw_error( env, nullptr, "invalid invocation. Must provide 5 arguments." );
			return nullptr;
		}

		napi_valuetype vtype0;
		status = napi_typeof( env, argv[ 0 ], &vtype0 );
		assert( status == napi_ok );
		if ( vtype0 != napi_number ) {
			napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
			return nullptr;
		}

		bool res1;
		status = napi_is_typedarray( env, argv[ 1 ], &res1 );
		assert( status == napi_ok );
		if ( res1 == false ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
			return nullptr;
		}

		napi_valuetype vtype2;
		status = napi_typeof( env, argv[ 2 ], &vtype2 );
		assert( status == napi_ok );
		if ( vtype2 != napi_number ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." );
			return nullptr;
		}

		bool res3;
		status = napi_is_typedarray( env, argv[ 3 ], &res3 );
		assert( status == napi_ok );
		if ( res3 == false ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float32Array." );
			return nullptr;
		}

		napi_valuetype vtype4;
		status = napi_typeof( env, argv[ 4 ], &vtype4 );
		assert( status == napi_ok );
		if ( vtype4 != napi_number ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a number." );
			return nullptr;
		}

		int64_t N;
		status = napi_get_value_int64( env, argv[ 0 ], &N );
		assert( status == napi_ok );

		int64_t strideX;
		status = napi_get_value_int64( env, argv[ 2 ], &strideX );
		assert( status == napi_ok );

		int64_t strideY;
		status = napi_get_value_int64( env, argv[ 4 ], &strideY );
		assert( status == napi_ok );

		napi_typedarray_type vtype1;
		size_t xlen;
		void *X;
		status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr );
		assert( status == napi_ok );
		if ( vtype1 != napi_float32_array ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
			return nullptr;
		}
		if ( 2*(N-1)*llabs(strideX) > (int64_t)xlen ) {
			napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." );
			return nullptr;
		}

		napi_typedarray_type vtype3;
		size_t ylen;
		void *Y;
		status = napi_get_typedarray_info( env, argv[ 3 ], &vtype3, &ylen, &Y, nullptr, nullptr );
		assert( status == napi_ok );
		if ( vtype3 != napi_float32_array ) {
			napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float32Array." );
			return nullptr;
		}
		if ( 2*(N-1)*llabs(strideY) > (int64_t)ylen ) {
			napi_throw_range_error( env, nullptr, "invalid argument. Fourth argument has insufficient elements based on the associated stride and the number of indexed elements." );
			return nullptr;
		}

		c_ccopy( N, X, strideX, Y, strideY );

		return nullptr;
	}

	napi_value Init( napi_env env, napi_value exports ) {
		napi_status status;
		napi_value fcn;
		status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_ccopy, NULL, &fcn );
		assert( status == napi_ok );
		return fcn;
	}

	NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
} // end namespace stdlib_blas_base_ccopy

{'fraction_non_alphanumeric': 0.11385606874328678, 'fraction_numerical': 0.015623474270090811, 'mean_word_length': 3.7927000467945717, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5008010', 'n_tokens_mistral': 3841, 'n_tokens_neox': 3488, 'n_words': 1080}