From 010161b1505d8b27276ca7810630cf3f3d4ac618 Mon Sep 17 00:00:00 2001 From: marq Date: Sat, 14 Feb 2026 19:57:16 +0530 Subject: [PATCH 1/2] feat: Add math/base/special/log10f --- .../math/base/special/log10f/README.md | 232 ++++++++++++++++++ .../special/log10f/benchmark/benchmark.js | 86 +++++++ .../log10f/benchmark/benchmark.native.js | 63 +++++ .../base/special/log10f/benchmark/c/Makefile | 151 ++++++++++++ .../special/log10f/benchmark/c/benchmark.c | 136 ++++++++++ .../math/base/special/log10f/binding.gyp | 170 +++++++++++++ .../math/base/special/log10f/docs/repl.txt | 34 +++ .../base/special/log10f/docs/types/index.d.ts | 56 +++++ .../base/special/log10f/docs/types/test.ts | 44 ++++ .../base/special/log10f/examples/c/Makefile | 150 +++++++++++ .../base/special/log10f/examples/c/example.c | 33 +++ .../base/special/log10f/examples/index.js | 33 +++ .../math/base/special/log10f/include.gypi | 53 ++++ .../include/stdlib/math/base/special/log10f.h | 38 +++ .../math/base/special/log10f/lib/index.js | 40 +++ .../math/base/special/log10f/lib/main.js | 114 +++++++++ .../math/base/special/log10f/lib/native.js | 62 +++++ .../math/base/special/log10f/manifest.json | 87 +++++++ .../math/base/special/log10f/package.json | 76 ++++++ .../math/base/special/log10f/src/Makefile | 70 ++++++ .../math/base/special/log10f/src/addon.c | 22 ++ .../math/base/special/log10f/src/main.c | 95 +++++++ .../math/base/special/log10f/test/test.js | 118 +++++++++ .../base/special/log10f/test/test.native.js | 125 ++++++++++ 24 files changed, 2088 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/include/stdlib/math/base/special/log10f.h create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/log10f/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/README.md b/lib/node_modules/@stdlib/math/base/special/log10f/README.md new file mode 100644 index 000000000000..150508f59bae --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/README.md @@ -0,0 +1,232 @@ + + +# log10f + +> Evaluate the [common logarithm][common-logarithm] of a single-precision floating-point number. + +
+ +The [common logarithm][common-logarithm] (logarithm with base 10) is defined for any positive real number as + + + +```math +\quad \log_{10} \left( x \right) = y \quad \text{such that} \quad 10^y = x +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var log10f = require( '@stdlib/math/base/special/log10f' ); +``` + +#### log10f( x ) + +Evaluates the [common logarithm][common-logarithm] of a single-precision floating-point number. + +```javascript +var v = log10f( 100.0 ); +// returns 2.0 + +v = log10f( 10.0 ); +// returns 1.0 + +v = log10f( 0.0 ); +// returns -Infinity + +v = log10f( Infinity ); +// returns Infinity + +v = log10f( NaN ); +// returns NaN +``` + +For negative numbers, the [common logarithm][common-logarithm] is **not** defined. + +```javascript +var v = log10f( -4.0 ); +// returns NaN +``` + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var log10f = require( '@stdlib/math/base/special/log10f' ); + +var opts = { + 'dtype': 'float32' +}; +var x = uniform( 100, 0.0, 100.0, opts ); + +var i; +for ( i = 0; i < x.length; i++ ) { + console.log( 'log10f(%d) = %d', x[ i ], log10f( x[ i ] ) ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/log10f.h" +``` + +#### stdlib_base_log10f( x ) + +Evaluates the [common logarithm][common-logarithm] of a single-precision floating-point number. + +```c +float out = stdlib_base_log10f( 100.0f ); +// returns 2.0f + +out = stdlib_base_log10f( 10.0f ); +// returns 1.0f +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. + +```c +float stdlib_base_log10f( const float x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/log10f.h" +#include +#include + +int main( void ) { + float x; + float v; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( (float)rand() / (float)RAND_MAX ) * 100.0f; + v = stdlib_base_log10f( x ); + printf( "log10f(%f) = %f\n", x, v ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.js new file mode 100644 index 000000000000..657adc4dbc78 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.js @@ -0,0 +1,86 @@ +/** +* @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 uniform = require('@stdlib/random/array/uniform'); +var isnanf = require('@stdlib/math/base/assert/is-nanf'); +var float64ToFloat32 = require('@stdlib/number/float64/base/to-float32'); +var pkg = require('./../package.json').name; +var log10f = require('./../lib'); + + +// VARIABLES // + +var opts = { + 'skip': (typeof Math.log10 !== 'function') // eslint-disable-line stdlib/no-builtin-math +}; + + +// MAIN // + +bench(pkg, function benchmark(b) { + var x; + var y; + var i; + + x = uniform(100, 0.0, 1000.0, { + 'dtype': 'float32' + }); + + b.tic(); + for (i = 0; i < b.iterations; i++) { + y = log10f(x[i % x.length]); + if (isnanf(y)) { + b.fail('should not return NaN'); + } + } + b.toc(); + if (isnanf(y)) { + b.fail('should not return NaN'); + } + b.pass('benchmark finished'); + b.end(); +}); + +bench(pkg + '::built-in', opts, function benchmark(b) { + var x; + var y; + var i; + + x = uniform(100, 0.0, 1000.0, { + 'dtype': 'float32' + }); + + b.tic(); + for (i = 0; i < b.iterations; i++) { + y = Math.log10(x[i % x.length]); // eslint-disable-line stdlib/no-builtin-math + if (y !== y) { + b.fail('should not return NaN'); + } + } + b.toc(); + if (y !== y) { + b.fail('should not return NaN'); + } + b.pass('benchmark finished'); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.native.js new file mode 100644 index 000000000000..bc07bc23938c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/benchmark.native.js @@ -0,0 +1,63 @@ +/** +* @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 uniform = require('@stdlib/random/array/uniform'); +var isnanf = require('@stdlib/math/base/assert/is-nanf'); +var tryRequire = require('@stdlib/utils/try-require'); +var pkg = require('./../package.json').name; + + +// VARIABLES // + +var log10f = tryRequire(resolve(__dirname, './../lib/native.js')); +var opts = { + 'skip': (log10f instanceof Error) +}; + + +// MAIN // + +bench(pkg + '::native', opts, function benchmark(b) { + var x; + var y; + var i; + + x = uniform(100, 0.0, 1000.0, { + 'dtype': 'float32' + }); + + b.tic(); + for (i = 0; i < b.iterations; i++) { + y = log10f(x[i % x.length]); + if (isnanf(y)) { + b.fail('should not return NaN'); + } + } + b.toc(); + if (isnanf(y)) { + b.fail('should not return NaN'); + } + b.pass('benchmark finished'); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/Makefile new file mode 100644 index 000000000000..3a30b1c3ebfc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/Makefile @@ -0,0 +1,151 @@ +#/ +# @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 ?= \ + -I ./../../include \ + -I ./../../../../../../../../include + +# List of source files: +SOURCE_FILES ?= \ + ./../../src/main.c \ + ./../../../../../../../../lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/main.c + +# 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 := 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 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 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/log10f/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/benchmark.c new file mode 100644 index 000000000000..8736ce658a2d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/benchmark/c/benchmark.c @@ -0,0 +1,136 @@ +/** +* @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/log10f.h" +#include +#include +#include +#include +#include + +#define NAME "log10f" +#define ITERATIONS 1000000 +#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 number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float x[ 100 ]; + float y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0f*rand_float() ) - 0.0f; + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_log10f( x[ i%100 ] ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%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/log10f/binding.gyp b/lib/node_modules/@stdlib/math/base/special/log10f/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/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/log10f/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/log10f/docs/repl.txt new file mode 100644 index 000000000000..d9da7cf5bfcd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/docs/repl.txt @@ -0,0 +1,34 @@ + +{{alias}}( x ) + Evaluates the common logarithm (base 10) of a single-precision floating-point number. + + For negative numbers, the common logarithm is not defined. + + Parameters + ---------- + x: number + Input value. + + Returns + ------- + y: number + Function value. + + Examples + -------- + > var y = {{alias}}( 100.0 ) + 2.0 + > y = {{alias}}( 10.0 ) + 1.0 + > y = {{alias}}( 0.0 ) + -Infinity + > y = {{alias}}( {{alias:@stdlib/constants/float32/pinf}} ) + Infinity + > y = {{alias}}( NaN ) + NaN + > y = {{alias}}( -4.0 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/log10f/docs/types/index.d.ts new file mode 100644 index 000000000000..d1568eee79f1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/docs/types/index.d.ts @@ -0,0 +1,56 @@ +/* +* @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 + +/** +* Evaluates the common logarithm (base ten) of a single-precision floating-point number. +* +* ## Notes +* +* - For negative numbers, the common logarithm is not defined. +* +* @param x - input value +* @returns function value +* +* @example +* var v = log10f( 100.0 ); +* // returns 2.0 +* +* @example +* var v = log10f( 10.0 ); +* // returns 1.0 +* +* @example +* var v = log10f( 0.0 ); +* // returns -Infinity +* +* @example +* var v = log10f( NaN ); +* // returns NaN +* +* @example +* var v = log10f( -4.0 ); +* // returns NaN +*/ +declare function log10f(x: number): number; + + +// EXPORTS // + +export = log10f; diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/log10f/docs/types/test.ts new file mode 100644 index 000000000000..42d33c5fc7f1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @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 log10f = require('./index'); + + +// TESTS // + +// The function returns a number... +{ + log10f(8); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + log10f(true); // $ExpectError + log10f(false); // $ExpectError + log10f(null); // $ExpectError + log10f(undefined); // $ExpectError + log10f('5'); // $ExpectError + log10f([]); // $ExpectError + log10f({}); // $ExpectError + log10f((x: number): number => x); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + log10f(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/log10f/examples/c/Makefile new file mode 100644 index 000000000000..26ef116ac173 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/examples/c/Makefile @@ -0,0 +1,150 @@ +#/ +# @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 ?= \ + -I ./../../include \ + -I ./../../../../../../../../include + +# List of source files: +SOURCE_FILES ?= \ + ./../../src/main.c \ + ./../../../../../../../../lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/main.c + +# 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/log10f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/log10f/examples/c/example.c new file mode 100644 index 000000000000..0b331cf71a86 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/examples/c/example.c @@ -0,0 +1,33 @@ +/** +* @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/log10f.h" +#include +#include + +int main() { + float x; + float v; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( (float)rand() / (float)RAND_MAX ) * 100.0f; + v = stdlib_base_log10f( x ); + printf( "log10f(%f) = %f\n", x, v ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/log10f/examples/index.js new file mode 100644 index 000000000000..6e8cb9ae9019 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 uniform = require('@stdlib/random/array/uniform'); +var log10f = require('./../lib'); + +var x = uniform(100, 0.0, 100.0, { + 'dtype': 'float32' +}); + +var v; +var i; +for (i = 0; i < x.length; i++) { + v = log10f(x[i]); + console.log('log10f(%d) = %d', x[i], v); +} diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/include.gypi b/lib/node_modules/@stdlib/math/base/special/log10f/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/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': [ + ' bias 127 +var FLT_BIAS_EXP = 0x3f800000; + + +// MAIN // + +/** +* Evaluates the common logarithm (base ten) of a single-precision floating-point number. +* +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var v = log10f( 100.0 ); +* // returns 2.0 +*/ +function log10f(x) { + var hfsq; + var hi; + var lo; + var r; + var f; + var y; + var hx; + var i; + var k; + + if (x === 0.0) { + return NINF; + } + if (isnanf(x) || x < 0.0) { + return NaN; + } + hx = toWord(x); + k = 0; + if (hx < FLT_MIN_NORMAL_EXP) { + // x < 2**-126 + if ((hx & 0x7fffffff) === 0) { + return NINF; // log(+-0) = -inf + } + k -= 25; + x *= TWO25; // subnormal number, scale up x + hx = toWord(x); + } + if (hx >= FLT_MAX_EXP_BIT_MASK) { + return x + x; + } + if (hx === FLT_BIAS_EXP) { + return 0.0; // log(1) = +0 + } + k += (hx >>> 23) - 127; + hx &= 0x007fffff; + i = (hx + 0x95f64) & 0x800000; + // Normalize x or x/2... + x = fromWord(hx | (i ^ FLT_BIAS_EXP)); + k += (i >>> 23); + y = k; + f = x - 1.0; + hfsq = 0.5 * f * f; + r = kernelLog1pf(f); + + hi = f - hfsq; + hx = toWord(hi); + hi = fromWord(hx & 0xfffff000); + lo = (f - hi) - hfsq + r; + return (y * LOG10_2LO) + ((lo + hi) * IVLN10) + (y * LOG10_2HI); +} + + +// EXPORTS // + +module.exports = log10f; diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/log10f/lib/native.js new file mode 100644 index 000000000000..3f37ae61e750 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/lib/native.js @@ -0,0 +1,62 @@ +/** +* @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 // + +/** +* Evaluates the common logarithm (base ten) of a single-precision floating-point number. +* +* @private +* @param {number} x - input value +* @returns {number} function value +* +* @example +* var v = log10f( 100.0 ); +* // returns 2.0 +* +* @example +* var v = log10f( 10.0 ); +* // returns 1.0 +* +* @example +* var v = log10f( 0.0 ); +* // returns -Infinity +* +* @example +* var v = log10f( NaN ); +* // returns NaN +* +* @example +* var v = log10f( -4.0 ); +* // returns NaN +*/ +function log10f(x) { + return addon(x); +} + + +// EXPORTS // + +module.exports = log10f; diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/manifest.json b/lib/node_modules/@stdlib/math/base/special/log10f/manifest.json new file mode 100644 index 000000000000..73ec1bcea7c0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/manifest.json @@ -0,0 +1,87 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/constants/float32/ninf", + "@stdlib/constants/float32/pinf", + "@stdlib/number/float32/base/to-word", + "@stdlib/number/float32/base/from-word", + "@stdlib/math/base/special/kernel-log1pf", + "@stdlib/math/base/assert/is-nanf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/ninf", + "@stdlib/constants/float32/pinf", + "@stdlib/number/float32/base/to-word", + "@stdlib/number/float32/base/from-word", + "@stdlib/math/base/special/kernel-log1pf", + "@stdlib/math/base/assert/is-nanf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float32/ninf", + "@stdlib/constants/float32/pinf", + "@stdlib/number/float32/base/to-word", + "@stdlib/number/float32/base/from-word", + "@stdlib/math/base/special/kernel-log1pf", + "@stdlib/math/base/assert/is-nanf" + ] + } + ] +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/package.json b/lib/node_modules/@stdlib/math/base/special/log10f/package.json new file mode 100644 index 000000000000..af25158727a3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/package.json @@ -0,0 +1,76 @@ +{ + "name": "@stdlib/math/base/special/log10f", + "version": "0.0.0", + "description": "Evaluate the common logarithm (base 10) of a single-precision floating-point number.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "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": { + "@stdlib/math/base/assert/is-nanf": "^0.0.x", + "@stdlib/utils/library-manifest": "^0.0.x" + }, + "devDependencies": { + "@stdlib/math/base/assert/is-infinitef": "^0.0.x", + "tape": "git+https://github.com/kgryte/tape.git#fix/globby", + "istanbul": "^0.4.1", + "tap-min": "git+https://github.com/kgryte/tap-min.git#master" + }, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "math.log10f", + "log10f", + "common", + "base 10", + "logarithm", + "log", + "float", + "single" + ] +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/src/Makefile b/lib/node_modules/@stdlib/math/base/special/log10f/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/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/log10f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/log10f/src/addon.c new file mode 100644 index 000000000000..5a8426c065d5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/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/log10f.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_log10f ) diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/src/main.c b/lib/node_modules/@stdlib/math/base/special/log10f/src/main.c new file mode 100644 index 000000000000..e4cfa4e55057 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/src/main.c @@ -0,0 +1,95 @@ +/** +* @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/log10f.h" +#include "stdlib/number/float32/base/to_word.h" +#include "stdlib/number/float32/base/from_word.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/special/kernel_log1pf.h" +#include "stdlib/constants/float32/pinf.h" +#include "stdlib/constants/float32/ninf.h" +#include + +static const float TWO25 = 3.3554432000e+07f; // 0x4c000000 +static const float IVLN10 = 4.3429449201e-01f; // 0x3ede5bd9 +static const float LOG10_2HI = 3.0102999566e-01f; // 0x3e9a209a +static const float LOG10_2LO = 3.6942390772e-13f; // 0x2d022b36 + +// 0x7f800000 = 2139095040 +static const int32_t FLT_MAX_EXP_BIT_MASK = 0x7f800000; + +// 0x00800000 = 8388608 +static const int32_t FLT_MIN_NORMAL_EXP = 0x00800000; + +// 0x3f800000 = 1065353216 => bias 127 +static const int32_t FLT_BIAS_EXP = 0x3f800000; + +/** +* Evaluates the common logarithm (base ten) of a single-precision floating-point number. +* +* @param x input value +* @return output value +*/ +float stdlib_base_log10f( const float x ) { + float hfsq; + float hi; + float lo; + float r; + float f; + float y; + int32_t hx; + int32_t i; + int32_t k; + + if ( stdlib_base_is_nanf( x ) || x < 0.0f ) { + return 0.0f / 0.0f; // NaN + } + stdlib_base_float32_to_word( x, (uint32_t *)&hx ); + k = 0; + if ( hx < FLT_MIN_NORMAL_EXP ) { + // x < 2**-126 + if ( ( hx & 0x7fffffff ) == 0 ) { + return STDLIB_CONSTANT_FLOAT32_NINF; // log(+-0) = -inf + } + k -= 25; + x *= TWO25; // subnormal number, scale up x + stdlib_base_float32_to_word( x, (uint32_t *)&hx ); + } + if ( hx >= FLT_MAX_EXP_BIT_MASK ) { + return x + x; + } + if ( hx == FLT_BIAS_EXP ) { + return 0.0f; // log(1) = +0 + } + k += ( hx >> 23 ) - 127; + hx &= 0x007fffff; + i = ( hx + 0x95f64 ) & 0x800000; + // Normalize x or x/2... + stdlib_base_float32_from_word( (uint32_t)( hx | ( i ^ FLT_BIAS_EXP ) ), &x ); + k += ( i >> 23 ); + y = (float)k; + f = x - 1.0f; + hfsq = 0.5f * f * f; + r = stdlib_base_kernel_log1pf( f ); + + hi = f - hfsq; + stdlib_base_float32_to_word( hi, (uint32_t *)&hx ); + stdlib_base_float32_from_word( (uint32_t)( hx & 0xfffff000 ), &hi ); + lo = ( f - hi ) - hfsq + r; + return ( y * LOG10_2LO ) + ( ( lo + hi ) * IVLN10 ) + ( y * LOG10_2HI ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/test/test.js b/lib/node_modules/@stdlib/math/base/special/log10f/test/test.js new file mode 100644 index 000000000000..d37149f0f4b1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/test/test.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 tape = require('tape'); +var isnanf = require('@stdlib/math/base/assert/is-nanf'); +var isInfinitef = require('@stdlib/math/base/assert/is-infinitef'); +var PINF = require('@stdlib/constants/float32/pinf'); +var NINF = require('@stdlib/constants/float32/ninf'); +var EPS = require('@stdlib/constants/float32/eps'); +var absf = require('@stdlib/math/base/special/absf'); +var float64ToFloat32 = require('@stdlib/number/float64/base/to-float32'); +var log10f = require('./../lib'); + + +// TESTS // + +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof log10f, 'function', 'main export is a function'); + t.end(); +}); + +tape('the function returns `NaN` if provided `NaN` or a negative number', function test(t) { + var v; + + v = log10f(NaN); + t.strictEqual(isnanf(v), true, 'returns NaN'); + + v = log10f(-1.0); + t.strictEqual(isnanf(v), true, 'returns NaN'); + + v = log10f(-Infinity); + t.strictEqual(isnanf(v), true, 'returns NaN'); + + t.end(); +}); + +tape('the function returns `-infinity` if provided `+0` or `-0`', function test(t) { + var v; + + v = log10f(0.0); + t.strictEqual(v, NINF, 'returns -Infinity'); + + v = log10f(-0.0); + t.strictEqual(v, NINF, 'returns -Infinity'); + + t.end(); +}); + +tape('the function returns `+infinity` if provided `+infinity`', function test(t) { + var v = log10f(PINF); + t.strictEqual(v, PINF, 'returns +Infinity'); + t.end(); +}); + +tape('the function returns `0` if provided `1.0`', function test(t) { + var v = log10f(1.0); + t.strictEqual(v, 0.0, 'returns 0'); + t.end(); +}); + +tape('the function evaluates the common logarithm (powers of 10)', function test(t) { + var v; + var tol = EPS; + + v = log10f(10.0); + t.ok(absf(v - 1.0) <= tol, 'returns 1'); + + v = log10f(100.0); + t.ok(absf(v - 2.0) <= tol, 'returns 2'); + + v = log10f(0.1); + t.ok(absf(v - -1.0) <= tol, 'returns -1'); + + t.end(); +}); + +tape('the function matches Math.log10 results within tolerance', function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + for (i = 0; i < 100; i++) { + x = (Math.random() * 100.0) + 0.1; + x = float64ToFloat32(x); + y = log10f(x); + expected = float64ToFloat32(Math.log10(x)); + delta = absf(y - expected); + tol = 2.0 * EPS * absf(expected); + if (tol < EPS) { + tol = EPS; + } + t.ok(delta <= tol, 'within tolerance. x: ' + x + '. y: ' + y + '. expected: ' + expected + '. delta: ' + delta + '. tol: ' + tol); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/log10f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log10f/test/test.native.js new file mode 100644 index 000000000000..77692d51b6ce --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log10f/test/test.native.js @@ -0,0 +1,125 @@ +/** +* @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 isnanf = require('@stdlib/math/base/assert/is-nanf'); +var isInfinitef = require('@stdlib/math/base/assert/is-infinitef'); +var PINF = require('@stdlib/constants/float32/pinf'); +var NINF = require('@stdlib/constants/float32/ninf'); +var EPS = require('@stdlib/constants/float32/eps'); +var absf = require('@stdlib/math/base/special/absf'); +var float64ToFloat32 = require('@stdlib/number/float64/base/to-float32'); +var tryRequire = require('@stdlib/utils/try-require'); + + +// VARIABLES // + +var log10f = tryRequire('./../lib/native.js'); +var opts = { + 'skip': (log10f instanceof Error) +}; + + +// TESTS // + +tape('main export is a function', opts, function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof log10f, 'function', 'main export is a function'); + t.end(); +}); + +tape('the function returns `NaN` if provided `NaN` or a negative number', opts, function test(t) { + var v; + + v = log10f(NaN); + t.strictEqual(isnanf(v), true, 'returns NaN'); + + v = log10f(-1.0); + t.strictEqual(isnanf(v), true, 'returns NaN'); + + v = log10f(-Infinity); + t.strictEqual(isnanf(v), true, 'returns NaN'); + + t.end(); +}); + +tape('the function returns `-infinity` if provided `+0` or `-0`', opts, function test(t) { + var v; + + v = log10f(0.0); + t.strictEqual(v, NINF, 'returns -Infinity'); + + v = log10f(-0.0); + t.strictEqual(v, NINF, 'returns -Infinity'); + + t.end(); +}); + +tape('the function returns `+infinity` if provided `+infinity`', opts, function test(t) { + var v = log10f(PINF); + t.strictEqual(v, PINF, 'returns +Infinity'); + t.end(); +}); + +tape('the function returns `0` if provided `1.0`', opts, function test(t) { + var v = log10f(1.0); + t.strictEqual(v, 0.0, 'returns 0'); + t.end(); +}); + +tape('the function evaluates the common logarithm (powers of 10)', opts, function test(t) { + var v; + + v = log10f(10.0); + t.strictEqual(v, 1.0, 'returns 1'); + + v = log10f(100.0); + t.strictEqual(v, 2.0, 'returns 2'); + + v = log10f(0.1); + t.strictEqual(v, -1.0, 'returns -1'); + + t.end(); +}); + +tape('the function matches Math.log10 results within tolerance', opts, function test(t) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + + for (i = 0; i < 100; i++) { + x = (Math.random() * 100.0) + 0.1; + x = float64ToFloat32(x); + y = log10f(x); + expected = float64ToFloat32(Math.log10(x)); + delta = absf(y - expected); + tol = 2.0 * EPS * absf(expected); + if (tol < EPS) { + tol = EPS; + } + t.ok(delta <= tol, 'within tolerance. x: ' + x + '. y: ' + y + '. expected: ' + expected + '. delta: ' + delta + '. tol: ' + tol); + } + t.end(); +}); From c927f06133f5e8f1049c0adccc2f5f567c116b97 Mon Sep 17 00:00:00 2001 From: marq Date: Sun, 15 Feb 2026 11:30:21 +0530 Subject: [PATCH 2/2] fix lint errors test.dsyr2.js --- .../blas/base/dsyr2/test/test.dsyr2.js | 385 +++++++++--------- 1 file changed, 192 insertions(+), 193 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.js b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.js index 23ab41fce88b..f06527e31d69 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr2/test/test.dsyr2.js @@ -22,44 +22,43 @@ // MODULES // -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array/float64' ); -var dsyr2 = require( './../lib/dsyr2.js' ); - +var tape = require('tape'); +var Float64Array = require('@stdlib/array/float64'); +var dsyr2 = require('./../lib/dsyr2.js'); // FIXTURES // -var ru = require( './fixtures/row_major_u.json' ); -var rl = require( './fixtures/row_major_l.json' ); -var rx0 = require( './fixtures/row_major_x0.json' ); -var rxpyp = require( './fixtures/row_major_xpyp.json' ); -var rxnyp = require( './fixtures/row_major_xnyp.json' ); -var rxpyn = require( './fixtures/row_major_xpyn.json' ); -var rxnyn = require( './fixtures/row_major_xnyn.json' ); +var ru = require('./fixtures/row_major_u.json'); +var rl = require('./fixtures/row_major_l.json'); +var rx0 = require('./fixtures/row_major_x0.json'); +var rxpyp = require('./fixtures/row_major_xpyp.json'); +var rxnyp = require('./fixtures/row_major_xnyp.json'); +var rxpyn = require('./fixtures/row_major_xpyn.json'); +var rxnyn = require('./fixtures/row_major_xnyn.json'); -var cu = require( './fixtures/column_major_u.json' ); -var cl = require( './fixtures/column_major_l.json' ); -var cx0 = require( './fixtures/column_major_x0.json' ); -var cxpyp = require( './fixtures/column_major_xpyp.json' ); -var cxnyp = require( './fixtures/column_major_xnyp.json' ); -var cxpyn = require( './fixtures/column_major_xpyn.json' ); -var cxnyn = require( './fixtures/column_major_xnyn.json' ); +var cu = require('./fixtures/column_major_u.json'); +var cl = require('./fixtures/column_major_l.json'); +var cx0 = require('./fixtures/column_major_x0.json'); +var cxpyp = require('./fixtures/column_major_xpyp.json'); +var cxnyp = require('./fixtures/column_major_xnyp.json'); +var cxpyn = require('./fixtures/column_major_xpyn.json'); +var cxnyn = require('./fixtures/column_major_xnyn.json'); // TESTS // -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dsyr2, 'function', 'main export is a function' ); +tape('main export is a function', function test(t) { + t.ok(true, __filename); + t.strictEqual(typeof dsyr2, 'function', 'main export is a function'); t.end(); }); -tape( 'the function has an arity of 10', function test( t ) { - t.strictEqual( dsyr2.length, 10, 'returns expected value' ); +tape('the function has an arity of 10', function test(t) { + t.strictEqual(dsyr2.length, 10, 'returns expected value'); t.end(); }); -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { +tape('the function throws an error if provided an invalid first argument', function test(t) { var values; var data; var i; @@ -73,19 +72,19 @@ tape( 'the function throws an error if provided an invalid first argument', func 'boop' ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + for (i = 0; i < values.length; i++) { + t.throws(badValue(values[i]), TypeError, 'throws an error when provided ' + values[i]); } t.end(); - function badValue( value ) { + function badValue(value) { return function badValue() { - dsyr2( value, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + dsyr2(value, data.uplo, data.N, data.alpha, new Float64Array(data.x), data.strideX, new Float64Array(data.y), data.strideY, new Float64Array(data.A), data.lda); }; } }); -tape( 'the function throws an error if provided an invalid second argument', function test( t ) { +tape('the function throws an error if provided an invalid second argument', function test(t) { var values; var data; var i; @@ -99,19 +98,19 @@ tape( 'the function throws an error if provided an invalid second argument', fun 'boop' ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + for (i = 0; i < values.length; i++) { + t.throws(badValue(values[i]), TypeError, 'throws an error when provided ' + values[i]); } t.end(); - function badValue( value ) { + function badValue(value) { return function badValue() { - dsyr2( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + dsyr2(data.order, value, data.N, data.alpha, new Float64Array(data.x), data.strideX, new Float64Array(data.y), data.strideY, new Float64Array(data.A), data.lda); }; } }); -tape( 'the function throws an error if provided an invalid third argument', function test( t ) { +tape('the function throws an error if provided an invalid third argument', function test(t) { var values; var data; var i; @@ -124,19 +123,19 @@ tape( 'the function throws an error if provided an invalid third argument', func -3 ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + for (i = 0; i < values.length; i++) { + t.throws(badValue(values[i]), RangeError, 'throws an error when provided ' + values[i]); } t.end(); - function badValue( value ) { + function badValue(value) { return function badValue() { - dsyr2( data.order, data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + dsyr2(data.order, data.uplo, value, data.alpha, new Float64Array(data.x), data.strideX, new Float64Array(data.y), data.strideY, new Float64Array(data.A), data.lda); }; } }); -tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { +tape('the function throws an error if provided an invalid sixth argument', function test(t) { var values; var data; var i; @@ -147,19 +146,19 @@ tape( 'the function throws an error if provided an invalid sixth argument', func 0 ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + for (i = 0; i < values.length; i++) { + t.throws(badValue(values[i]), RangeError, 'throws an error when provided ' + values[i]); } t.end(); - function badValue( value ) { + function badValue(value) { return function badValue() { - dsyr2( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), data.lda ); + dsyr2(data.order, data.uplo, data.N, data.alpha, new Float64Array(data.x), value, new Float64Array(data.y), data.strideY, new Float64Array(data.A), data.lda); }; } }); -tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { +tape('the function throws an error if provided an invalid eighth argument', function test(t) { var values; var data; var i; @@ -170,19 +169,19 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun 0 ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + for (i = 0; i < values.length; i++) { + t.throws(badValue(values[i]), RangeError, 'throws an error when provided ' + values[i]); } t.end(); - function badValue( value ) { + function badValue(value) { return function badValue() { - dsyr2( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), value, new Float64Array( data.A ), data.lda ); + dsyr2(data.order, data.uplo, data.N, data.alpha, new Float64Array(data.x), data.strideX, new Float64Array(data.y), value, new Float64Array(data.A), data.lda); }; } }); -tape( 'the function throws an error if provided an invalid tenth argument', function test( t ) { +tape('the function throws an error if provided an invalid tenth argument', function test(t) { var values; var data; var i; @@ -198,19 +197,19 @@ tape( 'the function throws an error if provided an invalid tenth argument', func -3 ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + for (i = 0; i < values.length; i++) { + t.throws(badValue(values[i]), RangeError, 'throws an error when provided ' + values[i]); } t.end(); - function badValue( value ) { + function badValue(value) { return function badValue() { - dsyr2( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.y ), data.strideY, new Float64Array( data.A ), value ); + dsyr2(data.order, data.uplo, data.N, data.alpha, new Float64Array(data.x), data.strideX, new Float64Array(data.y), data.strideY, new Float64Array(data.A), value); }; } }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) { +tape('the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test(t) { var expected; var data; var out; @@ -220,20 +219,20 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y data = ru; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', function test( t ) { +tape('the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', function test(t) { var expected; var data; var out; @@ -243,20 +242,20 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y data = cu; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', function test( t ) { +tape('the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', function test(t) { var expected; var data; var out; @@ -266,20 +265,20 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y data = rl; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', function test( t ) { +tape('the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', function test(t) { var expected; var data; var out; @@ -289,20 +288,20 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y data = cl; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, zero-vector)', function test( t ) { +tape('the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, zero-vector)', function test(t) { var expected; var data; var out; @@ -312,20 +311,20 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y data = rx0; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', function test( t ) { +tape('the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, zero-vector)', function test(t) { var expected; var data; var out; @@ -335,20 +334,20 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y data = cx0; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function returns a reference to the input matrix `A`', function test( t ) { +tape('the function returns a reference to the input matrix `A`', function test(t) { var data; var out; var a; @@ -357,17 +356,17 @@ tape( 'the function returns a reference to the input matrix `A`', function test( data = ru; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); t.end(); }); -tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', function test( t ) { +tape('if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', function test(t) { var expected; var data; var out; @@ -377,24 +376,24 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i data = rl; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A ); + expected = new Float64Array(data.A); - out = dsyr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( a, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(a, expected, 'returns expected value'); - out = dsyr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( a, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(a, expected, 'returns expected value'); t.end(); }); -tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', function test( t ) { +tape('if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', function test(t) { var expected; var data; var out; @@ -404,24 +403,24 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i data = cl; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A ); + expected = new Float64Array(data.A); - out = dsyr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( a, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(a, expected, 'returns expected value'); - out = dsyr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( a, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(a, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports specifying strides (row-major)', function test( t ) { +tape('the function supports specifying strides (row-major)', function test(t) { var expected; var data; var out; @@ -431,20 +430,20 @@ tape( 'the function supports specifying strides (row-major)', function test( t ) data = rxpyp; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports specifying strides (column-major)', function test( t ) { +tape('the function supports specifying strides (column-major)', function test(t) { var expected; var data; var out; @@ -454,20 +453,20 @@ tape( 'the function supports specifying strides (column-major)', function test( data = cxpyp; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { +tape('the function supports specifying a negative `x` stride (row-major)', function test(t) { var expected; var data; var out; @@ -477,20 +476,20 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func data = rxnyp; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { +tape('the function supports specifying a negative `x` stride (column-major)', function test(t) { var expected; var data; var out; @@ -500,20 +499,20 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f data = cxnyp; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { +tape('the function supports specifying a negative `y` stride (row-major)', function test(t) { var expected; var data; var out; @@ -523,20 +522,20 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', func data = rxpyn; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports specifying a negative `y` stride (column-major)', function test( t ) { +tape('the function supports specifying a negative `y` stride (column-major)', function test(t) { var expected; var data; var out; @@ -546,20 +545,20 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', f data = cxpyn; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports complex access patterns (row-major)', function test( t ) { +tape('the function supports complex access patterns (row-major)', function test(t) { var expected; var data; var out; @@ -569,20 +568,20 @@ tape( 'the function supports complex access patterns (row-major)', function test data = rxnyn; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); }); -tape( 'the function supports complex access patterns (column-major)', function test( t ) { +tape('the function supports complex access patterns (column-major)', function test(t) { var expected; var data; var out; @@ -592,15 +591,15 @@ tape( 'the function supports complex access patterns (column-major)', function t data = cxnyn; - a = new Float64Array( data.A ); - x = new Float64Array( data.x ); - y = new Float64Array( data.y ); + a = new Float64Array(data.A); + x = new Float64Array(data.x); + y = new Float64Array(data.y); - expected = new Float64Array( data.A_out ); + expected = new Float64Array(data.A_out); - out = dsyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); - t.strictEqual( out, a, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + out = dsyr2(data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda); + t.strictEqual(out, a, 'returns expected value'); + t.deepEqual(out, expected, 'returns expected value'); t.end(); });