From 0895ff98203cbde3c1f9ea7e52549610a91d61e0 Mon Sep 17 00:00:00 2001 From: vivek maurya Date: Wed, 15 Jan 2025 10:46:08 +0000 Subject: [PATCH 01/10] feat(add c implementation): add math/base/special/cabs2f --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: failed --- --- .../math/base/special/cabs2f/README.md | 6 +- .../cabs2f/benchmark/benchmark.native.js | 65 +++++++ .../special/cabs2f/benchmark/c/benchmark.c | 28 ++- .../math/base/special/cabs2f/binding.gyp | 170 ++++++++++++++++++ .../base/special/cabs2f/examples/c/example.c | 17 +- .../math/base/special/cabs2f/include.gypi | 53 ++++++ .../include/stdlib/math/base/special/cabs2f.h | 4 +- .../math/base/special/cabs2f/lib/native.js | 48 +++++ .../math/base/special/cabs2f/manifest.json | 109 +++++++---- .../math/base/special/cabs2f/package.json | 1 + .../math/base/special/cabs2f/src/Makefile | 70 ++++++++ .../math/base/special/cabs2f/src/addon.c | 23 +++ .../math/base/special/cabs2f/src/main.c | 18 +- .../math/base/special/cabs2f/test/test.js | 6 +- .../base/special/cabs2f/test/test.native.js | 92 ++++++++++ 15 files changed, 641 insertions(+), 69 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md index 39cc61ff6c5d..ef48da5a0ada 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md @@ -139,9 +139,11 @@ for ( i = 0; i < 100; i++ ) { Computes the squared [absolute value][absolute-value] of a single-precision complex floating-point number. ```c -#include +#include "stdlib/complex/float32/ctor.h" + +stdlib_complex64_t z = stdlib_complex64( 5.0, 3.0 ); -float y = stdlib_base_cabs2f( 5.0+3.0*I ); +float y = stdlib_base_cabs2f( z ); // returns 34.0f ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js new file mode 100644 index 000000000000..556202f880dc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var cabs2f = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( cabs2f instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var values; + var y; + var i; + + values = [ + new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), + new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = cabs2f( values[ i%values.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c index 499af2bb548b..18c626fe975a 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c @@ -16,10 +16,12 @@ * limitations under the License. */ +#include "stdlib/math/base/special/cabs2f.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include #include #include -#include #include #define NAME "cabs2f" @@ -83,23 +85,12 @@ static float rand_float( void ) { return (float)r / ( (float)RAND_MAX + 1.0f ); } -/** -* Computes the squared absolute value of a complex number. -* -* @param z input value -* @return squared absolute value -*/ -float cabs2f( float complex z ) { - return ( crealf(z)*crealf(z) ) + ( cimagf(z)*cimagf(z) ); -} - /** * Runs a benchmark. * * @return elapsed time in seconds */ static double benchmark( void ) { - float complex z; double elapsed; double t; float re; @@ -107,12 +98,17 @@ static double benchmark( void ) { float y; int i; + stdlib_complex64_t z[ 100 ]; + + for ( i = 0; i < 100; i++ ) { + re = ( 1000.0f * rand_float() ) - 500.0f; + im = ( 1000.0f * rand_float() ) - 500.0f; + z[ i ] = stdlib_complex64( re, im ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - re = ( 1000.0f*rand_float() ) - 500.0f; - im = ( 1000.0f*rand_float() ) - 500.0f; - z = re + im*I; - y = cabs2f( z ); + y = stdlib_base_cabs2f( z[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp b/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp new file mode 100644 index 000000000000..f2b466aef5c4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2023 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c index 5e46ab652b1a..63d1f720b42f 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c @@ -17,18 +17,27 @@ */ #include "stdlib/math/base/special/cabs2f.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include -#include int main( void ) { - float complex x[] = { 3.14f+1.0f*I, -3.14f-1.0f*I, 0.0f+0.0f*I, 0.0f/0.0f+0.0f/0.0f*I }; + const stdlib_complex64_t x[] = { + stdlib_complex64( 3.14f, 1.0f ), + stdlib_complex64( -3.14f, -1.0f ), + stdlib_complex64( 0.0f, 0.0f ), + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) + }; - float complex v; + stdlib_complex64_t v; + float re; + float im; float y; int i; for ( i = 0; i < 4; i++ ) { v = x[ i ]; y = stdlib_base_cabs2f( v ); - printf( "f(%f + %f) = %f\n", crealf( v ), cimagf( v ), y ); + stdlib_complex64_reim( v, &re, &im ); + printf( "f(%f + %f) = %f\n", re, im, y ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi b/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi new file mode 100644 index 000000000000..78db9faf8c74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2023 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' +#include "stdlib/complex/float32/ctor.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -31,7 +31,7 @@ extern "C" { /** * Computes the squared absolute value of a single-precision complex floating-point number. */ -float stdlib_base_cabs2f( const float complex z ); +float stdlib_base_cabs2f( const stdlib_complex64_t z ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js new file mode 100644 index 000000000000..6c14410d1c57 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the squared absolute value of a single-precision complex floating-point number. +* +* @private +* @param {Complex64} z - complex number +* @returns {number} squared absolute value +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var v = cabs2f( new Complex64( 5.0, 3.0 ) ); +* // returns 34.0 +*/ +function cabs2f( z ) { + return addon( z ); +} + + +// EXPORTS // + +module.exports = cabs2f; diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/manifest.json b/lib/node_modules/@stdlib/math/base/special/cabs2f/manifest.json index 890a937a3dc0..b36aa0ccd4c6 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/manifest.json @@ -1,38 +1,75 @@ { - "options": {}, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [] - } - ] + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float32/reim" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float32/reim" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/float32/reim" + ] + } + ] } diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/package.json b/lib/node_modules/@stdlib/math/base/special/cabs2f/package.json index 2e31d01d6154..2c268482d0c5 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/package.json +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/package.json @@ -14,6 +14,7 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile new file mode 100644 index 000000000000..904c7dc4bd7a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2023 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c new file mode 100644 index 000000000000..ee70bcb84d33 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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. +*/ + +#include "stdlib/math/base/special/cabs2f.h" +#include "stdlib/math/base/napi/unary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_C_F( stdlib_base_cabs2f ) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c index f83b3faa0595..602da67da23d 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c @@ -17,7 +17,8 @@ */ #include "stdlib/math/base/special/cabs2f.h" -#include +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" /** * Computes the squared absolute value of a single-precision complex floating-point number. @@ -26,11 +27,16 @@ * @return result * * @example -* float y = stdlib_base_cabs2f( 5.0+3.0*I ); +* #include "stdlib/complex/float32/ctor.h" +* +* stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f ); +* +* float out = stdlib_base_cabs2f( z ); * // returns 34.0f */ -float stdlib_base_cabs2f( const float complex z ) { - float re = crealf( z ); - float im = cimagf( z ); - return (re*re) + (im*im); +float stdlib_base_cabs2f( const stdlib_complex64_t z ) { + float re ; + float im ; + stdlib_complex64_reim( z, &re, &im ); + return ( re * re ) + ( im * im ); } diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js index 5dafe7f9ffbc..40d002c8e483 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js @@ -23,7 +23,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var EPS = require( '@stdlib/constants/float32/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var absf = require( '@stdlib/math/base/special/absf' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var cabs2f = require( './../lib' ); @@ -59,8 +59,8 @@ tape( 'the function computes the squared absolute value of a complex number', fu if ( y === expected[ i ] ) { t.equal( y, expected[ i ], 're: '+re[i]+'. im: '+im[i]+'. Expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); + delta = absf( y - expected[i] ); + tol = EPS * absf( expected[i] ); t.ok( delta <= tol, 'within tolerance. re: '+re[i]+'. im: '+im[i]+' y: '+y+'. Expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js new file mode 100644 index 000000000000..3b8847f9a78b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var cabs2f = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( cabs2f instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cabs2f, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the squared absolute value of a complex number', opts, function test( t ) { + var expected; + var delta; + var tol; + var re; + var im; + var y; + var i; + + re = data.re; + im = data.im; + expected = data.expected; + + for ( i = 0; i < re.length; i++ ) { + y = cabs2f( new Complex64( re[ i ], im[ i ] ) ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 're: '+re[i]+'. im: '+im[i]+'. Expected: '+expected[i] ); + } else { + delta = absf( y - expected[i] ); + tol = EPS * absf( expected[i] ); + t.ok( delta <= tol, 'within tolerance. re: '+re[i]+'. im: '+im[i]+' y: '+y+'. Expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'if either the real or imaginary component is `NaN`, the function returns `NaN`', opts, function test( t ) { + var v; + + v = cabs2f( new Complex64( NaN, 3.0 ) ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + v = cabs2f( new Complex64( 5.0, NaN ) ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + v = cabs2f( new Complex64( NaN, NaN ) ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); + + t.end(); +}); From 97cc4aed09038626b56c94932801ba583ea94ce0 Mon Sep 17 00:00:00 2001 From: vivek maurya Date: Wed, 15 Jan 2025 11:09:05 +0000 Subject: [PATCH 02/10] feat(add c implementation): add math/base/special/cabs2f --- .../math/base/special/cabs2f/README.md | 23 +++++++++++++------ .../math/base/special/cabs2f/test/test.js | 6 ++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md index ef48da5a0ada..098902b01c43 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md @@ -149,10 +149,10 @@ float y = stdlib_base_cabs2f( z ); The function accepts the following arguments: -- **z**: `[in] float complex` input value. +- **z**: `[in] stdlib_complex64_t` input value. ```c -float stdlib_base_cabs2f( const float complex z ); +float stdlib_base_cabs2f( const stdlib_complex64_t z ); ``` @@ -175,19 +175,28 @@ float stdlib_base_cabs2f( const float complex z ); ```c #include "stdlib/math/base/special/cabs2f.h" +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include -#include int main( void ) { - const float complex x[] = { 3.14f+1.0f*I, -3.14f-1.0f*I, 0.0f+0.0f*I, 0.0f/0.0f+0.0f/0.0f*I }; - - float complex v; + const stdlib_complex64_t x[] = { + stdlib_complex64( 3.14f, 1.0f ), + stdlib_complex64( -3.14f, -1.0f ), + stdlib_complex64( 0.0f, 0.0f ), + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) + }; + + stdlib_complex64_t v; + float re; + float im; float y; int i; for ( i = 0; i < 4; i++ ) { v = x[ i ]; y = stdlib_base_cabs2f( v ); - printf( "f(%f + %f) = %f\n", crealf( v ), cimagf( v ), y ); + stdlib_complex64_reim( v, &re, &im ); + printf( "f(%f + %f) = %f\n", re, im, y ); } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js index 40d002c8e483..01123f34e0f9 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.js @@ -71,13 +71,13 @@ tape( 'if either the real or imaginary component is `NaN`, the function returns var v; v = cabs2f( new Complex64( NaN, 3.0 ) ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); v = cabs2f( new Complex64( 5.0, NaN ) ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); v = cabs2f( new Complex64( NaN, NaN ) ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns expected value' ); t.end(); }); From 1954bd5f09fa1b39e481a28588822f75d5e4114c Mon Sep 17 00:00:00 2001 From: vivek maurya Date: Wed, 15 Jan 2025 16:59:36 +0000 Subject: [PATCH 03/10] feat(add c implementation): add math/base/special/cabs2f --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../special/cabs2f/benchmark/c/benchmark.c | 28 +++++++++++-------- .../cabs2f/benchmark/c/native/benchmark.c | 17 +++++++---- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c index 18c626fe975a..499af2bb548b 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/benchmark.c @@ -16,12 +16,10 @@ * limitations under the License. */ -#include "stdlib/math/base/special/cabs2f.h" -#include "stdlib/complex/float32/ctor.h" -#include "stdlib/complex/float32/reim.h" #include #include #include +#include #include #define NAME "cabs2f" @@ -85,12 +83,23 @@ static float rand_float( void ) { return (float)r / ( (float)RAND_MAX + 1.0f ); } +/** +* Computes the squared absolute value of a complex number. +* +* @param z input value +* @return squared absolute value +*/ +float cabs2f( float complex z ) { + return ( crealf(z)*crealf(z) ) + ( cimagf(z)*cimagf(z) ); +} + /** * Runs a benchmark. * * @return elapsed time in seconds */ static double benchmark( void ) { + float complex z; double elapsed; double t; float re; @@ -98,17 +107,12 @@ static double benchmark( void ) { float y; int i; - stdlib_complex64_t z[ 100 ]; - - for ( i = 0; i < 100; i++ ) { - re = ( 1000.0f * rand_float() ) - 500.0f; - im = ( 1000.0f * rand_float() ) - 500.0f; - z[ i ] = stdlib_complex64( re, im ); - } - t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_cabs2f( z[ i % 100 ] ); + re = ( 1000.0f*rand_float() ) - 500.0f; + im = ( 1000.0f*rand_float() ) - 500.0f; + z = re + im*I; + y = cabs2f( z ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c index 6a9e4a273010..44e5c126c40d 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c @@ -17,7 +17,8 @@ */ #include "stdlib/math/base/special/cabs2f.h" -#include +#include "stdlib/complex/float32/ctor.h" +#include "stdlib/complex/float32/reim.h" #include #include #include @@ -91,7 +92,6 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { - float complex z; double elapsed; double t; float re; @@ -99,12 +99,17 @@ static double benchmark( void ) { float y; int i; + stdlib_complex64_t z[ 100 ]; + + for ( i = 0; i < 100; i++ ) { + re = ( 1000.0f * rand_float() ) - 500.0f; + im = ( 1000.0f * rand_float() ) - 500.0f; + z[ i ] = stdlib_complex64( re, im ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - re = ( 1000.0f*rand_float() ) - 500.0f; - im = ( 1000.0f*rand_float() ) - 500.0f; - z = re + im*I; - y = stdlib_base_cabs2f( z ); + y = stdlib_base_cabs2f( z[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; From b8487ca3c49b8d08ec2e44d0fc50d7dcce9b8174 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 15 Jan 2025 17:17:28 +0000 Subject: [PATCH 04/10] chore: update copyright years --- .../math/base/special/cabs2f/benchmark/benchmark.native.js | 2 +- lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp | 2 +- lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi | 2 +- lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js | 2 +- lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile | 2 +- lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c | 2 +- .../@stdlib/math/base/special/cabs2f/test/test.native.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js index 556202f880dc..dd28316c66f5 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp b/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp index f2b466aef5c4..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2023 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi b/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi index 78db9faf8c74..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2023 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js index 6c14410d1c57..d2f37f07907a 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile index 904c7dc4bd7a..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2023 The Stdlib Authors. +# 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. diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c index ee70bcb84d33..20fcab264e33 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js index 3b8847f9a78b..4d5990cf523b 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* 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. From 9a401b10eab15f77dd9fb484a8bbb9278eca68e8 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 14 Apr 2025 23:41:10 -0700 Subject: [PATCH 05/10] chore: fix use of negative spaces --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/cabs2f/src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c index 602da67da23d..f6bf2e78cf41 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/main.c @@ -31,12 +31,12 @@ * * stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f ); * -* float out = stdlib_base_cabs2f( z ); +* float y = stdlib_base_cabs2f( z ); * // returns 34.0f */ float stdlib_base_cabs2f( const stdlib_complex64_t z ) { - float re ; - float im ; + float re; + float im; stdlib_complex64_reim( z, &re, &im ); - return ( re * re ) + ( im * im ); + return ( re*re ) + ( im*im ); } From d474e2b5dade040e21f5f37311731991abaecc42 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 14 Apr 2025 23:41:45 -0700 Subject: [PATCH 06/10] docs: re-enable lint rule --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c index 20fcab264e33..a59c74d2f126 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/src/addon.c @@ -19,5 +19,4 @@ #include "stdlib/math/base/special/cabs2f.h" #include "stdlib/math/base/napi/unary.h" -// cppcheck-suppress shadowFunction STDLIB_MATH_BASE_NAPI_MODULE_C_F( stdlib_base_cabs2f ) From 508c857177e94cb8cc8129168861d969a98a3dfa Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 14 Apr 2025 23:42:29 -0700 Subject: [PATCH 07/10] docs: fix example inputs --- 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: passed - 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 --- --- lib/node_modules/@stdlib/math/base/special/cabs2f/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md index 098902b01c43..0d2378e7a198 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md @@ -141,7 +141,7 @@ Computes the squared [absolute value][absolute-value] of a single-precision comp ```c #include "stdlib/complex/float32/ctor.h" -stdlib_complex64_t z = stdlib_complex64( 5.0, 3.0 ); +stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f ); float y = stdlib_base_cabs2f( z ); // returns 34.0f From 59506ace7df0361a7d138a812d2dddb688aa8ed5 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 14 Apr 2025 23:42:53 -0700 Subject: [PATCH 08/10] bench: fix use of negative spaces --- 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: passed - 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/cabs2f/benchmark/c/native/benchmark.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c index 44e5c126c40d..ad9152827ae8 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/benchmark/c/native/benchmark.c @@ -102,14 +102,14 @@ static double benchmark( void ) { stdlib_complex64_t z[ 100 ]; for ( i = 0; i < 100; i++ ) { - re = ( 1000.0f * rand_float() ) - 500.0f; - im = ( 1000.0f * rand_float() ) - 500.0f; + re = ( 1000.0f*rand_float() ) - 500.0f; + im = ( 1000.0f*rand_float() ) - 500.0f; z[ i ] = stdlib_complex64( re, im ); } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_cabs2f( z[ i % 100 ] ); + y = stdlib_base_cabs2f( z[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; From 1c2dfe474ec51b5ee01415b0e35b651d899f9d12 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Tue, 15 Apr 2025 00:31:23 -0700 Subject: [PATCH 09/10] Update lib/node_modules/@stdlib/math/base/special/cabs2f/README.md Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/cabs2f/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md index 0d2378e7a198..791ff508ad3b 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/README.md @@ -196,7 +196,7 @@ int main( void ) { v = x[ i ]; y = stdlib_base_cabs2f( v ); stdlib_complex64_reim( v, &re, &im ); - printf( "f(%f + %f) = %f\n", re, im, y ); + printf( "f(%f + %fi) = %f\n", re, im, y ); } } ``` From ecf089f70c58c1cf16b7e212a311938855e417dc Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Tue, 15 Apr 2025 00:31:36 -0700 Subject: [PATCH 10/10] Update lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- .../@stdlib/math/base/special/cabs2f/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c index 63d1f720b42f..5f7b260079bf 100644 --- a/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/cabs2f/examples/c/example.c @@ -38,6 +38,6 @@ int main( void ) { v = x[ i ]; y = stdlib_base_cabs2f( v ); stdlib_complex64_reim( v, &re, &im ); - printf( "f(%f + %f) = %f\n", re, im, y ); + printf( "f(%f + %fi) = %f\n", re, im, y ); } }