diff --git a/lib/node_modules/@stdlib/math/base/special/cceil/package.json b/lib/node_modules/@stdlib/math/base/special/cceil/package.json index aaae6ab20ad4..b2e863a190cd 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceil/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceil/package.json @@ -66,5 +66,80 @@ "complex", "cmplx", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "cceil", + "alias": "cceil", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex128" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex128" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json index 9727be736b09..3a1b63d10991 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json @@ -66,5 +66,80 @@ "complex", "cmplx", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "cceilf", + "alias": "cceilf", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex64" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/ceil/package.json b/lib/node_modules/@stdlib/math/base/special/ceil/package.json index 38fc7b65e615..ffc9bfd38184 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceil/package.json @@ -63,5 +63,80 @@ "nearest", "value", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "ceil", + "alias": "ceil", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/ceilf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilf/package.json index 148b58ae6e25..00859904d3e9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilf/package.json @@ -67,5 +67,80 @@ "float32", "single-precision", "flt" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "ceilf", + "alias": "ceilf", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float32" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/special/ceil/lib/types.js b/lib/node_modules/@stdlib/math/special/ceil/lib/types.js new file mode 100644 index 000000000000..76984431d916 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/lib/types.js @@ -0,0 +1,77 @@ +/** +* @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. */ +/* +* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation. +*/ + +/* eslint-disable array-element-newline */ + +'use strict'; + +// MODULES // + +var dtypes = require( '@stdlib/ndarray/dtypes' ); + + +// MAIN // + +var types = [ + // complex64 (1) + dtypes.complex64, dtypes.complex128, + + // float32 (3) + dtypes.float32, dtypes.complex64, + dtypes.float32, dtypes.complex128, + dtypes.float32, dtypes.float64, + + // float64 (1) + dtypes.float64, dtypes.complex128, + + // int32 (2) + dtypes.int32, dtypes.complex128, + dtypes.int32, dtypes.float64, + + // int8 (4) + dtypes.int8, dtypes.complex64, + dtypes.int8, dtypes.complex128, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.float64, + + // uint16 (4) + dtypes.uint16, dtypes.complex64, + dtypes.uint16, dtypes.complex128, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.float64, + + // uint32 (2) + dtypes.uint32, dtypes.complex128, + dtypes.uint32, dtypes.float64, + + // uint8 (4) + dtypes.uint8, dtypes.complex64, + dtypes.uint8, dtypes.complex128, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.float64 +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/ceil/package.json b/lib/node_modules/@stdlib/math/special/ceil/package.json new file mode 100644 index 000000000000..203de43d4d02 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/math/special/ceil", + "version": "0.0.0", + "description": "Round a number toward positive infinity.", + "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", + "math.abs", + "abs", + "absolute", + "magnitude", + "value", + "ndarray", + "elementwise", + "element-wise" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js new file mode 100644 index 000000000000..4a19c3d6bc61 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.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. +*/ + +'use strict'; + +// MAIN // + +var config = { + 'input_dtypes': 'numeric_and_generic', + 'output_dtypes': 'numeric_and_generic' +}; + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js new file mode 100644 index 000000000000..0835c722dcec --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js @@ -0,0 +1,304 @@ +/** +* @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. +*/ + +'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 generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// FUNCTIONS // + +/** +* Groups matches by input data type. +* +* @private +* @param {Array} matches - array of match entries +* @returns {Object} object containing grouped matches, input types array, 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 += '* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation.\n'; + jsOut += '*/\n\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; + + // Generate grouped output with proper formatting and comments... + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + // Add comment with input type and count + jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + + for ( j = 0; j < outputTypes.length; j++ ) { + jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[ j ]; + if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { + jsOut += ',\n'; + } else { + jsOut += '\n'; + } + } + + // Add blank line between input type groups ( except for the last one )... + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\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 includeKey; + var inputType; + var grouped; + var result; + var cOut; + var i; + var j; + + // Generate unique includes... + uniqueIncludes = {}; + for ( i = 0; i < matches.length; i++ ) { + includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); + uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; + } + + // Group matches by input type for organized output... + 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'; + + // Define interface name with comment... + cOut += '// Define an interface name:\n'; + cOut += 'static const char name[] = "stdlib_ndarray_' + basePkg + '";\n\n'; + + // Define functions array with comments and grouping... + cOut += '// Define a list of ndarray functions:\n'; + cOut += 'static ndarrayFcn functions[] = {\n'; + + // Add functions with type group comments... + 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 ] + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define types array with comments and grouping... + 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() + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define data array with comments and grouping... + 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 ] + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define function object with detailed comments... + 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'; + + // Export the function object... + cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; + return cOut; +} + + +// MAIN // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // Extract package information: + basePkg = pkg.name.split( '/' ).pop(); + + // 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( __dirname, '../lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( matches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js new file mode 100644 index 000000000000..aca8b0426465 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js @@ -0,0 +1,223 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var promotionRules = require( '@stdlib/ndarray/promotion-rules' ); +var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var format = require( '@stdlib/string/format' ); +var safeCasts = require( '@stdlib/ndarray/safe-casts' ); +var generateTable = require( './table.js' ); +var config = require( './config.js' ); + + +// FUNCTIONS // + +/** +* Returns an array of matches with valid combinations. +* +* @private +* @param {Array} matches - array of all combinations +* @returns {Array} array of matches with valid combinations +*/ +function getValidCombinations( matches ) { + var validMatches = []; + var validDtypes; + var i; + + for ( i = 0; i < matches.length; i++ ) { + // Skip complex32, float16, uint8c and int16 as we don't support them yet... + if ( matches[ i ][ 0 ] === 'complex32' || + matches[ i ][ 0 ] === 'int16' || + matches[ i ][ 0 ] === 'float16' || + matches[ i ][ 0 ] === 'uint8c' || + matches[ i ][ 1 ] === 'complex32' || + matches[ i ][ 1 ] === 'int16'|| + matches[ i ][ 1 ] === 'float16' || + matches[ i ][ 1 ] === 'uint8c' ) { + continue; + } + + // Check if the dtypes are valid for the current match... + validDtypes = safeCasts( matches[ i ][ 5 ] ); + if ( validDtypes && validDtypes.includes( matches[ i ][ 1 ] ) && promotionRules( matches[ i ][ 0 ], matches[ i ][ 1 ] ) === matches[ i ][ 4 ] ) { // eslint-disable-line max-len + validMatches.push( matches[ i ] ); + } + } + + return validMatches; +} + + +// MAIN // + +/** +* Generate dtype pairs, match them with appropriate packages, and resolve C function names and loop kernels. +* +* ## Note +* +* - The function generates an array of matches, where each match is an array of the following format: +* +* ```text +* ---------------------------------------------------------------------------------------------------------------------------------------- +* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | +* ---------------------------------------------------------------------------------------------------------------------------------------- +* | | | | | | | | +* | | | | | | | | +* V V | V V V | V +* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_d_d' +* V V +* '@stdlib/math/base/special/expf' 'stdlib_base_expf' +* ``` +* +* @private +* @returns {Array} matches table containing dtype pairs and their corresponding package information +*/ +function main() { + var cFuncName; + var matches = []; + var kernel; + var table; + var pairs; + var pdt; + var row; + var idt; + var odt; + var dt; + var i; + var j; + + /* + Generate the table. For example, we'll have: + Table: [ + [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], + [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], + [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ] + [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ], + ] + */ + table = generateTable(); + + /* + Resolve list of input dtypes. For example, we'll have: + idt = [ + 'complex32', + 'complex64', + 'complex128', + 'float16', + 'float32', + 'float64', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ] + */ + idt = dtypes( config.input_dtypes ); + + /* + Resolve the list of output dtypes. For example, we'll have: + odt = [ + 'complex32', + 'complex128', + 'complex64', + 'float16', + 'float64', + 'float32', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ] + */ + odt = dtypes( config.output_dtypes ); + + /* + Generate the input-output dtype pairs. For example, we'll have: + pairs = [ + [ 'complex32', 'complex32' ], + [ 'complex32', 'complex64' ], + [ 'complex32', 'complex128' ], + [ 'complex32', 'float16' ], + [ 'complex32', 'float32' ], + [ 'complex32', 'float64' ], + [ 'complex32', 'int32' ], + [ 'complex32', 'int16' ], + [ 'complex32', 'int8' ], + [ 'complex32', 'uint32' ], + [ 'complex32', 'uint16' ], + [ 'complex32', 'uint8' ], + [ 'complex32', 'uint8c' ], + [ 'complex64', 'complex32' ], + [ 'complex64', 'complex64' ], + [ 'complex64', 'complex128' ], + [ 'complex64', 'float16' ], + [ 'complex64', 'float32' ], + [ 'complex64', 'float64' ], + [ 'complex64', 'int32' ], + ... + ] + */ + pairs = cartesianProduct( idt, odt ); + + // Match-make each dtype pair with a stdlib package... + for ( i = 0; i < pairs.length; i++ ) { + // Now let dt = [ 'uint32', 'float32' ]... + dt = pairs[ i ]; + + for ( j = 0; j < table.length; j++ ) { + row = table[ j ]; + + // Resolve the scalar math kernel C function name from package path ( e.g., '@stdlib/math/base/special/ceilf' -> 'ceilf' --> 'stdlib_base_ceilf' ): + cFuncName = 'stdlib_base_' + row[ 2 ].split( '/' ).pop(); + + // Firstly, look for exact matches. For example, let row = [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ]... + if ( row[ 0 ] === dt[ 0 ] && row[ 1 ] === dt[ 1 ] ) { + // Resolve the loop kernel... + kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, cFuncName, kernel ] ); // eslint-disable-line max-len + break; + } + + // Then check for package to which the dtype pair can promote. For example, pdt = promotionRules( 'uint32', 'float32' ) = 'float64': + pdt = promotionRules( dt[ 0 ], row[ 0 ] ); + if ( pdt ) { + // Check if the package in the present row supports the promoted dtypes... + if ( row[ 0 ] === pdt && row[ 1 ] === pdt ) { + // Resolve the loop kernel... + kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( dt[ 0 ] ), dtypeChar( dt[ 1 ] ), dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, cFuncName, kernel ] ); // eslint-disable-line max-len + } + } + } + } + + return getValidCombinations( matches ); +} + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js new file mode 100644 index 000000000000..3e227f87123f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js @@ -0,0 +1,218 @@ +/* eslint-disable stdlib/jsdoc-no-shortcut-reference-link, stdlib/jsdoc-no-undefined-references, stdlib/jsdoc-no-paragraph-content-indent */ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var basename = require( 'path' ).basename; +var resolve = require( 'path' ).resolve; +var path = require( 'path' ); +var ls = require( '@stdlib/_tools/pkgs/names' ).sync; +var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var pkg = require( './.././package.json' ); + + +// VARIABLES // + +var pathString = '@stdlib/math/base/special'; +var basePkg = basename( pkg.name ); +var ROOT_DIR = rootDir(); +var opts = { + 'dir': './' + pathString +}; +var jsonOpts = { + 'encoding': 'utf8' +}; + + +// FUNCTIONS // + +/** +* Returns a list of packages in `math/base/special/*` which are relevant for the current package. +* +* ## Note +* +* For now, we are trying the following four combinations. So, let us say, we are looking for the `sin` package, then we will try to find: +* +* - `@stdlib/math/base/special/sinf` +* - `@stdlib/math/base/special/sin` +* - `@stdlib/math/base/special/csinf` +* - `@stdlib/math/base/special/csin` +* +* Now since as of now, we don't have `@stdlib/math/base/special/csin` and `@stdlib/math/base/special/csinf`, we will only get the first two packages. +* +* @private +* @returns {Array} list of relevant packages +* +* @example +* var basePkg = 'inv'; +* +* var pkgs = getRelevantPackages(); +* // returns [ '@stdlib/math/base/special/invf', '@stdlib/math/base/special/inv', '@stdlib/math/base/special/cinvf', '@stdlib/math/base/special/cinv' ] +* +* @example +* var basePkg = 'sin'; +* +* var pkgs = getRelevantPackages( 'sin' ); +* // returns [ '@stdlib/math/base/special/sinf', '@stdlib/math/base/special/sin' ] +*/ +function getRelevantPackages() { + var combinations; + var names; + var pkgs; + var pkg; + var i; + var j; + + pkgs = []; + + // Initializing all possible combinations that we can try, in the required order: + combinations = [ + path.join( pathString, basePkg + 'f' ), + path.join( pathString, basePkg ), + path.join( pathString, 'c' + basePkg + 'f' ), + path.join( pathString, 'c' + basePkg ) + ]; + + // Get the list of all packages in `math/base/special/*`: + names = ls( opts ); + + // Filter the list of packages to only include those which match the combinations: + for ( i = 0; i < combinations.length; i++ ) { + pkg = combinations[ i ]; + for ( j = 0; j < names.length; j++ ) { + if ( names[ j ] === pkg ) { + pkgs.push( pkg ); + } + } + } + + return pkgs; +} + +/** +* Returns the input and output dtypes for a given package. +* +* ## Note +* +* - Currently, this function only supports those packages which expect a single input and return a single output. +* - In order to support packages with multiple inputs, we'll need to restructure our table and calculate accordingly. +* - As of now, each array in our table looks like this: +* +* [ input_dtype, output_dtype, package_name ] +* For example: [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] +* +* This is fine for single input & single output functions. But, for functions such as `pow`, which expect two input values, we can have: +* +* [ number_of_inputs, input_dtype_1, input_dtype_2, ... input_dtype_n, output_dtype, package_name ] +* [ 2, 'float64', 'float64', `float64`, '@stdlib/math/base/special/pow' ] +* +* @private +* @param {string} alias - package name +* @returns {Array} input and output dtypes +* +* @example +* var dtypes = getDtypes( 'acos' ); +* // returns [ 'float64', 'float64' ] +* +* @example +* var dtypes = getDtypes( 'acosf' ); +* // returns [ 'float32', 'float32' ] +*/ +function getDtypes( alias ) { + var outputDtype; + var inputDtype; + var path; + var json; + var pkg; + var out; + var o; + + // Resolve the package: + pkg = findPkgs({ + 'dir': ROOT_DIR, + 'pattern': '**/math/base/special/'+ alias +'/package.json' + }); + + if ( pkg.length === 0 ) { + return []; + } + + // Get the meta data: + path = resolve( ROOT_DIR, pkg[ 0 ] ); + json = readJSON( resolve( path, 'package.json' ), jsonOpts ); + o = json.__stdlib__; // eslint-disable-line no-underscore-dangle + if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { + out = o.scaffold; + } + + // NOTE: We might need to reconsider the below logic if there are two or more inputs... + inputDtype = out.parameters[ 0 ].type.dtype; + outputDtype = out.returns.type.dtype; + + return [ inputDtype, outputDtype ]; +} + + +// MAIN // + +/** +* Generate the function table. +* +* @returns {Array} function table +* +* @example +* var basePkg = 'ceil'; +* +* var table = generateTable(); +* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ], [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ] ] +*/ +function generateTable() { + var aliasName; + var dtypes; + var table; + var pkgs; + var pkg; + var i; + + // Get the list of relevant packages for the given base package: + pkgs = getRelevantPackages(); + + // Initialize the table: + table = []; + + // Loop over the packages and get the input and output dtypes: + for ( i = 0; i < pkgs.length; i++ ) { + // Extract the alias name out of the package path: + pkg = pkgs[ i ]; + aliasName = pkg.replace( pathString + '/', '' ); + dtypes = getDtypes( aliasName ); + table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkg ] ); + } + + return table; +} + + +// EXPORTS // + +module.exports = generateTable; diff --git a/lib/node_modules/@stdlib/math/special/ceil/src/addon.c b/lib/node_modules/@stdlib/math/special/ceil/src/addon.c new file mode 100644 index 000000000000..8c8b5c968b7f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/src/addon.c @@ -0,0 +1,183 @@ +/** +* @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/cceil.h" +#include "stdlib/math/base/special/cceilf.h" +#include "stdlib/math/base/special/ceil.h" +#include "stdlib/math/base/special/ceilf.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_ceil"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + // complex64 (1) + stdlib_ndarray_c_z_as_z_z, + + // float32 (3) + stdlib_ndarray_f_c_as_c_c, + stdlib_ndarray_f_z_as_z_z, + stdlib_ndarray_f_d_as_d_d, + + // float64 (1) + stdlib_ndarray_d_z_as_z_z, + + // int32 (2) + stdlib_ndarray_i_z_as_z_z, + stdlib_ndarray_i_d_as_d_d, + + // int8 (4) + stdlib_ndarray_s_c_as_c_c, + stdlib_ndarray_s_z_as_z_z, + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_d_as_d_d, + + // uint16 (4) + stdlib_ndarray_t_c_as_c_c, + stdlib_ndarray_t_z_as_z_z, + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_d_as_d_d, + + // uint32 (2) + stdlib_ndarray_u_z_as_z_z, + stdlib_ndarray_u_d_as_d_d, + + // uint8 (4) + stdlib_ndarray_b_c_as_c_c, + stdlib_ndarray_b_z_as_z_z, + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_d_as_d_d, + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // complex64 (1) + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, + + // float32 (3) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + + // float64 (1) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX128, + + // int32 (2) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + + // int8 (4) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + + // uint16 (4) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + + // uint32 (2) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + + // uint8 (4) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // complex64 (1) + (void *)stdlib_base_cceil, + + // float32 (3) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceil, + + // float64 (1) + (void *)stdlib_base_cceil, + + // int32 (2) + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceil, + + // int8 (4) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceilf, + (void *)stdlib_base_ceil, + + // uint16 (4) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceilf, + (void *)stdlib_base_ceil, + + // uint32 (2) + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceil, + + // uint8 (4) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceilf, + (void *)stdlib_base_ceil, + +}; + +// 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: + 21, + + // 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 )