diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/README__md.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/README__md.txt new file mode 100644 index 000000000000..3c13b714365f --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/README__md.txt @@ -0,0 +1,229 @@ + + +# {{ALIAS}} + +> {{README_PKG_DESC}} + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var {{ALIAS}} = require( '@{{PKG}}' ); +``` + +#### {{ALIAS}}( x\[, options] ) + +{{README_MAIN_DESC}} + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +var y = {{ALIAS}}( x ); +// returns + +var arr = ndarray2array( y ); +// returns {{JS_EXAMPLE_RESULTS_2X2}} +``` + +The function accepts the following arguments: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dtype**: output ndarray [data type][@stdlib/ndarray/dtypes]. Must be a real-valued or generic [data type][@stdlib/ndarray/dtypes]. +- **order**: output ndarray [order][@stdlib/ndarray/orders] (i.e., memory layout). + +By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [data type][@stdlib/ndarray/dtypes] determined by the function's output data type [policy][@stdlib/ndarray/output-dtype-policies]. To override the default behavior, set the `dtype` option. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); +var getDType = require( '@stdlib/ndarray/dtype' ); + +var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +var y = {{ALIAS}}( x, { + 'dtype': 'generic' +}); +// returns + +var dt = getDType( y ); +// returns 'generic' + +var arr = ndarray2array( y ); +// returns {{JS_EXAMPLE_RESULTS_2X2}} +``` + +By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having the same [order][@stdlib/ndarray/orders] as the input [ndarray][@stdlib/ndarray/ctor]. To return an [ndarray][@stdlib/ndarray/ctor] having a specific memory layout irrespective of the memory layout of the input [ndarray][@stdlib/ndarray/ctor], set the `order` option. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); +var getOrder = require( '@stdlib/ndarray/order' ); + +var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +var y = {{ALIAS}}( x, { + 'order': 'column-major' +}); +// returns + +var ord = getOrder( y ); +// returns 'column-major' + +var arr = ndarray2array( y ); +// returns {{JS_EXAMPLE_RESULTS_2X2}} +``` + +#### {{ALIAS}}.assign( x, y ) + +{{README_ASSIGN_DESC}} + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); + +var out = {{ALIAS}}.assign( x, y ); +// returns + +var bool = ( out === y ); +// returns true + +var arr = ndarray2array( out ); +// returns {{JS_EXAMPLE_RESULTS_2X2}} +``` + +The function accepts the following arguments: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape of the output [ndarray][@stdlib/ndarray/ctor]. +- **y**: output [ndarray][@stdlib/ndarray/ctor]. + +The function supports broadcasting an input [ndarray][@stdlib/ndarray/ctor] to the shape of the output [ndarray][@stdlib/ndarray/ctor] without performing a physical copy of the input [ndarray][@stdlib/ndarray/ctor]'s underlying data. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var array = require( '@stdlib/ndarray/array' ); + +// Create a 2x2 input ndarray: +var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); + +// Create a 2x2x2 output ndarray: +var y = zeros( [ 2, 2, 2 ] ); + +var out = {{ALIAS}}.assign( x, y ); +// returns + +var arr = ndarray2array( out ); +// returns [ {{JS_EXAMPLE_RESULTS_2X2}}, {{JS_EXAMPLE_RESULTS_2X2}} ] +``` + +
+ + + + + +
+ +## Notes + +- The output data type [policy][@stdlib/ndarray/output-dtype-policies] only applies to the main function and specifies that, by default, the function must return an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. For the `assign` method, the output [ndarray][@stdlib/ndarray/ctor] is allowed to have any supported output [data type][@stdlib/ndarray/dtypes]. + +
+ + + + + +
+ +## Examples + + + +```javascript +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var {{ALIAS}} = require( '@{{PKG}}' ); + +var x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}} ); +console.log( ndarray2array( x ) ); + +var y = {{ALIAS}}( x ); +console.log( ndarray2array( y ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous__js.txt new file mode 100644 index 000000000000..1f02ebfdea05 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous__js.txt @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var {{ALIAS}} = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous__native__js.txt new file mode 100644 index 000000000000..6093ff417fb1 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous__native__js.txt @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous_assign__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous_assign__js.txt new file mode 100644 index 000000000000..853e5933a9cf --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous_assign__js.txt @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var {{ALIAS}} = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var options; + var x; + var y; + + options = { + 'dtype': dtype + }; + x = random( [ size ], {{RAND_MIN}}, {{RAND_MAX}}, options ); + y = zeros( [ size ], options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = {{ALIAS}}.assign( x, y ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( z )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:assign:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous_assign__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous_assign__native__js.txt new file mode 100644 index 000000000000..a546c7e4e3ef --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__1d_contiguous_assign__native__js.txt @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var options; + var x; + var y; + + options = { + 'dtype': dtype + }; + x = random( [ size ], {{RAND_MIN}}, {{RAND_MAX}}, options ); + y = zeros( [ size ], options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = {{ALIAS}}.assign( x, y ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( z )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:assign:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_contiguous__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_contiguous__js.txt new file mode 100644 index 000000000000..840c763ab0d1 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_contiguous__js.txt @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var {{ALIAS}} = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size/2, 2, 1 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=true,ndims=3,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_contiguous__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_contiguous__native__js.txt new file mode 100644 index 000000000000..58f964a33342 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_contiguous__native__js.txt @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size/2, 2, 1 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=true,ndims=3,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_noncontiguous__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_noncontiguous__js.txt new file mode 100644 index 000000000000..ff58562cd34a --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_noncontiguous__js.txt @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/array/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var {{ALIAS}} = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var buf; + var x; + + buf = random( size*2, {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + x = new ndarray( dtype, buf, [ size/2, 2, 1 ], [ 4, 1, 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=false,ndims=3,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_noncontiguous__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_noncontiguous__native__js.txt new file mode 100644 index 000000000000..097733eed77b --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_noncontiguous__native__js.txt @@ -0,0 +1,127 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/array/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var buf; + var x; + + buf = random( size*2, {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + x = new ndarray( dtype, buf, [ size/2, 2, 1 ], [ 4, 1, 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=false,ndims=3,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_singleton_dims__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_singleton_dims__js.txt new file mode 100644 index 000000000000..21dbf39b6365 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_singleton_dims__js.txt @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var {{ALIAS}} = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size, 1, 1 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=false,ndims=3,singleton_dims=2,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_singleton_dims__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_singleton_dims__native__js.txt new file mode 100644 index 000000000000..9ac64481a6a1 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/benchmark/benchmark__nd_singleton_dims__native__js.txt @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size, 1, 1 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = {{ALIAS}}( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=false,ndims=3,singleton_dims=2,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/binding__gyp.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/binding__gyp.txt new file mode 100644 index 000000000000..f98b002d4798 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/binding__gyp.txt @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) {{YEAR}} {{COPYRIGHT}}. +# +# 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99' + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11' + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/repl__txt.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/repl__txt.txt new file mode 100644 index 000000000000..af3a1373947d --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/repl__txt.txt @@ -0,0 +1,67 @@ + +{{alias}}( x[, options] ) + {{REPL_TEXT_MAIN_DESC}} + + The function returns an ndarray having the same shape as the input ndarray. + + Parameters + ---------- + x: ndarray + Input array. Must have a numeric or "generic" data type. + + options: Object (optional) + Options. + + options.dtype: string|DataType (optional) + Output array data type. Must be a real-valued or "generic" data type. + + options.order: string (optional) + Output array order. Must be either row-major (C-style) or column-major + (Fortran-style). By default, the order of the output array is the same + as the input array. + + Returns + ------- + y: ndarray + Output array containing element-wise results. + + Examples + -------- + > var arr = {{JS_EXAMPLE_VALUES_2X2}}; + > var x = {{alias:@stdlib/ndarray/array}}( arr ); + > var y = {{alias}}( x ); + > {{alias:@stdlib/ndarray/to-array}}( y ) + {{JS_EXAMPLE_RESULTS_2X2}} + + +{{alias}}.assign( x, y ) + {{REPL_TEXT_ASSIGN_DESC}} + + Parameters + ---------- + x: ndarray + Input array. Must have a numeric or "generic" data type. + + y: ndarray + Output array. + + Returns + ------- + y: ndarray + Output array. + + Examples + -------- + > var arr = {{JS_EXAMPLE_VALUES_2X2}}; + > var x = {{alias:@stdlib/ndarray/array}}( arr ); + > var sh = {{alias:@stdlib/ndarray/shape}}( x ); + > var y = {{alias:@stdlib/ndarray/zeros}}( sh ); + > var out = {{alias}}.assign( x, y ); + > var bool = ( out === y ) + true + > {{alias:@stdlib/ndarray/to-array}}( y ) + {{JS_EXAMPLE_RESULTS_2X2}} + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/types/index__d__ts.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/types/index__d__ts.txt new file mode 100644 index 000000000000..9305a43d5184 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/types/index__d__ts.txt @@ -0,0 +1,146 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { typedndarray, {{NDARRAY_IMPORT_TYPES}}, genericndarray, RealAndGenericDataType as DataType, Order } from '@stdlib/types/ndarray'; + +/** +* Input array. +*/ +type InputArray = {{INPUT_NDARRAY_TYPE}} | genericndarray; + +/** +* Output array. +*/ +type OutputArray = {{OUTPUT_NDARRAY_TYPE}} | genericndarray; + +/** +* Interface describing options. +*/ +interface Options { + /** + * Output array order. + * + * ## Notes + * + * - By default, the order of the output array is the same as the input array. + */ + order?: Order; + + /** + * Output array data type. + */ + dtype?: DataType; +} + +/** +* Interface describing a unary element-wise function. +*/ +interface UnaryFunction { + /** + * {{MAIN_DESC}} + * + * @param x - input ndarray + * @param options - options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); + * // returns + * + * var y = {{ALIAS}}( x ); + * // returns + * + * var arr = ndarray2array( y ); + * // returns {{JS_EXAMPLE_RESULTS_2X2}} + */ + ( x: InputArray, options?: Options ): typedndarray; // FIXME: we lose type specificity here, as the output ndarray data type is determined according to the output data type policy in conjunction with the `dtype` option + + /** + * {{ASSIGN_DESC}} + * + * @param x - input ndarray + * @param y - output ndarray + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); + * var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); + * + * var z = {{ALIAS}}.assign( x, y ); + * // returns + * + * var bool = ( z === y ); + * // returns true + * + * var arr = ndarray2array( y ); + * // returns {{JS_EXAMPLE_RESULTS_2X2}} + */ + assign( x: InputArray, y: T ): T; +} + +/** +* {{MAIN_DESC}} +* +* @param x - input ndarray +* @param options - options +* @returns output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +* +* var y = {{ALIAS}}( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns {{JS_EXAMPLE_RESULTS_2X2}} +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +* var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); +* +* var z = {{ALIAS}}.assign( x, y ); +* // returns +* +* var bool = ( z === y ); +* // returns true +* +* var arr = ndarray2array( y ); +* // returns {{JS_EXAMPLE_RESULTS_2X2}} +*/ +declare var {{ALIAS}}: UnaryFunction; + + +// EXPORTS // + +export = {{ALIAS}}; diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/types/test__ts.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/types/test__ts.txt new file mode 100644 index 000000000000..142379ddd00e --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/docs/types/test__ts.txt @@ -0,0 +1,154 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import {{ALIAS}} = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}( x ); // $ExpectType typedndarray + {{ALIAS}}( x, {} ); // $ExpectType typedndarray + {{ALIAS}}( x, { 'dtype': 'float32' } ); // $ExpectType typedndarray + {{ALIAS}}( x, { 'order': 'row-major' } ); // $ExpectType typedndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + {{ALIAS}}( '5' ); // $ExpectError + {{ALIAS}}( 5 ); // $ExpectError + {{ALIAS}}( true ); // $ExpectError + {{ALIAS}}( false ); // $ExpectError + {{ALIAS}}( null ); // $ExpectError + {{ALIAS}}( void 0 ); // $ExpectError + {{ALIAS}}( [] ); // $ExpectError + {{ALIAS}}( {} ); // $ExpectError + {{ALIAS}}( [ '5' ] ); // $ExpectError + {{ALIAS}}( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a valid options object... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}( x, '5' ); // $ExpectError + {{ALIAS}}( x, true ); // $ExpectError + {{ALIAS}}( x, false ); // $ExpectError + {{ALIAS}}( x, [ '5' ] ); // $ExpectError + {{ALIAS}}( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dtype` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}( x, { 'dtype': '5' } ); // $ExpectError + {{ALIAS}}( x, { 'dtype': true } ); // $ExpectError + {{ALIAS}}( x, { 'dtype': false } ); // $ExpectError + {{ALIAS}}( x, { 'dtype': null } ); // $ExpectError + {{ALIAS}}( x, { 'dtype': {} } ); // $ExpectError + {{ALIAS}}( x, { 'dtype': [ '5' ] } ); // $ExpectError + {{ALIAS}}( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `order` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}( x, { 'order': '5' } ); // $ExpectError + {{ALIAS}}( x, { 'order': true } ); // $ExpectError + {{ALIAS}}( x, { 'order': false } ); // $ExpectError + {{ALIAS}}( x, { 'order': null } ); // $ExpectError + {{ALIAS}}( x, { 'order': {} } ); // $ExpectError + {{ALIAS}}( x, { 'order': [ '5' ] } ); // $ExpectError + {{ALIAS}}( x, { 'order': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}(); // $ExpectError + {{ALIAS}}( x, {}, {} ); // $ExpectError +} + +// Attached to the main function is an `assign` method which returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}.assign( x, x ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}.assign( '5', x ); // $ExpectError + {{ALIAS}}.assign( true, x ); // $ExpectError + {{ALIAS}}.assign( false, x ); // $ExpectError + {{ALIAS}}.assign( null, x ); // $ExpectError + {{ALIAS}}.assign( void 0, x ); // $ExpectError + {{ALIAS}}.assign( {}, x ); // $ExpectError + {{ALIAS}}.assign( ( x: number ): number => x, x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}.assign( x, '5' ); // $ExpectError + {{ALIAS}}.assign( x, true ); // $ExpectError + {{ALIAS}}.assign( x, false ); // $ExpectError + {{ALIAS}}.assign( x, null ); // $ExpectError + {{ALIAS}}.assign( x, void 0 ); // $ExpectError + {{ALIAS}}.assign( x, {} ); // $ExpectError + {{ALIAS}}.assign( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + {{ALIAS}}.assign(); // $ExpectError + {{ALIAS}}.assign( x ); // $ExpectError + {{ALIAS}}.assign( x, x, x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/examples/index__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/examples/index__js.txt new file mode 100644 index 000000000000..0af3a5623ea0 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/examples/index__js.txt @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var {{ALIAS}} = require( './../lib' ); + +var x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}} ); +console.log( ndarray2array( x ) ); + +var y = {{ALIAS}}( x ); +console.log( ndarray2array( y ) ); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/include__gypi.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/include__gypi.txt new file mode 100644 index 000000000000..9fad714bbcf4 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/include__gypi.txt @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) {{YEAR}} {{COPYRIGHT}}. +# +# 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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' +* +* var y = {{ALIAS}}( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns {{JS_EXAMPLE_RESULTS_2X2}} +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var javascript = require( './main.js' ); + + +// MAIN // + +var main; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( tmp instanceof Error ) { + main = javascript; +} else { + main = tmp; +} + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/lib/main__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/lib/main__js.txt new file mode 100644 index 000000000000..f0b5e50131ed --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/lib/main__js.txt @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var dispatch = require( '@stdlib/ndarray/dispatch' ); +var setProps = require( '@stdlib/ndarray/base/meta-data-props' ); +var ufunc = require( '@stdlib/math/tools/unary' ); +var unary = require( '@stdlib/ndarray/base/unary' ); +var data = require( './data.js' ); +var types = require( './types.json' ); +var config = require( './config.js' ); + + +// MAIN // + +/** +* {{MAIN_DESC}} +* +* @name {{ALIAS}} +* @type {Function} +* @param {ndarray} x - input ndarray +* @param {Options} [options] - options +* @param {string} [options.order] - output array order +* @param {*} [options.dtype] - output array dtype +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @returns {ndarray} output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +* // returns +* +* var y = {{ALIAS}}( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns {{JS_EXAMPLE_RESULTS_2X2}} +*/ +var {{ALIAS}} = ufunc( dispatch( unary, types, data, config.nargs, config.nin, config.nout ), [ config.idtypes ], config.odtypes, config.policies ); +setProps( config, types, {{ALIAS}} ); +setProps( config, types, {{ALIAS}}.assign ); + + +// EXPORTS // + +module.exports = {{ALIAS}}; diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/lib/native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/lib/native__js.txt new file mode 100644 index 000000000000..20e083e0b2b3 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/lib/native__js.txt @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var dispatch = require( '@stdlib/ndarray/base/unary-addon-dispatch' ); +var setProps = require( '@stdlib/ndarray/base/meta-data-props' ); +var ufunc = require( '@stdlib/math/tools/unary' ); +var addon = require( './../src/addon.node' ); +var types = require( './types.json' ); +var config = require( './config.js' ); +var fallback = require( './main.js' ).assign; + + +// MAIN // + +/** +* {{MAIN_DESC}} +* +* @name {{ALIAS}} +* @type {Function} +* @param {ndarray} x - input ndarray +* @param {Options} [options] - options +* @param {string} [options.order] - output array order +* @param {*} [options.dtype] - output array dtype +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @returns {ndarray} output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( {{JS_EXAMPLE_VALUES_2X2}} ); +* // returns +* +* var y = {{ALIAS}}( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns {{JS_EXAMPLE_RESULTS_2X2}} +*/ +var {{ALIAS}} = ufunc( dispatch( addon, fallback ), [ config.idtypes ], config.odtypes, config.policies ); +setProps( config, types, {{ALIAS}} ); +setProps( config, types, {{ALIAS}}.assign ); + + +// EXPORTS // + +module.exports = {{ALIAS}}; diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/manifest__json.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/manifest__json.txt new file mode 100644 index 000000000000..a67eb638d11e --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/manifest__json.txt @@ -0,0 +1,42 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + {{PKG_DEPS}}, + "@stdlib/ndarray/base/function-object", + "@stdlib/ndarray/base/napi/unary", + "@stdlib/ndarray/base/unary", + "@stdlib/ndarray/dtypes" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/package__json.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/package__json.txt new file mode 100644 index 000000000000..080bba60cdff --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/package__json.txt @@ -0,0 +1,65 @@ +{ + "name": "@{{PKG}}", + "version": "0.0.0", + "description": "{{PKG_DESC}}", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "ndarray", + "elementwise", + "element-wise",{{KEYWORDS}} + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/src/Makefile.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/src/Makefile.txt new file mode 100644 index 000000000000..a64cc31f1b68 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/src/Makefile.txt @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) {{YEAR}} {{COPYRIGHT}}. +# +# 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__assign__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__assign__js.txt new file mode 100644 index 000000000000..ab514ddbf589 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__assign__js.txt @@ -0,0 +1,136 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var base = require( '@stdlib/math/base/special/{{ALIAS}}' ); +var {{ALIAS}} = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof {{ALIAS}}, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( typeof {{ALIAS}}.assign, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var y; + var i; + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}.assign( value, y ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}.assign( x, value ); + }; + } +}); + +tape( 'the function {{TEST_DESC}} for each element in an ndarray and assigns the results to a provided output ndarray', function test( t ) { + var expected; + var out; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64' + }); + y = zeros( getShape( x ), { + 'dtype': 'float64' + }); + out = {{ALIAS}}.assign( x, y ); + + expected = map( x, naryFunction( base, 1 ) ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( ndarray2array( out ), ndarray2array( expected ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__assign__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__assign__native__js.txt new file mode 100644 index 000000000000..3f0568c356ed --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__assign__native__js.txt @@ -0,0 +1,145 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var base = require( '@stdlib/math/base/special/{{ALIAS}}' ); + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof {{ALIAS}}, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', opts, function test( t ) { + t.strictEqual( typeof {{ALIAS}}.assign, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', opts, function test( t ) { + var values; + var y; + var i; + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}.assign( value, y ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}.assign( x, value ); + }; + } +}); + +tape( 'the function {{TEST_DESC}} for each element in an ndarray and assigns the results to a provided output ndarray', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64' + }); + y = zeros( getShape( x ), { + 'dtype': 'float64' + }); + out = {{ALIAS}}.assign( x, y ); + + expected = map( x, naryFunction( base, 1 ) ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( ndarray2array( out ), ndarray2array( expected ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__js.txt new file mode 100644 index 000000000000..7762e5eb27ae --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__js.txt @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dtypes2signatures = require( '@stdlib/ndarray/base/dtypes2signatures' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var types = require( './../lib/types.json' ); +var config = require( './../lib/config.js' ); +var fcn = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fcn, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var fcn = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( fcn, mock, 'returns native implementation' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var main; + var fcn; + + main = require( './../lib/main.js' ); + + fcn = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( fcn, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); + +tape( 'attached to the main export is a property for retrieving the number of input and output arrays', function test( t ) { + t.strictEqual( fcn.nargs, config.nargs, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a property for retrieving the number of input arrays', function test( t ) { + t.strictEqual( fcn.nin, config.nin, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a property for retrieving the number of output arrays', function test( t ) { + t.strictEqual( fcn.nout, config.nout, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a property for retrieving the list of supported array data types', function test( t ) { + t.deepEqual( fcn.types, dtypes2signatures( types, config.nin, config.nout ), 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method for assigning results to a provided output array', function test( t ) { + t.strictEqual( hasProp( fcn, 'assign' ), true, 'returns expected value' ); + t.strictEqual( typeof fcn.assign, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the number of input and output arrays', function test( t ) { + t.strictEqual( fcn.assign.nargs, config.nargs, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the number of input arrays', function test( t ) { + t.strictEqual( fcn.assign.nin, config.nin, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the number of output arrays', function test( t ) { + t.strictEqual( fcn.assign.nout, config.nout, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the list of supported array data types', function test( t ) { + t.deepEqual( fcn.assign.types, dtypes2signatures( types, config.nin, config.nout ), 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__main__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__main__js.txt new file mode 100644 index 000000000000..bef0fd034fb1 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__main__js.txt @@ -0,0 +1,284 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var base = require( '@stdlib/math/base/special/{{ALIAS}}' ); +var {{ALIAS}} = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof {{ALIAS}}, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `dtype` option', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( x, { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `order` option', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( x, { + 'order': value + }); + }; + } +}); + +tape( 'the function {{TEST_DESC}} for each element in an ndarray', function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64' + }); + y = {{ALIAS}}( x ); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray data type', function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64' + }); + y = {{ALIAS}}( x, { + 'dtype': 'generic' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.strictEqual( getDType( y ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray order', function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64', + 'order': 'row-major' + }); + y = {{ALIAS}}( x, { + 'order': 'column-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'column-major', 'returns expected value' ); + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64', + 'order': 'column-major' + }); + y = {{ALIAS}}( x, { + 'order': 'row-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'row-major', 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__main__native__js.txt b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__main__native__js.txt new file mode 100644 index 000000000000..38ddae439751 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/data/test/test__main__native__js.txt @@ -0,0 +1,293 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/{{BASE_PRNG}}' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var base = require( '@stdlib/math/base/special/{{ALIAS}}' ); + + +// VARIABLES // + +var {{ALIAS}} = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( {{ALIAS}} instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof {{ALIAS}}, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', opts, function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', opts, function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an object', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `dtype` option', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( x, { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `order` option', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + {{ALIAS}}( x, { + 'order': value + }); + }; + } +}); + +tape( 'the function {{TEST_DESC}} for each element in an ndarray', opts, function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64' + }); + y = {{ALIAS}}( x ); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray data type', opts, function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64' + }); + y = {{ALIAS}}( x, { + 'dtype': 'generic' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.strictEqual( getDType( y ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray order', opts, function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64', + 'order': 'row-major' + }); + y = {{ALIAS}}( x, { + 'order': 'column-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'column-major', 'returns expected value' ); + + x = random( [ 5, 5 ], {{RAND_MIN}}, {{RAND_MAX}}, { + 'dtype': 'float64', + 'order': 'column-major' + }); + y = {{ALIAS}}( x, { + 'order': 'row-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'row-major', 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/dtype_ndarray_mappings.json b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/dtype_ndarray_mappings.json new file mode 100644 index 000000000000..8e9d08e70082 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/dtype_ndarray_mappings.json @@ -0,0 +1,12 @@ +{ + "input_dtypes": { + "numeric_and_generic": "realcomplexndarray", + "real_and_generic": "realndarray" + }, + "output_dtypes": { + "floating_point_and_generic": "floatcomplexndarray", + "numeric_and_generic": "realcomplexndarray", + "real_and_generic": "realndarray", + "real_floating_point_and_generic": "floatndarray" + } +} diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/generate_files.js b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/generate_files.js new file mode 100644 index 000000000000..3a7e3f2410b3 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/generate_files.js @@ -0,0 +1,455 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable max-lines */ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var currentYear = require( '@stdlib/time/current-year' ); +var capitalize = require( '@stdlib/string/capitalize' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var str2enum = require( '@stdlib/ndarray/base/dtype-str2enum' ); +var generateDtypes = require( './script.js' ); + + +// FUNCTIONS // + +/** +* Groups matches by input data type and returns grouped data, input types, and reordered matches. +* +* @private +* @param {Array} matches - array of match arrays +* @returns {Object} object containing grouped matches, input types, and reordered matches +*/ +function groupMatchesByInputType( matches ) { + var reorderedMatches = []; + var inputTypes = []; + var inputType; + var grouped = {}; + var i; + var j; + + for ( i = 0; i < matches.length; i++ ) { + inputType = matches[ i ][ 0 ]; + if ( !grouped[ inputType ] ) { + grouped[ inputType ] = []; + inputTypes.push( inputType ); + } + grouped[ inputType ].push( matches[ i ][ 1 ] ); + } + + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + for ( j = 0; j < matches.length; j++ ) { + if ( matches[ j ][ 0 ] === inputType ) { + reorderedMatches.push( matches[ j ] ); + } + } + } + + return { + 'grouped': grouped, + 'inputTypes': inputTypes, + 'reorderedMatches': reorderedMatches + }; +} + +/** +* Generates the types.js file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @returns {string} types.js file content +*/ +function generateTypesFile( matches, header ) { + var outputTypes; + var inputTypes; + var inputType; + var grouped; + var result; + var jsOut; + var i; + var j; + + jsOut = header; + jsOut += '\n'; + jsOut += '/* eslint-disable array-element-newline */\n\n'; + jsOut += '\'use strict\';\n\n'; + jsOut += '// MODULES //\n\n'; + jsOut += 'var dtypes = require( \'@stdlib/ndarray/dtypes\' );\n\n\n'; + jsOut += '// MAIN //\n\n'; + jsOut += 'var types = [\n'; + + // Group matches by input dtype: + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + inputTypes = result.inputTypes; + + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + jsOut += '\tdtypes.' + inputType + '.enum, dtypes.' + outputTypes[ j ] + '.enum'; + if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { + jsOut += ',\n'; + } else { + jsOut += '\n'; + } + } + + // Blank line between input type groups: + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\n'; + return jsOut; +} + +/** +* Generates the types.json file content. +* +* @private +* @param {Array} matches - array of match entries +* @returns {string} types.json file content +*/ +function generateTypesJsonFile( matches ) { + var typeEnums; + var result; + var i; + + typeEnums = []; + for ( i = 0; i < matches.length; i++ ) { + typeEnums.push( str2enum( matches[ i ][ 0 ] ) ); + typeEnums.push( str2enum( matches[ i ][ 1 ] ) ); + } + + result = JSON.stringify( typeEnums ) + '\n'; + return result; +} + +/** +* Generates the data.js file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @returns {string} data.js file content +*/ +function generateDataFile( matches, header ) { + var uniquePackages; + var packageKeys; + var outputTypes; + var importName; + var inputTypes; + var matchIndex; + var packageMap; + var inputType; + var grouped; + var pkgPath; + var result; + var parts; + var dtype; + var jsOut; + var i; + var j; + var k; + + uniquePackages = {}; + packageMap = {}; + + for ( i = 0; i < matches.length; i++ ) { + pkgPath = matches[ i ][ 2 ]; + if ( !hasOwnProp( uniquePackages, pkgPath ) ) { + uniquePackages[ pkgPath ] = true; + if ( pkgPath.indexOf( '/identity' ) === -1 ) { + importName = pkgPath.split( '/' ).pop(); + } else { + // For identity functions, include dtype in the name: + parts = pkgPath.split( '/' ); + dtype = parts[ parts.length - 3 ]; // For example, 'int32' from '@stdlib/number/int32/base/identity' + importName = 'identity' + capitalize( dtype ); + } + packageMap[ pkgPath ] = importName; + } + } + + jsOut = header; + jsOut += '\n/* eslint-disable stdlib/capitalized-comments */\n\n'; + jsOut += '\'use strict\';\n\n'; + jsOut += '// MODULES //\n\n'; + + // Add imports for all unique packages: + packageKeys = objectKeys( uniquePackages ); + for ( i = 0; i < packageKeys.length; i++ ) { + pkgPath = packageKeys[ i ]; + importName = packageMap[ pkgPath ]; + jsOut += 'var ' + importName + ' = require( \'' + pkgPath + '\' );\n'; + } + + jsOut += '\n\n// MAIN //\n\n'; + jsOut += 'var data = [\n'; + jsOut += '\t// NOTE: the following **must** match the order in `./types.js`. The order should be according to likelihood of use (e.g., if `float64` arrays are more likely, then `float64` types/data should come before `uint8`).\n\n'; + + // Group matches by input dtype: + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + inputTypes = result.inputTypes; + + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + jsOut += '\t// ' + inputType + '\n'; + + for ( j = 0; j < outputTypes.length; j++ ) { + matchIndex = 0; + for ( k = 0; k < matches.length; k++ ) { + if ( matches[ k ][ 0 ] === inputType && + matches[ k ][ 1 ] === outputTypes[ j ] ) { + matchIndex = k; + break; + } + } + pkgPath = matches[ matchIndex ][ 2 ]; + importName = packageMap[ pkgPath ]; + jsOut += '\t' + importName; + if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { + jsOut += ',\n'; + } else { + jsOut += '\n'; + } + } + + // Blank line between input type groups: + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = data;\n'; + return jsOut; +} + +/** +* Generates the addon.c file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @param {string} basePkg - base package name +* @returns {string} addon.c file content +*/ +function generateAddonFile( matches, header, basePkg ) { + var uniqueIncludes; + var functionIndex; + var outputTypes; + var includePath; + var kernelPath; + var inputType; + var grouped; + var result; + var cOut; + var i; + var j; + + // Generate unique includes... + uniqueIncludes = {}; + for ( i = 0; i < matches.length; i++ ) { + // Extract the full package path from the scalar kernel path: + kernelPath = matches[ i ][ 2 ]; + includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; + uniqueIncludes[ '#include "' + includePath + '"' ] = true; + } + + // Group matches by input type: + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + matches = result.reorderedMatches; + + cOut = header; + cOut += Object.keys( uniqueIncludes ).join( '\n' ) + '\n'; + cOut += '#include "stdlib/ndarray/base/function_object.h"\n'; + cOut += '#include "stdlib/ndarray/base/napi/unary.h"\n'; + cOut += '#include "stdlib/ndarray/base/unary.h"\n'; + cOut += '#include "stdlib/ndarray/dtypes.h"\n'; + cOut += '#include \n\n'; + cOut += '// Define an interface name:\n'; + cOut += 'static const char name[] = "stdlib_ndarray_' + basePkg + '";\n\n'; + cOut += '// Define a list of ndarray functions:\n'; + cOut += 'static ndarrayFcn functions[] = {\n'; + + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\t' + matches[ functionIndex ][ 7 ]; + functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } + } + cOut += '\n'; + } + cOut += '};\n\n'; + cOut += '// Define the array of input and output ndarray types:\n'; + cOut += 'static int32_t types[] = {\n'; + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase(); + functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } + } + cOut += '\n'; + } + cOut += '};\n\n'; + cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; + cOut += 'static void *data[] = {\n'; + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ]; + functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } + } + cOut += '\n'; + } + cOut += '};\n\n'; + cOut += '// Create an ndarray function object:\n'; + cOut += 'static const struct ndarrayFunctionObject obj = {\n'; + cOut += '\t// ndarray function name:\n'; + cOut += '\tname,\n\n'; + cOut += '\t// Number of input ndarrays:\n'; + cOut += '\t1,\n\n'; + cOut += '\t// Number of output ndarrays:\n'; + cOut += '\t1,\n\n'; + cOut += '\t// Total number of ndarray arguments (nin + nout):\n'; + cOut += '\t2,\n\n'; + cOut += '\t// Array containing ndarray functions:\n'; + cOut += '\tfunctions,\n\n'; + cOut += '\t// Number of ndarray functions:\n'; + cOut += '\t' + matches.length + ',\n\n'; + cOut += '\t// Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function:\n'; + cOut += '\ttypes,\n\n'; + cOut += '\t// Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions):\n'; + cOut += '\tdata\n'; + cOut += '};\n\n'; + cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; + return cOut; +} + + +// MAIN // + +/** +* Generates scaffold files for a math special unary function. +* +* @param {string} basePkg - base package name +* @param {string} destDir - destination directory +*/ +function generateFiles( basePkg, destDir ) { + var filteredMatches; + var typesJsonOut; + var dataOut; + var matches; + var header; + var jsOut; + var cOut; + var i; + + // Generate and filter matches table: + matches = generateDtypes( basePkg ); + + // Filter out generic types for addon.c: + filteredMatches = []; + for ( i = 0; i < matches.length; i++ ) { + if ( matches[ i ][ 0 ] !== 'generic' && matches[ i ][ 1 ] !== 'generic' ) { + filteredMatches.push( matches[ i ] ); + } + } + + // Generate license header: + header = licenseHeader( 'Apache-2.0', 'js', { + 'year': currentYear(), + 'copyright': 'The Stdlib Authors' + }); + header += '\n/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */\n'; + + // Generate types.js: + jsOut = generateTypesFile( matches, header ); + writeFileSync( join( destDir, 'lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate types.json: + typesJsonOut = generateTypesJsonFile( matches ); + writeFileSync( join( destDir, 'lib/types.json' ), typesJsonOut, { + 'encoding': 'utf8' + }); + + // Generate data.js: + dataOut = generateDataFile( matches, header ); + writeFileSync( join( destDir, 'lib/data.js' ), dataOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( filteredMatches, header, basePkg ); + writeFileSync( join( destDir, 'src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// EXPORTS // + +module.exports = generateFiles; diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/runner.js b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/runner.js new file mode 100644 index 000000000000..7503afa9ba2b --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/runner.js @@ -0,0 +1,462 @@ +#!/usr/bin/env node + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable indent */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var shell = require( 'child_process' ).execSync; // eslint-disable-line node/no-sync +var objectKeys = require( '@stdlib/utils/keys' ); +var isInteger = require( '@stdlib/math/base/assert/is-integer' ); +var slice = require( '@stdlib/array/slice' ); +var join = require( '@stdlib/array/base/join' ); +var capitalize = require( '@stdlib/string/capitalize' ); +var round = require( '@stdlib/math/base/special/round' ); +var DATA = require( '@stdlib/math/special/data/unary.json' ); +var FUNCTION_DATABASE = require( '@stdlib/math/special/data/unary_function_database.json' ); +var DTYPE_MAPPINGS = require( './dtype_ndarray_mappings.json' ); + + +// VARIABLES // + +var SCAFFOLD_SCRIPT = resolve( __dirname, 'scaffold.sh' ); + + +// FUNCTIONS // + +/** +* Returns a string containing environment variable for generating pseudorandom numbers. +* +* @private +* @param {Object} obj - configuration object +* @returns {string} environment variable string +* +* @example +* var o = { +* 'prng': 'random/base/uniform', +* 'parameters': [ -10, 10 ] +* }; +* +* var s = prngEnvVars( o ); +* // returns 'BASE_PRNG=\'uniform\',RAND_MIN=-10,RAND_MAX=10' +*/ +function prngEnvVars( obj ) { + var base; + var min; + var max; + var p; + + p = obj.prng.split( '/' ); + base = p[ p.length-1 ]; + min = obj.parameters[ 0 ]; + max = obj.parameters[ 1 ]; + if ( base === 'uniform' ) { + if ( isInteger( min ) ) { + min = min.toString() + '.0'; + } + if ( isInteger( max ) ) { + max = max.toString() + '.0'; + } + } else { + min = min.toString(); + max = max.toString(); + } + return [ + 'BASE_PRNG=\'' + base + '\'', + 'RAND_MIN=' + min, + 'RAND_MAX=' + max + ].join( ' ' ); +} + +/** +* Returns an `ALIAS` environment variable string. +* +* @private +* @param {string} alias - package alias +* @returns {string} environment variable string +* +* @example +* var s = aliasEnvVar( 'abs' ); +* // returns 'ALIAS=abs' +* +* @example +* var s = aliasEnvVar( 'absf' ); +* // returns 'ALIAS=absf' +*/ +function aliasEnvVar( alias ) { + return 'ALIAS=' + alias; +} + +/** +* Returns a string containing example values for a 2x2 array environment variable. +* +* @private +* @param {Array} values - example values +* @returns {string} environment variable string +* +* @example +* var exampleValues = [ 1.9, 4.8, 6.0, 8.1 ]; +* var out = jsExampleValues2x2EnvVar( exampleValues ); +* // returns "JS_EXAMPLE_VALUES_2X2='[ [ 1.9, 4.8 ], [ 6.0, 8.1 ] ]'" +*/ +function jsExampleValues2x2EnvVar( values ) { + var bottomRow; + var topRow; + var vals; + var v; + var i; + + vals = []; + for ( i = 0; i < 4; i++ ) { + v = values[ i ]; + vals.push( v.toString() ); + } + topRow = join( slice( vals, 0, 2 ), ', ' ); + bottomRow = join( slice( vals, 2, 4 ), ', ' ); + return 'JS_EXAMPLE_VALUES_2X2=\'[ [ ' + topRow + ' ], [ ' + bottomRow + ' ] ]\''; +} + +/** +* Returns a string containing example results for a 2x2 array environment variable. +* +* @private +* @param {Array} values - input values +* @param {string} functionAlias - function alias (e.g., 'sin', 'sqrt', 'abs') +* @returns {string} environment variable string +* +* @example +* var exampleValues = [ 0.0, 1.57, 3.14, 4.71 ]; +* var out = jsExampleResults2x2EnvVar( exampleValues, 'sin' ); +* // returns "JS_EXAMPLE_RESULTS_2X2='[ [ 0.0, 1.0 ], [ -0.0, -1.0 ] ]'" +*/ +function jsExampleResults2x2EnvVar( values, functionAlias ) { + var bottomRow; + var results; + var topRow; + var func; + var vals; + var v; + var i; + + func = require( '@stdlib/math/base/special/' + functionAlias ); // eslint-disable-line stdlib/no-dynamic-require + vals = []; + for ( i = 0; i < 4; i++ ) { + v = values[ i ]; + results = func( v ); + results = round( results * 100 ) / 100; // Rounding results to 2 decimal places + vals.push( '~' + results.toString() ); + } + topRow = join( slice( vals, 0, 2 ), ', ' ); + bottomRow = join( slice( vals, 2, 4 ), ', ' ); + return 'JS_EXAMPLE_RESULTS_2X2=\'[ [ ' + topRow + ' ], [ ' + bottomRow + ' ] ]\''; +} + +/** +* Returns the assign export description environment variable. +* +* @private +* @param {string} desc - function description +* @returns {string} environment variable string +*/ +function assignDescEnvVar( desc ) { + return 'ASSIGN_DESC=\'' + capitalize( escapeBashString( desc ) + ' for each element in an ndarray and assigns results to a provided output ndarray.' ) + '\''; +} + +/** +* Returns the input ndarray type environment variable. +* @private +* @param {string} dtypes - input dtypes +* @returns {string} environment variable string +*/ +function inputNdarrayTypeEnvVar( dtypes ) { + var ndarrayType; + + ndarrayType = DTYPE_MAPPINGS.input_dtypes[ dtypes ] || dtypes; + return 'INPUT_NDARRAY_TYPE=\'' + ndarrayType + '\''; +} + +/** +* Returns the output ndarray type environment variable. +* +* @private +* @param {string} dtypes - output dtypes +* @returns {string} environment variable string +*/ +function outputNdarrayTypeEnvVar( dtypes ) { + var ndarrayType; + + ndarrayType = DTYPE_MAPPINGS.output_dtypes[ dtypes ] || dtypes; + return 'OUTPUT_NDARRAY_TYPE=\'' + ndarrayType + '\''; +} + +/** +* Returns the ndarray import types environment variable. +* +* @private +* @param {string} inputDtypes - input dtypes +* @param {string} outputDtypes - output dtypes +* @returns {string} environment variable string +*/ +function ndarrayImportTypesEnvVar( inputDtypes, outputDtypes ) { + var outputNdarrayType; + var inputNdarrayType; + var importTypes; + + inputNdarrayType = DTYPE_MAPPINGS.input_dtypes[ inputDtypes ] || + inputDtypes; + outputNdarrayType = DTYPE_MAPPINGS.output_dtypes[ outputDtypes ] || + outputDtypes; + + // If both types are the same, they must be imported only once: + if ( inputNdarrayType === outputNdarrayType ) { + importTypes = inputNdarrayType; + } else { + importTypes = inputNdarrayType + ', ' + outputNdarrayType; + } + + return 'NDARRAY_IMPORT_TYPES=\'' + importTypes + '\''; +} + +/** +* Returns the package name environment variable. +* +* @private +* @param {string} pkg - package name +* @returns {string} environment variable string +*/ +function pkgEnvVar( pkg ) { + return 'PKG=\'@stdlib/math/special/' + pkg + '\''; +} + +/** +* Escapes single quotes in a string for bash environment variables. +* +* @private +* @param {string} str - input string +* @returns {string} escaped string +*/ +function escapeBashString( str ) { + return str.replace( /'/g, "'\\''" ); +} + +/** +* Returns the package dependencies environment variable. +* +* @private +* @param {string} pkg - function name (e.g., 'abs') +* @returns {string} environment variable string +* +* @example +* var deps = pkgDepsEnvVar( 'abs' ); +* // returns 'PKG_DEPS="@stdlib/math/base/special/abs", "@stdlib/math/base/special/absf", ...' +*/ +function pkgDepsEnvVar( pkg ) { + var scalarKernels; + var kernelPaths; + var depsString; + var kernelPath; + var funcData; + var keys; + var i; + + funcData = FUNCTION_DATABASE[ pkg ]; + if ( !funcData || !funcData.scalar_kernels ) { + return 'PKG_DEPS=\'\''; + } + + // Using the scalar kernels to compute the dependencies: + scalarKernels = funcData.scalar_kernels; + keys = Object.keys( scalarKernels ); + kernelPaths = []; + + for ( i = 0; i < keys.length; i++ ) { + kernelPath = scalarKernels[ keys[ i ] ]; + if ( kernelPath.startsWith( '/' ) ) { + kernelPath = '@stdlib' + kernelPath; + } + + // Avoiding duplicate dependencies (duplicate scalar kernels can exist, but not duplicate dependencies): + if ( kernelPaths.indexOf( '"' + kernelPath + '"' ) === -1 ) { + kernelPaths.push( '"' + kernelPath + '"' ); + } + } + + depsString = kernelPaths.join( ',\n ' ); + return 'PKG_DEPS=\'' + depsString + '\''; +} + +/** +* Returns the README package description environment variable. +* +* @private +* @param {string} desc - function description +* @param {string} pkg - package name +* @returns {string} environment variable string +* +* @example +* var envVar = readmePkgDescEnvVar( 'absolute value', '@stdlib/math/base/special/abs' ); +* // returns "README_PKG_DESC='Compute the [absolute value][@stdlib/math/base/special/abs] for each element in an [ndarray][@stdlib/ndarray/ctor].'" +*/ +function readmePkgDescEnvVar( desc, pkg ) { + var result; + + result = 'Compute the [' + desc + '][' + pkg + '] for each element in an [ndarray][@stdlib/ndarray/ctor].'; + return 'README_PKG_DESC=\'' + result + '\''; +} + +/** +* Returns the README main description environment variable. +* +* @private +* @param {string} desc - function description +* @param {string} pkg - package name +* @returns {string} environment variable string +* +* @example +* var envVar = readmeMainDescEnvVar( 'absolute value', '@stdlib/math/base/special/abs' ); +* // returns "README_MAIN_DESC='Computes the [absolute value][@stdlib/math/base/special/abs] for each element in an [ndarray][@stdlib/ndarray/ctor].'" +*/ +function readmeMainDescEnvVar( desc, pkg ) { + var result; + + result = 'Computes the [' + desc + '][' + pkg + '] for each element in an [ndarray][@stdlib/ndarray/ctor].'; + return 'README_MAIN_DESC=\'' + result + '\''; +} + +/** +* Returns the README assign description environment variable. +* +* @private +* @param {string} desc - function description +* @param {string} pkg - package name +* @returns {string} environment variable string +* +* @example +* var envVar = readmeAssignDescEnvVar( 'absolute value', '@stdlib/math/base/special/abs' ); +* // returns "README_ASSIGN_DESC='Computes the [absolute value][@stdlib/math/base/special/abs] ffor each element in an [ndarray][@stdlib/ndarray/ctor] and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].'" +*/ +function readmeAssignDescEnvVar( desc, pkg ) { + var result; + + result = 'Computes the [' + desc + '][' + pkg + '] for each element in an [ndarray][@stdlib/ndarray/ctor] and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].'; + return 'README_ASSIGN_DESC=\'' + result + '\''; +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var scalarKernelPath; + var outputDtypes; + var inputDtypes; + var moduleDesc; + var baseAlias; + var testDesc; + var funcData; + var keywords; + var dataKeys; + var mainDesc; + var pkgDesc; + var dataKey; + var param; + var alias; + var envs; + var cmd; + var o; + var i; // eslint-disable-line no-unused-vars + + // Get all function entries from unary.json database (these are the packages we want to generate)... + dataKeys = objectKeys( DATA ); // eslint-disable-line no-unused-vars + + // for ( i = 0; i < dataKeys.length; i++ ) { + + // dataKey = dataKeys[ i ]; + dataKey = '@stdlib/math/base/special/acosd'; + o = DATA[ dataKey ]; + alias = o.alias; + console.log( 'Processing function: %s...', alias ); // eslint-disable-line no-console + envs = []; + + envs.push( aliasEnvVar( o.alias ) ); + envs.push( pkgEnvVar( o.alias ) ); + envs.push( 'PKG_PATH=\'stdlib/math/special\'' ); + + pkgDesc = 'Compute the ' + o.short_desc + ' for each element in an ndarray.'; + moduleDesc = 'Compute the ' + o.short_desc + '.'; + mainDesc = 'Computes the ' + o.short_desc + ' for each element in an ndarray.'; + testDesc = 'computes the ' + o.short_desc + ' for each element in an ndarray'; + + envs.push( 'DESC=\'' + escapeBashString( o.short_desc ) + '\'' ); + envs.push( 'PKG_DESC=\'' + escapeBashString( pkgDesc ) + '\'' ); + envs.push( 'MODULE_DESC=\'' + escapeBashString( moduleDesc ) + '\'' ); + envs.push( 'MAIN_DESC=\'' + escapeBashString( mainDesc ) + '\'' ); + envs.push( assignDescEnvVar( pkgDesc ) ); + envs.push( 'TEST_DESC=\'' + escapeBashString( testDesc ) + '\'' ); + envs.push( readmePkgDescEnvVar( o.short_desc, dataKey ) ); + envs.push( readmeMainDescEnvVar( o.short_desc, dataKey ) ); + envs.push( readmeAssignDescEnvVar( o.short_desc, dataKey ) ); + envs.push( 'PKG_LINK_SUFFIX=\'' + dataKey.replace( /^@/, '' ) + '\'' ); + + param = o.parameters[ 0 ]; + envs.push( jsExampleValues2x2EnvVar( param.example_values ) ); + envs.push( jsExampleResults2x2EnvVar( param.example_values, alias ) ); + scalarKernelPath = '@stdlib/math/base/special/' + o.alias; + envs.push( 'SCALAR_KERNEL_PATH=\'' + scalarKernelPath + '\'' ); + envs.push( prngEnvVars( param.rand ) ); + keywords = o.keywords || []; + if ( o.extra_keywords ) { + keywords = keywords.concat( o.extra_keywords ); + } + envs.push( 'KEYWORDS=\'' + keywords.join( ',' ) + '\'' ); + envs.push( 'YEAR=\'' + new Date().getFullYear() + '\'' ); + envs.push( 'COPYRIGHT=\'The Stdlib Authors\'' ); + + baseAlias = o.base_alias || o.alias; + funcData = FUNCTION_DATABASE[ baseAlias ]; + inputDtypes = ( funcData ) ? funcData.input_dtypes : 'numeric_and_generic'; + outputDtypes = ( funcData ) ? funcData.output_dtypes : 'real_and_generic'; + + if ( funcData ) { + envs.push( 'INPUT_DTYPES=\'' + funcData.input_dtypes + '\'' ); + envs.push( 'OUTPUT_DTYPES=\'' + funcData.output_dtypes + '\'' ); + envs.push( 'OUTPUT_POLICY=\'' + funcData.policies.output + '\'' ); + envs.push( 'CASTING_POLICY=\'' + funcData.policies.casting + '\'' ); + } + + envs.push( ndarrayImportTypesEnvVar( inputDtypes, outputDtypes ) ); + envs.push( inputNdarrayTypeEnvVar( inputDtypes ) ); + envs.push( outputNdarrayTypeEnvVar( outputDtypes ) ); + envs.push( pkgDepsEnvVar( baseAlias ) ); + + cmd = envs.join( ' ' ) + ' . ' + SCAFFOLD_SCRIPT; + shell( cmd ); + + // } +} + +main(); diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/scaffold.sh b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/scaffold.sh new file mode 100755 index 000000000000..c533fb51254f --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/scaffold.sh @@ -0,0 +1,388 @@ +#!/usr/bin/env bash +# +# @license Apache-2.0 +# +# Copyright (c) 2025 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. + +# Script for scaffolding a package applying a unary mathematical function to each element in an ndarray. +# +# Usage: scaffold.h +# +# Environment Variables: +# +# ALIAS Main export alias. +# DESC Default description. +# PKG_DESC Package description. +# MODULE_DESC Module description. +# MAIN_DESC Main export description. +# TEST_DESC Test description. +# KEYWORDS List of keywords. +# BASE_PRNG Base name of the package for generating pseudorandom numbers. +# RAND_MIN Minimum value for generated values. +# RAND_MAX Maximum value for generated values. +# ASSIGN_DESC Assign function description. +# SCALAR_KERNEL_PATH Path to scalar kernel package. +# JS_EXAMPLE_VALUES_2X2 JavaScript example values for 2x2 array. +# JS_EXAMPLE_RESULTS_2X2 JavaScript example results for 2x2 array. +# INPUT_DTYPES Input data types. +# OUTPUT_DTYPES Output data types. +# OUTPUT_POLICY Output policy. +# CASTING_POLICY Casting policy. +# INPUT_NDARRAY_TYPE Input ndarray type. +# OUTPUT_NDARRAY_TYPE Output ndarray type. +# NDARRAY_IMPORT_TYPES Ndarray import types. +# PKG_DEPS Package dependencies. +# README_PKG_DESC Package description for the README. +# README_ASSIGN_DESC Assign function description for the README. +# README_MAIN_DESC Main export description for the README. +# PKG_LINK_SUFFIX Suffix to append to the unary package link. + +## USER-DEFINED VARIABLES ## + +# Define the main export alias: +alias=${ALIAS:-'TODO'} + +# Define the package description: +# shellcheck disable=SC2016 +pkg_desc=${PKG_DESC:-"${DESC:-'TODO'} for each element in an ndarray."} + +# Define the module description: +# shellcheck disable=SC2016 +module_desc=${MODULE_DESC:-"${DESC:-'TODO'} for each element in an ndarray."} + +# Define main export description: +# shellcheck disable=SC2016 +main_desc=${MAIN_DESC:-"${DESC:-'TODO'} for each element in an ndarray."} + +# Define the test description: +# shellcheck disable=SC2016 +test_desc=${TEST_DESC:-"the function ${DESC:-'TODO'} for each element in an ndarray."} + +# Define the assign description: +# shellcheck disable=SC2016 +assign_desc=${ASSIGN_DESC:-"${DESC:-'TODO'} for each element in an ndarray and assigns results to a provided output ndarray."} + +# Define the package description (found in the README): +readme_pkg_desc=${README_PKG_DESC:-"${pkg_desc}"} + +# Define the assign function description (found in the README): +readme_assign_desc=${README_ASSIGN_DESC:-"${assign_desc}"} + +# Define the main export description (found in the README): +readme_main_desc=${README_MAIN_DESC:-"${main_desc}"} + +# Define a list of keywords: +if [[ -z "${KEYWORDS:-}" ]]; then +keywords=( + "stdmath" + "mathematics" + "math" +) +else + IFS=','; read -ra keywords <<< "${KEYWORDS}"; IFS=' '; +fi + +# Define a pseudorandom number generator for generating random values: +base_prng=${BASE_PRNG:-'uniform'} + +# Define the minimum value of generated values when benchmarking and testing the implementation: +rand_min=${RAND_MIN:-'-10.0'} + +# Define the maximum value of generated values when benchmarking and testing the implementation: +rand_max=${RAND_MAX:-'10.0'} + +# Define the scalar kernel path for the base function: +scalar_kernel_path=${SCALAR_KERNEL_PATH:-'@stdlib/math/base/special/TODO'} + +# Define JavaScript example values and results for 2x2 arrays: +js_example_values_2x2=${JS_EXAMPLE_VALUES_2X2:-'[ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]'} +js_example_results_2x2=${JS_EXAMPLE_RESULTS_2X2:-'[ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]'} + +# Define input and output data type configurations: +input_dtypes=${INPUT_DTYPES:-'numeric_and_generic'} +output_dtypes=${OUTPUT_DTYPES:-'real_and_generic'} + +# Define policies: +output_policy=${OUTPUT_POLICY:-'same'} +casting_policy=${CASTING_POLICY:-'none'} + +# Define TypeScript ndarray types: +input_ndarray_type=${INPUT_NDARRAY_TYPE:-'realndarray'} +output_ndarray_type=${OUTPUT_NDARRAY_TYPE:-'realndarray'} +ndarray_import_types=${NDARRAY_IMPORT_TYPES:-'realndarray'} + +# Define package dependencies and link suffix: +pkg_deps=${PKG_DEPS:-''} +pkg_link_suffix=${PKG_LINK_SUFFIX:-''} + + +## COMPUTED VARIABLES ## + +# Converts from camel case to a underscored delineated string. +# +# $1 - string to convert +camelcase_to_snakecase() { + echo "$1" | sed 's/\([^A-Z]\)\([A-Z]\)/\1_\2/g' | sed 's/\([A-Z]\)\([A-Z]\)\([^A-Z]\)/\1_\2\3/g' | tr '[:upper:]' '[:lower:]' +} + +# Convert the alias to snakecase: +alias_snakecase=$(camelcase_to_snakecase "${alias}") + +# Define the destination package alias: +pkg_alias="${alias_snakecase//_/-}" + +# Define the destination package parent directory path: +pkg_path="${PKG_PATH:-'stdlib/math/special'}" + +# Define the full destination package name: +pkg="${pkg_path}/${pkg_alias}" + +# Determine the root project directory: +root_dir="$(git rev-parse --show-toplevel)" + +# Define the project source code directory: +base_dir="${root_dir}/lib/node_modules" + +# Define the destination path: +dest_dir="${base_dir}/@${pkg}" + +# Define the location of this scaffold: +this_dir="${base_dir}/@stdlib/_tools/scaffold/math-special-unary" + +# Define the location of a utility for wrapping REPL text descriptions: +wrap="${base_dir}/@stdlib/_tools/repl-txt/wrap-desc/bin/cli" + +# Define the REPL text main export description (note: 4 space indent and wrap at 80 characters): +repl_text_main_desc=$(printf "%s" "${main_desc}" | "${wrap}") +repl_text_main_desc="${repl_text_main_desc/ /}" + +# Define the REPL text assign export description (note: 4 space indent and wrap at 80 characters): +repl_text_assign_desc=$(printf "%s" "${assign_desc}" | "${wrap}") +repl_text_assign_desc="${repl_text_assign_desc/ /}" + +# Define the copyright year: +year=${YEAR:-$(date +'%Y')} + +# Define the copyright holders: +copyright=${COPYRIGHT:-'The Stdlib Authors'} + + +## SCRIPT ## + +# Define the list of scaffold directories: +dirs=( + "benchmark" + "docs" + "docs/types" + "examples" + "lib" + "src" + "test" +) + +# Define the list of scaffold files: +files=( + "benchmark/benchmark.1d_contiguous.js" + "benchmark/benchmark.1d_contiguous.native.js" + "benchmark/benchmark.1d_contiguous_assign.js" + "benchmark/benchmark.1d_contiguous_assign.native.js" + "benchmark/benchmark.nd_contiguous.js" + "benchmark/benchmark.nd_contiguous.native.js" + "benchmark/benchmark.nd_noncontiguous.js" + "benchmark/benchmark.nd_noncontiguous.native.js" + "benchmark/benchmark.nd_singleton_dims.js" + "benchmark/benchmark.nd_singleton_dims.native.js" + "docs/types/index.d.ts" + "docs/types/test.ts" + "docs/repl.txt" + "examples/index.js" + "lib/index.js" + "lib/main.js" + "lib/native.js" + "lib/config.js" + "test/test.js" + "test/test.assign.js" + "test/test.assign.native.js" + "test/test.main.js" + "test/test.main.native.js" + "package.json" + "README.md" + "binding.gyp" + "include.gypi" + "manifest.json" + "src/Makefile" +) + +# Create the destination directories... +# shellcheck disable=SC2048 +for dir in ${dirs[*]}; do + mkdir -p "${dest_dir}/${dir}" +done + +# Copy the scaffold files to the destination directory... +# shellcheck disable=SC2048 +for file in ${files[*]}; do + template_file="${this_dir}/data/${file//\./__}.txt" + if [ -f "${template_file}" ]; then + cp "${template_file}" "${dest_dir}/${file}" + else + echo "Warning: Template file ${template_file} not found. Skipping ${file}." + fi +done + +# Performs a find and replace across the destination directory. +# +# $1 - regular expression +find_and_replace() { + find "${dest_dir}" -type f -print0 | xargs -0 perl -pi -w -e "$1" +} + +# Performs a find and replace across a specified file. +# +# $1 - file +# $2 - regular expression +file_find_and_replace() { + find "${dest_dir}/$1" -type f -print0 | xargs -0 perl -pi -w -e "$2" +} + +# Joins a list of strings. +# +# $1 - separator +# $* - list of strings to join +join() { + local d=$1; shift; local f=$1; shift; printf %s "$f" "${@/#/$d}"; +} + +# For each of the variables defined above, insert into the scaffold files... +regex="s/\\{\\{YEAR\\}\\}/${year}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{COPYRIGHT\\}\\}/${copyright}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{ALIAS\\}\\}/${alias}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{PKG\\}\\}/${pkg//\//\\/}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{PKG_DESC\\}\\}/${pkg_desc}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{MODULE_DESC\\}\\}/${module_desc}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{MAIN_DESC\\}\\}/${main_desc}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{ASSIGN_DESC\\}\\}/${assign_desc}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{TEST_DESC\\}\\}/${test_desc}/g;" +find_and_replace "${regex}" + +# Escape special characters for Perl regex +readme_pkg_desc_escaped="${readme_pkg_desc//\//\\/}" +readme_pkg_desc_escaped="${readme_pkg_desc_escaped//\[/\\[}" +readme_pkg_desc_escaped="${readme_pkg_desc_escaped//\]/\\]}" +readme_pkg_desc_escaped="${readme_pkg_desc_escaped//@/\\@}" +regex="s/\\{\\{README_PKG_DESC\\}\\}/${readme_pkg_desc_escaped}/g;" +find_and_replace "${regex}" + +readme_assign_desc_escaped="${readme_assign_desc//\//\\/}" +readme_assign_desc_escaped="${readme_assign_desc_escaped//\[/\\[}" +readme_assign_desc_escaped="${readme_assign_desc_escaped//\]/\\]}" +readme_assign_desc_escaped="${readme_assign_desc_escaped//@/\\@}" +regex="s/\\{\\{README_ASSIGN_DESC\\}\\}/${readme_assign_desc_escaped}/g;" +find_and_replace "${regex}" + +readme_main_desc_escaped="${readme_main_desc//\//\\/}" +readme_main_desc_escaped="${readme_main_desc_escaped//\[/\\[}" +readme_main_desc_escaped="${readme_main_desc_escaped//\]/\\]}" +readme_main_desc_escaped="${readme_main_desc_escaped//@/\\@}" +regex="s/\\{\\{README_MAIN_DESC\\}\\}/${readme_main_desc_escaped}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{RAND_MIN\\}\\}/${rand_min}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{RAND_MAX\\}\\}/${rand_max}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{BASE_PRNG\\}\\}/${base_prng}/g;" +find_and_replace "${regex}" + +pkg_deps_escaped="${pkg_deps//\//\\/}" +pkg_deps_escaped="${pkg_deps_escaped//@/\\@}" +regex="s/\\{\\{PKG_DEPS\\}\\}/${pkg_deps_escaped}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{SCALAR_KERNEL_PATH\\}\\}/${scalar_kernel_path//\//\\/}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{REPL_TEXT_MAIN_DESC\\}\\}/${repl_text_main_desc}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{REPL_TEXT_ASSIGN_DESC\\}\\}/${repl_text_assign_desc}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{JS_EXAMPLE_VALUES_2X2\\}\\}/${js_example_values_2x2}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{JS_EXAMPLE_RESULTS_2X2\\}\\}/${js_example_results_2x2}/g;" +find_and_replace "${regex}" + +pkg_link_suffix_escaped="${pkg_link_suffix//\//\\/}" +regex="s/\\{\\{PKG_LINK_SUFFIX\\}\\}/${pkg_link_suffix_escaped}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{INPUT_DTYPES\\}\\}/${input_dtypes}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{OUTPUT_DTYPES\\}\\}/${output_dtypes}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{OUTPUT_POLICY\\}\\}/${output_policy}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{CASTING_POLICY\\}\\}/${casting_policy}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{INPUT_NDARRAY_TYPE\\}\\}/${input_ndarray_type}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{OUTPUT_NDARRAY_TYPE\\}\\}/${output_ndarray_type}/g;" +find_and_replace "${regex}" + +regex="s/\\{\\{NDARRAY_IMPORT_TYPES\\}\\}/${ndarray_import_types}/g;" +find_and_replace "${regex}" + +keywords_sep='",\n "' +if [ "${#keywords[*]}" -eq 0 ]; then + words='' +else + words=$(join "${keywords_sep}" "${keywords[@]}") + words="\\n \"${words}\"" +fi +regex="s/\\{\\{KEYWORDS\\}\\}/${words}/g;" +find_and_replace "${regex}" + +# Generate the dynamic files (data.js, types.js, types.json, addon.c) using the generation script +echo "Generating dynamic files for ${alias}..." +node -e "require('${this_dir}/scripts/generate_files.js')('${alias}', '${dest_dir}')" +if [ $? -ne 0 ]; then + echo "Error: Failed to generate dynamic files for ${alias}" + exit 1 +fi diff --git a/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/script.js b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/script.js new file mode 100644 index 000000000000..19d7d9c5b5a2 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/scaffold/math-special-unary/scripts/script.js @@ -0,0 +1,313 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var db = require( '@stdlib/math/special/data/unary_function_database.json' ); +var scaffoldDatabase = require( '@stdlib/math/special/data/unary.json' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var mostlySafeCasts = require( '@stdlib/ndarray/mostly-safe-casts' ); +var promotionRules = require( '@stdlib/ndarray/promotion-rules' ); + + +// FUNCTIONS // + +/** +* Selects the appropriate scalar kernel based on input and output dtypes. +* +* @private +* @param {Object} scalarKernels - available scalar kernels +* @param {string} outputDtype - output dtype +* @param {string} inputDtype - input dtype +* @returns {string} scalar kernel name +* +* @example +* var kernels = { +* 'float64': '@stdlib/math/base/special/floor', +* 'float32': '@stdlib/math/base/special/floorf', +* 'generic': '@stdlib/math/base/special/floor' +* }; +* var kernel = selectScalarKernel( kernels, 'float64', 'float32' ); +* // returns '@stdlib/math/base/special/floor' +*/ +function selectScalarKernel( scalarKernels, outputDtype, inputDtype ) { + var higherPrecisionDtype; + var scalarKernel; + + /* + * For example: + * + * inputDtype = 'complex64' + * outputDtype = 'float32' + */ + + if ( inputDtype === 'generic' ) { + scalarKernel = scalarKernels[ outputDtype ] || scalarKernels.generic; + } else if ( outputDtype === 'generic' ) { + // Using the function appropriate for the input dtype, in case of generic output: + scalarKernel = scalarKernels[ inputDtype ] || scalarKernels.generic; + } else { + // Determine which dtype has higher priority using promotion rules: + higherPrecisionDtype = promotionRules( inputDtype, outputDtype ); // promotionRules( 'complex64', 'float32' ) => 'complex64' + scalarKernel = scalarKernels[ higherPrecisionDtype ]; // scalarKernels[ 'complex64' ] => '@stdlib/math/base/special/cfloorf' + if ( !scalarKernel ) { + scalarKernel = scalarKernels.generic; + } + } + + return scalarKernel; +} + +/** +* Selects the appropriate ndarray kernel name for dtype casting. +* +* @private +* @param {string} inputDtype - input dtype +* @param {string} outputDtype - output dtype +* @param {string} scalarKernel - scalar kernel name +* @returns {string} kernel name +* +* @example +* var kernel = selectKernelName( 'float32', 'float64', '@stdlib/math/base/special/abs' ); +* // returns 'stdlib_ndarray_f_d_as_d_d' +* +* @example +* var kernel = selectKernelName( 'float64', 'float32', '@stdlib/math/base/special/absf' ); +* // returns 'stdlib_ndarray_d_f_as_f_f' +*/ +function selectKernelName( inputDtype, outputDtype, scalarKernel ) { + var scalarKernelOutputDtype; + var scalarKernelInputDtype; + var ndarrayKernel; + + /* + * For example: + * + * inputDtype = 'complex64' + * outputDtype = 'float32' + * scalarKernel = '@stdlib/math/base/special/cfloorf' + */ + + scalarKernelInputDtype = scaffoldDatabase[ scalarKernel ].parameters[ 0 ].type.dtype; // scaffoldDatabase[ '@stdlib/math/base/special/cfloorf' ].parameters[ 0 ].type.dtype => 'complex64' + scalarKernelOutputDtype = scaffoldDatabase[ scalarKernel ].returns.type.dtype; // scaffoldDatabase[ '@stdlib/math/base/special/cfloorf' ].returns.type.dtype => 'complex64' + + // Exact match: + if ( inputDtype === scalarKernelInputDtype && outputDtype === scalarKernelOutputDtype ) { + ndarrayKernel = 'stdlib_ndarray_' + dtypeChar( inputDtype ) + '_' + dtypeChar( outputDtype ); + } else { + // Not an exact match: + ndarrayKernel = 'stdlib_ndarray_'+dtypeChar(inputDtype)+'_'+dtypeChar(outputDtype)+'_as_'+dtypeChar(scalarKernelInputDtype)+'_'+dtypeChar(scalarKernelOutputDtype); // => 'stdlib_ndarray_c_f_as_c_c' + } + + return ndarrayKernel; +} + + +// MAIN // + +/** +* Main function to generate dtype mappings. +* +* @private +* @param {string} basePkg - base package name +* @returns {Array} array of mappings +*/ +function generateDtypes( basePkg ) { + var needsPromotion; + var cFunctionName; + var allowedCasts; + var scalarKernel; + var outputDtype; + var inputDtype; + var kernelName; + var mappings; + var filtered; + var obj; + var odt; + var idt; + var i; + var j; + var k; + + mappings = []; + + // Get scalar kernels and configuration for this function: + obj = db[ basePkg ]; + + /* + * obj = { + * "input_dtypes": "numeric_and_generic", + * "output_dtypes": "numeric_and_generic", + * "output_policy": "same", + * "excluded_dtypes": [ "float16", "uint8c", "complex32" ], + * "scalar_kernels": { + * "int8": "@stdlib/number/int8/base/identity", + * "int16": "@stdlib/number/int16/base/identity", + * "int32": "@stdlib/number/int32/base/identity", + * "uint8": "@stdlib/number/uint8/base/identity", + * "uint16": "@stdlib/number/uint16/base/identity", + * "uint32": "@stdlib/number/uint32/base/identity", + * "float32": "@stdlib/math/base/special/floorf", + * "float64": "@stdlib/math/base/special/floor", + * "complex64": "@stdlib/math/base/special/cfloorf", + * "complex128": "@stdlib/math/base/special/cfloor", + * "generic": "@stdlib/math/base/special/floor" + * } + * } + */ + + // Get input dtypes: + idt = dtypes( obj.input_dtypes ); + + // Get output dtypes: + odt = dtypes( obj.output_dtypes ); + + /* + * idt = [ + * 'complex32', + * 'complex64', + * 'complex128', + * 'float16', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'uint8c', + * 'generic' + * ] + */ + + // Filter out excluded dtypes: + filtered = []; + for ( i = 0; i < idt.length; i++ ) { + if ( obj.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { + filtered.push( idt[ i ] ); + } + } + idt = filtered; + + /* + * idt = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'generic' + * ] + */ + + // Generate all mostly-safe cast combinations: + for ( i = 0; i < idt.length; i++ ) { + inputDtype = idt[ i ]; + + /* + * For the first iteration: + * + * inputDtype = 'complex64' + */ + + if ( inputDtype === 'generic' ) { + allowedCasts = [ 'generic' ]; + } else { + // Get all dtypes this input can be mostly-safely cast to: + allowedCasts = mostlySafeCasts( inputDtype ); + + /* + * For the first iteration: + * + * allowedCasts = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64' + * ] + */ + } + + // Remove the dtypes which are not allowed for output, according to the output policy: + filtered = []; + for ( k = 0; k < allowedCasts.length; k++ ) { + if ( odt.indexOf( allowedCasts[ k ] ) !== -1 ) { + filtered.push( allowedCasts[ k ] ); + } + } + allowedCasts = filtered; + + // console.log( 'allowedCasts for input dtype %s: %s', inputDtype, allowedCasts ); + + for ( j = 0; j < allowedCasts.length; j++ ) { + outputDtype = allowedCasts[ j ]; + + if ( obj.excluded_dtypes.indexOf( outputDtype ) !== -1 ) { + continue; + } + + /* + * For example: + * + * outputDtype = 'float32' + */ + + // Get scalar kernel for this dtype combination: + scalarKernel = selectScalarKernel( obj.scalar_kernels, outputDtype, inputDtype ); // selectScalarKernel( kernels, 'float32', 'complex64' ) => '@stdlib/math/base/special/cfloorf' + + // Generate ndarray kernel name: + kernelName = selectKernelName( inputDtype, outputDtype, scalarKernel ); // selectKernelName( 'complex64', 'float32', '@stdlib/math/base/special/cfloorf' ) => 'stdlib_ndarray_c_f_as_c_c' + + // Generate mapping: + needsPromotion = inputDtype !== outputDtype; + + // Extract the function name from the scalar kernel path and create C function name: + cFunctionName = scalarKernel.split( '/' ).pop(); // Get last part (Ex: 'acosd') + cFunctionName = 'stdlib_base_' + cFunctionName; + + mappings.push([ + inputDtype, + outputDtype, + scalarKernel, + needsPromotion, + ( needsPromotion ) ? outputDtype : null, + ( needsPromotion ) ? outputDtype : null, + cFunctionName, + kernelName + ]); + } + } + + return mappings; +} + + +// EXPORTS // + +module.exports = generateDtypes; diff --git a/lib/node_modules/@stdlib/math/special/acosd/README.md b/lib/node_modules/@stdlib/math/special/acosd/README.md new file mode 100644 index 000000000000..ceb6e89c25dd --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/README.md @@ -0,0 +1,229 @@ + + +# acosd + +> Compute the [arccosine][@stdlib/math/base/special/acosd] for each element in an [ndarray][@stdlib/ndarray/ctor]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var acosd = require( '@stdlib/math/special/acosd' ); +``` + +#### acosd( x\[, options] ) + +Computes the [arccosine][@stdlib/math/base/special/acosd] for each element in an [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +var y = acosd( x ); +// returns + +var arr = ndarray2array( y ); +// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +``` + +The function accepts the following arguments: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. +- **options**: function options (_optional_). + +The function accepts the following options: + +- **dtype**: output ndarray [data type][@stdlib/ndarray/dtypes]. Must be a real-valued or generic [data type][@stdlib/ndarray/dtypes]. +- **order**: output ndarray [order][@stdlib/ndarray/orders] (i.e., memory layout). + +By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [data type][@stdlib/ndarray/dtypes] determined by the function's output data type [policy][@stdlib/ndarray/output-dtype-policies]. To override the default behavior, set the `dtype` option. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); +var getDType = require( '@stdlib/ndarray/dtype' ); + +var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +var y = acosd( x, { + 'dtype': 'generic' +}); +// returns + +var dt = getDType( y ); +// returns 'generic' + +var arr = ndarray2array( y ); +// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +``` + +By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having the same [order][@stdlib/ndarray/orders] as the input [ndarray][@stdlib/ndarray/ctor]. To return an [ndarray][@stdlib/ndarray/ctor] having a specific memory layout irrespective of the memory layout of the input [ndarray][@stdlib/ndarray/ctor], set the `order` option. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); +var getOrder = require( '@stdlib/ndarray/order' ); + +var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +var y = acosd( x, { + 'order': 'column-major' +}); +// returns + +var ord = getOrder( y ); +// returns 'column-major' + +var arr = ndarray2array( y ); +// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +``` + +#### acosd.assign( x, y ) + +Computes the [arccosine][@stdlib/math/base/special/acosd] for each element in an [ndarray][@stdlib/ndarray/ctor] and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); + +var out = acosd.assign( x, y ); +// returns + +var bool = ( out === y ); +// returns true + +var arr = ndarray2array( out ); +// returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +``` + +The function accepts the following arguments: + +- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape of the output [ndarray][@stdlib/ndarray/ctor]. +- **y**: output [ndarray][@stdlib/ndarray/ctor]. + +The function supports broadcasting an input [ndarray][@stdlib/ndarray/ctor] to the shape of the output [ndarray][@stdlib/ndarray/ctor] without performing a physical copy of the input [ndarray][@stdlib/ndarray/ctor]'s underlying data. + +```javascript +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var array = require( '@stdlib/ndarray/array' ); + +// Create a 2x2 input ndarray: +var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); + +// Create a 2x2x2 output ndarray: +var y = zeros( [ 2, 2, 2 ] ); + +var out = acosd.assign( x, y ); +// returns + +var arr = ndarray2array( out ); +// returns [ [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ], [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] ] +``` + +
+ + + + + +
+ +## Notes + +- The output data type [policy][@stdlib/ndarray/output-dtype-policies] only applies to the main function and specifies that, by default, the function must return an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. For the `assign` method, the output [ndarray][@stdlib/ndarray/ctor] is allowed to have any supported output [data type][@stdlib/ndarray/dtypes]. + +
+ + + + + +
+ +## Examples + + + +```javascript +var random = require( '@stdlib/random/uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var acosd = require( '@stdlib/math/special/acosd' ); + +var x = random( [ 5, 5 ], -1.0, 1.0 ); +console.log( ndarray2array( x ) ); + +var y = acosd( x ); +console.log( ndarray2array( y ) ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous.js new file mode 100644 index 000000000000..12aa933b362d --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var acosd = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size ], -1.0, 1.0, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous.native.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous.native.js new file mode 100644 index 000000000000..5fd392dd1e47 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous.native.js @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size ], -1.0, 1.0, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous_assign.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous_assign.js new file mode 100644 index 000000000000..b61f8eded492 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous_assign.js @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var acosd = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var options; + var x; + var y; + + options = { + 'dtype': dtype + }; + x = random( [ size ], -1.0, 1.0, options ); + y = zeros( [ size ], options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = acosd.assign( x, y ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( z )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:assign:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous_assign.native.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous_assign.native.js new file mode 100644 index 000000000000..4845e6e621e8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.1d_contiguous_assign.native.js @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var options; + var x; + var y; + + options = { + 'dtype': dtype + }; + x = random( [ size ], -1.0, 1.0, options ); + y = zeros( [ size ], options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = acosd.assign( x, y ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( z )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:assign:contiguous=true,ndims=1,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_contiguous.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_contiguous.js new file mode 100644 index 000000000000..99935117f204 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_contiguous.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var acosd = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size/2, 2, 1 ], -1.0, 1.0, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=true,ndims=3,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_contiguous.native.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_contiguous.native.js new file mode 100644 index 000000000000..758368ed4b5a --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_contiguous.native.js @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size/2, 2, 1 ], -1.0, 1.0, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=true,ndims=3,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_noncontiguous.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_noncontiguous.js new file mode 100644 index 000000000000..d96aa16ab7df --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_noncontiguous.js @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var acosd = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var buf; + var x; + + buf = random( size*2, -1.0, 1.0, { + 'dtype': dtype + }); + x = new ndarray( dtype, buf, [ size/2, 2, 1 ], [ 4, 1, 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=false,ndims=3,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_noncontiguous.native.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_noncontiguous.native.js new file mode 100644 index 000000000000..954d7aaf190b --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_noncontiguous.native.js @@ -0,0 +1,127 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var buf; + var x; + + buf = random( size*2, -1.0, 1.0, { + 'dtype': dtype + }); + x = new ndarray( dtype, buf, [ size/2, 2, 1 ], [ 4, 1, 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=false,ndims=3,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_singleton_dims.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_singleton_dims.js new file mode 100644 index 000000000000..438cb2faf6cb --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_singleton_dims.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var acosd = require( './../lib/main.js' ); + + +// VARIABLES // + +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size, 1, 1 ], -1.0, 1.0, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s:contiguous=false,ndims=3,singleton_dims=2,dtype=%s,size=%d', pkg, dt, size ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_singleton_dims.native.js b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_singleton_dims.native.js new file mode 100644 index 000000000000..eaf7266f0295 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/benchmark/benchmark.nd_singleton_dims.native.js @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tryRequire = require( '@stdlib/utils/try-require' ); +var bench = require( '@stdlib/bench' ); +var random = require( '@stdlib/random/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; +var DTYPES = [ + 'float64', + 'float32', + 'generic' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} size - array size +* @param {string} dtype - data type +* @returns {Function} benchmark function +*/ +function createBenchmark( size, dtype ) { + var x = random( [ size, 1, 1 ], -1.0, 1.0, { + 'dtype': dtype + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = acosd( x ); + if ( typeof y !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( getData( y )[ i%size ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var size; + var min; + var max; + var dt; + var f; + var i; + var j; + + min = 1; // 10^min + max = 6; // 10^max + + for ( j = 0; j < DTYPES.length; j++ ) { + dt = DTYPES[ j ]; + for ( i = min; i <= max; i++ ) { + size = pow( 10, i ); + f = createBenchmark( size, dt ); + bench( format( '%s::native:contiguous=false,ndims=3,singleton_dims=2,dtype=%s,size=%d', pkg, dt, size ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/acosd/binding.gyp b/lib/node_modules/@stdlib/math/special/acosd/binding.gyp new file mode 100644 index 000000000000..9deaf9ecc051 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99' + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11' + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/special/acosd/docs/repl.txt b/lib/node_modules/@stdlib/math/special/acosd/docs/repl.txt new file mode 100644 index 000000000000..d053def7d192 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/docs/repl.txt @@ -0,0 +1,68 @@ + +{{alias}}( x[, options] ) + Computes the arccosine for each element in an ndarray. + + The function returns an ndarray having the same shape as the input ndarray. + + Parameters + ---------- + x: ndarray + Input array. Must have a numeric or "generic" data type. + + options: Object (optional) + Options. + + options.dtype: string|DataType (optional) + Output array data type. Must be a real-valued or "generic" data type. + + options.order: string (optional) + Output array order. Must be either row-major (C-style) or column-major + (Fortran-style). By default, the order of the output array is the same + as the input array. + + Returns + ------- + y: ndarray + Output array containing element-wise results. + + Examples + -------- + > var arr = [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ]; + > var x = {{alias:@stdlib/ndarray/array}}( arr ); + > var y = {{alias}}( x ); + > {{alias:@stdlib/ndarray/to-array}}( y ) + [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] + + +{{alias}}.assign( x, y ) + Compute the arccosine for each element in an ndarray. for each element in an + ndarray and assigns results to a provided output ndarray. + + Parameters + ---------- + x: ndarray + Input array. Must have a numeric or "generic" data type. + + y: ndarray + Output array. + + Returns + ------- + y: ndarray + Output array. + + Examples + -------- + > var arr = [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ]; + > var x = {{alias:@stdlib/ndarray/array}}( arr ); + > var sh = {{alias:@stdlib/ndarray/shape}}( x ); + > var y = {{alias:@stdlib/ndarray/zeros}}( sh ); + > var out = {{alias}}.assign( x, y ); + > var bool = ( out === y ) + true + > {{alias:@stdlib/ndarray/to-array}}( y ) + [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/special/acosd/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/special/acosd/docs/types/index.d.ts new file mode 100644 index 000000000000..11fa0f2326a7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/docs/types/index.d.ts @@ -0,0 +1,146 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { typedndarray, realndarray, floatndarray, genericndarray, RealAndGenericDataType as DataType, Order } from '@stdlib/types/ndarray'; + +/** +* Input array. +*/ +type InputArray = realndarray | genericndarray; + +/** +* Output array. +*/ +type OutputArray = floatndarray | genericndarray; + +/** +* Interface describing options. +*/ +interface Options { + /** + * Output array order. + * + * ## Notes + * + * - By default, the order of the output array is the same as the input array. + */ + order?: Order; + + /** + * Output array data type. + */ + dtype?: DataType; +} + +/** +* Interface describing a unary element-wise function. +*/ +interface UnaryFunction { + /** + * Computes the arccosine for each element in an ndarray. + * + * @param x - input ndarray + * @param options - options + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); + * // returns + * + * var y = acosd( x ); + * // returns + * + * var arr = ndarray2array( y ); + * // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] + */ + ( x: InputArray, options?: Options ): typedndarray; // FIXME: we lose type specificity here, as the output ndarray data type is determined according to the output data type policy in conjunction with the `dtype` option + + /** + * Compute the arccosine for each element in an ndarray. for each element in an ndarray and assigns results to a provided output ndarray. + * + * @param x - input ndarray + * @param y - output ndarray + * @returns output ndarray + * + * @example + * var ndarray2array = require( '@stdlib/ndarray/to-array' ); + * var array = require( '@stdlib/ndarray/array' ); + * + * var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); + * var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); + * + * var z = acosd.assign( x, y ); + * // returns + * + * var bool = ( z === y ); + * // returns true + * + * var arr = ndarray2array( y ); + * // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] + */ + assign( x: InputArray, y: T ): T; +} + +/** +* Computes the arccosine for each element in an ndarray. +* +* @param x - input ndarray +* @param options - options +* @returns output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +* +* var y = acosd( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +* var y = array( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ); +* +* var z = acosd.assign( x, y ); +* // returns +* +* var bool = ( z === y ); +* // returns true +* +* var arr = ndarray2array( y ); +* // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +*/ +declare var acosd: UnaryFunction; + + +// EXPORTS // + +export = acosd; diff --git a/lib/node_modules/@stdlib/math/special/acosd/docs/types/test.ts b/lib/node_modules/@stdlib/math/special/acosd/docs/types/test.ts new file mode 100644 index 000000000000..69a0b8d49a19 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/docs/types/test.ts @@ -0,0 +1,154 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import acosd = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd( x ); // $ExpectType typedndarray + acosd( x, {} ); // $ExpectType typedndarray + acosd( x, { 'dtype': 'float32' } ); // $ExpectType typedndarray + acosd( x, { 'order': 'row-major' } ); // $ExpectType typedndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + acosd( '5' ); // $ExpectError + acosd( 5 ); // $ExpectError + acosd( true ); // $ExpectError + acosd( false ); // $ExpectError + acosd( null ); // $ExpectError + acosd( void 0 ); // $ExpectError + acosd( [] ); // $ExpectError + acosd( {} ); // $ExpectError + acosd( [ '5' ] ); // $ExpectError + acosd( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a valid options object... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd( x, '5' ); // $ExpectError + acosd( x, true ); // $ExpectError + acosd( x, false ); // $ExpectError + acosd( x, [ '5' ] ); // $ExpectError + acosd( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `dtype` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd( x, { 'dtype': '5' } ); // $ExpectError + acosd( x, { 'dtype': true } ); // $ExpectError + acosd( x, { 'dtype': false } ); // $ExpectError + acosd( x, { 'dtype': null } ); // $ExpectError + acosd( x, { 'dtype': {} } ); // $ExpectError + acosd( x, { 'dtype': [ '5' ] } ); // $ExpectError + acosd( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid `order` option... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd( x, { 'order': '5' } ); // $ExpectError + acosd( x, { 'order': true } ); // $ExpectError + acosd( x, { 'order': false } ); // $ExpectError + acosd( x, { 'order': null } ); // $ExpectError + acosd( x, { 'order': {} } ); // $ExpectError + acosd( x, { 'order': [ '5' ] } ); // $ExpectError + acosd( x, { 'order': ( x: number ): number => x } ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd(); // $ExpectError + acosd( x, {}, {} ); // $ExpectError +} + +// Attached to the main function is an `assign` method which returns an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd.assign( x, x ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd.assign( '5', x ); // $ExpectError + acosd.assign( true, x ); // $ExpectError + acosd.assign( false, x ); // $ExpectError + acosd.assign( null, x ); // $ExpectError + acosd.assign( void 0, x ); // $ExpectError + acosd.assign( {}, x ); // $ExpectError + acosd.assign( ( x: number ): number => x, x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd.assign( x, '5' ); // $ExpectError + acosd.assign( x, true ); // $ExpectError + acosd.assign( x, false ); // $ExpectError + acosd.assign( x, null ); // $ExpectError + acosd.assign( x, void 0 ); // $ExpectError + acosd.assign( x, {} ); // $ExpectError + acosd.assign( x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const x = zeros( [ 2, 2 ], { + 'dtype': 'float64' + }); + + acosd.assign(); // $ExpectError + acosd.assign( x ); // $ExpectError + acosd.assign( x, x, x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/special/acosd/examples/index.js b/lib/node_modules/@stdlib/math/special/acosd/examples/index.js new file mode 100644 index 000000000000..e16b9f7479f7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/examples/index.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +var random = require( '@stdlib/random/uniform' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var acosd = require( './../lib' ); + +var x = random( [ 5, 5 ], -1.0, 1.0 ); +console.log( ndarray2array( x ) ); + +var y = acosd( x ); +console.log( ndarray2array( y ) ); diff --git a/lib/node_modules/@stdlib/math/special/acosd/include.gypi b/lib/node_modules/@stdlib/math/special/acosd/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' +* +* var y = acosd( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var javascript = require( './main.js' ); + + +// MAIN // + +var main; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( tmp instanceof Error ) { + main = javascript; +} else { + main = tmp; +} + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign" } diff --git a/lib/node_modules/@stdlib/math/special/acosd/lib/main.js b/lib/node_modules/@stdlib/math/special/acosd/lib/main.js new file mode 100644 index 000000000000..33b722cd5661 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/lib/main.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var dispatch = require( '@stdlib/ndarray/dispatch' ); +var setProps = require( '@stdlib/ndarray/base/meta-data-props' ); +var ufunc = require( '@stdlib/math/tools/unary' ); +var unary = require( '@stdlib/ndarray/base/unary' ); +var data = require( './data.js' ); +var types = require( './types.json' ); +var config = require( './config.js' ); + + +// MAIN // + +/** +* Computes the arccosine for each element in an ndarray. +* +* @name acosd +* @type {Function} +* @param {ndarray} x - input ndarray +* @param {Options} [options] - options +* @param {string} [options.order] - output array order +* @param {*} [options.dtype] - output array dtype +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @returns {ndarray} output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +* // returns +* +* var y = acosd( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +*/ +var acosd = ufunc( dispatch( unary, types, data, config.nargs, config.nin, config.nout ), [ config.idtypes ], config.odtypes, config.policies ); +setProps( config, types, acosd ); +setProps( config, types, acosd.assign ); + + +// EXPORTS // + +module.exports = acosd; diff --git a/lib/node_modules/@stdlib/math/special/acosd/lib/native.js b/lib/node_modules/@stdlib/math/special/acosd/lib/native.js new file mode 100644 index 000000000000..e01878a8db87 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/lib/native.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var dispatch = require( '@stdlib/ndarray/base/unary-addon-dispatch' ); +var setProps = require( '@stdlib/ndarray/base/meta-data-props' ); +var ufunc = require( '@stdlib/math/tools/unary' ); +var addon = require( './../src/addon.node' ); +var types = require( './types.json' ); +var config = require( './config.js' ); +var fallback = require( './main.js' ).assign; + + +// MAIN // + +/** +* Computes the arccosine for each element in an ndarray. +* +* @name acosd +* @type {Function} +* @param {ndarray} x - input ndarray +* @param {Options} [options] - options +* @param {string} [options.order] - output array order +* @param {*} [options.dtype] - output array dtype +* @throws {TypeError} first argument must be an ndarray-like object +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @returns {ndarray} output ndarray +* +* @example +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( [ [ 0.84, -0.37 ], [ 0.12, -0.93 ] ] ); +* // returns +* +* var y = acosd( x ); +* // returns +* +* var arr = ndarray2array( y ); +* // returns [ [ ~32.86, ~111.72 ], [ ~83.11, ~158.43 ] ] +*/ +var acosd = ufunc( dispatch( addon, fallback ), [ config.idtypes ], config.odtypes, config.policies ); +setProps( config, types, acosd ); +setProps( config, types, acosd.assign ); + + +// EXPORTS // + +module.exports = acosd; diff --git a/lib/node_modules/@stdlib/math/special/acosd/lib/types.js b/lib/node_modules/@stdlib/math/special/acosd/lib/types.js new file mode 100644 index 000000000000..aa7d26ac4011 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/lib/types.js @@ -0,0 +1,78 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +/* eslint-disable array-element-newline */ + +'use strict'; + +// MODULES // + +var dtypes = require( '@stdlib/ndarray/dtypes' ); + + +// MAIN // + +var types = [ + // float32 (3) + dtypes.float32.enum, dtypes.float64.enum, + dtypes.float32.enum, dtypes.float32.enum, + dtypes.float32.enum, dtypes.generic.enum, + + // float64 (3) + dtypes.float64.enum, dtypes.float64.enum, + dtypes.float64.enum, dtypes.float32.enum, + dtypes.float64.enum, dtypes.generic.enum, + + // int16 (3) + dtypes.int16.enum, dtypes.float64.enum, + dtypes.int16.enum, dtypes.float32.enum, + dtypes.int16.enum, dtypes.generic.enum, + + // int32 (2) + dtypes.int32.enum, dtypes.float64.enum, + dtypes.int32.enum, dtypes.generic.enum, + + // int8 (3) + dtypes.int8.enum, dtypes.float64.enum, + dtypes.int8.enum, dtypes.float32.enum, + dtypes.int8.enum, dtypes.generic.enum, + + // uint16 (3) + dtypes.uint16.enum, dtypes.float64.enum, + dtypes.uint16.enum, dtypes.float32.enum, + dtypes.uint16.enum, dtypes.generic.enum, + + // uint32 (2) + dtypes.uint32.enum, dtypes.float64.enum, + dtypes.uint32.enum, dtypes.generic.enum, + + // uint8 (3) + dtypes.uint8.enum, dtypes.float64.enum, + dtypes.uint8.enum, dtypes.float32.enum, + dtypes.uint8.enum, dtypes.generic.enum, + + // generic (1) + dtypes.generic.enum, dtypes.generic.enum +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/acosd/lib/types.json b/lib/node_modules/@stdlib/math/special/acosd/lib/types.json new file mode 100644 index 000000000000..f8914ac0faf2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/lib/types.json @@ -0,0 +1 @@ +[11,12,11,11,11,17,12,12,12,11,12,17,4,12,4,11,4,17,6,12,6,17,1,12,1,11,1,17,5,12,5,11,5,17,7,12,7,17,2,12,2,11,2,17,17,17] diff --git a/lib/node_modules/@stdlib/math/special/acosd/manifest.json b/lib/node_modules/@stdlib/math/special/acosd/manifest.json new file mode 100644 index 000000000000..9a089b6cb141 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/manifest.json @@ -0,0 +1,43 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/acosdf", + "@stdlib/math/base/special/acosd", + "@stdlib/ndarray/base/function-object", + "@stdlib/ndarray/base/napi/unary", + "@stdlib/ndarray/base/unary", + "@stdlib/ndarray/dtypes" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/special/acosd/package.json b/lib/node_modules/@stdlib/math/special/acosd/package.json new file mode 100644 index 000000000000..7180ca13824a --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/math/special/acosd", + "version": "0.0.0", + "description": "Compute the arccosine for each element in an ndarray.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "ndarray", + "elementwise", + "element-wise", + "acosd", + "arccosine", + "inverse", + "trig", + "trigonometry", + "degrees", + "math.acos" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/math/special/acosd/src/Makefile b/lib/node_modules/@stdlib/math/special/acosd/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/special/acosd/src/addon.c b/lib/node_modules/@stdlib/math/special/acosd/src/addon.c new file mode 100644 index 000000000000..6ceb5bb824ae --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/src/addon.c @@ -0,0 +1,160 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ +#include "stdlib/math/base/special/acosd.h" +#include "stdlib/math/base/special/acosdf.h" +#include "stdlib/ndarray/base/function_object.h" +#include "stdlib/ndarray/base/napi/unary.h" +#include "stdlib/ndarray/base/unary.h" +#include "stdlib/ndarray/dtypes.h" +#include + +// Define an interface name: +static const char name[] = "stdlib_ndarray_acosd"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + // float32 (2) + stdlib_ndarray_f_d_as_d_d, + stdlib_ndarray_f_f, + + // float64 (2) + stdlib_ndarray_d_d, + stdlib_ndarray_d_f_as_d_d, + + // int16 (2) + stdlib_ndarray_k_d_as_d_d, + stdlib_ndarray_k_f_as_f_f, + + // int32 (1) + stdlib_ndarray_i_d_as_d_d, + + // int8 (2) + stdlib_ndarray_s_d_as_d_d, + stdlib_ndarray_s_f_as_f_f, + + // uint16 (2) + stdlib_ndarray_t_d_as_d_d, + stdlib_ndarray_t_f_as_f_f, + + // uint32 (1) + stdlib_ndarray_u_d_as_d_d, + + // uint8 (2) + stdlib_ndarray_b_d_as_d_d, + stdlib_ndarray_b_f_as_f_f + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // float32 (2) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + + // float64 (2) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, + + // int16 (2) + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + + // int32 (1) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + + // int8 (2) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + + // uint16 (2) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + + // uint32 (1) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + + // uint8 (2) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32 + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // float32 (2) + (void *)stdlib_base_acosd, + (void *)stdlib_base_acosdf, + + // float64 (2) + (void *)stdlib_base_acosd, + (void *)stdlib_base_acosd, + + // int16 (2) + (void *)stdlib_base_acosd, + (void *)stdlib_base_acosdf, + + // int32 (1) + (void *)stdlib_base_acosd, + + // int8 (2) + (void *)stdlib_base_acosd, + (void *)stdlib_base_acosdf, + + // uint16 (2) + (void *)stdlib_base_acosd, + (void *)stdlib_base_acosdf, + + // uint32 (1) + (void *)stdlib_base_acosd, + + // uint8 (2) + (void *)stdlib_base_acosd, + (void *)stdlib_base_acosdf + +}; + +// Create an ndarray function object: +static const struct ndarrayFunctionObject obj = { + // ndarray function name: + name, + + // Number of input ndarrays: + 1, + + // Number of output ndarrays: + 1, + + // Total number of ndarray arguments (nin + nout): + 2, + + // Array containing ndarray functions: + functions, + + // Number of ndarray functions: + 14, + + // Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function: + types, + + // Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions): + data +}; + +STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj ) diff --git a/lib/node_modules/@stdlib/math/special/acosd/test/test.assign.js b/lib/node_modules/@stdlib/math/special/acosd/test/test.assign.js new file mode 100644 index 000000000000..f93b6d1c3d1d --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/test/test.assign.js @@ -0,0 +1,136 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var base = require( '@stdlib/math/base/special/acosd' ); +var acosd = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof acosd, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( typeof acosd.assign, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var y; + var i; + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd.assign( value, y ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd.assign( x, value ); + }; + } +}); + +tape( 'the function computes the arccosine for each element in an ndarray for each element in an ndarray and assigns the results to a provided output ndarray', function test( t ) { + var expected; + var out; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64' + }); + y = zeros( getShape( x ), { + 'dtype': 'float64' + }); + out = acosd.assign( x, y ); + + expected = map( x, naryFunction( base, 1 ) ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( ndarray2array( out ), ndarray2array( expected ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/special/acosd/test/test.assign.native.js b/lib/node_modules/@stdlib/math/special/acosd/test/test.assign.native.js new file mode 100644 index 000000000000..0309874f3655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/test/test.assign.native.js @@ -0,0 +1,145 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var base = require( '@stdlib/math/base/special/acosd' ); + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof acosd, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', opts, function test( t ) { + t.strictEqual( typeof acosd.assign, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', opts, function test( t ) { + var values; + var y; + var i; + + y = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd.assign( value, y ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an ndarray-like object', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd.assign( x, value ); + }; + } +}); + +tape( 'the function computes the arccosine for each element in an ndarray for each element in an ndarray and assigns the results to a provided output ndarray', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64' + }); + y = zeros( getShape( x ), { + 'dtype': 'float64' + }); + out = acosd.assign( x, y ); + + expected = map( x, naryFunction( base, 1 ) ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( ndarray2array( out ), ndarray2array( expected ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/special/acosd/test/test.js b/lib/node_modules/@stdlib/math/special/acosd/test/test.js new file mode 100644 index 000000000000..26d7a11e65d2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/test/test.js @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dtypes2signatures = require( '@stdlib/ndarray/base/dtypes2signatures' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var types = require( './../lib/types.json' ); +var config = require( './../lib/config.js' ); +var fcn = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof fcn, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var fcn = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( fcn, mock, 'returns native implementation' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var main; + var fcn; + + main = require( './../lib/main.js' ); + + fcn = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( fcn, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); + +tape( 'attached to the main export is a property for retrieving the number of input and output arrays', function test( t ) { + t.strictEqual( fcn.nargs, config.nargs, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a property for retrieving the number of input arrays', function test( t ) { + t.strictEqual( fcn.nin, config.nin, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a property for retrieving the number of output arrays', function test( t ) { + t.strictEqual( fcn.nout, config.nout, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a property for retrieving the list of supported array data types', function test( t ) { + t.deepEqual( fcn.types, dtypes2signatures( types, config.nin, config.nout ), 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method for assigning results to a provided output array', function test( t ) { + t.strictEqual( hasProp( fcn, 'assign' ), true, 'returns expected value' ); + t.strictEqual( typeof fcn.assign, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the number of input and output arrays', function test( t ) { + t.strictEqual( fcn.assign.nargs, config.nargs, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the number of input arrays', function test( t ) { + t.strictEqual( fcn.assign.nin, config.nin, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the number of output arrays', function test( t ) { + t.strictEqual( fcn.assign.nout, config.nout, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the `assign` method is a property for retrieving the list of supported array data types', function test( t ) { + t.deepEqual( fcn.assign.types, dtypes2signatures( types, config.nin, config.nout ), 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/special/acosd/test/test.main.js b/lib/node_modules/@stdlib/math/special/acosd/test/test.main.js new file mode 100644 index 000000000000..cc0d6b465f8d --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/test/test.main.js @@ -0,0 +1,284 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var base = require( '@stdlib/math/base/special/acosd' ); +var acosd = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof acosd, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an object', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `dtype` option', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( x, { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `order` option', function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( x, { + 'order': value + }); + }; + } +}); + +tape( 'the function computes the arccosine for each element in an ndarray for each element in an ndarray', function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64' + }); + y = acosd( x ); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray data type', function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64' + }); + y = acosd( x, { + 'dtype': 'generic' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.strictEqual( getDType( y ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray order', function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64', + 'order': 'row-major' + }); + y = acosd( x, { + 'order': 'column-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'column-major', 'returns expected value' ); + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64', + 'order': 'column-major' + }); + y = acosd( x, { + 'order': 'row-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'row-major', 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/special/acosd/test/test.main.native.js b/lib/node_modules/@stdlib/math/special/acosd/test/test.main.native.js new file mode 100644 index 000000000000..4852d4770d69 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/acosd/test/test.main.native.js @@ -0,0 +1,293 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var random = require( '@stdlib/random/uniform' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var map = require( '@stdlib/ndarray/map' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var getShape = require( '@stdlib/ndarray/shape' ); +var getOrder = require( '@stdlib/ndarray/order' ); +var getDType = require( '@stdlib/ndarray/dtype' ); +var base = require( '@stdlib/math/base/special/acosd' ); + + +// VARIABLES // + +var acosd = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( acosd instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof acosd, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', opts, function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( value ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', opts, function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an object', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( x, value ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `dtype` option', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( x, { + 'dtype': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not an invalid `order` option', opts, function test( t ) { + var values; + var x; + var i; + + x = zeros( [ 2, 2 ], { + 'dtype': 'generic' + }); + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + acosd( x, { + 'order': value + }); + }; + } +}); + +tape( 'the function computes the arccosine for each element in an ndarray for each element in an ndarray', opts, function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64' + }); + y = acosd( x ); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray data type', opts, function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64' + }); + y = acosd( x, { + 'dtype': 'generic' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.strictEqual( getDType( y ), 'generic', 'returns expected value' ); + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), getOrder( x ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the output ndarray order', opts, function test( t ) { + var expected; + var x; + var y; + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64', + 'order': 'row-major' + }); + y = acosd( x, { + 'order': 'column-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'column-major', 'returns expected value' ); + + x = random( [ 5, 5 ], -1.0, 1.0, { + 'dtype': 'float64', + 'order': 'column-major' + }); + y = acosd( x, { + 'order': 'row-major' + }); + + expected = map( x, naryFunction( base, 1 ) ); + t.deepEqual( ndarray2array( y ), ndarray2array( expected ), 'returns expected value' ); + + t.deepEqual( getShape( y ), getShape( x ), 'returns expected value' ); + t.strictEqual( getOrder( y ), 'row-major', 'returns expected value' ); + + t.end(); +});