From 56dab208b05e42985315dd235f4d8612b0397c87 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 22 Jul 2025 07:47:39 +0530 Subject: [PATCH 01/31] chore: initial script --- .../special/abs/scripts/generate_addon.js | 387 ++++++++++++++++++ .../@stdlib/math/special/abs/src/addon.c.txt | 131 ++++++ 2 files changed, 518 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js create mode 100644 lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt diff --git a/lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js b/lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js new file mode 100644 index 000000000000..fa4682534f32 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js @@ -0,0 +1,387 @@ +/* eslint-disable */ + +var resolve = require( 'path' ).resolve; +var writeFile = require( '@stdlib/fs/write-file' ).sync; +var readFile = require( '@stdlib/fs/read-file' ).sync; +var replace = require( '@stdlib/string/replace' ); +var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var dtypeEnum2Str = require( '@stdlib/ndarray/base/dtype-enum2str' ); +var uppercase = require( '@stdlib/string/uppercase' ); +var currentYear = require( '@stdlib/time/current-year' ); +var supportedTypes = require( './../lib/types.js' ); + +// VARIABLES // + +var OPTS = { + 'encoding': 'utf8' +}; + +// Define paths +var SRC_PATH = resolve( __dirname, '..', 'src', 'addon.c.txt' ); +var OUT_PATH = resolve( __dirname, '..', 'src', 'addon.c' ); + +// Define constants for the abs function +var FCN_BASENAME = 'abs'; +var FCN_DESCRIPTION = 'Computes the absolute value.'; +var INTERFACE_NAME = 'stdlib_ndarray_abs'; + +// Define a note +var NOTE = 'NOTE: Do not edit this file directly. This file is auto-generated.'; +var YEAR = currentYear(); +var COPYRIGHT = 'The Stdlib Authors'; + +// FUNCTIONS // + +/** +* Generates function mappings based on the existing types.js file. +* +* @private +* @returns {Object} object containing functions, types, and data arrays +*/ +function generateFunctionMappings() { + var functions = []; + var typeEnums = []; + var data = []; + var i, inputDtype, outputDtype, inputChar, outputChar; + var functionName, typePair, dataFunction; + + // Process the supportedTypes array (which contains pairs: input, output, input, output, ...) + for ( i = 0; i < supportedTypes.length; i += 2 ) { + // Convert numeric dtype constants to string names + inputDtype = dtypeEnum2Str( supportedTypes[ i ] ); + outputDtype = dtypeEnum2Str( supportedTypes[ i + 1 ] ); + + // Handle generic types specially + if ( inputDtype === 'generic' || outputDtype === 'generic' ) { + // For generic types, we use a special function name pattern + if ( inputDtype === 'generic' && outputDtype === 'generic' ) { + functionName = 'stdlib_ndarray_v_v'; + } else if ( outputDtype === 'generic' ) { + inputChar = dtypeChar( inputDtype ); + functionName = 'stdlib_ndarray_' + inputChar + '_v'; + } else { + // This case shouldn't occur in the current types.js + continue; + } + } else { + // Get dtype characters for non-generic types + inputChar = dtypeChar( inputDtype ); + outputChar = dtypeChar( outputDtype ); + + if ( inputChar === 'a' ) { + inputChar = 'b'; + } + if ( outputChar === 'a' ) { + outputChar = 'b'; + } + + // Generate function name + functionName = generateFunctionName( inputChar, outputChar ); + } + + functions.push( functionName ); + + // Generate type pair + typePair = generateTypePair( inputDtype, outputDtype ); + typeEnums.push( typePair ); + + // Generate data function (generic types also use abs) + dataFunction = generateDataFunction( inputDtype ); + data.push( dataFunction ); + } + + return { + 'functions': functions, + 'types': typeEnums, + 'data': data + }; +} + +/** +* Generates the ndarray function name for given input and output dtype characters. +* +* @private +* @param {string} inputChar - input dtype character +* @param {string} outputChar - output dtype character +* @returns {string} function name +*/ +function generateFunctionName( inputChar, outputChar ) { + // Use simple naming convention without casting suffix (matches original) + var functionName = 'stdlib_ndarray_' + inputChar + '_' + outputChar; + return functionName; +} + +/** +* Generates the type pair string for given input and output dtypes. +* +* @private +* @param {string} inputDtype - input data type +* @param {string} outputDtype - output data type +* @returns {string} type pair string +*/ +function generateTypePair( inputDtype, outputDtype ) { + var inputEnum, outputEnum; + + // Handle generic type specially + if ( inputDtype === 'generic' ) { + inputEnum = 'STDLIB_NDARRAY_GENERIC'; + } else { + inputEnum = 'STDLIB_NDARRAY_' + uppercase( inputDtype ); + } + + if ( outputDtype === 'generic' ) { + outputEnum = 'STDLIB_NDARRAY_GENERIC'; + } else { + outputEnum = 'STDLIB_NDARRAY_' + uppercase( outputDtype ); + } + + return inputEnum + ', ' + outputEnum; +} + +/** +* Generates the data function pointer for given input dtype. +* +* @private +* @param {string} inputDtype - input data type +* @returns {string} data function pointer +*/ +function generateDataFunction( inputDtype ) { + var functionPtr; + + // Map dtypes to appropriate C functions + if ( inputDtype === 'float64' ) { + functionPtr = '(void *)stdlib_base_abs'; + } else if ( inputDtype === 'float32' ) { + functionPtr = '(void *)stdlib_base_absf'; + } else if ( inputDtype === 'int32' ) { + functionPtr = '(void *)stdlib_base_labs'; + } else if ( inputDtype === 'int16' ) { + functionPtr = '(void *)abs_k'; // Custom int16 abs function + } else if ( inputDtype === 'int8' ) { + functionPtr = '(void *)abs_s'; // Custom int8 abs function + } else if ( inputDtype === 'uint32' ) { + functionPtr = '(void *)identity_u'; // Identity for unsigned types + } else if ( inputDtype === 'uint16' ) { + functionPtr = '(void *)identity_t'; + } else if ( inputDtype === 'uint8' || inputDtype === 'uint8c' ) { + functionPtr = '(void *)identity_b'; + } else if ( inputDtype === 'generic' ) { + functionPtr = '(void *)stdlib_base_abs'; // Generic uses regular abs + } else { + // Default fallback + functionPtr = '(void *)stdlib_base_abs'; + } + + return functionPtr; +} + +/** +* Creates a basic addon.c template if it doesn't exist. +* +* @private +*/ +function createTemplate() { + var template = `/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* {{NOTE}} */ + +#include "stdlib/math/base/special/abs.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/special/labs.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 + +/** +* Evaluates the identity function for an unsigned 32-bit integer. +* +* @param x input value +* @return input value +*/ +static uint32_t identity_u( const uint32_t x ) { + return x; +} + +/** +* Evaluates the identity function for an unsigned 16-bit integer. +* +* @param x input value +* @return input value +*/ +static uint16_t identity_t( const uint16_t x ) { + return x; +} + +/** +* Evaluates the identity function for an unsigned 8-bit integer. +* +* @param x input value +* @return input value +*/ +static uint8_t identity_b( const uint8_t x ) { + return x; +} + +/** +* Computes the absolute value of a signed 16-bit integer. +* +* @param x input value +* @return absolute value +*/ +static int16_t abs_k( const int16_t x ) { + if ( x < 0 ) { + return -x; + } + return x; +} + +/** +* Computes the absolute value of a signed 8-bit integer. +* +* @param x input value +* @return absolute value +*/ +static int8_t abs_s( const int8_t x ) { + if ( x < 0 ) { + return -x; + } + return x; +} + +// Define an interface name: +static const char name[] = "{{INTERFACE_NAME}}"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + {{FUNCTIONS}} +}; + +// Define the **ndarray** argument types for each ndarray function: +static int32_t types[] = { + {{TYPES}} +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + {{DATA}} +}; + +// 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: + {{NUM_FUNCTIONS}}, + + // 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 ) +`; + + var err = writeFile( SRC_PATH, template, OPTS ); + if ( err ) { + throw err; + } + console.log( 'Created template file: ' + SRC_PATH ); +} + +/** +* Generates the addon.c file for the abs function. +* +* @private +* @throws {Error} unexpected error +*/ +function generateAddonC() { + var template; + var functions; + var types; + var data; + var err; + + // Read the template file + template = readFile( SRC_PATH, OPTS ); + if ( template instanceof Error ) { + throw template; + } + + // Generate function signatures, types, and data arrays + var result = generateFunctionMappings(); + functions = result.functions; + types = result.types; + data = result.data; + + // Replace template placeholders + template = replace( template, '{{YEAR}}', YEAR.toString() ); + template = replace( template, '{{COPYRIGHT}}', COPYRIGHT ); + template = replace( template, '{{NOTE}}', NOTE ); + template = replace( template, '{{FCN_BASENAME}}', FCN_BASENAME ); + template = replace( template, '{{FCN_DESCRIPTION}}', FCN_DESCRIPTION ); + template = replace( template, '{{INTERFACE_NAME}}', INTERFACE_NAME ); + template = replace( template, '{{FUNCTIONS}}', functions.join( ',\n\t' ) ); + template = replace( template, '{{TYPES}}', types.join( ',\n\t' ) ); + template = replace( template, '{{DATA}}', data.join( ',\n\t' ) ); + template = replace( template, '{{NUM_FUNCTIONS}}', functions.length.toString() ); + + // Write the generated file + err = writeFile( OUT_PATH, template, OPTS ); + if ( err ) { + throw err; + } + + console.log( 'Generated addon.c with ' + functions.length + ' function mappings.' ); +} + + + +// MAIN // + +console.log( 'Generating addon.c for stdlib abs function...' ); + +// Create template if it doesn't exist, then generate the addon.c file +try { + generateAddonC(); +} catch ( error ) { + if ( error.code === 'ENOENT' ) { + console.log( 'Template file not found. Creating template...' ); + createTemplate(); + generateAddonC(); + } else { + throw error; + } +} diff --git a/lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt b/lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt new file mode 100644 index 000000000000..dde86a193d01 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} {{COPYRIGHT}}. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* {{NOTE}} */ + +#include "stdlib/math/base/special/abs.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/special/labs.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 + +/** +* Evaluates the identity function for an unsigned 32-bit integer. +* +* @param x input value +* @return input value +*/ +static uint32_t identity_u( const uint32_t x ) { + return x; +} + +/** +* Evaluates the identity function for an unsigned 16-bit integer. +* +* @param x input value +* @return input value +*/ +static uint16_t identity_t( const uint16_t x ) { + return x; +} + +/** +* Evaluates the identity function for an unsigned 8-bit integer. +* +* @param x input value +* @return input value +*/ +static uint8_t identity_b( const uint8_t x ) { + return x; +} + +/** +* Computes the absolute value of a signed 16-bit integer. +* +* @param x input value +* @return absolute value +*/ +static int16_t abs_k( const int16_t x ) { + if ( x < 0 ) { + return -x; + } + return x; +} + +/** +* Computes the absolute value of a signed 8-bit integer. +* +* @param x input value +* @return absolute value +*/ +static int8_t abs_s( const int8_t x ) { + if ( x < 0 ) { + return -x; + } + return x; +} + +// Define an interface name: +static const char name[] = "{{INTERFACE_NAME}}"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + {{FUNCTIONS}} +}; + +// Define the **ndarray** argument types for each ndarray function: +static int32_t types[] = { + {{TYPES}} +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + {{DATA}} +}; + +// 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: + {{NUM_FUNCTIONS}}, + + // 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 ) From e1ce37bcc45e9405646d27d2130af345fb72fa0b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 23 Jul 2025 23:00:16 +0530 Subject: [PATCH 02/31] feat: add script to generate addon.c and types.js --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/special/abs/scripts/test.js | 319 ++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/special/abs/scripts/test.js diff --git a/lib/node_modules/@stdlib/math/special/abs/scripts/test.js b/lib/node_modules/@stdlib/math/special/abs/scripts/test.js new file mode 100644 index 000000000000..f863bf702ecb --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/abs/scripts/test.js @@ -0,0 +1,319 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var currentYear = require( '@stdlib/time/current-year' ); + + +// VARIABLES // + +var FUNCTION_NAME = 'abs'; +var KERNEL_MAP = { + 'float64': 'stdlib_base_abs', + 'float32': 'stdlib_base_absf', + 'complex128': 'stdlib_base_cabs', + 'complex64': 'stdlib_base_cabsf', + 'int32': 'stdlib_base_labs', + 'int16': 'stdlib_base_labs', + 'int8': 'stdlib_base_labs', + 'uint32': 'stdlib_base_abs', + 'uint16': 'stdlib_base_abs', + 'uint8': 'stdlib_base_abs', + 'uint8c': 'stdlib_base_abs', + 'generic': 'stdlib_base_abs' +}; +var INCLUDE_MAP = { + 'abs': 'abs.h', + 'absf': 'absf.h', + 'cabs': 'cabs.h', + 'cabsf': 'cabsf.h', + 'labs': 'labs.h' +}; + +/** +* Default output dtype rule for abs function. +* +* @private +* @param {string} input - input dtype +* @returns {Array} array of valid output dtypes +*/ +function outputDtypeRule( input ) { + var rules = { + 'float64': [ 'float64', 'generic' ], + 'float32': [ 'float32', 'float64', 'generic' ], + 'complex128': [ 'float64', 'generic' ], + 'complex64': [ 'float32', 'float64', 'generic' ], + 'int32': [ 'int32', 'uint32', 'float64', 'generic' ], + 'int16': [ 'int16', 'int32', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], + 'int8': [ 'int8', 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], + 'uint32': [ 'uint32', 'float64', 'generic' ], + 'uint16': [ 'int32', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], + 'uint8': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], + 'uint8c': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], + 'generic': [ 'generic' ] + }; + return rules[ input ] || []; +} + +/** +* Generates the ndarray function name for given input and output dtypes. +* +* @private +* @param {string} input - input dtype +* @param {string} output - output dtype +* @returns {string} ndarray function name +*/ +function getNdarrayFcnName( input, output ) { + var map = { + 'float64': 'd', + 'float32': 'f', + 'generic': 'g', + 'int32': 'i', + 'int16': 'k', + 'int8': 's', + 'uint32': 'u', + 'uint16': 't', + 'uint8': 'b', + 'uint8c': 'b' + }; + return 'stdlib_ndarray_' + map[ input ] + '_' + map[ output ]; +} + +/** +* Counts the number of functions in a group. +* +* @private +* @param {string} dt - dtype +* @param {Object} grouped - grouped functions +* @returns {number} count +*/ +function countGroup( dt, grouped ) { + return grouped[ dt ].length; +} + +/** +* Generates function-specific includes. +* +* @private +* @returns {Array} array of include statements +*/ +function generateFunctionIncludes() { + var includeStatement; + var functionIncludes; + var kernelNames; + var includeKey; + var kernel; + var i; + + functionIncludes = []; + kernelNames = Object.keys( KERNEL_MAP ); + for ( i = 0; i < kernelNames.length; i++ ) { + kernel = KERNEL_MAP[ kernelNames[ i ] ]; + includeKey = kernel.replace( 'stdlib_base_', '' ); + if ( INCLUDE_MAP[ includeKey ] ) { + includeStatement = '#include "stdlib/math/base/special/' + INCLUDE_MAP[ includeKey ] + '"'; + if ( functionIncludes.indexOf( includeStatement ) === -1 ) { + functionIncludes.push( includeStatement ); + } + } + } + return functionIncludes; +} + +/** +* Generates type pairs and kernels. +* +* @private +* @returns {Object} object containing types and kernels arrays +*/ +function generateTypesAndKernels() { + var outputDtypes; + var allDtypes; + var kernels; + var output; + var input; + var types; + var i; + var j; + + allDtypes = dtypes( 'all' ); + types = []; + kernels = []; + + for ( i = 0; i < allDtypes.length; i++ ) { + input = allDtypes[ i ]; + outputDtypes = outputDtypeRule( input ); + for ( j = 0; j < outputDtypes.length; j++ ) { + output = outputDtypes[ j ]; + types.push( [ input, output ] ); + kernels.push( KERNEL_MAP[ input ] || 'stdlib_base_' + FUNCTION_NAME ); + } + } + + return { + 'types': types, + 'kernels': kernels + }; +} + +/** +* Main function to generate addon arrays. +* +* @private +*/ +function main() { + var functionIncludes; + var licenseHeader; + var baseIncludes; + var dtypeOrder; + var groupItems; + var cHeader; + var kernels; + var grouped; + var result; + var types; + var jsOut; + var pair; + var cOut; + var obj; + var dt; + var i; + var j; + + result = generateTypesAndKernels(); + types = result.types; + kernels = result.kernels; + + dtypeOrder = [ + 'float64', 'float32', 'generic', 'int32', 'int16', 'int8', 'uint32', 'uint16', 'uint8', 'uint8c' + ]; + grouped = {}; + + for ( i = 0; i < dtypeOrder.length; i++ ) { + grouped[ dtypeOrder[ i ] ] = []; + } + + for ( i = 0; i < types.length; i++ ) { + pair = types[ i ]; + if ( grouped[ pair[ 0 ] ] ) { + grouped[ pair[ 0 ] ].push({ + 'pair': pair, + 'kernel': kernels[ i ] + }); + } + } + + // Write generated_types.js: + licenseHeader = '/**\n* @license Apache-2.0\n*\n* Copyright (c) ' + currentYear() + ' The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the "License");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an "AS IS" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable array-element-newline */\n\n\'use strict\';\n\n// MODULES //\n\nvar dtypes = require( \'@stdlib/ndarray/dtypes\' );\n\n\n// MAIN //\n\nvar types = [\n'; + jsOut = licenseHeader; + + for ( i = 0; i < dtypeOrder.length; i++ ) { + dt = dtypeOrder[ i ]; + groupItems = grouped[ dt ]; + for ( j = 0; j < groupItems.length; j++ ) { + obj = groupItems[ j ]; + jsOut += ' dtypes.' + obj.pair[ 0 ] + ', dtypes.' + obj.pair[ 1 ] + ',\n'; + } + } + jsOut += '];\n\n\n// EXPORTS //\n\nmodule.exports = types;\n'; + writeFileSync( join( __dirname, '../lib/generated_types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Write generated_addon_arrays.c: + cHeader = '/**\n* @license Apache-2.0\n*\n* Copyright (c) ' + currentYear() + ' The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the "License");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an "AS IS" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'; + + // Add base includes (always required for all math functions): + baseIncludes = [ + '#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 ' + ]; + cHeader += baseIncludes.join('\n') + '\n'; + + // Add function-specific includes: + functionIncludes = generateFunctionIncludes(); + if ( functionIncludes.length > 0 ) { + cHeader += functionIncludes.join('\n') + '\n'; + } + + cOut = cHeader; + cOut += '\n// Define a list of ndarray functions:\n'; + cOut += 'static ndarrayFcn functions[] = {\n'; + for ( i = 0; i < dtypeOrder.length; i++ ) { + dt = dtypeOrder[ i ]; + if ( grouped[ dt ].length > 0 ) { + cOut += ' // ' + dt + ' (' + countGroup( dt, grouped ) + ')\n'; + groupItems = grouped[ dt ]; + for ( j = 0; j < groupItems.length; j++ ) { + obj = groupItems[ j ]; + cOut += ' ' + getNdarrayFcnName( obj.pair[ 0 ], obj.pair[ 1 ] ) + ',\n'; + } + } + } + cOut += '};\n\n'; + cOut += '// Define the **ndarray** argument types for each ndarray function:\n'; + cOut += 'static int32_t types[] = {\n'; + for ( i = 0; i < dtypeOrder.length; i++ ) { + dt = dtypeOrder[ i ]; + groupItems = grouped[ dt ]; + for ( j = 0; j < groupItems.length; j++ ) { + obj = groupItems[ j ]; + cOut += ' STDLIB_NDARRAY_' + obj.pair[ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + obj.pair[ 1 ].toUpperCase() + ',\n'; + } + } + cOut += '};\n\n'; + cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; + cOut += 'static void *data[] = {\n'; + for ( i = 0; i < dtypeOrder.length; i++ ) { + dt = dtypeOrder[ i ]; + if ( grouped[ dt ].length > 0 ) { + cOut += ' // ' + dt + ' (' + countGroup( dt, grouped ) + ')\n'; + groupItems = grouped[ dt ]; + for ( j = 0; j < groupItems.length; j++ ) { + obj = groupItems[ j ]; + cOut += ' (void *)' + obj.kernel + ',\n'; + } + } + } + cOut += '};\n\n'; + cOut += '// Create an ndarray function object:\n'; + cOut += 'static const struct ndarrayFunctionObject obj = {\n'; + cOut += ' // ndarray function name:\n name,\n\n'; + cOut += ' // Number of input ndarrays:\n 1,\n\n'; + cOut += ' // Number of output ndarrays:\n 1,\n\n'; + cOut += ' // Total number of ndarray arguments (nin + nout):\n 2,\n\n'; + cOut += ' // Array containing ndarray functions:\n functions,\n\n'; + cOut += ' // Number of ndarray functions:\n ' + types.length + ',\n\n'; + cOut += ' // 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 types,\n\n'; + cOut += ' // 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 data\n};\n\n'; + cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; + writeFileSync( join( __dirname, '../src/generated_addon_arrays.c' ), cOut, { + 'encoding': 'utf8' + }); +} + +main(); From 4977f9e823e298d1b35de8f2c278bbcab1e16a5d Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 23 Jul 2025 23:04:45 +0530 Subject: [PATCH 03/31] refactor: remove script --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/abs/scripts/generate_addon.js | 387 ------------------ 1 file changed, 387 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js diff --git a/lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js b/lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js deleted file mode 100644 index fa4682534f32..000000000000 --- a/lib/node_modules/@stdlib/math/special/abs/scripts/generate_addon.js +++ /dev/null @@ -1,387 +0,0 @@ -/* eslint-disable */ - -var resolve = require( 'path' ).resolve; -var writeFile = require( '@stdlib/fs/write-file' ).sync; -var readFile = require( '@stdlib/fs/read-file' ).sync; -var replace = require( '@stdlib/string/replace' ); -var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); -var dtypeEnum2Str = require( '@stdlib/ndarray/base/dtype-enum2str' ); -var uppercase = require( '@stdlib/string/uppercase' ); -var currentYear = require( '@stdlib/time/current-year' ); -var supportedTypes = require( './../lib/types.js' ); - -// VARIABLES // - -var OPTS = { - 'encoding': 'utf8' -}; - -// Define paths -var SRC_PATH = resolve( __dirname, '..', 'src', 'addon.c.txt' ); -var OUT_PATH = resolve( __dirname, '..', 'src', 'addon.c' ); - -// Define constants for the abs function -var FCN_BASENAME = 'abs'; -var FCN_DESCRIPTION = 'Computes the absolute value.'; -var INTERFACE_NAME = 'stdlib_ndarray_abs'; - -// Define a note -var NOTE = 'NOTE: Do not edit this file directly. This file is auto-generated.'; -var YEAR = currentYear(); -var COPYRIGHT = 'The Stdlib Authors'; - -// FUNCTIONS // - -/** -* Generates function mappings based on the existing types.js file. -* -* @private -* @returns {Object} object containing functions, types, and data arrays -*/ -function generateFunctionMappings() { - var functions = []; - var typeEnums = []; - var data = []; - var i, inputDtype, outputDtype, inputChar, outputChar; - var functionName, typePair, dataFunction; - - // Process the supportedTypes array (which contains pairs: input, output, input, output, ...) - for ( i = 0; i < supportedTypes.length; i += 2 ) { - // Convert numeric dtype constants to string names - inputDtype = dtypeEnum2Str( supportedTypes[ i ] ); - outputDtype = dtypeEnum2Str( supportedTypes[ i + 1 ] ); - - // Handle generic types specially - if ( inputDtype === 'generic' || outputDtype === 'generic' ) { - // For generic types, we use a special function name pattern - if ( inputDtype === 'generic' && outputDtype === 'generic' ) { - functionName = 'stdlib_ndarray_v_v'; - } else if ( outputDtype === 'generic' ) { - inputChar = dtypeChar( inputDtype ); - functionName = 'stdlib_ndarray_' + inputChar + '_v'; - } else { - // This case shouldn't occur in the current types.js - continue; - } - } else { - // Get dtype characters for non-generic types - inputChar = dtypeChar( inputDtype ); - outputChar = dtypeChar( outputDtype ); - - if ( inputChar === 'a' ) { - inputChar = 'b'; - } - if ( outputChar === 'a' ) { - outputChar = 'b'; - } - - // Generate function name - functionName = generateFunctionName( inputChar, outputChar ); - } - - functions.push( functionName ); - - // Generate type pair - typePair = generateTypePair( inputDtype, outputDtype ); - typeEnums.push( typePair ); - - // Generate data function (generic types also use abs) - dataFunction = generateDataFunction( inputDtype ); - data.push( dataFunction ); - } - - return { - 'functions': functions, - 'types': typeEnums, - 'data': data - }; -} - -/** -* Generates the ndarray function name for given input and output dtype characters. -* -* @private -* @param {string} inputChar - input dtype character -* @param {string} outputChar - output dtype character -* @returns {string} function name -*/ -function generateFunctionName( inputChar, outputChar ) { - // Use simple naming convention without casting suffix (matches original) - var functionName = 'stdlib_ndarray_' + inputChar + '_' + outputChar; - return functionName; -} - -/** -* Generates the type pair string for given input and output dtypes. -* -* @private -* @param {string} inputDtype - input data type -* @param {string} outputDtype - output data type -* @returns {string} type pair string -*/ -function generateTypePair( inputDtype, outputDtype ) { - var inputEnum, outputEnum; - - // Handle generic type specially - if ( inputDtype === 'generic' ) { - inputEnum = 'STDLIB_NDARRAY_GENERIC'; - } else { - inputEnum = 'STDLIB_NDARRAY_' + uppercase( inputDtype ); - } - - if ( outputDtype === 'generic' ) { - outputEnum = 'STDLIB_NDARRAY_GENERIC'; - } else { - outputEnum = 'STDLIB_NDARRAY_' + uppercase( outputDtype ); - } - - return inputEnum + ', ' + outputEnum; -} - -/** -* Generates the data function pointer for given input dtype. -* -* @private -* @param {string} inputDtype - input data type -* @returns {string} data function pointer -*/ -function generateDataFunction( inputDtype ) { - var functionPtr; - - // Map dtypes to appropriate C functions - if ( inputDtype === 'float64' ) { - functionPtr = '(void *)stdlib_base_abs'; - } else if ( inputDtype === 'float32' ) { - functionPtr = '(void *)stdlib_base_absf'; - } else if ( inputDtype === 'int32' ) { - functionPtr = '(void *)stdlib_base_labs'; - } else if ( inputDtype === 'int16' ) { - functionPtr = '(void *)abs_k'; // Custom int16 abs function - } else if ( inputDtype === 'int8' ) { - functionPtr = '(void *)abs_s'; // Custom int8 abs function - } else if ( inputDtype === 'uint32' ) { - functionPtr = '(void *)identity_u'; // Identity for unsigned types - } else if ( inputDtype === 'uint16' ) { - functionPtr = '(void *)identity_t'; - } else if ( inputDtype === 'uint8' || inputDtype === 'uint8c' ) { - functionPtr = '(void *)identity_b'; - } else if ( inputDtype === 'generic' ) { - functionPtr = '(void *)stdlib_base_abs'; // Generic uses regular abs - } else { - // Default fallback - functionPtr = '(void *)stdlib_base_abs'; - } - - return functionPtr; -} - -/** -* Creates a basic addon.c template if it doesn't exist. -* -* @private -*/ -function createTemplate() { - var template = `/** -* @license Apache-2.0 -* -* Copyright (c) {{YEAR}} {{COPYRIGHT}}. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* {{NOTE}} */ - -#include "stdlib/math/base/special/abs.h" -#include "stdlib/math/base/special/absf.h" -#include "stdlib/math/base/special/labs.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 - -/** -* Evaluates the identity function for an unsigned 32-bit integer. -* -* @param x input value -* @return input value -*/ -static uint32_t identity_u( const uint32_t x ) { - return x; -} - -/** -* Evaluates the identity function for an unsigned 16-bit integer. -* -* @param x input value -* @return input value -*/ -static uint16_t identity_t( const uint16_t x ) { - return x; -} - -/** -* Evaluates the identity function for an unsigned 8-bit integer. -* -* @param x input value -* @return input value -*/ -static uint8_t identity_b( const uint8_t x ) { - return x; -} - -/** -* Computes the absolute value of a signed 16-bit integer. -* -* @param x input value -* @return absolute value -*/ -static int16_t abs_k( const int16_t x ) { - if ( x < 0 ) { - return -x; - } - return x; -} - -/** -* Computes the absolute value of a signed 8-bit integer. -* -* @param x input value -* @return absolute value -*/ -static int8_t abs_s( const int8_t x ) { - if ( x < 0 ) { - return -x; - } - return x; -} - -// Define an interface name: -static const char name[] = "{{INTERFACE_NAME}}"; - -// Define a list of ndarray functions: -static ndarrayFcn functions[] = { - {{FUNCTIONS}} -}; - -// Define the **ndarray** argument types for each ndarray function: -static int32_t types[] = { - {{TYPES}} -}; - -// Define a list of ndarray function "data" (in this case, callbacks): -static void *data[] = { - {{DATA}} -}; - -// 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: - {{NUM_FUNCTIONS}}, - - // 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 ) -`; - - var err = writeFile( SRC_PATH, template, OPTS ); - if ( err ) { - throw err; - } - console.log( 'Created template file: ' + SRC_PATH ); -} - -/** -* Generates the addon.c file for the abs function. -* -* @private -* @throws {Error} unexpected error -*/ -function generateAddonC() { - var template; - var functions; - var types; - var data; - var err; - - // Read the template file - template = readFile( SRC_PATH, OPTS ); - if ( template instanceof Error ) { - throw template; - } - - // Generate function signatures, types, and data arrays - var result = generateFunctionMappings(); - functions = result.functions; - types = result.types; - data = result.data; - - // Replace template placeholders - template = replace( template, '{{YEAR}}', YEAR.toString() ); - template = replace( template, '{{COPYRIGHT}}', COPYRIGHT ); - template = replace( template, '{{NOTE}}', NOTE ); - template = replace( template, '{{FCN_BASENAME}}', FCN_BASENAME ); - template = replace( template, '{{FCN_DESCRIPTION}}', FCN_DESCRIPTION ); - template = replace( template, '{{INTERFACE_NAME}}', INTERFACE_NAME ); - template = replace( template, '{{FUNCTIONS}}', functions.join( ',\n\t' ) ); - template = replace( template, '{{TYPES}}', types.join( ',\n\t' ) ); - template = replace( template, '{{DATA}}', data.join( ',\n\t' ) ); - template = replace( template, '{{NUM_FUNCTIONS}}', functions.length.toString() ); - - // Write the generated file - err = writeFile( OUT_PATH, template, OPTS ); - if ( err ) { - throw err; - } - - console.log( 'Generated addon.c with ' + functions.length + ' function mappings.' ); -} - - - -// MAIN // - -console.log( 'Generating addon.c for stdlib abs function...' ); - -// Create template if it doesn't exist, then generate the addon.c file -try { - generateAddonC(); -} catch ( error ) { - if ( error.code === 'ENOENT' ) { - console.log( 'Template file not found. Creating template...' ); - createTemplate(); - generateAddonC(); - } else { - throw error; - } -} From 0d164cf095ecaaacb9b6c8a3cb1880ee39e88a83 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 23 Jul 2025 23:40:29 +0530 Subject: [PATCH 04/31] refactor: modify script --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/special/abs/scripts/test.js | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/abs/scripts/test.js b/lib/node_modules/@stdlib/math/special/abs/scripts/test.js index f863bf702ecb..c00d737be402 100644 --- a/lib/node_modules/@stdlib/math/special/abs/scripts/test.js +++ b/lib/node_modules/@stdlib/math/special/abs/scripts/test.js @@ -40,8 +40,7 @@ var KERNEL_MAP = { 'uint32': 'stdlib_base_abs', 'uint16': 'stdlib_base_abs', 'uint8': 'stdlib_base_abs', - 'uint8c': 'stdlib_base_abs', - 'generic': 'stdlib_base_abs' + 'uint8c': 'stdlib_base_abs' }; var INCLUDE_MAP = { 'abs': 'abs.h', @@ -60,18 +59,17 @@ var INCLUDE_MAP = { */ function outputDtypeRule( input ) { var rules = { - 'float64': [ 'float64', 'generic' ], - 'float32': [ 'float32', 'float64', 'generic' ], - 'complex128': [ 'float64', 'generic' ], - 'complex64': [ 'float32', 'float64', 'generic' ], - 'int32': [ 'int32', 'uint32', 'float64', 'generic' ], - 'int16': [ 'int16', 'int32', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], - 'int8': [ 'int8', 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], - 'uint32': [ 'uint32', 'float64', 'generic' ], - 'uint16': [ 'int32', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], - 'uint8': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], - 'uint8c': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64', 'generic' ], - 'generic': [ 'generic' ] + 'float64': [ 'float64' ], + 'float32': [ 'float32', 'float64' ], + 'complex128': [ 'float64' ], + 'complex64': [ 'float32', 'float64' ], + 'int32': [ 'int32', 'uint32', 'float64' ], + 'int16': [ 'int16', 'int32', 'uint16', 'uint32', 'float32', 'float64' ], + 'int8': [ 'int8', 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64' ], + 'uint32': [ 'uint32', 'float64' ], + 'uint16': [ 'int32', 'uint16', 'uint32', 'float32', 'float64' ], + 'uint8': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64' ], + 'uint8c': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64' ] }; return rules[ input ] || []; } @@ -88,14 +86,15 @@ function getNdarrayFcnName( input, output ) { var map = { 'float64': 'd', 'float32': 'f', - 'generic': 'g', + 'complex128': 'z', + 'complex64': 'c', 'int32': 'i', 'int16': 'k', 'int8': 's', 'uint32': 'u', 'uint16': 't', 'uint8': 'b', - 'uint8c': 'b' + 'uint8c': 'a' }; return 'stdlib_ndarray_' + map[ input ] + '_' + map[ output ]; } From e2875279a3cee40e92edb751327c34d5cebb0349 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 29 Jul 2025 01:07:32 +0530 Subject: [PATCH 05/31] refactor: try out the script for ceil --- .../math/special/ceil/scripts/config.js | 31 + .../special/ceil/scripts/generate_files.js | 443 +++++ .../math/special/ceil/scripts/matches.json | 1692 +++++++++++++++++ .../math/special/ceil/scripts/script.js | 206 ++ .../math/special/ceil/scripts/table.js | 235 +++ 5 files changed, 2607 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/config.js create mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js create mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json create mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/script.js create mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/table.js diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js new file mode 100644 index 000000000000..861381270577 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +var config = { + 'input_dtypes': 'numeric', + 'output_dtypes': 'numeric' +}; + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js new file mode 100644 index 000000000000..e7d82aef3899 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js @@ -0,0 +1,443 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var currentYear = require( '@stdlib/time/current-year' ); +var safeCasts = require( '@stdlib/ndarray/safe-casts' ); +var generateMatchesTable = require( './script.js' ); + + +// FUNCTIONS // + +/** +* Checks if a type promotion preserves mathematical domain for ceil function. +* +* @private +* @param {string} inputType - input data type +* @param {string} outputType - output data type +* @returns {boolean} true if promotion preserves domain consistency +*/ +function isValidDomainPromotion( inputType, outputType ) { + var complexTypes = [ 'complex32', 'complex64', 'complex128' ]; + var realTypes = [ + 'float16', + 'float32', + 'float64', + 'int8', + 'int16', + 'int32', + 'uint8', + 'uint8c', + 'uint16', + 'uint32' + ]; + + // Rule 1: Real types should not promote to complex types for ceil... + if ( realTypes.indexOf( inputType ) !== -1 && + complexTypes.indexOf( outputType ) !== -1 ) { + return false; + } + + // Rule 2: Complex types should not promote to real types for ceil... + if ( complexTypes.indexOf( inputType ) !== -1 && + realTypes.indexOf( outputType ) !== -1 ) { + return false; + } + + // Rule 3: Always allow same-type mappings... + if ( inputType === outputType ) { + return true; + } + + // Rule 4: Always allow promotion to generic (fallback)... + if ( outputType === 'generic' ) { + return true; + } + + // Rule 5: Allow promotions within the same domain... + if ( realTypes.indexOf( inputType ) !== -1 && + realTypes.indexOf( outputType ) !== -1 ) { + return true; + } + if ( complexTypes.indexOf( inputType ) !== -1 && + complexTypes.indexOf( outputType ) !== -1 ) { + return true; + } + + return false; +} + +/** +* Filters matches to only include mathematically valid type promotions. +* +* @private +* @param {Array} matches - array of match entries +* @returns {Array} filtered array of valid matches +*/ +function filterValidMatches( matches ) { + var validMatches; + var validCasts; + var outputType; + var inputType; + var match; + var i; + + validMatches = []; + for ( i = 0; i < matches.length; i++ ) { + match = matches[i]; + inputType = match[0]; + outputType = match[1]; + + // First check: Can the input type be safely cast to the output type?... + validCasts = safeCasts( inputType ); + if ( !validCasts || validCasts.indexOf( outputType ) === -1 ) { + continue; + } + + // Second check: Does this promotion preserve mathematical domain for ceil?... + if ( !isValidDomainPromotion( inputType, outputType ) ) { + continue; + } + + validMatches.push( match ); + } + return validMatches; +} + +/** +* Generates the license header. +* +* @private +* @returns {string} license header +*/ +function generateLicenseHeader() { + var year = currentYear(); + return [ + '/**', + '* @license Apache-2.0', + '*', + '* Copyright (c) ' + year + ' 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.', + '*/', + '', + '' + ].join( '\n' ); +} + +/** +* Groups matches by input data type and orders by likelihood of use. +* +* @private +* @param {Array} matches - array of match entries +* @returns {Object} object containing grouped matches, input types array, and reordered matches +*/ +function groupMatchesByInputType( matches ) { + var reorderedMatches; + var groupedOutputs; + var inputTypes; + var inputType; + var grouped; + var i; + var j; + + grouped = {}; + inputTypes = []; + for ( i = 0; i < matches.length; i++ ) { + inputType = matches[i][0]; + if ( !grouped[inputType] ) { + grouped[inputType] = []; + inputTypes.push( inputType ); + } + grouped[inputType].push( matches[i] ); + } + + // Keep inputTypes in original order (no sorting)... + + // Reorder matches to match the sorted input types... + reorderedMatches = []; + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[i]; + for ( j = 0; j < grouped[inputType].length; j++ ) { + reorderedMatches.push( grouped[inputType][j] ); + } + } + + // Rebuild grouped with just output types for display... + groupedOutputs = {}; + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[i]; + groupedOutputs[inputType] = []; + for ( j = 0; j < grouped[inputType].length; j++ ) { + groupedOutputs[inputType].push( grouped[inputType][j][1] ); + } + } + + return { + 'grouped': groupedOutputs, + 'inputTypes': inputTypes, + 'reorderedMatches': reorderedMatches + }; +} + +/** +* Generates the types.js file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @returns {string} types.js file content +*/ +function generateTypesFile( matches, header ) { + var outputTypes; + var inputTypes; + var inputType; + var grouped; + var result; + var jsOut; + var i; + var j; + + jsOut = header; + jsOut += '/*\n'; + jsOut += '* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation.\n'; + jsOut += '*/\n\n'; + jsOut += '/* eslint-disable array-element-newline */\n\n'; + jsOut += '\'use strict\';\n\n'; + jsOut += '// MODULES //\n\n'; + jsOut += 'var dtypes = require( \'@stdlib/ndarray/dtypes\' );\n\n\n'; + jsOut += '// MAIN //\n\n'; + jsOut += 'var types = [\n'; + + // Group matches by input dtype... + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + inputTypes = result.inputTypes; + + // Generate grouped output with proper formatting and comments... + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[i]; + outputTypes = grouped[inputType]; + + // Add comment with input type and count + jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + + for ( j = 0; j < outputTypes.length; j++ ) { + jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[j]; + if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { + jsOut += ',\n'; + } else { + jsOut += '\n'; + } + } + + // Add blank line between input type groups (except for the last one)... + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\n'; + return jsOut; +} + +/** +* Generates the addon.c file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @param {string} basePkg - base package name +* @returns {string} addon.c file content +*/ +function generateAddonFile( matches, header, basePkg ) { + var uniqueIncludes; + var functionIndex; + var outputTypes; + var includeKey; + var inputType; + var grouped; + var result; + var cOut; + var i; + var j; + + // Generate unique includes... + uniqueIncludes = {}; + for ( i = 0; i < matches.length; i++ ) { + includeKey = matches[i][6].replace( 'stdlib_base_', '' ); + uniqueIncludes['#include "stdlib/math/base/special/' + includeKey + '.h"'] = true; + } + + // Group matches by input type for organized output... + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + matches = result.reorderedMatches; + + cOut = header; + cOut += Object.keys( uniqueIncludes ).join( '\n' ) + '\n'; + cOut += '#include "stdlib/ndarray/base/function_object.h"\n'; + cOut += '#include "stdlib/ndarray/base/napi/unary.h"\n'; + cOut += '#include "stdlib/ndarray/base/unary.h"\n'; + cOut += '#include "stdlib/ndarray/dtypes.h"\n'; + cOut += '#include \n\n'; + + // Define interface name with comment... + cOut += '// Define an interface name:\n'; + cOut += 'static const char name[] = "stdlib_ndarray_' + basePkg + '";\n\n'; + + // Define functions array with comments and grouping... + cOut += '// Define a list of ndarray functions:\n'; + cOut += 'static ndarrayFcn functions[] = {\n'; + + // Add functions with type group comments... + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[i]; + outputTypes = grouped[inputType]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\t' + matches[functionIndex][7] + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define types array with comments and grouping... + cOut += '// Define the array of input and output ndarray types:\n'; + cOut += 'static int32_t types[] = {\n'; + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[i]; + outputTypes = grouped[inputType]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\tSTDLIB_NDARRAY_' + matches[functionIndex][0].toUpperCase() + ', STDLIB_NDARRAY_' + matches[functionIndex][1].toUpperCase() + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define data array with comments and grouping... + cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; + cOut += 'static void *data[] = {\n'; + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[i]; + outputTypes = grouped[inputType]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\t(void *)' + matches[functionIndex][6] + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define function object with detailed comments... + cOut += '// Create an ndarray function object:\n'; + cOut += 'static const struct ndarrayFunctionObject obj = {\n'; + cOut += '\t// ndarray function name:\n'; + cOut += '\tname,\n\n'; + cOut += '\t// Number of input ndarrays:\n'; + cOut += '\t1,\n\n'; + cOut += '\t// Number of output ndarrays:\n'; + cOut += '\t1,\n\n'; + cOut += '\t// Total number of ndarray arguments (nin + nout):\n'; + cOut += '\t2,\n\n'; + cOut += '\t// Array containing ndarray functions:\n'; + cOut += '\tfunctions,\n\n'; + cOut += '\t// Number of ndarray functions:\n'; + cOut += '\t' + matches.length + ',\n\n'; + cOut += '\t// Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function:\n'; + cOut += '\ttypes,\n\n'; + cOut += '\t// Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions):\n'; + cOut += '\tdata\n'; + cOut += '};\n\n'; + + // Export the function object... + cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; + return cOut; +} + + +// MAIN // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + var pkg; + + // Generate and filter matches table: + matches = generateMatchesTable(); + matches = filterValidMatches( matches ); + + // Extract package information: + pkg = require( './../package.json' ); + basePkg = pkg.name.split( '/' ).pop(); + + // Generate license header: + header = generateLicenseHeader(); + + // Generate types.js: + jsOut = generateTypesFile( matches, header ); + writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( matches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json b/lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json new file mode 100644 index 000000000000..8521899b4572 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json @@ -0,0 +1,1692 @@ +[ + [ + "complex32", + "complex32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_j_as_c_c" + ], + [ + "complex32", + "complex64", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_c_as_c_c" + ], + [ + "complex32", + "complex128", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_z_as_c_c" + ], + [ + "complex32", + "float16", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_h_as_c_c" + ], + [ + "complex32", + "float32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_f_as_c_c" + ], + [ + "complex32", + "float64", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_d_as_c_c" + ], + [ + "complex32", + "int16", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_k_as_c_c" + ], + [ + "complex32", + "int32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_i_as_c_c" + ], + [ + "complex32", + "int8", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_s_as_c_c" + ], + [ + "complex32", + "uint16", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_t_as_c_c" + ], + [ + "complex32", + "uint32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_u_as_c_c" + ], + [ + "complex32", + "uint8", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_b_as_c_c" + ], + [ + "complex32", + "uint8c", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_j_a_as_c_c" + ], + [ + "complex64", + "complex32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_j_as_c_c" + ], + [ + "complex64", + "complex64", + "@stdlib/math/base/special/cceilf", + false, + null, + null, + "stdlib_base_cceilf", + "stdlib_ndarray_c_c" + ], + [ + "complex64", + "complex128", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_z_as_c_c" + ], + [ + "complex64", + "float16", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_h_as_c_c" + ], + [ + "complex64", + "float32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_f_as_c_c" + ], + [ + "complex64", + "float64", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_d_as_c_c" + ], + [ + "complex64", + "int16", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_k_as_c_c" + ], + [ + "complex64", + "int32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_i_as_c_c" + ], + [ + "complex64", + "int8", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_s_as_c_c" + ], + [ + "complex64", + "uint16", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_t_as_c_c" + ], + [ + "complex64", + "uint32", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_u_as_c_c" + ], + [ + "complex64", + "uint8", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_b_as_c_c" + ], + [ + "complex64", + "uint8c", + "@stdlib/math/base/special/cceilf", + true, + "complex64", + "complex64", + "stdlib_base_cceilf", + "stdlib_ndarray_c_a_as_c_c" + ], + [ + "complex128", + "complex32", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_j_as_z_z" + ], + [ + "complex128", + "complex64", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_c_as_z_z" + ], + [ + "complex128", + "complex128", + "@stdlib/math/base/special/cceil", + false, + null, + null, + "stdlib_base_cceil", + "stdlib_ndarray_z_z" + ], + [ + "complex128", + "float16", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_h_as_z_z" + ], + [ + "complex128", + "float32", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_f_as_z_z" + ], + [ + "complex128", + "float64", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_d_as_z_z" + ], + [ + "complex128", + "int16", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_k_as_z_z" + ], + [ + "complex128", + "int32", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_i_as_z_z" + ], + [ + "complex128", + "int8", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_s_as_z_z" + ], + [ + "complex128", + "uint16", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_t_as_z_z" + ], + [ + "complex128", + "uint32", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_u_as_z_z" + ], + [ + "complex128", + "uint8", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_b_as_z_z" + ], + [ + "complex128", + "uint8c", + "@stdlib/math/base/special/cceil", + true, + "complex128", + "complex128", + "stdlib_base_cceil", + "stdlib_ndarray_z_a_as_z_z" + ], + [ + "float16", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_j_as_f_f" + ], + [ + "float16", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_c_as_f_f" + ], + [ + "float16", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_z_as_f_f" + ], + [ + "float16", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_h_as_f_f" + ], + [ + "float16", + "float32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_f_as_f_f" + ], + [ + "float16", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_d_as_f_f" + ], + [ + "float16", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_k_as_f_f" + ], + [ + "float16", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_i_as_f_f" + ], + [ + "float16", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_s_as_f_f" + ], + [ + "float16", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_t_as_f_f" + ], + [ + "float16", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_u_as_f_f" + ], + [ + "float16", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_b_as_f_f" + ], + [ + "float16", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_h_a_as_f_f" + ], + [ + "float32", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_j_as_f_f" + ], + [ + "float32", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_c_as_f_f" + ], + [ + "float32", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_z_as_f_f" + ], + [ + "float32", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_h_as_f_f" + ], + [ + "float32", + "float32", + "@stdlib/math/base/special/ceilf", + false, + null, + null, + "stdlib_base_ceilf", + "stdlib_ndarray_f_f" + ], + [ + "float32", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_d_as_f_f" + ], + [ + "float32", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_k_as_f_f" + ], + [ + "float32", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_i_as_f_f" + ], + [ + "float32", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_s_as_f_f" + ], + [ + "float32", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_t_as_f_f" + ], + [ + "float32", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_u_as_f_f" + ], + [ + "float32", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_b_as_f_f" + ], + [ + "float32", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_f_a_as_f_f" + ], + [ + "float64", + "complex32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_j_as_d_d" + ], + [ + "float64", + "complex64", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_c_as_d_d" + ], + [ + "float64", + "complex128", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_z_as_d_d" + ], + [ + "float64", + "float16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_h_as_d_d" + ], + [ + "float64", + "float32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_f_as_d_d" + ], + [ + "float64", + "float64", + "@stdlib/math/base/special/ceil", + false, + null, + null, + "stdlib_base_ceil", + "stdlib_ndarray_d_d" + ], + [ + "float64", + "int16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_k_as_d_d" + ], + [ + "float64", + "int32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_i_as_d_d" + ], + [ + "float64", + "int8", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_s_as_d_d" + ], + [ + "float64", + "uint16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_t_as_d_d" + ], + [ + "float64", + "uint32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_u_as_d_d" + ], + [ + "float64", + "uint8", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_b_as_d_d" + ], + [ + "float64", + "uint8c", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_d_a_as_d_d" + ], + [ + "int16", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_j_as_f_f" + ], + [ + "int16", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_c_as_f_f" + ], + [ + "int16", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_z_as_f_f" + ], + [ + "int16", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_h_as_f_f" + ], + [ + "int16", + "float32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_f_as_f_f" + ], + [ + "int16", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_d_as_f_f" + ], + [ + "int16", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_k_as_f_f" + ], + [ + "int16", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_i_as_f_f" + ], + [ + "int16", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_s_as_f_f" + ], + [ + "int16", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_t_as_f_f" + ], + [ + "int16", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_u_as_f_f" + ], + [ + "int16", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_b_as_f_f" + ], + [ + "int16", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_k_a_as_f_f" + ], + [ + "int32", + "complex32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_j_as_d_d" + ], + [ + "int32", + "complex64", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_c_as_d_d" + ], + [ + "int32", + "complex128", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_z_as_d_d" + ], + [ + "int32", + "float16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_h_as_d_d" + ], + [ + "int32", + "float32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_f_as_d_d" + ], + [ + "int32", + "float64", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_d_as_d_d" + ], + [ + "int32", + "int16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_k_as_d_d" + ], + [ + "int32", + "int32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_i_as_d_d" + ], + [ + "int32", + "int8", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_s_as_d_d" + ], + [ + "int32", + "uint16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_t_as_d_d" + ], + [ + "int32", + "uint32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_u_as_d_d" + ], + [ + "int32", + "uint8", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_b_as_d_d" + ], + [ + "int32", + "uint8c", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_i_a_as_d_d" + ], + [ + "int8", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_j_as_f_f" + ], + [ + "int8", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_c_as_f_f" + ], + [ + "int8", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_z_as_f_f" + ], + [ + "int8", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_h_as_f_f" + ], + [ + "int8", + "float32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_f_as_f_f" + ], + [ + "int8", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_d_as_f_f" + ], + [ + "int8", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_k_as_f_f" + ], + [ + "int8", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_i_as_f_f" + ], + [ + "int8", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_s_as_f_f" + ], + [ + "int8", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_t_as_f_f" + ], + [ + "int8", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_u_as_f_f" + ], + [ + "int8", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_b_as_f_f" + ], + [ + "int8", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_s_a_as_f_f" + ], + [ + "uint16", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_j_as_f_f" + ], + [ + "uint16", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_c_as_f_f" + ], + [ + "uint16", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_z_as_f_f" + ], + [ + "uint16", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_h_as_f_f" + ], + [ + "uint16", + "float32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_f_as_f_f" + ], + [ + "uint16", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_d_as_f_f" + ], + [ + "uint16", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_k_as_f_f" + ], + [ + "uint16", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_i_as_f_f" + ], + [ + "uint16", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_s_as_f_f" + ], + [ + "uint16", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_t_as_f_f" + ], + [ + "uint16", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_u_as_f_f" + ], + [ + "uint16", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_b_as_f_f" + ], + [ + "uint16", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_t_a_as_f_f" + ], + [ + "uint32", + "complex32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_j_as_d_d" + ], + [ + "uint32", + "complex64", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_c_as_d_d" + ], + [ + "uint32", + "complex128", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_z_as_d_d" + ], + [ + "uint32", + "float16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_h_as_d_d" + ], + [ + "uint32", + "float32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_f_as_d_d" + ], + [ + "uint32", + "float64", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_d_as_d_d" + ], + [ + "uint32", + "int16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_k_as_d_d" + ], + [ + "uint32", + "int32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_i_as_d_d" + ], + [ + "uint32", + "int8", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_s_as_d_d" + ], + [ + "uint32", + "uint16", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_t_as_d_d" + ], + [ + "uint32", + "uint32", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_u_as_d_d" + ], + [ + "uint32", + "uint8", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_b_as_d_d" + ], + [ + "uint32", + "uint8c", + "@stdlib/math/base/special/ceil", + true, + "float64", + "float64", + "stdlib_base_ceil", + "stdlib_ndarray_u_a_as_d_d" + ], + [ + "uint8", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_j_as_f_f" + ], + [ + "uint8", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_c_as_f_f" + ], + [ + "uint8", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_z_as_f_f" + ], + [ + "uint8", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_h_as_f_f" + ], + [ + "uint8", + "float32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_f_as_f_f" + ], + [ + "uint8", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_d_as_f_f" + ], + [ + "uint8", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_k_as_f_f" + ], + [ + "uint8", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_i_as_f_f" + ], + [ + "uint8", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_s_as_f_f" + ], + [ + "uint8", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_t_as_f_f" + ], + [ + "uint8", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_u_as_f_f" + ], + [ + "uint8", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_b_as_f_f" + ], + [ + "uint8", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_b_a_as_f_f" + ], + [ + "uint8c", + "complex32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_j_as_f_f" + ], + [ + "uint8c", + "complex64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_c_as_f_f" + ], + [ + "uint8c", + "complex128", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_z_as_f_f" + ], + [ + "uint8c", + "float16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_h_as_f_f" + ], + [ + "uint8c", + "float32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_f_as_f_f" + ], + [ + "uint8c", + "float64", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_d_as_f_f" + ], + [ + "uint8c", + "int16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_k_as_f_f" + ], + [ + "uint8c", + "int32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_i_as_f_f" + ], + [ + "uint8c", + "int8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_s_as_f_f" + ], + [ + "uint8c", + "uint16", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_t_as_f_f" + ], + [ + "uint8c", + "uint32", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_u_as_f_f" + ], + [ + "uint8c", + "uint8", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_b_as_f_f" + ], + [ + "uint8c", + "uint8c", + "@stdlib/math/base/special/ceilf", + true, + "float32", + "float32", + "stdlib_base_ceilf", + "stdlib_ndarray_a_a_as_f_f" + ] +] \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js new file mode 100644 index 000000000000..f79525ac8611 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js @@ -0,0 +1,206 @@ +/** +* @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 promotionRules = require( '@stdlib/ndarray/promotion-rules' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var format = require( '@stdlib/string/format' ); +var config = require( '@stdlib/math/special/ceil/scripts/config.js' ); +var generateTable = require( '@stdlib/math/special/ceil/scripts/table.js' ); + + +// MAIN // + +/** +* Generate dtype pairs, match them with stdlib packages, and resolve C function names and loop kernels. +* +* ## Note +* +* - The function generates an array of matches, where each match is an array in the format: +* +* ```text +* ---------------------------------------------------------------------------------------------------------------------------------------- +* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | +* ---------------------------------------------------------------------------------------------------------------------------------------- +* | | | | | | | | +* | | | | | | | | +* V V | V V V | V +* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_f_f' +* V V +* '@stdlib/math/base/special/expf' 'stdlib_base_expf' +* ``` +* +* @private +* @returns {Array} matches table containing dtype pairs and their corresponding package information +*/ +function main() { + var functionName; + var matches = []; + var basePkg; + var kernel; + var table; + var pairs; + var pkg; + var pdt; + var row; + var idt; + var odt; + var dt; + var i; + var j; + + // Generate the table: + pkg = require( '@stdlib/math/special/ceil/package.json' ); + basePkg = pkg.name.split( '/' ).pop(); + table = generateTable( basePkg ); + + /* + Should be generated in this order only. Check once: + Table: [ + [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], + [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], + [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ] + [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ], + ] + */ + + /* + Resolve list of input dtypes. After this, we'll have: + idt = [ + 'complex32', + 'complex64', + 'complex128', + 'float16', + 'float32', + 'float64', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ] + */ + idt = dtypes( config.input_dtypes ); + + /* + Resolve the list of output dtypes. After this, we'll have: + odt = [ + 'complex32', + 'complex128', + 'complex64', + 'float16', + 'float64', + 'float32', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ] + */ + odt = dtypes( config.output_dtypes ); + + /* + Generate the input-output dtype pairs. After this, we'll have: + pairs = [ + [ 'complex32', 'complex32' ], + [ 'complex32', 'complex64' ], + [ 'complex32', 'complex128' ], + [ 'complex32', 'float16' ], + [ 'complex32', 'float32' ], + [ 'complex32', 'float64' ], + [ 'complex32', 'int32' ], + [ 'complex32', 'int16' ], + [ 'complex32', 'int8' ], + [ 'complex32', 'uint32' ], + [ 'complex32', 'uint16' ], + [ 'complex32', 'uint8' ], + [ 'complex32', 'uint8c' ], + [ 'complex64', 'complex32' ], + [ 'complex64', 'complex64' ], + [ 'complex64', 'complex128' ], + [ 'complex64', 'float16' ], + [ 'complex64', 'float32' ], + [ 'complex64', 'float64' ], + [ 'complex64', 'int32' ], + ... + ] + */ + pairs = cartesianProduct( idt, odt ); + + // Match-make each dtype pair with a stdlib package... + for ( i = 0; i < pairs.length; i++ ) { + // Now let dt = [ 'complex32', 'float32' ]... + dt = pairs[ i ]; + + // First pass: look for exact matches... + for ( j = 0; j < table.length; j++ ) { + // Now let row = [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ]... + row = table[ j ]; + if ( row[ 0 ] === dt[ 0 ] && row[ 1 ] === dt[ 1 ] ) { + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, '', '' ] ); + break; + } + + // Next check for package to which the dtype pair can promote... + // For example, pdt = promotionRules( 'complex32', 'complex64' ) = 'complex64' + pdt = promotionRules( dt[ 0 ], row[ 0 ] ); + if ( pdt ) { + // Check for a package which supports the promoted dtypes... + if ( row[ 0 ] === pdt && row[ 1 ] === pdt ) { + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, '', '' ] ); + break; + } + } + } + } + + // NOTE: modify below to also resolve JS alias for generating the JavaScript tables, as well... + // Resolve the scalar math kernel C function name... + for ( i = 0; i < matches.length; i++ ) { + row = matches[ i ]; + + // Extract function name from package path (e.g., '@stdlib/math/base/special/ceilf' -> 'ceilf') + functionName = row[ 2 ].split( '/' ).pop(); + row[ 6 ] = 'stdlib_base_' + functionName; + } + + // Resolve the loop kernel... + for ( i = 0; i < matches.length; i++ ) { + row = matches[ i ]; + if ( row[ 3 ] === true ) { + kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ), dtypeChar( row[ 4 ] ), dtypeChar( row[ 5 ] ) ); + } else { + kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + } + row[ 7 ] = kernel; + } + + return matches; +} + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js new file mode 100644 index 000000000000..edf28dba8b4f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js @@ -0,0 +1,235 @@ +/* eslint-disable stdlib/jsdoc-no-shortcut-reference-link, stdlib/jsdoc-no-undefined-references, stdlib/jsdoc-no-paragraph-content-indent */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var basename = require( 'path' ).basename; +var path = require( 'path' ); +var ls = require( '@stdlib/_tools/pkgs/names' ).sync; +var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var pkg = require( '@stdlib/math/special/ceil/package.json' ); + + +// VARIABLES // + +var pathString = '@stdlib/math/base/special'; +var basePkg = basename( pkg.name ); +var ROOT_DIR = rootDir(); +var opts = { + 'dir': './' + pathString +}; +var jsonOpts = { + 'encoding': 'utf8' +}; + + +// FUNCTIONS // + +/** +* Returns a list of packages in `math/base/special/*` which are relevant for the current package. +* +* ## Note +* +* For now, we are trying only four combinations. So, let us say we are looking for the `sin` package, we will try to find: +* +* - `@stdlib/math/base/special/sin` +* - `@stdlib/math/base/special/sinf` +* - `@stdlib/math/base/special/csin` +* - `@stdlib/math/base/special/csinf` +* +* Now since as of now, we don't have `@stdlib/math/base/special/csin` and `@stdlib/math/base/special/csinf`, we will only get the first two packages. +* +* @private +* @param {string} base - base package name +* @returns {Array} list of relevant packages +* +* @example +* var pkgs = getRelevantPackages( 'exp' ); +* // returns [ '@stdlib/math/base/special/exp', '@stdlib/math/base/special/expf', '@stdlib/math/base/special/cexp', '@stdlib/math/base/special/cexpf' ] +* +* @example +* var pkgs = getRelevantPackages( 'sin' ); +* // returns [ '@stdlib/math/base/special/sin', '@stdlib/math/base/special/sinf' ] +*/ +function getRelevantPackages( base ) { + var combinations; + var names; + var pkgs; + var pkg; + var i; + var j; + + pkgs = []; + + /* + * Initializing all possible combinations that we can try. + * + * For example, for `exp`, we will try looking for: + * + * - `@stdlib/math/base/special/exp` + * - `@stdlib/math/base/special/expf` + * - `@stdlib/math/base/special/cexp` + * - `@stdlib/math/base/special/cexpf` + */ + combinations = [ + path.join(pathString, base + 'f'), + path.join(pathString, base), + path.join(pathString, 'c' + base + 'f'), + path.join(pathString, 'c' + base) + ]; + + // Get the list of packages in `math/base/special/*`: + names = ls( opts ); + + // Filter the list of packages to only include those which match the combinations: + for ( i = 0; i < combinations.length; i++ ) { + pkg = combinations[ i ]; + for ( j = 0; j < names.length; j++ ) { + if ( names[ j ] === pkg ) { + pkgs.push( pkg ); + } + } + } + + return pkgs; +} + +// Now we need to fetch the meta data (input/output dtypes) from the relevant packages: + +/** +* Returns the input and output dtypes for a given package. +* +* ## Note +* +* Currently, this only supports packages which have a single input and a single output. +* In order to support packages with multiple inputs, we can restructure the our table and calculate accordingly. +* As of now, each array in our table looks like this: +* +* [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] +* +* This is fine for single input & single output functions. But, for functions such as `pow`, we can have: +* +* [ 2, 'float64', 'float64', `float64`, '@stdlib/math/base/special/pow' ] +* +* where the first element ( 2, in this case ) is the number of inputs. +* +* @private +* @param {string} alias - package name +* @returns {Array} input and output dtypes +* +* @example +* var dtypes = getDtypes( 'acos' ); +* // returns [ 'float64', 'float64' ] +* +* @example +* var dtypes = getDtypes( 'acosf' ); +* // returns [ 'float32', 'float32' ] +*/ +function getDtypes( alias ) { + var outputDtype; + var inputDtype; + var path; + var json; + var pkg; + var out; + var o; + + // Resolve the package: + pkg = findPkgs({ + 'dir': ROOT_DIR, + 'pattern': '**/math/base/special/'+ alias +'/package.json' // Check once, we should pass only the base name of the package here + }); + + if ( pkg.length === 0 ) { + return []; + } + + // Get the meta data: + path = resolve( ROOT_DIR, pkg[ 0 ] ); + json = readJSON( resolve( path, 'package.json' ), jsonOpts ); + o = json.__stdlib__; // eslint-disable-line no-underscore-dangle + if ( o && o.scaffold && o.scaffold.parameters.length === 1 ) { + out = o.scaffold; + } + + // NOTE: We might need to reconsider the below logic if there are two or more inputs... + inputDtype = out.parameters[ 0 ].type.dtype; + outputDtype = out.returns.type.dtype; + + return [ inputDtype, outputDtype ]; +} + + +// MAIN // + +/** +* Generate the function table. +* +* @param {string} base - base package name +* @returns {Array} function table +* +* @example +* var table = generateTable( 'exp' ); +* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/expf' ], [ 'float64', 'float64', '@stdlib/math/base/special/exp' ], [ 'complex64', 'complex64', '@stdlib/math/base/special/cexpf' ], [ 'complex128', 'complex128', '@stdlib/math/base/special/cexp' ] ] +*/ +function generateTable( base ) { + var aliasName; + var dtypes; + var table; + var pkgs; + var i; + + /* + * Get the list of relevant packages for the given base package. + * + * For example, for `exp`, we will get: + * + * pkgs = [ + * '@stdlib/math/base/special/exp', + * '@stdlib/math/base/special/expf', + * '@stdlib/math/base/special/cexp', + * '@stdlib/math/base/special/cexpf' + * ]; + */ + + pkgs = getRelevantPackages( base ); + + // Initialize the table: + table = []; + + // Loop over the packages and get the input/output dtypes: + for ( i = 0; i < pkgs.length; i++ ) { + // Extract the alias name out of the package path: + aliasName = pkgs[ i ].replace( pathString + '/', '' ); + dtypes = getDtypes( aliasName ); + table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkgs[ i ] ] ); + } + + return table; +} + + +// EXPORTS // + +module.exports = generateTable; From 423b15e06699fc0ce3957506ae713b5b0d824b09 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 29 Jul 2025 17:41:00 +0530 Subject: [PATCH 06/31] refactor: update scripts --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/cceil/package.json | 77 +- .../math/base/special/cceilf/package.json | 77 +- .../math/base/special/ceil/package.json | 77 +- .../math/base/special/ceilf/package.json | 77 +- .../@stdlib/math/special/ceil/lib/types.js | 77 + .../@stdlib/math/special/ceil/package.json | 70 + .../math/special/ceil/scripts/config.js | 4 +- .../special/ceil/scripts/generate_files.js | 211 +- .../math/special/ceil/scripts/matches.json | 1692 ----------------- .../math/special/ceil/scripts/script.js | 119 +- .../math/special/ceil/scripts/table.js | 99 +- .../@stdlib/math/special/ceil/src/addon.c | 183 ++ 12 files changed, 782 insertions(+), 1981 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/special/ceil/lib/types.js create mode 100644 lib/node_modules/@stdlib/math/special/ceil/package.json delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json create mode 100644 lib/node_modules/@stdlib/math/special/ceil/src/addon.c diff --git a/lib/node_modules/@stdlib/math/base/special/cceil/package.json b/lib/node_modules/@stdlib/math/base/special/cceil/package.json index aaae6ab20ad4..b2e863a190cd 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceil/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceil/package.json @@ -66,5 +66,80 @@ "complex", "cmplx", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "cceil", + "alias": "cceil", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex128" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex128" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json index 9727be736b09..3a1b63d10991 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json @@ -66,5 +66,80 @@ "complex", "cmplx", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "cceilf", + "alias": "cceilf", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "complex64" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/ceil/package.json b/lib/node_modules/@stdlib/math/base/special/ceil/package.json index 38fc7b65e615..ffc9bfd38184 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceil/package.json @@ -63,5 +63,80 @@ "nearest", "value", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "ceil", + "alias": "ceil", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/ceilf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilf/package.json index 148b58ae6e25..00859904d3e9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilf/package.json @@ -67,5 +67,80 @@ "float32", "single-precision", "flt" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "ceilf", + "alias": "ceilf", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float32" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/special/ceil/lib/types.js b/lib/node_modules/@stdlib/math/special/ceil/lib/types.js new file mode 100644 index 000000000000..76984431d916 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/lib/types.js @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* This is a generated file. Do not edit directly. */ +/* +* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation. +*/ + +/* eslint-disable array-element-newline */ + +'use strict'; + +// MODULES // + +var dtypes = require( '@stdlib/ndarray/dtypes' ); + + +// MAIN // + +var types = [ + // complex64 (1) + dtypes.complex64, dtypes.complex128, + + // float32 (3) + dtypes.float32, dtypes.complex64, + dtypes.float32, dtypes.complex128, + dtypes.float32, dtypes.float64, + + // float64 (1) + dtypes.float64, dtypes.complex128, + + // int32 (2) + dtypes.int32, dtypes.complex128, + dtypes.int32, dtypes.float64, + + // int8 (4) + dtypes.int8, dtypes.complex64, + dtypes.int8, dtypes.complex128, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.float64, + + // uint16 (4) + dtypes.uint16, dtypes.complex64, + dtypes.uint16, dtypes.complex128, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.float64, + + // uint32 (2) + dtypes.uint32, dtypes.complex128, + dtypes.uint32, dtypes.float64, + + // uint8 (4) + dtypes.uint8, dtypes.complex64, + dtypes.uint8, dtypes.complex128, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.float64 +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/ceil/package.json b/lib/node_modules/@stdlib/math/special/ceil/package.json new file mode 100644 index 000000000000..203de43d4d02 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/math/special/ceil", + "version": "0.0.0", + "description": "Round a number toward positive infinity.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "math.abs", + "abs", + "absolute", + "magnitude", + "value", + "ndarray", + "elementwise", + "element-wise" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js index 861381270577..4a19c3d6bc61 100644 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js @@ -21,8 +21,8 @@ // MAIN // var config = { - 'input_dtypes': 'numeric', - 'output_dtypes': 'numeric' + 'input_dtypes': 'numeric_and_generic', + 'output_dtypes': 'numeric_and_generic' }; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js index e7d82aef3899..0835c722dcec 100644 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js @@ -22,189 +22,49 @@ 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 safeCasts = require( '@stdlib/ndarray/safe-casts' ); var generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); // FUNCTIONS // /** -* Checks if a type promotion preserves mathematical domain for ceil function. -* -* @private -* @param {string} inputType - input data type -* @param {string} outputType - output data type -* @returns {boolean} true if promotion preserves domain consistency -*/ -function isValidDomainPromotion( inputType, outputType ) { - var complexTypes = [ 'complex32', 'complex64', 'complex128' ]; - var realTypes = [ - 'float16', - 'float32', - 'float64', - 'int8', - 'int16', - 'int32', - 'uint8', - 'uint8c', - 'uint16', - 'uint32' - ]; - - // Rule 1: Real types should not promote to complex types for ceil... - if ( realTypes.indexOf( inputType ) !== -1 && - complexTypes.indexOf( outputType ) !== -1 ) { - return false; - } - - // Rule 2: Complex types should not promote to real types for ceil... - if ( complexTypes.indexOf( inputType ) !== -1 && - realTypes.indexOf( outputType ) !== -1 ) { - return false; - } - - // Rule 3: Always allow same-type mappings... - if ( inputType === outputType ) { - return true; - } - - // Rule 4: Always allow promotion to generic (fallback)... - if ( outputType === 'generic' ) { - return true; - } - - // Rule 5: Allow promotions within the same domain... - if ( realTypes.indexOf( inputType ) !== -1 && - realTypes.indexOf( outputType ) !== -1 ) { - return true; - } - if ( complexTypes.indexOf( inputType ) !== -1 && - complexTypes.indexOf( outputType ) !== -1 ) { - return true; - } - - return false; -} - -/** -* Filters matches to only include mathematically valid type promotions. -* -* @private -* @param {Array} matches - array of match entries -* @returns {Array} filtered array of valid matches -*/ -function filterValidMatches( matches ) { - var validMatches; - var validCasts; - var outputType; - var inputType; - var match; - var i; - - validMatches = []; - for ( i = 0; i < matches.length; i++ ) { - match = matches[i]; - inputType = match[0]; - outputType = match[1]; - - // First check: Can the input type be safely cast to the output type?... - validCasts = safeCasts( inputType ); - if ( !validCasts || validCasts.indexOf( outputType ) === -1 ) { - continue; - } - - // Second check: Does this promotion preserve mathematical domain for ceil?... - if ( !isValidDomainPromotion( inputType, outputType ) ) { - continue; - } - - validMatches.push( match ); - } - return validMatches; -} - -/** -* Generates the license header. -* -* @private -* @returns {string} license header -*/ -function generateLicenseHeader() { - var year = currentYear(); - return [ - '/**', - '* @license Apache-2.0', - '*', - '* Copyright (c) ' + year + ' 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.', - '*/', - '', - '' - ].join( '\n' ); -} - -/** -* Groups matches by input data type and orders by likelihood of use. +* Groups matches by input data type. * * @private * @param {Array} matches - array of match entries * @returns {Object} object containing grouped matches, input types array, and reordered matches */ function groupMatchesByInputType( matches ) { - var reorderedMatches; - var groupedOutputs; - var inputTypes; + var reorderedMatches = []; + var inputTypes = []; var inputType; - var grouped; + var grouped = {}; var i; var j; - grouped = {}; - inputTypes = []; for ( i = 0; i < matches.length; i++ ) { - inputType = matches[i][0]; - if ( !grouped[inputType] ) { - grouped[inputType] = []; + inputType = matches[ i ][ 0 ]; + if ( !grouped[ inputType ] ) { + grouped[ inputType ] = []; inputTypes.push( inputType ); } - grouped[inputType].push( matches[i] ); - } - - // Keep inputTypes in original order (no sorting)... - - // Reorder matches to match the sorted input types... - reorderedMatches = []; - for ( i = 0; i < inputTypes.length; i++ ) { - inputType = inputTypes[i]; - for ( j = 0; j < grouped[inputType].length; j++ ) { - reorderedMatches.push( grouped[inputType][j] ); - } + grouped[ inputType ].push( matches[ i ][ 1 ] ); } - // Rebuild grouped with just output types for display... - groupedOutputs = {}; for ( i = 0; i < inputTypes.length; i++ ) { - inputType = inputTypes[i]; - groupedOutputs[inputType] = []; - for ( j = 0; j < grouped[inputType].length; j++ ) { - groupedOutputs[inputType].push( grouped[inputType][j][1] ); + inputType = inputTypes[ i ]; + for ( j = 0; j < matches.length; j++ ) { + if ( matches[ j ][ 0 ] === inputType ) { + reorderedMatches.push( matches[ j ] ); + } } } return { - 'grouped': groupedOutputs, + 'grouped': grouped, 'inputTypes': inputTypes, 'reorderedMatches': reorderedMatches }; @@ -246,14 +106,14 @@ function generateTypesFile( matches, header ) { // Generate grouped output with proper formatting and comments... for ( i = 0; i < inputTypes.length; i++ ) { - inputType = inputTypes[i]; - outputTypes = grouped[inputType]; + inputType = inputTypes[ i ]; + outputTypes = grouped[ inputType ]; // Add comment with input type and count jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[j]; + jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[ j ]; if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { jsOut += ',\n'; } else { @@ -261,7 +121,7 @@ function generateTypesFile( matches, header ) { } } - // Add blank line between input type groups (except for the last one)... + // Add blank line between input type groups ( except for the last one )... if ( i < inputTypes.length - 1 ) { jsOut += '\n'; } @@ -297,8 +157,8 @@ function generateAddonFile( matches, header, basePkg ) { // Generate unique includes... uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { - includeKey = matches[i][6].replace( 'stdlib_base_', '' ); - uniqueIncludes['#include "stdlib/math/base/special/' + includeKey + '.h"'] = true; + includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); + uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; } // Group matches by input type for organized output... @@ -325,12 +185,12 @@ function generateAddonFile( matches, header, basePkg ) { // Add functions with type group comments... functionIndex = 0; for ( i = 0; i < result.inputTypes.length; i++ ) { - inputType = result.inputTypes[i]; - outputTypes = grouped[inputType]; + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t' + matches[functionIndex][7] + ',\n'; + cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; functionIndex += 1; } cOut += '\n'; @@ -342,12 +202,12 @@ function generateAddonFile( matches, header, basePkg ) { cOut += 'static int32_t types[] = {\n'; functionIndex = 0; for ( i = 0; i < result.inputTypes.length; i++ ) { - inputType = result.inputTypes[i]; - outputTypes = grouped[inputType]; + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\tSTDLIB_NDARRAY_' + matches[functionIndex][0].toUpperCase() + ', STDLIB_NDARRAY_' + matches[functionIndex][1].toUpperCase() + ',\n'; + cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; functionIndex += 1; } cOut += '\n'; @@ -359,12 +219,12 @@ function generateAddonFile( matches, header, basePkg ) { cOut += 'static void *data[] = {\n'; functionIndex = 0; for ( i = 0; i < result.inputTypes.length; i++ ) { - inputType = result.inputTypes[i]; - outputTypes = grouped[inputType]; + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t(void *)' + matches[functionIndex][6] + ',\n'; + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; functionIndex += 1; } cOut += '\n'; @@ -411,18 +271,19 @@ function main() { var header; var jsOut; var cOut; - var pkg; // Generate and filter matches table: matches = generateMatchesTable(); - matches = filterValidMatches( matches ); // Extract package information: - pkg = require( './../package.json' ); basePkg = pkg.name.split( '/' ).pop(); // Generate license header: - header = generateLicenseHeader(); + 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 ); diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json b/lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json deleted file mode 100644 index 8521899b4572..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/matches.json +++ /dev/null @@ -1,1692 +0,0 @@ -[ - [ - "complex32", - "complex32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_j_as_c_c" - ], - [ - "complex32", - "complex64", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_c_as_c_c" - ], - [ - "complex32", - "complex128", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_z_as_c_c" - ], - [ - "complex32", - "float16", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_h_as_c_c" - ], - [ - "complex32", - "float32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_f_as_c_c" - ], - [ - "complex32", - "float64", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_d_as_c_c" - ], - [ - "complex32", - "int16", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_k_as_c_c" - ], - [ - "complex32", - "int32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_i_as_c_c" - ], - [ - "complex32", - "int8", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_s_as_c_c" - ], - [ - "complex32", - "uint16", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_t_as_c_c" - ], - [ - "complex32", - "uint32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_u_as_c_c" - ], - [ - "complex32", - "uint8", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_b_as_c_c" - ], - [ - "complex32", - "uint8c", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_j_a_as_c_c" - ], - [ - "complex64", - "complex32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_j_as_c_c" - ], - [ - "complex64", - "complex64", - "@stdlib/math/base/special/cceilf", - false, - null, - null, - "stdlib_base_cceilf", - "stdlib_ndarray_c_c" - ], - [ - "complex64", - "complex128", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_z_as_c_c" - ], - [ - "complex64", - "float16", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_h_as_c_c" - ], - [ - "complex64", - "float32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_f_as_c_c" - ], - [ - "complex64", - "float64", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_d_as_c_c" - ], - [ - "complex64", - "int16", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_k_as_c_c" - ], - [ - "complex64", - "int32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_i_as_c_c" - ], - [ - "complex64", - "int8", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_s_as_c_c" - ], - [ - "complex64", - "uint16", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_t_as_c_c" - ], - [ - "complex64", - "uint32", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_u_as_c_c" - ], - [ - "complex64", - "uint8", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_b_as_c_c" - ], - [ - "complex64", - "uint8c", - "@stdlib/math/base/special/cceilf", - true, - "complex64", - "complex64", - "stdlib_base_cceilf", - "stdlib_ndarray_c_a_as_c_c" - ], - [ - "complex128", - "complex32", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_j_as_z_z" - ], - [ - "complex128", - "complex64", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_c_as_z_z" - ], - [ - "complex128", - "complex128", - "@stdlib/math/base/special/cceil", - false, - null, - null, - "stdlib_base_cceil", - "stdlib_ndarray_z_z" - ], - [ - "complex128", - "float16", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_h_as_z_z" - ], - [ - "complex128", - "float32", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_f_as_z_z" - ], - [ - "complex128", - "float64", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_d_as_z_z" - ], - [ - "complex128", - "int16", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_k_as_z_z" - ], - [ - "complex128", - "int32", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_i_as_z_z" - ], - [ - "complex128", - "int8", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_s_as_z_z" - ], - [ - "complex128", - "uint16", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_t_as_z_z" - ], - [ - "complex128", - "uint32", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_u_as_z_z" - ], - [ - "complex128", - "uint8", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_b_as_z_z" - ], - [ - "complex128", - "uint8c", - "@stdlib/math/base/special/cceil", - true, - "complex128", - "complex128", - "stdlib_base_cceil", - "stdlib_ndarray_z_a_as_z_z" - ], - [ - "float16", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_j_as_f_f" - ], - [ - "float16", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_c_as_f_f" - ], - [ - "float16", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_z_as_f_f" - ], - [ - "float16", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_h_as_f_f" - ], - [ - "float16", - "float32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_f_as_f_f" - ], - [ - "float16", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_d_as_f_f" - ], - [ - "float16", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_k_as_f_f" - ], - [ - "float16", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_i_as_f_f" - ], - [ - "float16", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_s_as_f_f" - ], - [ - "float16", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_t_as_f_f" - ], - [ - "float16", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_u_as_f_f" - ], - [ - "float16", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_b_as_f_f" - ], - [ - "float16", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_h_a_as_f_f" - ], - [ - "float32", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_j_as_f_f" - ], - [ - "float32", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_c_as_f_f" - ], - [ - "float32", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_z_as_f_f" - ], - [ - "float32", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_h_as_f_f" - ], - [ - "float32", - "float32", - "@stdlib/math/base/special/ceilf", - false, - null, - null, - "stdlib_base_ceilf", - "stdlib_ndarray_f_f" - ], - [ - "float32", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_d_as_f_f" - ], - [ - "float32", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_k_as_f_f" - ], - [ - "float32", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_i_as_f_f" - ], - [ - "float32", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_s_as_f_f" - ], - [ - "float32", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_t_as_f_f" - ], - [ - "float32", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_u_as_f_f" - ], - [ - "float32", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_b_as_f_f" - ], - [ - "float32", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_f_a_as_f_f" - ], - [ - "float64", - "complex32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_j_as_d_d" - ], - [ - "float64", - "complex64", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_c_as_d_d" - ], - [ - "float64", - "complex128", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_z_as_d_d" - ], - [ - "float64", - "float16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_h_as_d_d" - ], - [ - "float64", - "float32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_f_as_d_d" - ], - [ - "float64", - "float64", - "@stdlib/math/base/special/ceil", - false, - null, - null, - "stdlib_base_ceil", - "stdlib_ndarray_d_d" - ], - [ - "float64", - "int16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_k_as_d_d" - ], - [ - "float64", - "int32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_i_as_d_d" - ], - [ - "float64", - "int8", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_s_as_d_d" - ], - [ - "float64", - "uint16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_t_as_d_d" - ], - [ - "float64", - "uint32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_u_as_d_d" - ], - [ - "float64", - "uint8", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_b_as_d_d" - ], - [ - "float64", - "uint8c", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_d_a_as_d_d" - ], - [ - "int16", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_j_as_f_f" - ], - [ - "int16", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_c_as_f_f" - ], - [ - "int16", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_z_as_f_f" - ], - [ - "int16", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_h_as_f_f" - ], - [ - "int16", - "float32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_f_as_f_f" - ], - [ - "int16", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_d_as_f_f" - ], - [ - "int16", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_k_as_f_f" - ], - [ - "int16", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_i_as_f_f" - ], - [ - "int16", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_s_as_f_f" - ], - [ - "int16", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_t_as_f_f" - ], - [ - "int16", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_u_as_f_f" - ], - [ - "int16", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_b_as_f_f" - ], - [ - "int16", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_k_a_as_f_f" - ], - [ - "int32", - "complex32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_j_as_d_d" - ], - [ - "int32", - "complex64", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_c_as_d_d" - ], - [ - "int32", - "complex128", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_z_as_d_d" - ], - [ - "int32", - "float16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_h_as_d_d" - ], - [ - "int32", - "float32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_f_as_d_d" - ], - [ - "int32", - "float64", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_d_as_d_d" - ], - [ - "int32", - "int16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_k_as_d_d" - ], - [ - "int32", - "int32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_i_as_d_d" - ], - [ - "int32", - "int8", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_s_as_d_d" - ], - [ - "int32", - "uint16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_t_as_d_d" - ], - [ - "int32", - "uint32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_u_as_d_d" - ], - [ - "int32", - "uint8", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_b_as_d_d" - ], - [ - "int32", - "uint8c", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_i_a_as_d_d" - ], - [ - "int8", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_j_as_f_f" - ], - [ - "int8", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_c_as_f_f" - ], - [ - "int8", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_z_as_f_f" - ], - [ - "int8", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_h_as_f_f" - ], - [ - "int8", - "float32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_f_as_f_f" - ], - [ - "int8", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_d_as_f_f" - ], - [ - "int8", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_k_as_f_f" - ], - [ - "int8", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_i_as_f_f" - ], - [ - "int8", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_s_as_f_f" - ], - [ - "int8", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_t_as_f_f" - ], - [ - "int8", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_u_as_f_f" - ], - [ - "int8", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_b_as_f_f" - ], - [ - "int8", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_s_a_as_f_f" - ], - [ - "uint16", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_j_as_f_f" - ], - [ - "uint16", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_c_as_f_f" - ], - [ - "uint16", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_z_as_f_f" - ], - [ - "uint16", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_h_as_f_f" - ], - [ - "uint16", - "float32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_f_as_f_f" - ], - [ - "uint16", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_d_as_f_f" - ], - [ - "uint16", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_k_as_f_f" - ], - [ - "uint16", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_i_as_f_f" - ], - [ - "uint16", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_s_as_f_f" - ], - [ - "uint16", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_t_as_f_f" - ], - [ - "uint16", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_u_as_f_f" - ], - [ - "uint16", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_b_as_f_f" - ], - [ - "uint16", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_t_a_as_f_f" - ], - [ - "uint32", - "complex32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_j_as_d_d" - ], - [ - "uint32", - "complex64", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_c_as_d_d" - ], - [ - "uint32", - "complex128", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_z_as_d_d" - ], - [ - "uint32", - "float16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_h_as_d_d" - ], - [ - "uint32", - "float32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_f_as_d_d" - ], - [ - "uint32", - "float64", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_d_as_d_d" - ], - [ - "uint32", - "int16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_k_as_d_d" - ], - [ - "uint32", - "int32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_i_as_d_d" - ], - [ - "uint32", - "int8", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_s_as_d_d" - ], - [ - "uint32", - "uint16", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_t_as_d_d" - ], - [ - "uint32", - "uint32", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_u_as_d_d" - ], - [ - "uint32", - "uint8", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_b_as_d_d" - ], - [ - "uint32", - "uint8c", - "@stdlib/math/base/special/ceil", - true, - "float64", - "float64", - "stdlib_base_ceil", - "stdlib_ndarray_u_a_as_d_d" - ], - [ - "uint8", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_j_as_f_f" - ], - [ - "uint8", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_c_as_f_f" - ], - [ - "uint8", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_z_as_f_f" - ], - [ - "uint8", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_h_as_f_f" - ], - [ - "uint8", - "float32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_f_as_f_f" - ], - [ - "uint8", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_d_as_f_f" - ], - [ - "uint8", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_k_as_f_f" - ], - [ - "uint8", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_i_as_f_f" - ], - [ - "uint8", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_s_as_f_f" - ], - [ - "uint8", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_t_as_f_f" - ], - [ - "uint8", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_u_as_f_f" - ], - [ - "uint8", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_b_as_f_f" - ], - [ - "uint8", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_b_a_as_f_f" - ], - [ - "uint8c", - "complex32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_j_as_f_f" - ], - [ - "uint8c", - "complex64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_c_as_f_f" - ], - [ - "uint8c", - "complex128", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_z_as_f_f" - ], - [ - "uint8c", - "float16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_h_as_f_f" - ], - [ - "uint8c", - "float32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_f_as_f_f" - ], - [ - "uint8c", - "float64", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_d_as_f_f" - ], - [ - "uint8c", - "int16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_k_as_f_f" - ], - [ - "uint8c", - "int32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_i_as_f_f" - ], - [ - "uint8c", - "int8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_s_as_f_f" - ], - [ - "uint8c", - "uint16", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_t_as_f_f" - ], - [ - "uint8c", - "uint32", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_u_as_f_f" - ], - [ - "uint8c", - "uint8", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_b_as_f_f" - ], - [ - "uint8c", - "uint8c", - "@stdlib/math/base/special/ceilf", - true, - "float32", - "float32", - "stdlib_base_ceilf", - "stdlib_ndarray_a_a_as_f_f" - ] -] \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js index f79525ac8611..1f043d1074ce 100644 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js @@ -20,23 +20,62 @@ // MODULES // +var cartesianProduct = require( '@stdlib/array/cartesian-product' ); var promotionRules = require( '@stdlib/ndarray/promotion-rules' ); -var dtypes = require( '@stdlib/ndarray/dtypes' ); var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); var format = require( '@stdlib/string/format' ); -var config = require( '@stdlib/math/special/ceil/scripts/config.js' ); -var generateTable = require( '@stdlib/math/special/ceil/scripts/table.js' ); +var safeCasts = require( '@stdlib/ndarray/safe-casts' ); +var generateTable = require( './table.js' ); +var config = require( './config.js' ); + + +// FUNCTIONS // + +/** +* Returns an array of matches with valid combinations. +* +* @private +* @param {Array} matches - array of all combinations +* @returns {Array} array of matches with valid combinations +*/ +function getValidCombinations( matches ) { + var validMatches = []; + var validDtypes; + var i; + + for ( i = 0; i < matches.length; i++ ) { + // Skip complex32, float16, uint8c and int16 as we don't support them yet... + if ( matches[ i ][ 0 ] === 'complex32' || + matches[ i ][ 0 ] === 'int16' || + matches[ i ][ 0 ] === 'float16' || + matches[ i ][ 0 ] === 'uint8c' || + matches[ i ][ 1 ] === 'complex32' || + matches[ i ][ 1 ] === 'int16'|| + matches[ i ][ 1 ] === 'float16' || + matches[ i ][ 1 ] === 'uint8c' ) { + continue; + } + + // Check if the dtypes are valid for the current match... + validDtypes = safeCasts( matches[ i ][ 5 ] ); + if ( validDtypes && validDtypes.includes( matches[ i ][ 1 ] ) && promotionRules( matches[ i ][ 0 ], matches[ i ][ 1 ] ) === matches[ i ][ 4 ] ) { // eslint-disable-line max-len + validMatches.push( matches[ i ] ); + } + } + + return validMatches; +} // MAIN // /** -* Generate dtype pairs, match them with stdlib packages, and resolve C function names and loop kernels. +* Generate dtype pairs, match them with appropriate packages, and resolve C function names and loop kernels. * * ## Note * -* - The function generates an array of matches, where each match is an array in the format: +* - The function generates an array of matches, where each match is an array of the following format: * * ```text * ---------------------------------------------------------------------------------------------------------------------------------------- @@ -45,7 +84,7 @@ var generateTable = require( '@stdlib/math/special/ceil/scripts/table.js' ); * | | | | | | | | * | | | | | | | | * V V | V V V | V -* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_f_f' +* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_d_d' * V V * '@stdlib/math/base/special/expf' 'stdlib_base_expf' * ``` @@ -54,13 +93,11 @@ var generateTable = require( '@stdlib/math/special/ceil/scripts/table.js' ); * @returns {Array} matches table containing dtype pairs and their corresponding package information */ function main() { - var functionName; + var cFuncName; var matches = []; - var basePkg; var kernel; var table; var pairs; - var pkg; var pdt; var row; var idt; @@ -69,13 +106,8 @@ function main() { var i; var j; - // Generate the table: - pkg = require( '@stdlib/math/special/ceil/package.json' ); - basePkg = pkg.name.split( '/' ).pop(); - table = generateTable( basePkg ); - /* - Should be generated in this order only. Check once: + Generate the table. For example, we'll have: Table: [ [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], @@ -83,9 +115,10 @@ function main() { [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ], ] */ + table = generateTable(); /* - Resolve list of input dtypes. After this, we'll have: + Resolve list of input dtypes. For example, we'll have: idt = [ 'complex32', 'complex64', @@ -105,7 +138,7 @@ function main() { idt = dtypes( config.input_dtypes ); /* - Resolve the list of output dtypes. After this, we'll have: + Resolve the list of output dtypes. For example, we'll have: odt = [ 'complex32', 'complex128', @@ -125,7 +158,7 @@ function main() { odt = dtypes( config.output_dtypes ); /* - Generate the input-output dtype pairs. After this, we'll have: + Generate the input-output dtype pairs. For example, we'll have: pairs = [ [ 'complex32', 'complex32' ], [ 'complex32', 'complex64' ], @@ -154,53 +187,39 @@ function main() { // Match-make each dtype pair with a stdlib package... for ( i = 0; i < pairs.length; i++ ) { - // Now let dt = [ 'complex32', 'float32' ]... + // Now let dt = [ 'uint32', 'float32' ]... dt = pairs[ i ]; - // First pass: look for exact matches... for ( j = 0; j < table.length; j++ ) { - // Now let row = [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ]... row = table[ j ]; + + // Resolve the scalar math kernel C function name from package path ( e.g., '@stdlib/math/base/special/ceilf' -> 'ceilf' --> 'stdlib_base_ceilf' ): + cFuncName = 'stdlib_base_' + row[ 2 ].split( '/' ).pop(); + + // Firstly, look for exact matches. For example, let row = [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ]... if ( row[ 0 ] === dt[ 0 ] && row[ 1 ] === dt[ 1 ] ) { - matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, '', '' ] ); + // Resolve the loop kernel... + kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, cFuncName, kernel ] ); // eslint-disable-line max-len break; } - // Next check for package to which the dtype pair can promote... - // For example, pdt = promotionRules( 'complex32', 'complex64' ) = 'complex64' + // Then check for package to which the dtype pair can promote. For example, pdt = promotionRules( 'uint32', 'float32' ) = 'float64': pdt = promotionRules( dt[ 0 ], row[ 0 ] ); if ( pdt ) { - // Check for a package which supports the promoted dtypes... + // Check if the package in the present row supports the promoted dtypes... if ( row[ 0 ] === pdt && row[ 1 ] === pdt ) { - matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, '', '' ] ); - break; + // Resolve the loop kernel... + kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( dt[ 0 ] ), dtypeChar( dt[ 1 ] ), dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, cFuncName, kernel ] ); // eslint-disable-line max-len } } } } - // NOTE: modify below to also resolve JS alias for generating the JavaScript tables, as well... - // Resolve the scalar math kernel C function name... - for ( i = 0; i < matches.length; i++ ) { - row = matches[ i ]; - - // Extract function name from package path (e.g., '@stdlib/math/base/special/ceilf' -> 'ceilf') - functionName = row[ 2 ].split( '/' ).pop(); - row[ 6 ] = 'stdlib_base_' + functionName; - } - - // Resolve the loop kernel... - for ( i = 0; i < matches.length; i++ ) { - row = matches[ i ]; - if ( row[ 3 ] === true ) { - kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ), dtypeChar( row[ 4 ] ), dtypeChar( row[ 5 ] ) ); - } else { - kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); - } - row[ 7 ] = kernel; - } - - return matches; + return getValidCombinations( matches ); } +main(); + module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js index edf28dba8b4f..3e227f87123f 100644 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js @@ -21,14 +21,14 @@ // MODULES // -var resolve = require( 'path' ).resolve; var basename = require( 'path' ).basename; +var resolve = require( 'path' ).resolve; var path = require( 'path' ); var ls = require( '@stdlib/_tools/pkgs/names' ).sync; var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; -var readJSON = require( '@stdlib/fs/read-json' ).sync; var rootDir = require( '@stdlib/_tools/utils/root-dir' ); -var pkg = require( '@stdlib/math/special/ceil/package.json' ); +var readJSON = require( '@stdlib/fs/read-json' ).sync; +var pkg = require( './.././package.json' ); // VARIABLES // @@ -51,28 +51,31 @@ var jsonOpts = { * * ## Note * -* For now, we are trying only four combinations. So, let us say we are looking for the `sin` package, we will try to find: +* For now, we are trying the following four combinations. So, let us say, we are looking for the `sin` package, then we will try to find: * -* - `@stdlib/math/base/special/sin` * - `@stdlib/math/base/special/sinf` -* - `@stdlib/math/base/special/csin` +* - `@stdlib/math/base/special/sin` * - `@stdlib/math/base/special/csinf` +* - `@stdlib/math/base/special/csin` * * Now since as of now, we don't have `@stdlib/math/base/special/csin` and `@stdlib/math/base/special/csinf`, we will only get the first two packages. * * @private -* @param {string} base - base package name * @returns {Array} list of relevant packages * * @example -* var pkgs = getRelevantPackages( 'exp' ); -* // returns [ '@stdlib/math/base/special/exp', '@stdlib/math/base/special/expf', '@stdlib/math/base/special/cexp', '@stdlib/math/base/special/cexpf' ] +* var basePkg = 'inv'; +* +* var pkgs = getRelevantPackages(); +* // returns [ '@stdlib/math/base/special/invf', '@stdlib/math/base/special/inv', '@stdlib/math/base/special/cinvf', '@stdlib/math/base/special/cinv' ] * * @example +* var basePkg = 'sin'; +* * var pkgs = getRelevantPackages( 'sin' ); -* // returns [ '@stdlib/math/base/special/sin', '@stdlib/math/base/special/sinf' ] +* // returns [ '@stdlib/math/base/special/sinf', '@stdlib/math/base/special/sin' ] */ -function getRelevantPackages( base ) { +function getRelevantPackages() { var combinations; var names; var pkgs; @@ -82,24 +85,15 @@ function getRelevantPackages( base ) { pkgs = []; - /* - * Initializing all possible combinations that we can try. - * - * For example, for `exp`, we will try looking for: - * - * - `@stdlib/math/base/special/exp` - * - `@stdlib/math/base/special/expf` - * - `@stdlib/math/base/special/cexp` - * - `@stdlib/math/base/special/cexpf` - */ + // Initializing all possible combinations that we can try, in the required order: combinations = [ - path.join(pathString, base + 'f'), - path.join(pathString, base), - path.join(pathString, 'c' + base + 'f'), - path.join(pathString, 'c' + base) + path.join( pathString, basePkg + 'f' ), + path.join( pathString, basePkg ), + path.join( pathString, 'c' + basePkg + 'f' ), + path.join( pathString, 'c' + basePkg ) ]; - // Get the list of packages in `math/base/special/*`: + // Get the list of all packages in `math/base/special/*`: names = ls( opts ); // Filter the list of packages to only include those which match the combinations: @@ -115,25 +109,23 @@ function getRelevantPackages( base ) { return pkgs; } -// Now we need to fetch the meta data (input/output dtypes) from the relevant packages: - /** * Returns the input and output dtypes for a given package. * * ## Note * -* Currently, this only supports packages which have a single input and a single output. -* In order to support packages with multiple inputs, we can restructure the our table and calculate accordingly. -* As of now, each array in our table looks like this: +* - Currently, this function only supports those packages which expect a single input and return a single output. +* - In order to support packages with multiple inputs, we'll need to restructure our table and calculate accordingly. +* - As of now, each array in our table looks like this: * -* [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] +* [ input_dtype, output_dtype, package_name ] +* For example: [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] * -* This is fine for single input & single output functions. But, for functions such as `pow`, we can have: +* This is fine for single input & single output functions. But, for functions such as `pow`, which expect two input values, we can have: * +* [ number_of_inputs, input_dtype_1, input_dtype_2, ... input_dtype_n, output_dtype, package_name ] * [ 2, 'float64', 'float64', `float64`, '@stdlib/math/base/special/pow' ] * -* where the first element ( 2, in this case ) is the number of inputs. -* * @private * @param {string} alias - package name * @returns {Array} input and output dtypes @@ -158,7 +150,7 @@ function getDtypes( alias ) { // Resolve the package: pkg = findPkgs({ 'dir': ROOT_DIR, - 'pattern': '**/math/base/special/'+ alias +'/package.json' // Check once, we should pass only the base name of the package here + 'pattern': '**/math/base/special/'+ alias +'/package.json' }); if ( pkg.length === 0 ) { @@ -169,7 +161,7 @@ function getDtypes( alias ) { path = resolve( ROOT_DIR, pkg[ 0 ] ); json = readJSON( resolve( path, 'package.json' ), jsonOpts ); o = json.__stdlib__; // eslint-disable-line no-underscore-dangle - if ( o && o.scaffold && o.scaffold.parameters.length === 1 ) { + if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { out = o.scaffold; } @@ -186,44 +178,35 @@ function getDtypes( alias ) { /** * Generate the function table. * -* @param {string} base - base package name * @returns {Array} function table * * @example -* var table = generateTable( 'exp' ); -* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/expf' ], [ 'float64', 'float64', '@stdlib/math/base/special/exp' ], [ 'complex64', 'complex64', '@stdlib/math/base/special/cexpf' ], [ 'complex128', 'complex128', '@stdlib/math/base/special/cexp' ] ] +* var basePkg = 'ceil'; +* +* var table = generateTable(); +* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ], [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ] ] */ -function generateTable( base ) { +function generateTable() { var aliasName; var dtypes; var table; var pkgs; + var pkg; var i; - /* - * Get the list of relevant packages for the given base package. - * - * For example, for `exp`, we will get: - * - * pkgs = [ - * '@stdlib/math/base/special/exp', - * '@stdlib/math/base/special/expf', - * '@stdlib/math/base/special/cexp', - * '@stdlib/math/base/special/cexpf' - * ]; - */ - - pkgs = getRelevantPackages( base ); + // Get the list of relevant packages for the given base package: + pkgs = getRelevantPackages(); // Initialize the table: table = []; - // Loop over the packages and get the input/output dtypes: + // Loop over the packages and get the input and output dtypes: for ( i = 0; i < pkgs.length; i++ ) { // Extract the alias name out of the package path: - aliasName = pkgs[ i ].replace( pathString + '/', '' ); + pkg = pkgs[ i ]; + aliasName = pkg.replace( pathString + '/', '' ); dtypes = getDtypes( aliasName ); - table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkgs[ i ] ] ); + table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkg ] ); } return table; diff --git a/lib/node_modules/@stdlib/math/special/ceil/src/addon.c b/lib/node_modules/@stdlib/math/special/ceil/src/addon.c new file mode 100644 index 000000000000..8c8b5c968b7f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/ceil/src/addon.c @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* This is a generated file. Do not edit directly. */ +#include "stdlib/math/base/special/cceil.h" +#include "stdlib/math/base/special/cceilf.h" +#include "stdlib/math/base/special/ceil.h" +#include "stdlib/math/base/special/ceilf.h" +#include "stdlib/ndarray/base/function_object.h" +#include "stdlib/ndarray/base/napi/unary.h" +#include "stdlib/ndarray/base/unary.h" +#include "stdlib/ndarray/dtypes.h" +#include + +// Define an interface name: +static const char name[] = "stdlib_ndarray_ceil"; + +// Define a list of ndarray functions: +static ndarrayFcn functions[] = { + // complex64 (1) + stdlib_ndarray_c_z_as_z_z, + + // float32 (3) + stdlib_ndarray_f_c_as_c_c, + stdlib_ndarray_f_z_as_z_z, + stdlib_ndarray_f_d_as_d_d, + + // float64 (1) + stdlib_ndarray_d_z_as_z_z, + + // int32 (2) + stdlib_ndarray_i_z_as_z_z, + stdlib_ndarray_i_d_as_d_d, + + // int8 (4) + stdlib_ndarray_s_c_as_c_c, + stdlib_ndarray_s_z_as_z_z, + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_d_as_d_d, + + // uint16 (4) + stdlib_ndarray_t_c_as_c_c, + stdlib_ndarray_t_z_as_z_z, + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_d_as_d_d, + + // uint32 (2) + stdlib_ndarray_u_z_as_z_z, + stdlib_ndarray_u_d_as_d_d, + + // uint8 (4) + stdlib_ndarray_b_c_as_c_c, + stdlib_ndarray_b_z_as_z_z, + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_d_as_d_d, + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // complex64 (1) + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, + + // float32 (3) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + + // float64 (1) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX128, + + // int32 (2) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + + // int8 (4) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + + // uint16 (4) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + + // uint32 (2) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + + // uint8 (4) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // complex64 (1) + (void *)stdlib_base_cceil, + + // float32 (3) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceil, + + // float64 (1) + (void *)stdlib_base_cceil, + + // int32 (2) + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceil, + + // int8 (4) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceilf, + (void *)stdlib_base_ceil, + + // uint16 (4) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceilf, + (void *)stdlib_base_ceil, + + // uint32 (2) + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceil, + + // uint8 (4) + (void *)stdlib_base_cceilf, + (void *)stdlib_base_cceil, + (void *)stdlib_base_ceilf, + (void *)stdlib_base_ceil, + +}; + +// Create an ndarray function object: +static const struct ndarrayFunctionObject obj = { + // ndarray function name: + name, + + // Number of input ndarrays: + 1, + + // Number of output ndarrays: + 1, + + // Total number of ndarray arguments (nin + nout): + 2, + + // Array containing ndarray functions: + functions, + + // Number of ndarray functions: + 21, + + // Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function: + types, + + // Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions): + data +}; + +STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj ) From cced8c11c81d5e62a12bb2cefe5d813c24500fdf Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 29 Jul 2025 17:54:38 +0530 Subject: [PATCH 07/31] Delete lib/node_modules/@stdlib/math/special/abs/scripts/test.js Signed-off-by: Gunj Joshi --- .../@stdlib/math/special/abs/scripts/test.js | 318 ------------------ 1 file changed, 318 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/abs/scripts/test.js diff --git a/lib/node_modules/@stdlib/math/special/abs/scripts/test.js b/lib/node_modules/@stdlib/math/special/abs/scripts/test.js deleted file mode 100644 index c00d737be402..000000000000 --- a/lib/node_modules/@stdlib/math/special/abs/scripts/test.js +++ /dev/null @@ -1,318 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var join = require( 'path' ).join; -var writeFileSync = require( '@stdlib/fs/write-file' ).sync; -var dtypes = require( '@stdlib/ndarray/dtypes' ); -var currentYear = require( '@stdlib/time/current-year' ); - - -// VARIABLES // - -var FUNCTION_NAME = 'abs'; -var KERNEL_MAP = { - 'float64': 'stdlib_base_abs', - 'float32': 'stdlib_base_absf', - 'complex128': 'stdlib_base_cabs', - 'complex64': 'stdlib_base_cabsf', - 'int32': 'stdlib_base_labs', - 'int16': 'stdlib_base_labs', - 'int8': 'stdlib_base_labs', - 'uint32': 'stdlib_base_abs', - 'uint16': 'stdlib_base_abs', - 'uint8': 'stdlib_base_abs', - 'uint8c': 'stdlib_base_abs' -}; -var INCLUDE_MAP = { - 'abs': 'abs.h', - 'absf': 'absf.h', - 'cabs': 'cabs.h', - 'cabsf': 'cabsf.h', - 'labs': 'labs.h' -}; - -/** -* Default output dtype rule for abs function. -* -* @private -* @param {string} input - input dtype -* @returns {Array} array of valid output dtypes -*/ -function outputDtypeRule( input ) { - var rules = { - 'float64': [ 'float64' ], - 'float32': [ 'float32', 'float64' ], - 'complex128': [ 'float64' ], - 'complex64': [ 'float32', 'float64' ], - 'int32': [ 'int32', 'uint32', 'float64' ], - 'int16': [ 'int16', 'int32', 'uint16', 'uint32', 'float32', 'float64' ], - 'int8': [ 'int8', 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64' ], - 'uint32': [ 'uint32', 'float64' ], - 'uint16': [ 'int32', 'uint16', 'uint32', 'float32', 'float64' ], - 'uint8': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64' ], - 'uint8c': [ 'int16', 'int32', 'uint8', 'uint8c', 'uint16', 'uint32', 'float32', 'float64' ] - }; - return rules[ input ] || []; -} - -/** -* Generates the ndarray function name for given input and output dtypes. -* -* @private -* @param {string} input - input dtype -* @param {string} output - output dtype -* @returns {string} ndarray function name -*/ -function getNdarrayFcnName( input, output ) { - var map = { - 'float64': 'd', - 'float32': 'f', - 'complex128': 'z', - 'complex64': 'c', - 'int32': 'i', - 'int16': 'k', - 'int8': 's', - 'uint32': 'u', - 'uint16': 't', - 'uint8': 'b', - 'uint8c': 'a' - }; - return 'stdlib_ndarray_' + map[ input ] + '_' + map[ output ]; -} - -/** -* Counts the number of functions in a group. -* -* @private -* @param {string} dt - dtype -* @param {Object} grouped - grouped functions -* @returns {number} count -*/ -function countGroup( dt, grouped ) { - return grouped[ dt ].length; -} - -/** -* Generates function-specific includes. -* -* @private -* @returns {Array} array of include statements -*/ -function generateFunctionIncludes() { - var includeStatement; - var functionIncludes; - var kernelNames; - var includeKey; - var kernel; - var i; - - functionIncludes = []; - kernelNames = Object.keys( KERNEL_MAP ); - for ( i = 0; i < kernelNames.length; i++ ) { - kernel = KERNEL_MAP[ kernelNames[ i ] ]; - includeKey = kernel.replace( 'stdlib_base_', '' ); - if ( INCLUDE_MAP[ includeKey ] ) { - includeStatement = '#include "stdlib/math/base/special/' + INCLUDE_MAP[ includeKey ] + '"'; - if ( functionIncludes.indexOf( includeStatement ) === -1 ) { - functionIncludes.push( includeStatement ); - } - } - } - return functionIncludes; -} - -/** -* Generates type pairs and kernels. -* -* @private -* @returns {Object} object containing types and kernels arrays -*/ -function generateTypesAndKernels() { - var outputDtypes; - var allDtypes; - var kernels; - var output; - var input; - var types; - var i; - var j; - - allDtypes = dtypes( 'all' ); - types = []; - kernels = []; - - for ( i = 0; i < allDtypes.length; i++ ) { - input = allDtypes[ i ]; - outputDtypes = outputDtypeRule( input ); - for ( j = 0; j < outputDtypes.length; j++ ) { - output = outputDtypes[ j ]; - types.push( [ input, output ] ); - kernels.push( KERNEL_MAP[ input ] || 'stdlib_base_' + FUNCTION_NAME ); - } - } - - return { - 'types': types, - 'kernels': kernels - }; -} - -/** -* Main function to generate addon arrays. -* -* @private -*/ -function main() { - var functionIncludes; - var licenseHeader; - var baseIncludes; - var dtypeOrder; - var groupItems; - var cHeader; - var kernels; - var grouped; - var result; - var types; - var jsOut; - var pair; - var cOut; - var obj; - var dt; - var i; - var j; - - result = generateTypesAndKernels(); - types = result.types; - kernels = result.kernels; - - dtypeOrder = [ - 'float64', 'float32', 'generic', 'int32', 'int16', 'int8', 'uint32', 'uint16', 'uint8', 'uint8c' - ]; - grouped = {}; - - for ( i = 0; i < dtypeOrder.length; i++ ) { - grouped[ dtypeOrder[ i ] ] = []; - } - - for ( i = 0; i < types.length; i++ ) { - pair = types[ i ]; - if ( grouped[ pair[ 0 ] ] ) { - grouped[ pair[ 0 ] ].push({ - 'pair': pair, - 'kernel': kernels[ i ] - }); - } - } - - // Write generated_types.js: - licenseHeader = '/**\n* @license Apache-2.0\n*\n* Copyright (c) ' + currentYear() + ' The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the "License");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an "AS IS" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable array-element-newline */\n\n\'use strict\';\n\n// MODULES //\n\nvar dtypes = require( \'@stdlib/ndarray/dtypes\' );\n\n\n// MAIN //\n\nvar types = [\n'; - jsOut = licenseHeader; - - for ( i = 0; i < dtypeOrder.length; i++ ) { - dt = dtypeOrder[ i ]; - groupItems = grouped[ dt ]; - for ( j = 0; j < groupItems.length; j++ ) { - obj = groupItems[ j ]; - jsOut += ' dtypes.' + obj.pair[ 0 ] + ', dtypes.' + obj.pair[ 1 ] + ',\n'; - } - } - jsOut += '];\n\n\n// EXPORTS //\n\nmodule.exports = types;\n'; - writeFileSync( join( __dirname, '../lib/generated_types.js' ), jsOut, { - 'encoding': 'utf8' - }); - - // Write generated_addon_arrays.c: - cHeader = '/**\n* @license Apache-2.0\n*\n* Copyright (c) ' + currentYear() + ' The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the "License");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an "AS IS" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'; - - // Add base includes (always required for all math functions): - baseIncludes = [ - '#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 ' - ]; - cHeader += baseIncludes.join('\n') + '\n'; - - // Add function-specific includes: - functionIncludes = generateFunctionIncludes(); - if ( functionIncludes.length > 0 ) { - cHeader += functionIncludes.join('\n') + '\n'; - } - - cOut = cHeader; - cOut += '\n// Define a list of ndarray functions:\n'; - cOut += 'static ndarrayFcn functions[] = {\n'; - for ( i = 0; i < dtypeOrder.length; i++ ) { - dt = dtypeOrder[ i ]; - if ( grouped[ dt ].length > 0 ) { - cOut += ' // ' + dt + ' (' + countGroup( dt, grouped ) + ')\n'; - groupItems = grouped[ dt ]; - for ( j = 0; j < groupItems.length; j++ ) { - obj = groupItems[ j ]; - cOut += ' ' + getNdarrayFcnName( obj.pair[ 0 ], obj.pair[ 1 ] ) + ',\n'; - } - } - } - cOut += '};\n\n'; - cOut += '// Define the **ndarray** argument types for each ndarray function:\n'; - cOut += 'static int32_t types[] = {\n'; - for ( i = 0; i < dtypeOrder.length; i++ ) { - dt = dtypeOrder[ i ]; - groupItems = grouped[ dt ]; - for ( j = 0; j < groupItems.length; j++ ) { - obj = groupItems[ j ]; - cOut += ' STDLIB_NDARRAY_' + obj.pair[ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + obj.pair[ 1 ].toUpperCase() + ',\n'; - } - } - cOut += '};\n\n'; - cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; - cOut += 'static void *data[] = {\n'; - for ( i = 0; i < dtypeOrder.length; i++ ) { - dt = dtypeOrder[ i ]; - if ( grouped[ dt ].length > 0 ) { - cOut += ' // ' + dt + ' (' + countGroup( dt, grouped ) + ')\n'; - groupItems = grouped[ dt ]; - for ( j = 0; j < groupItems.length; j++ ) { - obj = groupItems[ j ]; - cOut += ' (void *)' + obj.kernel + ',\n'; - } - } - } - cOut += '};\n\n'; - cOut += '// Create an ndarray function object:\n'; - cOut += 'static const struct ndarrayFunctionObject obj = {\n'; - cOut += ' // ndarray function name:\n name,\n\n'; - cOut += ' // Number of input ndarrays:\n 1,\n\n'; - cOut += ' // Number of output ndarrays:\n 1,\n\n'; - cOut += ' // Total number of ndarray arguments (nin + nout):\n 2,\n\n'; - cOut += ' // Array containing ndarray functions:\n functions,\n\n'; - cOut += ' // Number of ndarray functions:\n ' + types.length + ',\n\n'; - cOut += ' // 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 types,\n\n'; - cOut += ' // 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 data\n};\n\n'; - cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; - writeFileSync( join( __dirname, '../src/generated_addon_arrays.c' ), cOut, { - 'encoding': 'utf8' - }); -} - -main(); From ff7deecbfd5f623fbbed7f530d5bbc13f55040fe Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 29 Jul 2025 17:55:08 +0530 Subject: [PATCH 08/31] Delete lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt Signed-off-by: Gunj Joshi --- .../@stdlib/math/special/abs/src/addon.c.txt | 131 ------------------ 1 file changed, 131 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt diff --git a/lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt b/lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt deleted file mode 100644 index dde86a193d01..000000000000 --- a/lib/node_modules/@stdlib/math/special/abs/src/addon.c.txt +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) {{YEAR}} {{COPYRIGHT}}. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* {{NOTE}} */ - -#include "stdlib/math/base/special/abs.h" -#include "stdlib/math/base/special/absf.h" -#include "stdlib/math/base/special/labs.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 - -/** -* Evaluates the identity function for an unsigned 32-bit integer. -* -* @param x input value -* @return input value -*/ -static uint32_t identity_u( const uint32_t x ) { - return x; -} - -/** -* Evaluates the identity function for an unsigned 16-bit integer. -* -* @param x input value -* @return input value -*/ -static uint16_t identity_t( const uint16_t x ) { - return x; -} - -/** -* Evaluates the identity function for an unsigned 8-bit integer. -* -* @param x input value -* @return input value -*/ -static uint8_t identity_b( const uint8_t x ) { - return x; -} - -/** -* Computes the absolute value of a signed 16-bit integer. -* -* @param x input value -* @return absolute value -*/ -static int16_t abs_k( const int16_t x ) { - if ( x < 0 ) { - return -x; - } - return x; -} - -/** -* Computes the absolute value of a signed 8-bit integer. -* -* @param x input value -* @return absolute value -*/ -static int8_t abs_s( const int8_t x ) { - if ( x < 0 ) { - return -x; - } - return x; -} - -// Define an interface name: -static const char name[] = "{{INTERFACE_NAME}}"; - -// Define a list of ndarray functions: -static ndarrayFcn functions[] = { - {{FUNCTIONS}} -}; - -// Define the **ndarray** argument types for each ndarray function: -static int32_t types[] = { - {{TYPES}} -}; - -// Define a list of ndarray function "data" (in this case, callbacks): -static void *data[] = { - {{DATA}} -}; - -// 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: - {{NUM_FUNCTIONS}}, - - // 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 ) From 807edcdbdbe34a85abff34fb22408660eb52dab9 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 29 Jul 2025 18:09:22 +0530 Subject: [PATCH 09/31] Update script.js Signed-off-by: Gunj Joshi --- lib/node_modules/@stdlib/math/special/ceil/scripts/script.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js index 1f043d1074ce..aca8b0426465 100644 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js @@ -220,6 +220,4 @@ function main() { return getValidCombinations( matches ); } -main(); - module.exports = main; From 34f340ea193e313dd0db767067e406be548a9729 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sun, 3 Aug 2025 23:51:40 +0530 Subject: [PATCH 10/31] refactor: try new approach --- .../@stdlib/math/special/notes.txt | 127 ++++++ .../special/scripts/function_database.json | 12 + .../@stdlib/math/special/sqrt/lib/types.js | 61 +++ .../math/special/sqrt/scripts/config.js | 31 ++ .../special/sqrt/scripts/generate_files.js | 381 ++++++++++++++++++ .../math/special/sqrt/scripts/script.js | 205 ++++++++++ .../math/special/sqrt/scripts/table.js | 219 ++++++++++ .../@stdlib/math/special/sqrt/src/addon.c | 133 ++++++ 8 files changed, 1169 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/special/notes.txt create mode 100644 lib/node_modules/@stdlib/math/special/scripts/function_database.json create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/lib/types.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/src/addon.c diff --git a/lib/node_modules/@stdlib/math/special/notes.txt b/lib/node_modules/@stdlib/math/special/notes.txt new file mode 100644 index 000000000000..5f5424617c8a --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/notes.txt @@ -0,0 +1,127 @@ +// math/special/scripts/function_database.json + +```json +{ + "abs": { + // ... + }, + ... + "ceil": { + "input_dtypes": "numeric_and_generic", + "output_dtypes": "numeric_and_generic", + "output_policy": "same", + + "scalar_kernels": { + // "input_type": "scalar_kernel" + + "float64": "@stdlib/math/base/special/ceil", + "float32": "@stdlib/math/base/special/ceilf", + "complex128": "@stdlib/math/base/special/cceil", + "complex64": "@stdlib/math/base/special/cceilf", + "uint8": "@stdlib/number/uint8/base/identity", + "uint16" "@stdlib/number/uint16/base/identity", + ... + } + }, + ... + "sqrt": { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point", + "output_policy": "real_floating_point", + "scalar_kernels": { + "float64": "@stdlib/math/base/special/sqrt", + "float32": "@stdlib/math/base/special/sqrtf" + } + } +} +``` + + +// Script.js + +```javascript +var objectKeys = require( '@stdlib/utils/keys' ); +var db = require( '@stdlib/math/special/scripts/function_database.json' ); + +// Get the list of dtypes we'd like to support: +var idt = dtypes( config.input_dtypes ); +var odt = dtypes( config.output_dtypes ); + +// Compute the Cartesian product of input and output dtypes: +var iopairs = cartesianProduct( idt, sdt ); + +// Filter based on "mostly safe" casts: +iopairs = filter( iopairs ); // => only those dtype pairs which make "sense" and are mostly safe casts + +// Get the list of dtypes with scalar math kernels: +var obj = db[ 'ceil' ]; // => {...} +var sdt = objectKeys( obj.scalar_kernels ); // => [ 'float64', 'float32', 'int8', 'uint8', 'int16', 'uint16', ... ] + +// Then map each pair to a scalar math kernel based on the output dtype: +var scalarKernels = getScalarKernels( iopairs ); // => [ '@stdlib/number/int8/base/identity', '@stdlib/number/int16/base/identity', ... ] + +// Resolve the input-output dtypes for each scalar math kernel: +var iodt = resolveInOutDtypes( scalarKernels ); // => read the package.json scaffold meta data +/* +* Prioritization: +* +* 1. scalar kernels having a signature which exactly matches the iopair +* 2. scalar kernels which have a signature exactly matching (out_dtype, out_dtype) +* +* Example: +* +* sqrt: +* - (float32,float32) => @stdlib/math/base/special/sqrtf +* - (int8,float32) => @stdlib/math/base/special/sqrtf +* - (float32,float64) => @stdlib/math/base/special/sqrt +* +* ceil: +* - (float32,float32) => @stdlib/math/base/special/ceilf +* - (int8,float32) => @stdlib/math/base/special/ceilf +*/ + +// Map dtype pairs to ndarray functions: +int8,float32 => s,f => stdlib_ndarray_s_f_as_f_f( stdlib_base_sqrtf ) +int8,float64 => s,d => stdlib_ndarray_s_d_as_d_d( stdlib_base_sqrt ) +int16,float32 => k,f => stdlib_ndarray_k_f_as_f_f( stdlib_base_sqrtf ) +int16,float64 => k,d => stdlib_ndarray_k_d_as_d_d( stdlib_base_sqrt ) +... +float32,float32 => stdlib_ndarray_f_f( stdlib_base_sqrtf ) +float32,float64 => stdlib_ndarray_f_d_as_d_d( stdlib_base_sqrt ) +float64,float32 => stdlib_ndarray_d_f( stdlib_base_sqrt ) +``` + + +[ 'int8', 'int16' ] + +- number/int8/base/identity => stdlib_ndarray_s_k => stdlib_ndarray_s_k_as_s_s +- number/int16/base/identity => stdlib_ndarray_s_k_as_k_k + - CHOOSE this one, as it makes more sense to upcast the input, than upcast the output after the operation, in order to perform the operation at higher precision. + +[ 'float32', 'float64' ] + +- stdlib_ndarray_f_d_as_d_d + +[ 'float64', 'float32' ] + +- stdlib_ndarray_d_f_as_f_f +- stdlib_ndarray_d_f => stdlib_ndarray_d_f_as_d_d + - CHOOSE this one, as it allows us to compute in higher precision and then downcast the output after the operation, in order to perform the operation at higher precision. + +Comments: + +- One thing which would be useful to have in `ndarray/base/unary` is a `data/function_list.json`, which can be filtered during scalar math kernel matchmaking with a ndarray function... + +``` +[ + "stdlib_ndarray_f_f", + ... + "stdlib_ndarray_b_k", + "stdlib_ndarray_b_k_as_k_k", + ... + "stdlib_ndarray_d_f", + "stdlib_ndarray_d_f_as_f_f" +] +``` + +To break ties (i.e., multiple matches for an input-output dtype pair), always compute at a higher precision. \ No newline at end of file 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..5250774f1ee3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -0,0 +1,12 @@ +{ + "sqrt": { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point", + "output_policy": "real_floating_point", + "scalar_kernels": { + "float64": "@stdlib/math/base/special/sqrt", + "float32": "@stdlib/math/base/special/sqrtf" + } + } +} + 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..d7398ba52f1a --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* This is a generated file. Do not edit directly. */ +/* +* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation. +*/ + +/* eslint-disable array-element-newline */ + +'use strict'; + +// MODULES // + +var dtypes = require( '@stdlib/ndarray/dtypes' ); + + +// MAIN // + +var types = [ + // float32 (1) + dtypes.float32, dtypes.float64, + + // int32 (1) + dtypes.int32, dtypes.float64, + + // int8 (2) + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.float64, + + // uint32 (1) + dtypes.uint32, dtypes.float64, + + // uint16 (2) + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.float64, + + // uint8 (2) + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.float64 +]; + + +// EXPORTS // + +module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js new file mode 100644 index 000000000000..ae75f3c989e3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +var config = { + 'input_dtypes': 'real_and_generic', + 'output_dtypes': 'real_floating_point' +}; + + +// EXPORTS // + +module.exports = config; 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..3ff7c5b9e701 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -0,0 +1,381 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var basename = require( 'path' ).basename; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var currentYear = require( '@stdlib/time/current-year' ); +var generateMatchesTable = require( './script.js' ); + + +// FUNCTIONS // + +/** +* Returns an index for ordering input types by approximate likelihood of use. +* +* @private +* @param {string} dtype - input dtype +* @returns {number} order index +*/ +function inputTypeOrderIndex( dtype ) { + // Prefer float64, then float32, then generic, then signed ints, then unsigned ints, then others... + switch ( dtype ) { // eslint-disable-line default-case + case 'float64': + return 0; + case 'float32': + return 1; + case 'generic': + return 2; + case 'int32': + return 3; + case 'int16': + return 4; + case 'int8': + return 5; + case 'uint32': + return 6; + case 'uint16': + return 7; + case 'uint8': + return 8; + case 'uint8c': + return 9; + case 'float16': + return 10; + case 'complex128': + return 11; + case 'complex64': + return 12; + case 'complex32': + return 13; + } + return 99; +} + +/** +* Groups matches by input data type and reorders by likelihood of use. +* +* @private +* @param {Array} matches - array of match entries +* @returns {Object} object containing grouped matches, ordered input types array, and reordered matches +*/ +function groupMatchesByInputType( matches ) { + var reorderedMatches = []; + var inputTypes = []; + var inputType; + var grouped = {}; + var i; + var j; + + for ( i = 0; i < matches.length; i++ ) { + inputType = matches[ i ][ 0 ]; + if ( !grouped[ inputType ] ) { + grouped[ inputType ] = []; + inputTypes.push( inputType ); + } + grouped[ inputType ].push( matches[ i ][ 1 ] ); + } + + // Order input types by preferred usage: + inputTypes.sort( compare ); + + /** + * Comparison function for input dtype ordering. + * + * @private + * @param {string} a - left dtype + * @param {string} b - right dtype + * @returns {number} comparison result + */ + function compare( a, b ) { + return inputTypeOrderIndex( a ) - inputTypeOrderIndex( b ); + } + + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + for ( j = 0; j < matches.length; j++ ) { + if ( matches[ j ][ 0 ] === inputType ) { + reorderedMatches.push( matches[ j ] ); + } + } + } + + return { + 'grouped': grouped, + 'inputTypes': inputTypes, + 'reorderedMatches': reorderedMatches + }; +} + +/** +* Generates the types.js file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @returns {string} types.js file content +*/ +function generateTypesFile( matches, header ) { + var outputTypes; + var inputTypes; + var inputType; + var grouped; + var result; + var jsOut; + var i; + var j; + + jsOut = header; + jsOut += '/*\n'; + jsOut += '* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation.\n'; + jsOut += '*/\n\n'; + jsOut += '/* eslint-disable array-element-newline */\n\n'; + jsOut += '\'use strict\';\n\n'; + jsOut += '// MODULES //\n\n'; + jsOut += 'var dtypes = require( \'@stdlib/ndarray/dtypes\' );\n\n\n'; + jsOut += '// MAIN //\n\n'; + jsOut += 'var types = [\n'; + + // Group matches by input dtype... + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + inputTypes = result.inputTypes; + + // Generate grouped output with proper formatting and comments... + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + // Add comment with input type and count + jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + + for ( j = 0; j < outputTypes.length; j++ ) { + jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[ j ]; + if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { + jsOut += ',\n'; + } else { + jsOut += '\n'; + } + } + + // Add blank line between input type groups ( except for the last one )... + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\n'; + return jsOut; +} + +/** +* Generates the addon.c file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @param {string} basePkg - base package name +* @returns {string} addon.c file content +*/ +function generateAddonFile( matches, header, basePkg ) { + var uniqueIncludes; + var functionIndex; + var outputTypes; + var includeKey; + var inputType; + var grouped; + var result; + var cOut; + var i; + var j; + + // Generate unique includes... + uniqueIncludes = {}; + for ( i = 0; i < matches.length; i++ ) { + includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); + uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; + } + + // Group matches by input type and reorder by likelihood of use... + result = groupMatchesByInputType( matches ); + grouped = result.grouped; + matches = result.reorderedMatches; + + cOut = header; + cOut += Object.keys( uniqueIncludes ).join( '\n' ) + '\n'; + cOut += '#include "stdlib/ndarray/base/function_object.h"\n'; + cOut += '#include "stdlib/ndarray/base/napi/unary.h"\n'; + cOut += '#include "stdlib/ndarray/base/unary.h"\n'; + cOut += '#include "stdlib/ndarray/dtypes.h"\n'; + cOut += '#include \n\n'; + + // Define interface name with comment... + cOut += '// Define an interface name:\n'; + cOut += 'static const char name[] = "stdlib_ndarray_' + basePkg + '";\n\n'; + + // Define functions array with comments and grouping... + cOut += '// Define a list of ndarray functions:\n'; + cOut += 'static ndarrayFcn functions[] = {\n'; + + // Add functions with type group comments... + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define types array with comments and grouping... + cOut += '// Define the array of input and output ndarray types:\n'; + cOut += 'static int32_t types[] = {\n'; + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define data array with comments and grouping... + cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; + cOut += 'static void *data[] = {\n'; + functionIndex = 0; + for ( i = 0; i < result.inputTypes.length; i++ ) { + inputType = result.inputTypes[ i ]; + outputTypes = grouped[ inputType ]; + + cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; + for ( j = 0; j < outputTypes.length; j++ ) { + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; + functionIndex += 1; + } + cOut += '\n'; + } + cOut += '};\n\n'; + + // Define function object with detailed comments... + cOut += '// Create an ndarray function object:\n'; + cOut += 'static const struct ndarrayFunctionObject obj = {\n'; + cOut += '\t// ndarray function name:\n'; + cOut += '\tname,\n\n'; + cOut += '\t// Number of input ndarrays:\n'; + cOut += '\t1,\n\n'; + cOut += '\t// Number of output ndarrays:\n'; + cOut += '\t1,\n\n'; + cOut += '\t// Total number of ndarray arguments (nin + nout):\n'; + cOut += '\t2,\n\n'; + cOut += '\t// Array containing ndarray functions:\n'; + cOut += '\tfunctions,\n\n'; + cOut += '\t// Number of ndarray functions:\n'; + cOut += '\t' + matches.length + ',\n\n'; + cOut += '\t// Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function:\n'; + cOut += '\ttypes,\n\n'; + cOut += '\t// Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions):\n'; + cOut += '\tdata\n'; + cOut += '};\n\n'; + + // Export the function object... + cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; + return cOut; +} + + +// MAIN // + +/** +* Main execution function. +* +* @private +*/ +function main() { + var basePkg; + var matches; + var header; + var jsOut; + var cOut; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // Extract package information (base package name): + basePkg = basename( join( __dirname, '..' ) ); + + // 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'; + + // Ensure output directories exist: + ensureDir( join( __dirname, '../lib' ) ); + ensureDir( join( __dirname, '../src' ) ); + + /** + * Ensures a directory exists. + * + * @private + * @param {string} d - directory path + */ + function ensureDir( d ) { + try { + writeFileSync( join( d, '.keep' ), '', { + 'encoding': 'utf8' + }); + } catch ( error ) { // eslint-disable-line no-unused-vars + // If the directory does not exist, creating a file will fail. Attempt again by creating a placeholder in parent. + } + } + + // Generate types.js: + jsOut = generateTypesFile( matches, header ); + writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( matches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js new file mode 100644 index 000000000000..3c59f722a692 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var promotionRules = require( '@stdlib/ndarray/promotion-rules' ); +var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var format = require( '@stdlib/string/format' ); +var safeCasts = require( '@stdlib/ndarray/safe-casts' ); +var generateTable = require( './table.js' ); +var config = require( './config.js' ); + + +// FUNCTIONS // + +/** +* Returns an array of matches with valid combinations. +* +* @private +* @param {Array} matches - array of all combinations +* @returns {Array} array of matches with valid combinations +*/ +function getValidCombinations( matches ) { + var validMatches = []; + var validDtypes; + var i; + + for ( i = 0; i < matches.length; i++ ) { + // Skip complex32, float16, uint8c and int16 as we don't support them yet... + if ( matches[ i ][ 0 ] === 'complex32' || + matches[ i ][ 0 ] === 'int16' || + matches[ i ][ 0 ] === 'float16' || + matches[ i ][ 0 ] === 'uint8c' || + matches[ i ][ 1 ] === 'complex32' || + matches[ i ][ 1 ] === 'int16'|| + matches[ i ][ 1 ] === 'float16' || + matches[ i ][ 1 ] === 'uint8c' ) { + continue; + } + + // Accept exact matches (no promotion required)... + if ( matches[ i ][ 3 ] === false ) { + validMatches.push( matches[ i ] ); + continue; + } + + // For promoted cases, check if the dtypes are valid for the current match... + validDtypes = safeCasts( matches[ i ][ 5 ] ); + if ( validDtypes && validDtypes.includes( matches[ i ][ 1 ] ) && promotionRules( matches[ i ][ 0 ], matches[ i ][ 1 ] ) === matches[ i ][ 4 ] ) { // eslint-disable-line max-len + validMatches.push( matches[ i ] ); + } + } + + return validMatches; +} + + +// MAIN // + +/** +* Generate dtype pairs for sqrt, match them with appropriate packages, and resolve C function names and loop kernels. +* +* ## Note +* +* - The function generates an array of matches, where each match is an array of the following format: +* +* ```text +* ---------------------------------------------------------------------------------------------------------------------------------------- +* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | +* ---------------------------------------------------------------------------------------------------------------------------------------- +* | | | | | | | | +* | | | | | | | | +* V V | V V V | V +* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_d_d' +* V V +* '@stdlib/math/base/special/sqrtf' 'stdlib_base_sqrtf' +* ``` +* +* @private +* @returns {Array} matches table containing dtype pairs and their corresponding package information +*/ +function main() { + var cFuncName; + var matches = []; + var kernel; + var table; + var pairs; + var pdt; + var row; + var idt; + var odt; + var dt; + var i; + var j; + + /* + Generate the table. For example, we'll have: + Table: [ + [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf' ], + [ 'float64', 'float64', '@stdlib/math/base/special/sqrt' ] + ] + */ + table = generateTable(); + + /* + Resolve list of input dtypes. For example, we'll have: + idt = [ + 'complex32', + 'complex64', + 'complex128', + 'float16', + 'float32', + 'float64', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ] + */ + idt = dtypes( config.input_dtypes ); + + /* + Resolve the list of output dtypes. For example, we'll have: + odt = [ + 'complex32', + 'complex128', + 'complex64', + 'float16', + 'float64', + 'float32', + 'int32', + 'int16', + 'int8', + 'uint32', + 'uint16', + 'uint8', + 'uint8c' + ] + */ + odt = dtypes( config.output_dtypes ); + + /* + Generate the input-output dtype pairs. For example, we'll have: + pairs = [ [ 'int8', 'float32' ], [ 'int8', 'float64' ], [ 'float32', 'float32' ], [ 'float32', 'float64' ], ... ] + */ + pairs = cartesianProduct( idt, odt ); + + // Match-make each dtype pair with a stdlib package... + for ( i = 0; i < pairs.length; i++ ) { + // Now let dt = [ 'uint32', 'float32' ]... + dt = pairs[ i ]; + + for ( j = 0; j < table.length; j++ ) { + row = table[ j ]; + + // Resolve the scalar math kernel C function name from package path ( e.g., '@stdlib/math/base/special/sqrtf' -> 'sqrtf' --> 'stdlib_base_sqrtf' ): + cFuncName = 'stdlib_base_' + row[ 2 ].split( '/' ).pop(); + + // Firstly, look for exact matches. For example, let row = [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf' ]... + if ( row[ 0 ] === dt[ 0 ] && row[ 1 ] === dt[ 1 ] ) { + // Resolve the loop kernel... + kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, cFuncName, kernel ] ); // eslint-disable-line max-len + break; + } + + // Then check for package to which the dtype pair can promote. For example, pdt = promotionRules( 'uint32', 'float32' ) = 'float64': + pdt = promotionRules( dt[ 0 ], row[ 0 ] ); + if ( pdt ) { + // Check if the package in the present row supports the promoted dtypes... + if ( row[ 0 ] === pdt && row[ 1 ] === pdt ) { + // Resolve the loop kernel... + kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( dt[ 0 ] ), dtypeChar( dt[ 1 ] ), dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); + matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, cFuncName, kernel ] ); // eslint-disable-line max-len + } + } + } + } + + return getValidCombinations( matches ); +} + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js new file mode 100644 index 000000000000..1ccb269a5b56 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js @@ -0,0 +1,219 @@ +/* eslint-disable stdlib/jsdoc-no-shortcut-reference-link, stdlib/jsdoc-no-undefined-references, stdlib/jsdoc-no-paragraph-content-indent */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var path = require( 'path' ); +var ls = require( '@stdlib/_tools/pkgs/names' ).sync; +var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var readJSON = require( '@stdlib/fs/read-json' ).sync; + + +// VARIABLES // + +var pathString = '@stdlib/math/base/special'; +var basePkg = 'sqrt'; +var ROOT_DIR = rootDir(); +var opts = { + 'dir': './' + pathString +}; +var jsonOpts = { + 'encoding': 'utf8' +}; + + +// FUNCTIONS // + +/** +* Returns a list of packages in `math/base/special/*` which are relevant for the current package. +* +* ## Note +* +* For now, we are trying the following four combinations. So, let us say, we are looking for the `sin` package, then we will try to find: +* +* - `@stdlib/math/base/special/sinf` +* - `@stdlib/math/base/special/sin` +* - `@stdlib/math/base/special/csinf` +* - `@stdlib/math/base/special/csin` +* +* Now since as of now, we don't have `@stdlib/math/base/special/csin` and `@stdlib/math/base/special/csinf`, we will only get the first two packages. +* +* @private +* @returns {Array} list of relevant packages +* +* @example +* var basePkg = 'sqrt'; +* +* var pkgs = getRelevantPackages(); +* // returns [ '@stdlib/math/base/special/sqrtf', '@stdlib/math/base/special/sqrt' ] +*/ +function getRelevantPackages() { + var combinations; + var names; + var pkgs; + var pkg; + var i; + var j; + + pkgs = []; + + // Initializing all possible combinations that we can try, in the required order: + combinations = [ + path.join( pathString, basePkg + 'f' ), + path.join( pathString, basePkg ), + path.join( pathString, 'c' + basePkg + 'f' ), + path.join( pathString, 'c' + basePkg ) + ]; + + // Get the list of all packages in `math/base/special/*`: + names = ls( opts ); + + // Filter the list of packages to only include those which match the combinations: + for ( i = 0; i < combinations.length; i++ ) { + pkg = combinations[ i ]; + for ( j = 0; j < names.length; j++ ) { + if ( names[ j ] === pkg ) { + pkgs.push( pkg ); + } + } + } + + return pkgs; +} + +/** +* Returns the input and output dtypes for a given package. +* +* ## Note +* +* - Currently, this function only supports those packages which expect a single input and return a single output. +* - In order to support packages with multiple inputs, we'll need to restructure our table and calculate accordingly. +* - As of now, each array in our table looks like this: +* +* [ input_dtype, output_dtype, package_name ] +* For example: [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] +* +* This is fine for single input & single output functions. But, for functions such as `pow`, which expect two input values, we can have: +* +* [ number_of_inputs, input_dtype_1, input_dtype_2, ... input_dtype_n, output_dtype, package_name ] +* [ 2, 'float64', 'float64', `float64`, '@stdlib/math/base/special/pow' ] +* +* @private +* @param {string} alias - package name +* @returns {Array} input and output dtypes +* +* @example +* var dtypes = getDtypes( 'acos' ); +* // returns [ 'float64', 'float64' ] +* +* @example +* var dtypes = getDtypes( 'acosf' ); +* // returns [ 'float32', 'float32' ] +*/ +function getDtypes( alias ) { + var outputDtype; + var inputDtype; + var path; + var json; + var pkg; + var out; + var o; + + // Resolve the package: + pkg = findPkgs({ + 'dir': ROOT_DIR, + 'pattern': '**/math/base/special/'+ alias +'/package.json' + }); + + if ( pkg.length === 0 ) { + return []; + } + + // Get the meta data: + path = resolve( ROOT_DIR, pkg[ 0 ] ); + json = readJSON( resolve( path, 'package.json' ), jsonOpts ); + o = json.__stdlib__; // eslint-disable-line no-underscore-dangle + if ( o && o.scaffold ) { + out = o.scaffold; + } + + // Fallback when __stdlib__.scaffold is missing in package.json: + if ( !out ) { + // Heuristics: float suffix means float32 IO, otherwise float64 IO for sqrt... + if ( alias.charAt( alias.length-1 ) === 'f' ) { + return [ 'float32', 'float32' ]; + } + return [ 'float64', 'float64' ]; + } + + // NOTE: We might need to reconsider the below logic if there are two or more inputs... + inputDtype = out.parameters[ 0 ].type.dtype; + outputDtype = out.returns.type.dtype; + + return [ inputDtype, outputDtype ]; +} + + +// MAIN // + +/** +* Generate the function table. +* +* @returns {Array} function table +* +* @example +* var basePkg = 'sqrt'; +* +* var table = generateTable(); +* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf' ], [ 'float64', 'float64', '@stdlib/math/base/special/sqrt' ] ] +*/ +function generateTable() { + var aliasName; + var dtypes; + var table; + var pkgs; + var pkg; + var i; + + // Get the list of relevant packages for the given base package: + pkgs = getRelevantPackages(); + + // Initialize the table: + table = []; + + // Loop over the packages and get the input and output dtypes: + for ( i = 0; i < pkgs.length; i++ ) { + // Extract the alias name out of the package path: + pkg = pkgs[ i ]; + aliasName = pkg.replace( pathString + '/', '' ); + dtypes = getDtypes( aliasName ); + table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkg ] ); + } + + return table; +} + + +// EXPORTS // + +module.exports = generateTable; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c new file mode 100644 index 000000000000..f25e473ea34e --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c @@ -0,0 +1,133 @@ +/** +* @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 (1) + stdlib_ndarray_f_d_as_d_d, + + // int32 (1) + stdlib_ndarray_i_d_as_d_d, + + // int8 (2) + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_d_as_d_d, + + // uint32 (1) + stdlib_ndarray_u_d_as_d_d, + + // uint16 (2) + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_d_as_d_d, + + // uint8 (2) + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_d_as_d_d, + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // float32 (1) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + + // int32 (1) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + + // int8 (2) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + + // uint32 (1) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + + // uint16 (2) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + + // uint8 (2) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // float32 (1) + (void *)stdlib_base_sqrt, + + // int32 (1) + (void *)stdlib_base_sqrt, + + // int8 (2) + (void *)stdlib_base_sqrtf, + (void *)stdlib_base_sqrt, + + // uint32 (1) + (void *)stdlib_base_sqrt, + + // uint16 (2) + (void *)stdlib_base_sqrtf, + (void *)stdlib_base_sqrt, + + // uint8 (2) + (void *)stdlib_base_sqrtf, + (void *)stdlib_base_sqrt, + +}; + +// 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: + 9, + + // 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 ) From 0ddf2f39f8590019344ca80afd4e7d4111a1042a Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 9 Aug 2025 01:02:53 +0530 Subject: [PATCH 11/31] refactor: try newer approach --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/sqrt/package.json | 77 ++++- .../math/base/special/sqrtf/package.json | 96 +++++- .../@stdlib/math/special/notes.txt | 127 -------- .../math/special/scripts/dtype_hierarchy.js | 43 +++ .../special/scripts/function_database.json | 3 +- .../@stdlib/math/special/sqrt/lib/types.js | 19 +- .../@stdlib/math/special/sqrt/package.json | 57 ++++ .../math/special/sqrt/scripts/config.js | 9 +- .../special/sqrt/scripts/generate_files.js | 110 +------ .../math/special/sqrt/scripts/get_dtypes.js | 95 ++++++ .../sqrt/scripts/map_to_scalar_kernel.js | 178 ++++++++++ .../math/special/sqrt/scripts/script.js | 304 ++++++++++-------- .../math/special/sqrt/scripts/table.js | 219 ------------- .../@stdlib/math/special/sqrt/src/addon.c | 52 ++- .../base/unary/data/function_list.json | 147 +++++++++ 15 files changed, 927 insertions(+), 609 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/notes.txt create mode 100644 lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/package.json create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js delete mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js create mode 100644 lib/node_modules/@stdlib/ndarray/base/unary/data/function_list.json 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..2e48013743c3 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,80 @@ "root", "power", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "sqrt", + "alias": "sqrt", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json index 70c0cea65789..a744b64da3e5 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json @@ -1,7 +1,7 @@ { - "name": "@stdlib/math/base/special/sqrtf", + "name": "@stdlib/math/base/special/cceil", "version": "0.0.0", - "description": "Compute the principal square root of a single-precision floating-point number.", + "description": "Round each component of a double-precision complex floating-point number toward positive infinity.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -56,12 +56,90 @@ "stdmath", "mathematics", "math", - "math.sqrtf", - "sqrtf", - "principal", - "square", - "root", - "power", + "math.ceil", + "ceil", + "cceil", + "round", + "integer", + "nearest", + "value", + "complex", + "cmplx", "number" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "sqrtf", + "alias": "sqrtf", + "pkg_desc": "round toward positive infinity", + "desc": "rounds toward positive infinity", + "short_desc": "ceil value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "absolute value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float32" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [ + "math.abs" + ] + } + } } diff --git a/lib/node_modules/@stdlib/math/special/notes.txt b/lib/node_modules/@stdlib/math/special/notes.txt deleted file mode 100644 index 5f5424617c8a..000000000000 --- a/lib/node_modules/@stdlib/math/special/notes.txt +++ /dev/null @@ -1,127 +0,0 @@ -// math/special/scripts/function_database.json - -```json -{ - "abs": { - // ... - }, - ... - "ceil": { - "input_dtypes": "numeric_and_generic", - "output_dtypes": "numeric_and_generic", - "output_policy": "same", - - "scalar_kernels": { - // "input_type": "scalar_kernel" - - "float64": "@stdlib/math/base/special/ceil", - "float32": "@stdlib/math/base/special/ceilf", - "complex128": "@stdlib/math/base/special/cceil", - "complex64": "@stdlib/math/base/special/cceilf", - "uint8": "@stdlib/number/uint8/base/identity", - "uint16" "@stdlib/number/uint16/base/identity", - ... - } - }, - ... - "sqrt": { - "input_dtypes": "real_and_generic", - "output_dtypes": "real_floating_point", - "output_policy": "real_floating_point", - "scalar_kernels": { - "float64": "@stdlib/math/base/special/sqrt", - "float32": "@stdlib/math/base/special/sqrtf" - } - } -} -``` - - -// Script.js - -```javascript -var objectKeys = require( '@stdlib/utils/keys' ); -var db = require( '@stdlib/math/special/scripts/function_database.json' ); - -// Get the list of dtypes we'd like to support: -var idt = dtypes( config.input_dtypes ); -var odt = dtypes( config.output_dtypes ); - -// Compute the Cartesian product of input and output dtypes: -var iopairs = cartesianProduct( idt, sdt ); - -// Filter based on "mostly safe" casts: -iopairs = filter( iopairs ); // => only those dtype pairs which make "sense" and are mostly safe casts - -// Get the list of dtypes with scalar math kernels: -var obj = db[ 'ceil' ]; // => {...} -var sdt = objectKeys( obj.scalar_kernels ); // => [ 'float64', 'float32', 'int8', 'uint8', 'int16', 'uint16', ... ] - -// Then map each pair to a scalar math kernel based on the output dtype: -var scalarKernels = getScalarKernels( iopairs ); // => [ '@stdlib/number/int8/base/identity', '@stdlib/number/int16/base/identity', ... ] - -// Resolve the input-output dtypes for each scalar math kernel: -var iodt = resolveInOutDtypes( scalarKernels ); // => read the package.json scaffold meta data -/* -* Prioritization: -* -* 1. scalar kernels having a signature which exactly matches the iopair -* 2. scalar kernels which have a signature exactly matching (out_dtype, out_dtype) -* -* Example: -* -* sqrt: -* - (float32,float32) => @stdlib/math/base/special/sqrtf -* - (int8,float32) => @stdlib/math/base/special/sqrtf -* - (float32,float64) => @stdlib/math/base/special/sqrt -* -* ceil: -* - (float32,float32) => @stdlib/math/base/special/ceilf -* - (int8,float32) => @stdlib/math/base/special/ceilf -*/ - -// Map dtype pairs to ndarray functions: -int8,float32 => s,f => stdlib_ndarray_s_f_as_f_f( stdlib_base_sqrtf ) -int8,float64 => s,d => stdlib_ndarray_s_d_as_d_d( stdlib_base_sqrt ) -int16,float32 => k,f => stdlib_ndarray_k_f_as_f_f( stdlib_base_sqrtf ) -int16,float64 => k,d => stdlib_ndarray_k_d_as_d_d( stdlib_base_sqrt ) -... -float32,float32 => stdlib_ndarray_f_f( stdlib_base_sqrtf ) -float32,float64 => stdlib_ndarray_f_d_as_d_d( stdlib_base_sqrt ) -float64,float32 => stdlib_ndarray_d_f( stdlib_base_sqrt ) -``` - - -[ 'int8', 'int16' ] - -- number/int8/base/identity => stdlib_ndarray_s_k => stdlib_ndarray_s_k_as_s_s -- number/int16/base/identity => stdlib_ndarray_s_k_as_k_k - - CHOOSE this one, as it makes more sense to upcast the input, than upcast the output after the operation, in order to perform the operation at higher precision. - -[ 'float32', 'float64' ] - -- stdlib_ndarray_f_d_as_d_d - -[ 'float64', 'float32' ] - -- stdlib_ndarray_d_f_as_f_f -- stdlib_ndarray_d_f => stdlib_ndarray_d_f_as_d_d - - CHOOSE this one, as it allows us to compute in higher precision and then downcast the output after the operation, in order to perform the operation at higher precision. - -Comments: - -- One thing which would be useful to have in `ndarray/base/unary` is a `data/function_list.json`, which can be filtered during scalar math kernel matchmaking with a ndarray function... - -``` -[ - "stdlib_ndarray_f_f", - ... - "stdlib_ndarray_b_k", - "stdlib_ndarray_b_k_as_k_k", - ... - "stdlib_ndarray_d_f", - "stdlib_ndarray_d_f_as_f_f" -] -``` - -To break ties (i.e., multiple matches for an input-output dtype pair), always compute at a higher precision. \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js b/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js new file mode 100644 index 000000000000..90799c47f3ac --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Dtype precision hierarchy. +* +* @type {Object} +*/ +var DTYPE_HIERARCHY = { + 'int8': 1, + 'uint8': 1, + 'int16': 2, + 'uint16': 2, + 'int32': 3, + 'uint32': 3, + 'float32': 4, + 'float64': 5, + 'generic': 6 +}; + + +// EXPORTS // + +module.exports = DTYPE_HIERARCHY; diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index 5250774f1ee3..de123a5ccf51 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -4,8 +4,9 @@ "output_dtypes": "real_floating_point", "output_policy": "real_floating_point", "scalar_kernels": { + "float32": "@stdlib/math/base/special/sqrtf", "float64": "@stdlib/math/base/special/sqrt", - "float32": "@stdlib/math/base/special/sqrtf" + "generic": "@stdlib/math/base/special/sqrt" } } } diff --git a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js index d7398ba52f1a..ba8b4897156e 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js @@ -17,9 +17,6 @@ */ /* This is a generated file. Do not edit directly. */ -/* -* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation. -*/ /* eslint-disable array-element-newline */ @@ -33,9 +30,17 @@ var dtypes = require( '@stdlib/ndarray/dtypes' ); // MAIN // var types = [ - // float32 (1) + // float32 (2) + dtypes.float32, dtypes.float32, dtypes.float32, dtypes.float64, + // float64 (1) + dtypes.float64, dtypes.float64, + + // int16 (2) + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.float64, + // int32 (1) dtypes.int32, dtypes.float64, @@ -43,13 +48,13 @@ var types = [ dtypes.int8, dtypes.float32, dtypes.int8, dtypes.float64, - // uint32 (1) - dtypes.uint32, dtypes.float64, - // uint16 (2) dtypes.uint16, dtypes.float32, dtypes.uint16, dtypes.float64, + // uint32 (1) + dtypes.uint32, dtypes.float64, + // uint8 (2) dtypes.uint8, dtypes.float32, dtypes.uint8, dtypes.float64 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/config.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js index ae75f3c989e3..13d8ee48102b 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js @@ -20,9 +20,16 @@ // MAIN // +/** +* Configuration object. +* +* @private +* @type {Object} +*/ var config = { 'input_dtypes': 'real_and_generic', - 'output_dtypes': 'real_floating_point' + 'output_dtypes': 'real_floating_point', + 'excluded_dtypes': [ 'float16', 'uint8c' ] }; 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 index 3ff7c5b9e701..7828f33b516f 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -21,63 +21,21 @@ // MODULES // var join = require( 'path' ).join; -var basename = require( 'path' ).basename; var writeFileSync = require( '@stdlib/fs/write-file' ).sync; var licenseHeader = require( '@stdlib/_tools/licenses/header' ); var currentYear = require( '@stdlib/time/current-year' ); var generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); // FUNCTIONS // /** -* Returns an index for ordering input types by approximate likelihood of use. -* -* @private -* @param {string} dtype - input dtype -* @returns {number} order index -*/ -function inputTypeOrderIndex( dtype ) { - // Prefer float64, then float32, then generic, then signed ints, then unsigned ints, then others... - switch ( dtype ) { // eslint-disable-line default-case - case 'float64': - return 0; - case 'float32': - return 1; - case 'generic': - return 2; - case 'int32': - return 3; - case 'int16': - return 4; - case 'int8': - return 5; - case 'uint32': - return 6; - case 'uint16': - return 7; - case 'uint8': - return 8; - case 'uint8c': - return 9; - case 'float16': - return 10; - case 'complex128': - return 11; - case 'complex64': - return 12; - case 'complex32': - return 13; - } - return 99; -} - -/** -* Groups matches by input data type and reorders by likelihood of use. +* Groups matches by input data type. * * @private * @param {Array} matches - array of match entries -* @returns {Object} object containing grouped matches, ordered input types array, and reordered matches +* @returns {Object} object containing grouped matches, input types array, and reordered matches */ function groupMatchesByInputType( matches ) { var reorderedMatches = []; @@ -96,21 +54,6 @@ function groupMatchesByInputType( matches ) { grouped[ inputType ].push( matches[ i ][ 1 ] ); } - // Order input types by preferred usage: - inputTypes.sort( compare ); - - /** - * Comparison function for input dtype ordering. - * - * @private - * @param {string} a - left dtype - * @param {string} b - right dtype - * @returns {number} comparison result - */ - function compare( a, b ) { - return inputTypeOrderIndex( a ) - inputTypeOrderIndex( b ); - } - for ( i = 0; i < inputTypes.length; i++ ) { inputType = inputTypes[ i ]; for ( j = 0; j < matches.length; j++ ) { @@ -146,9 +89,7 @@ function generateTypesFile( matches, header ) { var j; jsOut = header; - jsOut += '/*\n'; - jsOut += '* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation.\n'; - jsOut += '*/\n\n'; + jsOut += '\n'; jsOut += '/* eslint-disable array-element-newline */\n\n'; jsOut += '\'use strict\';\n\n'; jsOut += '// MODULES //\n\n'; @@ -161,14 +102,10 @@ function generateTypesFile( matches, header ) { grouped = result.grouped; inputTypes = result.inputTypes; - // Generate grouped output with proper formatting and comments... for ( i = 0; i < inputTypes.length; i++ ) { inputType = inputTypes[ i ]; outputTypes = grouped[ inputType ]; - - // Add comment with input type and count jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; - for ( j = 0; j < outputTypes.length; j++ ) { jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[ j ]; if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { @@ -218,7 +155,7 @@ function generateAddonFile( matches, header, basePkg ) { uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; } - // Group matches by input type and reorder by likelihood of use... + // Group matches by input type... result = groupMatchesByInputType( matches ); grouped = result.grouped; matches = result.reorderedMatches; @@ -230,16 +167,11 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '#include "stdlib/ndarray/base/unary.h"\n'; cOut += '#include "stdlib/ndarray/dtypes.h"\n'; cOut += '#include \n\n'; - - // Define interface name with comment... cOut += '// Define an interface name:\n'; cOut += 'static const char name[] = "stdlib_ndarray_' + basePkg + '";\n\n'; - - // Define functions array with comments and grouping... cOut += '// Define a list of ndarray functions:\n'; cOut += 'static ndarrayFcn functions[] = {\n'; - // Add functions with type group comments... functionIndex = 0; for ( i = 0; i < result.inputTypes.length; i++ ) { inputType = result.inputTypes[ i ]; @@ -253,8 +185,6 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\n'; } cOut += '};\n\n'; - - // Define types array with comments and grouping... cOut += '// Define the array of input and output ndarray types:\n'; cOut += 'static int32_t types[] = {\n'; functionIndex = 0; @@ -270,8 +200,6 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\n'; } cOut += '};\n\n'; - - // Define data array with comments and grouping... cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; cOut += 'static void *data[] = {\n'; functionIndex = 0; @@ -287,8 +215,6 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\n'; } cOut += '};\n\n'; - - // Define function object with detailed comments... cOut += '// Create an ndarray function object:\n'; cOut += 'static const struct ndarrayFunctionObject obj = {\n'; cOut += '\t// ndarray function name:\n'; @@ -308,8 +234,6 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions):\n'; cOut += '\tdata\n'; cOut += '};\n\n'; - - // Export the function object... cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; return cOut; } @@ -332,8 +256,8 @@ function main() { // Generate and filter matches table: matches = generateMatchesTable(); - // Extract package information (base package name): - basePkg = basename( join( __dirname, '..' ) ); + // Extract package information: + basePkg = pkg.name.split( '/' ).pop(); // Generate license header: header = licenseHeader( 'Apache-2.0', 'js', { @@ -342,26 +266,6 @@ function main() { }); header += '\n/* This is a generated file. Do not edit directly. */\n'; - // Ensure output directories exist: - ensureDir( join( __dirname, '../lib' ) ); - ensureDir( join( __dirname, '../src' ) ); - - /** - * Ensures a directory exists. - * - * @private - * @param {string} d - directory path - */ - function ensureDir( d ) { - try { - writeFileSync( join( d, '.keep' ), '', { - 'encoding': 'utf8' - }); - } catch ( error ) { // eslint-disable-line no-unused-vars - // If the directory does not exist, creating a file will fail. Attempt again by creating a placeholder in parent. - } - } - // Generate types.js: jsOut = generateTypesFile( matches, header ); writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js new file mode 100644 index 000000000000..f961d1011401 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js @@ -0,0 +1,95 @@ +/** +* @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 findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var readJSON = require( '@stdlib/fs/read-json' ).sync; + + +// VARIABLES // + +var ROOT_DIR = rootDir(); +var jsonOpts = { + 'encoding': 'utf8' +}; + + +// FUNCTIONS // + +/** +* Returns the input and output dtypes for a given package by reading scaffold metadata. +* +* @private +* @param {string} pkgPath - package path +* @returns {Array} input and output dtypes +* +* @example +* var dtypes = getDtypes( '@stdlib/math/base/special/sqrt' ); +* // returns [ 'float64', 'float64' ] +* +* @example +* var dtypes = getDtypes( '@stdlib/math/base/special/sqrtf' ); +* // returns [ 'float32', 'float32' ] +*/ +function getDtypes( pkgPath ) { + var outputDtype; + var inputDtype; + var aliasName; + var path; + var json; + var pkg; + var out; + var o; + + // Extract alias name from package path: + aliasName = pkgPath.split( '/' ).pop(); + + // Find the package: + pkg = findPkgs({ + 'dir': ROOT_DIR, + 'pattern': '**/math/base/special/' + aliasName + '/package.json' // Currently we are looking only in `math/base/special/` + }); + + if ( pkg.length === 0 ) { + return []; + } + + // Get the metadata: + path = resolve( ROOT_DIR, pkg[ 0 ] ); + json = readJSON( resolve( path, 'package.json' ), jsonOpts ); + o = json.__stdlib__; // eslint-disable-line no-underscore-dangle + if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { + out = o.scaffold; + } + + // Extract input and output dtypes: + inputDtype = out.parameters[ 0 ].type.dtype; + outputDtype = out.returns.type.dtype; + + return [ inputDtype, outputDtype ]; +} + + +// EXPORTS // + +module.exports = getDtypes; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js new file mode 100644 index 000000000000..74a3929877f2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js @@ -0,0 +1,178 @@ +/** +* @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 dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var format = require( '@stdlib/string/format' ); +var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); + + +// FUNCTIONS // + +/** +* Maps dtype pairs to appropriate scalar functions. +* +* ## Note +* +* - The function returns an array with the following structure: +* +* ```text +* --------------------------------------------------------------------------------- +* Array: | kernel | cFunc | ndarrayKernel | match | +* --------------------------------------------------------------------------------- +* | | | | +* | | | | +* V V V V +* Example: '@stdlib/math/base/ 'stdlib_base_sqrt' 'stdlib_ndarray_ ['float64', +* special/sqrt' f_d_as_d_d' 'float64'] +* ``` +* +* @private +* @param {Array} iopair - input-output dtype pair +* @param {Array} iodt - array of available scalar kernel dtypes +* @param {Object} scalarKernels - scalar kernels object +* @returns {Array} mapping result +* +* @example +* var iopair = [ 'float32', 'float64' ]; +* var iodt = [ +* [ 'float32', 'float32' ], +* [ 'float64', 'float64' ] +* ]; +* var scalarKernels = { +* 'float32': '@stdlib/math/base/special/sqrtf', +* 'float64': '@stdlib/math/base/special/sqrt' +* }; +* +* var result = mapToScalarKernel( iopair, iodt, scalarKernels ); +* // returns [ '@stdlib/math/base/special/sqrt', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d', [ 'float64', 'float64' ] ] +*/ +function mapToScalarKernel( iopair, iodt, scalarKernels ) { + var ndarrayKernel; + var precision1; + var precision2; + var matchChar1; + var matchChar2; + var outputChar; + var cFuncName; + var inputChar; + var kernel; + var match; + var dtype; + var i; + + inputChar = dtypeChar( iopair[ 0 ] ); + outputChar = dtypeChar( iopair[ 1 ] ); + + // For generic input, always use highest precision kernel + if ( iopair[ 0 ] === 'generic' ) { + kernel = scalarKernels.float64 || scalarKernels.generic; + cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); + ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_d_d', inputChar, outputChar ); + + return [ kernel, cFuncName, ndarrayKernel, [ 'float64', 'float64' ] ]; + } + + // Priority 1: Look for exact match in available scalar kernel dtypes: + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 0 ] && + iodt[ i ][ 1 ] === iopair[ 1 ] ) { + match = iodt[ i ]; + break; + } + } + + // Priority 2: Look for higher precision matches to break ties: + if ( !match ) { + /* + * Always prefer computing at higher precision: + * - For cases like ['float32', 'float64'], prefer computing at float64: f_d_as_d_d + * - For cases like ['int8', 'float32'], prefer computing at float32: s_f_as_f_f + */ + + // Get higher precision dtype using hierarchy table: + if ( iopair[ 0 ] === iopair[ 1 ] ) { + dtype = iopair[ 0 ]; + } else { + precision1 = DTYPE_HIERARCHY[ iopair[ 0 ] ] || 0; + precision2 = DTYPE_HIERARCHY[ iopair[ 1 ] ] || 0; + dtype = ( precision2 > precision1 ) ? iopair[ 1 ] : iopair[ 0 ]; + } + + // First try: Look for (higher_precision_dtype, higher_precision_dtype)... + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === dtype && iodt[ i ][ 1 ] === dtype ) { + match = iodt[ i ]; + break; + } + } + + // Second try: Look for (input_dtype, input_dtype) if higher precision not found... + if ( !match ) { + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 0 ] && + iodt[ i ][ 1 ] === iopair[ 0 ] ) { + match = iodt[ i ]; + break; + } + } + } + + // Third try: Look for (output_dtype, output_dtype)... + if ( !match ) { + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 1 ] && + iodt[ i ][ 1 ] === iopair[ 1 ] ) { + match = iodt[ i ]; + break; + } + } + } + } + + if ( match ) { + // Get the scalar kernel package + kernel = scalarKernels[ match[ 1 ] ]; + + // Generate C function name + cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); + + // Generate ndarray kernel name + if ( match[ 0 ] === iopair[ 0 ] && match[ 1 ] === iopair[ 1 ] ) { + // Exact match + ndarrayKernel = format( 'stdlib_ndarray_%s_%s', inputChar, outputChar ); + } else { + // Promotion case + matchChar1 = dtypeChar( match[ 0 ] ); + matchChar2 = dtypeChar( match[ 1 ] ); + ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', inputChar, outputChar, matchChar1, matchChar2 ); + } + + return [ kernel, cFuncName, ndarrayKernel, match ]; + } + + return []; +} + + +// EXPORTS // + +module.exports = mapToScalarKernel; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js index 3c59f722a692..99d479a116d9 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -20,64 +20,28 @@ // MODULES // +var basename = require( 'path' ).basename; +var join = require( 'path' ).join; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); var cartesianProduct = require( '@stdlib/array/cartesian-product' ); -var promotionRules = require( '@stdlib/ndarray/promotion-rules' ); -var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); -var format = require( '@stdlib/string/format' ); -var safeCasts = require( '@stdlib/ndarray/safe-casts' ); -var generateTable = require( './table.js' ); +var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); +var mapToScalarKernel = require( './map_to_scalar_kernel.js' ); +var getDtypes = require( './get_dtypes.js' ); var config = require( './config.js' ); -// FUNCTIONS // +// VARIABLES // -/** -* Returns an array of matches with valid combinations. -* -* @private -* @param {Array} matches - array of all combinations -* @returns {Array} array of matches with valid combinations -*/ -function getValidCombinations( matches ) { - var validMatches = []; - var validDtypes; - var i; - - for ( i = 0; i < matches.length; i++ ) { - // Skip complex32, float16, uint8c and int16 as we don't support them yet... - if ( matches[ i ][ 0 ] === 'complex32' || - matches[ i ][ 0 ] === 'int16' || - matches[ i ][ 0 ] === 'float16' || - matches[ i ][ 0 ] === 'uint8c' || - matches[ i ][ 1 ] === 'complex32' || - matches[ i ][ 1 ] === 'int16'|| - matches[ i ][ 1 ] === 'float16' || - matches[ i ][ 1 ] === 'uint8c' ) { - continue; - } - - // Accept exact matches (no promotion required)... - if ( matches[ i ][ 3 ] === false ) { - validMatches.push( matches[ i ] ); - continue; - } - - // For promoted cases, check if the dtypes are valid for the current match... - validDtypes = safeCasts( matches[ i ][ 5 ] ); - if ( validDtypes && validDtypes.includes( matches[ i ][ 1 ] ) && promotionRules( matches[ i ][ 0 ], matches[ i ][ 1 ] ) === matches[ i ][ 4 ] ) { // eslint-disable-line max-len - validMatches.push( matches[ i ] ); - } - } - - return validMatches; -} +var DTYPES = {}; +var basePkg = basename( join( __dirname, '..' ) ); // MAIN // /** -* Generate dtype pairs for sqrt, match them with appropriate packages, and resolve C function names and loop kernels. +* Main execution sequence. * * ## Note * @@ -90,116 +54,202 @@ function getValidCombinations( matches ) { * | | | | | | | | * | | | | | | | | * V V | V V V | V -* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_d_d' +* Example: 'float32' 'float64' | true 'float64' 'float64' | 'stdlib_ndarray_f_d_as_d_d' * V V -* '@stdlib/math/base/special/sqrtf' 'stdlib_base_sqrtf' +* '@stdlib/math/base/special/sqrt' 'stdlib_base_sqrt' * ``` * * @private -* @returns {Array} matches table containing dtype pairs and their corresponding package information +* @returns {Array} array of mappings */ function main() { - var cFuncName; - var matches = []; - var kernel; - var table; - var pairs; - var pdt; - var row; - var idt; + var outputPrecision; + var needsPromotion; + var inputPrecision; + var outputDtype; + var inputDtype; + var filtered = []; + var mappings; + var kernels = []; + var iopairs; + var mapping; + var iodt = []; + var seen = {}; var odt; + var idt; + var out; + var obj; var dt; + var k; var i; - var j; + + // Resolve list of input dtypes: + idt = dtypes( config.input_dtypes ); + filtered = []; + for ( i = 0; i < idt.length; i++ ) { + if ( config.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { // Exclude irrelevant dtypes + filtered.push( idt[ i ] ); + } + } + idt = filtered; /* - Generate the table. For example, we'll have: - Table: [ - [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf' ], - [ 'float64', 'float64', '@stdlib/math/base/special/sqrt' ] - ] + For example, we'll have: + idt = [ + 'float32', + 'float64', + 'int16', + 'int32', + 'int8', + 'uint16', + 'uint32', + 'uint8', + 'generic' + ] */ - table = generateTable(); + + // Resolve the list of output dtypes: + odt = dtypes( config.output_dtypes ); + filtered = []; + for ( i = 0; i < odt.length; i++ ) { + if ( config.excluded_dtypes.indexOf( odt[ i ] ) === -1 ) { // Exclude irrelevant dtypes + filtered.push( odt[ i ] ); + } + } + odt = filtered; /* - Resolve list of input dtypes. For example, we'll have: - idt = [ - 'complex32', - 'complex64', - 'complex128', - 'float16', - 'float32', - 'float64', - 'int32', - 'int16', - 'int8', - 'uint32', - 'uint16', - 'uint8', - 'uint8c' - ] + For example, we'll have: + odt = [ + 'float32', + 'float64' + ] */ - idt = dtypes( config.input_dtypes ); + + // Computing the Cartesian product of input and output dtypes: + iopairs = cartesianProduct( idt, odt ); /* - Resolve the list of output dtypes. For example, we'll have: - odt = [ - 'complex32', - 'complex128', - 'complex64', - 'float16', - 'float64', - 'float32', - 'int32', - 'int16', - 'int8', - 'uint32', - 'uint16', - 'uint8', - 'uint8c' - ] + For example, we'll have: + iopairs = [ + [ 'float32', 'float32' ], + [ 'float32', 'float64' ], + [ 'float64', 'float32' ], + [ 'float64', 'float64' ], + ... + ] */ - odt = dtypes( config.output_dtypes ); + + // Filter based on dtype hierarchy: + for ( i = 0; i < iopairs.length; i++ ) { + inputDtype = iopairs[ i ][ 0 ]; + outputDtype = iopairs[ i ][ 1 ]; + inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; + outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; + + // Only allow upcasts (higher or equal precision) or same dtype or generic source: + if ( inputDtype === outputDtype || inputDtype === 'generic' || outputPrecision >= inputPrecision ) { + filtered.push( iopairs[ i ] ); + } + } + iopairs = filtered; /* - Generate the input-output dtype pairs. For example, we'll have: - pairs = [ [ 'int8', 'float32' ], [ 'int8', 'float64' ], [ 'float32', 'float32' ], [ 'float32', 'float64' ], ... ] + For example, we'll have: + iopairs = [ + [ 'float32', 'float32' ], + [ 'float32', 'float64' ], + [ 'float64', 'float64' ], + ... + ] */ - pairs = cartesianProduct( idt, odt ); - // Match-make each dtype pair with a stdlib package... - for ( i = 0; i < pairs.length; i++ ) { - // Now let dt = [ 'uint32', 'float32' ]... - dt = pairs[ i ]; + // Get the list of dtypes with scalar math kernels: + obj = db[ basePkg ]; - for ( j = 0; j < table.length; j++ ) { - row = table[ j ]; + /* + For example, we'll have: + obj = { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point", + "output_policy": "real_floating_point", + "scalar_kernels": { + "float32": "@stdlib/math/base/special/sqrtf", + "float64": "@stdlib/math/base/special/sqrt", + "generic": "@stdlib/math/base/special/sqrt" + } + } + */ - // Resolve the scalar math kernel C function name from package path ( e.g., '@stdlib/math/base/special/sqrtf' -> 'sqrtf' --> 'stdlib_base_sqrtf' ): - cFuncName = 'stdlib_base_' + row[ 2 ].split( '/' ).pop(); + /* + Available scalar kernel dtypes: + objectKeys( obj.scalar_kernels ) = [ + 'float32', + 'float64' + ] + */ - // Firstly, look for exact matches. For example, let row = [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf' ]... - if ( row[ 0 ] === dt[ 0 ] && row[ 1 ] === dt[ 1 ] ) { - // Resolve the loop kernel... - kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); - matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, cFuncName, kernel ] ); // eslint-disable-line max-len - break; - } + // Build a list of scalar kernels based on output dtype: + for ( i = 0; iopairs && i < iopairs.length; i++ ) { + out = iopairs[ i ][ 1 ]; - // Then check for package to which the dtype pair can promote. For example, pdt = promotionRules( 'uint32', 'float32' ) = 'float64': - pdt = promotionRules( dt[ 0 ], row[ 0 ] ); - if ( pdt ) { - // Check if the package in the present row supports the promoted dtypes... - if ( row[ 0 ] === pdt && row[ 1 ] === pdt ) { - // Resolve the loop kernel... - kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( dt[ 0 ] ), dtypeChar( dt[ 1 ] ), dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); - matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, cFuncName, kernel ] ); // eslint-disable-line max-len - } + // For generic input, always use highest precision kernel: + if ( iopairs[ i ][ 0 ] === 'generic' ) { + k = obj.scalar_kernels.float64 || obj.scalar_kernels.generic; + } else { + k = obj.scalar_kernels[ out ] || obj.scalar_kernels.generic; + } + + if ( k && !seen[ k ] ) { + seen[ k ] = true; + kernels.push( k ); + } + } + + // Resolve the input-output dtypes for each unique scalar kernel: + iodt = []; + for ( i = 0; i < kernels.length; i++ ) { + if ( DTYPES[ kernels[ i ] ] ) { + iodt.push( DTYPES[ kernels[ i ] ] ); + continue; + } + dt = getDtypes( kernels[ i ] ); + DTYPES[ kernels[ i ] ] = dt; + iodt.push( dt ); + } + + // Map dtype pairs to appropriate scalar functions based on prioritization rules: + mappings = []; + for ( i = 0; i < iopairs.length; i++ ) { + mapping = mapToScalarKernel( iopairs[ i ], iodt, obj.scalar_kernels ); + if ( mapping && mapping.length === 4 ) { + // Verify that the ndarray kernel exists in the function list + if ( NDARRAY_KERNELS.indexOf( mapping[ 2 ] ) !== -1 ) { + // Check if promotion is needed... + needsPromotion = mapping[ 3 ][ 0 ] !== iopairs[ i ][ 0 ] || + mapping[ 3 ][ 1 ] !== iopairs[ i ][ 1 ]; + + // [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ]... + mappings.push([ iopairs[ i ][ 0 ], iopairs[ i ][ 1 ], mapping[ 0 ], needsPromotion, ( needsPromotion ) ? mapping[ 3 ][ 0 ] : null, ( needsPromotion ) ? mapping[ 3 ][ 1 ] : null, mapping[ 1 ], mapping[ 2 ] ]); // eslint-disable-line max-len } } } - return getValidCombinations( matches ); + /* + For example, we'll have: + mappings = [ + [ 'int8', 'float32', '@stdlib/math/base/special/sqrtf', true, 'float32', 'float32', 'stdlib_base_sqrtf', 'stdlib_ndarray_s_f_as_f_f' ], + [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf', false, null, null, 'stdlib_base_sqrtf', 'stdlib_ndarray_f_f' ], + [ 'float32', 'float64', '@stdlib/math/base/special/sqrt', true, 'float64', 'float64', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d' ], + [ 'float64', 'float64', '@stdlib/math/base/special/sqrt', false, null, null, 'stdlib_base_sqrt', 'stdlib_ndarray_d_d' ], + ... + ] + */ + + return mappings; } + +// EXPORTS // + module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js deleted file mode 100644 index 1ccb269a5b56..000000000000 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/table.js +++ /dev/null @@ -1,219 +0,0 @@ -/* eslint-disable stdlib/jsdoc-no-shortcut-reference-link, stdlib/jsdoc-no-undefined-references, stdlib/jsdoc-no-paragraph-content-indent */ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolve = require( 'path' ).resolve; -var path = require( 'path' ); -var ls = require( '@stdlib/_tools/pkgs/names' ).sync; -var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; -var rootDir = require( '@stdlib/_tools/utils/root-dir' ); -var readJSON = require( '@stdlib/fs/read-json' ).sync; - - -// VARIABLES // - -var pathString = '@stdlib/math/base/special'; -var basePkg = 'sqrt'; -var ROOT_DIR = rootDir(); -var opts = { - 'dir': './' + pathString -}; -var jsonOpts = { - 'encoding': 'utf8' -}; - - -// FUNCTIONS // - -/** -* Returns a list of packages in `math/base/special/*` which are relevant for the current package. -* -* ## Note -* -* For now, we are trying the following four combinations. So, let us say, we are looking for the `sin` package, then we will try to find: -* -* - `@stdlib/math/base/special/sinf` -* - `@stdlib/math/base/special/sin` -* - `@stdlib/math/base/special/csinf` -* - `@stdlib/math/base/special/csin` -* -* Now since as of now, we don't have `@stdlib/math/base/special/csin` and `@stdlib/math/base/special/csinf`, we will only get the first two packages. -* -* @private -* @returns {Array} list of relevant packages -* -* @example -* var basePkg = 'sqrt'; -* -* var pkgs = getRelevantPackages(); -* // returns [ '@stdlib/math/base/special/sqrtf', '@stdlib/math/base/special/sqrt' ] -*/ -function getRelevantPackages() { - var combinations; - var names; - var pkgs; - var pkg; - var i; - var j; - - pkgs = []; - - // Initializing all possible combinations that we can try, in the required order: - combinations = [ - path.join( pathString, basePkg + 'f' ), - path.join( pathString, basePkg ), - path.join( pathString, 'c' + basePkg + 'f' ), - path.join( pathString, 'c' + basePkg ) - ]; - - // Get the list of all packages in `math/base/special/*`: - names = ls( opts ); - - // Filter the list of packages to only include those which match the combinations: - for ( i = 0; i < combinations.length; i++ ) { - pkg = combinations[ i ]; - for ( j = 0; j < names.length; j++ ) { - if ( names[ j ] === pkg ) { - pkgs.push( pkg ); - } - } - } - - return pkgs; -} - -/** -* Returns the input and output dtypes for a given package. -* -* ## Note -* -* - Currently, this function only supports those packages which expect a single input and return a single output. -* - In order to support packages with multiple inputs, we'll need to restructure our table and calculate accordingly. -* - As of now, each array in our table looks like this: -* -* [ input_dtype, output_dtype, package_name ] -* For example: [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] -* -* This is fine for single input & single output functions. But, for functions such as `pow`, which expect two input values, we can have: -* -* [ number_of_inputs, input_dtype_1, input_dtype_2, ... input_dtype_n, output_dtype, package_name ] -* [ 2, 'float64', 'float64', `float64`, '@stdlib/math/base/special/pow' ] -* -* @private -* @param {string} alias - package name -* @returns {Array} input and output dtypes -* -* @example -* var dtypes = getDtypes( 'acos' ); -* // returns [ 'float64', 'float64' ] -* -* @example -* var dtypes = getDtypes( 'acosf' ); -* // returns [ 'float32', 'float32' ] -*/ -function getDtypes( alias ) { - var outputDtype; - var inputDtype; - var path; - var json; - var pkg; - var out; - var o; - - // Resolve the package: - pkg = findPkgs({ - 'dir': ROOT_DIR, - 'pattern': '**/math/base/special/'+ alias +'/package.json' - }); - - if ( pkg.length === 0 ) { - return []; - } - - // Get the meta data: - path = resolve( ROOT_DIR, pkg[ 0 ] ); - json = readJSON( resolve( path, 'package.json' ), jsonOpts ); - o = json.__stdlib__; // eslint-disable-line no-underscore-dangle - if ( o && o.scaffold ) { - out = o.scaffold; - } - - // Fallback when __stdlib__.scaffold is missing in package.json: - if ( !out ) { - // Heuristics: float suffix means float32 IO, otherwise float64 IO for sqrt... - if ( alias.charAt( alias.length-1 ) === 'f' ) { - return [ 'float32', 'float32' ]; - } - return [ 'float64', 'float64' ]; - } - - // NOTE: We might need to reconsider the below logic if there are two or more inputs... - inputDtype = out.parameters[ 0 ].type.dtype; - outputDtype = out.returns.type.dtype; - - return [ inputDtype, outputDtype ]; -} - - -// MAIN // - -/** -* Generate the function table. -* -* @returns {Array} function table -* -* @example -* var basePkg = 'sqrt'; -* -* var table = generateTable(); -* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf' ], [ 'float64', 'float64', '@stdlib/math/base/special/sqrt' ] ] -*/ -function generateTable() { - var aliasName; - var dtypes; - var table; - var pkgs; - var pkg; - var i; - - // Get the list of relevant packages for the given base package: - pkgs = getRelevantPackages(); - - // Initialize the table: - table = []; - - // Loop over the packages and get the input and output dtypes: - for ( i = 0; i < pkgs.length; i++ ) { - // Extract the alias name out of the package path: - pkg = pkgs[ i ]; - aliasName = pkg.replace( pathString + '/', '' ); - dtypes = getDtypes( aliasName ); - table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkg ] ); - } - - return table; -} - - -// EXPORTS // - -module.exports = generateTable; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c index f25e473ea34e..bd7cada61ec3 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c @@ -17,8 +17,8 @@ */ /* 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/math/base/special/sqrt.h" #include "stdlib/ndarray/base/function_object.h" #include "stdlib/ndarray/base/napi/unary.h" #include "stdlib/ndarray/base/unary.h" @@ -30,9 +30,17 @@ static const char name[] = "stdlib_ndarray_sqrt"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { - // float32 (1) + // float32 (2) + stdlib_ndarray_f_f, stdlib_ndarray_f_d_as_d_d, + // float64 (1) + stdlib_ndarray_d_d, + + // int16 (2) + stdlib_ndarray_k_f_as_f_f, + stdlib_ndarray_k_d_as_d_d, + // int32 (1) stdlib_ndarray_i_d_as_d_d, @@ -40,13 +48,13 @@ static ndarrayFcn functions[] = { stdlib_ndarray_s_f_as_f_f, stdlib_ndarray_s_d_as_d_d, - // uint32 (1) - stdlib_ndarray_u_d_as_d_d, - // uint16 (2) stdlib_ndarray_t_f_as_f_f, stdlib_ndarray_t_d_as_d_d, + // uint32 (1) + stdlib_ndarray_u_d_as_d_d, + // uint8 (2) stdlib_ndarray_b_f_as_f_f, stdlib_ndarray_b_d_as_d_d, @@ -55,9 +63,17 @@ static ndarrayFcn functions[] = { // Define the array of input and output ndarray types: static int32_t types[] = { - // float32 (1) + // float32 (2) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + // float64 (1) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + + // int16 (2) + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, + // int32 (1) STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, @@ -65,13 +81,13 @@ static int32_t types[] = { STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, - // uint32 (1) - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, - // uint16 (2) STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + // uint32 (1) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + // uint8 (2) STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, @@ -80,23 +96,31 @@ static int32_t types[] = { // Define a list of ndarray function "data" (in this case, callbacks): static void *data[] = { - // float32 (1) + // float32 (2) + (void *)stdlib_base_sqrtf, (void *)stdlib_base_sqrt, - // int32 (1) + // float64 (1) (void *)stdlib_base_sqrt, - // int8 (2) + // int16 (2) (void *)stdlib_base_sqrtf, (void *)stdlib_base_sqrt, - // uint32 (1) + // int32 (1) + (void *)stdlib_base_sqrt, + + // int8 (2) + (void *)stdlib_base_sqrtf, (void *)stdlib_base_sqrt, // uint16 (2) (void *)stdlib_base_sqrtf, (void *)stdlib_base_sqrt, + // uint32 (1) + (void *)stdlib_base_sqrt, + // uint8 (2) (void *)stdlib_base_sqrtf, (void *)stdlib_base_sqrt, @@ -121,7 +145,7 @@ static const struct ndarrayFunctionObject obj = { functions, // Number of ndarray functions: - 9, + 13, // 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, 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" +] From 6d253934fb50f53e541b1f259b06f6a185d2476b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 9 Aug 2025 01:09:27 +0530 Subject: [PATCH 12/31] refactor: remove ceil --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/cceil/package.json | 77 +---- .../math/base/special/cceilf/package.json | 77 +---- .../math/base/special/ceil/package.json | 77 +---- .../math/base/special/ceilf/package.json | 77 +---- .../@stdlib/math/special/ceil/lib/types.js | 77 ----- .../@stdlib/math/special/ceil/package.json | 70 ---- .../math/special/ceil/scripts/config.js | 31 -- .../special/ceil/scripts/generate_files.js | 304 ------------------ .../math/special/ceil/scripts/script.js | 223 ------------- .../math/special/ceil/scripts/table.js | 218 ------------- .../@stdlib/math/special/ceil/src/addon.c | 183 ----------- 11 files changed, 4 insertions(+), 1410 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/lib/types.js delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/package.json delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/config.js delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/script.js delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/scripts/table.js delete mode 100644 lib/node_modules/@stdlib/math/special/ceil/src/addon.c diff --git a/lib/node_modules/@stdlib/math/base/special/cceil/package.json b/lib/node_modules/@stdlib/math/base/special/cceil/package.json index b2e863a190cd..aaae6ab20ad4 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceil/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceil/package.json @@ -66,80 +66,5 @@ "complex", "cmplx", "number" - ], - "__stdlib__": { - "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "cceil", - "alias": "cceil", - "pkg_desc": "round toward positive infinity", - "desc": "rounds toward positive infinity", - "short_desc": "ceil value", - "parameters": [ - { - "name": "x", - "desc": "input value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "complex128" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] - } - ], - "output_policy": "same", - "returns": { - "desc": "absolute value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "complex128" - } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [ - "math.abs" - ] - } - } + ] } diff --git a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json index 3a1b63d10991..9727be736b09 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cceilf/package.json @@ -66,80 +66,5 @@ "complex", "cmplx", "number" - ], - "__stdlib__": { - "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "cceilf", - "alias": "cceilf", - "pkg_desc": "round toward positive infinity", - "desc": "rounds toward positive infinity", - "short_desc": "ceil value", - "parameters": [ - { - "name": "x", - "desc": "input value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "complex64" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] - } - ], - "output_policy": "same", - "returns": { - "desc": "absolute value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "complex64" - } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [ - "math.abs" - ] - } - } + ] } diff --git a/lib/node_modules/@stdlib/math/base/special/ceil/package.json b/lib/node_modules/@stdlib/math/base/special/ceil/package.json index ffc9bfd38184..38fc7b65e615 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceil/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceil/package.json @@ -63,80 +63,5 @@ "nearest", "value", "number" - ], - "__stdlib__": { - "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "ceil", - "alias": "ceil", - "pkg_desc": "round toward positive infinity", - "desc": "rounds toward positive infinity", - "short_desc": "ceil value", - "parameters": [ - { - "name": "x", - "desc": "input value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "float64" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] - } - ], - "output_policy": "same", - "returns": { - "desc": "absolute value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "float64" - } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [ - "math.abs" - ] - } - } + ] } diff --git a/lib/node_modules/@stdlib/math/base/special/ceilf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilf/package.json index 00859904d3e9..148b58ae6e25 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilf/package.json @@ -67,80 +67,5 @@ "float32", "single-precision", "flt" - ], - "__stdlib__": { - "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "ceilf", - "alias": "ceilf", - "pkg_desc": "round toward positive infinity", - "desc": "rounds toward positive infinity", - "short_desc": "ceil value", - "parameters": [ - { - "name": "x", - "desc": "input value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "float32" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] - } - ], - "output_policy": "same", - "returns": { - "desc": "absolute value", - "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", - "dtype": "float32" - } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [ - "math.abs" - ] - } - } + ] } diff --git a/lib/node_modules/@stdlib/math/special/ceil/lib/types.js b/lib/node_modules/@stdlib/math/special/ceil/lib/types.js deleted file mode 100644 index 76984431d916..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/lib/types.js +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* This is a generated file. Do not edit directly. */ -/* -* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation. -*/ - -/* eslint-disable array-element-newline */ - -'use strict'; - -// MODULES // - -var dtypes = require( '@stdlib/ndarray/dtypes' ); - - -// MAIN // - -var types = [ - // complex64 (1) - dtypes.complex64, dtypes.complex128, - - // float32 (3) - dtypes.float32, dtypes.complex64, - dtypes.float32, dtypes.complex128, - dtypes.float32, dtypes.float64, - - // float64 (1) - dtypes.float64, dtypes.complex128, - - // int32 (2) - dtypes.int32, dtypes.complex128, - dtypes.int32, dtypes.float64, - - // int8 (4) - dtypes.int8, dtypes.complex64, - dtypes.int8, dtypes.complex128, - dtypes.int8, dtypes.float32, - dtypes.int8, dtypes.float64, - - // uint16 (4) - dtypes.uint16, dtypes.complex64, - dtypes.uint16, dtypes.complex128, - dtypes.uint16, dtypes.float32, - dtypes.uint16, dtypes.float64, - - // uint32 (2) - dtypes.uint32, dtypes.complex128, - dtypes.uint32, dtypes.float64, - - // uint8 (4) - dtypes.uint8, dtypes.complex64, - dtypes.uint8, dtypes.complex128, - dtypes.uint8, dtypes.float32, - dtypes.uint8, dtypes.float64 -]; - - -// EXPORTS // - -module.exports = types; diff --git a/lib/node_modules/@stdlib/math/special/ceil/package.json b/lib/node_modules/@stdlib/math/special/ceil/package.json deleted file mode 100644 index 203de43d4d02..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/math/special/ceil", - "version": "0.0.0", - "description": "Round a number toward positive infinity.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "browser": "./lib/main.js", - "gypfile": true, - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "scripts": "./scripts", - "src": "./src", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "mathematics", - "math", - "math.abs", - "abs", - "absolute", - "magnitude", - "value", - "ndarray", - "elementwise", - "element-wise" - ], - "__stdlib__": {} -} diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js deleted file mode 100644 index 4a19c3d6bc61..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/config.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var config = { - 'input_dtypes': 'numeric_and_generic', - 'output_dtypes': 'numeric_and_generic' -}; - - -// EXPORTS // - -module.exports = config; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js deleted file mode 100644 index 0835c722dcec..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/generate_files.js +++ /dev/null @@ -1,304 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var join = require( 'path' ).join; -var writeFileSync = require( '@stdlib/fs/write-file' ).sync; -var licenseHeader = require( '@stdlib/_tools/licenses/header' ); -var currentYear = require( '@stdlib/time/current-year' ); -var generateMatchesTable = require( './script.js' ); -var pkg = require( './../package.json' ); - - -// FUNCTIONS // - -/** -* Groups matches by input data type. -* -* @private -* @param {Array} matches - array of match entries -* @returns {Object} object containing grouped matches, input types array, and reordered matches -*/ -function groupMatchesByInputType( matches ) { - var reorderedMatches = []; - var inputTypes = []; - var inputType; - var grouped = {}; - var i; - var j; - - for ( i = 0; i < matches.length; i++ ) { - inputType = matches[ i ][ 0 ]; - if ( !grouped[ inputType ] ) { - grouped[ inputType ] = []; - inputTypes.push( inputType ); - } - grouped[ inputType ].push( matches[ i ][ 1 ] ); - } - - for ( i = 0; i < inputTypes.length; i++ ) { - inputType = inputTypes[ i ]; - for ( j = 0; j < matches.length; j++ ) { - if ( matches[ j ][ 0 ] === inputType ) { - reorderedMatches.push( matches[ j ] ); - } - } - } - - return { - 'grouped': grouped, - 'inputTypes': inputTypes, - 'reorderedMatches': reorderedMatches - }; -} - -/** -* Generates the types.js file content. -* -* @private -* @param {Array} matches - array of match entries -* @param {string} header - license header -* @returns {string} types.js file content -*/ -function generateTypesFile( matches, header ) { - var outputTypes; - var inputTypes; - var inputType; - var grouped; - var result; - var jsOut; - var i; - var j; - - jsOut = header; - jsOut += '/*\n'; - jsOut += '* NOTE: this file is only for developer convenience. Upon updating this file, run the `scripts/types.js` file to regenerate the compact types representation.\n'; - jsOut += '*/\n\n'; - jsOut += '/* eslint-disable array-element-newline */\n\n'; - jsOut += '\'use strict\';\n\n'; - jsOut += '// MODULES //\n\n'; - jsOut += 'var dtypes = require( \'@stdlib/ndarray/dtypes\' );\n\n\n'; - jsOut += '// MAIN //\n\n'; - jsOut += 'var types = [\n'; - - // Group matches by input dtype... - result = groupMatchesByInputType( matches ); - grouped = result.grouped; - inputTypes = result.inputTypes; - - // Generate grouped output with proper formatting and comments... - for ( i = 0; i < inputTypes.length; i++ ) { - inputType = inputTypes[ i ]; - outputTypes = grouped[ inputType ]; - - // Add comment with input type and count - jsOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; - - for ( j = 0; j < outputTypes.length; j++ ) { - jsOut += '\tdtypes.' + inputType + ', dtypes.' + outputTypes[ j ]; - if ( i < inputTypes.length - 1 || j < outputTypes.length - 1 ) { - jsOut += ',\n'; - } else { - jsOut += '\n'; - } - } - - // Add blank line between input type groups ( except for the last one )... - if ( i < inputTypes.length - 1 ) { - jsOut += '\n'; - } - } - - jsOut += '];\n\n\n'; - jsOut += '// EXPORTS //\n\n'; - jsOut += 'module.exports = types;\n'; - return jsOut; -} - -/** -* Generates the addon.c file content. -* -* @private -* @param {Array} matches - array of match entries -* @param {string} header - license header -* @param {string} basePkg - base package name -* @returns {string} addon.c file content -*/ -function generateAddonFile( matches, header, basePkg ) { - var uniqueIncludes; - var functionIndex; - var outputTypes; - var includeKey; - var inputType; - var grouped; - var result; - var cOut; - var i; - var j; - - // Generate unique includes... - uniqueIncludes = {}; - for ( i = 0; i < matches.length; i++ ) { - includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); - uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; - } - - // Group matches by input type for organized output... - result = groupMatchesByInputType( matches ); - grouped = result.grouped; - matches = result.reorderedMatches; - - cOut = header; - cOut += Object.keys( uniqueIncludes ).join( '\n' ) + '\n'; - cOut += '#include "stdlib/ndarray/base/function_object.h"\n'; - cOut += '#include "stdlib/ndarray/base/napi/unary.h"\n'; - cOut += '#include "stdlib/ndarray/base/unary.h"\n'; - cOut += '#include "stdlib/ndarray/dtypes.h"\n'; - cOut += '#include \n\n'; - - // Define interface name with comment... - cOut += '// Define an interface name:\n'; - cOut += 'static const char name[] = "stdlib_ndarray_' + basePkg + '";\n\n'; - - // Define functions array with comments and grouping... - cOut += '// Define a list of ndarray functions:\n'; - cOut += 'static ndarrayFcn functions[] = {\n'; - - // Add functions with type group comments... - functionIndex = 0; - for ( i = 0; i < result.inputTypes.length; i++ ) { - inputType = result.inputTypes[ i ]; - outputTypes = grouped[ inputType ]; - - cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; - for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; - functionIndex += 1; - } - cOut += '\n'; - } - cOut += '};\n\n'; - - // Define types array with comments and grouping... - cOut += '// Define the array of input and output ndarray types:\n'; - cOut += 'static int32_t types[] = {\n'; - functionIndex = 0; - for ( i = 0; i < result.inputTypes.length; i++ ) { - inputType = result.inputTypes[ i ]; - outputTypes = grouped[ inputType ]; - - cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; - for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; - functionIndex += 1; - } - cOut += '\n'; - } - cOut += '};\n\n'; - - // Define data array with comments and grouping... - cOut += '// Define a list of ndarray function "data" (in this case, callbacks):\n'; - cOut += 'static void *data[] = {\n'; - functionIndex = 0; - for ( i = 0; i < result.inputTypes.length; i++ ) { - inputType = result.inputTypes[ i ]; - outputTypes = grouped[ inputType ]; - - cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; - for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; - functionIndex += 1; - } - cOut += '\n'; - } - cOut += '};\n\n'; - - // Define function object with detailed comments... - cOut += '// Create an ndarray function object:\n'; - cOut += 'static const struct ndarrayFunctionObject obj = {\n'; - cOut += '\t// ndarray function name:\n'; - cOut += '\tname,\n\n'; - cOut += '\t// Number of input ndarrays:\n'; - cOut += '\t1,\n\n'; - cOut += '\t// Number of output ndarrays:\n'; - cOut += '\t1,\n\n'; - cOut += '\t// Total number of ndarray arguments (nin + nout):\n'; - cOut += '\t2,\n\n'; - cOut += '\t// Array containing ndarray functions:\n'; - cOut += '\tfunctions,\n\n'; - cOut += '\t// Number of ndarray functions:\n'; - cOut += '\t' + matches.length + ',\n\n'; - cOut += '\t// Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function:\n'; - cOut += '\ttypes,\n\n'; - cOut += '\t// Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions):\n'; - cOut += '\tdata\n'; - cOut += '};\n\n'; - - // Export the function object... - cOut += 'STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj )\n'; - return cOut; -} - - -// MAIN // - -/** -* Main execution function. -* -* @private -*/ -function main() { - var basePkg; - var matches; - var header; - var jsOut; - var cOut; - - // Generate and filter matches table: - matches = generateMatchesTable(); - - // Extract package information: - basePkg = pkg.name.split( '/' ).pop(); - - // Generate license header: - header = licenseHeader( 'Apache-2.0', 'js', { - 'year': currentYear(), - 'copyright': 'The Stdlib Authors' - }); - header += '\n/* This is a generated file. Do not edit directly. */\n'; - - // Generate types.js: - jsOut = generateTypesFile( matches, header ); - writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { - 'encoding': 'utf8' - }); - - // Generate addon.c: - cOut = generateAddonFile( matches, header, basePkg ); - writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { - 'encoding': 'utf8' - }); -} - - -// MAIN // - -main(); diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js deleted file mode 100644 index aca8b0426465..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/script.js +++ /dev/null @@ -1,223 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); -var promotionRules = require( '@stdlib/ndarray/promotion-rules' ); -var dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); -var dtypes = require( '@stdlib/ndarray/dtypes' ); -var format = require( '@stdlib/string/format' ); -var safeCasts = require( '@stdlib/ndarray/safe-casts' ); -var generateTable = require( './table.js' ); -var config = require( './config.js' ); - - -// FUNCTIONS // - -/** -* Returns an array of matches with valid combinations. -* -* @private -* @param {Array} matches - array of all combinations -* @returns {Array} array of matches with valid combinations -*/ -function getValidCombinations( matches ) { - var validMatches = []; - var validDtypes; - var i; - - for ( i = 0; i < matches.length; i++ ) { - // Skip complex32, float16, uint8c and int16 as we don't support them yet... - if ( matches[ i ][ 0 ] === 'complex32' || - matches[ i ][ 0 ] === 'int16' || - matches[ i ][ 0 ] === 'float16' || - matches[ i ][ 0 ] === 'uint8c' || - matches[ i ][ 1 ] === 'complex32' || - matches[ i ][ 1 ] === 'int16'|| - matches[ i ][ 1 ] === 'float16' || - matches[ i ][ 1 ] === 'uint8c' ) { - continue; - } - - // Check if the dtypes are valid for the current match... - validDtypes = safeCasts( matches[ i ][ 5 ] ); - if ( validDtypes && validDtypes.includes( matches[ i ][ 1 ] ) && promotionRules( matches[ i ][ 0 ], matches[ i ][ 1 ] ) === matches[ i ][ 4 ] ) { // eslint-disable-line max-len - validMatches.push( matches[ i ] ); - } - } - - return validMatches; -} - - -// MAIN // - -/** -* Generate dtype pairs, match them with appropriate packages, and resolve C function names and loop kernels. -* -* ## Note -* -* - The function generates an array of matches, where each match is an array of the following format: -* -* ```text -* ---------------------------------------------------------------------------------------------------------------------------------------- -* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | -* ---------------------------------------------------------------------------------------------------------------------------------------- -* | | | | | | | | -* | | | | | | | | -* V V | V V V | V -* Example: 'float32' 'float32' | true 'float64' 'float64' | 'stdlib_ndarray_d_d' -* V V -* '@stdlib/math/base/special/expf' 'stdlib_base_expf' -* ``` -* -* @private -* @returns {Array} matches table containing dtype pairs and their corresponding package information -*/ -function main() { - var cFuncName; - var matches = []; - var kernel; - var table; - var pairs; - var pdt; - var row; - var idt; - var odt; - var dt; - var i; - var j; - - /* - Generate the table. For example, we'll have: - Table: [ - [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], - [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], - [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ] - [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ], - ] - */ - table = generateTable(); - - /* - Resolve list of input dtypes. For example, we'll have: - idt = [ - 'complex32', - 'complex64', - 'complex128', - 'float16', - 'float32', - 'float64', - 'int32', - 'int16', - 'int8', - 'uint32', - 'uint16', - 'uint8', - 'uint8c' - ] - */ - idt = dtypes( config.input_dtypes ); - - /* - Resolve the list of output dtypes. For example, we'll have: - odt = [ - 'complex32', - 'complex128', - 'complex64', - 'float16', - 'float64', - 'float32', - 'int32', - 'int16', - 'int8', - 'uint32', - 'uint16', - 'uint8', - 'uint8c' - ] - */ - odt = dtypes( config.output_dtypes ); - - /* - Generate the input-output dtype pairs. For example, we'll have: - pairs = [ - [ 'complex32', 'complex32' ], - [ 'complex32', 'complex64' ], - [ 'complex32', 'complex128' ], - [ 'complex32', 'float16' ], - [ 'complex32', 'float32' ], - [ 'complex32', 'float64' ], - [ 'complex32', 'int32' ], - [ 'complex32', 'int16' ], - [ 'complex32', 'int8' ], - [ 'complex32', 'uint32' ], - [ 'complex32', 'uint16' ], - [ 'complex32', 'uint8' ], - [ 'complex32', 'uint8c' ], - [ 'complex64', 'complex32' ], - [ 'complex64', 'complex64' ], - [ 'complex64', 'complex128' ], - [ 'complex64', 'float16' ], - [ 'complex64', 'float32' ], - [ 'complex64', 'float64' ], - [ 'complex64', 'int32' ], - ... - ] - */ - pairs = cartesianProduct( idt, odt ); - - // Match-make each dtype pair with a stdlib package... - for ( i = 0; i < pairs.length; i++ ) { - // Now let dt = [ 'uint32', 'float32' ]... - dt = pairs[ i ]; - - for ( j = 0; j < table.length; j++ ) { - row = table[ j ]; - - // Resolve the scalar math kernel C function name from package path ( e.g., '@stdlib/math/base/special/ceilf' -> 'ceilf' --> 'stdlib_base_ceilf' ): - cFuncName = 'stdlib_base_' + row[ 2 ].split( '/' ).pop(); - - // Firstly, look for exact matches. For example, let row = [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ]... - if ( row[ 0 ] === dt[ 0 ] && row[ 1 ] === dt[ 1 ] ) { - // Resolve the loop kernel... - kernel = format( 'stdlib_ndarray_%s_%s', dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); - matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], false, null, null, cFuncName, kernel ] ); // eslint-disable-line max-len - break; - } - - // Then check for package to which the dtype pair can promote. For example, pdt = promotionRules( 'uint32', 'float32' ) = 'float64': - pdt = promotionRules( dt[ 0 ], row[ 0 ] ); - if ( pdt ) { - // Check if the package in the present row supports the promoted dtypes... - if ( row[ 0 ] === pdt && row[ 1 ] === pdt ) { - // Resolve the loop kernel... - kernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', dtypeChar( dt[ 0 ] ), dtypeChar( dt[ 1 ] ), dtypeChar( row[ 0 ] ), dtypeChar( row[ 1 ] ) ); - matches.push( [ dt[ 0 ], dt[ 1 ], row[ 2 ], true, pdt, pdt, cFuncName, kernel ] ); // eslint-disable-line max-len - } - } - } - } - - return getValidCombinations( matches ); -} - -module.exports = main; diff --git a/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js b/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js deleted file mode 100644 index 3e227f87123f..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/scripts/table.js +++ /dev/null @@ -1,218 +0,0 @@ -/* eslint-disable stdlib/jsdoc-no-shortcut-reference-link, stdlib/jsdoc-no-undefined-references, stdlib/jsdoc-no-paragraph-content-indent */ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var basename = require( 'path' ).basename; -var resolve = require( 'path' ).resolve; -var path = require( 'path' ); -var ls = require( '@stdlib/_tools/pkgs/names' ).sync; -var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; -var rootDir = require( '@stdlib/_tools/utils/root-dir' ); -var readJSON = require( '@stdlib/fs/read-json' ).sync; -var pkg = require( './.././package.json' ); - - -// VARIABLES // - -var pathString = '@stdlib/math/base/special'; -var basePkg = basename( pkg.name ); -var ROOT_DIR = rootDir(); -var opts = { - 'dir': './' + pathString -}; -var jsonOpts = { - 'encoding': 'utf8' -}; - - -// FUNCTIONS // - -/** -* Returns a list of packages in `math/base/special/*` which are relevant for the current package. -* -* ## Note -* -* For now, we are trying the following four combinations. So, let us say, we are looking for the `sin` package, then we will try to find: -* -* - `@stdlib/math/base/special/sinf` -* - `@stdlib/math/base/special/sin` -* - `@stdlib/math/base/special/csinf` -* - `@stdlib/math/base/special/csin` -* -* Now since as of now, we don't have `@stdlib/math/base/special/csin` and `@stdlib/math/base/special/csinf`, we will only get the first two packages. -* -* @private -* @returns {Array} list of relevant packages -* -* @example -* var basePkg = 'inv'; -* -* var pkgs = getRelevantPackages(); -* // returns [ '@stdlib/math/base/special/invf', '@stdlib/math/base/special/inv', '@stdlib/math/base/special/cinvf', '@stdlib/math/base/special/cinv' ] -* -* @example -* var basePkg = 'sin'; -* -* var pkgs = getRelevantPackages( 'sin' ); -* // returns [ '@stdlib/math/base/special/sinf', '@stdlib/math/base/special/sin' ] -*/ -function getRelevantPackages() { - var combinations; - var names; - var pkgs; - var pkg; - var i; - var j; - - pkgs = []; - - // Initializing all possible combinations that we can try, in the required order: - combinations = [ - path.join( pathString, basePkg + 'f' ), - path.join( pathString, basePkg ), - path.join( pathString, 'c' + basePkg + 'f' ), - path.join( pathString, 'c' + basePkg ) - ]; - - // Get the list of all packages in `math/base/special/*`: - names = ls( opts ); - - // Filter the list of packages to only include those which match the combinations: - for ( i = 0; i < combinations.length; i++ ) { - pkg = combinations[ i ]; - for ( j = 0; j < names.length; j++ ) { - if ( names[ j ] === pkg ) { - pkgs.push( pkg ); - } - } - } - - return pkgs; -} - -/** -* Returns the input and output dtypes for a given package. -* -* ## Note -* -* - Currently, this function only supports those packages which expect a single input and return a single output. -* - In order to support packages with multiple inputs, we'll need to restructure our table and calculate accordingly. -* - As of now, each array in our table looks like this: -* -* [ input_dtype, output_dtype, package_name ] -* For example: [ 'float32', 'float32', '@stdlib/math/base/special/sinf' ] -* -* This is fine for single input & single output functions. But, for functions such as `pow`, which expect two input values, we can have: -* -* [ number_of_inputs, input_dtype_1, input_dtype_2, ... input_dtype_n, output_dtype, package_name ] -* [ 2, 'float64', 'float64', `float64`, '@stdlib/math/base/special/pow' ] -* -* @private -* @param {string} alias - package name -* @returns {Array} input and output dtypes -* -* @example -* var dtypes = getDtypes( 'acos' ); -* // returns [ 'float64', 'float64' ] -* -* @example -* var dtypes = getDtypes( 'acosf' ); -* // returns [ 'float32', 'float32' ] -*/ -function getDtypes( alias ) { - var outputDtype; - var inputDtype; - var path; - var json; - var pkg; - var out; - var o; - - // Resolve the package: - pkg = findPkgs({ - 'dir': ROOT_DIR, - 'pattern': '**/math/base/special/'+ alias +'/package.json' - }); - - if ( pkg.length === 0 ) { - return []; - } - - // Get the meta data: - path = resolve( ROOT_DIR, pkg[ 0 ] ); - json = readJSON( resolve( path, 'package.json' ), jsonOpts ); - o = json.__stdlib__; // eslint-disable-line no-underscore-dangle - if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { - out = o.scaffold; - } - - // NOTE: We might need to reconsider the below logic if there are two or more inputs... - inputDtype = out.parameters[ 0 ].type.dtype; - outputDtype = out.returns.type.dtype; - - return [ inputDtype, outputDtype ]; -} - - -// MAIN // - -/** -* Generate the function table. -* -* @returns {Array} function table -* -* @example -* var basePkg = 'ceil'; -* -* var table = generateTable(); -* // returns [ [ 'float32', 'float32', '@stdlib/math/base/special/ceilf' ], [ 'float64', 'float64', '@stdlib/math/base/special/ceil' ], [ 'complex64', 'complex64', '@stdlib/math/base/special/cceilf' ], [ 'complex128', 'complex128', '@stdlib/math/base/special/cceil' ] ] -*/ -function generateTable() { - var aliasName; - var dtypes; - var table; - var pkgs; - var pkg; - var i; - - // Get the list of relevant packages for the given base package: - pkgs = getRelevantPackages(); - - // Initialize the table: - table = []; - - // Loop over the packages and get the input and output dtypes: - for ( i = 0; i < pkgs.length; i++ ) { - // Extract the alias name out of the package path: - pkg = pkgs[ i ]; - aliasName = pkg.replace( pathString + '/', '' ); - dtypes = getDtypes( aliasName ); - table.push( [ dtypes[ 0 ], dtypes[ 1 ], pkg ] ); - } - - return table; -} - - -// EXPORTS // - -module.exports = generateTable; diff --git a/lib/node_modules/@stdlib/math/special/ceil/src/addon.c b/lib/node_modules/@stdlib/math/special/ceil/src/addon.c deleted file mode 100644 index 8c8b5c968b7f..000000000000 --- a/lib/node_modules/@stdlib/math/special/ceil/src/addon.c +++ /dev/null @@ -1,183 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* This is a generated file. Do not edit directly. */ -#include "stdlib/math/base/special/cceil.h" -#include "stdlib/math/base/special/cceilf.h" -#include "stdlib/math/base/special/ceil.h" -#include "stdlib/math/base/special/ceilf.h" -#include "stdlib/ndarray/base/function_object.h" -#include "stdlib/ndarray/base/napi/unary.h" -#include "stdlib/ndarray/base/unary.h" -#include "stdlib/ndarray/dtypes.h" -#include - -// Define an interface name: -static const char name[] = "stdlib_ndarray_ceil"; - -// Define a list of ndarray functions: -static ndarrayFcn functions[] = { - // complex64 (1) - stdlib_ndarray_c_z_as_z_z, - - // float32 (3) - stdlib_ndarray_f_c_as_c_c, - stdlib_ndarray_f_z_as_z_z, - stdlib_ndarray_f_d_as_d_d, - - // float64 (1) - stdlib_ndarray_d_z_as_z_z, - - // int32 (2) - stdlib_ndarray_i_z_as_z_z, - stdlib_ndarray_i_d_as_d_d, - - // int8 (4) - stdlib_ndarray_s_c_as_c_c, - stdlib_ndarray_s_z_as_z_z, - stdlib_ndarray_s_f_as_f_f, - stdlib_ndarray_s_d_as_d_d, - - // uint16 (4) - stdlib_ndarray_t_c_as_c_c, - stdlib_ndarray_t_z_as_z_z, - stdlib_ndarray_t_f_as_f_f, - stdlib_ndarray_t_d_as_d_d, - - // uint32 (2) - stdlib_ndarray_u_z_as_z_z, - stdlib_ndarray_u_d_as_d_d, - - // uint8 (4) - stdlib_ndarray_b_c_as_c_c, - stdlib_ndarray_b_z_as_z_z, - stdlib_ndarray_b_f_as_f_f, - stdlib_ndarray_b_d_as_d_d, - -}; - -// Define the array of input and output ndarray types: -static int32_t types[] = { - // complex64 (1) - STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, - - // float32 (3) - STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, - - // float64 (1) - STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX128, - - // int32 (2) - STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, - - // int8 (4) - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, - - // uint16 (4) - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, - - // uint32 (2) - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, - - // uint8 (4) - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, - -}; - -// Define a list of ndarray function "data" (in this case, callbacks): -static void *data[] = { - // complex64 (1) - (void *)stdlib_base_cceil, - - // float32 (3) - (void *)stdlib_base_cceilf, - (void *)stdlib_base_cceil, - (void *)stdlib_base_ceil, - - // float64 (1) - (void *)stdlib_base_cceil, - - // int32 (2) - (void *)stdlib_base_cceil, - (void *)stdlib_base_ceil, - - // int8 (4) - (void *)stdlib_base_cceilf, - (void *)stdlib_base_cceil, - (void *)stdlib_base_ceilf, - (void *)stdlib_base_ceil, - - // uint16 (4) - (void *)stdlib_base_cceilf, - (void *)stdlib_base_cceil, - (void *)stdlib_base_ceilf, - (void *)stdlib_base_ceil, - - // uint32 (2) - (void *)stdlib_base_cceil, - (void *)stdlib_base_ceil, - - // uint8 (4) - (void *)stdlib_base_cceilf, - (void *)stdlib_base_cceil, - (void *)stdlib_base_ceilf, - (void *)stdlib_base_ceil, - -}; - -// Create an ndarray function object: -static const struct ndarrayFunctionObject obj = { - // ndarray function name: - name, - - // Number of input ndarrays: - 1, - - // Number of output ndarrays: - 1, - - // Total number of ndarray arguments (nin + nout): - 2, - - // Array containing ndarray functions: - functions, - - // Number of ndarray functions: - 21, - - // Array of type "numbers" (as enumerated elsewhere), where the total number of types equals `narrays * nfunctions` and where each set of `narrays` consecutive types (non-overlapping) corresponds to the set of ndarray argument types for a corresponding ndarray function: - types, - - // Array of void pointers corresponding to the "data" (e.g., callbacks) which should be passed to a respective ndarray function (note: the number of pointers should match the number of ndarray functions): - data -}; - -STDLIB_NDARRAY_NAPI_MODULE_UNARY( obj ) From 557c8fccb8dcd8655ee1034ab7583cd7e55ec57b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 11 Aug 2025 08:28:26 +0530 Subject: [PATCH 13/31] chore: generate files for sin --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/sin/package.json | 75 ++++- .../special/scripts/function_database.json | 10 + .../@stdlib/math/special/sin/lib/types.js | 66 ++++ .../@stdlib/math/special/sin/package.json | 69 +++++ .../math/special/sin/scripts/config.js | 38 +++ .../special/sin/scripts/generate_files.js | 285 ++++++++++++++++++ .../math/special/sin/scripts/get_dtypes.js | 95 ++++++ .../sin/scripts/map_to_scalar_kernel.js | 178 +++++++++++ .../math/special/sin/scripts/script.js | 255 ++++++++++++++++ .../@stdlib/math/special/sin/src/addon.c | 157 ++++++++++ 10 files changed, 1227 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/math/special/sin/lib/types.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/package.json create mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/config.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/script.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/src/addon.c 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..7f377e131081 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,78 @@ "trigonometry", "radians", "angle" - ] + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base@v1.0", + "base_alias": "sin", + "alias": "sin", + "pkg_desc": "compute the sine of a number", + "desc": "computes the sine of a number", + "short_desc": "sine value", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + }, + "example_values": [ + 64, + 27, + 0, + 0.1, + -9, + 8, + -1, + 125, + -10.2, + 11.3, + -12.4, + 3.5, + -1.6, + 15.7, + -16, + 17.9, + -188, + 19.11, + -200, + 21.15 + ] + } + ], + "output_policy": "same", + "returns": { + "desc": "sine value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "double", + "dtype": "float64" + } + }, + "keywords": [ + "abs", + "absolute", + "magnitude" + ], + "extra_keywords": [] + } + } } diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index de123a5ccf51..7df060a5803d 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -8,6 +8,16 @@ "float64": "@stdlib/math/base/special/sqrt", "generic": "@stdlib/math/base/special/sqrt" } + }, + "sin": { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point", + "output_policy": "real_floating_point", + "scalar_kernels": { + "float32": "@stdlib/math/base/special/sinf", + "float64": "@stdlib/math/base/special/sin", + "generic": "@stdlib/math/base/special/sin" + } } } 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..ba8b4897156e --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/lib/types.js @@ -0,0 +1,66 @@ +/** +* @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 (2) + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.float64, + + // float64 (1) + dtypes.float64, dtypes.float64, + + // int16 (2) + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.float64, + + // int32 (1) + dtypes.int32, dtypes.float64, + + // int8 (2) + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.float64, + + // uint16 (2) + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.float64, + + // uint32 (1) + dtypes.uint32, dtypes.float64, + + // uint8 (2) + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.float64 +]; + + +// EXPORTS // + +module.exports = types; 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/config.js b/lib/node_modules/@stdlib/math/special/sin/scripts/config.js new file mode 100644 index 000000000000..13d8ee48102b --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/config.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Configuration object. +* +* @private +* @type {Object} +*/ +var config = { + 'input_dtypes': 'real_and_generic', + 'output_dtypes': 'real_floating_point', + 'excluded_dtypes': [ 'float16', 'uint8c' ] +}; + + +// EXPORTS // + +module.exports = config; 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..7828f33b516f --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -0,0 +1,285 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var currentYear = require( '@stdlib/time/current-year' ); +var generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// FUNCTIONS // + +/** +* Groups matches by input data type. +* +* @private +* @param {Array} matches - array of match entries +* @returns {Object} object containing grouped matches, input types array, and reordered matches +*/ +function groupMatchesByInputType( matches ) { + var reorderedMatches = []; + var inputTypes = []; + var inputType; + var grouped = {}; + var i; + var j; + + for ( i = 0; i < matches.length; i++ ) { + inputType = matches[ i ][ 0 ]; + if ( !grouped[ inputType ] ) { + grouped[ inputType ] = []; + inputTypes.push( inputType ); + } + grouped[ inputType ].push( matches[ i ][ 1 ] ); + } + + for ( i = 0; i < inputTypes.length; i++ ) { + inputType = inputTypes[ i ]; + for ( j = 0; j < matches.length; j++ ) { + if ( matches[ j ][ 0 ] === inputType ) { + reorderedMatches.push( matches[ j ] ); + } + } + } + + return { + 'grouped': grouped, + 'inputTypes': inputTypes, + 'reorderedMatches': reorderedMatches + }; +} + +/** +* Generates the types.js file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @returns {string} types.js file content +*/ +function generateTypesFile( matches, header ) { + var outputTypes; + var inputTypes; + var inputType; + var grouped; + var result; + var jsOut; + var i; + var j; + + jsOut = header; + jsOut += '\n'; + jsOut += '/* 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'; + } + } + + // Add blank line between input type groups ( except for the last one )... + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\n'; + return jsOut; +} + +/** +* Generates the addon.c file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @param {string} basePkg - base package name +* @returns {string} addon.c file content +*/ +function generateAddonFile( matches, header, basePkg ) { + var uniqueIncludes; + var functionIndex; + var outputTypes; + var includeKey; + var inputType; + var grouped; + var result; + var cOut; + var i; + var j; + + // Generate unique includes... + uniqueIncludes = {}; + for ( i = 0; i < matches.length; i++ ) { + includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); + uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; + } + + // Group matches by input type... + 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 ] + ',\n'; + functionIndex += 1; + } + 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() + ',\n'; + functionIndex += 1; + } + 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 ] + ',\n'; + functionIndex += 1; + } + 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 basePkg; + var matches; + var header; + var jsOut; + var cOut; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // Extract package information: + basePkg = pkg.name.split( '/' ).pop(); + + // Generate license header: + header = licenseHeader( 'Apache-2.0', 'js', { + 'year': currentYear(), + 'copyright': 'The Stdlib Authors' + }); + header += '\n/* This is a generated file. Do not edit directly. */\n'; + + // Generate types.js: + jsOut = generateTypesFile( matches, header ); + writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( matches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js new file mode 100644 index 000000000000..f961d1011401 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js @@ -0,0 +1,95 @@ +/** +* @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 findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var readJSON = require( '@stdlib/fs/read-json' ).sync; + + +// VARIABLES // + +var ROOT_DIR = rootDir(); +var jsonOpts = { + 'encoding': 'utf8' +}; + + +// FUNCTIONS // + +/** +* Returns the input and output dtypes for a given package by reading scaffold metadata. +* +* @private +* @param {string} pkgPath - package path +* @returns {Array} input and output dtypes +* +* @example +* var dtypes = getDtypes( '@stdlib/math/base/special/sqrt' ); +* // returns [ 'float64', 'float64' ] +* +* @example +* var dtypes = getDtypes( '@stdlib/math/base/special/sqrtf' ); +* // returns [ 'float32', 'float32' ] +*/ +function getDtypes( pkgPath ) { + var outputDtype; + var inputDtype; + var aliasName; + var path; + var json; + var pkg; + var out; + var o; + + // Extract alias name from package path: + aliasName = pkgPath.split( '/' ).pop(); + + // Find the package: + pkg = findPkgs({ + 'dir': ROOT_DIR, + 'pattern': '**/math/base/special/' + aliasName + '/package.json' // Currently we are looking only in `math/base/special/` + }); + + if ( pkg.length === 0 ) { + return []; + } + + // Get the metadata: + path = resolve( ROOT_DIR, pkg[ 0 ] ); + json = readJSON( resolve( path, 'package.json' ), jsonOpts ); + o = json.__stdlib__; // eslint-disable-line no-underscore-dangle + if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { + out = o.scaffold; + } + + // Extract input and output dtypes: + inputDtype = out.parameters[ 0 ].type.dtype; + outputDtype = out.returns.type.dtype; + + return [ inputDtype, outputDtype ]; +} + + +// EXPORTS // + +module.exports = getDtypes; diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js b/lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js new file mode 100644 index 000000000000..74a3929877f2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js @@ -0,0 +1,178 @@ +/** +* @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 dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var format = require( '@stdlib/string/format' ); +var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); + + +// FUNCTIONS // + +/** +* Maps dtype pairs to appropriate scalar functions. +* +* ## Note +* +* - The function returns an array with the following structure: +* +* ```text +* --------------------------------------------------------------------------------- +* Array: | kernel | cFunc | ndarrayKernel | match | +* --------------------------------------------------------------------------------- +* | | | | +* | | | | +* V V V V +* Example: '@stdlib/math/base/ 'stdlib_base_sqrt' 'stdlib_ndarray_ ['float64', +* special/sqrt' f_d_as_d_d' 'float64'] +* ``` +* +* @private +* @param {Array} iopair - input-output dtype pair +* @param {Array} iodt - array of available scalar kernel dtypes +* @param {Object} scalarKernels - scalar kernels object +* @returns {Array} mapping result +* +* @example +* var iopair = [ 'float32', 'float64' ]; +* var iodt = [ +* [ 'float32', 'float32' ], +* [ 'float64', 'float64' ] +* ]; +* var scalarKernels = { +* 'float32': '@stdlib/math/base/special/sqrtf', +* 'float64': '@stdlib/math/base/special/sqrt' +* }; +* +* var result = mapToScalarKernel( iopair, iodt, scalarKernels ); +* // returns [ '@stdlib/math/base/special/sqrt', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d', [ 'float64', 'float64' ] ] +*/ +function mapToScalarKernel( iopair, iodt, scalarKernels ) { + var ndarrayKernel; + var precision1; + var precision2; + var matchChar1; + var matchChar2; + var outputChar; + var cFuncName; + var inputChar; + var kernel; + var match; + var dtype; + var i; + + inputChar = dtypeChar( iopair[ 0 ] ); + outputChar = dtypeChar( iopair[ 1 ] ); + + // For generic input, always use highest precision kernel + if ( iopair[ 0 ] === 'generic' ) { + kernel = scalarKernels.float64 || scalarKernels.generic; + cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); + ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_d_d', inputChar, outputChar ); + + return [ kernel, cFuncName, ndarrayKernel, [ 'float64', 'float64' ] ]; + } + + // Priority 1: Look for exact match in available scalar kernel dtypes: + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 0 ] && + iodt[ i ][ 1 ] === iopair[ 1 ] ) { + match = iodt[ i ]; + break; + } + } + + // Priority 2: Look for higher precision matches to break ties: + if ( !match ) { + /* + * Always prefer computing at higher precision: + * - For cases like ['float32', 'float64'], prefer computing at float64: f_d_as_d_d + * - For cases like ['int8', 'float32'], prefer computing at float32: s_f_as_f_f + */ + + // Get higher precision dtype using hierarchy table: + if ( iopair[ 0 ] === iopair[ 1 ] ) { + dtype = iopair[ 0 ]; + } else { + precision1 = DTYPE_HIERARCHY[ iopair[ 0 ] ] || 0; + precision2 = DTYPE_HIERARCHY[ iopair[ 1 ] ] || 0; + dtype = ( precision2 > precision1 ) ? iopair[ 1 ] : iopair[ 0 ]; + } + + // First try: Look for (higher_precision_dtype, higher_precision_dtype)... + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === dtype && iodt[ i ][ 1 ] === dtype ) { + match = iodt[ i ]; + break; + } + } + + // Second try: Look for (input_dtype, input_dtype) if higher precision not found... + if ( !match ) { + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 0 ] && + iodt[ i ][ 1 ] === iopair[ 0 ] ) { + match = iodt[ i ]; + break; + } + } + } + + // Third try: Look for (output_dtype, output_dtype)... + if ( !match ) { + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 1 ] && + iodt[ i ][ 1 ] === iopair[ 1 ] ) { + match = iodt[ i ]; + break; + } + } + } + } + + if ( match ) { + // Get the scalar kernel package + kernel = scalarKernels[ match[ 1 ] ]; + + // Generate C function name + cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); + + // Generate ndarray kernel name + if ( match[ 0 ] === iopair[ 0 ] && match[ 1 ] === iopair[ 1 ] ) { + // Exact match + ndarrayKernel = format( 'stdlib_ndarray_%s_%s', inputChar, outputChar ); + } else { + // Promotion case + matchChar1 = dtypeChar( match[ 0 ] ); + matchChar2 = dtypeChar( match[ 1 ] ); + ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', inputChar, outputChar, matchChar1, matchChar2 ); + } + + return [ kernel, cFuncName, ndarrayKernel, match ]; + } + + return []; +} + + +// EXPORTS // + +module.exports = mapToScalarKernel; 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..99d479a116d9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js @@ -0,0 +1,255 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var basename = require( 'path' ).basename; +var join = require( 'path' ).join; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); +var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); +var mapToScalarKernel = require( './map_to_scalar_kernel.js' ); +var getDtypes = require( './get_dtypes.js' ); +var config = require( './config.js' ); + + +// VARIABLES // + +var DTYPES = {}; +var basePkg = basename( join( __dirname, '..' ) ); + + +// MAIN // + +/** +* Main execution sequence. +* +* ## Note +* +* - The function generates an array of matches, where each match is an array of the following format: +* +* ```text +* ---------------------------------------------------------------------------------------------------------------------------------------- +* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | +* ---------------------------------------------------------------------------------------------------------------------------------------- +* | | | | | | | | +* | | | | | | | | +* V V | V V V | V +* Example: 'float32' 'float64' | true 'float64' 'float64' | 'stdlib_ndarray_f_d_as_d_d' +* V V +* '@stdlib/math/base/special/sqrt' 'stdlib_base_sqrt' +* ``` +* +* @private +* @returns {Array} array of mappings +*/ +function main() { + var outputPrecision; + var needsPromotion; + var inputPrecision; + var outputDtype; + var inputDtype; + var filtered = []; + var mappings; + var kernels = []; + var iopairs; + var mapping; + var iodt = []; + var seen = {}; + var odt; + var idt; + var out; + var obj; + var dt; + var k; + var i; + + // Resolve list of input dtypes: + idt = dtypes( config.input_dtypes ); + filtered = []; + for ( i = 0; i < idt.length; i++ ) { + if ( config.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { // Exclude irrelevant dtypes + filtered.push( idt[ i ] ); + } + } + idt = filtered; + + /* + For example, we'll have: + idt = [ + 'float32', + 'float64', + 'int16', + 'int32', + 'int8', + 'uint16', + 'uint32', + 'uint8', + 'generic' + ] + */ + + // Resolve the list of output dtypes: + odt = dtypes( config.output_dtypes ); + filtered = []; + for ( i = 0; i < odt.length; i++ ) { + if ( config.excluded_dtypes.indexOf( odt[ i ] ) === -1 ) { // Exclude irrelevant dtypes + filtered.push( odt[ i ] ); + } + } + odt = filtered; + + /* + For example, we'll have: + odt = [ + 'float32', + 'float64' + ] + */ + + // Computing the Cartesian product of input and output dtypes: + iopairs = cartesianProduct( idt, odt ); + + /* + For example, we'll have: + iopairs = [ + [ 'float32', 'float32' ], + [ 'float32', 'float64' ], + [ 'float64', 'float32' ], + [ 'float64', 'float64' ], + ... + ] + */ + + // Filter based on dtype hierarchy: + for ( i = 0; i < iopairs.length; i++ ) { + inputDtype = iopairs[ i ][ 0 ]; + outputDtype = iopairs[ i ][ 1 ]; + inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; + outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; + + // Only allow upcasts (higher or equal precision) or same dtype or generic source: + if ( inputDtype === outputDtype || inputDtype === 'generic' || outputPrecision >= inputPrecision ) { + filtered.push( iopairs[ i ] ); + } + } + iopairs = filtered; + + /* + For example, we'll have: + iopairs = [ + [ 'float32', 'float32' ], + [ 'float32', 'float64' ], + [ 'float64', 'float64' ], + ... + ] + */ + + // Get the list of dtypes with scalar math kernels: + obj = db[ basePkg ]; + + /* + For example, we'll have: + obj = { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point", + "output_policy": "real_floating_point", + "scalar_kernels": { + "float32": "@stdlib/math/base/special/sqrtf", + "float64": "@stdlib/math/base/special/sqrt", + "generic": "@stdlib/math/base/special/sqrt" + } + } + */ + + /* + Available scalar kernel dtypes: + objectKeys( obj.scalar_kernels ) = [ + 'float32', + 'float64' + ] + */ + + // Build a list of scalar kernels based on output dtype: + for ( i = 0; iopairs && i < iopairs.length; i++ ) { + out = iopairs[ i ][ 1 ]; + + // For generic input, always use highest precision kernel: + if ( iopairs[ i ][ 0 ] === 'generic' ) { + k = obj.scalar_kernels.float64 || obj.scalar_kernels.generic; + } else { + k = obj.scalar_kernels[ out ] || obj.scalar_kernels.generic; + } + + if ( k && !seen[ k ] ) { + seen[ k ] = true; + kernels.push( k ); + } + } + + // Resolve the input-output dtypes for each unique scalar kernel: + iodt = []; + for ( i = 0; i < kernels.length; i++ ) { + if ( DTYPES[ kernels[ i ] ] ) { + iodt.push( DTYPES[ kernels[ i ] ] ); + continue; + } + dt = getDtypes( kernels[ i ] ); + DTYPES[ kernels[ i ] ] = dt; + iodt.push( dt ); + } + + // Map dtype pairs to appropriate scalar functions based on prioritization rules: + mappings = []; + for ( i = 0; i < iopairs.length; i++ ) { + mapping = mapToScalarKernel( iopairs[ i ], iodt, obj.scalar_kernels ); + if ( mapping && mapping.length === 4 ) { + // Verify that the ndarray kernel exists in the function list + if ( NDARRAY_KERNELS.indexOf( mapping[ 2 ] ) !== -1 ) { + // Check if promotion is needed... + needsPromotion = mapping[ 3 ][ 0 ] !== iopairs[ i ][ 0 ] || + mapping[ 3 ][ 1 ] !== iopairs[ i ][ 1 ]; + + // [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ]... + mappings.push([ iopairs[ i ][ 0 ], iopairs[ i ][ 1 ], mapping[ 0 ], needsPromotion, ( needsPromotion ) ? mapping[ 3 ][ 0 ] : null, ( needsPromotion ) ? mapping[ 3 ][ 1 ] : null, mapping[ 1 ], mapping[ 2 ] ]); // eslint-disable-line max-len + } + } + } + + /* + For example, we'll have: + mappings = [ + [ 'int8', 'float32', '@stdlib/math/base/special/sqrtf', true, 'float32', 'float32', 'stdlib_base_sqrtf', 'stdlib_ndarray_s_f_as_f_f' ], + [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf', false, null, null, 'stdlib_base_sqrtf', 'stdlib_ndarray_f_f' ], + [ 'float32', 'float64', '@stdlib/math/base/special/sqrt', true, 'float64', 'float64', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d' ], + [ 'float64', 'float64', '@stdlib/math/base/special/sqrt', false, null, null, 'stdlib_base_sqrt', 'stdlib_ndarray_d_d' ], + ... + ] + */ + + 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..250c7b5bbe43 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/sin/src/addon.c @@ -0,0 +1,157 @@ +/** +* @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/sinf.h" +#include "stdlib/math/base/special/sin.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_f, + stdlib_ndarray_f_d_as_d_d, + + // float64 (1) + stdlib_ndarray_d_d, + + // int16 (2) + stdlib_ndarray_k_f_as_f_f, + stdlib_ndarray_k_d_as_d_d, + + // int32 (1) + stdlib_ndarray_i_d_as_d_d, + + // int8 (2) + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_d_as_d_d, + + // uint16 (2) + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_d_as_d_d, + + // uint32 (1) + stdlib_ndarray_u_d_as_d_d, + + // uint8 (2) + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_d_as_d_d, + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // float32 (2) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + + // float64 (1) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + + // int16 (2) + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, + + // int32 (1) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + + // int8 (2) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + + // uint16 (2) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + + // uint32 (1) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + + // uint8 (2) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // float32 (2) + (void *)stdlib_base_sinf, + (void *)stdlib_base_sin, + + // float64 (1) + (void *)stdlib_base_sin, + + // int16 (2) + (void *)stdlib_base_sinf, + (void *)stdlib_base_sin, + + // int32 (1) + (void *)stdlib_base_sin, + + // int8 (2) + (void *)stdlib_base_sinf, + (void *)stdlib_base_sin, + + // uint16 (2) + (void *)stdlib_base_sinf, + (void *)stdlib_base_sin, + + // uint32 (1) + (void *)stdlib_base_sin, + + // uint8 (2) + (void *)stdlib_base_sinf, + (void *)stdlib_base_sin, + +}; + +// 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: + 13, + + // 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 ) From e759e6ef92b816add959bb8944718ae3287c62ee Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 13 Aug 2025 22:58:43 +0530 Subject: [PATCH 14/31] refactor: update script, try it out with floor --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/cfloor/package.json | 17 +- .../math/base/special/cfloorf/package.json | 17 +- .../math/base/special/floor/package.json | 17 +- .../math/base/special/floorf/package.json | 17 +- .../math/base/special/sin/package.json | 64 +--- .../math/base/special/sqrt/package.json | 66 +--- .../math/base/special/sqrtf/package.json | 66 +--- .../@stdlib/math/special/floor/lib/types.js | 88 ++++++ .../@stdlib/math/special/floor/package.json | 64 ++++ .../math/special/floor/scripts/config.js | 38 +++ .../special/floor/scripts/generate_files.js | 289 ++++++++++++++++++ .../math/special/floor/scripts/get_dtypes.js | 93 ++++++ .../floor/scripts/map_to_scalar_kernel.js | 178 +++++++++++ .../math/special/floor/scripts/script.js | 269 ++++++++++++++++ .../@stdlib/math/special/floor/src/addon.c | 231 ++++++++++++++ .../math/special/scripts/dtype_hierarchy.js | 4 +- .../special/scripts/function_database.json | 18 ++ .../special/sin/scripts/generate_files.js | 10 +- .../math/special/sin/scripts/get_dtypes.js | 10 +- .../math/special/sin/scripts/script.js | 20 +- .../special/sqrt/scripts/generate_files.js | 10 +- .../math/special/sqrt/scripts/get_dtypes.js | 10 +- .../math/special/sqrt/scripts/script.js | 20 +- .../number/int16/base/identity/package.json | 18 +- .../number/int32/base/identity/package.json | 18 +- .../number/int8/base/identity/package.json | 18 +- .../number/uint16/base/identity/package.json | 18 +- .../number/uint32/base/identity/package.json | 18 +- .../number/uint8/base/identity/package.json | 18 +- 29 files changed, 1496 insertions(+), 228 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/special/floor/lib/types.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/package.json create mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/config.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/script.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/src/addon.c 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/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 7f377e131081..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,78 +63,20 @@ "trigonometry", "radians", "angle" - ], - "__stdlib__": { + ],"__stdlib__": { "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "sin", - "alias": "sin", - "pkg_desc": "compute the sine of a number", - "desc": "computes the sine of a number", - "short_desc": "sine value", "parameters": [ { - "name": "x", - "desc": "input value", "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", "dtype": "float64" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] + } } ], - "output_policy": "same", "returns": { - "desc": "sine value", "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", "dtype": "float64" } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [] + } } } } 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 2e48013743c3..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,80 +63,20 @@ "root", "power", "number" - ], - "__stdlib__": { + ],"__stdlib__": { "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "sqrt", - "alias": "sqrt", - "pkg_desc": "round toward positive infinity", - "desc": "rounds toward positive infinity", - "short_desc": "ceil value", "parameters": [ { - "name": "x", - "desc": "input value", "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", "dtype": "float64" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] + } } ], - "output_policy": "same", "returns": { - "desc": "absolute value", "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", "dtype": "float64" } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [ - "math.abs" - ] + } } } } diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json index a744b64da3e5..54a8bc407a66 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json @@ -66,80 +66,20 @@ "complex", "cmplx", "number" - ], - "__stdlib__": { + ],"__stdlib__": { "scaffold": { - "$schema": "math/base@v1.0", - "base_alias": "sqrtf", - "alias": "sqrtf", - "pkg_desc": "round toward positive infinity", - "desc": "rounds toward positive infinity", - "short_desc": "ceil value", "parameters": [ { - "name": "x", - "desc": "input value", "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", "dtype": "float32" - }, - "domain": [ - { - "min": "-infinity", - "max": "infinity" - } - ], - "rand": { - "prng": "random/base/uniform", - "parameters": [ - -10, - 10 - ] - }, - "example_values": [ - 64, - 27, - 0, - 0.1, - -9, - 8, - -1, - 125, - -10.2, - 11.3, - -12.4, - 3.5, - -1.6, - 15.7, - -16, - 17.9, - -188, - 19.11, - -200, - 21.15 - ] + } } ], - "output_policy": "same", "returns": { - "desc": "absolute value", "type": { - "javascript": "number", - "jsdoc": "number", - "c": "double", "dtype": "float32" } - }, - "keywords": [ - "abs", - "absolute", - "magnitude" - ], - "extra_keywords": [ - "math.abs" - ] + } } } } diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/types.js b/lib/node_modules/@stdlib/math/special/floor/lib/types.js new file mode 100644 index 000000000000..846808e0ef84 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/lib/types.js @@ -0,0 +1,88 @@ +/** +* @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 (2) + dtypes.complex64, dtypes.complex64, + dtypes.complex64, dtypes.complex128, + + // complex128 (1) + dtypes.complex128, dtypes.complex128, + + // float32 (2) + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.float64, + + // float64 (1) + dtypes.float64, dtypes.float64, + + // int16 (4) + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.int16, + dtypes.int16, dtypes.int32, + + // int32 (2) + dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.int32, + + // int8 (5) + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.int16, + dtypes.int8, dtypes.int32, + dtypes.int8, dtypes.int8, + + // uint16 (5) + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.int32, + dtypes.uint16, dtypes.uint16, + dtypes.uint16, dtypes.uint32, + + // uint32 (2) + dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.uint32, + + // uint8 (7) + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.float64, + dtypes.uint8, dtypes.int16, + dtypes.uint8, dtypes.int32, + dtypes.uint8, dtypes.uint16, + dtypes.uint8, dtypes.uint32, + dtypes.uint8, dtypes.uint8 +]; + + +// EXPORTS // + +module.exports = types; 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/config.js b/lib/node_modules/@stdlib/math/special/floor/scripts/config.js new file mode 100644 index 000000000000..6ee8b7734c61 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/config.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Configuration object. +* +* @private +* @type {Object} +*/ +var config = { + 'input_dtypes': 'numeric_and_generic', + 'output_dtypes': 'numeric_and_generic', + 'excluded_dtypes': [ 'float16', 'uint8c' ] +}; + + +// EXPORTS // + +module.exports = config; 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..04646c87bcc0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js @@ -0,0 +1,289 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var currentYear = require( '@stdlib/time/current-year' ); +var generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// FUNCTIONS // + +/** +* Groups matches by input data type and returns grouped data, input types, and reordered matches. +* +* @private +* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @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'; + } + } + + // Add blank line between input type groups ( except for the last one )... + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\n'; + return jsOut; +} + +/** +* Generates the addon.c file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @param {string} basePkg - base package name +* @returns {string} addon.c file content +*/ +function generateAddonFile( matches, header, basePkg ) { + var uniqueIncludes; + var functionIndex; + var outputTypes; + var 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 ]; // Package path is at index 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 ] + ',\n'; + functionIndex += 1; + } + 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() + ',\n'; + functionIndex += 1; + } + 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 ] + ',\n'; + functionIndex += 1; + } + 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 basePkg; + var matches; + var header; + var jsOut; + var cOut; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // Extract package information: + basePkg = pkg.name.split( '/' ).pop(); + + // Generate license header: + header = licenseHeader( 'Apache-2.0', 'js', { + 'year': currentYear(), + 'copyright': 'The Stdlib Authors' + }); + header += '\n/* This is a generated file. Do not edit directly. */\n'; + + // Generate types.js: + jsOut = generateTypesFile( matches, header ); + writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( matches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js new file mode 100644 index 000000000000..0603c523c5e7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; +var rootDir = require( '@stdlib/_tools/utils/root-dir' ); +var readJSON = require( '@stdlib/fs/read-json' ).sync; + + +// VARIABLES // + +var ROOT_DIR = rootDir(); +var jsonOpts = { + 'encoding': 'utf8' +}; + + +// FUNCTIONS // + +/** +* Returns the input and output dtypes for a given package by reading scaffold metadata. +* +* @private +* @param {string} pkgPath - package path +* @returns {Array} input and output dtypes +* +* @example +* var dtypes = getDtypes( '@stdlib/math/base/special/sqrt' ); +* // returns [ 'float64', 'float64' ] +* +* @example +* var dtypes = getDtypes( '@stdlib/math/base/special/sqrtf' ); +* // returns [ 'float32', 'float32' ] +*/ +function getDtypes( pkgPath ) { + var packageJsonPath; + var outputDtype; + var inputDtype; + var path; + var json; + var pkg; + var out; + var o; + + // Find the package using the full package path: + packageJsonPath = pkgPath.replace('@stdlib/', '') + '/package.json'; + pkg = findPkgs({ + 'dir': ROOT_DIR, + 'pattern': '**/' + packageJsonPath + }); + + if ( pkg.length === 0 ) { + return []; + } + + // Get the metadata: + path = resolve( ROOT_DIR, pkg[ 0 ] ); + json = readJSON( resolve( path, 'package.json' ), jsonOpts ); + o = json.__stdlib__; // eslint-disable-line no-underscore-dangle + if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { + out = o.scaffold; + } + + // Extract input and output dtypes: + inputDtype = out.parameters[ 0 ].type.dtype; + outputDtype = out.returns.type.dtype; + + return [ inputDtype, outputDtype ]; +} + + +// EXPORTS // + +module.exports = getDtypes; diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js b/lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js new file mode 100644 index 000000000000..74a3929877f2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js @@ -0,0 +1,178 @@ +/** +* @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 dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); +var format = require( '@stdlib/string/format' ); +var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); + + +// FUNCTIONS // + +/** +* Maps dtype pairs to appropriate scalar functions. +* +* ## Note +* +* - The function returns an array with the following structure: +* +* ```text +* --------------------------------------------------------------------------------- +* Array: | kernel | cFunc | ndarrayKernel | match | +* --------------------------------------------------------------------------------- +* | | | | +* | | | | +* V V V V +* Example: '@stdlib/math/base/ 'stdlib_base_sqrt' 'stdlib_ndarray_ ['float64', +* special/sqrt' f_d_as_d_d' 'float64'] +* ``` +* +* @private +* @param {Array} iopair - input-output dtype pair +* @param {Array} iodt - array of available scalar kernel dtypes +* @param {Object} scalarKernels - scalar kernels object +* @returns {Array} mapping result +* +* @example +* var iopair = [ 'float32', 'float64' ]; +* var iodt = [ +* [ 'float32', 'float32' ], +* [ 'float64', 'float64' ] +* ]; +* var scalarKernels = { +* 'float32': '@stdlib/math/base/special/sqrtf', +* 'float64': '@stdlib/math/base/special/sqrt' +* }; +* +* var result = mapToScalarKernel( iopair, iodt, scalarKernels ); +* // returns [ '@stdlib/math/base/special/sqrt', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d', [ 'float64', 'float64' ] ] +*/ +function mapToScalarKernel( iopair, iodt, scalarKernels ) { + var ndarrayKernel; + var precision1; + var precision2; + var matchChar1; + var matchChar2; + var outputChar; + var cFuncName; + var inputChar; + var kernel; + var match; + var dtype; + var i; + + inputChar = dtypeChar( iopair[ 0 ] ); + outputChar = dtypeChar( iopair[ 1 ] ); + + // For generic input, always use highest precision kernel + if ( iopair[ 0 ] === 'generic' ) { + kernel = scalarKernels.float64 || scalarKernels.generic; + cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); + ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_d_d', inputChar, outputChar ); + + return [ kernel, cFuncName, ndarrayKernel, [ 'float64', 'float64' ] ]; + } + + // Priority 1: Look for exact match in available scalar kernel dtypes: + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 0 ] && + iodt[ i ][ 1 ] === iopair[ 1 ] ) { + match = iodt[ i ]; + break; + } + } + + // Priority 2: Look for higher precision matches to break ties: + if ( !match ) { + /* + * Always prefer computing at higher precision: + * - For cases like ['float32', 'float64'], prefer computing at float64: f_d_as_d_d + * - For cases like ['int8', 'float32'], prefer computing at float32: s_f_as_f_f + */ + + // Get higher precision dtype using hierarchy table: + if ( iopair[ 0 ] === iopair[ 1 ] ) { + dtype = iopair[ 0 ]; + } else { + precision1 = DTYPE_HIERARCHY[ iopair[ 0 ] ] || 0; + precision2 = DTYPE_HIERARCHY[ iopair[ 1 ] ] || 0; + dtype = ( precision2 > precision1 ) ? iopair[ 1 ] : iopair[ 0 ]; + } + + // First try: Look for (higher_precision_dtype, higher_precision_dtype)... + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === dtype && iodt[ i ][ 1 ] === dtype ) { + match = iodt[ i ]; + break; + } + } + + // Second try: Look for (input_dtype, input_dtype) if higher precision not found... + if ( !match ) { + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 0 ] && + iodt[ i ][ 1 ] === iopair[ 0 ] ) { + match = iodt[ i ]; + break; + } + } + } + + // Third try: Look for (output_dtype, output_dtype)... + if ( !match ) { + for ( i = 0; i < iodt.length; i++ ) { + if ( iodt[ i ][ 0 ] === iopair[ 1 ] && + iodt[ i ][ 1 ] === iopair[ 1 ] ) { + match = iodt[ i ]; + break; + } + } + } + } + + if ( match ) { + // Get the scalar kernel package + kernel = scalarKernels[ match[ 1 ] ]; + + // Generate C function name + cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); + + // Generate ndarray kernel name + if ( match[ 0 ] === iopair[ 0 ] && match[ 1 ] === iopair[ 1 ] ) { + // Exact match + ndarrayKernel = format( 'stdlib_ndarray_%s_%s', inputChar, outputChar ); + } else { + // Promotion case + matchChar1 = dtypeChar( match[ 0 ] ); + matchChar2 = dtypeChar( match[ 1 ] ); + ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', inputChar, outputChar, matchChar1, matchChar2 ); + } + + return [ kernel, cFuncName, ndarrayKernel, match ]; + } + + return []; +} + + +// EXPORTS // + +module.exports = mapToScalarKernel; 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..552490d4813c --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -0,0 +1,269 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var basename = require( 'path' ).basename; +var join = require( 'path' ).join; +var db = require( '@stdlib/math/special/scripts/function_database.json' ); +var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var dtypes = require( '@stdlib/ndarray/dtypes' ); +var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); +var NDARRAY_KERNELS = require( '@stdlib/ndarray/base/unary/data/function_list.json' ); +var mapToScalarKernel = require( './map_to_scalar_kernel.js' ); +var getDtypes = require( './get_dtypes.js' ); +var config = require( './config.js' ); + + +// VARIABLES // + +var DTYPES = {}; +var basePkg = basename( join( __dirname, '..' ) ); + + +// MAIN // + +/** +* Main execution sequence. +* +* ## Note +* +* - The function generates an array of matches, where each match is an array of the following format: +* +* ```text +* ---------------------------------------------------------------------------------------------------------------------------------------- +* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | +* ---------------------------------------------------------------------------------------------------------------------------------------- +* | | | | | | | | +* | | | | | | | | +* V V | V V V | V +* Example: 'float32' 'float64' | true 'float64' 'float64' | 'stdlib_ndarray_f_d_as_d_d' +* V V +* '@stdlib/math/base/special/sqrt' 'stdlib_base_sqrt' +* ``` +* +* @private +* @returns {Array} array of mappings +*/ +function main() { + var outputPrecision; + var outputIsComplex; + var needsPromotion; + var inputIsComplex; + var inputPrecision; + var outputDtype; + var inputDtype; + var filtered = []; + var mappings; + var kernels = []; + var iopairs; + var mapping; + var iodt = []; + var seen = {}; + var odt; + var idt; + var out; + var obj; + var dt; + var k; + var i; + + // Resolve list of input dtypes: + idt = dtypes( config.input_dtypes ); + filtered = []; + for ( i = 0; i < idt.length; i++ ) { + if ( config.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { // Exclude irrelevant dtypes + filtered.push( idt[ i ] ); + } + } + idt = filtered; + + /* + For example, we'll have: + idt = [ + 'float32', + 'float64', + 'int16', + 'int32', + 'int8', + 'uint16', + 'uint32', + 'uint8', + 'generic' + ] + */ + + // Resolve the list of output dtypes: + odt = dtypes( config.output_dtypes ); + filtered = []; + for ( i = 0; i < odt.length; i++ ) { + if ( config.excluded_dtypes.indexOf( odt[ i ] ) === -1 ) { // Exclude irrelevant dtypes + filtered.push( odt[ i ] ); + } + } + odt = filtered; + + /* + For example, we'll have: + odt = [ + 'float32', + 'float64' + ] + */ + + // Computing the Cartesian product of input and output dtypes: + iopairs = cartesianProduct( idt, odt ); + + /* + For example, we'll have: + iopairs = [ + [ 'float32', 'float32' ], + [ 'float32', 'float64' ], + [ 'float64', 'float32' ], + [ 'float64', 'float64' ], + ... + ] + */ + + // Filter based on dtype hierarchy and type compatibility: + for ( i = 0; i < iopairs.length; i++ ) { + inputDtype = iopairs[ i ][ 0 ]; + outputDtype = iopairs[ i ][ 1 ]; + inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; + outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; + + // Check if dtypes are compatible (real with real, complex with complex): + inputIsComplex = inputDtype.indexOf( 'complex' ) !== -1; + outputIsComplex = outputDtype.indexOf( 'complex' ) !== -1; + + /* Allow pairing only if: + 1. Same dtype + 2. Generic input + 3. Both are real dtypes with valid precision hierarchy + 4. Both are complex dtypes with valid precision hierarchy + */ + if ( inputDtype === outputDtype || + inputDtype === 'generic' || + ( !inputIsComplex && !outputIsComplex && outputPrecision >= inputPrecision ) || + ( inputIsComplex && outputIsComplex && outputPrecision >= inputPrecision ) ) { + filtered.push( iopairs[ i ] ); + } + } + iopairs = filtered; + + /* + For example, we'll have: + iopairs = [ + [ 'float32', 'float32' ], + [ 'float32', 'float64' ], + [ 'float64', 'float64' ], + ... + ] + */ + + // Get the list of dtypes with scalar math kernels: + obj = db[ basePkg ]; + + /* + For example, we'll have: + obj = { + "input_dtypes": "real_and_generic", + "output_dtypes": "real_floating_point", + "output_policy": "real_floating_point", + "scalar_kernels": { + "float32": "@stdlib/math/base/special/sqrtf", + "float64": "@stdlib/math/base/special/sqrt", + "generic": "@stdlib/math/base/special/sqrt" + } + } + */ + + /* + Available scalar kernel dtypes: + objectKeys( obj.scalar_kernels ) = [ + 'float32', + 'float64' + ] + */ + + // Build a list of scalar kernels based on output dtype: + for ( i = 0; iopairs && i < iopairs.length; i++ ) { + out = iopairs[ i ][ 1 ]; + + // For generic input, always use highest precision kernel: + if ( iopairs[ i ][ 0 ] === 'generic' ) { + k = obj.scalar_kernels.float64 || obj.scalar_kernels.generic; + } else { + k = obj.scalar_kernels[ out ] || obj.scalar_kernels.generic; + } + + if ( k && !seen[ k ] ) { + seen[ k ] = true; + kernels.push( k ); + } + } + + // Resolve the input-output dtypes for each unique scalar kernel: + iodt = []; + for ( i = 0; i < kernels.length; i++ ) { + if ( DTYPES[ kernels[ i ] ] ) { + iodt.push( DTYPES[ kernels[ i ] ] ); + continue; + } + dt = getDtypes( kernels[ i ] ); + DTYPES[ kernels[ i ] ] = dt; + iodt.push( dt ); + } + + // Map dtype pairs to appropriate scalar functions based on prioritization rules: + mappings = []; + for ( i = 0; i < iopairs.length; i++ ) { + mapping = mapToScalarKernel( iopairs[ i ], iodt, obj.scalar_kernels ); + if ( mapping && mapping.length === 4 ) { + // Verify that the ndarray kernel exists in the function list + if ( NDARRAY_KERNELS.indexOf( mapping[ 2 ] ) !== -1 ) { + // Check if promotion is needed... + needsPromotion = mapping[ 3 ][ 0 ] !== iopairs[ i ][ 0 ] || + mapping[ 3 ][ 1 ] !== iopairs[ i ][ 1 ]; + + // [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ]... + mappings.push([ iopairs[ i ][ 0 ], iopairs[ i ][ 1 ], mapping[ 0 ], needsPromotion, ( needsPromotion ) ? mapping[ 3 ][ 0 ] : null, ( needsPromotion ) ? mapping[ 3 ][ 1 ] : null, mapping[ 1 ], mapping[ 2 ] ]); // eslint-disable-line max-len + } + } + } + + /* + For example, we'll have: + mappings = [ + [ 'int8', 'float32', '@stdlib/math/base/special/sqrtf', true, 'float32', 'float32', 'stdlib_base_sqrtf', 'stdlib_ndarray_s_f_as_f_f' ], + [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf', false, null, null, 'stdlib_base_sqrtf', 'stdlib_ndarray_f_f' ], + [ 'float32', 'float64', '@stdlib/math/base/special/sqrt', true, 'float64', 'float64', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d' ], + [ 'float64', 'float64', '@stdlib/math/base/special/sqrt', false, null, null, 'stdlib_base_sqrt', 'stdlib_ndarray_d_d' ], + ... + ] + */ + + 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..dcc6bc062676 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/floor/src/addon.c @@ -0,0 +1,231 @@ +/** +* @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/cfloorf.h" +#include "stdlib/math/base/special/cfloor.h" +#include "stdlib/math/base/special/floorf.h" +#include "stdlib/math/base/special/floor.h" +#include "stdlib/number/int16/base/identity.h" +#include "stdlib/number/int32/base/identity.h" +#include "stdlib/number/int8/base/identity.h" +#include "stdlib/number/uint16/base/identity.h" +#include "stdlib/number/uint32/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_c, + stdlib_ndarray_c_z_as_z_z, + + // complex128 (1) + stdlib_ndarray_z_z, + + // float32 (2) + stdlib_ndarray_f_f, + stdlib_ndarray_f_d_as_d_d, + + // float64 (1) + stdlib_ndarray_d_d, + + // int16 (4) + stdlib_ndarray_k_f_as_f_f, + stdlib_ndarray_k_d_as_d_d, + stdlib_ndarray_k_k, + stdlib_ndarray_k_i_as_i_i, + + // int32 (2) + stdlib_ndarray_i_d_as_d_d, + stdlib_ndarray_i_i, + + // int8 (5) + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_d_as_d_d, + stdlib_ndarray_s_k_as_k_k, + stdlib_ndarray_s_i_as_i_i, + stdlib_ndarray_s_s, + + // uint16 (5) + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_d_as_d_d, + stdlib_ndarray_t_i_as_i_i, + stdlib_ndarray_t_t, + stdlib_ndarray_t_u_as_u_u, + + // uint32 (2) + stdlib_ndarray_u_d_as_d_d, + stdlib_ndarray_u_u, + + // uint8 (7) + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_d_as_d_d, + stdlib_ndarray_b_k_as_k_k, + stdlib_ndarray_b_i_as_i_i, + stdlib_ndarray_b_t_as_t_t, + stdlib_ndarray_b_u_as_u_u, + stdlib_ndarray_b_b, + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // complex64 (2) + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, + + // complex128 (1) + STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX128, + + // float32 (2) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + + // float64 (1) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + + // int16 (4) + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT32, + + // int32 (2) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, + + // int8 (5) + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT8, + + // uint16 (5) + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT32, + + // uint32 (2) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, + + // uint8 (7) + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT8, + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // complex64 (2) + (void *)stdlib_base_cfloorf, + (void *)stdlib_base_cfloor, + + // complex128 (1) + (void *)stdlib_base_cfloor, + + // float32 (2) + (void *)stdlib_base_floorf, + (void *)stdlib_base_floor, + + // float64 (1) + (void *)stdlib_base_floor, + + // int16 (4) + (void *)stdlib_base_floorf, + (void *)stdlib_base_floor, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + + // int32 (2) + (void *)stdlib_base_floor, + (void *)stdlib_base_identity, + + // int8 (5) + (void *)stdlib_base_floorf, + (void *)stdlib_base_floor, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + + // uint16 (5) + (void *)stdlib_base_floorf, + (void *)stdlib_base_floor, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + + // uint32 (2) + (void *)stdlib_base_floor, + (void *)stdlib_base_identity, + + // uint8 (7) + (void *)stdlib_base_floorf, + (void *)stdlib_base_floor, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + (void *)stdlib_base_identity, + +}; + +// 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: + 31, + + // 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/dtype_hierarchy.js b/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js index 90799c47f3ac..f3b32d27eb16 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js +++ b/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js @@ -34,7 +34,9 @@ var DTYPE_HIERARCHY = { 'uint32': 3, 'float32': 4, 'float64': 5, - 'generic': 6 + 'complex64': 6, + 'complex128': 7, + 'generic': 8 }; diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index 7df060a5803d..b1da1f570eb8 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -18,6 +18,24 @@ "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", + "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" + } } } 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 index 7828f33b516f..95dac3531db5 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -140,7 +140,8 @@ function generateAddonFile( matches, header, basePkg ) { var uniqueIncludes; var functionIndex; var outputTypes; - var includeKey; + var includePath; + var kernelPath; var inputType; var grouped; var result; @@ -151,8 +152,11 @@ function generateAddonFile( matches, header, basePkg ) { // Generate unique includes... uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { - includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); - uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; + // Extract the full package path from the scalar kernel path: + kernelPath = matches[ i ][ 2 ]; // Package path is at index 2 + + includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; + uniqueIncludes[ '#include "' + includePath + '"' ] = true; } // Group matches by input type... diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js index f961d1011401..0603c523c5e7 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js @@ -52,22 +52,20 @@ var jsonOpts = { * // returns [ 'float32', 'float32' ] */ function getDtypes( pkgPath ) { + var packageJsonPath; var outputDtype; var inputDtype; - var aliasName; var path; var json; var pkg; var out; var o; - // Extract alias name from package path: - aliasName = pkgPath.split( '/' ).pop(); - - // Find the package: + // Find the package using the full package path: + packageJsonPath = pkgPath.replace('@stdlib/', '') + '/package.json'; pkg = findPkgs({ 'dir': ROOT_DIR, - 'pattern': '**/math/base/special/' + aliasName + '/package.json' // Currently we are looking only in `math/base/special/` + 'pattern': '**/' + packageJsonPath }); if ( pkg.length === 0 ) { diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js index 99d479a116d9..552490d4813c 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js @@ -64,7 +64,9 @@ var basePkg = basename( join( __dirname, '..' ) ); */ function main() { var outputPrecision; + var outputIsComplex; var needsPromotion; + var inputIsComplex; var inputPrecision; var outputDtype; var inputDtype; @@ -140,15 +142,27 @@ function main() { ] */ - // Filter based on dtype hierarchy: + // Filter based on dtype hierarchy and type compatibility: for ( i = 0; i < iopairs.length; i++ ) { inputDtype = iopairs[ i ][ 0 ]; outputDtype = iopairs[ i ][ 1 ]; inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; - // Only allow upcasts (higher or equal precision) or same dtype or generic source: - if ( inputDtype === outputDtype || inputDtype === 'generic' || outputPrecision >= inputPrecision ) { + // Check if dtypes are compatible (real with real, complex with complex): + inputIsComplex = inputDtype.indexOf( 'complex' ) !== -1; + outputIsComplex = outputDtype.indexOf( 'complex' ) !== -1; + + /* Allow pairing only if: + 1. Same dtype + 2. Generic input + 3. Both are real dtypes with valid precision hierarchy + 4. Both are complex dtypes with valid precision hierarchy + */ + if ( inputDtype === outputDtype || + inputDtype === 'generic' || + ( !inputIsComplex && !outputIsComplex && outputPrecision >= inputPrecision ) || + ( inputIsComplex && outputIsComplex && outputPrecision >= inputPrecision ) ) { filtered.push( iopairs[ i ] ); } } 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 index 7828f33b516f..95dac3531db5 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -140,7 +140,8 @@ function generateAddonFile( matches, header, basePkg ) { var uniqueIncludes; var functionIndex; var outputTypes; - var includeKey; + var includePath; + var kernelPath; var inputType; var grouped; var result; @@ -151,8 +152,11 @@ function generateAddonFile( matches, header, basePkg ) { // Generate unique includes... uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { - includeKey = matches[ i ][ 6 ].replace( 'stdlib_base_', '' ); - uniqueIncludes[ '#include "stdlib/math/base/special/' + includeKey + '.h"' ] = true; + // Extract the full package path from the scalar kernel path: + kernelPath = matches[ i ][ 2 ]; // Package path is at index 2 + + includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; + uniqueIncludes[ '#include "' + includePath + '"' ] = true; } // Group matches by input type... diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js index f961d1011401..0603c523c5e7 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js @@ -52,22 +52,20 @@ var jsonOpts = { * // returns [ 'float32', 'float32' ] */ function getDtypes( pkgPath ) { + var packageJsonPath; var outputDtype; var inputDtype; - var aliasName; var path; var json; var pkg; var out; var o; - // Extract alias name from package path: - aliasName = pkgPath.split( '/' ).pop(); - - // Find the package: + // Find the package using the full package path: + packageJsonPath = pkgPath.replace('@stdlib/', '') + '/package.json'; pkg = findPkgs({ 'dir': ROOT_DIR, - 'pattern': '**/math/base/special/' + aliasName + '/package.json' // Currently we are looking only in `math/base/special/` + 'pattern': '**/' + packageJsonPath }); if ( pkg.length === 0 ) { diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js index 99d479a116d9..552490d4813c 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -64,7 +64,9 @@ var basePkg = basename( join( __dirname, '..' ) ); */ function main() { var outputPrecision; + var outputIsComplex; var needsPromotion; + var inputIsComplex; var inputPrecision; var outputDtype; var inputDtype; @@ -140,15 +142,27 @@ function main() { ] */ - // Filter based on dtype hierarchy: + // Filter based on dtype hierarchy and type compatibility: for ( i = 0; i < iopairs.length; i++ ) { inputDtype = iopairs[ i ][ 0 ]; outputDtype = iopairs[ i ][ 1 ]; inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; - // Only allow upcasts (higher or equal precision) or same dtype or generic source: - if ( inputDtype === outputDtype || inputDtype === 'generic' || outputPrecision >= inputPrecision ) { + // Check if dtypes are compatible (real with real, complex with complex): + inputIsComplex = inputDtype.indexOf( 'complex' ) !== -1; + outputIsComplex = outputDtype.indexOf( 'complex' ) !== -1; + + /* Allow pairing only if: + 1. Same dtype + 2. Generic input + 3. Both are real dtypes with valid precision hierarchy + 4. Both are complex dtypes with valid precision hierarchy + */ + if ( inputDtype === outputDtype || + inputDtype === 'generic' || + ( !inputIsComplex && !outputIsComplex && outputPrecision >= inputPrecision ) || + ( inputIsComplex && outputIsComplex && outputPrecision >= inputPrecision ) ) { filtered.push( iopairs[ i ] ); } } 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" + } + } + } + } } From 030c100bdf336f01a0646e4d9b4341fdec7ac94f Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Thu, 14 Aug 2025 10:10:46 +0530 Subject: [PATCH 15/31] docs: revert unwanted changes in package.json --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/sqrtf/package.json | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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 54a8bc407a66..7bd0c208a276 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/sqrtf/package.json @@ -1,7 +1,7 @@ { - "name": "@stdlib/math/base/special/cceil", + "name": "@stdlib/math/base/special/sqrtf", "version": "0.0.0", - "description": "Round each component of a double-precision complex floating-point number toward positive infinity.", + "description": "Compute the principal square root of a single-precision floating-point number.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -56,15 +56,12 @@ "stdmath", "mathematics", "math", - "math.ceil", - "ceil", - "cceil", - "round", - "integer", - "nearest", - "value", - "complex", - "cmplx", + "math.sqrtf", + "sqrtf", + "principal", + "square", + "root", + "power", "number" ],"__stdlib__": { "scaffold": { From 9d211a70804c4689376667830a70e6d2491d6866 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 19 Aug 2025 11:37:03 +0530 Subject: [PATCH 16/31] refactor: modify script --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/special/floor/lib/types.js | 83 +++- .../math/special/floor/scripts/config.js | 38 -- .../math/special/floor/scripts/get_dtypes.js | 93 ---- .../floor/scripts/map_to_scalar_kernel.js | 178 -------- .../math/special/floor/scripts/script.js | 416 ++++++++++-------- .../@stdlib/math/special/floor/src/addon.c | 311 +++++++++---- .../math/special/scripts/dtypes_database.json | 114 +++++ .../special/scripts/function_database.json | 3 + .../scripts/generate_dtypes_database.js | 164 +++++++ 9 files changed, 784 insertions(+), 616 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/config.js delete mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js delete mode 100644 lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js create mode 100644 lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json create mode 100644 lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/types.js b/lib/node_modules/@stdlib/math/special/floor/lib/types.js index 846808e0ef84..fe1764d0f49e 100644 --- a/lib/node_modules/@stdlib/math/special/floor/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/floor/lib/types.js @@ -30,56 +30,95 @@ var dtypes = require( '@stdlib/ndarray/dtypes' ); // MAIN // var types = [ - // complex64 (2) - dtypes.complex64, dtypes.complex64, + // complex64 (3) dtypes.complex64, dtypes.complex128, + dtypes.complex64, dtypes.complex64, + dtypes.complex64, dtypes.generic, - // complex128 (1) + // complex128 (3) dtypes.complex128, dtypes.complex128, + dtypes.complex128, dtypes.complex64, + dtypes.complex128, dtypes.generic, - // float32 (2) - dtypes.float32, dtypes.float32, + // float32 (5) dtypes.float32, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.complex128, + dtypes.float32, dtypes.complex64, + dtypes.float32, dtypes.generic, - // float64 (1) + // float64 (5) dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.complex128, + dtypes.float64, dtypes.complex64, + dtypes.float64, dtypes.generic, - // int16 (4) - dtypes.int16, dtypes.float32, + // int16 (8) dtypes.int16, dtypes.float64, - dtypes.int16, dtypes.int16, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.int64, dtypes.int16, dtypes.int32, + dtypes.int16, dtypes.int16, + dtypes.int16, dtypes.complex128, + dtypes.int16, dtypes.complex64, + dtypes.int16, dtypes.generic, - // int32 (2) + // int32 (5) dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.int64, dtypes.int32, dtypes.int32, + dtypes.int32, dtypes.complex128, + dtypes.int32, dtypes.generic, - // int8 (5) - dtypes.int8, dtypes.float32, + // int8 (9) dtypes.int8, dtypes.float64, - dtypes.int8, dtypes.int16, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.int64, 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 (5) - dtypes.uint16, dtypes.float32, + // uint16 (10) dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.int64, dtypes.uint16, dtypes.int32, - dtypes.uint16, dtypes.uint16, + dtypes.uint16, dtypes.uint64, dtypes.uint16, dtypes.uint32, + dtypes.uint16, dtypes.uint16, + dtypes.uint16, dtypes.complex128, + dtypes.uint16, dtypes.complex64, + dtypes.uint16, dtypes.generic, - // uint32 (2) + // uint32 (6) dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.int64, + dtypes.uint32, dtypes.uint64, dtypes.uint32, dtypes.uint32, + dtypes.uint32, dtypes.complex128, + dtypes.uint32, dtypes.generic, - // uint8 (7) - dtypes.uint8, dtypes.float32, + // uint8 (12) dtypes.uint8, dtypes.float64, - dtypes.uint8, dtypes.int16, + dtypes.uint8, dtypes.float32, + dtypes.uint8, dtypes.int64, dtypes.uint8, dtypes.int32, - dtypes.uint8, dtypes.uint16, + dtypes.uint8, dtypes.int16, + dtypes.uint8, dtypes.uint64, dtypes.uint8, dtypes.uint32, - dtypes.uint8, dtypes.uint8 + dtypes.uint8, dtypes.uint16, + dtypes.uint8, dtypes.uint8, + dtypes.uint8, dtypes.complex128, + dtypes.uint8, dtypes.complex64, + dtypes.uint8, dtypes.generic, + + // generic (2) + dtypes.generic, dtypes.float64, + dtypes.generic, dtypes.complex128 ]; diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/config.js b/lib/node_modules/@stdlib/math/special/floor/scripts/config.js deleted file mode 100644 index 6ee8b7734c61..000000000000 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/config.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Configuration object. -* -* @private -* @type {Object} -*/ -var config = { - 'input_dtypes': 'numeric_and_generic', - 'output_dtypes': 'numeric_and_generic', - 'excluded_dtypes': [ 'float16', 'uint8c' ] -}; - - -// EXPORTS // - -module.exports = config; diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js deleted file mode 100644 index 0603c523c5e7..000000000000 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/get_dtypes.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @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 findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; -var rootDir = require( '@stdlib/_tools/utils/root-dir' ); -var readJSON = require( '@stdlib/fs/read-json' ).sync; - - -// VARIABLES // - -var ROOT_DIR = rootDir(); -var jsonOpts = { - 'encoding': 'utf8' -}; - - -// FUNCTIONS // - -/** -* Returns the input and output dtypes for a given package by reading scaffold metadata. -* -* @private -* @param {string} pkgPath - package path -* @returns {Array} input and output dtypes -* -* @example -* var dtypes = getDtypes( '@stdlib/math/base/special/sqrt' ); -* // returns [ 'float64', 'float64' ] -* -* @example -* var dtypes = getDtypes( '@stdlib/math/base/special/sqrtf' ); -* // returns [ 'float32', 'float32' ] -*/ -function getDtypes( pkgPath ) { - var packageJsonPath; - var outputDtype; - var inputDtype; - var path; - var json; - var pkg; - var out; - var o; - - // Find the package using the full package path: - packageJsonPath = pkgPath.replace('@stdlib/', '') + '/package.json'; - pkg = findPkgs({ - 'dir': ROOT_DIR, - 'pattern': '**/' + packageJsonPath - }); - - if ( pkg.length === 0 ) { - return []; - } - - // Get the metadata: - path = resolve( ROOT_DIR, pkg[ 0 ] ); - json = readJSON( resolve( path, 'package.json' ), jsonOpts ); - o = json.__stdlib__; // eslint-disable-line no-underscore-dangle - if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { - out = o.scaffold; - } - - // Extract input and output dtypes: - inputDtype = out.parameters[ 0 ].type.dtype; - outputDtype = out.returns.type.dtype; - - return [ inputDtype, outputDtype ]; -} - - -// EXPORTS // - -module.exports = getDtypes; diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js b/lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js deleted file mode 100644 index 74a3929877f2..000000000000 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/map_to_scalar_kernel.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @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 dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); -var format = require( '@stdlib/string/format' ); -var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); - - -// FUNCTIONS // - -/** -* Maps dtype pairs to appropriate scalar functions. -* -* ## Note -* -* - The function returns an array with the following structure: -* -* ```text -* --------------------------------------------------------------------------------- -* Array: | kernel | cFunc | ndarrayKernel | match | -* --------------------------------------------------------------------------------- -* | | | | -* | | | | -* V V V V -* Example: '@stdlib/math/base/ 'stdlib_base_sqrt' 'stdlib_ndarray_ ['float64', -* special/sqrt' f_d_as_d_d' 'float64'] -* ``` -* -* @private -* @param {Array} iopair - input-output dtype pair -* @param {Array} iodt - array of available scalar kernel dtypes -* @param {Object} scalarKernels - scalar kernels object -* @returns {Array} mapping result -* -* @example -* var iopair = [ 'float32', 'float64' ]; -* var iodt = [ -* [ 'float32', 'float32' ], -* [ 'float64', 'float64' ] -* ]; -* var scalarKernels = { -* 'float32': '@stdlib/math/base/special/sqrtf', -* 'float64': '@stdlib/math/base/special/sqrt' -* }; -* -* var result = mapToScalarKernel( iopair, iodt, scalarKernels ); -* // returns [ '@stdlib/math/base/special/sqrt', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d', [ 'float64', 'float64' ] ] -*/ -function mapToScalarKernel( iopair, iodt, scalarKernels ) { - var ndarrayKernel; - var precision1; - var precision2; - var matchChar1; - var matchChar2; - var outputChar; - var cFuncName; - var inputChar; - var kernel; - var match; - var dtype; - var i; - - inputChar = dtypeChar( iopair[ 0 ] ); - outputChar = dtypeChar( iopair[ 1 ] ); - - // For generic input, always use highest precision kernel - if ( iopair[ 0 ] === 'generic' ) { - kernel = scalarKernels.float64 || scalarKernels.generic; - cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); - ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_d_d', inputChar, outputChar ); - - return [ kernel, cFuncName, ndarrayKernel, [ 'float64', 'float64' ] ]; - } - - // Priority 1: Look for exact match in available scalar kernel dtypes: - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 0 ] && - iodt[ i ][ 1 ] === iopair[ 1 ] ) { - match = iodt[ i ]; - break; - } - } - - // Priority 2: Look for higher precision matches to break ties: - if ( !match ) { - /* - * Always prefer computing at higher precision: - * - For cases like ['float32', 'float64'], prefer computing at float64: f_d_as_d_d - * - For cases like ['int8', 'float32'], prefer computing at float32: s_f_as_f_f - */ - - // Get higher precision dtype using hierarchy table: - if ( iopair[ 0 ] === iopair[ 1 ] ) { - dtype = iopair[ 0 ]; - } else { - precision1 = DTYPE_HIERARCHY[ iopair[ 0 ] ] || 0; - precision2 = DTYPE_HIERARCHY[ iopair[ 1 ] ] || 0; - dtype = ( precision2 > precision1 ) ? iopair[ 1 ] : iopair[ 0 ]; - } - - // First try: Look for (higher_precision_dtype, higher_precision_dtype)... - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === dtype && iodt[ i ][ 1 ] === dtype ) { - match = iodt[ i ]; - break; - } - } - - // Second try: Look for (input_dtype, input_dtype) if higher precision not found... - if ( !match ) { - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 0 ] && - iodt[ i ][ 1 ] === iopair[ 0 ] ) { - match = iodt[ i ]; - break; - } - } - } - - // Third try: Look for (output_dtype, output_dtype)... - if ( !match ) { - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 1 ] && - iodt[ i ][ 1 ] === iopair[ 1 ] ) { - match = iodt[ i ]; - break; - } - } - } - } - - if ( match ) { - // Get the scalar kernel package - kernel = scalarKernels[ match[ 1 ] ]; - - // Generate C function name - cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); - - // Generate ndarray kernel name - if ( match[ 0 ] === iopair[ 0 ] && match[ 1 ] === iopair[ 1 ] ) { - // Exact match - ndarrayKernel = format( 'stdlib_ndarray_%s_%s', inputChar, outputChar ); - } else { - // Promotion case - matchChar1 = dtypeChar( match[ 0 ] ); - matchChar2 = dtypeChar( match[ 1 ] ); - ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', inputChar, outputChar, matchChar1, matchChar2 ); - } - - return [ kernel, cFuncName, ndarrayKernel, match ]; - } - - return []; -} - - -// EXPORTS // - -module.exports = mapToScalarKernel; diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js index 552490d4813c..51ccfa273e12 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -16,250 +16,290 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // -var basename = require( 'path' ).basename; var join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; var db = require( '@stdlib/math/special/scripts/function_database.json' ); -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var dtypesDatabase = require( '@stdlib/math/special/scripts/dtypes_database.json' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); -var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); +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' ); -var mapToScalarKernel = require( './map_to_scalar_kernel.js' ); -var getDtypes = require( './get_dtypes.js' ); -var config = require( './config.js' ); // VARIABLES // -var DTYPES = {}; -var basePkg = basename( join( __dirname, '..' ) ); +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); -// MAIN // +// FUNCTIONS // /** -* Main execution sequence. +* Selects the appropriate scalar kernel based on input and output dtypes. * -* ## Note +* @private +* @param {Object} scalarKernels - available scalar kernels +* @param {string} outputDtype - output dtype +* @param {string} inputDtype - input dtype +* @returns {string} scalar kernel name * -* - The function generates an array of matches, where each match is an array of the following format: +* @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 { + // 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. * -* ```text -* ---------------------------------------------------------------------------------------------------------------------------------------- -* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | -* ---------------------------------------------------------------------------------------------------------------------------------------- -* | | | | | | | | -* | | | | | | | | -* V V | V V V | V -* Example: 'float32' 'float64' | true 'float64' 'float64' | 'stdlib_ndarray_f_d_as_d_d' -* V V -* '@stdlib/math/base/special/sqrt' 'stdlib_base_sqrt' -* ``` +* @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 = dtypesDatabase[ scalarKernel ].input[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].input[ 0 ] => 'complex64' + scalarKernelOutputDtype = dtypesDatabase[ scalarKernel ].output[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].output[ 0 ] => '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 outputPrecision; - var outputIsComplex; var needsPromotion; - var inputIsComplex; - var inputPrecision; + var cFunctionName; + var allowedCasts; + var scalarKernel; var outputDtype; var inputDtype; - var filtered = []; + var kernelName; var mappings; - var kernels = []; - var iopairs; - var mapping; - var iodt = []; - var seen = {}; - var odt; - var idt; - var out; + var filtered; var obj; - var dt; - var k; + var idt; var i; + var j; - // Resolve list of input dtypes: - idt = dtypes( config.input_dtypes ); - filtered = []; - for ( i = 0; i < idt.length; i++ ) { - if ( config.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { // Exclude irrelevant dtypes - filtered.push( idt[ i ] ); - } - } - idt = filtered; - - /* - For example, we'll have: - idt = [ - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'generic' - ] - */ + mappings = []; - // Resolve the list of output dtypes: - odt = dtypes( config.output_dtypes ); - filtered = []; - for ( i = 0; i < odt.length; i++ ) { - if ( config.excluded_dtypes.indexOf( odt[ i ] ) === -1 ) { // Exclude irrelevant dtypes - filtered.push( odt[ i ] ); - } - } - odt = filtered; + // Get scalar kernels and configuration for this function: + obj = db[ basePkg ]; /* - For example, we'll have: - odt = [ - 'float32', - 'float64' - ] + * 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" + * } + * } */ - // Computing the Cartesian product of input and output dtypes: - iopairs = cartesianProduct( idt, odt ); + // Get input dtypes: + idt = dtypes( obj.input_dtypes ); /* - For example, we'll have: - iopairs = [ - [ 'float32', 'float32' ], - [ 'float32', 'float64' ], - [ 'float64', 'float32' ], - [ 'float64', 'float64' ], - ... - ] + * idt = [ + * 'complex32', + * 'complex64', + * 'complex128', + * 'float16', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'uint8c', + * 'generic' + * ] */ - // Filter based on dtype hierarchy and type compatibility: - for ( i = 0; i < iopairs.length; i++ ) { - inputDtype = iopairs[ i ][ 0 ]; - outputDtype = iopairs[ i ][ 1 ]; - inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; - outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; - - // Check if dtypes are compatible (real with real, complex with complex): - inputIsComplex = inputDtype.indexOf( 'complex' ) !== -1; - outputIsComplex = outputDtype.indexOf( 'complex' ) !== -1; - - /* Allow pairing only if: - 1. Same dtype - 2. Generic input - 3. Both are real dtypes with valid precision hierarchy - 4. Both are complex dtypes with valid precision hierarchy - */ - if ( inputDtype === outputDtype || - inputDtype === 'generic' || - ( !inputIsComplex && !outputIsComplex && outputPrecision >= inputPrecision ) || - ( inputIsComplex && outputIsComplex && outputPrecision >= inputPrecision ) ) { - filtered.push( iopairs[ i ] ); + // Filter out excluded dtypes: + filtered = []; + for ( i = 0; i < idt.length; i++ ) { + if ( obj.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { + filtered.push( idt[ i ] ); } } - iopairs = filtered; - - /* - For example, we'll have: - iopairs = [ - [ 'float32', 'float32' ], - [ 'float32', 'float64' ], - [ 'float64', 'float64' ], - ... - ] - */ - - // Get the list of dtypes with scalar math kernels: - obj = db[ basePkg ]; + idt = filtered; /* - For example, we'll have: - obj = { - "input_dtypes": "real_and_generic", - "output_dtypes": "real_floating_point", - "output_policy": "real_floating_point", - "scalar_kernels": { - "float32": "@stdlib/math/base/special/sqrtf", - "float64": "@stdlib/math/base/special/sqrt", - "generic": "@stdlib/math/base/special/sqrt" - } - } + * idt = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'generic' + * ] */ - /* - Available scalar kernel dtypes: - objectKeys( obj.scalar_kernels ) = [ - 'float32', - 'float64' - ] - */ + // Generate all mostly-safe cast combinations: + for ( i = 0; i < idt.length; i++ ) { + inputDtype = idt[ i ]; - // Build a list of scalar kernels based on output dtype: - for ( i = 0; iopairs && i < iopairs.length; i++ ) { - out = iopairs[ i ][ 1 ]; + /* + * For the first iteration: + * + * inputDtype = 'complex64' + */ - // For generic input, always use highest precision kernel: - if ( iopairs[ i ][ 0 ] === 'generic' ) { - k = obj.scalar_kernels.float64 || obj.scalar_kernels.generic; + if ( inputDtype === 'generic' ) { + // For generic input, generate mappings to highest precision dtypes: + allowedCasts = [ 'float64', 'complex128' ]; } else { - k = obj.scalar_kernels[ out ] || obj.scalar_kernels.generic; - } - - if ( k && !seen[ k ] ) { - seen[ k ] = true; - kernels.push( k ); + // Get all dtypes this input can be mostly-safely cast to: + allowedCasts = mostlySafeCasts( inputDtype ); + + /* + * For the first iteration: + * + * allowedCasts = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64' + * ] + */ } - } - // Resolve the input-output dtypes for each unique scalar kernel: - iodt = []; - for ( i = 0; i < kernels.length; i++ ) { - if ( DTYPES[ kernels[ i ] ] ) { - iodt.push( DTYPES[ kernels[ i ] ] ); - continue; - } - dt = getDtypes( kernels[ i ] ); - DTYPES[ kernels[ i ] ] = dt; - iodt.push( dt ); - } + for ( j = 0; j < allowedCasts.length; j++ ) { + outputDtype = allowedCasts[ j ]; - // Map dtype pairs to appropriate scalar functions based on prioritization rules: - mappings = []; - for ( i = 0; i < iopairs.length; i++ ) { - mapping = mapToScalarKernel( iopairs[ i ], iodt, obj.scalar_kernels ); - if ( mapping && mapping.length === 4 ) { - // Verify that the ndarray kernel exists in the function list - if ( NDARRAY_KERNELS.indexOf( mapping[ 2 ] ) !== -1 ) { - // Check if promotion is needed... - needsPromotion = mapping[ 3 ][ 0 ] !== iopairs[ i ][ 0 ] || - mapping[ 3 ][ 1 ] !== iopairs[ i ][ 1 ]; - - // [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ]... - mappings.push([ iopairs[ i ][ 0 ], iopairs[ i ][ 1 ], mapping[ 0 ], needsPromotion, ( needsPromotion ) ? mapping[ 3 ][ 0 ] : null, ( needsPromotion ) ? mapping[ 3 ][ 1 ] : null, mapping[ 1 ], mapping[ 2 ] ]); // eslint-disable-line max-len + 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 + ]); } } - /* - For example, we'll have: - mappings = [ - [ 'int8', 'float32', '@stdlib/math/base/special/sqrtf', true, 'float32', 'float32', 'stdlib_base_sqrtf', 'stdlib_ndarray_s_f_as_f_f' ], - [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf', false, null, null, 'stdlib_base_sqrtf', 'stdlib_ndarray_f_f' ], - [ 'float32', 'float64', '@stdlib/math/base/special/sqrt', true, 'float64', 'float64', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d' ], - [ 'float64', 'float64', '@stdlib/math/base/special/sqrt', false, null, null, 'stdlib_base_sqrt', 'stdlib_ndarray_d_d' ], - ... - ] - */ - return mappings; } diff --git a/lib/node_modules/@stdlib/math/special/floor/src/addon.c b/lib/node_modules/@stdlib/math/special/floor/src/addon.c index dcc6bc062676..7a08e0656bb2 100644 --- a/lib/node_modules/@stdlib/math/special/floor/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/floor/src/addon.c @@ -17,15 +17,15 @@ */ /* This is a generated file. Do not edit directly. */ -#include "stdlib/math/base/special/cfloorf.h" #include "stdlib/math/base/special/cfloor.h" -#include "stdlib/math/base/special/floorf.h" +#include "stdlib/math/base/special/cfloorf.h" #include "stdlib/math/base/special/floor.h" -#include "stdlib/number/int16/base/identity.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/uint16/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" @@ -38,166 +38,283 @@ static const char name[] = "stdlib_ndarray_floor"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { - // complex64 (2) - stdlib_ndarray_c_c, + // complex64 (3) stdlib_ndarray_c_z_as_z_z, + stdlib_ndarray_c_c, + stdlib_ndarray_c_o_as_d_d, - // complex128 (1) + // complex128 (3) stdlib_ndarray_z_z, + stdlib_ndarray_z_c_as_z_z, + stdlib_ndarray_z_o_as_d_d, - // float32 (2) - stdlib_ndarray_f_f, + // float32 (5) 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, + stdlib_ndarray_f_o_as_d_d, - // float64 (1) + // float64 (5) 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, + stdlib_ndarray_d_o_as_d_d, - // int16 (4) - stdlib_ndarray_k_f_as_f_f, + // int16 (8) stdlib_ndarray_k_d_as_d_d, - stdlib_ndarray_k_k, + stdlib_ndarray_k_f_as_f_f, + stdlib_ndarray_k_l_as_d_d, 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, + stdlib_ndarray_k_o_as_d_d, - // int32 (2) + // int32 (5) stdlib_ndarray_i_d_as_d_d, + stdlib_ndarray_i_l_as_d_d, stdlib_ndarray_i_i, + stdlib_ndarray_i_z_as_z_z, + stdlib_ndarray_i_o_as_d_d, - // int8 (5) - stdlib_ndarray_s_f_as_f_f, + // int8 (9) stdlib_ndarray_s_d_as_d_d, - stdlib_ndarray_s_k_as_k_k, + stdlib_ndarray_s_f_as_f_f, + stdlib_ndarray_s_l_as_d_d, 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, + stdlib_ndarray_s_o_as_d_d, - // uint16 (5) - stdlib_ndarray_t_f_as_f_f, + // uint16 (10) stdlib_ndarray_t_d_as_d_d, + stdlib_ndarray_t_f_as_f_f, + stdlib_ndarray_t_l_as_d_d, stdlib_ndarray_t_i_as_i_i, - stdlib_ndarray_t_t, + stdlib_ndarray_t_v_as_d_d, 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, + stdlib_ndarray_t_o_as_d_d, - // uint32 (2) + // uint32 (6) stdlib_ndarray_u_d_as_d_d, + stdlib_ndarray_u_l_as_d_d, + stdlib_ndarray_u_v_as_d_d, stdlib_ndarray_u_u, + stdlib_ndarray_u_z_as_z_z, + stdlib_ndarray_u_o_as_d_d, - // uint8 (7) - stdlib_ndarray_b_f_as_f_f, + // uint8 (12) stdlib_ndarray_b_d_as_d_d, - stdlib_ndarray_b_k_as_k_k, + stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_l_as_d_d, stdlib_ndarray_b_i_as_i_i, - stdlib_ndarray_b_t_as_t_t, + stdlib_ndarray_b_k_as_k_k, + stdlib_ndarray_b_v_as_d_d, 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, + stdlib_ndarray_b_o_as_d_d, + + // generic (2) + stdlib_ndarray_o_d_as_d_d, + stdlib_ndarray_o_z_as_z_z, }; // Define the array of input and output ndarray types: static int32_t types[] = { - // complex64 (2) - STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX64, + // complex64 (3) STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_GENERIC, - // complex128 (1) + // complex128 (3) STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_GENERIC, - // float32 (2) - STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + // float32 (5) STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_GENERIC, - // float64 (1) + // float64 (5) STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_GENERIC, - // int16 (4) - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + // int16 (8) STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_GENERIC, - // int32 (2) + // int32 (5) STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_GENERIC, - // int8 (5) - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + // int8 (9) STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT64, 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, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_GENERIC, - // uint16 (5) - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + // uint16 (10) STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT32, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT64, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_GENERIC, - // uint32 (2) + // uint32 (6) STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_INT64, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT64, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_COMPLEX128, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_GENERIC, - // uint8 (7) - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + // uint8 (12) STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT32, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT16, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT64, 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, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_GENERIC, + + // generic (2) + STDLIB_NDARRAY_GENERIC, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_GENERIC, STDLIB_NDARRAY_COMPLEX128, }; // Define a list of ndarray function "data" (in this case, callbacks): static void *data[] = { - // complex64 (2) - (void *)stdlib_base_cfloorf, - (void *)stdlib_base_cfloor, - - // complex128 (1) - (void *)stdlib_base_cfloor, - - // float32 (2) - (void *)stdlib_base_floorf, - (void *)stdlib_base_floor, - - // float64 (1) - (void *)stdlib_base_floor, - - // int16 (4) - (void *)stdlib_base_floorf, - (void *)stdlib_base_floor, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - - // int32 (2) - (void *)stdlib_base_floor, - (void *)stdlib_base_identity, - - // int8 (5) - (void *)stdlib_base_floorf, - (void *)stdlib_base_floor, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - - // uint16 (5) - (void *)stdlib_base_floorf, - (void *)stdlib_base_floor, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - - // uint32 (2) - (void *)stdlib_base_floor, - (void *)stdlib_base_identity, - - // uint8 (7) - (void *)stdlib_base_floorf, - (void *)stdlib_base_floor, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, - (void *)stdlib_base_identity, + // complex64 (3) + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + (void *)stdlib_math_base_special_floor, + + // complex128 (3) + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_floor, + + // float32 (5) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + (void *)stdlib_math_base_special_floor, + + // float64 (5) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_floor, + + // int16 (8) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_number_int16_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + (void *)stdlib_math_base_special_floor, + + // int32 (5) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_floor, + + // int8 (9) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_math_base_special_floor, + (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, + (void *)stdlib_math_base_special_floor, + + // uint16 (10) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_uint32_base_identity, + (void *)stdlib_number_uint16_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_cfloorf, + (void *)stdlib_math_base_special_floor, + + // uint32 (6) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_uint32_base_identity, + (void *)stdlib_math_base_special_cfloor, + (void *)stdlib_math_base_special_floor, + + // uint8 (12) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_floorf, + (void *)stdlib_math_base_special_floor, + (void *)stdlib_number_int32_base_identity, + (void *)stdlib_number_int16_base_identity, + (void *)stdlib_math_base_special_floor, + (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, + (void *)stdlib_math_base_special_floor, + + // generic (2) + (void *)stdlib_math_base_special_floor, + (void *)stdlib_math_base_special_cfloor, }; @@ -219,7 +336,7 @@ static const struct ndarrayFunctionObject obj = { functions, // Number of ndarray functions: - 31, + 68, // 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, diff --git a/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json b/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json new file mode 100644 index 000000000000..66ea2baef2f9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json @@ -0,0 +1,114 @@ +{ + "@stdlib/math/base/special/sqrtf": { + "input": [ + "float32" + ], + "output": [ + "float32" + ] + }, + "@stdlib/math/base/special/sqrt": { + "input": [ + "float64" + ], + "output": [ + "float64" + ] + }, + "@stdlib/math/base/special/sinf": { + "input": [ + "float32" + ], + "output": [ + "float32" + ] + }, + "@stdlib/math/base/special/sin": { + "input": [ + "float64" + ], + "output": [ + "float64" + ] + }, + "@stdlib/number/int8/base/identity": { + "input": [ + "int8" + ], + "output": [ + "int8" + ] + }, + "@stdlib/number/int16/base/identity": { + "input": [ + "int16" + ], + "output": [ + "int16" + ] + }, + "@stdlib/number/int32/base/identity": { + "input": [ + "int32" + ], + "output": [ + "int32" + ] + }, + "@stdlib/number/uint8/base/identity": { + "input": [ + "uint8" + ], + "output": [ + "uint8" + ] + }, + "@stdlib/number/uint16/base/identity": { + "input": [ + "uint16" + ], + "output": [ + "uint16" + ] + }, + "@stdlib/number/uint32/base/identity": { + "input": [ + "uint32" + ], + "output": [ + "uint32" + ] + }, + "@stdlib/math/base/special/floorf": { + "input": [ + "float32" + ], + "output": [ + "float32" + ] + }, + "@stdlib/math/base/special/floor": { + "input": [ + "float64" + ], + "output": [ + "float64" + ] + }, + "@stdlib/math/base/special/cfloorf": { + "input": [ + "complex64" + ], + "output": [ + "complex64" + ] + }, + "@stdlib/math/base/special/cfloor": { + "input": [ + "complex128" + ], + "output": [ + "complex128" + ] + } +} diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index b1da1f570eb8..f1b86ea848d9 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -3,6 +3,7 @@ "input_dtypes": "real_and_generic", "output_dtypes": "real_floating_point", "output_policy": "real_floating_point", + "excluded_dtypes": [ "float16", "uint8c" ], "scalar_kernels": { "float32": "@stdlib/math/base/special/sqrtf", "float64": "@stdlib/math/base/special/sqrt", @@ -13,6 +14,7 @@ "input_dtypes": "real_and_generic", "output_dtypes": "real_floating_point", "output_policy": "real_floating_point", + "excluded_dtypes": [ "float16", "uint8c" ], "scalar_kernels": { "float32": "@stdlib/math/base/special/sinf", "float64": "@stdlib/math/base/special/sin", @@ -23,6 +25,7 @@ "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", diff --git a/lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js b/lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js new file mode 100644 index 000000000000..c7d724068ad5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js @@ -0,0 +1,164 @@ +#!/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 isArray = require( '@stdlib/assert/is-array' ); +var functionDatabase = require( './function_database.json' ); + + +// FUNCTIONS // + +/** +* Extracts dtypes from a package's package.json file. +* +* @private +* @param {string} pkgPath - package path +* @returns {Array} array containing input and output dtypes +* +* @example +* var dtypes = extractDtypes( '@stdlib/math/base/special/sqrt' ); +* // returns [ ['float64'], ['float64'] ] +*/ +function extractDtypes( pkgPath ) { + var packageJsonPath; + var outputDtypes; + var inputDtypes; + var scaffold; + var content; + var param; + var path; + var pkg; + var i; + + // 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 ); + + // Look for dtypes in __stdlib__.scaffold: + if ( pkg[ '__stdlib__' ] && pkg[ '__stdlib__' ].scaffold ) { + scaffold = pkg[ '__stdlib__' ].scaffold; + inputDtypes = []; + outputDtypes = []; + + // Extract input dtypes: + if ( scaffold.parameters && isArray( scaffold.parameters ) ) { + for ( i = 0; i < scaffold.parameters.length; i++ ) { + param = scaffold.parameters[ i ]; + if ( param.type && param.type.dtype ) { + inputDtypes.push( param.type.dtype ); + } + } + } + + // Extract output dtypes: + if ( scaffold.returns && scaffold.returns.type ) { + if ( scaffold.returns.type.dtype ) { + outputDtypes.push( scaffold.returns.type.dtype ); + } + } + + return [ inputDtypes, outputDtypes ]; + } + + return []; +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var scalarKernelNames; + var dtypesDatabase; + var scalarKernels; + var jsonContent; + var outputPath; + var functions; + var pkgPath; + var dtypes; + var func; + var pkg; + var i; + var j; + + dtypesDatabase = {}; + + // 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( dtypesDatabase, pkgPath ) ) { + continue; + } + + dtypes = extractDtypes( pkgPath ); + + if ( dtypes.length > 0 ) { + dtypesDatabase[ pkgPath ] = { + 'input': dtypes[ 0 ], + 'output': dtypes[ 1 ] + }; + } + } + } + + // Write the dtypes database to file: + outputPath = join( __dirname, 'dtypes_database.json' ); + jsonContent = JSON.stringify( dtypesDatabase, null, 2 ); + + writeFile( outputPath, jsonContent ); +} + +main(); From 9ab0db2326620f600909f5f45f7d01003020d42c Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 19 Aug 2025 12:27:37 +0530 Subject: [PATCH 17/31] refactor: remove dtype_hierarchy.js --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/scripts/dtype_hierarchy.js | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js diff --git a/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js b/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js deleted file mode 100644 index f3b32d27eb16..000000000000 --- a/lib/node_modules/@stdlib/math/special/scripts/dtype_hierarchy.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Dtype precision hierarchy. -* -* @type {Object} -*/ -var DTYPE_HIERARCHY = { - 'int8': 1, - 'uint8': 1, - 'int16': 2, - 'uint16': 2, - 'int32': 3, - 'uint32': 3, - 'float32': 4, - 'float64': 5, - 'complex64': 6, - 'complex128': 7, - 'generic': 8 -}; - - -// EXPORTS // - -module.exports = DTYPE_HIERARCHY; From 16fda9d846f9f09262e8495005b87f5043dc9c29 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 19 Aug 2025 21:25:58 +0530 Subject: [PATCH 18/31] feat: try the script for fibonacci --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/fibonacci/package.json | 18 +- .../math/base/special/fibonaccif/package.json | 18 +- .../math/special/fibonacci/lib/types.js | 93 +++++ .../math/special/fibonacci/package.json | 64 ++++ .../fibonacci/scripts/generate_files.js | 289 ++++++++++++++++ .../math/special/fibonacci/scripts/script.js | 325 ++++++++++++++++++ .../math/special/fibonacci/src/addon.c | 238 +++++++++++++ .../math/special/floor/scripts/script.js | 16 + .../math/special/scripts/dtypes_database.json | 16 + .../special/scripts/function_database.json | 17 + 10 files changed, 1092 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/package.json create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c 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/special/fibonacci/lib/types.js b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js new file mode 100644 index 000000000000..5c01bf22144b --- /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.float64 +]; + + +// EXPORTS // + +module.exports = types; 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..04646c87bcc0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js @@ -0,0 +1,289 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var join = require( 'path' ).join; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var currentYear = require( '@stdlib/time/current-year' ); +var generateMatchesTable = require( './script.js' ); +var pkg = require( './../package.json' ); + + +// FUNCTIONS // + +/** +* Groups matches by input data type and returns grouped data, input types, and reordered matches. +* +* @private +* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @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'; + } + } + + // Add blank line between input type groups ( except for the last one )... + if ( i < inputTypes.length - 1 ) { + jsOut += '\n'; + } + } + + jsOut += '];\n\n\n'; + jsOut += '// EXPORTS //\n\n'; + jsOut += 'module.exports = types;\n'; + return jsOut; +} + +/** +* Generates the addon.c file content. +* +* @private +* @param {Array} matches - array of match entries +* @param {string} header - license header +* @param {string} basePkg - base package name +* @returns {string} addon.c file content +*/ +function generateAddonFile( matches, header, basePkg ) { + var uniqueIncludes; + var functionIndex; + var outputTypes; + var 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 ]; // Package path is at index 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 ] + ',\n'; + functionIndex += 1; + } + 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() + ',\n'; + functionIndex += 1; + } + 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 ] + ',\n'; + functionIndex += 1; + } + 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 basePkg; + var matches; + var header; + var jsOut; + var cOut; + + // Generate and filter matches table: + matches = generateMatchesTable(); + + // Extract package information: + basePkg = pkg.name.split( '/' ).pop(); + + // Generate license header: + header = licenseHeader( 'Apache-2.0', 'js', { + 'year': currentYear(), + 'copyright': 'The Stdlib Authors' + }); + header += '\n/* This is a generated file. Do not edit directly. */\n'; + + // Generate types.js: + jsOut = generateTypesFile( matches, header ); + writeFileSync( join( __dirname, '../lib/types.js' ), jsOut, { + 'encoding': 'utf8' + }); + + // Generate addon.c: + cOut = generateAddonFile( matches, header, basePkg ); + writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { + 'encoding': 'utf8' + }); +} + + +// MAIN // + +main(); diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js new file mode 100644 index 000000000000..cf4f8352e1db --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js @@ -0,0 +1,325 @@ +/** +* @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 dtypesDatabase = require( '@stdlib/math/special/scripts/dtypes_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 { + // 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 = dtypesDatabase[ scalarKernel ].input[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].input[ 0 ] => 'complex64' + scalarKernelOutputDtype = dtypesDatabase[ scalarKernel ].output[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].output[ 0 ] => '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' ) { + // For generic input, generate mappings to highest precision dtypes: + allowedCasts = [ 'float64', 'complex128' ]; + } 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..7cfc770694ec --- /dev/null +++ b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c @@ -0,0 +1,238 @@ +/** +* @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 (3) + undefined, + undefined, + undefined, + + // float64 (3) + undefined, + undefined, + undefined, + + // int16 (5) + undefined, + undefined, + undefined, + undefined, + undefined, + + // int32 (3) + stdlib_ndarray_i_d, + undefined, + undefined, + + // int8 (6) + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + + // uint16 (6) + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + + // uint32 (3) + undefined, + undefined, + undefined, + + // uint8 (8) + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + + // generic (1) + undefined, + +}; + +// Define the array of input and output ndarray types: +static int32_t types[] = { + // float32 (3) + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_GENERIC, + + // float64 (3) + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_GENERIC, + + // int16 (5) + 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_GENERIC, + + // int32 (3) + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, + STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_GENERIC, + + // int8 (6) + 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_GENERIC, + + // uint16 (6) + 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_GENERIC, + + // uint32 (3) + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, + STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_GENERIC, + + // uint8 (8) + 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_GENERIC, + + // generic (1) + STDLIB_NDARRAY_GENERIC, STDLIB_NDARRAY_FLOAT64, + +}; + +// Define a list of ndarray function "data" (in this case, callbacks): +static void *data[] = { + // float32 (3) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonacci, + + // float64 (3) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonacci, + + // int16 (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_fibonacci, + + // int32 (3) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonacci, + + // int8 (6) + (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_fibonacci, + + // uint16 (6) + (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_fibonacci, + + // uint32 (3) + (void *)stdlib_math_base_special_fibonacci, + (void *)stdlib_math_base_special_fibonaccif, + (void *)stdlib_math_base_special_fibonacci, + + // uint8 (8) + (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, + (void *)stdlib_math_base_special_fibonacci, + + // generic (1) + (void *)stdlib_math_base_special_fibonacci, + +}; + +// 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: + 38, + + // 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/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js index 51ccfa273e12..cf4f8352e1db 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -156,9 +156,11 @@ function main() { var mappings; var filtered; var obj; + var odt; var idt; var i; var j; + var k; mappings = []; @@ -190,6 +192,9 @@ function main() { // Get input dtypes: idt = dtypes( obj.input_dtypes ); + // Get output dtypes: + odt = dtypes( obj.output_dtypes ); + /* * idt = [ * 'complex32', @@ -263,6 +268,17 @@ function main() { */ } + // 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 ]; diff --git a/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json b/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json index 66ea2baef2f9..2cbd78fea25f 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json @@ -110,5 +110,21 @@ "output": [ "complex128" ] + }, + "@stdlib/math/base/special/fibonaccif": { + "input": [ + "int32" + ], + "output": [ + "float32" + ] + }, + "@stdlib/math/base/special/fibonacci": { + "input": [ + "int32" + ], + "output": [ + "float64" + ] } } diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index f1b86ea848d9..9dc7346d6b0d 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -39,6 +39,23 @@ "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" ], + "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" + } } } From e23d8e5bd4dd39b5064742d1bda5ac6082480182 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 19 Aug 2025 21:42:55 +0530 Subject: [PATCH 19/31] refactor: regenerate addon.c for fibonacci --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/fibonacci/src/addon.c | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c index 7cfc770694ec..2225a3bf2b86 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c @@ -31,60 +31,60 @@ static const char name[] = "stdlib_ndarray_fibonacci"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { // float32 (3) - undefined, - undefined, - undefined, + stdlib_ndarray_f_d_as_i_d, + stdlib_ndarray_f_f_as_i_f, + stdlib_ndarray_f_o_as_i_d, // float64 (3) - undefined, - undefined, - undefined, + stdlib_ndarray_d_d_as_i_d, + stdlib_ndarray_d_f_as_i_d, + stdlib_ndarray_d_o_as_i_d, // int16 (5) - undefined, - undefined, - undefined, - undefined, - undefined, + 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, + stdlib_ndarray_k_o_as_i_d, // int32 (3) stdlib_ndarray_i_d, - undefined, - undefined, + stdlib_ndarray_i_i_as_i_f, + stdlib_ndarray_i_o_as_i_d, // int8 (6) - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, + 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, + stdlib_ndarray_s_o_as_i_d, // uint16 (6) - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, + 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, + stdlib_ndarray_t_o_as_i_d, // uint32 (3) - undefined, - undefined, - undefined, + stdlib_ndarray_u_d_as_i_d, + stdlib_ndarray_u_u_as_i_f, + stdlib_ndarray_u_o_as_i_d, // uint8 (8) - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, + 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, + stdlib_ndarray_b_o_as_i_d, // generic (1) - undefined, + stdlib_ndarray_o_d_as_i_d, }; From 637de3c37e6429b2a7cca4fc5b0b3ce651c7a885 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 20 Aug 2025 12:47:53 +0530 Subject: [PATCH 20/31] refactor: modify script to exclude generic dtypes in addon --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/fibonacci/lib/types.js | 5 +- .../fibonacci/scripts/generate_files.js | 12 +- .../math/special/fibonacci/scripts/script.js | 3 +- .../math/special/fibonacci/src/addon.c | 153 +++++++----------- .../@stdlib/math/special/floor/lib/types.js | 27 +--- .../special/floor/scripts/generate_files.js | 12 +- .../math/special/floor/scripts/script.js | 3 +- .../@stdlib/math/special/floor/src/addon.c | 137 ++++------------ .../special/scripts/function_database.json | 4 +- 9 files changed, 128 insertions(+), 228 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js index 5c01bf22144b..6ed08fe282eb 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js @@ -81,10 +81,7 @@ var types = [ dtypes.uint8, dtypes.uint32, dtypes.uint8, dtypes.uint16, dtypes.uint8, dtypes.uint8, - dtypes.uint8, dtypes.generic, - - // generic (1) - dtypes.generic, dtypes.float64 + dtypes.uint8, dtypes.generic ]; 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 index 04646c87bcc0..b599217e9f80 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js @@ -251,15 +251,25 @@ function generateAddonFile( matches, header, basePkg ) { * @private */ function main() { + var filteredMatches; 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(); @@ -277,7 +287,7 @@ function main() { }); // Generate addon.c: - cOut = generateAddonFile( matches, header, basePkg ); + cOut = generateAddonFile( filteredMatches, header, basePkg ); writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { 'encoding': 'utf8' }); diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js index cf4f8352e1db..af6adbc7b807 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js @@ -250,8 +250,7 @@ function main() { */ if ( inputDtype === 'generic' ) { - // For generic input, generate mappings to highest precision dtypes: - allowedCasts = [ 'float64', 'complex128' ]; + continue; } else { // Get all dtypes this input can be mostly-safely cast to: allowedCasts = mostlySafeCasts( inputDtype ); diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c index 2225a3bf2b86..c5ebe89bab71 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c @@ -30,110 +30,92 @@ static const char name[] = "stdlib_ndarray_fibonacci"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { - // float32 (3) - stdlib_ndarray_f_d_as_i_d, - stdlib_ndarray_f_f_as_i_f, - stdlib_ndarray_f_o_as_i_d, - - // float64 (3) - stdlib_ndarray_d_d_as_i_d, - stdlib_ndarray_d_f_as_i_d, - stdlib_ndarray_d_o_as_i_d, - - // int16 (5) - 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, - stdlib_ndarray_k_o_as_i_d, - - // int32 (3) + // float32 (2) + undefined, + undefined, + + // float64 (2) + undefined, + undefined, + + // int16 (4) + undefined, + undefined, + undefined, + undefined, + + // int32 (2) stdlib_ndarray_i_d, - stdlib_ndarray_i_i_as_i_f, - stdlib_ndarray_i_o_as_i_d, - - // int8 (6) - 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, - stdlib_ndarray_s_o_as_i_d, - - // uint16 (6) - 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, - stdlib_ndarray_t_o_as_i_d, - - // uint32 (3) - stdlib_ndarray_u_d_as_i_d, - stdlib_ndarray_u_u_as_i_f, - stdlib_ndarray_u_o_as_i_d, - - // uint8 (8) - 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, - stdlib_ndarray_b_o_as_i_d, - - // generic (1) - stdlib_ndarray_o_d_as_i_d, + undefined, + + // int8 (5) + undefined, + undefined, + undefined, + undefined, + undefined, + + // uint16 (5) + undefined, + undefined, + undefined, + undefined, + undefined, + + // uint32 (2) + undefined, + undefined, + + // uint8 (7) + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, }; // Define the array of input and output ndarray types: static int32_t types[] = { - // float32 (3) + // float32 (2) STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_GENERIC, - // float64 (3) + // float64 (2) STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_GENERIC, - // int16 (5) + // 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, - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_GENERIC, - // int32 (3) + // int32 (2) STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, - STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_GENERIC, - // int8 (6) + // 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, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_GENERIC, - // uint16 (6) + // 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, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_GENERIC, - // uint32 (3) + // uint32 (2) STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_GENERIC, - // uint8 (8) + // uint8 (7) STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT32, @@ -141,59 +123,48 @@ static int32_t types[] = { STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT8, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_GENERIC, - - // generic (1) - STDLIB_NDARRAY_GENERIC, STDLIB_NDARRAY_FLOAT64, }; // Define a list of ndarray function "data" (in this case, callbacks): static void *data[] = { - // float32 (3) + // float32 (2) (void *)stdlib_math_base_special_fibonacci, (void *)stdlib_math_base_special_fibonaccif, - (void *)stdlib_math_base_special_fibonacci, - // float64 (3) - (void *)stdlib_math_base_special_fibonacci, + // float64 (2) (void *)stdlib_math_base_special_fibonacci, (void *)stdlib_math_base_special_fibonacci, - // int16 (5) + // 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, - (void *)stdlib_math_base_special_fibonacci, - // int32 (3) + // int32 (2) (void *)stdlib_math_base_special_fibonacci, (void *)stdlib_math_base_special_fibonaccif, - (void *)stdlib_math_base_special_fibonacci, - // int8 (6) + // 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, - (void *)stdlib_math_base_special_fibonacci, - // uint16 (6) + // 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, - (void *)stdlib_math_base_special_fibonacci, - // uint32 (3) + // uint32 (2) (void *)stdlib_math_base_special_fibonacci, (void *)stdlib_math_base_special_fibonaccif, - (void *)stdlib_math_base_special_fibonacci, - // uint8 (8) + // uint8 (7) (void *)stdlib_math_base_special_fibonacci, (void *)stdlib_math_base_special_fibonaccif, (void *)stdlib_math_base_special_fibonaccif, @@ -201,10 +172,6 @@ static void *data[] = { (void *)stdlib_math_base_special_fibonaccif, (void *)stdlib_math_base_special_fibonaccif, (void *)stdlib_math_base_special_fibonaccif, - (void *)stdlib_math_base_special_fibonacci, - - // generic (1) - (void *)stdlib_math_base_special_fibonacci, }; @@ -226,7 +193,7 @@ static const struct ndarrayFunctionObject obj = { functions, // Number of ndarray functions: - 38, + 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, diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/types.js b/lib/node_modules/@stdlib/math/special/floor/lib/types.js index fe1764d0f49e..ba87c8a9f4a0 100644 --- a/lib/node_modules/@stdlib/math/special/floor/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/floor/lib/types.js @@ -54,27 +54,24 @@ var types = [ dtypes.float64, dtypes.complex64, dtypes.float64, dtypes.generic, - // int16 (8) + // int16 (7) dtypes.int16, dtypes.float64, dtypes.int16, dtypes.float32, - dtypes.int16, dtypes.int64, dtypes.int16, dtypes.int32, dtypes.int16, dtypes.int16, dtypes.int16, dtypes.complex128, dtypes.int16, dtypes.complex64, dtypes.int16, dtypes.generic, - // int32 (5) + // int32 (4) dtypes.int32, dtypes.float64, - dtypes.int32, dtypes.int64, dtypes.int32, dtypes.int32, dtypes.int32, dtypes.complex128, dtypes.int32, dtypes.generic, - // int8 (9) + // int8 (8) dtypes.int8, dtypes.float64, dtypes.int8, dtypes.float32, - dtypes.int8, dtypes.int64, dtypes.int8, dtypes.int32, dtypes.int8, dtypes.int16, dtypes.int8, dtypes.int8, @@ -82,43 +79,33 @@ var types = [ dtypes.int8, dtypes.complex64, dtypes.int8, dtypes.generic, - // uint16 (10) + // uint16 (8) dtypes.uint16, dtypes.float64, dtypes.uint16, dtypes.float32, - dtypes.uint16, dtypes.int64, dtypes.uint16, dtypes.int32, - dtypes.uint16, dtypes.uint64, dtypes.uint16, dtypes.uint32, dtypes.uint16, dtypes.uint16, dtypes.uint16, dtypes.complex128, dtypes.uint16, dtypes.complex64, dtypes.uint16, dtypes.generic, - // uint32 (6) + // uint32 (4) dtypes.uint32, dtypes.float64, - dtypes.uint32, dtypes.int64, - dtypes.uint32, dtypes.uint64, dtypes.uint32, dtypes.uint32, dtypes.uint32, dtypes.complex128, dtypes.uint32, dtypes.generic, - // uint8 (12) + // uint8 (10) dtypes.uint8, dtypes.float64, dtypes.uint8, dtypes.float32, - dtypes.uint8, dtypes.int64, dtypes.uint8, dtypes.int32, dtypes.uint8, dtypes.int16, - dtypes.uint8, dtypes.uint64, 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 (2) - dtypes.generic, dtypes.float64, - dtypes.generic, dtypes.complex128 + dtypes.uint8, dtypes.generic ]; 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 index 04646c87bcc0..b599217e9f80 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js @@ -251,15 +251,25 @@ function generateAddonFile( matches, header, basePkg ) { * @private */ function main() { + var filteredMatches; 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(); @@ -277,7 +287,7 @@ function main() { }); // Generate addon.c: - cOut = generateAddonFile( matches, header, basePkg ); + cOut = generateAddonFile( filteredMatches, header, basePkg ); writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { 'encoding': 'utf8' }); diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js index cf4f8352e1db..af6adbc7b807 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -250,8 +250,7 @@ function main() { */ if ( inputDtype === 'generic' ) { - // For generic input, generate mappings to highest precision dtypes: - allowedCasts = [ 'float64', 'complex128' ]; + continue; } else { // Get all dtypes this input can be mostly-safely cast to: allowedCasts = mostlySafeCasts( inputDtype ); diff --git a/lib/node_modules/@stdlib/math/special/floor/src/addon.c b/lib/node_modules/@stdlib/math/special/floor/src/addon.c index 7a08e0656bb2..5ba436060ce9 100644 --- a/lib/node_modules/@stdlib/math/special/floor/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/floor/src/addon.c @@ -38,283 +38,214 @@ static const char name[] = "stdlib_ndarray_floor"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { - // complex64 (3) + // complex64 (2) stdlib_ndarray_c_z_as_z_z, stdlib_ndarray_c_c, - stdlib_ndarray_c_o_as_d_d, - // complex128 (3) + // complex128 (2) stdlib_ndarray_z_z, - stdlib_ndarray_z_c_as_z_z, - stdlib_ndarray_z_o_as_d_d, + undefined, - // float32 (5) + // 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, - stdlib_ndarray_f_o_as_d_d, - // float64 (5) + // float64 (4) stdlib_ndarray_d_d, - stdlib_ndarray_d_f_as_d_d, + undefined, stdlib_ndarray_d_z_as_z_z, - stdlib_ndarray_d_c_as_z_z, - stdlib_ndarray_d_o_as_d_d, + undefined, - // int16 (8) + // int16 (6) stdlib_ndarray_k_d_as_d_d, stdlib_ndarray_k_f_as_f_f, - stdlib_ndarray_k_l_as_d_d, 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, - stdlib_ndarray_k_o_as_d_d, - // int32 (5) + // int32 (3) stdlib_ndarray_i_d_as_d_d, - stdlib_ndarray_i_l_as_d_d, stdlib_ndarray_i_i, stdlib_ndarray_i_z_as_z_z, - stdlib_ndarray_i_o_as_d_d, - // int8 (9) + // int8 (7) stdlib_ndarray_s_d_as_d_d, stdlib_ndarray_s_f_as_f_f, - stdlib_ndarray_s_l_as_d_d, 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, - stdlib_ndarray_s_o_as_d_d, - // uint16 (10) + // uint16 (7) stdlib_ndarray_t_d_as_d_d, stdlib_ndarray_t_f_as_f_f, - stdlib_ndarray_t_l_as_d_d, stdlib_ndarray_t_i_as_i_i, - stdlib_ndarray_t_v_as_d_d, 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, - stdlib_ndarray_t_o_as_d_d, - // uint32 (6) + // uint32 (3) stdlib_ndarray_u_d_as_d_d, - stdlib_ndarray_u_l_as_d_d, - stdlib_ndarray_u_v_as_d_d, stdlib_ndarray_u_u, stdlib_ndarray_u_z_as_z_z, - stdlib_ndarray_u_o_as_d_d, - // uint8 (12) + // uint8 (9) stdlib_ndarray_b_d_as_d_d, stdlib_ndarray_b_f_as_f_f, - stdlib_ndarray_b_l_as_d_d, stdlib_ndarray_b_i_as_i_i, stdlib_ndarray_b_k_as_k_k, - stdlib_ndarray_b_v_as_d_d, 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, - stdlib_ndarray_b_o_as_d_d, - - // generic (2) - stdlib_ndarray_o_d_as_d_d, - stdlib_ndarray_o_z_as_z_z, }; // Define the array of input and output ndarray types: static int32_t types[] = { - // complex64 (3) + // complex64 (2) STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_COMPLEX64, STDLIB_NDARRAY_GENERIC, - // complex128 (3) + // complex128 (2) STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_GENERIC, - // float32 (5) + // 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, - STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_GENERIC, - // float64 (5) + // 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, - STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_GENERIC, - // int16 (8) + // int16 (6) STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_GENERIC, - // int32 (5) + // int32 (3) STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_GENERIC, - // int8 (9) + // int8 (7) STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_INT64, 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, - STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_GENERIC, - // uint16 (10) + // uint16 (7) STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_INT32, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT64, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX128, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_COMPLEX64, - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_GENERIC, - // uint32 (6) + // uint32 (3) STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_INT64, - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT64, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_UINT32, STDLIB_NDARRAY_GENERIC, - // uint8 (12) + // uint8 (9) STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT64, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT32, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_INT16, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT64, 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, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_GENERIC, - - // generic (2) - STDLIB_NDARRAY_GENERIC, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_GENERIC, STDLIB_NDARRAY_COMPLEX128, }; // Define a list of ndarray function "data" (in this case, callbacks): static void *data[] = { - // complex64 (3) + // complex64 (2) (void *)stdlib_math_base_special_cfloor, (void *)stdlib_math_base_special_cfloorf, - (void *)stdlib_math_base_special_floor, - // complex128 (3) + // complex128 (2) (void *)stdlib_math_base_special_cfloor, (void *)stdlib_math_base_special_cfloor, - (void *)stdlib_math_base_special_floor, - // float32 (5) + // 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, - (void *)stdlib_math_base_special_floor, - // float64 (5) + // 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, - (void *)stdlib_math_base_special_floor, - // int16 (8) + // int16 (6) (void *)stdlib_math_base_special_floor, (void *)stdlib_math_base_special_floorf, - (void *)stdlib_math_base_special_floor, (void *)stdlib_number_int32_base_identity, (void *)stdlib_number_int16_base_identity, (void *)stdlib_math_base_special_cfloor, (void *)stdlib_math_base_special_cfloorf, - (void *)stdlib_math_base_special_floor, - // int32 (5) - (void *)stdlib_math_base_special_floor, + // int32 (3) (void *)stdlib_math_base_special_floor, (void *)stdlib_number_int32_base_identity, (void *)stdlib_math_base_special_cfloor, - (void *)stdlib_math_base_special_floor, - // int8 (9) + // int8 (7) (void *)stdlib_math_base_special_floor, (void *)stdlib_math_base_special_floorf, - (void *)stdlib_math_base_special_floor, (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, - (void *)stdlib_math_base_special_floor, - // uint16 (10) + // uint16 (7) (void *)stdlib_math_base_special_floor, (void *)stdlib_math_base_special_floorf, - (void *)stdlib_math_base_special_floor, (void *)stdlib_number_int32_base_identity, - (void *)stdlib_math_base_special_floor, (void *)stdlib_number_uint32_base_identity, (void *)stdlib_number_uint16_base_identity, (void *)stdlib_math_base_special_cfloor, (void *)stdlib_math_base_special_cfloorf, - (void *)stdlib_math_base_special_floor, - // uint32 (6) - (void *)stdlib_math_base_special_floor, - (void *)stdlib_math_base_special_floor, + // uint32 (3) (void *)stdlib_math_base_special_floor, (void *)stdlib_number_uint32_base_identity, (void *)stdlib_math_base_special_cfloor, - (void *)stdlib_math_base_special_floor, - // uint8 (12) + // uint8 (9) (void *)stdlib_math_base_special_floor, (void *)stdlib_math_base_special_floorf, - (void *)stdlib_math_base_special_floor, (void *)stdlib_number_int32_base_identity, (void *)stdlib_number_int16_base_identity, - (void *)stdlib_math_base_special_floor, (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, - (void *)stdlib_math_base_special_floor, - - // generic (2) - (void *)stdlib_math_base_special_floor, - (void *)stdlib_math_base_special_cfloor, }; @@ -336,7 +267,7 @@ static const struct ndarrayFunctionObject obj = { functions, // Number of ndarray functions: - 68, + 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, diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index 9dc7346d6b0d..4aa286b0e00f 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -25,7 +25,7 @@ "input_dtypes": "numeric_and_generic", "output_dtypes": "numeric_and_generic", "output_policy": "same", - "excluded_dtypes": [ "float16", "uint8c", "complex32" ], + "excluded_dtypes": [ "float16", "uint8c", "complex32", "int64", "uint64" ], "scalar_kernels": { "int8": "@stdlib/number/int8/base/identity", "int16": "@stdlib/number/int16/base/identity", @@ -44,7 +44,7 @@ "input_dtypes": "real_and_generic", "output_dtypes": "real_and_generic", "output_policy": "real_and_generic", - "excluded_dtypes": [ "float16", "uint8c" ], + "excluded_dtypes": [ "float16", "uint8c", "int64", "uint64" ], "scalar_kernels": { "int8": "@stdlib/math/base/special/fibonaccif", "int16": "@stdlib/math/base/special/fibonaccif", From 6dc4f19e8149cda8f4b05fb916ff64c5d6ccecac Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 20 Aug 2025 12:50:27 +0530 Subject: [PATCH 21/31] chore: regenerate files --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/fibonacci/src/addon.c | 56 +++++++++---------- .../@stdlib/math/special/floor/src/addon.c | 6 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c index c5ebe89bab71..110397bdaa8f 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c @@ -31,49 +31,49 @@ static const char name[] = "stdlib_ndarray_fibonacci"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { // float32 (2) - undefined, - undefined, + stdlib_ndarray_f_d_as_i_d, + stdlib_ndarray_f_f_as_i_f, // float64 (2) - undefined, - undefined, + stdlib_ndarray_d_d_as_i_d, + stdlib_ndarray_d_f_as_i_d, // int16 (4) - undefined, - undefined, - undefined, - undefined, + 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, - undefined, + stdlib_ndarray_i_i_as_i_f, // int8 (5) - undefined, - undefined, - undefined, - undefined, - undefined, + 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) - undefined, - undefined, - undefined, - undefined, - undefined, + 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) - undefined, - undefined, + stdlib_ndarray_u_d_as_i_d, + stdlib_ndarray_u_u_as_i_f, // uint8 (7) - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, - undefined, + 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, }; diff --git a/lib/node_modules/@stdlib/math/special/floor/src/addon.c b/lib/node_modules/@stdlib/math/special/floor/src/addon.c index 5ba436060ce9..722385a68ee7 100644 --- a/lib/node_modules/@stdlib/math/special/floor/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/floor/src/addon.c @@ -44,7 +44,7 @@ static ndarrayFcn functions[] = { // complex128 (2) stdlib_ndarray_z_z, - undefined, + stdlib_ndarray_z_c_as_z_z, // float32 (4) stdlib_ndarray_f_d_as_d_d, @@ -54,9 +54,9 @@ static ndarrayFcn functions[] = { // float64 (4) stdlib_ndarray_d_d, - undefined, + stdlib_ndarray_d_f_as_d_d, stdlib_ndarray_d_z_as_z_z, - undefined, + stdlib_ndarray_d_c_as_z_z, // int16 (6) stdlib_ndarray_k_d_as_d_d, From 9c55af345911c4dccc9f439fc2db4b52fae26110 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 20 Aug 2025 18:14:14 +0530 Subject: [PATCH 22/31] refactor: read whole scaffold object instead of only dtypes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/fibonacci/scripts/script.js | 6 +- .../math/special/floor/scripts/script.js | 6 +- .../math/special/scripts/dtypes_database.json | 130 -------- ...base.js => generate_scaffolds_database.js} | 70 ++--- .../special/scripts/scaffold_database.json | 289 ++++++++++++++++++ 5 files changed, 315 insertions(+), 186 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json rename lib/node_modules/@stdlib/math/special/scripts/{generate_dtypes_database.js => generate_scaffolds_database.js} (62%) create mode 100644 lib/node_modules/@stdlib/math/special/scripts/scaffold_database.json diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js index af6adbc7b807..995bda4a3a16 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js @@ -25,7 +25,7 @@ var join = require( 'path' ).join; var readJSON = require( '@stdlib/fs/read-json' ).sync; var db = require( '@stdlib/math/special/scripts/function_database.json' ); -var dtypesDatabase = require( '@stdlib/math/special/scripts/dtypes_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' ); @@ -118,8 +118,8 @@ function selectKernelName( inputDtype, outputDtype, scalarKernel, kernelList ) { * scalarKernel = '@stdlib/math/base/special/cfloorf' */ - scalarKernelInputDtype = dtypesDatabase[ scalarKernel ].input[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].input[ 0 ] => 'complex64' - scalarKernelOutputDtype = dtypesDatabase[ scalarKernel ].output[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].output[ 0 ] => 'complex64' + 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 ) { diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js index af6adbc7b807..995bda4a3a16 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -25,7 +25,7 @@ var join = require( 'path' ).join; var readJSON = require( '@stdlib/fs/read-json' ).sync; var db = require( '@stdlib/math/special/scripts/function_database.json' ); -var dtypesDatabase = require( '@stdlib/math/special/scripts/dtypes_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' ); @@ -118,8 +118,8 @@ function selectKernelName( inputDtype, outputDtype, scalarKernel, kernelList ) { * scalarKernel = '@stdlib/math/base/special/cfloorf' */ - scalarKernelInputDtype = dtypesDatabase[ scalarKernel ].input[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].input[ 0 ] => 'complex64' - scalarKernelOutputDtype = dtypesDatabase[ scalarKernel ].output[ 0 ]; // dtypesDatabase[ '@stdlib/math/base/special/cfloorf' ].output[ 0 ] => 'complex64' + 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 ) { diff --git a/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json b/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json deleted file mode 100644 index 2cbd78fea25f..000000000000 --- a/lib/node_modules/@stdlib/math/special/scripts/dtypes_database.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "@stdlib/math/base/special/sqrtf": { - "input": [ - "float32" - ], - "output": [ - "float32" - ] - }, - "@stdlib/math/base/special/sqrt": { - "input": [ - "float64" - ], - "output": [ - "float64" - ] - }, - "@stdlib/math/base/special/sinf": { - "input": [ - "float32" - ], - "output": [ - "float32" - ] - }, - "@stdlib/math/base/special/sin": { - "input": [ - "float64" - ], - "output": [ - "float64" - ] - }, - "@stdlib/number/int8/base/identity": { - "input": [ - "int8" - ], - "output": [ - "int8" - ] - }, - "@stdlib/number/int16/base/identity": { - "input": [ - "int16" - ], - "output": [ - "int16" - ] - }, - "@stdlib/number/int32/base/identity": { - "input": [ - "int32" - ], - "output": [ - "int32" - ] - }, - "@stdlib/number/uint8/base/identity": { - "input": [ - "uint8" - ], - "output": [ - "uint8" - ] - }, - "@stdlib/number/uint16/base/identity": { - "input": [ - "uint16" - ], - "output": [ - "uint16" - ] - }, - "@stdlib/number/uint32/base/identity": { - "input": [ - "uint32" - ], - "output": [ - "uint32" - ] - }, - "@stdlib/math/base/special/floorf": { - "input": [ - "float32" - ], - "output": [ - "float32" - ] - }, - "@stdlib/math/base/special/floor": { - "input": [ - "float64" - ], - "output": [ - "float64" - ] - }, - "@stdlib/math/base/special/cfloorf": { - "input": [ - "complex64" - ], - "output": [ - "complex64" - ] - }, - "@stdlib/math/base/special/cfloor": { - "input": [ - "complex128" - ], - "output": [ - "complex128" - ] - }, - "@stdlib/math/base/special/fibonaccif": { - "input": [ - "int32" - ], - "output": [ - "float32" - ] - }, - "@stdlib/math/base/special/fibonacci": { - "input": [ - "int32" - ], - "output": [ - "float64" - ] - } -} diff --git a/lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js b/lib/node_modules/@stdlib/math/special/scripts/generate_scaffolds_database.js similarity index 62% rename from lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js rename to lib/node_modules/@stdlib/math/special/scripts/generate_scaffolds_database.js index c7d724068ad5..8f61d06aaaf7 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/generate_dtypes_database.js +++ b/lib/node_modules/@stdlib/math/special/scripts/generate_scaffolds_database.js @@ -29,76 +29,49 @@ 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 isArray = require( '@stdlib/assert/is-array' ); -var functionDatabase = require( './function_database.json' ); +var functionDatabase = require( '@stdlib/math/special/scripts/function_database.json' ); // FUNCTIONS // /** -* Extracts dtypes from a package's package.json file. +* Extracts scaffold metadata from a package's package.json file. * * @private * @param {string} pkgPath - package path -* @returns {Array} array containing input and output dtypes +* @returns {Object} scaffold object * * @example -* var dtypes = extractDtypes( '@stdlib/math/base/special/sqrt' ); -* // returns [ ['float64'], ['float64'] ] +* var scaffold = extractScaffold( '@stdlib/math/base/special/sqrt' ); +* // returns { 'parameters': [...], 'returns': {...} } */ -function extractDtypes( pkgPath ) { +function extractScaffold( pkgPath ) { var packageJsonPath; - var outputDtypes; - var inputDtypes; - var scaffold; var content; - var param; var path; var pkg; - var i; // 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 []; + return {}; } content = readFile( packageJsonPath, 'utf8' ); if ( content instanceof Error ) { - return []; + return {}; } pkg = JSON.parse( content ); - // Look for dtypes in __stdlib__.scaffold: + // Return the complete scaffold object: if ( pkg[ '__stdlib__' ] && pkg[ '__stdlib__' ].scaffold ) { - scaffold = pkg[ '__stdlib__' ].scaffold; - inputDtypes = []; - outputDtypes = []; - - // Extract input dtypes: - if ( scaffold.parameters && isArray( scaffold.parameters ) ) { - for ( i = 0; i < scaffold.parameters.length; i++ ) { - param = scaffold.parameters[ i ]; - if ( param.type && param.type.dtype ) { - inputDtypes.push( param.type.dtype ); - } - } - } - - // Extract output dtypes: - if ( scaffold.returns && scaffold.returns.type ) { - if ( scaffold.returns.type.dtype ) { - outputDtypes.push( scaffold.returns.type.dtype ); - } - } - - return [ inputDtypes, outputDtypes ]; + return pkg[ '__stdlib__' ].scaffold; } - return []; + return {}; } @@ -111,19 +84,19 @@ function extractDtypes( pkgPath ) { */ function main() { var scalarKernelNames; - var dtypesDatabase; + var scaffoldDatabase; var scalarKernels; var jsonContent; var outputPath; var functions; + var scaffold; var pkgPath; - var dtypes; var func; var pkg; var i; var j; - dtypesDatabase = {}; + scaffoldDatabase = {}; // Get all function names: functions = objectKeys( functionDatabase ); @@ -139,24 +112,21 @@ function main() { pkgPath = scalarKernels[ pkg ]; // Skip if we already processed this package: - if ( hasOwnProp( dtypesDatabase, pkgPath ) ) { + if ( hasOwnProp( scaffoldDatabase, pkgPath ) ) { continue; } - dtypes = extractDtypes( pkgPath ); + scaffold = extractScaffold( pkgPath ); - if ( dtypes.length > 0 ) { - dtypesDatabase[ pkgPath ] = { - 'input': dtypes[ 0 ], - 'output': dtypes[ 1 ] - }; + if ( scaffold ) { + scaffoldDatabase[ pkgPath ] = scaffold; } } } // Write the dtypes database to file: - outputPath = join( __dirname, 'dtypes_database.json' ); - jsonContent = JSON.stringify( dtypesDatabase, null, 2 ); + outputPath = join( __dirname, 'scaffold_database.json' ); + jsonContent = JSON.stringify( scaffoldDatabase, null, 2 ); writeFile( outputPath, jsonContent ); } 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" + } + } + } +} From eae79f47c940fbfe9542adafd64745ea4a0af462 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 20 Aug 2025 23:37:17 +0530 Subject: [PATCH 23/31] refactor: use new script for sin and sqrt --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/scripts/function_database.json | 20 +- .../math/special/sin/scripts/config.js | 38 -- .../special/sin/scripts/generate_files.js | 18 +- .../math/special/sin/scripts/get_dtypes.js | 93 ---- .../sin/scripts/map_to_scalar_kernel.js | 178 -------- .../math/special/sin/scripts/script.js | 425 ++++++++++-------- .../math/special/sqrt/scripts/config.js | 38 -- .../special/sqrt/scripts/generate_files.js | 18 +- .../math/special/sqrt/scripts/get_dtypes.js | 93 ---- .../sqrt/scripts/map_to_scalar_kernel.js | 178 -------- .../math/special/sqrt/scripts/script.js | 425 ++++++++++-------- 11 files changed, 524 insertions(+), 1000 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/config.js delete mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js delete mode 100644 lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js delete mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js delete mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js delete mode 100644 lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js diff --git a/lib/node_modules/@stdlib/math/special/scripts/function_database.json b/lib/node_modules/@stdlib/math/special/scripts/function_database.json index 4aa286b0e00f..868c033bc9c5 100644 --- a/lib/node_modules/@stdlib/math/special/scripts/function_database.json +++ b/lib/node_modules/@stdlib/math/special/scripts/function_database.json @@ -1,10 +1,16 @@ { "sqrt": { "input_dtypes": "real_and_generic", - "output_dtypes": "real_floating_point", + "output_dtypes": "real_floating_point_and_generic", "output_policy": "real_floating_point", - "excluded_dtypes": [ "float16", "uint8c" ], + "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" @@ -12,10 +18,16 @@ }, "sin": { "input_dtypes": "real_and_generic", - "output_dtypes": "real_floating_point", + "output_dtypes": "real_floating_point_and_generic", "output_policy": "real_floating_point", - "excluded_dtypes": [ "float16", "uint8c" ], + "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" diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/config.js b/lib/node_modules/@stdlib/math/special/sin/scripts/config.js deleted file mode 100644 index 13d8ee48102b..000000000000 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/config.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Configuration object. -* -* @private -* @type {Object} -*/ -var config = { - 'input_dtypes': 'real_and_generic', - 'output_dtypes': 'real_floating_point', - 'excluded_dtypes': [ 'float16', 'uint8c' ] -}; - - -// EXPORTS // - -module.exports = config; 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 index 95dac3531db5..b599217e9f80 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -31,11 +31,11 @@ var pkg = require( './../package.json' ); // FUNCTIONS // /** -* Groups matches by input data type. +* Groups matches by input data type and returns grouped data, input types, and reordered matches. * * @private -* @param {Array} matches - array of match entries -* @returns {Object} object containing grouped matches, input types array, and reordered matches +* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @returns {Object} object containing grouped matches, input types, and reordered matches */ function groupMatchesByInputType( matches ) { var reorderedMatches = []; @@ -251,15 +251,25 @@ function generateAddonFile( matches, header, basePkg ) { * @private */ function main() { + var filteredMatches; 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(); @@ -277,7 +287,7 @@ function main() { }); // Generate addon.c: - cOut = generateAddonFile( matches, header, basePkg ); + cOut = generateAddonFile( filteredMatches, header, basePkg ); writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { 'encoding': 'utf8' }); diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js deleted file mode 100644 index 0603c523c5e7..000000000000 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/get_dtypes.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @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 findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; -var rootDir = require( '@stdlib/_tools/utils/root-dir' ); -var readJSON = require( '@stdlib/fs/read-json' ).sync; - - -// VARIABLES // - -var ROOT_DIR = rootDir(); -var jsonOpts = { - 'encoding': 'utf8' -}; - - -// FUNCTIONS // - -/** -* Returns the input and output dtypes for a given package by reading scaffold metadata. -* -* @private -* @param {string} pkgPath - package path -* @returns {Array} input and output dtypes -* -* @example -* var dtypes = getDtypes( '@stdlib/math/base/special/sqrt' ); -* // returns [ 'float64', 'float64' ] -* -* @example -* var dtypes = getDtypes( '@stdlib/math/base/special/sqrtf' ); -* // returns [ 'float32', 'float32' ] -*/ -function getDtypes( pkgPath ) { - var packageJsonPath; - var outputDtype; - var inputDtype; - var path; - var json; - var pkg; - var out; - var o; - - // Find the package using the full package path: - packageJsonPath = pkgPath.replace('@stdlib/', '') + '/package.json'; - pkg = findPkgs({ - 'dir': ROOT_DIR, - 'pattern': '**/' + packageJsonPath - }); - - if ( pkg.length === 0 ) { - return []; - } - - // Get the metadata: - path = resolve( ROOT_DIR, pkg[ 0 ] ); - json = readJSON( resolve( path, 'package.json' ), jsonOpts ); - o = json.__stdlib__; // eslint-disable-line no-underscore-dangle - if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { - out = o.scaffold; - } - - // Extract input and output dtypes: - inputDtype = out.parameters[ 0 ].type.dtype; - outputDtype = out.returns.type.dtype; - - return [ inputDtype, outputDtype ]; -} - - -// EXPORTS // - -module.exports = getDtypes; diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js b/lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js deleted file mode 100644 index 74a3929877f2..000000000000 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/map_to_scalar_kernel.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @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 dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); -var format = require( '@stdlib/string/format' ); -var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); - - -// FUNCTIONS // - -/** -* Maps dtype pairs to appropriate scalar functions. -* -* ## Note -* -* - The function returns an array with the following structure: -* -* ```text -* --------------------------------------------------------------------------------- -* Array: | kernel | cFunc | ndarrayKernel | match | -* --------------------------------------------------------------------------------- -* | | | | -* | | | | -* V V V V -* Example: '@stdlib/math/base/ 'stdlib_base_sqrt' 'stdlib_ndarray_ ['float64', -* special/sqrt' f_d_as_d_d' 'float64'] -* ``` -* -* @private -* @param {Array} iopair - input-output dtype pair -* @param {Array} iodt - array of available scalar kernel dtypes -* @param {Object} scalarKernels - scalar kernels object -* @returns {Array} mapping result -* -* @example -* var iopair = [ 'float32', 'float64' ]; -* var iodt = [ -* [ 'float32', 'float32' ], -* [ 'float64', 'float64' ] -* ]; -* var scalarKernels = { -* 'float32': '@stdlib/math/base/special/sqrtf', -* 'float64': '@stdlib/math/base/special/sqrt' -* }; -* -* var result = mapToScalarKernel( iopair, iodt, scalarKernels ); -* // returns [ '@stdlib/math/base/special/sqrt', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d', [ 'float64', 'float64' ] ] -*/ -function mapToScalarKernel( iopair, iodt, scalarKernels ) { - var ndarrayKernel; - var precision1; - var precision2; - var matchChar1; - var matchChar2; - var outputChar; - var cFuncName; - var inputChar; - var kernel; - var match; - var dtype; - var i; - - inputChar = dtypeChar( iopair[ 0 ] ); - outputChar = dtypeChar( iopair[ 1 ] ); - - // For generic input, always use highest precision kernel - if ( iopair[ 0 ] === 'generic' ) { - kernel = scalarKernels.float64 || scalarKernels.generic; - cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); - ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_d_d', inputChar, outputChar ); - - return [ kernel, cFuncName, ndarrayKernel, [ 'float64', 'float64' ] ]; - } - - // Priority 1: Look for exact match in available scalar kernel dtypes: - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 0 ] && - iodt[ i ][ 1 ] === iopair[ 1 ] ) { - match = iodt[ i ]; - break; - } - } - - // Priority 2: Look for higher precision matches to break ties: - if ( !match ) { - /* - * Always prefer computing at higher precision: - * - For cases like ['float32', 'float64'], prefer computing at float64: f_d_as_d_d - * - For cases like ['int8', 'float32'], prefer computing at float32: s_f_as_f_f - */ - - // Get higher precision dtype using hierarchy table: - if ( iopair[ 0 ] === iopair[ 1 ] ) { - dtype = iopair[ 0 ]; - } else { - precision1 = DTYPE_HIERARCHY[ iopair[ 0 ] ] || 0; - precision2 = DTYPE_HIERARCHY[ iopair[ 1 ] ] || 0; - dtype = ( precision2 > precision1 ) ? iopair[ 1 ] : iopair[ 0 ]; - } - - // First try: Look for (higher_precision_dtype, higher_precision_dtype)... - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === dtype && iodt[ i ][ 1 ] === dtype ) { - match = iodt[ i ]; - break; - } - } - - // Second try: Look for (input_dtype, input_dtype) if higher precision not found... - if ( !match ) { - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 0 ] && - iodt[ i ][ 1 ] === iopair[ 0 ] ) { - match = iodt[ i ]; - break; - } - } - } - - // Third try: Look for (output_dtype, output_dtype)... - if ( !match ) { - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 1 ] && - iodt[ i ][ 1 ] === iopair[ 1 ] ) { - match = iodt[ i ]; - break; - } - } - } - } - - if ( match ) { - // Get the scalar kernel package - kernel = scalarKernels[ match[ 1 ] ]; - - // Generate C function name - cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); - - // Generate ndarray kernel name - if ( match[ 0 ] === iopair[ 0 ] && match[ 1 ] === iopair[ 1 ] ) { - // Exact match - ndarrayKernel = format( 'stdlib_ndarray_%s_%s', inputChar, outputChar ); - } else { - // Promotion case - matchChar1 = dtypeChar( match[ 0 ] ); - matchChar2 = dtypeChar( match[ 1 ] ); - ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', inputChar, outputChar, matchChar1, matchChar2 ); - } - - return [ kernel, cFuncName, ndarrayKernel, match ]; - } - - return []; -} - - -// EXPORTS // - -module.exports = mapToScalarKernel; diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js index 552490d4813c..995bda4a3a16 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js @@ -16,250 +16,305 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // -var basename = require( 'path' ).basename; var join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; var db = require( '@stdlib/math/special/scripts/function_database.json' ); -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var scaffoldDatabase = require( '@stdlib/math/special/scripts/scaffold_database.json' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); -var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); +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' ); -var mapToScalarKernel = require( './map_to_scalar_kernel.js' ); -var getDtypes = require( './get_dtypes.js' ); -var config = require( './config.js' ); // VARIABLES // -var DTYPES = {}; -var basePkg = basename( join( __dirname, '..' ) ); +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); -// MAIN // +// 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 { + // 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; +} /** -* Main execution sequence. +* Selects the appropriate ndarray kernel name for dtype casting. * -* ## Note +* @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 * -* - The function generates an array of matches, where each match is an array of the following format: +* @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' * -* ```text -* ---------------------------------------------------------------------------------------------------------------------------------------- -* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | -* ---------------------------------------------------------------------------------------------------------------------------------------- -* | | | | | | | | -* | | | | | | | | -* V V | V V V | V -* Example: 'float32' 'float64' | true 'float64' 'float64' | 'stdlib_ndarray_f_d_as_d_d' -* V V -* '@stdlib/math/base/special/sqrt' 'stdlib_base_sqrt' -* ``` +* @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 outputPrecision; - var outputIsComplex; var needsPromotion; - var inputIsComplex; - var inputPrecision; + var cFunctionName; + var allowedCasts; + var scalarKernel; var outputDtype; var inputDtype; - var filtered = []; + var kernelName; var mappings; - var kernels = []; - var iopairs; - var mapping; - var iodt = []; - var seen = {}; + var filtered; + var obj; var odt; var idt; - var out; - var obj; - var dt; - var k; var i; + var j; + var k; - // Resolve list of input dtypes: - idt = dtypes( config.input_dtypes ); - filtered = []; - for ( i = 0; i < idt.length; i++ ) { - if ( config.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { // Exclude irrelevant dtypes - filtered.push( idt[ i ] ); - } - } - idt = filtered; - - /* - For example, we'll have: - idt = [ - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'generic' - ] - */ + mappings = []; - // Resolve the list of output dtypes: - odt = dtypes( config.output_dtypes ); - filtered = []; - for ( i = 0; i < odt.length; i++ ) { - if ( config.excluded_dtypes.indexOf( odt[ i ] ) === -1 ) { // Exclude irrelevant dtypes - filtered.push( odt[ i ] ); - } - } - odt = filtered; + // Get scalar kernels and configuration for this function: + obj = db[ basePkg ]; /* - For example, we'll have: - odt = [ - 'float32', - 'float64' - ] + * 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" + * } + * } */ - // Computing the Cartesian product of input and output dtypes: - iopairs = cartesianProduct( idt, odt ); + // Get input dtypes: + idt = dtypes( obj.input_dtypes ); - /* - For example, we'll have: - iopairs = [ - [ 'float32', 'float32' ], - [ 'float32', 'float64' ], - [ 'float64', 'float32' ], - [ 'float64', 'float64' ], - ... - ] - */ - - // Filter based on dtype hierarchy and type compatibility: - for ( i = 0; i < iopairs.length; i++ ) { - inputDtype = iopairs[ i ][ 0 ]; - outputDtype = iopairs[ i ][ 1 ]; - inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; - outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; - - // Check if dtypes are compatible (real with real, complex with complex): - inputIsComplex = inputDtype.indexOf( 'complex' ) !== -1; - outputIsComplex = outputDtype.indexOf( 'complex' ) !== -1; - - /* Allow pairing only if: - 1. Same dtype - 2. Generic input - 3. Both are real dtypes with valid precision hierarchy - 4. Both are complex dtypes with valid precision hierarchy - */ - if ( inputDtype === outputDtype || - inputDtype === 'generic' || - ( !inputIsComplex && !outputIsComplex && outputPrecision >= inputPrecision ) || - ( inputIsComplex && outputIsComplex && outputPrecision >= inputPrecision ) ) { - filtered.push( iopairs[ i ] ); - } - } - iopairs = filtered; + // Get output dtypes: + odt = dtypes( obj.output_dtypes ); /* - For example, we'll have: - iopairs = [ - [ 'float32', 'float32' ], - [ 'float32', 'float64' ], - [ 'float64', 'float64' ], - ... - ] + * idt = [ + * 'complex32', + * 'complex64', + * 'complex128', + * 'float16', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'uint8c', + * 'generic' + * ] */ - // Get the list of dtypes with scalar math kernels: - obj = db[ basePkg ]; - - /* - For example, we'll have: - obj = { - "input_dtypes": "real_and_generic", - "output_dtypes": "real_floating_point", - "output_policy": "real_floating_point", - "scalar_kernels": { - "float32": "@stdlib/math/base/special/sqrtf", - "float64": "@stdlib/math/base/special/sqrt", - "generic": "@stdlib/math/base/special/sqrt" + // 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; /* - Available scalar kernel dtypes: - objectKeys( obj.scalar_kernels ) = [ - 'float32', - 'float64' - ] + * idt = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'generic' + * ] */ - // Build a list of scalar kernels based on output dtype: - for ( i = 0; iopairs && i < iopairs.length; i++ ) { - out = iopairs[ i ][ 1 ]; + // Generate all mostly-safe cast combinations: + for ( i = 0; i < idt.length; i++ ) { + inputDtype = idt[ i ]; + + /* + * For the first iteration: + * + * inputDtype = 'complex64' + */ - // For generic input, always use highest precision kernel: - if ( iopairs[ i ][ 0 ] === 'generic' ) { - k = obj.scalar_kernels.float64 || obj.scalar_kernels.generic; + if ( inputDtype === 'generic' ) { + continue; } else { - k = obj.scalar_kernels[ out ] || obj.scalar_kernels.generic; + // Get all dtypes this input can be mostly-safely cast to: + allowedCasts = mostlySafeCasts( inputDtype ); + + /* + * For the first iteration: + * + * allowedCasts = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64' + * ] + */ } - if ( k && !seen[ k ] ) { - seen[ k ] = true; - kernels.push( k ); + // 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; - // Resolve the input-output dtypes for each unique scalar kernel: - iodt = []; - for ( i = 0; i < kernels.length; i++ ) { - if ( DTYPES[ kernels[ i ] ] ) { - iodt.push( DTYPES[ kernels[ i ] ] ); - continue; - } - dt = getDtypes( kernels[ i ] ); - DTYPES[ kernels[ i ] ] = dt; - iodt.push( dt ); - } + // console.log( 'allowedCasts for input dtype %s: %s', inputDtype, allowedCasts ); - // Map dtype pairs to appropriate scalar functions based on prioritization rules: - mappings = []; - for ( i = 0; i < iopairs.length; i++ ) { - mapping = mapToScalarKernel( iopairs[ i ], iodt, obj.scalar_kernels ); - if ( mapping && mapping.length === 4 ) { - // Verify that the ndarray kernel exists in the function list - if ( NDARRAY_KERNELS.indexOf( mapping[ 2 ] ) !== -1 ) { - // Check if promotion is needed... - needsPromotion = mapping[ 3 ][ 0 ] !== iopairs[ i ][ 0 ] || - mapping[ 3 ][ 1 ] !== iopairs[ i ][ 1 ]; - - // [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ]... - mappings.push([ iopairs[ i ][ 0 ], iopairs[ i ][ 1 ], mapping[ 0 ], needsPromotion, ( needsPromotion ) ? mapping[ 3 ][ 0 ] : null, ( needsPromotion ) ? mapping[ 3 ][ 1 ] : null, mapping[ 1 ], mapping[ 2 ] ]); // eslint-disable-line max-len + 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 + ]); } } - /* - For example, we'll have: - mappings = [ - [ 'int8', 'float32', '@stdlib/math/base/special/sqrtf', true, 'float32', 'float32', 'stdlib_base_sqrtf', 'stdlib_ndarray_s_f_as_f_f' ], - [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf', false, null, null, 'stdlib_base_sqrtf', 'stdlib_ndarray_f_f' ], - [ 'float32', 'float64', '@stdlib/math/base/special/sqrt', true, 'float64', 'float64', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d' ], - [ 'float64', 'float64', '@stdlib/math/base/special/sqrt', false, null, null, 'stdlib_base_sqrt', 'stdlib_ndarray_d_d' ], - ... - ] - */ - return mappings; } diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js deleted file mode 100644 index 13d8ee48102b..000000000000 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/config.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Configuration object. -* -* @private -* @type {Object} -*/ -var config = { - 'input_dtypes': 'real_and_generic', - 'output_dtypes': 'real_floating_point', - 'excluded_dtypes': [ 'float16', 'uint8c' ] -}; - - -// EXPORTS // - -module.exports = config; 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 index 95dac3531db5..b599217e9f80 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -31,11 +31,11 @@ var pkg = require( './../package.json' ); // FUNCTIONS // /** -* Groups matches by input data type. +* Groups matches by input data type and returns grouped data, input types, and reordered matches. * * @private -* @param {Array} matches - array of match entries -* @returns {Object} object containing grouped matches, input types array, and reordered matches +* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @returns {Object} object containing grouped matches, input types, and reordered matches */ function groupMatchesByInputType( matches ) { var reorderedMatches = []; @@ -251,15 +251,25 @@ function generateAddonFile( matches, header, basePkg ) { * @private */ function main() { + var filteredMatches; 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(); @@ -277,7 +287,7 @@ function main() { }); // Generate addon.c: - cOut = generateAddonFile( matches, header, basePkg ); + cOut = generateAddonFile( filteredMatches, header, basePkg ); writeFileSync( join( __dirname, '../src/addon.c' ), cOut, { 'encoding': 'utf8' }); diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js deleted file mode 100644 index 0603c523c5e7..000000000000 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/get_dtypes.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @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 findPkgs = require( '@stdlib/_tools/pkgs/find' ).sync; -var rootDir = require( '@stdlib/_tools/utils/root-dir' ); -var readJSON = require( '@stdlib/fs/read-json' ).sync; - - -// VARIABLES // - -var ROOT_DIR = rootDir(); -var jsonOpts = { - 'encoding': 'utf8' -}; - - -// FUNCTIONS // - -/** -* Returns the input and output dtypes for a given package by reading scaffold metadata. -* -* @private -* @param {string} pkgPath - package path -* @returns {Array} input and output dtypes -* -* @example -* var dtypes = getDtypes( '@stdlib/math/base/special/sqrt' ); -* // returns [ 'float64', 'float64' ] -* -* @example -* var dtypes = getDtypes( '@stdlib/math/base/special/sqrtf' ); -* // returns [ 'float32', 'float32' ] -*/ -function getDtypes( pkgPath ) { - var packageJsonPath; - var outputDtype; - var inputDtype; - var path; - var json; - var pkg; - var out; - var o; - - // Find the package using the full package path: - packageJsonPath = pkgPath.replace('@stdlib/', '') + '/package.json'; - pkg = findPkgs({ - 'dir': ROOT_DIR, - 'pattern': '**/' + packageJsonPath - }); - - if ( pkg.length === 0 ) { - return []; - } - - // Get the metadata: - path = resolve( ROOT_DIR, pkg[ 0 ] ); - json = readJSON( resolve( path, 'package.json' ), jsonOpts ); - o = json.__stdlib__; // eslint-disable-line no-underscore-dangle - if ( o && o.scaffold && o.scaffold.parameters.length >= 1 ) { - out = o.scaffold; - } - - // Extract input and output dtypes: - inputDtype = out.parameters[ 0 ].type.dtype; - outputDtype = out.returns.type.dtype; - - return [ inputDtype, outputDtype ]; -} - - -// EXPORTS // - -module.exports = getDtypes; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js deleted file mode 100644 index 74a3929877f2..000000000000 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/map_to_scalar_kernel.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @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 dtypeChar = require( '@stdlib/ndarray/base/dtype-char' ); -var format = require( '@stdlib/string/format' ); -var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); - - -// FUNCTIONS // - -/** -* Maps dtype pairs to appropriate scalar functions. -* -* ## Note -* -* - The function returns an array with the following structure: -* -* ```text -* --------------------------------------------------------------------------------- -* Array: | kernel | cFunc | ndarrayKernel | match | -* --------------------------------------------------------------------------------- -* | | | | -* | | | | -* V V V V -* Example: '@stdlib/math/base/ 'stdlib_base_sqrt' 'stdlib_ndarray_ ['float64', -* special/sqrt' f_d_as_d_d' 'float64'] -* ``` -* -* @private -* @param {Array} iopair - input-output dtype pair -* @param {Array} iodt - array of available scalar kernel dtypes -* @param {Object} scalarKernels - scalar kernels object -* @returns {Array} mapping result -* -* @example -* var iopair = [ 'float32', 'float64' ]; -* var iodt = [ -* [ 'float32', 'float32' ], -* [ 'float64', 'float64' ] -* ]; -* var scalarKernels = { -* 'float32': '@stdlib/math/base/special/sqrtf', -* 'float64': '@stdlib/math/base/special/sqrt' -* }; -* -* var result = mapToScalarKernel( iopair, iodt, scalarKernels ); -* // returns [ '@stdlib/math/base/special/sqrt', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d', [ 'float64', 'float64' ] ] -*/ -function mapToScalarKernel( iopair, iodt, scalarKernels ) { - var ndarrayKernel; - var precision1; - var precision2; - var matchChar1; - var matchChar2; - var outputChar; - var cFuncName; - var inputChar; - var kernel; - var match; - var dtype; - var i; - - inputChar = dtypeChar( iopair[ 0 ] ); - outputChar = dtypeChar( iopair[ 1 ] ); - - // For generic input, always use highest precision kernel - if ( iopair[ 0 ] === 'generic' ) { - kernel = scalarKernels.float64 || scalarKernels.generic; - cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); - ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_d_d', inputChar, outputChar ); - - return [ kernel, cFuncName, ndarrayKernel, [ 'float64', 'float64' ] ]; - } - - // Priority 1: Look for exact match in available scalar kernel dtypes: - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 0 ] && - iodt[ i ][ 1 ] === iopair[ 1 ] ) { - match = iodt[ i ]; - break; - } - } - - // Priority 2: Look for higher precision matches to break ties: - if ( !match ) { - /* - * Always prefer computing at higher precision: - * - For cases like ['float32', 'float64'], prefer computing at float64: f_d_as_d_d - * - For cases like ['int8', 'float32'], prefer computing at float32: s_f_as_f_f - */ - - // Get higher precision dtype using hierarchy table: - if ( iopair[ 0 ] === iopair[ 1 ] ) { - dtype = iopair[ 0 ]; - } else { - precision1 = DTYPE_HIERARCHY[ iopair[ 0 ] ] || 0; - precision2 = DTYPE_HIERARCHY[ iopair[ 1 ] ] || 0; - dtype = ( precision2 > precision1 ) ? iopair[ 1 ] : iopair[ 0 ]; - } - - // First try: Look for (higher_precision_dtype, higher_precision_dtype)... - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === dtype && iodt[ i ][ 1 ] === dtype ) { - match = iodt[ i ]; - break; - } - } - - // Second try: Look for (input_dtype, input_dtype) if higher precision not found... - if ( !match ) { - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 0 ] && - iodt[ i ][ 1 ] === iopair[ 0 ] ) { - match = iodt[ i ]; - break; - } - } - } - - // Third try: Look for (output_dtype, output_dtype)... - if ( !match ) { - for ( i = 0; i < iodt.length; i++ ) { - if ( iodt[ i ][ 0 ] === iopair[ 1 ] && - iodt[ i ][ 1 ] === iopair[ 1 ] ) { - match = iodt[ i ]; - break; - } - } - } - } - - if ( match ) { - // Get the scalar kernel package - kernel = scalarKernels[ match[ 1 ] ]; - - // Generate C function name - cFuncName = 'stdlib_base_' + kernel.split( '/' ).pop(); - - // Generate ndarray kernel name - if ( match[ 0 ] === iopair[ 0 ] && match[ 1 ] === iopair[ 1 ] ) { - // Exact match - ndarrayKernel = format( 'stdlib_ndarray_%s_%s', inputChar, outputChar ); - } else { - // Promotion case - matchChar1 = dtypeChar( match[ 0 ] ); - matchChar2 = dtypeChar( match[ 1 ] ); - ndarrayKernel = format( 'stdlib_ndarray_%s_%s_as_%s_%s', inputChar, outputChar, matchChar1, matchChar2 ); - } - - return [ kernel, cFuncName, ndarrayKernel, match ]; - } - - return []; -} - - -// EXPORTS // - -module.exports = mapToScalarKernel; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js index 552490d4813c..995bda4a3a16 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -16,250 +16,305 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // -var basename = require( 'path' ).basename; var join = require( 'path' ).join; +var readJSON = require( '@stdlib/fs/read-json' ).sync; var db = require( '@stdlib/math/special/scripts/function_database.json' ); -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); +var scaffoldDatabase = require( '@stdlib/math/special/scripts/scaffold_database.json' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); -var DTYPE_HIERARCHY = require( '@stdlib/math/special/scripts/dtype_hierarchy.js' ); +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' ); -var mapToScalarKernel = require( './map_to_scalar_kernel.js' ); -var getDtypes = require( './get_dtypes.js' ); -var config = require( './config.js' ); // VARIABLES // -var DTYPES = {}; -var basePkg = basename( join( __dirname, '..' ) ); +var pkgPath = join( __dirname, '..', 'package.json' ); +var pkg = readJSON( pkgPath ); +var basePkg = pkg.name.split( '/' ).pop(); -// MAIN // +// 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 { + // 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; +} /** -* Main execution sequence. +* Selects the appropriate ndarray kernel name for dtype casting. * -* ## Note +* @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 * -* - The function generates an array of matches, where each match is an array of the following format: +* @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' * -* ```text -* ---------------------------------------------------------------------------------------------------------------------------------------- -* Array: | input_dtype | output_dtype | package | needs_to_promote | promoted_input_dtype | promoted_output_dtype | c_function_name | loop_kernel | -* ---------------------------------------------------------------------------------------------------------------------------------------- -* | | | | | | | | -* | | | | | | | | -* V V | V V V | V -* Example: 'float32' 'float64' | true 'float64' 'float64' | 'stdlib_ndarray_f_d_as_d_d' -* V V -* '@stdlib/math/base/special/sqrt' 'stdlib_base_sqrt' -* ``` +* @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 outputPrecision; - var outputIsComplex; var needsPromotion; - var inputIsComplex; - var inputPrecision; + var cFunctionName; + var allowedCasts; + var scalarKernel; var outputDtype; var inputDtype; - var filtered = []; + var kernelName; var mappings; - var kernels = []; - var iopairs; - var mapping; - var iodt = []; - var seen = {}; + var filtered; + var obj; var odt; var idt; - var out; - var obj; - var dt; - var k; var i; + var j; + var k; - // Resolve list of input dtypes: - idt = dtypes( config.input_dtypes ); - filtered = []; - for ( i = 0; i < idt.length; i++ ) { - if ( config.excluded_dtypes.indexOf( idt[ i ] ) === -1 ) { // Exclude irrelevant dtypes - filtered.push( idt[ i ] ); - } - } - idt = filtered; - - /* - For example, we'll have: - idt = [ - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'generic' - ] - */ + mappings = []; - // Resolve the list of output dtypes: - odt = dtypes( config.output_dtypes ); - filtered = []; - for ( i = 0; i < odt.length; i++ ) { - if ( config.excluded_dtypes.indexOf( odt[ i ] ) === -1 ) { // Exclude irrelevant dtypes - filtered.push( odt[ i ] ); - } - } - odt = filtered; + // Get scalar kernels and configuration for this function: + obj = db[ basePkg ]; /* - For example, we'll have: - odt = [ - 'float32', - 'float64' - ] + * 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" + * } + * } */ - // Computing the Cartesian product of input and output dtypes: - iopairs = cartesianProduct( idt, odt ); + // Get input dtypes: + idt = dtypes( obj.input_dtypes ); - /* - For example, we'll have: - iopairs = [ - [ 'float32', 'float32' ], - [ 'float32', 'float64' ], - [ 'float64', 'float32' ], - [ 'float64', 'float64' ], - ... - ] - */ - - // Filter based on dtype hierarchy and type compatibility: - for ( i = 0; i < iopairs.length; i++ ) { - inputDtype = iopairs[ i ][ 0 ]; - outputDtype = iopairs[ i ][ 1 ]; - inputPrecision = DTYPE_HIERARCHY[ inputDtype ] || 0; - outputPrecision = DTYPE_HIERARCHY[ outputDtype ] || 0; - - // Check if dtypes are compatible (real with real, complex with complex): - inputIsComplex = inputDtype.indexOf( 'complex' ) !== -1; - outputIsComplex = outputDtype.indexOf( 'complex' ) !== -1; - - /* Allow pairing only if: - 1. Same dtype - 2. Generic input - 3. Both are real dtypes with valid precision hierarchy - 4. Both are complex dtypes with valid precision hierarchy - */ - if ( inputDtype === outputDtype || - inputDtype === 'generic' || - ( !inputIsComplex && !outputIsComplex && outputPrecision >= inputPrecision ) || - ( inputIsComplex && outputIsComplex && outputPrecision >= inputPrecision ) ) { - filtered.push( iopairs[ i ] ); - } - } - iopairs = filtered; + // Get output dtypes: + odt = dtypes( obj.output_dtypes ); /* - For example, we'll have: - iopairs = [ - [ 'float32', 'float32' ], - [ 'float32', 'float64' ], - [ 'float64', 'float64' ], - ... - ] + * idt = [ + * 'complex32', + * 'complex64', + * 'complex128', + * 'float16', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'uint8c', + * 'generic' + * ] */ - // Get the list of dtypes with scalar math kernels: - obj = db[ basePkg ]; - - /* - For example, we'll have: - obj = { - "input_dtypes": "real_and_generic", - "output_dtypes": "real_floating_point", - "output_policy": "real_floating_point", - "scalar_kernels": { - "float32": "@stdlib/math/base/special/sqrtf", - "float64": "@stdlib/math/base/special/sqrt", - "generic": "@stdlib/math/base/special/sqrt" + // 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; /* - Available scalar kernel dtypes: - objectKeys( obj.scalar_kernels ) = [ - 'float32', - 'float64' - ] + * idt = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64', + * 'int16', + * 'int32', + * 'int8', + * 'uint16', + * 'uint32', + * 'uint8', + * 'generic' + * ] */ - // Build a list of scalar kernels based on output dtype: - for ( i = 0; iopairs && i < iopairs.length; i++ ) { - out = iopairs[ i ][ 1 ]; + // Generate all mostly-safe cast combinations: + for ( i = 0; i < idt.length; i++ ) { + inputDtype = idt[ i ]; + + /* + * For the first iteration: + * + * inputDtype = 'complex64' + */ - // For generic input, always use highest precision kernel: - if ( iopairs[ i ][ 0 ] === 'generic' ) { - k = obj.scalar_kernels.float64 || obj.scalar_kernels.generic; + if ( inputDtype === 'generic' ) { + continue; } else { - k = obj.scalar_kernels[ out ] || obj.scalar_kernels.generic; + // Get all dtypes this input can be mostly-safely cast to: + allowedCasts = mostlySafeCasts( inputDtype ); + + /* + * For the first iteration: + * + * allowedCasts = [ + * 'complex64', + * 'complex128', + * 'float32', + * 'float64' + * ] + */ } - if ( k && !seen[ k ] ) { - seen[ k ] = true; - kernels.push( k ); + // 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; - // Resolve the input-output dtypes for each unique scalar kernel: - iodt = []; - for ( i = 0; i < kernels.length; i++ ) { - if ( DTYPES[ kernels[ i ] ] ) { - iodt.push( DTYPES[ kernels[ i ] ] ); - continue; - } - dt = getDtypes( kernels[ i ] ); - DTYPES[ kernels[ i ] ] = dt; - iodt.push( dt ); - } + // console.log( 'allowedCasts for input dtype %s: %s', inputDtype, allowedCasts ); - // Map dtype pairs to appropriate scalar functions based on prioritization rules: - mappings = []; - for ( i = 0; i < iopairs.length; i++ ) { - mapping = mapToScalarKernel( iopairs[ i ], iodt, obj.scalar_kernels ); - if ( mapping && mapping.length === 4 ) { - // Verify that the ndarray kernel exists in the function list - if ( NDARRAY_KERNELS.indexOf( mapping[ 2 ] ) !== -1 ) { - // Check if promotion is needed... - needsPromotion = mapping[ 3 ][ 0 ] !== iopairs[ i ][ 0 ] || - mapping[ 3 ][ 1 ] !== iopairs[ i ][ 1 ]; - - // [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ]... - mappings.push([ iopairs[ i ][ 0 ], iopairs[ i ][ 1 ], mapping[ 0 ], needsPromotion, ( needsPromotion ) ? mapping[ 3 ][ 0 ] : null, ( needsPromotion ) ? mapping[ 3 ][ 1 ] : null, mapping[ 1 ], mapping[ 2 ] ]); // eslint-disable-line max-len + 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 + ]); } } - /* - For example, we'll have: - mappings = [ - [ 'int8', 'float32', '@stdlib/math/base/special/sqrtf', true, 'float32', 'float32', 'stdlib_base_sqrtf', 'stdlib_ndarray_s_f_as_f_f' ], - [ 'float32', 'float32', '@stdlib/math/base/special/sqrtf', false, null, null, 'stdlib_base_sqrtf', 'stdlib_ndarray_f_f' ], - [ 'float32', 'float64', '@stdlib/math/base/special/sqrt', true, 'float64', 'float64', 'stdlib_base_sqrt', 'stdlib_ndarray_f_d_as_d_d' ], - [ 'float64', 'float64', '@stdlib/math/base/special/sqrt', false, null, null, 'stdlib_base_sqrt', 'stdlib_ndarray_d_d' ], - ... - ] - */ - return mappings; } From f2edc8de59c413338232baa85145437a9f867998 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Wed, 20 Aug 2025 23:39:22 +0530 Subject: [PATCH 24/31] chore: add generated files for sin and sqrt --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/special/sin/lib/types.js | 35 +++++++---- .../@stdlib/math/special/sin/src/addon.c | 59 ++++++++++--------- .../@stdlib/math/special/sqrt/lib/types.js | 35 +++++++---- .../@stdlib/math/special/sqrt/src/addon.c | 59 ++++++++++--------- 4 files changed, 106 insertions(+), 82 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/sin/lib/types.js b/lib/node_modules/@stdlib/math/special/sin/lib/types.js index ba8b4897156e..09bc30e94e94 100644 --- a/lib/node_modules/@stdlib/math/special/sin/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/sin/lib/types.js @@ -30,34 +30,43 @@ var dtypes = require( '@stdlib/ndarray/dtypes' ); // MAIN // var types = [ - // float32 (2) - dtypes.float32, dtypes.float32, + // float32 (3) dtypes.float32, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.generic, - // float64 (1) + // float64 (3) dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.generic, - // int16 (2) - dtypes.int16, dtypes.float32, + // int16 (3) dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.generic, - // int32 (1) + // int32 (2) dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.generic, - // int8 (2) - dtypes.int8, dtypes.float32, + // int8 (3) dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.generic, - // uint16 (2) - dtypes.uint16, dtypes.float32, + // uint16 (3) dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.generic, - // uint32 (1) + // uint32 (2) dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.generic, - // uint8 (2) + // uint8 (3) + dtypes.uint8, dtypes.float64, dtypes.uint8, dtypes.float32, - dtypes.uint8, dtypes.float64 + dtypes.uint8, dtypes.generic ]; diff --git a/lib/node_modules/@stdlib/math/special/sin/src/addon.c b/lib/node_modules/@stdlib/math/special/sin/src/addon.c index 250c7b5bbe43..16c75cec1416 100644 --- a/lib/node_modules/@stdlib/math/special/sin/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/sin/src/addon.c @@ -17,8 +17,8 @@ */ /* This is a generated file. Do not edit directly. */ -#include "stdlib/math/base/special/sinf.h" #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" @@ -31,99 +31,102 @@ static const char name[] = "stdlib_ndarray_sin"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { // float32 (2) - stdlib_ndarray_f_f, stdlib_ndarray_f_d_as_d_d, + stdlib_ndarray_f_f, - // float64 (1) + // float64 (2) stdlib_ndarray_d_d, + stdlib_ndarray_d_f_as_d_d, // int16 (2) - stdlib_ndarray_k_f_as_f_f, 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_f_as_f_f, stdlib_ndarray_s_d_as_d_d, + stdlib_ndarray_s_f_as_f_f, // uint16 (2) - stdlib_ndarray_t_f_as_f_f, 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_f_as_f_f, 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_FLOAT32, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, - // float64 (1) + // float64 (2) STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, // int16 (2) - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, 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_FLOAT32, STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, // uint16 (2) - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, 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_FLOAT32, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, }; // Define a list of ndarray function "data" (in this case, callbacks): static void *data[] = { // float32 (2) - (void *)stdlib_base_sinf, - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, - // float64 (1) - (void *)stdlib_base_sin, + // float64 (2) + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sin, // int16 (2) - (void *)stdlib_base_sinf, - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, // int32 (1) - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, // int8 (2) - (void *)stdlib_base_sinf, - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, // uint16 (2) - (void *)stdlib_base_sinf, - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, // uint32 (1) - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, // uint8 (2) - (void *)stdlib_base_sinf, - (void *)stdlib_base_sin, + (void *)stdlib_math_base_special_sin, + (void *)stdlib_math_base_special_sinf, }; @@ -145,7 +148,7 @@ static const struct ndarrayFunctionObject obj = { functions, // Number of ndarray functions: - 13, + 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, diff --git a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js index ba8b4897156e..09bc30e94e94 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js @@ -30,34 +30,43 @@ var dtypes = require( '@stdlib/ndarray/dtypes' ); // MAIN // var types = [ - // float32 (2) - dtypes.float32, dtypes.float32, + // float32 (3) dtypes.float32, dtypes.float64, + dtypes.float32, dtypes.float32, + dtypes.float32, dtypes.generic, - // float64 (1) + // float64 (3) dtypes.float64, dtypes.float64, + dtypes.float64, dtypes.float32, + dtypes.float64, dtypes.generic, - // int16 (2) - dtypes.int16, dtypes.float32, + // int16 (3) dtypes.int16, dtypes.float64, + dtypes.int16, dtypes.float32, + dtypes.int16, dtypes.generic, - // int32 (1) + // int32 (2) dtypes.int32, dtypes.float64, + dtypes.int32, dtypes.generic, - // int8 (2) - dtypes.int8, dtypes.float32, + // int8 (3) dtypes.int8, dtypes.float64, + dtypes.int8, dtypes.float32, + dtypes.int8, dtypes.generic, - // uint16 (2) - dtypes.uint16, dtypes.float32, + // uint16 (3) dtypes.uint16, dtypes.float64, + dtypes.uint16, dtypes.float32, + dtypes.uint16, dtypes.generic, - // uint32 (1) + // uint32 (2) dtypes.uint32, dtypes.float64, + dtypes.uint32, dtypes.generic, - // uint8 (2) + // uint8 (3) + dtypes.uint8, dtypes.float64, dtypes.uint8, dtypes.float32, - dtypes.uint8, dtypes.float64 + dtypes.uint8, dtypes.generic ]; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c index bd7cada61ec3..ba414671a51f 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c @@ -17,8 +17,8 @@ */ /* This is a generated file. Do not edit directly. */ -#include "stdlib/math/base/special/sqrtf.h" #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" @@ -31,99 +31,102 @@ static const char name[] = "stdlib_ndarray_sqrt"; // Define a list of ndarray functions: static ndarrayFcn functions[] = { // float32 (2) - stdlib_ndarray_f_f, stdlib_ndarray_f_d_as_d_d, + stdlib_ndarray_f_f, - // float64 (1) + // float64 (2) stdlib_ndarray_d_d, + stdlib_ndarray_d_f_as_d_d, // int16 (2) - stdlib_ndarray_k_f_as_f_f, 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_f_as_f_f, stdlib_ndarray_s_d_as_d_d, + stdlib_ndarray_s_f_as_f_f, // uint16 (2) - stdlib_ndarray_t_f_as_f_f, 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_f_as_f_f, 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_FLOAT32, STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT32, STDLIB_NDARRAY_FLOAT32, - // float64 (1) + // float64 (2) STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_FLOAT64, STDLIB_NDARRAY_FLOAT32, // int16 (2) - STDLIB_NDARRAY_INT16, STDLIB_NDARRAY_FLOAT32, 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_FLOAT32, STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_INT8, STDLIB_NDARRAY_FLOAT32, // uint16 (2) - STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_FLOAT32, 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_FLOAT32, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, }; // Define a list of ndarray function "data" (in this case, callbacks): static void *data[] = { // float32 (2) - (void *)stdlib_base_sqrtf, - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, - // float64 (1) - (void *)stdlib_base_sqrt, + // float64 (2) + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrt, // int16 (2) - (void *)stdlib_base_sqrtf, - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, // int32 (1) - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, // int8 (2) - (void *)stdlib_base_sqrtf, - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, // uint16 (2) - (void *)stdlib_base_sqrtf, - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, // uint32 (1) - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, // uint8 (2) - (void *)stdlib_base_sqrtf, - (void *)stdlib_base_sqrt, + (void *)stdlib_math_base_special_sqrt, + (void *)stdlib_math_base_special_sqrtf, }; @@ -145,7 +148,7 @@ static const struct ndarrayFunctionObject obj = { functions, // Number of ndarray functions: - 13, + 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, From 877ef4e8197bad4a4d541e6f42be721562a8f020 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Fri, 22 Aug 2025 22:29:46 +0530 Subject: [PATCH 25/31] refactor: remove trailing comma, add generic pair --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/floor/scripts/generate_files.js | 21 ++++++++++++++++--- .../math/special/floor/scripts/script.js | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) 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 index b599217e9f80..74176559c2bd 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js @@ -183,8 +183,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; + cOut += '\t' + matches[ functionIndex ][ 7 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } @@ -198,8 +203,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; + 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'; } @@ -213,8 +223,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js index 995bda4a3a16..479669d19711 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -250,7 +250,7 @@ function main() { */ if ( inputDtype === 'generic' ) { - continue; + allowedCasts = [ 'generic' ]; } else { // Get all dtypes this input can be mostly-safely cast to: allowedCasts = mostlySafeCasts( inputDtype ); From 0741336639685b63e52a8bdd98d4fb3f9f650ce6 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Fri, 22 Aug 2025 22:39:04 +0530 Subject: [PATCH 26/31] refactor: remove trailing comma, add generic pair --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../fibonacci/scripts/generate_files.js | 21 ++++++++++++++++--- .../math/special/fibonacci/scripts/script.js | 2 +- .../special/sin/scripts/generate_files.js | 21 ++++++++++++++++--- .../math/special/sin/scripts/script.js | 2 +- .../special/sqrt/scripts/generate_files.js | 21 ++++++++++++++++--- .../math/special/sqrt/scripts/script.js | 2 +- 6 files changed, 57 insertions(+), 12 deletions(-) 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 index b599217e9f80..74176559c2bd 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js @@ -183,8 +183,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; + cOut += '\t' + matches[ functionIndex ][ 7 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } @@ -198,8 +203,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; + 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'; } @@ -213,8 +223,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js index 995bda4a3a16..479669d19711 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js @@ -250,7 +250,7 @@ function main() { */ if ( inputDtype === 'generic' ) { - continue; + allowedCasts = [ 'generic' ]; } else { // Get all dtypes this input can be mostly-safely cast to: allowedCasts = mostlySafeCasts( inputDtype ); 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 index b599217e9f80..74176559c2bd 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -183,8 +183,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; + cOut += '\t' + matches[ functionIndex ][ 7 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } @@ -198,8 +203,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; + 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'; } @@ -213,8 +223,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js index 995bda4a3a16..479669d19711 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js @@ -250,7 +250,7 @@ function main() { */ if ( inputDtype === 'generic' ) { - continue; + allowedCasts = [ 'generic' ]; } else { // Get all dtypes this input can be mostly-safely cast to: allowedCasts = mostlySafeCasts( inputDtype ); 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 index b599217e9f80..74176559c2bd 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -183,8 +183,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t' + matches[ functionIndex ][ 7 ] + ',\n'; + cOut += '\t' + matches[ functionIndex ][ 7 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } @@ -198,8 +203,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\tSTDLIB_NDARRAY_' + matches[ functionIndex ][ 0 ].toUpperCase() + ', STDLIB_NDARRAY_' + matches[ functionIndex ][ 1 ].toUpperCase() + ',\n'; + 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'; } @@ -213,8 +223,13 @@ function generateAddonFile( matches, header, basePkg ) { cOut += '\t// ' + inputType + ' (' + outputTypes.length + ')\n'; for ( j = 0; j < outputTypes.length; j++ ) { - cOut += '\t(void *)' + matches[ functionIndex ][ 6 ] + ',\n'; + cOut += '\t(void *)' + matches[ functionIndex ][ 6 ]; functionIndex += 1; + if ( functionIndex < matches.length ) { + cOut += ',\n'; + } else { + cOut += '\n'; + } } cOut += '\n'; } diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js index 995bda4a3a16..479669d19711 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -250,7 +250,7 @@ function main() { */ if ( inputDtype === 'generic' ) { - continue; + allowedCasts = [ 'generic' ]; } else { // Get all dtypes this input can be mostly-safely cast to: allowedCasts = mostlySafeCasts( inputDtype ); From d5100648bcdbb05e5faae8a5214a11552c52c35d Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Fri, 22 Aug 2025 22:44:15 +0530 Subject: [PATCH 27/31] chore: add generated files --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/special/fibonacci/lib/types.js | 5 ++++- lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c | 6 +++--- lib/node_modules/@stdlib/math/special/floor/lib/types.js | 5 ++++- lib/node_modules/@stdlib/math/special/floor/src/addon.c | 6 +++--- lib/node_modules/@stdlib/math/special/sin/lib/types.js | 5 ++++- lib/node_modules/@stdlib/math/special/sin/src/addon.c | 6 +++--- lib/node_modules/@stdlib/math/special/sqrt/lib/types.js | 5 ++++- lib/node_modules/@stdlib/math/special/sqrt/src/addon.c | 6 +++--- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js index 6ed08fe282eb..6d38c0803cc7 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/lib/types.js @@ -81,7 +81,10 @@ var types = [ dtypes.uint8, dtypes.uint32, dtypes.uint8, dtypes.uint16, dtypes.uint8, dtypes.uint8, - dtypes.uint8, dtypes.generic + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic ]; diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c index 110397bdaa8f..c7877a3d4f43 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/fibonacci/src/addon.c @@ -73,7 +73,7 @@ static ndarrayFcn functions[] = { 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, + stdlib_ndarray_b_b_as_i_f }; @@ -122,7 +122,7 @@ static int32_t types[] = { 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_UINT8 }; @@ -171,7 +171,7 @@ static void *data[] = { (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 }; diff --git a/lib/node_modules/@stdlib/math/special/floor/lib/types.js b/lib/node_modules/@stdlib/math/special/floor/lib/types.js index ba87c8a9f4a0..4df5e8b36939 100644 --- a/lib/node_modules/@stdlib/math/special/floor/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/floor/lib/types.js @@ -105,7 +105,10 @@ var types = [ dtypes.uint8, dtypes.uint8, dtypes.uint8, dtypes.complex128, dtypes.uint8, dtypes.complex64, - dtypes.uint8, dtypes.generic + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic ]; diff --git a/lib/node_modules/@stdlib/math/special/floor/src/addon.c b/lib/node_modules/@stdlib/math/special/floor/src/addon.c index 722385a68ee7..02a309065bd3 100644 --- a/lib/node_modules/@stdlib/math/special/floor/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/floor/src/addon.c @@ -103,7 +103,7 @@ static ndarrayFcn functions[] = { 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, + stdlib_ndarray_b_c_as_c_c }; @@ -174,7 +174,7 @@ static int32_t types[] = { STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT16, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX128, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX64, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_COMPLEX64 }; @@ -245,7 +245,7 @@ static void *data[] = { (void *)stdlib_number_uint16_base_identity, (void *)stdlib_number_uint8_base_identity, (void *)stdlib_math_base_special_cfloor, - (void *)stdlib_math_base_special_cfloorf, + (void *)stdlib_math_base_special_cfloorf }; diff --git a/lib/node_modules/@stdlib/math/special/sin/lib/types.js b/lib/node_modules/@stdlib/math/special/sin/lib/types.js index 09bc30e94e94..c44d4cf38a19 100644 --- a/lib/node_modules/@stdlib/math/special/sin/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/sin/lib/types.js @@ -66,7 +66,10 @@ var types = [ // uint8 (3) dtypes.uint8, dtypes.float64, dtypes.uint8, dtypes.float32, - dtypes.uint8, dtypes.generic + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic ]; diff --git a/lib/node_modules/@stdlib/math/special/sin/src/addon.c b/lib/node_modules/@stdlib/math/special/sin/src/addon.c index 16c75cec1416..c1a6bfd44227 100644 --- a/lib/node_modules/@stdlib/math/special/sin/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/sin/src/addon.c @@ -58,7 +58,7 @@ static ndarrayFcn functions[] = { // uint8 (2) stdlib_ndarray_b_d_as_d_d, - stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_f_as_f_f }; @@ -92,7 +92,7 @@ static int32_t types[] = { // uint8 (2) STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32 }; @@ -126,7 +126,7 @@ static void *data[] = { // uint8 (2) (void *)stdlib_math_base_special_sin, - (void *)stdlib_math_base_special_sinf, + (void *)stdlib_math_base_special_sinf }; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js index 09bc30e94e94..c44d4cf38a19 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/lib/types.js @@ -66,7 +66,10 @@ var types = [ // uint8 (3) dtypes.uint8, dtypes.float64, dtypes.uint8, dtypes.float32, - dtypes.uint8, dtypes.generic + dtypes.uint8, dtypes.generic, + + // generic (1) + dtypes.generic, dtypes.generic ]; diff --git a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c index ba414671a51f..eb06def94d6b 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c +++ b/lib/node_modules/@stdlib/math/special/sqrt/src/addon.c @@ -58,7 +58,7 @@ static ndarrayFcn functions[] = { // uint8 (2) stdlib_ndarray_b_d_as_d_d, - stdlib_ndarray_b_f_as_f_f, + stdlib_ndarray_b_f_as_f_f }; @@ -92,7 +92,7 @@ static int32_t types[] = { // uint8 (2) STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT64, - STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32, + STDLIB_NDARRAY_UINT8, STDLIB_NDARRAY_FLOAT32 }; @@ -126,7 +126,7 @@ static void *data[] = { // uint8 (2) (void *)stdlib_math_base_special_sqrt, - (void *)stdlib_math_base_special_sqrtf, + (void *)stdlib_math_base_special_sqrtf }; From 860301567059f7da7879534fae94022eeedc3416 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 23 Aug 2025 10:44:57 +0530 Subject: [PATCH 28/31] feat: generate data.js and meta.json too --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/floor/scripts/generate_files.js | 150 +++++++++++++++++- .../math/special/floor/scripts/script.js | 3 + 2 files changed, 148 insertions(+), 5 deletions(-) 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 index 74176559c2bd..50e5573002f1 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-lines */ + 'use strict'; // MODULES // @@ -24,6 +26,9 @@ 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 generateMatchesTable = require( './script.js' ); var pkg = require( './../package.json' ); @@ -34,7 +39,7 @@ var pkg = require( './../package.json' ); * Groups matches by input data type and returns grouped data, input types, and reordered matches. * * @private -* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @param {Array} matches - array of match arrays * @returns {Object} object containing grouped matches, input types, and reordered matches */ function groupMatchesByInputType( matches ) { @@ -97,7 +102,7 @@ function generateTypesFile( matches, header ) { jsOut += '// MAIN //\n\n'; jsOut += 'var types = [\n'; - // Group matches by input dtype... + // Group matches by input dtype: result = groupMatchesByInputType( matches ); grouped = result.grouped; inputTypes = result.inputTypes; @@ -115,7 +120,7 @@ function generateTypesFile( matches, header ) { } } - // Add blank line between input type groups ( except for the last one )... + // Blank line between input type groups: if ( i < inputTypes.length - 1 ) { jsOut += '\n'; } @@ -127,6 +132,127 @@ function generateTypesFile( matches, header ) { 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 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. * @@ -153,13 +279,13 @@ function generateAddonFile( matches, header, basePkg ) { uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { // Extract the full package path from the scalar kernel path: - kernelPath = matches[ i ][ 2 ]; // Package path is at index 2 + kernelPath = matches[ i ][ 2 ]; includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; uniqueIncludes[ '#include "' + includePath + '"' ] = true; } - // Group matches by input type... + // Group matches by input type: result = groupMatchesByInputType( matches ); grouped = result.grouped; matches = result.reorderedMatches; @@ -267,6 +393,8 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var metaOut; + var dataOut; var basePkg; var matches; var header; @@ -301,6 +429,18 @@ function main() { '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, { diff --git a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js index 479669d19711..2f8805783331 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/script.js @@ -73,6 +73,9 @@ function selectScalarKernel( scalarKernels, outputDtype, inputDtype ) { 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' From 66c131584b828eb9b0471983edd236dc1a73d00a Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 23 Aug 2025 10:48:33 +0530 Subject: [PATCH 29/31] feat: generate data.js and meta.json too --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../fibonacci/scripts/generate_files.js | 150 +++++++++++++++++- .../math/special/fibonacci/scripts/script.js | 3 + .../special/sin/scripts/generate_files.js | 150 +++++++++++++++++- .../math/special/sin/scripts/script.js | 3 + .../special/sqrt/scripts/generate_files.js | 150 +++++++++++++++++- .../math/special/sqrt/scripts/script.js | 3 + 6 files changed, 444 insertions(+), 15 deletions(-) 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 index 74176559c2bd..50e5573002f1 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-lines */ + 'use strict'; // MODULES // @@ -24,6 +26,9 @@ 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 generateMatchesTable = require( './script.js' ); var pkg = require( './../package.json' ); @@ -34,7 +39,7 @@ var pkg = require( './../package.json' ); * Groups matches by input data type and returns grouped data, input types, and reordered matches. * * @private -* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @param {Array} matches - array of match arrays * @returns {Object} object containing grouped matches, input types, and reordered matches */ function groupMatchesByInputType( matches ) { @@ -97,7 +102,7 @@ function generateTypesFile( matches, header ) { jsOut += '// MAIN //\n\n'; jsOut += 'var types = [\n'; - // Group matches by input dtype... + // Group matches by input dtype: result = groupMatchesByInputType( matches ); grouped = result.grouped; inputTypes = result.inputTypes; @@ -115,7 +120,7 @@ function generateTypesFile( matches, header ) { } } - // Add blank line between input type groups ( except for the last one )... + // Blank line between input type groups: if ( i < inputTypes.length - 1 ) { jsOut += '\n'; } @@ -127,6 +132,127 @@ function generateTypesFile( matches, header ) { 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 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. * @@ -153,13 +279,13 @@ function generateAddonFile( matches, header, basePkg ) { uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { // Extract the full package path from the scalar kernel path: - kernelPath = matches[ i ][ 2 ]; // Package path is at index 2 + kernelPath = matches[ i ][ 2 ]; includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; uniqueIncludes[ '#include "' + includePath + '"' ] = true; } - // Group matches by input type... + // Group matches by input type: result = groupMatchesByInputType( matches ); grouped = result.grouped; matches = result.reorderedMatches; @@ -267,6 +393,8 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var metaOut; + var dataOut; var basePkg; var matches; var header; @@ -301,6 +429,18 @@ function main() { '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, { diff --git a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js index 479669d19711..2f8805783331 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/script.js @@ -73,6 +73,9 @@ function selectScalarKernel( scalarKernels, outputDtype, inputDtype ) { 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' 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 index 74176559c2bd..50e5573002f1 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-lines */ + 'use strict'; // MODULES // @@ -24,6 +26,9 @@ 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 generateMatchesTable = require( './script.js' ); var pkg = require( './../package.json' ); @@ -34,7 +39,7 @@ var pkg = require( './../package.json' ); * Groups matches by input data type and returns grouped data, input types, and reordered matches. * * @private -* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @param {Array} matches - array of match arrays * @returns {Object} object containing grouped matches, input types, and reordered matches */ function groupMatchesByInputType( matches ) { @@ -97,7 +102,7 @@ function generateTypesFile( matches, header ) { jsOut += '// MAIN //\n\n'; jsOut += 'var types = [\n'; - // Group matches by input dtype... + // Group matches by input dtype: result = groupMatchesByInputType( matches ); grouped = result.grouped; inputTypes = result.inputTypes; @@ -115,7 +120,7 @@ function generateTypesFile( matches, header ) { } } - // Add blank line between input type groups ( except for the last one )... + // Blank line between input type groups: if ( i < inputTypes.length - 1 ) { jsOut += '\n'; } @@ -127,6 +132,127 @@ function generateTypesFile( matches, header ) { 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 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. * @@ -153,13 +279,13 @@ function generateAddonFile( matches, header, basePkg ) { uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { // Extract the full package path from the scalar kernel path: - kernelPath = matches[ i ][ 2 ]; // Package path is at index 2 + kernelPath = matches[ i ][ 2 ]; includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; uniqueIncludes[ '#include "' + includePath + '"' ] = true; } - // Group matches by input type... + // Group matches by input type: result = groupMatchesByInputType( matches ); grouped = result.grouped; matches = result.reorderedMatches; @@ -267,6 +393,8 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var metaOut; + var dataOut; var basePkg; var matches; var header; @@ -301,6 +429,18 @@ function main() { '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, { diff --git a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js index 479669d19711..2f8805783331 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/script.js @@ -73,6 +73,9 @@ function selectScalarKernel( scalarKernels, outputDtype, inputDtype ) { 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' 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 index 74176559c2bd..50e5573002f1 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-lines */ + 'use strict'; // MODULES // @@ -24,6 +26,9 @@ 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 generateMatchesTable = require( './script.js' ); var pkg = require( './../package.json' ); @@ -34,7 +39,7 @@ var pkg = require( './../package.json' ); * Groups matches by input data type and returns grouped data, input types, and reordered matches. * * @private -* @param {Array} matches - array of match arrays, where each match is [ input_dtype, output_dtype, package, needs_to_promote, promoted_input_dtype, promoted_output_dtype, c_function_name, loop_kernel ] +* @param {Array} matches - array of match arrays * @returns {Object} object containing grouped matches, input types, and reordered matches */ function groupMatchesByInputType( matches ) { @@ -97,7 +102,7 @@ function generateTypesFile( matches, header ) { jsOut += '// MAIN //\n\n'; jsOut += 'var types = [\n'; - // Group matches by input dtype... + // Group matches by input dtype: result = groupMatchesByInputType( matches ); grouped = result.grouped; inputTypes = result.inputTypes; @@ -115,7 +120,7 @@ function generateTypesFile( matches, header ) { } } - // Add blank line between input type groups ( except for the last one )... + // Blank line between input type groups: if ( i < inputTypes.length - 1 ) { jsOut += '\n'; } @@ -127,6 +132,127 @@ function generateTypesFile( matches, header ) { 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 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. * @@ -153,13 +279,13 @@ function generateAddonFile( matches, header, basePkg ) { uniqueIncludes = {}; for ( i = 0; i < matches.length; i++ ) { // Extract the full package path from the scalar kernel path: - kernelPath = matches[ i ][ 2 ]; // Package path is at index 2 + kernelPath = matches[ i ][ 2 ]; includePath = kernelPath.replace( '@stdlib/', 'stdlib/' ) + '.h'; uniqueIncludes[ '#include "' + includePath + '"' ] = true; } - // Group matches by input type... + // Group matches by input type: result = groupMatchesByInputType( matches ); grouped = result.grouped; matches = result.reorderedMatches; @@ -267,6 +393,8 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var metaOut; + var dataOut; var basePkg; var matches; var header; @@ -301,6 +429,18 @@ function main() { '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, { diff --git a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js index 479669d19711..2f8805783331 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/script.js @@ -73,6 +73,9 @@ function selectScalarKernel( scalarKernels, outputDtype, inputDtype ) { 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' From 58b7f7e59fc941b058b2bb1c7d461e2e4c71efed Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 23 Aug 2025 10:50:58 +0530 Subject: [PATCH 30/31] chore: add generated files --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/fibonacci/lib/data.js | 96 +++++++++++++ .../math/special/fibonacci/lib/meta.json | 5 + .../@stdlib/math/special/floor/lib/data.js | 128 ++++++++++++++++++ .../@stdlib/math/special/floor/lib/meta.json | 5 + .../@stdlib/math/special/sin/lib/data.js | 81 +++++++++++ .../@stdlib/math/special/sin/lib/meta.json | 5 + .../@stdlib/math/special/sqrt/lib/data.js | 81 +++++++++++ .../@stdlib/math/special/sqrt/lib/meta.json | 5 + 8 files changed, 406 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/lib/data.js create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/lib/meta.json create mode 100644 lib/node_modules/@stdlib/math/special/floor/lib/data.js create mode 100644 lib/node_modules/@stdlib/math/special/floor/lib/meta.json create mode 100644 lib/node_modules/@stdlib/math/special/sin/lib/data.js create mode 100644 lib/node_modules/@stdlib/math/special/sin/lib/meta.json create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/lib/data.js create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/lib/meta.json 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/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/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/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 +} From b5a9e02f4082168c46a4a0538b6167b93b4f0c40 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Sat, 23 Aug 2025 11:09:45 +0530 Subject: [PATCH 31/31] feat: generate types.json --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/special/fibonacci/lib/types.json | 1 + .../fibonacci/scripts/generate_files.js | 30 +++++++++++++++++++ .../@stdlib/math/special/floor/lib/types.json | 1 + .../special/floor/scripts/generate_files.js | 30 +++++++++++++++++++ .../@stdlib/math/special/sin/lib/types.json | 1 + .../special/sin/scripts/generate_files.js | 30 +++++++++++++++++++ .../@stdlib/math/special/sqrt/lib/types.json | 1 + .../special/sqrt/scripts/generate_files.js | 30 +++++++++++++++++++ 8 files changed, 124 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/special/fibonacci/lib/types.json create mode 100644 lib/node_modules/@stdlib/math/special/floor/lib/types.json create mode 100644 lib/node_modules/@stdlib/math/special/sin/lib/types.json create mode 100644 lib/node_modules/@stdlib/math/special/sqrt/lib/types.json 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/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js index 50e5573002f1..d54a3da7601f 100644 --- a/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/fibonacci/scripts/generate_files.js @@ -29,6 +29,7 @@ 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' ); @@ -147,6 +148,28 @@ function generateMetaFile() { 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. * @@ -393,6 +416,7 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var typesJsonOut; var metaOut; var dataOut; var basePkg; @@ -429,6 +453,12 @@ function main() { '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, { 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/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js index 50e5573002f1..d54a3da7601f 100644 --- a/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/floor/scripts/generate_files.js @@ -29,6 +29,7 @@ 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' ); @@ -147,6 +148,28 @@ function generateMetaFile() { 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. * @@ -393,6 +416,7 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var typesJsonOut; var metaOut; var dataOut; var basePkg; @@ -429,6 +453,12 @@ function main() { '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, { 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/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js index 50e5573002f1..d54a3da7601f 100644 --- a/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sin/scripts/generate_files.js @@ -29,6 +29,7 @@ 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' ); @@ -147,6 +148,28 @@ function generateMetaFile() { 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. * @@ -393,6 +416,7 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var typesJsonOut; var metaOut; var dataOut; var basePkg; @@ -429,6 +453,12 @@ function main() { '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, { 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/scripts/generate_files.js b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js index 50e5573002f1..d54a3da7601f 100644 --- a/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js +++ b/lib/node_modules/@stdlib/math/special/sqrt/scripts/generate_files.js @@ -29,6 +29,7 @@ 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' ); @@ -147,6 +148,28 @@ function generateMetaFile() { 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. * @@ -393,6 +416,7 @@ function generateAddonFile( matches, header, basePkg ) { */ function main() { var filteredMatches; + var typesJsonOut; var metaOut; var dataOut; var basePkg; @@ -429,6 +453,12 @@ function main() { '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, {