From 7d853defe0c466da8829c08ab128f06aec7bf8e5 Mon Sep 17 00:00:00 2001 From: Harsh Mathur Date: Mon, 11 Nov 2024 16:49:08 +0530 Subject: [PATCH 01/70] feat: add math/base/special/lcmf --- .../@stdlib/math/base/special/lcmf/README.md | 227 ++++++++++++++++++ .../base/special/lcmf/benchmark/benchmark.js | 53 ++++ .../lcmf/benchmark/benchmark.native.js | 60 +++++ .../base/special/lcmf/benchmark/c/Makefile | 146 +++++++++++ .../base/special/lcmf/benchmark/c/benchmark.c | 129 ++++++++++ .../math/base/special/lcmf/binding.gyp | 170 +++++++++++++ .../math/base/special/lcmf/docs/repl.txt | 25 ++ .../base/special/lcmf/docs/types/index.d.ts | 53 ++++ .../math/base/special/lcmf/docs/types/test.ts | 52 ++++ .../base/special/lcmf/examples/c/Makefile | 146 +++++++++++ .../base/special/lcmf/examples/c/example.c | 32 +++ .../math/base/special/lcmf/examples/index.js | 29 +++ .../math/base/special/lcmf/include.gypi | 53 ++++ .../include/stdlib/math/base/special/lcmf.h | 40 +++ .../math/base/special/lcmf/lib/index.js | 49 ++++ .../math/base/special/lcmf/lib/main.js | 68 ++++++ .../math/base/special/lcmf/lib/native.js | 54 +++++ .../math/base/special/lcmf/manifest.json | 76 ++++++ .../math/base/special/lcmf/package.json | 72 ++++++ .../math/base/special/lcmf/src/Makefile | 70 ++++++ .../math/base/special/lcmf/src/addon.c | 22 ++ .../@stdlib/math/base/special/lcmf/src/main.c | 57 +++++ .../math/base/special/lcmf/test/test.js | 211 ++++++++++++++++ .../base/special/lcmf/test/test.native.js | 118 +++++++++ 24 files changed, 2012 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/include/stdlib/math/base/special/lcmf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md new file mode 100644 index 000000000000..0dabd06fdf0b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -0,0 +1,227 @@ + + +# lcmf + +> Compute the [least common multiple][lcm] of all integers from 1 up to a specified integer \( n \). + + + +
+ +The [least common multiple][lcm] of a set of integers is the smallest positive integer that is divisible by each number in the set. This function computes the LCM[lcm] for all integers from 1 up to a given integer \( n \), which is especially useful in various mathematical and computational applications. + +
+ + + + + +
+ +## Usage + +```javascript +var lcmf = require( '@stdlib/math/base/special/lcmf' ); +``` + +### lcmf(n) +Computes the [least common multiple][lcm] for all integers from 1 up to n. + +```javascript +var v = lcmf( 10 ); +// returns 2520 +``` + +If n is less than 1, the function returns 0. + +```javascript +var v = lcmf( 0 ); +// returns 0 + +v = lcmf( -5 ); +// returns 0 +``` + +The input n must be an integer; otherwise, the function returns NaN. + +```javascript +var v = lcmf( 3.14 ); +// returns NaN + +v = lcmf( NaN ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var lcmf = require( '@stdlib/math/base/special/lcmf' ); + +var v; +var i; + +for ( i = 1; i <= 10; i++ ) { + v = lcmf( i ); + console.log( 'lcm(1 to %d) = %d', i, v ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/lcmf.h" +``` + +### stdlib_base_lcmf( n ) + +Computes the [least common multiple][lcm] for all integers from 1 up to n. + +```c +double v = stdlib_base_lcmf( 10 ); +// returns 2520.0 +``` + +The function accepts the following argument: + +- **n**: `[in] double` input value. + +```c +double stdlib_base_lcmf( const double n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/lcmf.h" +#include + +int main( void ) { + double v; + int i; + for ( i = 1; i <= 10; i++ ) { + v = stdlib_base_lcmf( i ); + printf( "lcm(1 to %d) = %lf\n", i, v ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js new file mode 100644 index 000000000000..ad0cb2351aac --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var lcmf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = round( randu() * 50.0 ); + z = lcmf( x ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..f7b659a499e1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var lcmf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( lcmf instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts,function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for( i = 0;i < b.iterations; i++ ) { + x = ( randu() * 100.0 ) + 1.0; + y = lcmf( x ); + if( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/Makefile new file mode 100644 index 000000000000..3f41176faf73 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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 + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries: +LIBRARIES ?= + +# List of library paths: +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag for position independent code +# @param {string} [INCLUDE] - list of includes +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths +# @param {string} [LIBRARIES] - list of libraries +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..8d83b06e52b8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/lcmf.h" +#include +#include +#include +#include +#include + +#define NAME "lcmf" +#define ITERATIONS 10000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; +} + +/** +* Generates a random integer in the interval [1, 20]. +* +* @return random integer +*/ +static int rand_int( void ) { + return (rand() % 20) + 1; // Random value between 1 and 20 for small lcmf tests +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + unsigned long result; + double t; + int n; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + n = rand_int(); + result = stdlib_base_lcmf( n ); // Call to lcmf function + if ( result == 0 ) { + printf( "should not return 0 for n > 0\n" ); + break; + } + } + elapsed = tic() - t; + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Seed the random number generator with the current time + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/lcmf/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/lcmf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt new file mode 100644 index 000000000000..c157ba251a7c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt @@ -0,0 +1,25 @@ +{{alias}}( n ) + Computes the least common multiple (LCM) of all integers from 1 up to `n`. + + If `n` is less than or equal to 0, the function returns `0`. + + The input `n` must be an integer; otherwise, the function returns `NaN`. + + Parameters + ---------- + n: integer + Upper bound integer for the range (1 to `n`). + + Returns + ------- + out: integer + Least common multiple of all integers from 1 to `n`. + + Examples + -------- + > var v = {{alias}}( 10 ) + 2520 + + See Also + -------- + - `@stdlib/math/base/special/gcd`: compute the greatest common divisor (gcd). diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts new file mode 100644 index 000000000000..316b7b3e889f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts @@ -0,0 +1,53 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Computes the least common multiple (LCM) of all integers from 1 up to `n`. +* +* ## Notes +* +* - If `n` is less than or equal to `0`, the function returns `0`. +* - The input `n` must be an integer; otherwise, the function returns `NaN`. +* +* @param n - upper bound integer for the range (1 to `n`) +* @returns least common multiple of all integers from 1 up to `n` +* +* @example +* var v = lcmf( 10 ); +* // returns 2520 +* +* @example +* var v = lcmf( 0 ); +* // returns 0 +* +* @example +* var v = lcmf( 3.14 ); +* // returns NaN +* +* @example +* var v = lcmf( NaN ); +* // returns NaN +*/ +declare function lcmf( n: number ): number; + + +// EXPORTS // + +export = lcmf; diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts new file mode 100644 index 000000000000..bff3191a129d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts @@ -0,0 +1,52 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +import lcmf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + lcmf( 10 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a single number... +{ + lcmf( true ); // $ExpectError + lcmf( false ); // $ExpectError + lcmf( '5' ); // $ExpectError + lcmf( [] ); // $ExpectError + lcmf( {} ); // $ExpectError + lcmf( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided multiple arguments... +{ + lcmf( 10, 5 ); // $ExpectError + lcmf( 10, true ); // $ExpectError + lcmf( 10, '5' ); // $ExpectError + lcmf( 10, [] ); // $ExpectError + lcmf( 10, {} ); // $ExpectError + lcmf( 10, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + lcmf(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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 + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c new file mode 100644 index 000000000000..63683802c3f0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c @@ -0,0 +1,32 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/lcmf.h" +#include + +int main( void ) { + const unsigned long nums[] = { 1, 2, 3, 4, 5, 6, 10, 15, 20 }; + unsigned long result; + int i; + + for ( i = 0; i < 9; i++ ) { + result = stdlib_base_lcmf( nums[i] ); + printf( "LCM(1 to %lu) = %lu\n", nums[i], result ); + } + return 0; +} diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js new file mode 100644 index 000000000000..1d2e1bbaf5c9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +var linspace = require( '@stdlib/array/base/linspace' ); +var lcmf = require( './../lib' ); + +var nValues = linspace( 1, 20, 20 ); + +var i; +for ( i = 0; i < nValues.length; i++ ) { + console.log( 'LCM of numbers from 1 to %d = %d', nValues[ i ], lcmf( nValues[ i ] ) ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/include.gypi b/lib/node_modules/@stdlib/math/base/special/lcmf/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 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': [ + ' + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Computes the least common multiple of all numbers from 1 to n. +*/ +unsigned long stdlib_base_lcmf( unsigned long n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_LCMF_H diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js new file mode 100644 index 000000000000..b10f43f7beb2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* Compute the least common multiple of all numbers from 1 to `n`. +* +* @module @stdlib/math/base/special/lcmf +* +* @example +* var lcmf = require( '@stdlib/math/base/special/lcmf' ); +* +* var v = lcmf( 10 ); +* // returns 2520 +* +* v = lcmf( 15 ); +* // returns 360360 +* +* v = lcmf( 0 ); +* // returns 0 +* +* v = lcmf( NaN ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js new file mode 100644 index 000000000000..af67f409bccc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var gcd = require( '@stdlib/math/base/special/gcd' ); + + +// MAIN // + +/** +* Computes the least common multiple of all integers from 1 to `n` (Least Common Multiple Function, LCMF). +* +* @param {integer} n - integer +* @returns {integer} least common multiple of all integers from 1 to `n` +* +* @example +* var v = lcmf( 5 ); +* // returns 60 +* +* @example +* var v = lcmf( 10 ); +* // returns 2520 +* +* @example +* var v = lcmf( NaN ); +* // returns NaN +*/ +function lcmf( n ) { + var result; + var i; + + if ( isnan( n ) || n < 1 ) { + return NaN; + } + if ( n === 1 ) { + return 1; + } + result = 1; + // Note: we rely on `gcd` to perform further argument validation... + for ( i = 2; i <= n; i++ ) { + result = (result / gcd( result, i )) * i; + } + return result; +} + + +// EXPORTS // + +module.exports = lcmf; diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js new file mode 100644 index 000000000000..a3dc47f0cdf8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 least common multiple of all integers from 1 to `n` (Least Common Multiple Function, LCMF). +* +* @private +* @param {integer} n - integer +* @returns {number} least common multiple of all integers from 1 to `n` +* +* @example +* var v = lcmf( 5 ); +* // returns 60 +* +* @example +* var v = lcmf( 10 ); +* // returns 2520 +* +* @example +* var v = lcmf( NaN ); +* // returns NaN +*/ +function lcmf( n ) { + return addon( n ); +} + + +// EXPORTS // + +module.exports = lcmf; diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json b/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json new file mode 100644 index 000000000000..1dc7d0d9456d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json @@ -0,0 +1,76 @@ +{ + "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/binary", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/gcd" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/gcd" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/gcd" + ] + } + ] + } + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json new file mode 100644 index 000000000000..7c24246de9e7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/math/base/special/lcmf", + "version": "0.0.0", + "description": "Compute the least common multiple (LCM) of all integers from 1 up to a given integer n.", + "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", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "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", + "math", + "mathematics", + "euclid", + "euclidean", + "least common multiple", + "lcm", + "lcmf", + "arithmetic", + "discrete", + "gcd", + "integer", + "range LCM", + "from 1 to n" + ] + } + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/lcmf/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/lcmf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c new file mode 100644 index 000000000000..a089f631a51b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c @@ -0,0 +1,22 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/lcmf.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_lcmf ) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c new file mode 100644 index 000000000000..1b06b5cef65c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/lcmf.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/special/gcd.h" + +/** +* Computes the least common multiple (lcm) for a single number and a constant. +* +* @param a integer +* @return least common multiple (NaN if input is invalid) +* +* @example +* double out = stdlib_base_lcmf( 21.0 ); +* // returns 21.0 +*/ +double stdlib_base_lcmf( const double a ) { + double abs_a; + double gcd_value; + const double b = 1.0; + + if ( a != a ) { + return a; + } + + if ( a == 0.0 ) { + return 0.0; + } + + abs_a = ( a < 0.0 ) ? -a : a; + + // Note: we rely on `gcd` to perform further argument validation... + + gcd_value = stdlib_base_gcd( abs_a, b ); + + if ( stdlib_base_is_nan( gcd_value ) ) { + return gcd_value; + } + + return ( abs_a / gcd_value ) * b; +} diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js new file mode 100644 index 000000000000..c3b4ddf036c4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js @@ -0,0 +1,211 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var lcmf = require( './../lib' ); + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof lcmf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if input is `NaN`', function test( t ) { + var v; + + v = lcmf( NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if input is `+infinity`', function test( t ) { + var v; + + v = lcmf( PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if input is `-infinity`', function test( t ) { + var v; + + v = lcmf( NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if input is not an integer value', function test( t ) { + var v; + + v = lcmf( 3.14 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = lcmf( 6.18 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `0` if input is `0`', function test( t ) { + var v; + + v = lcmf( 0 ); + t.strictEqual( v, 0, 'returns 0' ); + + t.end(); +}); + +tape( 'the function computes the least common multiple of a number with 1 (LCM(a, 1) = a)', function test( t ) { + var v; + + v = lcmf( 6 ); + t.strictEqual( v, 6, 'returns 6' ); + + v = lcmf( 10 ); + t.strictEqual( v, 10, 'returns 10' ); + + v = lcmf( -7 ); + t.strictEqual( v, 7, 'returns 7' ); + + v = lcmf( 21 ); + t.strictEqual( v, 21, 'returns 21' ); + + v = lcmf( 0 ); + t.strictEqual( v, 0, 'returns 0' ); + + v = lcmf( 1 ); + t.strictEqual( v, 1, 'returns 1' ); + + t.end(); +}); + + +tape( 'the function returns `NaN` if input is a non-integer floating point number', function test( t ) { + var v; + + v = lcmf( 3.14159 ); + t.strictEqual( isnan( v ), true, 'returns NaN for float' ); + + v = lcmf( 6.28 ); + t.strictEqual( isnan( v ), true, 'returns NaN for float' ); + + v = lcmf( -1.1 ); + t.strictEqual( isnan( v ), true, 'returns NaN for negative float' ); + + t.end(); +}); + +tape( 'the function handles negative numbers correctly (LCM of negative numbers)', function test( t ) { + var v; + + v = lcmf( -6 ); + t.strictEqual( v, 6, 'returns 6 for negative input' ); + + v = lcmf( -10 ); + t.strictEqual( v, 10, 'returns 10 for negative input' ); + + v = lcmf( -25 ); + t.strictEqual( v, 25, 'returns 25 for negative input' ); + + v = lcmf( -21 ); + t.strictEqual( v, 21, 'returns 21 for negative input' ); + + v = lcmf( -100 ); + t.strictEqual( v, 100, 'returns 100 for negative input' ); + + t.end(); +}); + +tape( 'the function computes the least common multiple of two integers', function test( t ) { + var v; + + v = lcmf( 12 ); // LCM(12, 1) + t.strictEqual( v, 12, 'returns 12' ); + + v = lcmf( 15 ); // LCM(15, 1) + t.strictEqual( v, 15, 'returns 15' ); + + v = lcmf( 24 ); // LCM(24, 1) + t.strictEqual( v, 24, 'returns 24' ); + + v = lcmf( 35 ); // LCM(35, 1) + t.strictEqual( v, 35, 'returns 35' ); + + v = lcmf( 45 ); // LCM(45, 1) + t.strictEqual( v, 45, 'returns 45' ); + + t.end(); +}); + +tape( 'the function computes LCM for large inputs', function test( t ) { + var v; + + v = lcmf( 1000 ); + t.strictEqual( v, 1000, 'returns 1000 for large number' ); + + v = lcmf( 10000 ); + t.strictEqual( v, 10000, 'returns 10000 for large number' ); + + v = lcmf( 50000 ); + t.strictEqual( v, 50000, 'returns 50000 for large number' ); + + v = lcmf( 100000 ); + t.strictEqual( v, 100000, 'returns 100000 for large number' ); + + t.end(); +}); + +tape( 'the function handles the special case of LCM with zero (LCM(0, a) = 0)', function test( t ) { + var v; + + v = lcmf( 0 ); + t.strictEqual( v, 0, 'returns 0 when input is 0' ); + + t.end(); +}); + +tape( 'the function computes LCM for numbers with common factors', function test( t ) { + var v; + + v = lcmf( 18 ); // LCM(18, 1) + t.strictEqual( v, 18, 'returns 18' ); + + v = lcmf( 28 ); // LCM(28, 1) + t.strictEqual( v, 28, 'returns 28' ); + + v = lcmf( 36 ); // LCM(36, 1) + t.strictEqual( v, 36, 'returns 36' ); + + v = lcmf( 48 ); // LCM(48, 1) + t.strictEqual( v, 48, 'returns 48' ); + + t.end(); +}); + diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js new file mode 100644 index 000000000000..7bab6023163c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js @@ -0,0 +1,118 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + +// VARIABLES // + +var lcmf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( lcmf instanceof Error ) +}; + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof lcmf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if the argument is `NaN`', opts, function test( t ) { + var v; + + v = lcmf( NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if the argument is `+infinity`', opts, function test( t ) { + var v; + + v = lcmf( PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if the argument is `-infinity`', opts, function test( t ) { + var v; + + v = lcmf( NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if the argument is not an integer', opts, function test( t ) { + var v; + + v = lcmf( 3.14 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = lcmf( 6.18 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `0` if the argument is `0`', opts, function test( t ) { + var v = lcmf( 0 ); + t.strictEqual( v, 0, 'returns 0' ); + + t.end(); +}); + +tape( 'the function computes the least common multiple of a number and a predefined value', opts, function test( t ) { + var v; + + var predefinedValue = 12; + + v = lcmf( 0 ); + t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + + v = lcmf( 6 ); + t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + + v = lcmf( 4 ); + t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + + v = lcmf( -4 ); + t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + + v = lcmf( 15 ); + t.strictEqual( v, 60, 'returns 60' ); // LCM(15, 12) = 60 + + v = lcmf( 5 ); + t.strictEqual( v, 60, 'returns 60' ); // LCM(5, 12) = 60 + + v = lcmf( 7 ); + t.strictEqual( v, 84, 'returns 84' ); // LCM(7, 12) = 84 + + t.end(); +}); From 09d7f6ce94913686293c6714a225c79420e6c8cb Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:38:34 +0530 Subject: [PATCH 02/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 0dabd06fdf0b..bf081ac36f26 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -2,6 +2,8 @@ @license Apache-2.0 +Copyright (c) 2024 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 From dff1b9c6e6923c448b34d754f4a712ac4878837d Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:38:50 +0530 Subject: [PATCH 03/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index bf081ac36f26..d3318b2dadab 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -20,7 +20,7 @@ limitations under the License. # lcmf -> Compute the [least common multiple][lcm] of all integers from 1 up to a specified integer \( n \). +> Compute the [least common multiple][lcm] of two single-precision floating-point numbers. From 213016007d970e0c6a3ae2dbc36d626d07b0b952 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:39:18 +0530 Subject: [PATCH 04/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index d3318b2dadab..6a401d717a69 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -26,7 +26,7 @@ limitations under the License.
-The [least common multiple][lcm] of a set of integers is the smallest positive integer that is divisible by each number in the set. This function computes the LCM[lcm] for all integers from 1 up to a given integer \( n \), which is especially useful in various mathematical and computational applications. +The [least common multiple][lcm] (lcm) of two non-zero integers `a` and `b` is the smallest positive integer that is divisible by both `a` and `b`. The lcm is also known as the **lowest common multiple** or **smallest common multiple** and finds common use in calculating the **lowest common denominator** (lcd).
From 814abeceb34d62f985d7d1019edd6c8e355fa8a0 Mon Sep 17 00:00:00 2001 From: Harsh Mathur Date: Tue, 12 Nov 2024 10:46:42 +0530 Subject: [PATCH 05/70] resolved the changes as requested --- .../@stdlib/math/base/special/lcmf/README.md | 50 +++-- .../base/special/lcmf/benchmark/benchmark.js | 39 ++-- .../lcmf/benchmark/benchmark.native.js | 14 +- .../math/base/special/lcmf/docs/repl.txt | 23 ++- .../base/special/lcmf/docs/types/index.d.ts | 26 ++- .../math/base/special/lcmf/docs/types/test.ts | 35 ++-- .../base/special/lcmf/examples/c/example.c | 17 +- .../math/base/special/lcmf/examples/index.js | 17 +- .../include/stdlib/math/base/special/lcmf.h | 4 +- .../math/base/special/lcmf/lib/index.js | 16 +- .../math/base/special/lcmf/lib/main.js | 41 ++-- .../math/base/special/lcmf/lib/native.js | 23 +-- .../math/base/special/lcmf/package.json | 2 +- .../@stdlib/math/base/special/lcmf/src/main.c | 43 ++-- .../math/base/special/lcmf/test/test.js | 184 ++++++------------ .../base/special/lcmf/test/test.native.js | 139 ++++++++----- 16 files changed, 343 insertions(+), 330 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 0dabd06fdf0b..f619fe6ef705 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Licensed under the Apache License, Version 2.0 (the "License"); +Copyright (c) 2024 The Stdlib Authors. you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -18,13 +18,13 @@ limitations under the License. # lcmf -> Compute the [least common multiple][lcm] of all integers from 1 up to a specified integer \( n \). +> Compute the [least common multiple][lcm] of two single-precision floating-point numbers.
-The [least common multiple][lcm] of a set of integers is the smallest positive integer that is divisible by each number in the set. This function computes the LCM[lcm] for all integers from 1 up to a given integer \( n \), which is especially useful in various mathematical and computational applications. +The [least common multiple][lcm] (lcm) of two non-zero integers `a` and `b` is the smallest positive integer that is divisible by both `a` and `b`. The lcm is also known as the **lowest common multiple** or **smallest common multiple** and finds common use in calculating the **lowest common denominator** (lcd).
@@ -40,31 +40,31 @@ The [least common multiple][lcm] of a set of integers is the smallest positive i var lcmf = require( '@stdlib/math/base/special/lcmf' ); ``` -### lcmf(n) -Computes the [least common multiple][lcm] for all integers from 1 up to n. +### lcmf(a,b) +Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```javascript -var v = lcmf( 10 ); -// returns 2520 +var v = lcmf( 10.0,12.0 ); +// returns 60 ``` -If n is less than 1, the function returns 0. +If either number is less than 1, the function returns `0`. ```javascript -var v = lcmf( 0 ); +var v = lcmf( 0.0, 12.0 ); // returns 0 -v = lcmf( -5 ); +v = lcmf( -5.0, 12.0 ); // returns 0 ``` -The input n must be an integer; otherwise, the function returns NaN. +The inputs must be valid floating-point numbers; otherwise, the function returns `NaN`. ```javascript -var v = lcmf( 3.14 ); +var v = lcmf( 3.14, 12.0 ); // returns NaN -v = lcmf( NaN ); +v = lcmf( NaN, 12.0 ); // returns NaN ``` @@ -95,8 +95,8 @@ var v; var i; for ( i = 1; i <= 10; i++ ) { - v = lcmf( i ); - console.log( 'lcm(1 to %d) = %d', i, v ); + v = lcmf( i, 12 ); + console.log( 'lcm(%d, 12) = %d', i, v ); } ``` @@ -130,21 +130,22 @@ for ( i = 1; i <= 10; i++ ) { #include "stdlib/math/base/special/lcmf.h" ``` -### stdlib_base_lcmf( n ) +### stdlib_base_lcmf( a,b ) -Computes the [least common multiple][lcm] for all integers from 1 up to n. +Computes the [least common multiple][lcm] for two floating-point numbers `a` and `b`. ```c -double v = stdlib_base_lcmf( 10 ); -// returns 2520.0 +float v = stdlib_base_lcmf( 10.0, 12.0 ); +// returns 60.0 ``` The function accepts the following argument: -- **n**: `[in] double` input value. +- **a**: `[in] float` input value. +- **b**: `[in] float` input value. ```c -double stdlib_base_lcmf( const double n ); +double stdlib_base_lcmf( const float a, const float b ); ``` @@ -171,11 +172,8 @@ double stdlib_base_lcmf( const double n ); int main( void ) { double v; - int i; - for ( i = 1; i <= 10; i++ ) { - v = stdlib_base_lcmf( i ); - printf( "lcm(1 to %d) = %lf\n", i, v ); - } + v = stdlib_base_lcmf( 10.0, 12.0 ); + printf( "lcm(10.0, 12.0) = %lf\n", v ); } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js index ad0cb2351aac..7cb902bb71e6 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var roundf = require( '@stdlib/math/base/special/roundf' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var lcmf = require( './../lib' ); @@ -31,23 +31,24 @@ var lcmf = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var x; - var y; - var z; - var i; + var x; + var y; + var z; + var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = round( randu() * 50.0 ); - z = lcmf( x ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = roundf( randu() * 50.0 ); + y = roundf( randu() * 50.0 ); + z = lcmf( x, y ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js index f7b659a499e1..048732a0624d 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js @@ -38,23 +38,25 @@ var opts = { // MAIN // -bench( pkg+'::native', opts,function benchmark( b ) { +bench( pkg+'::native', opts, function benchmark( b ) { var x; var y; + var z; var i; b.tic(); - for( i = 0;i < b.iterations; i++ ) { + for ( i = 0; i < b.iterations; i++ ) { x = ( randu() * 100.0 ) + 1.0; - y = lcmf( x ); - if( isnan( y ) ) { + y = ( randu() * 100.0 ) + 1.0; + z = lcmf( x, y ); + if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if( isnan( y ) ) { + if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); b.end(); -}); \ No newline at end of file +}); diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt index c157ba251a7c..1a818c2b34e5 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt @@ -1,24 +1,27 @@ -{{alias}}( n ) - Computes the least common multiple (LCM) of all integers from 1 up to `n`. +{{alias}}( a, b ) + Computes the least common multiple (LCM) of two single-precision floating-point numbers. - If `n` is less than or equal to 0, the function returns `0`. + If either `a` or `b` is `0`, the function returns `0`. - The input `n` must be an integer; otherwise, the function returns `NaN`. + Both `a` and `b` must have integer values in single-precision floating-point format; otherwise, the function returns `NaN`. Parameters ---------- - n: integer - Upper bound integer for the range (1 to `n`). + a: float32 + First single-precision floating-point number. + + b: float32 + Second single-precision floating-point number. Returns ------- - out: integer - Least common multiple of all integers from 1 to `n`. + out: float32 + Least common multiple in single-precision floating-point format. Examples -------- - > var v = {{alias}}( 10 ) - 2520 + > var v = {{alias}}( 21.0, 6.0 ) + 42.0 See Also -------- diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts index 316b7b3e889f..16187d93535a 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts @@ -19,33 +19,31 @@ // TypeScript Version: 4.1 /** -* Computes the least common multiple (LCM) of all integers from 1 up to `n`. +* Computes the least common multiple (LCM) of two single-precision floating-point numbers. * * ## Notes * -* - If `n` is less than or equal to `0`, the function returns `0`. -* - The input `n` must be an integer; otherwise, the function returns `NaN`. +* - If either `a` or `b` is `0`, the function returns `0`. +* - The inputs `a` and `b` are expected to be single-precision floating-point numbers. +* - If `a` or `b` are not whole numbers, the function returns `NaN`. * -* @param n - upper bound integer for the range (1 to `n`) -* @returns least common multiple of all integers from 1 up to `n` +* @param a - single-precision floating-point number +* @param b - single-precision floating-point number +* @returns least common multiple as a single-precision floating-point number * * @example -* var v = lcmf( 10 ); -* // returns 2520 +* var v = lcmf( 21.0, 6.0 ); +* // returns 42.0 * * @example -* var v = lcmf( 0 ); -* // returns 0 -* -* @example -* var v = lcmf( 3.14 ); +* var v = lcmf( 3.14, 6.0 ); * // returns NaN * * @example -* var v = lcmf( NaN ); +* var v = lcmf( NaN, 6.0 ); * // returns NaN */ -declare function lcmf( n: number ): number; +declare function lcmf( a: number, b: number ): number; // EXPORTS // diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts index bff3191a129d..3a91593c076b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts @@ -18,35 +18,30 @@ import lcmf = require( './index' ); - // TESTS // // The function returns a number... { - lcmf( 10 ); // $ExpectType number + lcmf( 10.0, 5.0 ); // $ExpectType number } -// The compiler throws an error if the function is provided a value other than a single number... +// The compiler throws an error if the function is provided a value other than single precision floating-point numbers... { - lcmf( true ); // $ExpectError - lcmf( false ); // $ExpectError - lcmf( '5' ); // $ExpectError - lcmf( [] ); // $ExpectError - lcmf( {} ); // $ExpectError - lcmf( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided multiple arguments... -{ - lcmf( 10, 5 ); // $ExpectError - lcmf( 10, true ); // $ExpectError - lcmf( 10, '5' ); // $ExpectError - lcmf( 10, [] ); // $ExpectError - lcmf( 10, {} ); // $ExpectError - lcmf( 10, ( x: number ): number => x ); // $ExpectError + lcmf( true, 5.0 ); // $ExpectError + lcmf( false, 5.0 ); // $ExpectError + lcmf( '5.0', 5.0 ); // $ExpectError + lcmf( [], 5.0 ); // $ExpectError + lcmf( {}, 5.0 ); // $ExpectError + lcmf( ( x: number ): number => x, 5.0 ); // $ExpectError + lcmf( 10.0, true ); // $ExpectError + lcmf( 10.0, false ); // $ExpectError + lcmf( 10.0, '5.0' ); // $ExpectError + lcmf( 10.0, [] ); // $ExpectError + lcmf( 10.0, {} ); // $ExpectError + lcmf( 10.0, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { lcmf(); // $ExpectError -} +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c index 63683802c3f0..770ef3ee78eb 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c @@ -20,13 +20,22 @@ #include int main( void ) { - const unsigned long nums[] = { 1, 2, 3, 4, 5, 6, 10, 15, 20 }; - unsigned long result; + // Define two float arrays to work with floating-point numbers + const float nums_a[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 10.0f, 15.0f, 20.0f }; + const float nums_b[] = { 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 15.0f, 20.0f, 25.0f }; + + // Variable to store LCM result + float result; int i; + // Loop over the arrays and compute LCM of pairs for ( i = 0; i < 9; i++ ) { - result = stdlib_base_lcmf( nums[i] ); - printf( "LCM(1 to %lu) = %lu\n", nums[i], result ); + // Compute the LCM of two floating-point numbers + result = stdlib_base_lcmf( nums_a[i], nums_b[i] ); + + // Print the result + printf( "LCM( %.2f, %.2f ) = %.2f\n", nums_a[i], nums_b[i], result ); } + return 0; } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js index 1d2e1bbaf5c9..6b9783a2c87e 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js @@ -1,4 +1,4 @@ -/** +/* * @license Apache-2.0 * * Copyright (c) 2024 The Stdlib Authors. @@ -21,9 +21,18 @@ var linspace = require( '@stdlib/array/base/linspace' ); var lcmf = require( './../lib' ); -var nValues = linspace( 1, 20, 20 ); +var nValues = linspace( 1.0, 20.0, 20 ); +// Iterate through the values and compute the LCM of two numbers var i; -for ( i = 0; i < nValues.length; i++ ) { - console.log( 'LCM of numbers from 1 to %d = %d', nValues[ i ], lcmf( nValues[ i ] ) ); +for ( i = 0; i < nValues.length - 1; i++ ) { + var a = nValues[i]; + var b = nValues[i + 1]; + + // Ensure a and b are single-precision floating-point numbers (float32) + if ( typeof a === 'number' && typeof b === 'number' ) { + console.log( 'LCM of %d and %d = %d', a, b, lcmf( a, b ) ); + } else { + console.log( 'Invalid input types. Both a and b should be single-precision floating-point numbers.' ); + } } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/include/stdlib/math/base/special/lcmf.h b/lib/node_modules/@stdlib/math/base/special/lcmf/include/stdlib/math/base/special/lcmf.h index 32f988be4592..fe3e7813a76f 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/include/stdlib/math/base/special/lcmf.h +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/include/stdlib/math/base/special/lcmf.h @@ -29,9 +29,9 @@ extern "C" { #endif /** -* Computes the least common multiple of all numbers from 1 to n. +* Computes the least common multiple (LCM) of two floating-point numbers. */ -unsigned long stdlib_base_lcmf( unsigned long n ); +float stdlib_base_lcmf( float a, float b ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js index b10f43f7beb2..6c37abbc9bba 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js @@ -19,23 +19,23 @@ 'use strict'; /** -* Compute the least common multiple of all numbers from 1 to `n`. +* Computes the least common multiple (LCM) of two floating-point numbers. * * @module @stdlib/math/base/special/lcmf * * @example * var lcmf = require( '@stdlib/math/base/special/lcmf' ); * -* var v = lcmf( 10 ); -* // returns 2520 +* var v = lcmf( 10.0 , 5.0 ); +* // returns 10.0 * -* v = lcmf( 15 ); -* // returns 360360 +* v = lcmf( 15.0 , 6.0 ); +* // returns 30.0 * -* v = lcmf( 0 ); -* // returns 0 +* v = lcmf( 0.0 , 6.0 ); +* // returns 0.0 * -* v = lcmf( NaN ); +* v = lcmf( 3.14 , 6.0 ); * // returns NaN */ diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index af67f409bccc..e9b65ea4eb41 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -27,38 +27,47 @@ var gcd = require( '@stdlib/math/base/special/gcd' ); // MAIN // /** -* Computes the least common multiple of all integers from 1 to `n` (Least Common Multiple Function, LCMF). +* Computes the least common multiple (LCM) of two floating-point numbers. * -* @param {integer} n - integer -* @returns {integer} least common multiple of all integers from 1 to `n` +* @param {number} a - first floating-point number +* @param {number} b - second floating-point number +* @returns {number} least common multiple of `a` and `b` * * @example -* var v = lcmf( 5 ); -* // returns 60 +* var v = lcmf( 21.0, 6.0 ); +* // returns 42.0 * * @example -* var v = lcmf( 10 ); -* // returns 2520 +* var v = lcmf( 3.0, 7.0 ); +* // returns 21.0 * * @example -* var v = lcmf( NaN ); +* var v = lcmf( 0.0, 5.0 ); +* // returns 0.0 +* +* @example +* var v = lcmf( NaN, 5.0 ); * // returns NaN */ -function lcmf( n ) { +function lcmf( a , b ) { var result; var i; - if ( isnan( n ) || n < 1 ) { - return NaN; - } - if ( n === 1 ) { - return 1; + if ( isnan( a ) || isnan( b ) || ( a == 0 ) || ( b == 0 ) ) { + return 0.0; } + result = 1; // Note: we rely on `gcd` to perform further argument validation... - for ( i = 2; i <= n; i++ ) { - result = (result / gcd( result, i )) * i; + + var g = gcd( a, b ); + + if ( g === 0 ) { + return NaN; } + + result = a * b / g; + return result; } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js index a3dc47f0cdf8..4c76d8811dd0 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js @@ -26,26 +26,27 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the least common multiple of all integers from 1 to `n` (Least Common Multiple Function, LCMF). +* Computes the least common multiple (LCM) of two floating-point numbers. * * @private -* @param {integer} n - integer -* @returns {number} least common multiple of all integers from 1 to `n` +* @param {number} a - first floating-point number +* @param {number} b - second floating-point number +* @returns {number} least common multiple of `a` and `b` * * @example -* var v = lcmf( 5 ); -* // returns 60 +* var v = lcmf( 21.0, 6.0 ); +* // returns 42.0 * * @example -* var v = lcmf( 10 ); -* // returns 2520 +* var v = lcmf( 3.0, 7.0 ); +* // returns 21.0 * * @example -* var v = lcmf( NaN ); +* var v = lcmf( NaN, 5.0 ); * // returns NaN -*/ -function lcmf( n ) { - return addon( n ); +*/ +function lcmf( a , b ) { + return addon( a , b ); } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json index 7c24246de9e7..23d15b06d25f 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/lcmf", "version": "0.0.0", - "description": "Compute the least common multiple (LCM) of all integers from 1 up to a given integer n.", + "description": "Compute the least common multiple (LCM) of two single-point floating-numbers", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 1b06b5cef65c..8d914636aff8 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -21,37 +21,46 @@ #include "stdlib/math/base/special/gcd.h" /** -* Computes the least common multiple (lcm) for a single number and a constant. +* Computes the least common multiple (LCM) of two single-precision floating-point numbers. * -* @param a integer +* @param a first floating-point number (single precision) +* @param b second floating-point number (single precision) * @return least common multiple (NaN if input is invalid) * * @example -* double out = stdlib_base_lcmf( 21.0 ); -* // returns 21.0 +* float out = stdlib_base_lcmf( 21.0f, 6.0f ); +* // returns 42.0f */ -double stdlib_base_lcmf( const double a ) { - double abs_a; - double gcd_value; +double stdlib_base_lcmf( const float a, const float b ) { + float abs_a; + float abs_b; + float gcd_value; const double b = 1.0; - if ( a != a ) { - return a; - } - - if ( a == 0.0 ) { - return 0.0; - } + if ( a == 0.0 || b == 0.0 ) { + return 0.0; + } + if ( a < 0.0 ) { + abs_a = -a; + } else { + abs_a = a; + } + if ( b < 0.0 ) { + abs_b = -b; + } else { + abs_b = b; + } - abs_a = ( a < 0.0 ) ? -a : a; + abs_a = ( a < 0.0f ) ? -a : a; + abs_b = ( b < 0.0f ) ? -b : b; // Note: we rely on `gcd` to perform further argument validation... - gcd_value = stdlib_base_gcd( abs_a, b ); + gcd_value = stdlib_base_gcd( abs_a, abs_b ); if ( stdlib_base_is_nan( gcd_value ) ) { return gcd_value; } - return ( abs_a / gcd_value ) * b; + return ( abs_a / gcd_value ) * abs_b; } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js index c3b4ddf036c4..161eada855da 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js @@ -37,175 +37,111 @@ tape( 'main export is a function', function test( t ) { tape( 'the function returns `NaN` if input is `NaN`', function test( t ) { var v; - v = lcmf( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + v = lcmf( NaN, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); -}); - -tape( 'the function returns `NaN` if input is `+infinity`', function test( t ) { - var v; - - v = lcmf( PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - t.end(); -}); - -tape( 'the function returns `NaN` if input is `-infinity`', function test( t ) { - var v; - - v = lcmf( NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - t.end(); -}); - -tape( 'the function returns `NaN` if input is not an integer value', function test( t ) { - var v; - - v = lcmf( 3.14 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - v = lcmf( 6.18 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - - t.end(); -}); - -tape( 'the function returns `0` if input is `0`', function test( t ) { - var v; + v = lcmf( 10.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( 0 ); - t.strictEqual( v, 0, 'returns 0' ); + v = lcmf( NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function computes the least common multiple of a number with 1 (LCM(a, 1) = a)', function test( t ) { +tape( 'the function returns `NaN` if input is `+infinity`', function test( t ) { var v; - v = lcmf( 6 ); - t.strictEqual( v, 6, 'returns 6' ); - - v = lcmf( 10 ); - t.strictEqual( v, 10, 'returns 10' ); - - v = lcmf( -7 ); - t.strictEqual( v, 7, 'returns 7' ); - - v = lcmf( 21 ); - t.strictEqual( v, 21, 'returns 21' ); + v = lcmf( PINF, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( 0 ); - t.strictEqual( v, 0, 'returns 0' ); + v = lcmf( 10.0, PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( 1 ); - t.strictEqual( v, 1, 'returns 1' ); + v = lcmf( PINF, PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); - -tape( 'the function returns `NaN` if input is a non-integer floating point number', function test( t ) { +tape( 'the function returns `NaN` if input is `-infinity`', function test( t ) { var v; - v = lcmf( 3.14159 ); - t.strictEqual( isnan( v ), true, 'returns NaN for float' ); + v = lcmf( NINF, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( 6.28 ); - t.strictEqual( isnan( v ), true, 'returns NaN for float' ); + v = lcmf( 10.0, NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( -1.1 ); - t.strictEqual( isnan( v ), true, 'returns NaN for negative float' ); + v = lcmf( NINF, NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function handles negative numbers correctly (LCM of negative numbers)', function test( t ) { +tape( 'the function returns `NaN` if input is not an floating point number', function test( t ) { var v; - v = lcmf( -6 ); - t.strictEqual( v, 6, 'returns 6 for negative input' ); - - v = lcmf( -10 ); - t.strictEqual( v, 10, 'returns 10 for negative input' ); + v = lcmf( 3.14, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( -25 ); - t.strictEqual( v, 25, 'returns 25 for negative input' ); + v = lcmf( 10.0, 3.14 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( -21 ); - t.strictEqual( v, 21, 'returns 21 for negative input' ); - - v = lcmf( -100 ); - t.strictEqual( v, 100, 'returns 100 for negative input' ); + v = lcmf( 3.14, 6.18 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function computes the least common multiple of two integers', function test( t ) { - var v; - - v = lcmf( 12 ); // LCM(12, 1) - t.strictEqual( v, 12, 'returns 12' ); - - v = lcmf( 15 ); // LCM(15, 1) - t.strictEqual( v, 15, 'returns 15' ); - - v = lcmf( 24 ); // LCM(24, 1) - t.strictEqual( v, 24, 'returns 24' ); +tape( 'the function returns `0` if input is `0`', function test( t ) { + var v = lcmf( 0.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - v = lcmf( 35 ); // LCM(35, 1) - t.strictEqual( v, 35, 'returns 35' ); + v = lcmf( 2.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - v = lcmf( 45 ); // LCM(45, 1) - t.strictEqual( v, 45, 'returns 45' ); + v = lcmf( 0.0, -3.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); t.end(); }); -tape( 'the function computes LCM for large inputs', function test( t ) { - var v; - - v = lcmf( 1000 ); - t.strictEqual( v, 1000, 'returns 1000 for large number' ); - - v = lcmf( 10000 ); - t.strictEqual( v, 10000, 'returns 10000 for large number' ); +tape( 'the function computes the least common multiple for two single precision floating-point numbers', function test( t ) { + var v; - v = lcmf( 50000 ); - t.strictEqual( v, 50000, 'returns 50000 for large number' ); + v = lcmf( 0.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - v = lcmf( 100000 ); - t.strictEqual( v, 100000, 'returns 100000 for large number' ); - - t.end(); -}); + v = lcmf( 1.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); -tape( 'the function handles the special case of LCM with zero (LCM(0, a) = 0)', function test( t ) { - var v; + v = lcmf( 0.0, 1.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - v = lcmf( 0 ); - t.strictEqual( v, 0, 'returns 0 when input is 0' ); + v = lcmf( 6.0, 4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - t.end(); -}); + v = lcmf( 6.0, -4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); -tape( 'the function computes LCM for numbers with common factors', function test( t ) { - var v; + v = lcmf( -6.0, -4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - v = lcmf( 18 ); // LCM(18, 1) - t.strictEqual( v, 18, 'returns 18' ); + v = lcmf( 2.0, 8.0 ); + t.strictEqual( v, 8.0, 'returns 8' ); - v = lcmf( 28 ); // LCM(28, 1) - t.strictEqual( v, 28, 'returns 28' ); + v = lcmf( 15.0, 20.0 ); + t.strictEqual( v, 60.0, 'returns 60' ); - v = lcmf( 36 ); // LCM(36, 1) - t.strictEqual( v, 36, 'returns 36' ); + v = lcmf( 20.0, 15.0 ); + t.strictEqual( v, 60.0, 'returns 60' ); - v = lcmf( 48 ); // LCM(48, 1) - t.strictEqual( v, 48, 'returns 48' ); + v = lcmf( 35.0, -21.0 ); + t.strictEqual( v, 105.0, 'returns 105' ); - t.end(); -}); + v = lcmf( 48.0, 18.0 ); + t.strictEqual( v, 144.0, 'returns 144' ); + t.end(); +}); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js index 7bab6023163c..3b22f8370156 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js @@ -31,88 +31,131 @@ var tryRequire = require( '@stdlib/utils/try-require' ); var lcmf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': ( lcmf instanceof Error ) + 'skip': ( lcmf instanceof Error ) }; // TESTS // tape( 'main export is a function', opts, function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof lcmf, 'function', 'main export is a function' ); - t.end(); + t.ok( true, __filename ); + t.strictEqual( typeof lcmf, 'function', 'main export is a function' ); + t.end(); }); -tape( 'the function returns `NaN` if the argument is `NaN`', opts, function test( t ) { - var v; +tape( 'the function returns `NaN` if either argument is `NaN`', opts, function test( t ) { + var v; - v = lcmf( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + v = lcmf( NaN, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); + v = lcmf( 10.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = lcmf( NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); }); -tape( 'the function returns `NaN` if the argument is `+infinity`', opts, function test( t ) { - var v; +tape( 'the function returns `NaN` if either argument is `+infinity`', opts, function test( t ) { + var v; + + v = lcmf( PINF, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = lcmf( 10.0, PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + v = lcmf( PINF, PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); + t.end(); }); -tape( 'the function returns `NaN` if the argument is `-infinity`', opts, function test( t ) { - var v; +tape( 'the function returns `NaN` if either argument is `-infinity`', opts, function test( t ) { + var v; - v = lcmf( NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + v = lcmf( NINF, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); + v = lcmf( 10.0, NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = lcmf( NINF, NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); }); -tape( 'the function returns `NaN` if the argument is not an integer', opts, function test( t ) { - var v; +tape( 'the function returns `NaN` if either argument is not a valid floating-point number', opts, function test( t ) { + var v; + + v = lcmf( 3.14, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( 3.14 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + v = lcmf( 10.0, 3.14 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = lcmf( 6.18 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + v = lcmf( 3.14, 6.18 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); + t.end(); }); -tape( 'the function returns `0` if the argument is `0`', opts, function test( t ) { - var v = lcmf( 0 ); - t.strictEqual( v, 0, 'returns 0' ); +tape( 'the function returns `0` if either argument is `0`', opts, function test( t ) { + var v = lcmf( 0.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - t.end(); + v = lcmf( 2.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); + + v = lcmf( 0.0, -3.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); + + t.end(); }); -tape( 'the function computes the least common multiple of a number and a predefined value', opts, function test( t ) { - var v; +tape( 'the function computes the least common multiple of two floating-point numbers', opts, function test( t ) { + var v; + + v = lcmf( 0.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); + + v = lcmf( 1.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); + + v = lcmf( 0.0, 1.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); + + v = lcmf( 6.0, 4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); + + v = lcmf( 6.0, -4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - var predefinedValue = 12; + v = lcmf( -6.0, -4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - v = lcmf( 0 ); - t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + v = lcmf( 2.0, 8.0 ); + t.strictEqual( v, 8.0, 'returns 8' ); - v = lcmf( 6 ); - t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + v = lcmf( 15.0, 20.0 ); + t.strictEqual( v, 60.0, 'returns 60' ); - v = lcmf( 4 ); - t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + v = lcmf( 20.0, 15.0 ); + t.strictEqual( v, 60.0, 'returns 60' ); - v = lcmf( -4 ); - t.strictEqual( v, predefinedValue, 'returns ' + predefinedValue ); + v = lcmf( 35.0, -21.0 ); + t.strictEqual( v, 105.0, 'returns 105' ); - v = lcmf( 15 ); - t.strictEqual( v, 60, 'returns 60' ); // LCM(15, 12) = 60 + v = lcmf( 48.0, 18.0 ); + t.strictEqual( v, 144.0, 'returns 144' ); - v = lcmf( 5 ); - t.strictEqual( v, 60, 'returns 60' ); // LCM(5, 12) = 60 + v = lcmf( 5.0, 6.0 ); // LCM(5, 6) = 30 + t.strictEqual( v, 30.0, 'returns 30' ); - v = lcmf( 7 ); - t.strictEqual( v, 84, 'returns 84' ); // LCM(7, 12) = 84 + v = lcmf( 3.0, 8.0 ); // LCM(3, 8) = 24 + t.strictEqual( v, 24.0, 'returns 24' ); - t.end(); + t.end(); }); From 755782e5d86c87e455479d946faec48bba582df2 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:50:51 +0530 Subject: [PATCH 06/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 12896397b8b2..0e7a5451a811 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -4,6 +4,7 @@ Copyright (c) 2024 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 From 5fc950b31a25fa3d3772ef6b1ef75afec91de20e Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:51:13 +0530 Subject: [PATCH 07/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 0e7a5451a811..179ee281afee 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -42,7 +42,7 @@ The [least common multiple][lcm] (lcm) of two non-zero integers `a` and `b` is t var lcmf = require( '@stdlib/math/base/special/lcmf' ); ``` -### lcmf(a,b) +### lcmf( a, b ) Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```javascript From 3f1961213e12d661458cdc581cf5e5a5375d275a Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:51:38 +0530 Subject: [PATCH 08/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 179ee281afee..30e12d88cfb3 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -43,6 +43,7 @@ var lcmf = require( '@stdlib/math/base/special/lcmf' ); ``` ### lcmf( a, b ) + Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```javascript From d769d4eab4425b195a4c48cab576806b64669f71 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:52:08 +0530 Subject: [PATCH 09/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 30e12d88cfb3..b942c15e6708 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -47,7 +47,7 @@ var lcmf = require( '@stdlib/math/base/special/lcmf' ); Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```javascript -var v = lcmf( 10.0,12.0 ); +var v = lcmf( 10, 12 ); // returns 60 ``` From 0236db5d0f6f99438bab1130ae74241573bc46dd Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:52:19 +0530 Subject: [PATCH 10/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index b942c15e6708..9d64304d5e8b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -51,7 +51,7 @@ var v = lcmf( 10, 12 ); // returns 60 ``` -If either number is less than 1, the function returns `0`. +If either `a` or `b` is `0`, the function returns `0`. ```javascript var v = lcmf( 0.0, 12.0 ); From db63880511b3bc56adeb6a2f3a540fb957bb357f Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:52:31 +0530 Subject: [PATCH 11/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 9d64304d5e8b..f2b7ca086f4c 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -54,7 +54,7 @@ var v = lcmf( 10, 12 ); If either `a` or `b` is `0`, the function returns `0`. ```javascript -var v = lcmf( 0.0, 12.0 ); +var v = lcmf( 0, 12 ); // returns 0 v = lcmf( -5.0, 12.0 ); From d233b45cdeed0aa847c1ad6baba5a7b8c5a4ba04 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:53:17 +0530 Subject: [PATCH 12/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index f2b7ca086f4c..196a212852af 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -57,8 +57,6 @@ If either `a` or `b` is `0`, the function returns `0`. var v = lcmf( 0, 12 ); // returns 0 -v = lcmf( -5.0, 12.0 ); -// returns 0 ``` The inputs must be valid floating-point numbers; otherwise, the function returns `NaN`. From d5e2ea1b5036327decddf91c5ef767219bd69902 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:53:30 +0530 Subject: [PATCH 13/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 196a212852af..c6deb8b9abfe 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -56,7 +56,6 @@ If either `a` or `b` is `0`, the function returns `0`. ```javascript var v = lcmf( 0, 12 ); // returns 0 - ``` The inputs must be valid floating-point numbers; otherwise, the function returns `NaN`. From a290354cef4d3a57da5779e53d414c33f669c677 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:53:45 +0530 Subject: [PATCH 14/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index c6deb8b9abfe..37c0cd6b6f53 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -61,7 +61,7 @@ var v = lcmf( 0, 12 ); The inputs must be valid floating-point numbers; otherwise, the function returns `NaN`. ```javascript -var v = lcmf( 3.14, 12.0 ); +var v = lcmf( 3.14, 12 ); // returns NaN v = lcmf( NaN, 12.0 ); From 246a7634869a06087ae2bdd22db862f22b1ff75c Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:54:08 +0530 Subject: [PATCH 15/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 37c0cd6b6f53..0ec04ccf98fa 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -132,7 +132,7 @@ for ( i = 1; i <= 10; i++ ) { ### stdlib_base_lcmf( a,b ) -Computes the [least common multiple][lcm] for two floating-point numbers `a` and `b`. +Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```c float v = stdlib_base_lcmf( 10.0, 12.0 ); From 30b5fa76084872daa725669007ae5c6b53458b33 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:54:37 +0530 Subject: [PATCH 16/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 0ec04ccf98fa..37afd92bbc20 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -64,7 +64,7 @@ The inputs must be valid floating-point numbers; otherwise, the function returns var v = lcmf( 3.14, 12 ); // returns NaN -v = lcmf( NaN, 12.0 ); +v = lcmf( NaN, 12 ); // returns NaN ``` From afef3641072674a6f78bafa75be8099b2a1757ed Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:57:03 +0530 Subject: [PATCH 17/70] Update README.md Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 37afd92bbc20..9d040233fb08 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -94,9 +94,11 @@ var lcmf = require( '@stdlib/math/base/special/lcmf' ); var v; var i; -for ( i = 1; i <= 10; i++ ) { - v = lcmf( i, 12 ); - console.log( 'lcm(%d, 12) = %d', i, v ); +for ( i = 0; i < 100; i++ ) { + a = round( randu()*50 ); + b = round( randu()*50 ); + v = lcm( a, b ); + console.log( 'lcmf(%d,%d) = %d', a, b, v ); } ``` From 0d18ce7d453deb7ebf257263fea3ef8486a7d769 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:00:52 +0530 Subject: [PATCH 18/70] Updated examples Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 9d040233fb08..a7cb5a5cbb17 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -173,9 +173,15 @@ double stdlib_base_lcmf( const float a, const float b ); #include int main( void ) { - double v; - v = stdlib_base_lcmf( 10.0, 12.0 ); - printf( "lcm(10.0, 12.0) = %lf\n", v ); + const float a[] = { 24.0f, 32.0f, 48.0f, 116.0f, 33.0f }; + const float b[] = { 12.0f, 6.0f, 15.0f, 52.0f, 22.0f }; + + float out; + int i; + for (i = 0; i < 5; i++) { + out = lcmf(a[i], b[i]); + printf("lcm(%f, %f) = %f\n", a[i], b[i], out); + } } ``` From 7e2791e9ffd2cd58adc41c107291b5bd7ccea647 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:06:16 +0530 Subject: [PATCH 19/70] Apply suggestions from code review Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../math/base/special/lcmf/benchmark/benchmark.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js index 7cb902bb71e6..ca5a5a1715c1 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -21,9 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var roundf = require( '@stdlib/math/base/special/roundf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var randu = require( '@stdlib/random/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pkg = require( './../package.json' ).name; var lcmf = require( './../lib' ); @@ -38,15 +37,13 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = roundf( randu() * 50.0 ); - y = roundf( randu() * 50.0 ); - z = lcmf( x, y ); - if ( isnan( z ) ) { + z = lcmf( x[ i % x.length ], y[ i % y.length ] ); + if ( isnanf( z ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z ) ) { + if ( isnanf( z ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From ac500995bea7912149cc27525331c0883a004fb7 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:21:01 +0530 Subject: [PATCH 20/70] Apply suggestions from code review Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/README.md | 18 +++++------------- .../base/special/lcmf/benchmark/benchmark.js | 5 ++++- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index a7cb5a5cbb17..4cd4b27ea526 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -58,7 +58,7 @@ var v = lcmf( 0, 12 ); // returns 0 ``` -The inputs must be valid floating-point numbers; otherwise, the function returns `NaN`. +Both `a` and `b` must have integer values; otherwise, the function returns `NaN`. ```javascript var v = lcmf( 3.14, 12 ); @@ -132,22 +132,22 @@ for ( i = 0; i < 100; i++ ) { #include "stdlib/math/base/special/lcmf.h" ``` -### stdlib_base_lcmf( a,b ) +### stdlib_base_lcmf( a, b ) Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```c float v = stdlib_base_lcmf( 10.0, 12.0 ); -// returns 60.0 +// returns 60.0f ``` -The function accepts the following argument: +The function accepts the following arguments: - **a**: `[in] float` input value. - **b**: `[in] float` input value. ```c -double stdlib_base_lcmf( const float a, const float b ); +float stdlib_base_lcmf( const float a, const float b ); ``` @@ -205,12 +205,6 @@ int main( void ) { @@ -223,8 +217,6 @@ int main( void ) { -[@stdlib/math/base/special/gcd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/gcd - diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js index ca5a5a1715c1..e39efab5773d 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -35,7 +35,10 @@ bench( pkg, function benchmark( b ) { var z; var i; - b.tic(); + x = randu( 100, 0, 50 ); + y = randu( 100, 0, 50 ); + + b.tic(); for ( i = 0; i < b.iterations; i++ ) { z = lcmf( x[ i % x.length ], y[ i % y.length ] ); if ( isnanf( z ) ) { From cf7a56a1d4a71fee61b882aff4935c30c9d9841f Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:21:27 +0530 Subject: [PATCH 21/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 4cd4b27ea526..38ba8b639961 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -137,7 +137,7 @@ for ( i = 0; i < 100; i++ ) { Computes the [least common multiple][lcm] for two single-precision floating-point numbers `a` and `b`. ```c -float v = stdlib_base_lcmf( 10.0, 12.0 ); +float v = stdlib_base_lcmf( 10.0f, 12.0f ); // returns 60.0f ``` From 913bc0f602dd020140df771f08f6a73332f42652 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:23:05 +0530 Subject: [PATCH 22/70] Updated benchmark.js after review Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/benchmark/benchmark.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js index e39efab5773d..41a778545d0b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -34,6 +34,60 @@ bench( pkg, function benchmark( b ) { var y; var z; var i; +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pkg = require( './../package.json' ).name; +var lcmf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var z; + var i; + + x = randu( 100, 0, 50 ); + y = randu( 100, 0, 50 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = lcmf( x[ i % x.length ], y[ i % y.length ] ); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); x = randu( 100, 0, 50 ); y = randu( 100, 0, 50 ); From c8e6a51afb05258404c91eddf42eb3e86e990762 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:25:33 +0530 Subject: [PATCH 23/70] Update benchmark.native.js after review Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../lcmf/benchmark/benchmark.native.js | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js index 048732a0624d..fce885646936 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.native.js @@ -22,8 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var randu = require( '@stdlib/random/array/discrete-uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -32,31 +32,32 @@ var pkg = require( './../package.json' ).name; var lcmf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': ( lcmf instanceof Error ) + 'skip': ( lcmf instanceof Error ) }; // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var x; - var y; - var z; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x = ( randu() * 100.0 ) + 1.0; - y = ( randu() * 100.0 ) + 1.0; - z = lcmf( x, y ); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); + var x; + var y; + var z; + var i; + + x = randu( 100, 0, 50 ); + y = randu( 100, 0, 50 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = lcmf( x[ i % x.length ], y[ i % y.length ] ); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); }); From 5f8795b0aaed8fb8585ac530972d43fa6bed8572 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:28:43 +0530 Subject: [PATCH 24/70] Apply suggestions from code review Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 38ba8b639961..6d7bc265037b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -179,8 +179,8 @@ int main( void ) { float out; int i; for (i = 0; i < 5; i++) { - out = lcmf(a[i], b[i]); - printf("lcm(%f, %f) = %f\n", a[i], b[i], out); + out = stdlib_base_lcmf( a[ i ], b[ i ] ); + printf( "lcm(%f, %f) = %f\n", a[ i ], b[ i ], out ); } } ``` From 7a88267a711f58a2727e767e5517eb41863e63d5 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:29:32 +0530 Subject: [PATCH 25/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c index 8d83b06e52b8..cd3770d67980 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c @@ -24,7 +24,7 @@ #include #define NAME "lcmf" -#define ITERATIONS 10000 +#define ITERATIONS 1000000 #define REPEATS 3 /** From 5e5440d01050cd6438277b8648c378f7915e1b43 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:32:07 +0530 Subject: [PATCH 26/70] Update benchmark.c Replaced rand_int from rand_double as mentioned across other files Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c index cd3770d67980..65ebfffdde0f 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c @@ -79,8 +79,9 @@ static double tic( void ) { * * @return random integer */ -static int rand_int( void ) { - return (rand() % 20) + 1; // Random value between 1 and 20 for small lcmf tests +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); } /** From 77b4697df92cc46061b298ecd90150b7e0bb717a Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:33:19 +0530 Subject: [PATCH 27/70] Update benchmark.c Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/benchmark/c/benchmark.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c index 65ebfffdde0f..efd02c2f5fdb 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c @@ -91,21 +91,26 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - unsigned long result; + double x; + double y; + double z; double t; - int n; int i; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - n = rand_int(); - result = stdlib_base_lcmf( n ); // Call to lcmf function - if ( result == 0 ) { - printf( "should not return 0 for n > 0\n" ); + x = round( rand_double() * 500.0 ); + y = round( rand_double() * 500.0 ); + z = stdlib_base_lcmf( x, y ); + if ( z != z ) { + printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; + if ( z != z ) { + printf( "should not return NaN\n" ); + } return elapsed; } From 0a12704e0c7608d1a67689b7e1304ca701dd7782 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:03:40 +0530 Subject: [PATCH 28/70] Update repl.txt Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../math/base/special/lcmf/docs/repl.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt index 1a818c2b34e5..1f0cbf9d4ad3 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt @@ -7,22 +7,21 @@ Parameters ---------- - a: float32 - First single-precision floating-point number. + a: integer + First integer. - b: float32 - Second single-precision floating-point number. + b: integer + Second integer. Returns ------- - out: float32 - Least common multiple in single-precision floating-point format. + out: integer + Least common multiple. Examples -------- - > var v = {{alias}}( 21.0, 6.0 ) - 42.0 + > var v = {{alias}}( 21, 6 ) + 42 See Also -------- - - `@stdlib/math/base/special/gcd`: compute the greatest common divisor (gcd). From 881bfd4dd74aa56c22d6de4ab5a74b06c290f043 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:04:56 +0530 Subject: [PATCH 29/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt index 1f0cbf9d4ad3..eff6d986fb28 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt @@ -3,7 +3,8 @@ If either `a` or `b` is `0`, the function returns `0`. - Both `a` and `b` must have integer values in single-precision floating-point format; otherwise, the function returns `NaN`. + Both `a` and `b` must have integer values; otherwise, the function returns + `NaN`. Parameters ---------- From de17576f96dd58422d24e26ebbe7808d1cff70a0 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:07:37 +0530 Subject: [PATCH 30/70] Update README.md resolved import errors Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 6d7bc265037b..7ddee7b50e0a 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -89,6 +89,8 @@ v = lcmf( NaN, 12 ); ```javascript +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); var lcmf = require( '@stdlib/math/base/special/lcmf' ); var v; From 0c5e5d93ee8690a28a9e423342b843defc2b7fe8 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:09:58 +0530 Subject: [PATCH 31/70] Update benchmark.js resolved copy-paste error Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/benchmark/benchmark.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js index 41a778545d0b..286b200e0348 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -88,21 +88,3 @@ bench( pkg, function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); }); - - x = randu( 100, 0, 50 ); - y = randu( 100, 0, 50 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = lcmf( x[ i % x.length ], y[ i % y.length ] ); - if ( isnanf( z ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnanf( z ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); From 77e008afb3061a93a12ffc83dd9e6c602fb9654f Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:49:07 +0530 Subject: [PATCH 32/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 8d914636aff8..a4c7d98a3783 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -17,7 +17,7 @@ */ #include "stdlib/math/base/special/lcmf.h" -#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/special/gcd.h" /** From 8f59e2d2b218f8794f5d3c3c9d4dda76b885b3d3 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:49:18 +0530 Subject: [PATCH 33/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index a4c7d98a3783..23b3b4cc5eb7 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -18,7 +18,7 @@ #include "stdlib/math/base/special/lcmf.h" #include "stdlib/math/base/assert/is_nanf.h" -#include "stdlib/math/base/special/gcd.h" +#include "stdlib/math/base/special/gcdf.h" /** * Computes the least common multiple (LCM) of two single-precision floating-point numbers. From b34d9b3985096bcc223f942e478b2788190c9c8e Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:51:09 +0530 Subject: [PATCH 34/70] Update main.c replaced space with tab indentation Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/src/main.c | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 23b3b4cc5eb7..8ea817aee6a6 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -23,44 +23,43 @@ /** * Computes the least common multiple (LCM) of two single-precision floating-point numbers. * -* @param a first floating-point number (single precision) -* @param b second floating-point number (single precision) -* @return least common multiple (NaN if input is invalid) +* @param a first floating-point number (single precision) +* @param b second floating-point number (single precision) +* @return least common multiple (NaN if input is invalid) * * @example * float out = stdlib_base_lcmf( 21.0f, 6.0f ); * // returns 42.0f */ -double stdlib_base_lcmf( const float a, const float b ) { - float abs_a; - float abs_b; - float gcd_value; - const double b = 1.0; +double stdlib_base_lcmf(const float a,const float b){ + float abs_a; + float abs_b; + float gcd_value; + const double b = 1.0; - if ( a == 0.0 || b == 0.0 ) { + if(a==0.0||b==0.0){ return 0.0; } - if ( a < 0.0 ) { - abs_a = -a; - } else { - abs_a = a; + if(a<0.0){ + abs_a=-a; + }else{ + abs_a=a; } - if ( b < 0.0 ) { - abs_b = -b; - } else { - abs_b = b; + if(b<0.0){ + abs_b=-b; + }else{ + abs_b=b; } - abs_a = ( a < 0.0f ) ? -a : a; - abs_b = ( b < 0.0f ) ? -b : b; + abs_a=(a<0.0f)?-a:a; + abs_b=(b<0.0f)?-b:b; // Note: we rely on `gcd` to perform further argument validation... - - gcd_value = stdlib_base_gcd( abs_a, abs_b ); + gcd_value=stdlib_base_gcd(abs_a,abs_b); - if ( stdlib_base_is_nan( gcd_value ) ) { - return gcd_value; - } + if(stdlib_base_is_nan(gcd_value)){ + return gcd_value; + } - return ( abs_a / gcd_value ) * abs_b; + return(abs_a/gcd_value)*abs_b; } From 486a35264e2ff2708efeba9d3ab02fc17e787f2d Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:54:46 +0530 Subject: [PATCH 35/70] Update benchmark.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/benchmark/benchmark.js | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js index 286b200e0348..2577313c6fa7 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/benchmark.js @@ -26,45 +26,6 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pkg = require( './../package.json' ).name; var lcmf = require( './../lib' ); - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var y; - var z; - var i; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/array/discrete-uniform' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var pkg = require( './../package.json' ).name; -var lcmf = require( './../lib' ); - - -// MAIN // - bench( pkg, function benchmark( b ) { var x; var y; From 2400f976db52aee240928c6e75d02503aaef19ac Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:58:35 +0530 Subject: [PATCH 36/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 8ea817aee6a6..d5aa4e3b6111 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -23,9 +23,9 @@ /** * Computes the least common multiple (LCM) of two single-precision floating-point numbers. * -* @param a first floating-point number (single precision) -* @param b second floating-point number (single precision) -* @return least common multiple (NaN if input is invalid) +* @param a integer +* @param b integer +* @return least common multiple * * @example * float out = stdlib_base_lcmf( 21.0f, 6.0f ); From ef7a4c9136c5a8fec0d0d302444b116b2dc1fa23 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:58:52 +0530 Subject: [PATCH 37/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index d5aa4e3b6111..b87d490be81d 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -31,7 +31,7 @@ * float out = stdlib_base_lcmf( 21.0f, 6.0f ); * // returns 42.0f */ -double stdlib_base_lcmf(const float a,const float b){ +float stdlib_base_lcmf( const float a, const float b ) { float abs_a; float abs_b; float gcd_value; From 99acaceca53e092a501573a27737ddadc8da7b22 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:01:52 +0530 Subject: [PATCH 38/70] Update main.c Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/src/main.c | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index b87d490be81d..85e05f3b8680 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -32,31 +32,26 @@ * // returns 42.0f */ float stdlib_base_lcmf( const float a, const float b ) { - float abs_a; - float abs_b; - float gcd_value; + double abs_a; + double abs_b; + double gcd_value; const double b = 1.0; - if(a==0.0||b==0.0){ + if ( a == 0.0 || b == 0.0 ) { return 0.0; } - if(a<0.0){ - abs_a=-a; - }else{ - abs_a=a; + if ( a < 0.0 ) { + abs_a = -a; + } else { + abs_a = a; } - if(b<0.0){ - abs_b=-b; - }else{ - abs_b=b; + if ( b < 0.0 ) { + abs_b = -b; + } else { + abs_b = b; } - - abs_a=(a<0.0f)?-a:a; - abs_b=(b<0.0f)?-b:b; - // Note: we rely on `gcd` to perform further argument validation... gcd_value=stdlib_base_gcd(abs_a,abs_b); - if(stdlib_base_is_nan(gcd_value)){ return gcd_value; } From 5beabf0b17cfdd8470fb46d73582b04055019d41 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:08:40 +0530 Subject: [PATCH 39/70] Update main.c Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 85e05f3b8680..6ef34a6deb33 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -23,8 +23,8 @@ /** * Computes the least common multiple (LCM) of two single-precision floating-point numbers. * -* @param a integer -* @param b integer +* @param a single-precision floating-point number +* @param b single-precision floating-point number * @return least common multiple * * @example From 9e602ebdea471b6d9f31098f5965bde3e3151cd9 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:09:55 +0530 Subject: [PATCH 40/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js index 4c76d8811dd0..a4b85a59aa28 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js @@ -46,7 +46,7 @@ var addon = require( './../src/addon.node' ); * // returns NaN */ function lcmf( a , b ) { - return addon( a , b ); + return addon( a, b ); } From 1ffdfcdd227ec97ae4b02c464315575719331e05 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:10:16 +0530 Subject: [PATCH 41/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js index a4b85a59aa28..4bc436c70fc5 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js @@ -45,7 +45,7 @@ var addon = require( './../src/addon.node' ); * var v = lcmf( NaN, 5.0 ); * // returns NaN */ -function lcmf( a , b ) { +function lcmf( a, b ) { return addon( a, b ); } From 03e406854653511920b31cb40b3b7c4dbd1483fc Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:24:44 +0530 Subject: [PATCH 42/70] Update main.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../math/base/special/lcmf/lib/main.js | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index e9b65ea4eb41..a55f3cec446c 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -29,8 +29,8 @@ var gcd = require( '@stdlib/math/base/special/gcd' ); /** * Computes the least common multiple (LCM) of two floating-point numbers. * -* @param {number} a - first floating-point number -* @param {number} b - second floating-point number +* @param {number} a - integer +* @param {number} b - integer * @returns {number} least common multiple of `a` and `b` * * @example @@ -49,29 +49,27 @@ var gcd = require( '@stdlib/math/base/special/gcd' ); * var v = lcmf( NaN, 5.0 ); * // returns NaN */ -function lcmf( a , b ) { - var result; - var i; - - if ( isnan( a ) || isnan( b ) || ( a == 0 ) || ( b == 0 ) ) { - return 0.0; - } - - result = 1; - // Note: we rely on `gcd` to perform further argument validation... - - var g = gcd( a, b ); - - if ( g === 0 ) { - return NaN; - } - - result = a * b / g; - - return result; +function lcm( a, b ) { + var d; + if ( a === 0 || b === 0 ) { + return 0; + } + if ( a < 0 ) { + a = -a; + } + if ( b < 0 ) { + b = -b; + } + // Note: we rely on `gcd` to perform further argument validation... + d = gcd( a, b ); + if ( isnan( d ) ) { + return d; + } + return (a/d) * b; } + // EXPORTS // module.exports = lcmf; From cec31942bac7d4a9e44b84c38132a0e45d9b70cc Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:25:53 +0530 Subject: [PATCH 43/70] Update native.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js index 4bc436c70fc5..f6435d3382e7 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js @@ -29,8 +29,8 @@ var addon = require( './../src/addon.node' ); * Computes the least common multiple (LCM) of two floating-point numbers. * * @private -* @param {number} a - first floating-point number -* @param {number} b - second floating-point number +* @param {number} a - integer +* @param {number} b - integer * @returns {number} least common multiple of `a` and `b` * * @example From 7700ced55ffbe887c35687efe17116ae76bf7584 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:27:01 +0530 Subject: [PATCH 44/70] Update native.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js index f6435d3382e7..98db309241dc 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the least common multiple (LCM) of two floating-point numbers. +* Computes the least common multiple (LCM) of two single-precision floating-point numbers. * * @private * @param {number} a - integer From 5a3956f8a0e68199b67a461d447bcfee7edf671d Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:32:22 +0530 Subject: [PATCH 45/70] Update main.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index a55f3cec446c..fa88bca74276 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -49,7 +49,7 @@ var gcd = require( '@stdlib/math/base/special/gcd' ); * var v = lcmf( NaN, 5.0 ); * // returns NaN */ -function lcm( a, b ) { +function lcmf( a, b ) { var d; if ( a === 0 || b === 0 ) { return 0; From 5316ae68846f5a4313e7c8cb430fbc604f65889e Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:34:03 +0530 Subject: [PATCH 46/70] Update README.md Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index 7ddee7b50e0a..e83ab534fba5 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -99,7 +99,7 @@ var i; for ( i = 0; i < 100; i++ ) { a = round( randu()*50 ); b = round( randu()*50 ); - v = lcm( a, b ); + v = lcmf( a, b ); console.log( 'lcmf(%d,%d) = %d', a, b, v ); } ``` From de73acf9978ec3d30a2aa1195a5730ba26871069 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:36:25 +0530 Subject: [PATCH 47/70] Update index.d.ts Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/docs/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts index 16187d93535a..72f98da2ec96 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts @@ -27,9 +27,9 @@ * - The inputs `a` and `b` are expected to be single-precision floating-point numbers. * - If `a` or `b` are not whole numbers, the function returns `NaN`. * -* @param a - single-precision floating-point number -* @param b - single-precision floating-point number -* @returns least common multiple as a single-precision floating-point number +* @param a - integer +* @param b - integer +* @returns least common multiple * * @example * var v = lcmf( 21.0, 6.0 ); From d196732fde6da5f83478764a123f8c9cdb5c0e9c Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:38:03 +0530 Subject: [PATCH 48/70] Update main.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index fa88bca74276..debfb0e4fc73 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -20,7 +20,7 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var gcd = require( '@stdlib/math/base/special/gcd' ); @@ -62,7 +62,7 @@ function lcmf( a, b ) { } // Note: we rely on `gcd` to perform further argument validation... d = gcd( a, b ); - if ( isnan( d ) ) { + if ( isnanf( d ) ) { return d; } return (a/d) * b; From 8838682852ed6bbb780d91d038596213a0a39363 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:40:05 +0530 Subject: [PATCH 49/70] Update test.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../math/base/special/lcmf/test/test.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js index 161eada855da..271b59473f34 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js @@ -21,7 +21,7 @@ // MODULES // var tape = require( 'tape' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var lcmf = require( './../lib' ); @@ -38,13 +38,13 @@ tape( 'the function returns `NaN` if input is `NaN`', function test( t ) { var v; v = lcmf( NaN, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( NaN, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -53,13 +53,13 @@ tape( 'the function returns `NaN` if input is `+infinity`', function test( t ) { var v; v = lcmf( PINF, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( PINF, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -68,13 +68,13 @@ tape( 'the function returns `NaN` if input is `-infinity`', function test( t ) { var v; v = lcmf( NINF, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( NINF, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -83,13 +83,13 @@ tape( 'the function returns `NaN` if input is not an floating point number', fun var v; v = lcmf( 3.14, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, 3.14 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 3.14, 6.18 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -144,4 +144,4 @@ tape( 'the function computes the least common multiple for two single precision t.strictEqual( v, 144.0, 'returns 144' ); t.end(); -}); \ No newline at end of file +}); From 308353bb53cc88702266f5e44c5249f0b9f313c8 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:41:11 +0530 Subject: [PATCH 50/70] Update main.c Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 6ef34a6deb33..6e3157274028 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -51,8 +51,8 @@ float stdlib_base_lcmf( const float a, const float b ) { abs_b = b; } // Note: we rely on `gcd` to perform further argument validation... - gcd_value=stdlib_base_gcd(abs_a,abs_b); - if(stdlib_base_is_nan(gcd_value)){ + gcd_value=stdlib_base_gcdf(abs_a,abs_b); + if(stdlib_base_is_nanf(gcd_value)){ return gcd_value; } From 5ae902b6e830b99503c5bec352947b70f7ed5c6b Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 14:42:38 +0530 Subject: [PATCH 51/70] Update test.native.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/test/test.native.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js index 3b22f8370156..694aeef10069 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -46,13 +46,13 @@ tape( 'the function returns `NaN` if either argument is `NaN`', opts, function t var v; v = lcmf( NaN, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( NaN, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -61,13 +61,13 @@ tape( 'the function returns `NaN` if either argument is `+infinity`', opts, func var v; v = lcmf( PINF, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( PINF, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -76,13 +76,13 @@ tape( 'the function returns `NaN` if either argument is `-infinity`', opts, func var v; v = lcmf( NINF, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( NINF, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -91,13 +91,13 @@ tape( 'the function returns `NaN` if either argument is not a valid floating-poi var v; v = lcmf( 3.14, 10.0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 10.0, 3.14 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = lcmf( 3.14, 6.18 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); From ef7fd656bf90ca2b9d3749702b096d534e5cfb42 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:49:06 +0530 Subject: [PATCH 52/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index e83ab534fba5..d9c59c6be9f8 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -97,7 +97,7 @@ var v; var i; for ( i = 0; i < 100; i++ ) { - a = round( randu()*50 ); + a = round( randu() * 50 ); b = round( randu()*50 ); v = lcmf( a, b ); console.log( 'lcmf(%d,%d) = %d', a, b, v ); From 76b8ae999554eff7145f78bfebd722b02e118cc7 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:49:21 +0530 Subject: [PATCH 53/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/README.md Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md index d9c59c6be9f8..f51c3aa9151d 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/README.md @@ -98,7 +98,7 @@ var i; for ( i = 0; i < 100; i++ ) { a = round( randu() * 50 ); - b = round( randu()*50 ); + b = round( randu() * 50 ); v = lcmf( a, b ); console.log( 'lcmf(%d,%d) = %d', a, b, v ); } From 5b04e9d5eecdc5fe9a02280c3108871e0177d9ab Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:55:16 +0530 Subject: [PATCH 54/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c index efd02c2f5fdb..4639aec0c264 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c @@ -79,9 +79,9 @@ static double tic( void ) { * * @return random integer */ -static double rand_double( void ) { +static float rand_float( void ) { int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); + return (float)r / ( (float)RAND_MAX + 1.0f ); } /** From dcde939efbb2d3c43e6e04f025b01ac41d9f6b97 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:04:11 +0530 Subject: [PATCH 55/70] Update benchmark.c Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/benchmark/c/benchmark.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c index 4639aec0c264..044e0e56368b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c @@ -91,17 +91,19 @@ static float rand_float( void ) { */ static double benchmark( void ) { double elapsed; - double x; - double y; - double z; + float x[ 100 ]; + float y[ 100 ]; + float z; double t; int i; t = tic(); + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 20.0f * rand_float() ) - 10.0f; + y[ i ] = ( 2048.0f * rand_float() ) - 1024.0f; + } for ( i = 0; i < ITERATIONS; i++ ) { - x = round( rand_double() * 500.0 ); - y = round( rand_double() * 500.0 ); - z = stdlib_base_lcmf( x, y ); + z = stdlib_base_lcmf( x[ i % 100 ], y[ i % 100 ] ); if ( z != z ) { printf( "should not return NaN\n" ); break; @@ -113,7 +115,6 @@ static double benchmark( void ) { } return elapsed; } - /** * Main execution sequence. */ From 6d7843d6b5d67b02dbcf62e386fac1669485afcb Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:05:02 +0530 Subject: [PATCH 56/70] Update test.ts Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts index 3a91593c076b..315ca5657885 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts @@ -44,4 +44,4 @@ import lcmf = require( './index' ); // The compiler throws an error if the function is provided insufficient arguments... { lcmf(); // $ExpectError -} \ No newline at end of file +} From d212d482e4570b2b29c0f67933acabbde539db00 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:12:47 +0530 Subject: [PATCH 57/70] Update example.c Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../base/special/lcmf/examples/c/example.c | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c index 770ef3ee78eb..ab8686e07cc7 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c @@ -17,24 +17,19 @@ */ #include "stdlib/math/base/special/lcmf.h" +#include #include int main( void ) { - // Define two float arrays to work with floating-point numbers - const float nums_a[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 10.0f, 15.0f, 20.0f }; - const float nums_b[] = { 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 15.0f, 20.0f, 25.0f }; - - // Variable to store LCM result - float result; + float y; int i; - // Loop over the arrays and compute LCM of pairs - for ( i = 0; i < 9; i++ ) { - // Compute the LCM of two floating-point numbers - result = stdlib_base_lcmf( nums_a[i], nums_b[i] ); - - // Print the result - printf( "LCM( %.2f, %.2f ) = %.2f\n", nums_a[i], nums_b[i], result ); + const float frac[] = { 0.5f, 5.0f, 0.0f, 3.5f, 7.9f }; + const int32_t exp[] = { 3, -2, 20, 39, 14 }; + + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_lcmf( frac[ i ], exp[ i ] ); + printf( "ldexpf(%.2f, %d) = %f\n", frac[ i ], exp[ i ], y ); } return 0; From d28ccce30b5b980ed6b40fa5255ffb519c2f34d9 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:18:48 +0530 Subject: [PATCH 58/70] Update index.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../math/base/special/lcmf/examples/index.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js index 6b9783a2c87e..1ca2e7d0ff0b 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js @@ -19,20 +19,13 @@ 'use strict'; var linspace = require( '@stdlib/array/base/linspace' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var lcmf = require( './../lib' ); -var nValues = linspace( 1.0, 20.0, 20 ); +var numsA = linspace( 1.0, 10.0, 10 ); +var numsB = discreteUniform( 100, 0, 10 ); -// Iterate through the values and compute the LCM of two numbers var i; -for ( i = 0; i < nValues.length - 1; i++ ) { - var a = nValues[i]; - var b = nValues[i + 1]; - - // Ensure a and b are single-precision floating-point numbers (float32) - if ( typeof a === 'number' && typeof b === 'number' ) { - console.log( 'LCM of %d and %d = %d', a, b, lcmf( a, b ) ); - } else { - console.log( 'Invalid input types. Both a and b should be single-precision floating-point numbers.' ); - } +for ( i = 0; i < numsA.length; i++ ) { + console.log( 'lcmf(%d, %d) = %d', numsA[ i ], numsB[ i ], lcmf( numsA[ i ], numsB[ i ] ) ); } From 352a99c40a1f9e4b146e29394457850dde7bc667 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:25:41 +0530 Subject: [PATCH 59/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index debfb0e4fc73..077b5270d7ab 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -65,7 +65,7 @@ function lcmf( a, b ) { if ( isnanf( d ) ) { return d; } - return (a/d) * b; + return ( a / d ) * b; } From 784cc9a474c60adaf657b4c42c4feab145e9a0e9 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:26:00 +0530 Subject: [PATCH 60/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index 077b5270d7ab..f2d4718f860f 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -60,6 +60,7 @@ function lcmf( a, b ) { if ( b < 0 ) { b = -b; } + // Note: we rely on `gcd` to perform further argument validation... d = gcd( a, b ); if ( isnanf( d ) ) { From 5bacf396147b5fc2028b11c068cf7e791f2e8ca6 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:26:17 +0530 Subject: [PATCH 61/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index f2d4718f860f..3fa582014ee9 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -70,7 +70,6 @@ function lcmf( a, b ) { } - // EXPORTS // module.exports = lcmf; From 691cfb818972787ecfbeb524599934ef9285f3ea Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:27:20 +0530 Subject: [PATCH 62/70] Update manifest.json Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- .../@stdlib/math/base/special/lcmf/manifest.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json b/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json index 1dc7d0d9456d..ad83dc57770d 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/manifest.json @@ -37,8 +37,8 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/napi/binary", - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/gcd" + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/gcdf" ] }, { @@ -52,8 +52,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/gcd" + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/gcdf" ] }, { @@ -67,10 +67,10 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/gcd" + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/special/gcdf" ] } ] } - \ No newline at end of file + From 8f449729c45a8230b750ff758fe9cf754c7d56f7 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:28:30 +0530 Subject: [PATCH 63/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 6e3157274028..0d1a0f48e507 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -24,7 +24,7 @@ * Computes the least common multiple (LCM) of two single-precision floating-point numbers. * * @param a single-precision floating-point number -* @param b single-precision floating-point number +* @param b integer * @return least common multiple * * @example From 209d798bdd9674b9f5e584cadbbf6434cc906c0b Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:28:43 +0530 Subject: [PATCH 64/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/package.json Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json index 23d15b06d25f..36cf738c6bb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/lcmf", "version": "0.0.0", - "description": "Compute the least common multiple (LCM) of two single-point floating-numbers", + "description": "Compute the least common multiple (LCM) of two single-precision floating-numbers", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From ca16cf7aeadf8d06195d387220657a0eecfc122c Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:28:54 +0530 Subject: [PATCH 65/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/package.json Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json index 36cf738c6bb4..f570dd464d6e 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json @@ -66,7 +66,6 @@ "gcd", "integer", "range LCM", - "from 1 to n" ] } \ No newline at end of file From 03f16b9460ba6f3920b420b9862fdfede82fbd07 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:29:07 +0530 Subject: [PATCH 66/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/package.json Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json index f570dd464d6e..6fd04833e4dc 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json @@ -65,7 +65,6 @@ "discrete", "gcd", "integer", - "range LCM", ] } \ No newline at end of file From 4b7412122eb41152fb5b451240cb1c565a0ccfba Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:29:18 +0530 Subject: [PATCH 67/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/package.json Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json index 6fd04833e4dc..a22970cb7261 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/package.json @@ -64,7 +64,7 @@ "arithmetic", "discrete", "gcd", - "integer", + "integer" ] } \ No newline at end of file From ff495abf11dd6de3d7e2d6f0dbaca167a4a0a945 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:29:39 +0530 Subject: [PATCH 68/70] Update lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c Co-authored-by: Gunj Joshi Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 0d1a0f48e507..262c66b718c4 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -23,7 +23,7 @@ /** * Computes the least common multiple (LCM) of two single-precision floating-point numbers. * -* @param a single-precision floating-point number +* @param a integer * @param b integer * @return least common multiple * From 6f8f71151e58cedbbb37619b599eadd476cb077d Mon Sep 17 00:00:00 2001 From: Harsh Mathur Date: Sun, 17 Nov 2024 11:41:13 +0530 Subject: [PATCH 69/70] resolved conflicts --- .../lcmf/benchmark/c/{ => native}/Makefile | 0 .../lcmf/benchmark/c/{ => native}/benchmark.c | 0 .../base/special/lcmf/examples/c/example.c | 2 +- .../math/base/special/lcmf/lib/index.js | 2 +- .../math/base/special/lcmf/lib/main.js | 4 +- .../math/base/special/lcmf/src/addon.c | 2 +- .../@stdlib/math/base/special/lcmf/src/main.c | 27 ++--- .../math/base/special/lcmf/test/test.js | 112 +++++++++--------- .../base/special/lcmf/test/test.native.js | 4 +- 9 files changed, 73 insertions(+), 80 deletions(-) rename lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/{ => native}/Makefile (100%) rename lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/{ => native}/benchmark.c (100%) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/native/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/Makefile rename to lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/native/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/native/benchmark.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/benchmark.c rename to lib/node_modules/@stdlib/math/base/special/lcmf/benchmark/c/native/benchmark.c diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c index ab8686e07cc7..3990dec0525e 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/examples/c/example.c @@ -29,7 +29,7 @@ int main( void ) { for ( i = 0; i < 5; i++ ) { y = stdlib_base_lcmf( frac[ i ], exp[ i ] ); - printf( "ldexpf(%.2f, %d) = %f\n", frac[ i ], exp[ i ], y ); + printf( "lcmf(%.2f, %d) = %f\n", frac[ i ], exp[ i ], y ); } return 0; diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js index 6c37abbc9bba..ec87461ebfa0 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Computes the least common multiple (LCM) of two floating-point numbers. +* Computes the least common multiple (LCM) of two single-precision floating-point numbers. * * @module @stdlib/math/base/special/lcmf * diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js index 3fa582014ee9..632f546edd49 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js @@ -21,13 +21,13 @@ // MODULES // var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var gcd = require( '@stdlib/math/base/special/gcd' ); +var gcdf = require( '@stdlib/math/base/special/gcdf' ); // MAIN // /** -* Computes the least common multiple (LCM) of two floating-point numbers. +* Computes the least common multiple (LCM) of two single-precision floating-point numbers. * * @param {number} a - integer * @param {number} b - integer diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c index a089f631a51b..1d2a302e41ac 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/addon.c @@ -19,4 +19,4 @@ #include "stdlib/math/base/special/lcmf.h" #include "stdlib/math/base/napi/unary.h" -STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_lcmf ) +STDLIB_MATH_BASE_NAPI_MODULE_FF_F( stdlib_base_lcmf ) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c index 262c66b718c4..98d33e0227a3 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/src/main.c @@ -32,29 +32,28 @@ * // returns 42.0f */ float stdlib_base_lcmf( const float a, const float b ) { - double abs_a; - double abs_b; - double gcd_value; - const double b = 1.0; + float an; + float bn; + float d; - if ( a == 0.0 || b == 0.0 ) { - return 0.0; + if ( a == 0.0f || b == 0.0f ) { + return 0.0f; } if ( a < 0.0 ) { - abs_a = -a; + an = -a; } else { - abs_a = a; + an = a; } if ( b < 0.0 ) { - abs_b = -b; + bn = -b; } else { - abs_b = b; + bn = b; } // Note: we rely on `gcd` to perform further argument validation... - gcd_value=stdlib_base_gcdf(abs_a,abs_b); - if(stdlib_base_is_nanf(gcd_value)){ - return gcd_value; + d = stdlib_base_gcdf( an, bn ); + if ( stdlib_base_is_nanf ( d ) ){ + return d; } - return(abs_a/gcd_value)*abs_b; + return ( an / d ) * bn; } diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js index 271b59473f34..e08e7718942d 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js @@ -26,6 +26,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var lcmf = require( './../lib' ); + // TESTS // tape( 'main export is a function', function test( t ) { @@ -34,114 +35,107 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function returns `NaN` if input is `NaN`', function test( t ) { +tape( 'the function returns `NaN` if either argument is `NaN`', function test( t ) { var v; v = lcmf( NaN, 10.0 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( 10.0, NaN ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( 10.0, NaN ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( NaN, NaN ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( NaN, NaN ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function returns `NaN` if input is `+infinity`', function test( t ) { +tape( 'the function returns `NaN` if either argument is `+infinity`', function test( t ) { var v; v = lcmf( PINF, 10.0 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( 10.0, PINF ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( 10.0, PINF ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( PINF, PINF ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( PINF, PINF ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function returns `NaN` if input is `-infinity`', function test( t ) { +tape( 'the function returns `NaN` if either argument is `-infinity`', function test( t ) { var v; v = lcmf( NINF, 10.0 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( 10.0, NINF ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( 10.0, NINF ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( NINF, NINF ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( NINF, NINF ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function returns `NaN` if input is not an floating point number', function test( t ) { +tape( 'the function returns `NaN` if either argument is not a floating-point integer', function test( t ) { var v; v = lcmf( 3.14, 10.0 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( 10.0, 3.14 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( 10.0, 3.14 ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); - v = lcmf( 3.14, 6.18 ); - t.strictEqual( isnanf( v ), true, 'returns NaN' ); + v = lcmf( 3.14, 6.18 ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); -tape( 'the function returns `0` if input is `0`', function test( t ) { - var v = lcmf( 0.0, 0.0 ); - t.strictEqual( v, 0.0, 'returns 0' ); +tape( 'the function returns `0` if either argument is `0`', function test( t ) { + var v; + + v = lcmf( 0.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - v = lcmf( 2.0, 0.0 ); - t.strictEqual( v, 0.0, 'returns 0' ); + v = lcmf( 2.0, 0.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); - v = lcmf( 0.0, -3.0 ); - t.strictEqual( v, 0.0, 'returns 0' ); + v = lcmf( 0.0, -3.0 ); + t.strictEqual( v, 0.0, 'returns 0' ); t.end(); }); -tape( 'the function computes the least common multiple for two single precision floating-point numbers', function test( t ) { - var v; - - v = lcmf( 0.0, 0.0 ); - t.strictEqual( v, 0.0, 'returns 0' ); - - v = lcmf( 1.0, 0.0 ); - t.strictEqual( v, 0.0, 'returns 0' ); - - v = lcmf( 0.0, 1.0 ); - t.strictEqual( v, 0.0, 'returns 0' ); +tape( 'the function computes the least common multiple', function test( t ) { + var v; - v = lcmf( 6.0, 4.0 ); - t.strictEqual( v, 12.0, 'returns 12' ); + v = lcmf( 6.0, 4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - v = lcmf( 6.0, -4.0 ); - t.strictEqual( v, 12.0, 'returns 12' ); + v = lcmf( 6.0, -4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - v = lcmf( -6.0, -4.0 ); - t.strictEqual( v, 12.0, 'returns 12' ); + v = lcmf( -6.0, -4.0 ); + t.strictEqual( v, 12.0, 'returns 12' ); - v = lcmf( 2.0, 8.0 ); - t.strictEqual( v, 8.0, 'returns 8' ); + v = lcmf( 2.0, 8.0 ); + t.strictEqual( v, 8.0, 'returns 8' ); - v = lcmf( 15.0, 20.0 ); - t.strictEqual( v, 60.0, 'returns 60' ); + v = lcmf( 15.0, 20.0 ); + t.strictEqual( v, 60.0, 'returns 60' ); - v = lcmf( 20.0, 15.0 ); - t.strictEqual( v, 60.0, 'returns 60' ); + v = lcmf( 20.0, 15.0 ); + t.strictEqual( v, 60.0, 'returns 60' ); - v = lcmf( 35.0, -21.0 ); - t.strictEqual( v, 105.0, 'returns 105' ); + v = lcmf( 35.0, -21.0 ); + t.strictEqual( v, 105.0, 'returns 105' ); - v = lcmf( 48.0, 18.0 ); - t.strictEqual( v, 144.0, 'returns 144' ); + v = lcmf( 48.0, 18.0 ); + t.strictEqual( v, 144.0, 'returns 144' ); - t.end(); + t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js index 694aeef10069..072c2491a7ce 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.native.js @@ -151,10 +151,10 @@ tape( 'the function computes the least common multiple of two floating-point num v = lcmf( 48.0, 18.0 ); t.strictEqual( v, 144.0, 'returns 144' ); - v = lcmf( 5.0, 6.0 ); // LCM(5, 6) = 30 + v = lcmf( 5.0, 6.0 ); t.strictEqual( v, 30.0, 'returns 30' ); - v = lcmf( 3.0, 8.0 ); // LCM(3, 8) = 24 + v = lcmf( 3.0, 8.0 ); t.strictEqual( v, 24.0, 'returns 24' ); t.end(); From d3343c0c51a84c2fdd1ac638ed1c321c62717a18 Mon Sep 17 00:00:00 2001 From: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:06:56 +0530 Subject: [PATCH 70/70] Update test.js Signed-off-by: Harsh Mathur <104578544+Harsh-Mathur-1503@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js index e08e7718942d..5a36a82e2ff1 100644 --- a/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js @@ -22,8 +22,8 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); -var NINF = require( '@stdlib/constants/float64/ninf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); var lcmf = require( './../lib' );