From a8ae3731c47d884be4d21ee4461bdee3950bb4c4 Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Fri, 7 Aug 2026 14:52:31 +0530 Subject: [PATCH 1/2] test: add test.native.js to math/base/special/log1pmx --- .../base/special/log1pmx/test/test.native.js | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js new file mode 100644 index 000000000000..a0625acbf7e7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js @@ -0,0 +1,95 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var linspace = require( '@stdlib/array/linspace' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var log1p = require( '@stdlib/math/base/special/log1p' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var log1pmx = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( log1pmx instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof log1pmx, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if input is less than or equal to -1', opts, function test( t ) { + var values = linspace( -1.0, -50.0, 100 ); + var i; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isnan( log1pmx( values[ i ] ) ), true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function computes ln(1+x) - x if |x| > 0.95', opts, function test( t ) { + var values = linspace( 0.951, 100.0, 100 ); + var i; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( log1pmx( values[i] ), ln( 1.0 + values[i] ) - values[i], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns -x*x/2 if |x| < FLOAT_EPS', opts, function test( t ) { + var values = [ 0.0, EPS / 2.0 ]; + var i; + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( log1pmx( values[i] ), -pow( values[i], 2 ) / 2.0, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns a Taylor series expansion otherwise', opts, function test( t ) { + var expected; + var values; + var actual; + var i; + + values = linspace( 0.1, 0.95, 100 ); + for ( i = 0; i < values.length; i++ ) { + actual = log1pmx( values[ i ] ); + expected = log1p( values[ i ] ) - values[ i ]; + if ( actual === expected ) { + t.strictEqual( actual, expected, 'returns '+expected+' when provided '+values[ i ] ); + } else { + t.strictEqual( isAlmostSameValue( actual, expected, 9 ), true, 'returns expected value' ); + } + } + t.end(); +}); From c75cef820bfee7067f1e264529652ce2d396ec27 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 7 Aug 2026 10:16:51 +0000 Subject: [PATCH 2/2] chore: update copyright years --- .../@stdlib/math/base/special/log1pmx/test/test.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js index a0625acbf7e7..6778b1ca9c3e 100644 --- a/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/log1pmx/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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.