diff --git a/lib/node_modules/@stdlib/math/base/special/cfloor/package.json b/lib/node_modules/@stdlib/math/base/special/cfloor/package.json index 9f551d2f90ca..81ce0a2a5d2a 100644 --- a/lib/node_modules/@stdlib/math/base/special/cfloor/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cfloor/package.json @@ -66,5 +66,20 @@ "complex", "cmplx", "number" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "complex128" + } + } + ], + "returns": { + "type": { + "dtype": "complex128" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/cfloorf/package.json b/lib/node_modules/@stdlib/math/base/special/cfloorf/package.json index 356213819cf8..72ee7435ef8f 100644 --- a/lib/node_modules/@stdlib/math/base/special/cfloorf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cfloorf/package.json @@ -66,5 +66,20 @@ "complex", "cmplx", "number" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "complex64" + } + } + ], + "returns": { + "type": { + "dtype": "complex64" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/fibonacci/package.json b/lib/node_modules/@stdlib/math/base/special/fibonacci/package.json index a485d8b82c4a..35affb677874 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonacci/package.json +++ b/lib/node_modules/@stdlib/math/base/special/fibonacci/package.json @@ -62,5 +62,21 @@ "fibonacci", "fib", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "int32" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json b/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json index 0b60201bb397..ba887dba34a6 100644 --- a/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json +++ b/lib/node_modules/@stdlib/math/base/special/fibonaccif/package.json @@ -62,5 +62,21 @@ "fibonaccif", "fib", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "int32" + } + } + ], + "returns": { + "type": { + "dtype": "float32" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/floor/package.json b/lib/node_modules/@stdlib/math/base/special/floor/package.json index daa4df3c537d..c152f12bcf84 100644 --- a/lib/node_modules/@stdlib/math/base/special/floor/package.json +++ b/lib/node_modules/@stdlib/math/base/special/floor/package.json @@ -66,5 +66,20 @@ "double", "double-precision", "dbl" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "float64" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/floorf/package.json b/lib/node_modules/@stdlib/math/base/special/floorf/package.json index d3b01793472f..a3a0a981bb1b 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/floorf/package.json @@ -66,5 +66,20 @@ "float", "single-precision", "single" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "float32" + } + } + ], + "returns": { + "type": { + "dtype": "float32" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/sin/package.json b/lib/node_modules/@stdlib/math/base/special/sin/package.json index c407ebd5202f..116d2eee6221 100644 --- a/lib/node_modules/@stdlib/math/base/special/sin/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sin/package.json @@ -63,5 +63,20 @@ "trigonometry", "radians", "angle" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "float64" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrt/package.json b/lib/node_modules/@stdlib/math/base/special/sqrt/package.json index 949ffa145e87..4634a9386e80 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrt/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sqrt/package.json @@ -63,5 +63,20 @@ "root", "power", "number" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "float64" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json index 70c0cea65789..7bd0c208a276 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json @@ -63,5 +63,20 @@ "root", "power", "number" - ] + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "float32" + } + } + ], + "returns": { + "type": { + "dtype": "float32" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/lib/data.js b/lib/node_modules/@stdlib/math/special/fibonacci/lib/data.js new file mode 100644 index 000000000000..77859e778b7e --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/lib/data.js @@ -0,0 +1,96 @@ +/** +* @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 stdlib/capitalized-comments */ + +'use strict'; + +// MODULES // + +var fibonacci = require( '@stdlib/math/base/special/fibonacci' ); +var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' ); + + +// MAIN // + +var data = [ + // 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`). + + // float32 + fibonacci, + fibonaccif, + fibonaccif, + + // float64 + fibonacci, + fibonacci, + fibonacci, + + // int16 + fibonacci, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + + // int32 + fibonacci, + fibonaccif, + fibonaccif, + + // int8 + fibonacci, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + + // uint16 + fibonacci, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + + // uint32 + fibonacci, + fibonaccif, + fibonaccif, + + // uint8 + fibonacci, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + fibonaccif, + + // generic + fibonacci +]; + + +// EXPORTS // + +module.exports = data; diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/lib/meta.json b/lib/node_modules/@stdlib/math/special/fibonacci/lib/meta.json new file mode 100644 index 000000000000..83e1c3c14e09 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/lib/meta.json @@ -0,0 +1,5 @@ +{ + "nargs": 2, + "nin": 1, + "nout": 1 +} diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js new file mode 100644 index 000000000000..6d38c0803cc7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js @@ -0,0 +1,93 @@ +/** +* @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, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.generic, + + // float64 (3) + dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.generic, + + // int16 (5) + dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.int32, + dtypes.int16, dtypes.int16, + dtypes.int16, dtypes.generic, + + // int32 (3) + dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.int32, + dtypes.int32, dtypes.generic, + + // int8 (6) + dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.int32, + dtypes.int8, dtypes.int16, + dtypes.int8, dtypes.int8, + dtypes.int8, dtypes.generic, + + // uint16 (6) + dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.int32, + dtypes.uint16, dtypes.uint32, + dtypes.uint16, dtypes.uint16, + dtypes.uint16, dtypes.generic, + + // uint32 (3) + dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.uint32, + dtypes.uint32, dtypes.generic, + + // uint8 (8) + dtypes.uint8, dtypes.float64, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.int32, + dtypes.uint8, dtypes.int16, + dtypes.uint8, dtypes.uint32, + dtypes.uint8, dtypes.uint16, + dtypes.uint8, dtypes.uint8, + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.json b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.json new file mode 100644 index 000000000000..6589a4b342a9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.json @@ -0,0 +1 @@ +[11,12,11,11,11,17,12,12,12,11,12,17,4,12,4,11,4,6,4,4,4,17,6,12,6,6,6,17,1,12,1,11,1,6,1,4,1,1,1,17,5,12,5,11,5,6,5,7,5,5,5,17,7,12,7,7,7,17,2,12,2,11,2,6,2,4,2,7,2,5,2,2,2,17,17,17] diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/package.json b/lib/node_modules/@stdlib/math/special/fibonacci/package.json new file mode 100644 index 000000000000..02b05a7faf8c --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/math/special/fibonacci", + "version": "0.0.0", + "description": "Compute the nth Fibonacci number.", + "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", + "fibonacci", + "fib", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js new file mode 100644 index 000000000000..d54a3da7601f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js @@ -0,0 +1,484 @@ +/** +* @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 generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// 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 + ', dtypes.' + outputTypes[ j ]; + 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 meta.json file content. +* +* @private +* @returns {string} meta.json file content +*/ +function generateMetaFile() { + var meta = { + 'nargs': 2, + 'nin': 1, + 'nout': 1 + }; + return JSON.stringify( meta, null, 2 ) + '\n'; +} + +/** +* 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( '/' ); + + // In future, we can get this dtype from the structured package data, once we have it: + 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 // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var filteredMatches; + var typesJsonOut; + var metaOut; + var dataOut; + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + var i; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // 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 ] ); + } + } + + // 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 types.json: + typesJsonOut = generateTypesJsonFile( matches ); + writeFileSync( join( __dirname, '../lib/types.json' ), typesJsonOut, { + 'encoding': 'utf8' + }); + + // Generate meta.json: + metaOut = generateMetaFile(); + writeFileSync( join( __dirname, '../lib/meta.json' ), metaOut, { + 'encoding': 'utf8' + }); + + // Generate data.js: + dataOut = generateDataFile( matches, header ); + writeFileSync( join( __dirname, '../lib/data.js' ), dataOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( filteredMatches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js new file mode 100644 index 000000000000..2f8805783331 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js @@ -0,0 +1,327 @@ +/** +* @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 join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); +var scaffoldDatabase = require( '@stdlib/math/special/scripts/scaffold_database.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' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); + + +// VARIABLES // + +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); + + +// 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 +* @param {Array} kernelList - list of available kernels +* @returns {string} kernel name +* +* @example +* var kernels = [ 'stdlib_ndarray_f_d_as_d_d', 'stdlib_ndarray_f_d_as_f_f' ]; +* var kernel = selectKernelName( 'float32', 'float64', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_f_d_as_d_d' +* +* @example +* var kernels = [ 'stdlib_ndarray_d_f_as_d_d', 'stdlib_ndarray_d_f_as_f_f' ]; +* var kernel = selectKernelName( 'float64', 'float32', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_d_f_as_d_d' +*/ +function selectKernelName( inputDtype, outputDtype, scalarKernel, kernelList ) { + 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' + } + + if ( kernelList.indexOf( ndarrayKernel ) === -1 ) { + return; + } + + return ndarrayKernel; +} + + +// MAIN // + +/** +* Main function to generate dtype mappings. +* +* @private +* @returns {Array} array of mappings +*/ +function main() { + 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, NDARRAY_KERNELS ); // selectKernelName( 'complex64', 'float32', '@stdlib/math/base/special/cfloorf', kernels ) => 'stdlib_ndarray_c_f_as_c_c' + + // Generate mapping: + needsPromotion = inputDtype !== outputDtype; + cFunctionName = scalarKernel.replace( '@stdlib/', 'stdlib_' ); + cFunctionName = cFunctionName.replace( /\//g, '_' ); + + mappings.push([ + inputDtype, + outputDtype, + scalarKernel, + needsPromotion, + ( needsPromotion ) ? outputDtype : null, + ( needsPromotion ) ? outputDtype : null, + cFunctionName, + kernelName + ]); + } + } + + return mappings; +} + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c new file mode 100644 index 000000000000..c7877a3d4f43 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c @@ -0,0 +1,205 @@ +/** +* @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/fibonacci.h" +#include "stdlib/math/base/special/fibonaccif.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_fibonacci"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + // float32 (2) + stdlib_ndarray_f_d_as_i_d, + stdlib_ndarray_f_f_as_i_f, + + // float64 (2) + stdlib_ndarray_d_d_as_i_d, + stdlib_ndarray_d_f_as_i_d, + + // int16 (4) + stdlib_ndarray_k_d_as_i_d, + stdlib_ndarray_k_f_as_i_f, + stdlib_ndarray_k_i_as_i_f, + stdlib_ndarray_k_k_as_i_f, + + // int32 (2) + stdlib_ndarray_i_d, + stdlib_ndarray_i_i_as_i_f, + + // int8 (5) + stdlib_ndarray_s_d_as_i_d, + stdlib_ndarray_s_f_as_i_f, + stdlib_ndarray_s_i_as_i_f, + stdlib_ndarray_s_k_as_i_f, + stdlib_ndarray_s_s_as_i_f, + + // uint16 (5) + stdlib_ndarray_t_d_as_i_d, + stdlib_ndarray_t_f_as_i_f, + stdlib_ndarray_t_i_as_i_f, + stdlib_ndarray_t_u_as_i_f, + stdlib_ndarray_t_t_as_i_f, + + // uint32 (2) + stdlib_ndarray_u_d_as_i_d, + stdlib_ndarray_u_u_as_i_f, + + // uint8 (7) + stdlib_ndarray_b_d_as_i_d, + stdlib_ndarray_b_f_as_i_f, + stdlib_ndarray_b_i_as_i_f, + stdlib_ndarray_b_k_as_i_f, + stdlib_ndarray_b_u_as_i_f, + stdlib_ndarray_b_t_as_i_f, + stdlib_ndarray_b_b_as_i_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 (4) + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, + + // int32 (2) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, + + // int8 (5) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT8, + + // uint16 (5) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, + + // uint32 (2) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, + + // uint8 (7) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT8 + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // float32 (2) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + + // float64 (2) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonacci, + + // int16 (4) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + + // int32 (2) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + + // int8 (5) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + + // uint16 (5) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + + // uint32 (2) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + + // uint8 (7) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonaccif + +}; + +// 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: + 29, + + // 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/floor/lib/data.js b/lib/node_modules/@stdlib/math/special/floor/lib/data.js new file mode 100644 index 000000000000..1480a9a3e614 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/lib/data.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. */ + +/* eslint-disable stdlib/capitalized-comments */ + +'use strict'; + +// MODULES // + +var cfloor = require( '@stdlib/math/base/special/cfloor' ); +var cfloorf = require( '@stdlib/math/base/special/cfloorf' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +var identityInt32 = require( '@stdlib/number/int32/base/identity' ); +var identityInt16 = require( '@stdlib/number/int16/base/identity' ); +var identityInt8 = require( '@stdlib/number/int8/base/identity' ); +var identityUint32 = require( '@stdlib/number/uint32/base/identity' ); +var identityUint16 = require( '@stdlib/number/uint16/base/identity' ); +var identityUint8 = require( '@stdlib/number/uint8/base/identity' ); + + +// MAIN // + +var data = [ + // 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`). + + // complex64 + cfloor, + cfloorf, + cfloorf, + + // complex128 + cfloor, + cfloor, + cfloor, + + // float32 + floor, + floorf, + cfloor, + cfloorf, + floorf, + + // float64 + floor, + floor, + cfloor, + cfloor, + floor, + + // int16 + floor, + floorf, + identityInt32, + identityInt16, + cfloor, + cfloorf, + identityInt16, + + // int32 + floor, + identityInt32, + cfloor, + identityInt32, + + // int8 + floor, + floorf, + identityInt32, + identityInt16, + identityInt8, + cfloor, + cfloorf, + identityInt8, + + // uint16 + floor, + floorf, + identityInt32, + identityUint32, + identityUint16, + cfloor, + cfloorf, + identityUint16, + + // uint32 + floor, + identityUint32, + cfloor, + identityUint32, + + // uint8 + floor, + floorf, + identityInt32, + identityInt16, + identityUint32, + identityUint16, + identityUint8, + cfloor, + cfloorf, + identityUint8, + + // generic + floor +]; + + +// EXPORTS // + +module.exports = data; diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/meta.json b/lib/node_modules/@stdlib/math/special/floor/lib/meta.json new file mode 100644 index 000000000000..83e1c3c14e09 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/lib/meta.json @@ -0,0 +1,5 @@ +{ + "nargs": 2, + "nin": 1, + "nout": 1 +} diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/types.js b/lib/node_modules/@stdlib/math/special/floor/lib/types.js new file mode 100644 index 000000000000..4df5e8b36939 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/lib/types.js @@ -0,0 +1,117 @@ +/** +* @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 = [ + // complex64 (3) + dtypes.complex64, dtypes.complex128, + dtypes.complex64, dtypes.complex64, + dtypes.complex64, dtypes.generic, + + // complex128 (3) + dtypes.complex128, dtypes.complex128, + dtypes.complex128, dtypes.complex64, + dtypes.complex128, dtypes.generic, + + // float32 (5) + dtypes.float32, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.complex128, + dtypes.float32, dtypes.complex64, + dtypes.float32, dtypes.generic, + + // float64 (5) + dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.complex128, + dtypes.float64, dtypes.complex64, + dtypes.float64, dtypes.generic, + + // int16 (7) + dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.int32, + dtypes.int16, dtypes.int16, + dtypes.int16, dtypes.complex128, + dtypes.int16, dtypes.complex64, + dtypes.int16, dtypes.generic, + + // int32 (4) + dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.int32, + dtypes.int32, dtypes.complex128, + dtypes.int32, dtypes.generic, + + // int8 (8) + dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.int32, + dtypes.int8, dtypes.int16, + dtypes.int8, dtypes.int8, + dtypes.int8, dtypes.complex128, + dtypes.int8, dtypes.complex64, + dtypes.int8, dtypes.generic, + + // uint16 (8) + dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.int32, + dtypes.uint16, dtypes.uint32, + dtypes.uint16, dtypes.uint16, + dtypes.uint16, dtypes.complex128, + dtypes.uint16, dtypes.complex64, + dtypes.uint16, dtypes.generic, + + // uint32 (4) + dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.uint32, + dtypes.uint32, dtypes.complex128, + dtypes.uint32, dtypes.generic, + + // uint8 (10) + dtypes.uint8, dtypes.float64, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.int32, + dtypes.uint8, dtypes.int16, + dtypes.uint8, dtypes.uint32, + dtypes.uint8, dtypes.uint16, + dtypes.uint8, dtypes.uint8, + dtypes.uint8, dtypes.complex128, + dtypes.uint8, dtypes.complex64, + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/types.json b/lib/node_modules/@stdlib/math/special/floor/lib/types.json new file mode 100644 index 000000000000..a52eea643a68 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/lib/types.json @@ -0,0 +1 @@ +[14,15,14,14,14,17,15,15,15,14,15,17,11,12,11,11,11,15,11,14,11,17,12,12,12,11,12,15,12,14,12,17,4,12,4,11,4,6,4,4,4,15,4,14,4,17,6,12,6,6,6,15,6,17,1,12,1,11,1,6,1,4,1,1,1,15,1,14,1,17,5,12,5,11,5,6,5,7,5,5,5,15,5,14,5,17,7,12,7,7,7,15,7,17,2,12,2,11,2,6,2,4,2,7,2,5,2,2,2,15,2,14,2,17,17,17] diff --git a/lib/node_modules/@stdlib/math/special/floor/package.json b/lib/node_modules/@stdlib/math/special/floor/package.json new file mode 100644 index 000000000000..abbffc5a4485 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/math/special/floor", + "version": "0.0.0", + "description": "Round a number toward negative 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.floor", + "floor", + "round" + ] +} diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js new file mode 100644 index 000000000000..d54a3da7601f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js @@ -0,0 +1,484 @@ +/** +* @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 generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// 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 + ', dtypes.' + outputTypes[ j ]; + 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 meta.json file content. +* +* @private +* @returns {string} meta.json file content +*/ +function generateMetaFile() { + var meta = { + 'nargs': 2, + 'nin': 1, + 'nout': 1 + }; + return JSON.stringify( meta, null, 2 ) + '\n'; +} + +/** +* 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( '/' ); + + // In future, we can get this dtype from the structured package data, once we have it: + 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 // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var filteredMatches; + var typesJsonOut; + var metaOut; + var dataOut; + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + var i; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // 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 ] ); + } + } + + // 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 types.json: + typesJsonOut = generateTypesJsonFile( matches ); + writeFileSync( join( __dirname, '../lib/types.json' ), typesJsonOut, { + 'encoding': 'utf8' + }); + + // Generate meta.json: + metaOut = generateMetaFile(); + writeFileSync( join( __dirname, '../lib/meta.json' ), metaOut, { + 'encoding': 'utf8' + }); + + // Generate data.js: + dataOut = generateDataFile( matches, header ); + writeFileSync( join( __dirname, '../lib/data.js' ), dataOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( filteredMatches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js new file mode 100644 index 000000000000..2f8805783331 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -0,0 +1,327 @@ +/** +* @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 join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); +var scaffoldDatabase = require( '@stdlib/math/special/scripts/scaffold_database.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' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); + + +// VARIABLES // + +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); + + +// 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 +* @param {Array} kernelList - list of available kernels +* @returns {string} kernel name +* +* @example +* var kernels = [ 'stdlib_ndarray_f_d_as_d_d', 'stdlib_ndarray_f_d_as_f_f' ]; +* var kernel = selectKernelName( 'float32', 'float64', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_f_d_as_d_d' +* +* @example +* var kernels = [ 'stdlib_ndarray_d_f_as_d_d', 'stdlib_ndarray_d_f_as_f_f' ]; +* var kernel = selectKernelName( 'float64', 'float32', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_d_f_as_d_d' +*/ +function selectKernelName( inputDtype, outputDtype, scalarKernel, kernelList ) { + 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' + } + + if ( kernelList.indexOf( ndarrayKernel ) === -1 ) { + return; + } + + return ndarrayKernel; +} + + +// MAIN // + +/** +* Main function to generate dtype mappings. +* +* @private +* @returns {Array} array of mappings +*/ +function main() { + 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, NDARRAY_KERNELS ); // selectKernelName( 'complex64', 'float32', '@stdlib/math/base/special/cfloorf', kernels ) => 'stdlib_ndarray_c_f_as_c_c' + + // Generate mapping: + needsPromotion = inputDtype !== outputDtype; + cFunctionName = scalarKernel.replace( '@stdlib/', 'stdlib_' ); + cFunctionName = cFunctionName.replace( /\//g, '_' ); + + mappings.push([ + inputDtype, + outputDtype, + scalarKernel, + needsPromotion, + ( needsPromotion ) ? outputDtype : null, + ( needsPromotion ) ? outputDtype : null, + cFunctionName, + kernelName + ]); + } + } + + return mappings; +} + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/floor/src/addon.c b/lib/node_modules/@stdlib/math/special/floor/src/addon.c new file mode 100644 index 000000000000..02a309065bd3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/src/addon.c @@ -0,0 +1,279 @@ +/** +* @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/cfloor.h" +#include "stdlib/math/base/special/cfloorf.h" +#include "stdlib/math/base/special/floor.h" +#include "stdlib/math/base/special/floorf.h" +#include "stdlib/number/int32/base/identity.h" +#include "stdlib/number/int16/base/identity.h" +#include "stdlib/number/int8/base/identity.h" +#include "stdlib/number/uint32/base/identity.h" +#include "stdlib/number/uint16/base/identity.h" +#include "stdlib/number/uint8/base/identity.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_floor"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + // complex64 (2) + stdlib_ndarray_c_z_as_z_z, + stdlib_ndarray_c_c, + + // complex128 (2) + stdlib_ndarray_z_z, + stdlib_ndarray_z_c_as_z_z, + + // float32 (4) + stdlib_ndarray_f_d_as_d_d, + stdlib_ndarray_f_f, + stdlib_ndarray_f_z_as_z_z, + stdlib_ndarray_f_c_as_c_c, + + // float64 (4) + stdlib_ndarray_d_d, + stdlib_ndarray_d_f_as_d_d, + stdlib_ndarray_d_z_as_z_z, + stdlib_ndarray_d_c_as_z_z, + + // int16 (6) + stdlib_ndarray_k_d_as_d_d, + stdlib_ndarray_k_f_as_f_f, + stdlib_ndarray_k_i_as_i_i, + stdlib_ndarray_k_k, + stdlib_ndarray_k_z_as_z_z, + stdlib_ndarray_k_c_as_c_c, + + // int32 (3) + stdlib_ndarray_i_d_as_d_d, + stdlib_ndarray_i_i, + stdlib_ndarray_i_z_as_z_z, + + // int8 (7) + stdlib_ndarray_s_d_as_d_d, + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_i_as_i_i, + stdlib_ndarray_s_k_as_k_k, + stdlib_ndarray_s_s, + stdlib_ndarray_s_z_as_z_z, + stdlib_ndarray_s_c_as_c_c, + + // uint16 (7) + stdlib_ndarray_t_d_as_d_d, + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_i_as_i_i, + stdlib_ndarray_t_u_as_u_u, + stdlib_ndarray_t_t, + stdlib_ndarray_t_z_as_z_z, + stdlib_ndarray_t_c_as_c_c, + + // uint32 (3) + stdlib_ndarray_u_d_as_d_d, + stdlib_ndarray_u_u, + stdlib_ndarray_u_z_as_z_z, + + // uint8 (9) + stdlib_ndarray_b_d_as_d_d, + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_i_as_i_i, + stdlib_ndarray_b_k_as_k_k, + stdlib_ndarray_b_u_as_u_u, + stdlib_ndarray_b_t_as_t_t, + stdlib_ndarray_b_b, + stdlib_ndarray_b_z_as_z_z, + stdlib_ndarray_b_c_as_c_c + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // complex64 (2) + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX64, + + // complex128 (2) + STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX64, + + // float32 (4) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX64, + + // float64 (4) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX64, + + // int16 (6) + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_COMPLEX64, + + // int32 (3) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_COMPLEX128, + + // int8 (7) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT8, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX64, + + // uint16 (7) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX64, + + // uint32 (3) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_COMPLEX128, + + // uint8 (9) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT8, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX64 + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // complex64 (2) + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + + // complex128 (2) + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloor, + + // float32 (4) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + + // float64 (4) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloor, + + // int16 (6) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_number_int16_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + + // int32 (3) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_math_base_special_cfloor, + + // int8 (7) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_number_int16_base_identity, + (void *)stdlib_number_int8_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + + // uint16 (7) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_number_uint32_base_identity, + (void *)stdlib_number_uint16_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + + // uint32 (3) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_uint32_base_identity, + (void *)stdlib_math_base_special_cfloor, + + // uint8 (9) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_number_int16_base_identity, + (void *)stdlib_number_uint32_base_identity, + (void *)stdlib_number_uint16_base_identity, + (void *)stdlib_number_uint8_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf + +}; + +// 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: + 47, + + // 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/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json new file mode 100644 index 000000000000..868c033bc9c5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -0,0 +1,73 @@ +{ + "sqrt": { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point_and_generic", + "output_policy": "real_floating_point", + "excluded_dtypes": [ "float16", "uint8c", "int64", "uint64" ], + "scalar_kernels": { + "int8": "@stdlib/math/base/special/sqrtf", + "int16": "@stdlib/math/base/special/sqrtf", + "int32": "@stdlib/math/base/special/sqrtf", + "uint8": "@stdlib/math/base/special/sqrtf", + "uint16": "@stdlib/math/base/special/sqrtf", + "uint32": "@stdlib/math/base/special/sqrtf", + "float32": "@stdlib/math/base/special/sqrtf", + "float64": "@stdlib/math/base/special/sqrt", + "generic": "@stdlib/math/base/special/sqrt" + } + }, + "sin": { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point_and_generic", + "output_policy": "real_floating_point", + "excluded_dtypes": [ "float16", "uint8c", "int64", "uint64" ], + "scalar_kernels": { + "int8": "@stdlib/math/base/special/sinf", + "int16": "@stdlib/math/base/special/sinf", + "int32": "@stdlib/math/base/special/sinf", + "uint8": "@stdlib/math/base/special/sinf", + "uint16": "@stdlib/math/base/special/sinf", + "uint32": "@stdlib/math/base/special/sinf", + "float32": "@stdlib/math/base/special/sinf", + "float64": "@stdlib/math/base/special/sin", + "generic": "@stdlib/math/base/special/sin" + } + }, + "floor": { + "input_dtypes": "numeric_and_generic", + "output_dtypes": "numeric_and_generic", + "output_policy": "same", + "excluded_dtypes": [ "float16", "uint8c", "complex32", "int64", "uint64" ], + "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" + } + }, + "fibonacci": { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_and_generic", + "output_policy": "real_and_generic", + "excluded_dtypes": [ "float16", "uint8c", "int64", "uint64" ], + "scalar_kernels": { + "int8": "@stdlib/math/base/special/fibonaccif", + "int16": "@stdlib/math/base/special/fibonaccif", + "int32": "@stdlib/math/base/special/fibonaccif", + "uint8": "@stdlib/math/base/special/fibonaccif", + "uint16": "@stdlib/math/base/special/fibonaccif", + "uint32": "@stdlib/math/base/special/fibonaccif", + "float32": "@stdlib/math/base/special/fibonaccif", + "float64": "@stdlib/math/base/special/fibonacci", + "generic": "@stdlib/math/base/special/fibonacci" + } + } +} + diff --git a/lib/node_modules/@stdlib/math/special/scripts/generate_scaffolds_database.js b/lib/node_modules/@stdlib/math/special/scripts/generate_scaffolds_database.js new file mode 100644 index 000000000000..8f61d06aaaf7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/generate_scaffolds_database.js @@ -0,0 +1,134 @@ +#!/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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var join = require( 'path' ).join; +var readFile = require( '@stdlib/fs/read-file' ).sync; +var writeFile = require( '@stdlib/fs/write-file' ).sync; +var exists = require( '@stdlib/fs/exists' ).sync; +var objectKeys = require( '@stdlib/utils/keys' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var functionDatabase = require( '@stdlib/math/special/scripts/function_database.json' ); + + +// FUNCTIONS // + +/** +* Extracts scaffold metadata from a package's package.json file. +* +* @private +* @param {string} pkgPath - package path +* @returns {Object} scaffold object +* +* @example +* var scaffold = extractScaffold( '@stdlib/math/base/special/sqrt' ); +* // returns { 'parameters': [...], 'returns': {...} } +*/ +function extractScaffold( pkgPath ) { + var packageJsonPath; + var content; + var path; + var pkg; + + // Convert @stdlib/math/base/special/sqrt to lib/node_modules/@stdlib/math/base/special/sqrt: + path = pkgPath.replace( '@stdlib/', '' ); + packageJsonPath = join( resolve( __dirname, '../../..' ), path, 'package.json' ); + + if ( !exists( packageJsonPath ) ) { + return {}; + } + + content = readFile( packageJsonPath, 'utf8' ); + if ( content instanceof Error ) { + return {}; + } + + pkg = JSON.parse( content ); + + // Return the complete scaffold object: + if ( pkg[ '__stdlib__' ] && pkg[ '__stdlib__' ].scaffold ) { + return pkg[ '__stdlib__' ].scaffold; + } + + return {}; +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var scalarKernelNames; + var scaffoldDatabase; + var scalarKernels; + var jsonContent; + var outputPath; + var functions; + var scaffold; + var pkgPath; + var func; + var pkg; + var i; + var j; + + scaffoldDatabase = {}; + + // Get all function names: + functions = objectKeys( functionDatabase ); + + for ( i = 0; i < functions.length; i++ ) { + func = functions[ i ]; + scalarKernels = functionDatabase[ func ].scalar_kernels; + + // Process each scalar kernel: + scalarKernelNames = objectKeys( scalarKernels ); + for ( j = 0; j < scalarKernelNames.length; j++ ) { + pkg = scalarKernelNames[ j ]; + pkgPath = scalarKernels[ pkg ]; + + // Skip if we already processed this package: + if ( hasOwnProp( scaffoldDatabase, pkgPath ) ) { + continue; + } + + scaffold = extractScaffold( pkgPath ); + + if ( scaffold ) { + scaffoldDatabase[ pkgPath ] = scaffold; + } + } + } + + // Write the dtypes database to file: + outputPath = join( __dirname, 'scaffold_database.json' ); + jsonContent = JSON.stringify( scaffoldDatabase, null, 2 ); + + writeFile( outputPath, jsonContent ); +} + +main(); diff --git a/lib/node_modules/@stdlib/math/special/scripts/scaffold_database.json b/lib/node_modules/@stdlib/math/special/scripts/scaffold_database.json new file mode 100644 index 000000000000..4eae06ec0c8e --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/scaffold_database.json @@ -0,0 +1,289 @@ +{ + "@stdlib/math/base/special/sqrtf": { + "parameters": [ + { + "type": { + "dtype": "float32" + } + } + ], + "returns": { + "type": { + "dtype": "float32" + } + } + }, + "@stdlib/math/base/special/sqrt": { + "parameters": [ + { + "type": { + "dtype": "float64" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + }, + "@stdlib/math/base/special/sinf": { + "$schema": "math/base@v1.0", + "base_alias": "sin", + "alias": "sinf", + "pkg_desc": "compute the sine of a single-precision floating-point number (in radians)", + "desc": "computes the sine of a single-precision floating-point number (in radians)", + "short_desc": "sine", + "parameters": [ + { + "name": "x", + "desc": "input value (in radians)", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "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": "real_floating_point_and_generic", + "returns": { + "desc": "sine", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "sin", + "sinf", + "sine", + "trig", + "trigonometry", + "radians", + "angle" + ], + "extra_keywords": [ + "math.sin" + ] + }, + "@stdlib/math/base/special/sin": { + "parameters": [ + { + "type": { + "dtype": "float64" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + }, + "@stdlib/number/int8/base/identity": { + "parameters": [ + { + "type": { + "dtype": "int8" + } + } + ], + "returns": { + "type": { + "dtype": "int8" + } + } + }, + "@stdlib/number/int16/base/identity": { + "parameters": [ + { + "type": { + "dtype": "int16" + } + } + ], + "returns": { + "type": { + "dtype": "int16" + } + } + }, + "@stdlib/number/int32/base/identity": { + "parameters": [ + { + "type": { + "dtype": "int32" + } + } + ], + "returns": { + "type": { + "dtype": "int32" + } + } + }, + "@stdlib/number/uint8/base/identity": { + "parameters": [ + { + "type": { + "dtype": "uint8" + } + } + ], + "returns": { + "type": { + "dtype": "uint8" + } + } + }, + "@stdlib/number/uint16/base/identity": { + "parameters": [ + { + "type": { + "dtype": "uint16" + } + } + ], + "returns": { + "type": { + "dtype": "uint16" + } + } + }, + "@stdlib/number/uint32/base/identity": { + "parameters": [ + { + "type": { + "dtype": "uint32" + } + } + ], + "returns": { + "type": { + "dtype": "uint32" + } + } + }, + "@stdlib/math/base/special/floorf": { + "parameters": [ + { + "type": { + "dtype": "float32" + } + } + ], + "returns": { + "type": { + "dtype": "float32" + } + } + }, + "@stdlib/math/base/special/floor": { + "parameters": [ + { + "type": { + "dtype": "float64" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + }, + "@stdlib/math/base/special/cfloorf": { + "parameters": [ + { + "type": { + "dtype": "complex64" + } + } + ], + "returns": { + "type": { + "dtype": "complex64" + } + } + }, + "@stdlib/math/base/special/cfloor": { + "parameters": [ + { + "type": { + "dtype": "complex128" + } + } + ], + "returns": { + "type": { + "dtype": "complex128" + } + } + }, + "@stdlib/math/base/special/fibonaccif": { + "parameters": [ + { + "type": { + "dtype": "int32" + } + } + ], + "returns": { + "type": { + "dtype": "float32" + } + } + }, + "@stdlib/math/base/special/fibonacci": { + "parameters": [ + { + "type": { + "dtype": "int32" + } + } + ], + "returns": { + "type": { + "dtype": "float64" + } + } + } +} diff --git a/lib/node_modules/@stdlib/math/special/sin/lib/data.js b/lib/node_modules/@stdlib/math/special/sin/lib/data.js new file mode 100644 index 000000000000..d6593851b401 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/lib/data.js @@ -0,0 +1,81 @@ +/** +* @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 stdlib/capitalized-comments */ + +'use strict'; + +// MODULES // + +var sin = require( '@stdlib/math/base/special/sin' ); +var sinf = require( '@stdlib/math/base/special/sinf' ); + + +// MAIN // + +var data = [ + // 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`). + + // float32 + sin, + sinf, + sinf, + + // float64 + sin, + sin, + sin, + + // int16 + sin, + sinf, + sinf, + + // int32 + sin, + sinf, + + // int8 + sin, + sinf, + sinf, + + // uint16 + sin, + sinf, + sinf, + + // uint32 + sin, + sinf, + + // uint8 + sin, + sinf, + sinf, + + // generic + sin +]; + + +// EXPORTS // + +module.exports = data; diff --git a/lib/node_modules/@stdlib/math/special/sin/lib/meta.json b/lib/node_modules/@stdlib/math/special/sin/lib/meta.json new file mode 100644 index 000000000000..83e1c3c14e09 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/lib/meta.json @@ -0,0 +1,5 @@ +{ + "nargs": 2, + "nin": 1, + "nout": 1 +} diff --git a/lib/node_modules/@stdlib/math/special/sin/lib/types.js b/lib/node_modules/@stdlib/math/special/sin/lib/types.js new file mode 100644 index 000000000000..c44d4cf38a19 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/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, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.generic, + + // float64 (3) + dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.generic, + + // int16 (3) + dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.generic, + + // int32 (2) + dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.generic, + + // int8 (3) + dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.generic, + + // uint16 (3) + dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.generic, + + // uint32 (2) + dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.generic, + + // uint8 (3) + dtypes.uint8, dtypes.float64, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/sin/lib/types.json b/lib/node_modules/@stdlib/math/special/sin/lib/types.json new file mode 100644 index 000000000000..f8914ac0faf2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/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/sin/package.json b/lib/node_modules/@stdlib/math/special/sin/package.json new file mode 100644 index 000000000000..38c8f0e87423 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/math/special/sin", + "version": "0.0.0", + "description": "Compute the sine of a number.", + "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.sin", + "sin", + "sine", + "trig", + "trigonometry", + "radians", + "angle" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js new file mode 100644 index 000000000000..d54a3da7601f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -0,0 +1,484 @@ +/** +* @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 generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// 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 + ', dtypes.' + outputTypes[ j ]; + 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 meta.json file content. +* +* @private +* @returns {string} meta.json file content +*/ +function generateMetaFile() { + var meta = { + 'nargs': 2, + 'nin': 1, + 'nout': 1 + }; + return JSON.stringify( meta, null, 2 ) + '\n'; +} + +/** +* 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( '/' ); + + // In future, we can get this dtype from the structured package data, once we have it: + 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 // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var filteredMatches; + var typesJsonOut; + var metaOut; + var dataOut; + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + var i; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // 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 ] ); + } + } + + // 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 types.json: + typesJsonOut = generateTypesJsonFile( matches ); + writeFileSync( join( __dirname, '../lib/types.json' ), typesJsonOut, { + 'encoding': 'utf8' + }); + + // Generate meta.json: + metaOut = generateMetaFile(); + writeFileSync( join( __dirname, '../lib/meta.json' ), metaOut, { + 'encoding': 'utf8' + }); + + // Generate data.js: + dataOut = generateDataFile( matches, header ); + writeFileSync( join( __dirname, '../lib/data.js' ), dataOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( filteredMatches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js new file mode 100644 index 000000000000..2f8805783331 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js @@ -0,0 +1,327 @@ +/** +* @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 join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); +var scaffoldDatabase = require( '@stdlib/math/special/scripts/scaffold_database.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' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); + + +// VARIABLES // + +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); + + +// 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 +* @param {Array} kernelList - list of available kernels +* @returns {string} kernel name +* +* @example +* var kernels = [ 'stdlib_ndarray_f_d_as_d_d', 'stdlib_ndarray_f_d_as_f_f' ]; +* var kernel = selectKernelName( 'float32', 'float64', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_f_d_as_d_d' +* +* @example +* var kernels = [ 'stdlib_ndarray_d_f_as_d_d', 'stdlib_ndarray_d_f_as_f_f' ]; +* var kernel = selectKernelName( 'float64', 'float32', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_d_f_as_d_d' +*/ +function selectKernelName( inputDtype, outputDtype, scalarKernel, kernelList ) { + 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' + } + + if ( kernelList.indexOf( ndarrayKernel ) === -1 ) { + return; + } + + return ndarrayKernel; +} + + +// MAIN // + +/** +* Main function to generate dtype mappings. +* +* @private +* @returns {Array} array of mappings +*/ +function main() { + 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, NDARRAY_KERNELS ); // selectKernelName( 'complex64', 'float32', '@stdlib/math/base/special/cfloorf', kernels ) => 'stdlib_ndarray_c_f_as_c_c' + + // Generate mapping: + needsPromotion = inputDtype !== outputDtype; + cFunctionName = scalarKernel.replace( '@stdlib/', 'stdlib_' ); + cFunctionName = cFunctionName.replace( /\//g, '_' ); + + mappings.push([ + inputDtype, + outputDtype, + scalarKernel, + needsPromotion, + ( needsPromotion ) ? outputDtype : null, + ( needsPromotion ) ? outputDtype : null, + cFunctionName, + kernelName + ]); + } + } + + return mappings; +} + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/sin/src/addon.c b/lib/node_modules/@stdlib/math/special/sin/src/addon.c new file mode 100644 index 000000000000..c1a6bfd44227 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/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/sin.h" +#include "stdlib/math/base/special/sinf.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_sin"; + +// 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_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, + + // float64 (2) + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sin, + + // int16 (2) + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, + + // int32 (1) + (void *)stdlib_math_base_special_sin, + + // int8 (2) + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, + + // uint16 (2) + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, + + // uint32 (1) + (void *)stdlib_math_base_special_sin, + + // uint8 (2) + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf + +}; + +// 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/sqrt/lib/data.js b/lib/node_modules/@stdlib/math/special/sqrt/lib/data.js new file mode 100644 index 000000000000..e2d7df2bff52 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/lib/data.js @@ -0,0 +1,81 @@ +/** +* @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 stdlib/capitalized-comments */ + +'use strict'; + +// MODULES // + +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); + + +// MAIN // + +var data = [ + // 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`). + + // float32 + sqrt, + sqrtf, + sqrtf, + + // float64 + sqrt, + sqrt, + sqrt, + + // int16 + sqrt, + sqrtf, + sqrtf, + + // int32 + sqrt, + sqrtf, + + // int8 + sqrt, + sqrtf, + sqrtf, + + // uint16 + sqrt, + sqrtf, + sqrtf, + + // uint32 + sqrt, + sqrtf, + + // uint8 + sqrt, + sqrtf, + sqrtf, + + // generic + sqrt +]; + + +// EXPORTS // + +module.exports = data; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/lib/meta.json b/lib/node_modules/@stdlib/math/special/sqrt/lib/meta.json new file mode 100644 index 000000000000..83e1c3c14e09 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/lib/meta.json @@ -0,0 +1,5 @@ +{ + "nargs": 2, + "nin": 1, + "nout": 1 +} diff --git a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js new file mode 100644 index 000000000000..c44d4cf38a19 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/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, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.generic, + + // float64 (3) + dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.generic, + + // int16 (3) + dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.generic, + + // int32 (2) + dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.generic, + + // int8 (3) + dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.generic, + + // uint16 (3) + dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.generic, + + // uint32 (2) + dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.generic, + + // uint8 (3) + dtypes.uint8, dtypes.float64, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.json b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.json new file mode 100644 index 000000000000..f8914ac0faf2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/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/sqrt/package.json b/lib/node_modules/@stdlib/math/special/sqrt/package.json new file mode 100644 index 000000000000..b44a99001fdf --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/package.json @@ -0,0 +1,57 @@ +{ + "name": "@stdlib/math/special/sqrt", + "version": "0.0.0", + "description": "Compute the square root.", + "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__": {} +} diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js new file mode 100644 index 000000000000..d54a3da7601f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -0,0 +1,484 @@ +/** +* @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 generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// 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 + ', dtypes.' + outputTypes[ j ]; + 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 meta.json file content. +* +* @private +* @returns {string} meta.json file content +*/ +function generateMetaFile() { + var meta = { + 'nargs': 2, + 'nin': 1, + 'nout': 1 + }; + return JSON.stringify( meta, null, 2 ) + '\n'; +} + +/** +* 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( '/' ); + + // In future, we can get this dtype from the structured package data, once we have it: + 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 // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var filteredMatches; + var typesJsonOut; + var metaOut; + var dataOut; + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + var i; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // 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 ] ); + } + } + + // 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 types.json: + typesJsonOut = generateTypesJsonFile( matches ); + writeFileSync( join( __dirname, '../lib/types.json' ), typesJsonOut, { + 'encoding': 'utf8' + }); + + // Generate meta.json: + metaOut = generateMetaFile(); + writeFileSync( join( __dirname, '../lib/meta.json' ), metaOut, { + 'encoding': 'utf8' + }); + + // Generate data.js: + dataOut = generateDataFile( matches, header ); + writeFileSync( join( __dirname, '../lib/data.js' ), dataOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( filteredMatches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js new file mode 100644 index 000000000000..2f8805783331 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -0,0 +1,327 @@ +/** +* @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 join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); +var scaffoldDatabase = require( '@stdlib/math/special/scripts/scaffold_database.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' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); + + +// VARIABLES // + +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); + + +// 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 +* @param {Array} kernelList - list of available kernels +* @returns {string} kernel name +* +* @example +* var kernels = [ 'stdlib_ndarray_f_d_as_d_d', 'stdlib_ndarray_f_d_as_f_f' ]; +* var kernel = selectKernelName( 'float32', 'float64', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_f_d_as_d_d' +* +* @example +* var kernels = [ 'stdlib_ndarray_d_f_as_d_d', 'stdlib_ndarray_d_f_as_f_f' ]; +* var kernel = selectKernelName( 'float64', 'float32', '@stdlib/math/base/special/floor', kernels ); +* // returns 'stdlib_ndarray_d_f_as_d_d' +*/ +function selectKernelName( inputDtype, outputDtype, scalarKernel, kernelList ) { + 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' + } + + if ( kernelList.indexOf( ndarrayKernel ) === -1 ) { + return; + } + + return ndarrayKernel; +} + + +// MAIN // + +/** +* Main function to generate dtype mappings. +* +* @private +* @returns {Array} array of mappings +*/ +function main() { + 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, NDARRAY_KERNELS ); // selectKernelName( 'complex64', 'float32', '@stdlib/math/base/special/cfloorf', kernels ) => 'stdlib_ndarray_c_f_as_c_c' + + // Generate mapping: + needsPromotion = inputDtype !== outputDtype; + cFunctionName = scalarKernel.replace( '@stdlib/', 'stdlib_' ); + cFunctionName = cFunctionName.replace( /\//g, '_' ); + + mappings.push([ + inputDtype, + outputDtype, + scalarKernel, + needsPromotion, + ( needsPromotion ) ? outputDtype : null, + ( needsPromotion ) ? outputDtype : null, + cFunctionName, + kernelName + ]); + } + } + + return mappings; +} + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c new file mode 100644 index 000000000000..eb06def94d6b --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/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/sqrt.h" +#include "stdlib/math/base/special/sqrtf.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_sqrt"; + +// 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_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, + + // float64 (2) + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrt, + + // int16 (2) + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, + + // int32 (1) + (void *)stdlib_math_base_special_sqrt, + + // int8 (2) + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, + + // uint16 (2) + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, + + // uint32 (1) + (void *)stdlib_math_base_special_sqrt, + + // uint8 (2) + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf + +}; + +// 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/ndarray/base/unary/data/function_list.json b/lib/node_modules/@stdlib/ndarray/base/unary/data/function_list.json new file mode 100644 index 000000000000..e969cc38f887 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/unary/data/function_list.json @@ -0,0 +1,147 @@ +[ + "stdlib_ndarray_b_b", + "stdlib_ndarray_b_b_as_u_u", + "stdlib_ndarray_b_c", + "stdlib_ndarray_b_c_as_b_c", + "stdlib_ndarray_b_c_as_c_c", + "stdlib_ndarray_b_c_as_z_z", + "stdlib_ndarray_b_d", + "stdlib_ndarray_b_d_as_b_d", + "stdlib_ndarray_b_d_as_d_d", + "stdlib_ndarray_b_f", + "stdlib_ndarray_b_f_as_b_f", + "stdlib_ndarray_b_f_as_d_d", + "stdlib_ndarray_b_f_as_f_f", + "stdlib_ndarray_b_i", + "stdlib_ndarray_b_i_as_b_i", + "stdlib_ndarray_b_i_as_i_i", + "stdlib_ndarray_b_k", + "stdlib_ndarray_b_k_as_b_k", + "stdlib_ndarray_b_k_as_i_i", + "stdlib_ndarray_b_k_as_k_k", + "stdlib_ndarray_b_t", + "stdlib_ndarray_b_t_as_b_t", + "stdlib_ndarray_b_t_as_t_t", + "stdlib_ndarray_b_t_as_u_u", + "stdlib_ndarray_b_u", + "stdlib_ndarray_b_u_as_b_u", + "stdlib_ndarray_b_u_as_u_u", + "stdlib_ndarray_b_z", + "stdlib_ndarray_b_z_as_b_z", + "stdlib_ndarray_b_z_as_z_z", + "stdlib_ndarray_c_c", + "stdlib_ndarray_c_c_as_z_z", + "stdlib_ndarray_c_f_as_c_f", + "stdlib_ndarray_c_z", + "stdlib_ndarray_c_z_as_c_z", + "stdlib_ndarray_c_z_as_z_z", + "stdlib_ndarray_d_d", + "stdlib_ndarray_d_i_as_d_i", + "stdlib_ndarray_d_z", + "stdlib_ndarray_d_z_as_d_z", + "stdlib_ndarray_d_z_as_z_z", + "stdlib_ndarray_f_c", + "stdlib_ndarray_f_c_as_c_c", + "stdlib_ndarray_f_c_as_f_c", + "stdlib_ndarray_f_c_as_z_z", + "stdlib_ndarray_f_d", + "stdlib_ndarray_f_d_as_d_d", + "stdlib_ndarray_f_d_as_f_d", + "stdlib_ndarray_f_f", + "stdlib_ndarray_f_f_as_d_d", + "stdlib_ndarray_f_i_as_f_i", + "stdlib_ndarray_f_z", + "stdlib_ndarray_f_z_as_f_z", + "stdlib_ndarray_f_z_as_z_z", + "stdlib_ndarray_i_d", + "stdlib_ndarray_i_d_as_d_d", + "stdlib_ndarray_i_d_as_i_d", + "stdlib_ndarray_i_i", + "stdlib_ndarray_i_u", + "stdlib_ndarray_i_z", + "stdlib_ndarray_i_z_as_i_z", + "stdlib_ndarray_i_z_as_z_z", + "stdlib_ndarray_k_c", + "stdlib_ndarray_k_c_as_c_c", + "stdlib_ndarray_k_c_as_k_c", + "stdlib_ndarray_k_c_as_z_z", + "stdlib_ndarray_k_d", + "stdlib_ndarray_k_d_as_d_d", + "stdlib_ndarray_k_d_as_k_d", + "stdlib_ndarray_k_f", + "stdlib_ndarray_k_f_as_d_d", + "stdlib_ndarray_k_f_as_f_f", + "stdlib_ndarray_k_f_as_k_f", + "stdlib_ndarray_k_i", + "stdlib_ndarray_k_i_as_i_i", + "stdlib_ndarray_k_i_as_k_i", + "stdlib_ndarray_k_k", + "stdlib_ndarray_k_k_as_i_i", + "stdlib_ndarray_k_t", + "stdlib_ndarray_k_t_as_i_i", + "stdlib_ndarray_k_u", + "stdlib_ndarray_k_u_as_i_i", + "stdlib_ndarray_k_z", + "stdlib_ndarray_k_z_as_k_z", + "stdlib_ndarray_k_z_as_z_z", + "stdlib_ndarray_s_b", + "stdlib_ndarray_s_c", + "stdlib_ndarray_s_c_as_c_c", + "stdlib_ndarray_s_c_as_s_c", + "stdlib_ndarray_s_c_as_z_z", + "stdlib_ndarray_s_d", + "stdlib_ndarray_s_d_as_d_d", + "stdlib_ndarray_s_d_as_s_d", + "stdlib_ndarray_s_f", + "stdlib_ndarray_s_f_as_d_d", + "stdlib_ndarray_s_f_as_f_f", + "stdlib_ndarray_s_f_as_s_f", + "stdlib_ndarray_s_i", + "stdlib_ndarray_s_i_as_i_i", + "stdlib_ndarray_s_i_as_s_i", + "stdlib_ndarray_s_k", + "stdlib_ndarray_s_k_as_i_i", + "stdlib_ndarray_s_k_as_k_k", + "stdlib_ndarray_s_k_as_s_k", + "stdlib_ndarray_s_s", + "stdlib_ndarray_s_s_as_i_i", + "stdlib_ndarray_s_t", + "stdlib_ndarray_s_t_as_i_i", + "stdlib_ndarray_s_u", + "stdlib_ndarray_s_u_as_i_i", + "stdlib_ndarray_s_z", + "stdlib_ndarray_s_z_as_s_z", + "stdlib_ndarray_s_z_as_z_z", + "stdlib_ndarray_t_c", + "stdlib_ndarray_t_c_as_c_c", + "stdlib_ndarray_t_c_as_t_c", + "stdlib_ndarray_t_c_as_z_z", + "stdlib_ndarray_t_d", + "stdlib_ndarray_t_d_as_d_d", + "stdlib_ndarray_t_d_as_t_d", + "stdlib_ndarray_t_f", + "stdlib_ndarray_t_f_as_d_d", + "stdlib_ndarray_t_f_as_f_f", + "stdlib_ndarray_t_f_as_t_f", + "stdlib_ndarray_t_i", + "stdlib_ndarray_t_i_as_i_i", + "stdlib_ndarray_t_i_as_t_i", + "stdlib_ndarray_t_t", + "stdlib_ndarray_t_t_as_u_u", + "stdlib_ndarray_t_u", + "stdlib_ndarray_t_u_as_t_u", + "stdlib_ndarray_t_u_as_u_u", + "stdlib_ndarray_t_z", + "stdlib_ndarray_t_z_as_t_z", + "stdlib_ndarray_t_z_as_z_z", + "stdlib_ndarray_u_d", + "stdlib_ndarray_u_d_as_d_d", + "stdlib_ndarray_u_d_as_u_d", + "stdlib_ndarray_u_u", + "stdlib_ndarray_u_z", + "stdlib_ndarray_u_z_as_u_z", + "stdlib_ndarray_u_z_as_z_z", + "stdlib_ndarray_x_x", + "stdlib_ndarray_z_d_as_z_d", + "stdlib_ndarray_z_z" +] diff --git a/lib/node_modules/@stdlib/number/int16/base/identity/package.json b/lib/node_modules/@stdlib/number/int16/base/identity/package.json index 64cd49b76ade..2a7af8b2077c 100644 --- a/lib/node_modules/@stdlib/number/int16/base/identity/package.json +++ b/lib/node_modules/@stdlib/number/int16/base/identity/package.json @@ -60,6 +60,20 @@ "signed", "int16", "integer" - ], - "__stdlib__": {} + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "int16" + } + } + ], + "returns": { + "type": { + "dtype": "int16" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/number/int32/base/identity/package.json b/lib/node_modules/@stdlib/number/int32/base/identity/package.json index beeadb6fc5b3..64b438ec6f40 100644 --- a/lib/node_modules/@stdlib/number/int32/base/identity/package.json +++ b/lib/node_modules/@stdlib/number/int32/base/identity/package.json @@ -60,6 +60,20 @@ "signed", "int32", "integer" - ], - "__stdlib__": {} + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "int32" + } + } + ], + "returns": { + "type": { + "dtype": "int32" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/number/int8/base/identity/package.json b/lib/node_modules/@stdlib/number/int8/base/identity/package.json index a843d4a766d8..5c51c1989e44 100644 --- a/lib/node_modules/@stdlib/number/int8/base/identity/package.json +++ b/lib/node_modules/@stdlib/number/int8/base/identity/package.json @@ -60,6 +60,20 @@ "signed", "int8", "integer" - ], - "__stdlib__": {} + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "int8" + } + } + ], + "returns": { + "type": { + "dtype": "int8" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/number/uint16/base/identity/package.json b/lib/node_modules/@stdlib/number/uint16/base/identity/package.json index 571c59a74a88..c86a483f8ddd 100644 --- a/lib/node_modules/@stdlib/number/uint16/base/identity/package.json +++ b/lib/node_modules/@stdlib/number/uint16/base/identity/package.json @@ -60,6 +60,20 @@ "unsigned", "uint16", "integer" - ], - "__stdlib__": {} + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "uint16" + } + } + ], + "returns": { + "type": { + "dtype": "uint16" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/number/uint32/base/identity/package.json b/lib/node_modules/@stdlib/number/uint32/base/identity/package.json index 7af04f53fe81..1e8f5f336005 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/identity/package.json +++ b/lib/node_modules/@stdlib/number/uint32/base/identity/package.json @@ -60,6 +60,20 @@ "unsigned", "uint32", "integer" - ], - "__stdlib__": {} + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "uint32" + } + } + ], + "returns": { + "type": { + "dtype": "uint32" + } + } + } + } } diff --git a/lib/node_modules/@stdlib/number/uint8/base/identity/package.json b/lib/node_modules/@stdlib/number/uint8/base/identity/package.json index 884bf3ff121d..f8894c1f52ff 100644 --- a/lib/node_modules/@stdlib/number/uint8/base/identity/package.json +++ b/lib/node_modules/@stdlib/number/uint8/base/identity/package.json @@ -60,6 +60,20 @@ "unsigned", "uint8", "integer" - ], - "__stdlib__": {} + ],"__stdlib__": { + "scaffold": { + "parameters": [ + { + "type": { + "dtype": "uint8" + } + } + ], + "returns": { + "type": { + "dtype": "uint8" + } + } + } + } }