From 56dab208b05e42985315dd235f4d8612b0397c87 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 22 Jul 2025 07:47:39 +0530 Subject: [PATCH 01/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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 )