From e5ddcf58d1768162633d7911399186e9258a9f72 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 11 Mar 2025 12:33:12 -0700 Subject: [PATCH 1/6] feat: temp commit --- .../math/base/special/rempio2f/LICENSE | 192 ++++++ .../math/base/special/rempio2f/README.md | 228 +++++++ .../special/rempio2f/benchmark/benchmark.js | 54 ++ .../rempio2f/benchmark/benchmark.native.js | 63 ++ .../rempio2f/benchmark/c/native/Makefile | 146 ++++ .../rempio2f/benchmark/c/native/benchmark.c | 138 ++++ .../math/base/special/rempio2f/binding.gyp | 170 +++++ .../math/base/special/rempio2f/docs/repl.txt | 37 ++ .../special/rempio2f/docs/types/index.d.ts | 64 ++ .../base/special/rempio2f/docs/types/test.ts | 56 ++ .../base/special/rempio2f/examples/c/Makefile | 146 ++++ .../special/rempio2f/examples/c/example.c | 35 + .../base/special/rempio2f/examples/index.js | 32 + .../math/base/special/rempio2f/include.gypi | 53 ++ .../stdlib/math/base/special/rempio2.h | 40 ++ .../math/base/special/rempio2f/lib/index.js | 47 ++ .../special/rempio2f/lib/kernel_rempio2.js | 428 ++++++++++++ .../math/base/special/rempio2f/lib/main.js | 144 ++++ .../math/base/special/rempio2f/lib/native.js | 56 ++ .../special/rempio2f/lib/rempio2_medium.js | 126 ++++ .../math/base/special/rempio2f/manifest.json | 100 +++ .../math/base/special/rempio2f/package.json | 65 ++ .../math/base/special/rempio2f/src/Makefile | 70 ++ .../math/base/special/rempio2f/src/addon.c | 42 ++ .../math/base/special/rempio2f/src/main.c | 626 ++++++++++++++++++ .../math/base/special/rempio2f/test/test.js | 266 ++++++++ .../base/special/rempio2f/test/test.native.js | 282 ++++++++ 27 files changed, 3706 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/LICENSE create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2.h create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/LICENSE b/lib/node_modules/@stdlib/math/base/special/rempio2f/LICENSE new file mode 100644 index 000000000000..a7566ad6f2c3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/LICENSE @@ -0,0 +1,192 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +DEPENDENCIES & ATTRIBUTION + +The library links against the following external libraries or contains +implementations from the following external libraries, which have their own +licenses: + +* FreeBSD + +Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md b/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md new file mode 100644 index 000000000000..978033ba6f65 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md @@ -0,0 +1,228 @@ + + +# rempio2 + +> Compute `x - nπ/2 = r`. + +
+ +## Usage + +```javascript +var rempio2 = require( '@stdlib/math/base/special/rempio2' ); +``` + +#### rempio2( x, y ) + +Computes `x - nπ/2 = r`. + +```javascript +var y = [ 0.0, 0.0 ]; +var n = rempio2( 128.0, y ); +// returns 81 + +var y1 = y[ 0 ]; +// returns ~0.765 + +var y2 = y[ 1 ]; +// returns ~3.618e-17 +``` + +When `x` is `NaN` or infinite, the function returns `0` and sets the elements of `y` to `NaN`. + +```javascript +var y = [ 0.0, 0.0 ]; +var n = rempio2( NaN, y ); +// returns 0 + +var y1 = y[ 0 ]; +// returns NaN + +var y2 = y[ 1 ]; +// returns NaN + +y = [ 0.0, 0.0 ]; +n = rempio2( Infinity, y ); +// returns 0 + +y1 = y[ 0 ]; +// returns NaN + +y2 = y[ 1 ]; +// returns NaN +``` + +
+ + + + + +
+ +## Notes + +- The function returns `n` and stores the remainder `r` as two numbers in `y`, such that `y[0]+y[1] = r`. +- For input values larger than `2^20*π/2` in magnitude, the function **only** returns the last three binary digits of `n` and not the full result. + +
+ + + +
+ +## Examples + + + +```javascript +var linspace = require( '@stdlib/array/base/linspace' ); +var rempio2 = require( '@stdlib/math/base/special/rempio2' ); + +var x = linspace( 0.0, 100.0, 100 ); +var y = [ 0.0, 0.0 ]; +var n; +var i; + +for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[ i ], y ); + console.log( '%d - %dπ/2 = %d + %d', x[ i ], n, y[ 0 ], y[ 1 ] ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/rempio2.h" +``` + +#### stdlib_base_rempio2( x, &rem1, &rem2 ) + +Computes `x - nπ/2 = r`. + +```c +#include + +double rem1; +double rem2; + +int32_t n = stdlib_base_rempio2( 4.0, &rem1, &rem2 ); +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **rem1**: `[out] double*` destination for first remainder number. +- **rem2**: `[out] double*` destination for second remainder number. + +```c +int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ); +``` + +
+ + + + + +
+ +### Notes + +- The function returns `n` and stores the remainder `r` as two numbers in `rem1` and `rem2`, respectively, such that `rem1+rem2 = r`. + +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/rempio2.h" +#include +#include +#include + +int main( void ) { + const double x[] = { 0.0, 1.0, 4.0, 128.0 }; + + double rem1; + double rem2; + int32_t n; + int i; + for ( i = 0; i < 4; i++ ) { + n = stdlib_base_rempio2( x[ i ], &rem1, &rem2 ); + printf( "%lf - %"PRId32"π/2 = %lf + %lf\n", x[ i ], n, rem1, rem2 ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js new file mode 100644 index 000000000000..c654c7d2a26c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var rempio2 = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var n; + var i; + + y = [ 0.0, 0.0 ]; + x = randu( 100, -100.0, 100.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + n = rempio2( x[ i % x.length ], y ); + if ( isnan( n ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( n ) || isnan( y[0] ) || isnan( y[1] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js new file mode 100644 index 000000000000..d231943ea28c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/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 randu = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var rempio2 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( rempio2 instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var n; + var i; + + y = [ 0.0, 0.0 ]; + x = randu( 100, -100.0, 100.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + n = rempio2( x[ i % x.length ], y ); + if ( isnan( n ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( n ) || isnan( y[0] ) || isnan( y[1] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/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 := 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/rempio2f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..293062cc950f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c @@ -0,0 +1,138 @@ +/** +* @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/rempio2.h" +#include +#include +#include +#include +#include + +#define NAME "rempio2" +#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 double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double x[ 100 ]; + double elapsed; + double rem1; + double rem2; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( rand_double() * 200.0 ) - 100.0; + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_rempio2( x[ i % 100 ], &rem1, &rem2 ); + 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::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/rempio2f/binding.gyp b/lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/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/rempio2f/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt new file mode 100644 index 000000000000..30267fa19272 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt @@ -0,0 +1,37 @@ + +{{alias}}( x, y ) + Computes `x - nπ/2 = r`. + + The function returns `n` and stores the remainder `r` as the two numbers + `y[0]` and `y[1]`, such that `y[0] + y[1] = r`. + + For input values larger than `2^20 * π/2` in magnitude, the function only + returns the last three binary digits of `n` and not the full result. + + Parameters + ---------- + x: number + Input value. + + y: Array|TypedArray|Object + Remainder elements. + + Returns + ------- + n: integer + Factor of `π/2`. + + Examples + -------- + > var y = [ 0.0, 0.0 ]; + > var n = {{alias}}( 128.0, y ) + 81 + > var y1 = y[ 0 ] + ~0.765 + > var y2 = y[ 1 ] + ~3.618e-17 + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts new file mode 100644 index 000000000000..b99a2f922ea9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts @@ -0,0 +1,64 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 + +/// + +import { Collection } from '@stdlib/types/array'; + +/** +* Computes `x - nπ/2 = r`. +* +* ## Notes +* +* - The function returns `n` and stores the remainder `r` as the two numbers `y[0]` and `y[1]`, such that `y[0] + y[1] = r`. +* - For input values larger than `2^20 * π/2` in magnitude, the function only returns the last three binary digits of `n` and not the full result. +* +* @param x - input value +* @param y - remainder elements +* @returns factor of `π/2` +* +* @example +* var y = [ 0.0, 0.0 ]; +* var n = rempio2( 128.0, y ); +* // returns 81 +* +* var y1 = y[ 0 ]; +* // returns ~0.765 +* +* var y2 = y[ 1 ]; +* // returns ~3.618e-17 +* +* @example +* var y = [ 0.0, 0.0 ]; +* var n = rempio2( NaN, y ); +* // returns 0 +* +* var y1 = y[ 0 ]; +* // returns NaN +* +* var y2 = y[ 1 ]; +* // returns NaN +*/ +declare function rempio2( x: number, y: Collection ): number; + + +// EXPORTS // + +export = rempio2; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts new file mode 100644 index 000000000000..75954335dd45 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts @@ -0,0 +1,56 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 { Collection } from '@stdlib/types/array'; +import rempio2 = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const y: Collection = [ 0.0, 0.0 ]; + rempio2( 128, y ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number as its first argument... +{ + const y: Collection = [ 0.0, 0.0 ]; + rempio2( true, y ); // $ExpectError + rempio2( false, y ); // $ExpectError + rempio2( '5', y ); // $ExpectError + rempio2( [], y ); // $ExpectError + rempio2( {}, y ); // $ExpectError + rempio2( ( x: number ): number => x, y ); // $ExpectError +} + +// The compiler throws an error if the function is provided a value other than a collection as its second argument... +{ + rempio2( 128, true ); // $ExpectError + rempio2( 128, false ); // $ExpectError + rempio2( 128, 3 ); // $ExpectError + rempio2( 128, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + rempio2(); // $ExpectError + rempio2( 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/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/rempio2f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c new file mode 100644 index 000000000000..4b314d364054 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c @@ -0,0 +1,35 @@ +/** +* @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/rempio2.h" +#include +#include +#include + +int main( void ) { + const double x[] = { 0.0, 1.0, 4.0, 128.0 }; + + double rem1; + double rem2; + int32_t n; + int i; + for ( i = 0; i < 4; i++ ) { + n = stdlib_base_rempio2( x[ i ], &rem1, &rem2 ); + printf( "%lf - %"PRId32"π/2 = %lf + %lf\n", x[ i ], n, rem1, rem2 ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js new file mode 100644 index 000000000000..47d7f6950973 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js @@ -0,0 +1,32 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 rempio2 = require( './../lib' ); + +var x = linspace( 0.0, 100.0, 100 ); +var y = [ 0.0, 0.0 ]; +var n; +var i; + +for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[ i ], y ); + console.log( '%d - %dπ/2 = %d + %d', x[ i ], n, y[ 0 ], y[ 1 ] ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi b/lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/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 `x - nπ/2 = r`. +*/ +int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_REMPIO2_H diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js new file mode 100644 index 000000000000..00c5a6e6c928 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 `x - nπ/2 = r`. +* +* @module @stdlib/math/base/special/rempio2 +* +* @example +* var rempio2 = require( '@stdlib/math/base/special/rempio2' ); +* +* var y = [ 0.0, 0.0 ]; +* var n = rempio2( 128.0, y ); +* // returns 81 +* +* var y1 = y[ 0 ]; +* // returns ~0.765 +* +* var y2 = y[ 1 ]; +* // returns ~3.618e-17 +*/ + +// MODULES // + +var rempio2 = require( './main.js' ); + + +// EXPORTS // + +module.exports = rempio2; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js new file mode 100644 index 000000000000..6417f94af16d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js @@ -0,0 +1,428 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +* +* +* ## Notice +* +* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/k_rem_pio2.c}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +/* eslint-disable array-element-newline */ + +'use strict'; + +// MODULES // + +var floor = require( '@stdlib/math/base/special/floor' ); +var ldexp = require( '@stdlib/math/base/special/ldexp' ); +var zeros = require( '@stdlib/array/base/zeros' ); + + +// VARIABLES // + +/* +* Table of constants for `2/π` (`396` hex digits, `476` decimal). +* +* Integer array which contains the (`24*i`)-th to (`24*i+23`)-th bit of `2/π` after binary point. The corresponding floating value is +* +* ```tex +* \operatorname{ipio2}[i] \cdot 2^{-24(i+1)} +* ``` +* +* This table must have at least `(e0-3)/24 + jk` terms. For quad precision (`e0 <= 16360`, `jk = 6`), this is `686`. +*/ +var IPIO2 = [ + 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, + 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, + 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, + 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, + 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, + 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, + 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, + 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, + 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, + 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, + 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B +]; + +// Double precision array, obtained by cutting `π/2` into `24` bits chunks... +var PIO2 = [ + 1.57079625129699707031e+00, // 0x3FF921FB, 0x40000000 + 7.54978941586159635335e-08, // 0x3E74442D, 0x00000000 + 5.39030252995776476554e-15, // 0x3CF84698, 0x80000000 + 3.28200341580791294123e-22, // 0x3B78CC51, 0x60000000 + 1.27065575308067607349e-29, // 0x39F01B83, 0x80000000 + 1.22933308981111328932e-36, // 0x387A2520, 0x40000000 + 2.73370053816464559624e-44, // 0x36E38222, 0x80000000 + 2.16741683877804819444e-51 // 0x3569F31D, 0x00000000 +]; +var TWO24 = 1.67772160000000000000e+07; // 0x41700000, 0x00000000 +var TWON24 = 5.96046447753906250000e-08; // 0x3E700000, 0x00000000 + +// Arrays for storing temporary values (note that, in C, this is not thread safe): +var F = zeros( 20 ); +var Q = zeros( 20 ); +var FQ = zeros( 20 ); +var IQ = zeros( 20 ); + + +// FUNCTIONS // + +/** +* Performs the computation for `kernelRempio2()`. +* +* @private +* @param {PositiveNumber} x - input value +* @param {(Array|TypedArray|Object)} y - output object for storing double precision numbers +* @param {integer} jz - number of terms of `ipio2[]` used +* @param {Array} q - array with integral values, representing the 24-bits chunk of the product of `x` and `2/π` +* @param {integer} q0 - the corresponding exponent of `q[0]` (the exponent for `q[i]` would be `q0-24*i`) +* @param {integer} jk - `jk+1` is the initial number of terms of `IPIO2[]` needed in the computation +* @param {integer} jv - index for pointing to the suitable `ipio2[]` for the computation +* @param {integer} jx - `nx - 1` +* @param {Array} f - `IPIO2[]` in floating point +* @returns {number} last three binary digits of `N` +*/ +function compute( x, y, jz, q, q0, jk, jv, jx, f ) { + var carry; + var fw; + var ih; + var jp; + var i; + var k; + var n; + var j; + var z; + + // `jp+1` is the number of terms in `PIO2[]` needed: + jp = jk; + + // Distill `q[]` into `IQ[]` in reverse order... + z = q[ jz ]; + j = jz; + for ( i = 0; j > 0; i++ ) { + fw = ( TWON24 * z )|0; + IQ[ i ] = ( z - (TWO24*fw) )|0; + z = q[ j-1 ] + fw; + j -= 1; + } + // Compute `n`... + z = ldexp( z, q0 ); + z -= 8.0 * floor( z*0.125 ); // Trim off integer >= 8 + n = z|0; + z -= n; + ih = 0; + if ( q0 > 0 ) { + // Need `IQ[jz-1]` to determine `n`... + i = ( IQ[ jz-1 ] >> (24-q0) ); + n += i; + IQ[ jz-1 ] -= ( i << (24-q0) ); + ih = ( IQ[ jz-1 ] >> (23-q0) ); + } + else if ( q0 === 0 ) { + ih = ( IQ[ jz-1 ] >> 23 ); + } + else if ( z >= 0.5 ) { + ih = 2; + } + // Case: q > 0.5 + if ( ih > 0 ) { + n += 1; + carry = 0; + + // Compute `1-q`: + for ( i = 0; i < jz; i++ ) { + j = IQ[ i ]; + if ( carry === 0 ) { + if ( j !== 0 ) { + carry = 1; + IQ[ i ] = 0x1000000 - j; + } + } else { + IQ[ i ] = 0xffffff - j; + } + } + if ( q0 > 0 ) { + // Rare case: chance is 1 in 12... + switch ( q0 ) { // eslint-disable-line default-case + case 1: + IQ[ jz-1 ] &= 0x7fffff; + break; + case 2: + IQ[ jz-1 ] &= 0x3fffff; + break; + } + } + if ( ih === 2 ) { + z = 1.0 - z; + if ( carry !== 0 ) { + z -= ldexp( 1.0, q0 ); + } + } + } + // Check if re-computation is needed... + if ( z === 0.0 ) { + j = 0; + for ( i = jz-1; i >= jk; i-- ) { + j |= IQ[ i ]; + } + if ( j === 0 ) { + // Need re-computation... + for ( k = 1; IQ[ jk-k ] === 0; k++ ) { + // `k` is the number of terms needed... + } + for ( i = jz+1; i <= jz+k; i++ ) { + // Add `q[jz+1]` to `q[jz+k]`... + f[ jx+i ] = IPIO2[ jv+i ]; + fw = 0.0; + for ( j = 0; j <= jx; j++ ) { + fw += x[ j ] * f[ jx + (i-j) ]; + } + q[ i ] = fw; + } + jz += k; + return compute( x, y, jz, q, q0, jk, jv, jx, f ); + } + // Chop off zero terms... + jz -= 1; + q0 -= 24; + while ( IQ[ jz ] === 0 ) { + jz -= 1; + q0 -= 24; + } + } else { + // Break `z` into 24-bit if necessary... + z = ldexp( z, -q0 ); + if ( z >= TWO24 ) { + fw = (TWON24*z)|0; + IQ[ jz ] = ( z - (TWO24*fw) )|0; + jz += 1; + q0 += 24; + IQ[ jz ] = fw; + } else { + IQ[ jz ] = z|0; + } + } + // Convert integer "bit" chunk to floating-point value... + fw = ldexp( 1.0, q0 ); + for ( i = jz; i >= 0; i-- ) { + q[ i ] = fw * IQ[i]; + fw *= TWON24; + } + // Compute `PIO2[0,...,jp]*q[jz,...,0]`... + for ( i = jz; i >= 0; i-- ) { + fw = 0.0; + for ( k = 0; k <= jp && k <= jz-i; k++ ) { + fw += PIO2[ k ] * q[ i+k ]; + } + FQ[ jz-i ] = fw; + } + // Compress `FQ[]` into `y[]`... + fw = 0.0; + for ( i = jz; i >= 0; i-- ) { + fw += FQ[ i ]; + } + if ( ih === 0 ) { + y[ 0 ] = fw; + } else { + y[ 0 ] = -fw; + } + fw = FQ[ 0 ] - fw; + for ( i = 1; i <= jz; i++ ) { + fw += FQ[i]; + } + if ( ih === 0 ) { + y[ 1 ] = fw; + } else { + y[ 1 ] = -fw; + } + return ( n & 7 ); +} + + +// MAIN // + +/** +* Returns the last three binary digits of `N` with `y = x - Nπ/2` so that `|y| < π/2`. +* +* ## Method +* +* - The method is to compute the integer (mod 8) and fraction parts of (2/π) * x without doing the full multiplication. In general, we skip the part of the product that are known to be a huge integer (more accurately, = 0 mod 8 ). Thus the number of operations are independent of the exponent of the input. +* +* - (2/π) is represented by an array of 24-bit integers in `ipio2[]`. +* +* - Input parameters: +* +* - `x[]` The input value (must be positive) is broken into `nx` pieces of 24-bit integers in double precision format. `x[i]` will be the i-th 24 bit of x. The scaled exponent of `x[0]` is given in input parameter `e0` (i.e., `x[0]*2^e0` match x's up to 24 bits). +* +* Example of breaking a double positive `z` into `x[0]+x[1]+x[2]`: +* +* ```tex +* e0 = \mathrm{ilogb}(z) - 23 +* z = \mathrm{scalbn}(z, -e0) +* ``` +* +* for `i = 0,1,2` +* +* ```tex +* x[i] = \lfloor z \rfloor +* z = (z - x[i]) \times 2^{24} +* ``` +* +* - `y[]` output result in an array of double precision numbers. +* +* The dimension of `y[]` is: +* 24-bit precision 1 +* 53-bit precision 2 +* 64-bit precision 2 +* 113-bit precision 3 +* +* The actual value is the sum of them. Thus, for 113-bit precision, one may have to do something like: +* +* ```tex +* \mathrm{long\ double} \: t, w, r_{\text{head}}, r_{\text{tail}}; \\ +* t &= (\mathrm{long\ double}) y[2] + (\mathrm{long\ double}) y[1]; \\ +* w &= (\mathrm{long\ double}) y[0]; \\ +* r_{\text{head}} &= t + w; \\ +* r_{\text{tail}} &= w - (r_{\text{head}} - t); +* ``` +* +* - `e0` The exponent of `x[0]`. Must be <= 16360 or you need to expand the `ipio2` table. +* +* - `nx` dimension of `x[]` +* +* - `prec` an integer indicating the precision: +* 0 24 bits (single) +* 1 53 bits (double) +* 2 64 bits (extended) +* 3 113 bits (quad) +* +* - External function: +* +* - double `scalbn()`, `floor()`; +* +* - Here is the description of some local variables: +* +* - `jk` `jk+1` is the initial number of terms of `ipio2[]` needed in the computation. The minimum and recommended value for `jk` is 3,4,4,6 for single, double, extended, and quad. `jk+1` must be 2 larger than you might expect so that our recomputation test works. (Up to 24 bits in the integer part (the 24 bits of it that we compute) and 23 bits in the fraction part may be lost to cancellation before we recompute.) +* +* - `jz` local integer variable indicating the number of terms of `ipio2[]` used. +* +* - `jx` `nx - 1` +* +* - `jv` index for pointing to the suitable `ipio2[]` for the computation. In general, we want +* +* ```tex +* \frac{{2^{e0} \cdot x[0] \cdot \mathrm{ipio2}[jv-1] \cdot 2^{-24jv}}}{{8}} +* ``` +* +* to be an integer. Thus +* +* ```tex +* e0 - 3 - 24 \cdot jv \geq 0 \quad \text{or} \quad \frac{{e0 - 3}}{{24}} \geq jv +* ``` +* +* Hence +* +* ```tex +* jv = \max(0, \frac{{e0 - 3}}{{24}}) +* ``` +* +* - `jp` `jp+1` is the number of terms in `PIo2[]` needed, `jp = jk`. +* +* - `q[]` double array with integral value, representing the 24-bits chunk of the product of `x` and `2/π`. +* +* - `q0` the corresponding exponent of `q[0]`. Note that the exponent for `q[i]` would be `q0-24*i`. +* +* - `PIo2[]` double precision array, obtained by cutting `π/2` into 24 bits chunks. +* +* - `f[]` `ipso2[]` in floating point +* +* - `iq[]` integer array by breaking up `q[]` in 24-bits chunk. +* +* - `fq[]` final product of `x*(2/π)` in `fq[0],..,fq[jk]` +* +* - `ih` integer. If >0 it indicates `q[]` is >= 0.5, hence it also indicates the _sign_ of the result. +* +* - Constants: +* +* - The hexadecimal values are the intended ones for the following constants. The decimal values may be used, provided that the compiler will convert from decimal to binary accurately enough to produce the hexadecimal values shown. +* +* @private +* @param {PositiveNumber} x - input value +* @param {(Array|TypedArray|Object)} y - remainder elements +* @param {PositiveInteger} e0 - the exponent of `x[0]` (must be <= 16360) +* @param {PositiveInteger} nx - dimension of `x[]` +* @returns {number} last three binary digits of `N` +*/ +function kernelRempio2( x, y, e0, nx ) { + var fw; + var jk; + var jv; + var jx; + var jz; + var q0; + var i; + var j; + var m; + + // Initialize `jk` for double-precision floating-point numbers: + jk = 4; + + // Determine `jx`, `jv`, `q0` (note that `q0 < 3`): + jx = nx - 1; + jv = ( (e0 - 3) / 24 )|0; + if ( jv < 0 ) { + jv = 0; + } + q0 = e0 - (24 * (jv + 1)); + + // Set up `F[0]` to `F[jx+jk]` where `F[jx+jk] = IPIO2[jv+jk]`: + j = jv - jx; + m = jx + jk; + for ( i = 0; i <= m; i++ ) { + if ( j < 0 ) { + F[ i ] = 0.0; + } else { + F[ i ] = IPIO2[ j ]; + } + j += 1; + } + // Compute `Q[0],Q[1],...,Q[jk]`: + for ( i = 0; i <= jk; i++ ) { + fw = 0.0; + for ( j = 0; j <= jx; j++ ) { + fw += x[ j ] * F[ jx + (i-j) ]; + } + Q[ i ] = fw; + } + jz = jk; + return compute( x, y, jz, Q, q0, jk, jv, jx, F ); +} + + +// EXPORTS // + +module.exports = kernelRempio2; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js new file mode 100644 index 000000000000..2550886ba19b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js @@ -0,0 +1,144 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +* +* +* ## Notice +* +* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/e_rem_pio2.c}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* +* Optimized by Bruce D. Evans. +* ``` +*/ + +'use strict'; + +// MODULES // + +var ABS_MASK = require( '@stdlib/constants/float32/abs-mask' ); +var EXPONENT_MASK = require( '@stdlib/constants/float32/exponent-mask' ); +var roundf = require( '@stdlib/math/base/special/roundf' ); +var fromWordf = require( '@stdlib/number/float32/base/from-word' ); +var toWordf = require( '@stdlib/number/float32/base/to-word' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var rempio2Kernel = require( './kernel_rempio2.js' ); + + +// VARIABLES // + +// 53 bits of 2/π: +var INVPIO2 = 6.36619772367581382433e-01; // 0x3FE45F30, 0x6DC9C883 + +// First 25 bits of π/2: +var PIO2_1 = 1.57079631090164184570e+00; // 0x3FF921FB, 0x50000000 + +// PIO2_1T = π/2 - PIO2_1: +var PIO2_1T = 1.58932547735281966916e-08; // 0x3E5110b4, 0x611A6263 + +// 2^28*π/2 = 1647099.3291652855 => 0100000100111001001000011111101101010100010001000010110100011000 => high word => 0x4dc90fdb = 1305022427 => 01001101110010010000111111011011 +var MEDIUM = 0x4dc90fdb|0; // asm type annotation + +// Arrays for storing temporary values: +var TX = [ 0.0 ]; +var TY = [ 0.0 ]; + + +// MAIN // + +/** +* Computes `x - nπ/2 = r`. +* +* ## Notes +* +* - Returns `n` and stores the remainder `r` as two numbers `y[0]` and `y[1]`, such that `y[0]+y[1] = r`. +* +* @param {number} x - input value +* @param {(Array|TypedArray|Object)} y - remainder elements +* @returns {integer} factor of `π/2` +* +* @example +* var y = [ 0.0, 0.0 ]; +* var n = rempio2( 128.0, y ); +* // returns 81 +* +* var y1 = y[ 0 ]; +* // returns ~0.765 +* +* var y2 = y[ 1 ]; +* // returns ~3.618e-17 +* +* @example +* var y = [ 0.0, 0.0 ]; +* var n = rempio2( NaN, y ); +* // returns 0 +* +* var y1 = y[ 0 ]; +* // returns NaN +* +* var y2 = y[ 1 ]; +* // returns NaN +*/ +function rempio2( x, y ) { + var e0; + var hx; + var ix; + var n; + var r; + var w; + var z; + + hx = toWordf( x ); + ix = (hx & ABS_MASK)|0; // asm type annotation + + // Case: |x| ~< 2^28*π/2 (medium size) + if ( ix < MEDIUM ) { + x = float64ToFloat32( x ); + n = roundf( float64ToFloat32( x * INVPIO2 ) ); + r = x - ( n * PIO2_1 ); + w = n * PIO2_1T; + y[ 0 ] = r - w; + return n; + } + // Case: x is NaN or infinity + if ( ix >= EXPONENT_MASK ) { + y[ 0 ] = NaN; + return 0.0; + } + // Set z = scalbn(|x|, ilogb(|x|)-23)... + e0 = (ix >> 23) - 150; // `e0 = ilogb(|x|) - 23` => unbiased exponent minus 23 + z = fromWordf( ix - ((e0 << 23)|0) ); + TX[ 0 ] = z; + n = rempio2Kernel( TX, TY, e0, 1 ); + if ( hx < 0.0 ) { + y[ 0 ] = -TY[ 0 ]; + return -n; + } + y[ 0 ] = TY[ 0 ]; + return n; +} + + +// EXPORTS // + +module.exports = rempio2; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js new file mode 100644 index 000000000000..ab9ea199ea87 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes `x - nπ/2 = r`. +* +* @private +* @param {number} x - input value +* @param {Float64Array} y - remainder elements +* @returns {integer} factor of `π/2` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var y = new Float64Array( [ 0.0, 0.0 ] ); +* var n = rempio2( 128.0, y ); +* // returns 81 +* +* var y1 = y[ 0 ]; +* // returns ~0.765 +* +* var y2 = y[ 1 ]; +* // returns ~3.618e-17 +*/ +function rempio2( x, y ) { + return addon( x, y ); +} + + +// EXPORTS // + +module.exports = rempio2; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js new file mode 100644 index 000000000000..66c55c8db2cb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js @@ -0,0 +1,126 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +* +* +* ## Notice +* +* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/k_rem_pio2.c}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +'use strict'; + +// MODULES // + +var round = require( '@stdlib/math/base/special/round' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var getHighWord = require( '@stdlib/number/float64/base/get-high-word' ); + + +// VARIABLES // + +// 53 bits of 2/π: +var INVPIO2 = 6.36619772367581382433e-01; // 0x3FE45F30, 0x6DC9C883 + +// First 25 bits of π/2: +var PIO2_1 = 1.57079631090164184570e+00; // 0x3FF921FB, 0x50000000 + +// PIO2_1T = π/2 - PIO2_1: +var PIO2_1T = 1.58932547735281966916e-08; // 0x3E5110b4, 0x611A6263 + +// // Another 33 bits of π/2: +// var PIO2_2 = 6.07710050630396597660e-11; // 0x3DD0B461, 0x1A600000 + +// // PIO2_2T = π/2 - ( PIO2_1 + PIO2_2 ): +// var PIO2_2T = 2.02226624879595063154e-21; // 0x3BA3198A, 0x2E037073 + +// // Another 33 bits of π/2: +// var PIO2_3 = 2.02226624871116645580e-21; // 0x3BA3198A, 0x2E000000 + +// // PIO2_3T = π/2 - ( PIO2_1 + PIO2_2 + PIO2_3 ): +// var PIO2_3T = 8.47842766036889956997e-32; // 0x397B839A, 0x252049C1 + +// // Exponent mask (2047 => 0x7ff): +// var EXPONENT_MASK = 0x7ff|0; // asm type annotation + + +// MAIN // + +/** +* Computes `x - nπ/2 = r` for medium-sized inputs. +* +* @private +* @param {number} x - input value +* @param {uint32} ix - high word of `x` +* @param {(Array|TypedArray|Object)} y - remainder elements +* @returns {integer} factor of `π/2` +*/ +function rempio2Medium( x, ix, y ) { + var high; + var n; + var t; + var r; + var w; + var i; + var j; + + x = float64ToFloat32( x ); + n = round( float64ToFloat32( x * INVPIO2 ) ); + r = x - ( n * PIO2_1 ); + w = n * PIO2_1T; + + // First rounding (good to 85 bits)... + j = (ix >> 20)|0; // asm type annotation + y[ 0 ] = r - w; + high = getHighWord( y[0] ); + i = j - ( (high >> 20) & EXPONENT_MASK ); + + // Check if a second iteration is needed (good to 118 bits)... + if ( i > 16 ) { + t = r; + w = n * PIO2_2; + r = t - w; + w = (n * PIO2_2T) - ((t-r) - w); + y[ 0 ] = r - w; + high = getHighWord( y[0] ); + i = j - ( (high >> 20) & EXPONENT_MASK ); + + // Check if a third iteration is needed (151 bits accumulated)... + if ( i > 49 ) { + t = r; + w = n * PIO2_3; + r = t - w; + w = (n * PIO2_3T) - ((t-r) - w); + y[ 0 ] = r - w; + } + } + y[ 1 ] = (r - y[0]) - w; + return n; +} + + +// EXPORTS // + +module.exports = rempio2Medium; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json b/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json new file mode 100644 index 000000000000..69ce750a6ce5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json @@ -0,0 +1,100 @@ +{ + "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/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-float64array", + "@stdlib/napi/create-double", + "@stdlib/napi/export", + "@stdlib/math/base/special/round", + "@stdlib/math/base/special/floor", + "@stdlib/math/base/special/ldexp", + "@stdlib/number/float64/base/get-high-word", + "@stdlib/number/float64/base/get-low-word", + "@stdlib/number/float64/base/from-words", + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-exponent-mask", + "@stdlib/constants/float64/high-word-significand-mask" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/round", + "@stdlib/math/base/special/floor", + "@stdlib/math/base/special/ldexp", + "@stdlib/number/float64/base/get-high-word", + "@stdlib/number/float64/base/get-low-word", + "@stdlib/number/float64/base/from-words", + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-exponent-mask", + "@stdlib/constants/float64/high-word-significand-mask" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/round", + "@stdlib/math/base/special/floor", + "@stdlib/math/base/special/ldexp", + "@stdlib/number/float64/base/get-high-word", + "@stdlib/number/float64/base/get-low-word", + "@stdlib/number/float64/base/from-words", + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-exponent-mask", + "@stdlib/constants/float64/high-word-significand-mask" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json b/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json new file mode 100644 index 000000000000..5e5ac0a6d2d2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/math/base/special/rempio2", + "version": "0.0.0", + "description": "Compute `x - nπ/2 = r`.", + "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", + "mathematics", + "math", + "remainder", + "division", + "pi", + "pio2", + "precision" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/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/rempio2f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c new file mode 100644 index 000000000000..ca49f1877cf8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c @@ -0,0 +1,42 @@ +/** +* @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/rempio2.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_float64array.h" +#include "stdlib/napi/create_double.h" +#include "stdlib/napi/export.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 2 ); + STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, y, ylen, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_rempio2( x, &y[0], &y[1] ), n ); + return n; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c new file mode 100644 index 000000000000..0384913710a3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c @@ -0,0 +1,626 @@ +/** +* @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. +* +* +* ## Notice +* +* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_rem_pio2.c}. The implementation follows the original, but has been modified according to project conventions. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +#include "stdlib/math/base/special/rempio2.h" +#include "stdlib/math/base/special/round.h" +#include "stdlib/math/base/special/floor.h" +#include "stdlib/math/base/special/ldexp.h" +#include "stdlib/number/float64/base/get_high_word.h" +#include "stdlib/number/float64/base/get_low_word.h" +#include "stdlib/number/float64/base/from_words.h" +#include "stdlib/constants/float64/high_word_abs_mask.h" +#include "stdlib/constants/float64/high_word_exponent_mask.h" +#include "stdlib/constants/float64/high_word_significand_mask.h" +#include + +static const double ZERO = 0.00000000000000000000e+00; // 0x00000000, 0x00000000 +static const double TWO24 = 1.67772160000000000000e+07; // 0x41700000, 0x00000000 +static const double TWON24 = 5.96046447753906250000e-08; // 0x3E700000, 0x00000000 +static const double INVPIO2 = 6.36619772367581382433e-01; // 0x3FE45F30, 0x6DC9C883 +static const double PIO2_1 = 1.57079632673412561417e+00; // 0x3FF921FB, 0x54400000 +static const double PIO2_1T = 6.07710050650619224932e-11; // 0x3DD0B461, 0x1A626331 +static const double PIO2_2 = 6.07710050630396597660e-11; // 0x3DD0B461, 0x1A600000 +static const double PIO2_2T = 2.02226624879595063154e-21; // 0x3BA3198A, 0x2E037073 +static const double PIO2_3 = 2.02226624871116645580e-21; // 0x3BA3198A, 0x2E000000 +static const double PIO2_3T = 8.47842766036889956997e-32; // 0x397B839A, 0x252049C1 + +// High word significand for π and π/2: 0x921fb = 598523 => 00000000000010010010000111111011 +static const int32_t PI_HIGH_WORD_SIGNIFICAND = 0x921fb; + +// High word for π/4: 0x3fe921fb = 1072243195 => 00111111111010010010000111111011 +static const int32_t PIO4_HIGH_WORD = 0x3fe921fb; + +// High word for 3π/4: 0x4002d97c = 1073928572 => 01000000000000101101100101111100 +static const int32_t THREE_PIO4_HIGH_WORD = 0x4002d97c; + +// High word for 5π/4: 0x400f6a7a = 1074752122 => 01000000000011110110101001111010 +static const int32_t FIVE_PIO4_HIGH_WORD = 0x400f6a7a; + +// High word for 6π/4: 0x4012d97c = 1074977148 => 01000000000100101101100101111100 +static const int32_t THREE_PIO2_HIGH_WORD = 0x4012d97c; + +// High word for 7π/4: 0x4015fdbc = 1075183036 => 01000000000101011111110110111100 +static const int32_t SEVEN_PIO4_HIGH_WORD = 0x4015fdbc; + +// High word for 8π/4: 0x401921fb = 1075388923 => 01000000000110010010000111111011 +static const int32_t TWO_PI_HIGH_WORD = 0x401921fb; + +// High word for 9π/4: 0x401c463b = 1075594811 => 01000000000111000100011000111011 +static const int32_t NINE_PIO4_HIGH_WORD = 0x401c463b; + +// 2^20*π/2 = 1647099.3291652855 => 0100000100111001001000011111101101010100010001000010110100011000 => high word => 0x413921fb = 1094263291 => 01000001001110010010000111111011 +static const int32_t MEDIUM = 0x413921fb; + +// Exponent mask (2047 => 0x7ff): +static const int32_t EXPONENT_MASK = 0x7ff; + + +/* +* Table of constants for `2/π` (`396` hex digits, `476` decimal). +* +* Integer array which contains the (`24*i`)-th to (`24*i+23`)-th bit of `2/π` after binary point. The corresponding floating value is +* +* ```tex +* \operatorname{ipio2}[i] \cdot 2^{-24(i+1)} +* ``` +* +* This table must have at least `(e0-3)/24 + jk` terms. For quad precision (`e0 <= 16360`, `jk = 6`), this is `686`. +*/ +static const int32_t IPIO2[] = { + 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, + 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, + 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, + 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, + 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, + 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, + 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, + 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, + 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, + 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, + 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B +}; + +// Double precision array, obtained by cutting `π/2` into `24` bits chunks... +static const double PIO2[] = { + 1.57079625129699707031e+00, // 0x3FF921FB, 0x40000000 + 7.54978941586159635335e-08, // 0x3E74442D, 0x00000000 + 5.39030252995776476554e-15, // 0x3CF84698, 0x80000000 + 3.28200341580791294123e-22, // 0x3B78CC51, 0x60000000 + 1.27065575308067607349e-29, // 0x39F01B83, 0x80000000 + 1.22933308981111328932e-36, // 0x387A2520, 0x40000000 + 2.73370053816464559624e-44, // 0x36E38222, 0x80000000 + 2.16741683877804819444e-51 // 0x3569F31D, 0x00000000 +}; + +/** +* Returns the last three binary digits of `N` with `y = x - Nπ/2` so that `|y| < π/2`. +* +* ## Method +* +* - The method is to compute the integer (mod 8) and fraction parts of (2/π) * x without doing the full multiplication. In general, we skip the part of the product that are known to be a huge integer (more accurately, = 0 mod 8 ). Thus the number of operations are independent of the exponent of the input. +* +* - (2/π) is represented by an array of 24-bit integers in `ipio2[]`. +* +* - Input parameters: +* +* - `x[]` The input value (must be positive) is broken into `nx` pieces of 24-bit integers in double precision format. `x[i]` will be the i-th 24 bit of x. The scaled exponent of `x[0]` is given in input parameter `e0` (i.e., `x[0]*2^e0` match x's up to 24 bits). +* +* Example of breaking a double positive `z` into `x[0]+x[1]+x[2]`: +* +* ```tex +* e0 = \mathrm{ilogb}(z) - 23 +* z = \mathrm{scalbn}(z, -e0) +* ``` +* +* for `i = 0,1,2` +* +* ```tex +* x[i] = \lfloor z \rfloor +* z = (z - x[i]) \times 2^{24} +* ``` +* +* - `y[]` output result in an array of double precision numbers. +* +* The dimension of `y[]` is: +* 24-bit precision 1 +* 53-bit precision 2 +* 64-bit precision 2 +* 113-bit precision 3 +* +* The actual value is the sum of them. Thus, for 113-bit precision, one may have to do something like: +* +* ```tex +* \mathrm{long\ double} \: t, w, r_{\text{head}}, r_{\text{tail}}; \\ +* t &= (\mathrm{long\ double}) y[2] + (\mathrm{long\ double}) y[1]; \\ +* w &= (\mathrm{long\ double}) y[0]; \\ +* r_{\text{head}} &= t + w; \\ +* r_{\text{tail}} &= w - (r_{\text{head}} - t); +* ``` +* +* - `e0` The exponent of `x[0]`. Must be <= 16360 or you need to expand the `ipio2` table. +* +* - `nx` dimension of `x[]` +* +* - `prec` an integer indicating the precision: +* 0 24 bits (single) +* 1 53 bits (double) +* 2 64 bits (extended) +* 3 113 bits (quad) +* +* - External function: +* +* - double `scalbn()`, `floor()`; +* +* - Here is the description of some local variables: +* +* - `jk` `jk+1` is the initial number of terms of `ipio2[]` needed in the computation. The minimum and recommended value for `jk` is 3,4,4,6 for single, double, extended, and quad. `jk+1` must be 2 larger than you might expect so that our recomputation test works. (Up to 24 bits in the integer part (the 24 bits of it that we compute) and 23 bits in the fraction part may be lost to cancellation before we recompute.) +* +* - `jz` local integer variable indicating the number of terms of `ipio2[]` used. +* +* - `jx` `nx - 1` +* +* - `jv` index for pointing to the suitable `ipio2[]` for the computation. In general, we want +* +* ```tex +* \frac{{2^{e0} \cdot x[0] \cdot \mathrm{ipio2}[jv-1] \cdot 2^{-24jv}}}{{8}} +* ``` +* +* to be an integer. Thus +* +* ```tex +* e0 - 3 - 24 \cdot jv \geq 0 \quad \text{or} \quad \frac{{e0 - 3}}{{24}} \geq jv +* ``` +* +* Hence +* +* ```tex +* jv = \max(0, \frac{{e0 - 3}}{{24}}) +* ``` +* +* - `jp` `jp+1` is the number of terms in `PIo2[]` needed, `jp = jk`. +* +* - `q[]` double array with integral value, representing the 24-bits chunk of the product of `x` and `2/π`. +* +* - `q0` the corresponding exponent of `q[0]`. Note that the exponent for `q[i]` would be `q0-24*i`. +* +* - `PIo2[]` double precision array, obtained by cutting `π/2` into 24 bits chunks. +* +* - `f[]` `ipso2[]` in floating point +* +* - `iq[]` integer array by breaking up `q[]` in 24-bits chunk. +* +* - `fq[]` final product of `x*(2/π)` in `fq[0],..,fq[jk]` +* +* - `ih` integer. If >0 it indicates `q[]` is >= 0.5, hence it also indicates the _sign_ of the result. +* +* - Constants: +* +* - The hexadecimal values are the intended ones for the following constants. The decimal values may be used, provided that the compiler will convert from decimal to binary accurately enough to produce the hexadecimal values shown. +* +* @param x input value +* @param y output array to store the remainder +* @param e0 the exponent of `x[0]` (must be <= 16360) +* @param nx dimension of `x[]` +* @return last 3 binary digits +*/ +int32_t rempio2Kernel( const double* x, double *y, int32_t e0, int32_t nx ) { + double F[ 20 ] = { 0.0 }; + double Q[ 20 ] = { 0.0 }; + int32_t IQ[ 20 ]; + double FQ[ 20 ]; + int32_t carry; + int32_t jz; + int32_t jx; + int32_t jv; + int32_t jp; + int32_t jk; + int32_t q0; + int32_t ih; + int32_t n; + int32_t i; + int32_t j; + int32_t k; + int32_t m; + double fw; + double z; + + // Initialize `jk` for double-precision floating-point numbers: + jk = 4; + jp = jk; + + // Determine `jx`, `jv`, `q0` (note that `q0 < 3`): + jx = nx - 1; + jv = ( e0 - 3 ) / 24; + if ( jv < 0 ) { + jv = 0; + } + q0 = e0 - ( 24 * ( jv + 1 ) ); + + // Set up `F[0]` to `F[jx+jk]` where `F[jx+jk] = IPIO2[jv+jk]`: + j = jv - jx; + m = jx + jk; + for ( i = 0; i <= m; i++ ) { + if ( j < 0 ) { + F[ i ] = ZERO; + } else { + F[ i ] = ( double )IPIO2[ j ]; + } + j++; + } + + // Compute `Q[0],Q[1],...,Q[jk]`: + for ( i = 0; i <= jk; i++ ) { + fw = 0.0; + for ( j = 0; j <= jx; j++ ) { + fw += x[ j ] * F[ jx + ( i - j ) ]; + } + Q[ i ] = fw; + } + + jz = jk; +recompute: + // Distill `q[]` into `IQ[]` in reverse order... + z = Q[ jz ]; + j = jz; + for ( i = 0; j > 0; i++ ) { + fw = ( double )( ( int32_t )( TWON24 * z ) ); + IQ[ i ] = (int32_t)( z - ( TWO24 * fw ) ); + z = Q[ j - 1 ] + fw; + j--; + } + // Compute `n`... + z = stdlib_base_ldexp( z, q0 ); + z -= 8.0 * stdlib_base_floor( z * 0.125 ); // Trim off integer >= 8 + n = ( int32_t )z; + z -= ( double )n; + ih = 0; + if ( q0 > 0 ) { + // Need `IQ[jz-1]` to determine `n`... + i = ( IQ[ jz - 1 ] >> ( 24 - q0 ) ); + n += i; + IQ[ jz - 1 ] -= ( i << ( 24 - q0 ) ); + ih = ( IQ[ jz - 1 ] >> ( 23 - q0 ) ); + } else if ( q0 == 0 ) { + ih = ( IQ[ jz - 1 ] >> 23 ); + } else if ( z >= 0.5 ) { + ih = 2; + } + + // Case: q > 0.5 + if ( ih > 0 ) { + n += 1; + carry = 0; + // Compute `1-q`: + for ( i = 0; i < jz; i++ ) { + j = IQ[ i ]; + if ( carry == 0 ) { + if ( j != 0 ) { + carry = 1; + IQ[ i ] = 0x1000000 - j; + } + } else { + IQ[ i ] = 0xffffff - j; + } + } + if ( q0 > 0 ) { + // Rare case: chance is 1 in 12... + switch ( q0 ) { + case 1: + IQ[ jz - 1 ] &= 0x7fffff; + break; + case 2: + IQ[ jz - 1 ] &= 0x3fffff; + break; + } + } + if ( ih == 2 ) { + z = 1.0 - z; + if ( carry != 0 ) { + z -= stdlib_base_ldexp( 1.0, q0 ); + } + } + } + + // Check if re-computation is needed... + if ( z == ZERO ) { + j = 0; + for ( i = jz - 1; i >= jk; i-- ) { + j |= IQ[ i ]; + } + if ( j == 0 ) { + // Need re-computation... + for ( k = 1; IQ[ jk - k ] == 0; k++ ) { + // `k` is the number of terms needed... + } + + for ( i = jz + 1; i <= jz + k; i++ ) { + // Add `q[jz+1]` to `q[jz+k]`... + F[ jx + i ] = ( double )IPIO2[ jv + i ]; + fw = 0.0; + for ( j = 0; j <= jx; j++ ) { + fw += x[ j ] * F[ jx + ( i - j ) ]; + } + Q[ i ] = fw; + } + jz += k; + goto recompute; + } + // Chop off zero terms... + jz -= 1; + q0 -= 24; + while ( IQ[ jz ] == 0 ) { + jz--; + q0 -= 24; + } + } else { + // Break `z` into 24-bit if necessary... + z = stdlib_base_ldexp( z, -q0 ); + if ( z >= TWO24 ) { + fw = ( double )( ( int32_t )( TWON24 * z ) ); + IQ[ jz ] = ( int32_t )( z - ( TWO24 * fw ) ); + jz += 1; + q0 += 24; + IQ[ jz ] = ( int32_t )fw; + } else { + IQ[ jz ] = ( int32_t )z; + } + } + + // Convert integer "bit" chunk to floating-point value... + fw = stdlib_base_ldexp( 1.0, q0 ); + for ( i = jz; i >= 0; i-- ) { + Q[ i ] = fw * ( double )IQ[ i ]; + fw *= TWON24; + } + + // Compute `PIO2[0,...,jp]*q[jz,...,0]`... + for ( i = jz; i >= 0; i-- ) { + fw = 0.0; + for ( k = 0; k <= jp && k <= jz - i; k++ ) { + fw += PIO2[ k ] * Q[ i + k ]; + } + FQ[ jz - i ] = fw; + } + // Compress `FQ[]` into `y[]`... + fw = 0.0; + for ( i = jz; i >= 0; i-- ) { + fw += FQ[ i ]; + } + if ( ih == 0 ) { + y[ 0 ] = fw; + } else { + y[ 0 ] = -fw; + } + fw = FQ[ 0 ] - fw; + for ( i = 1; i <= jz; i++ ) { + fw += FQ[i]; + } + if ( ih == 0 ) { + y[ 1 ] = fw; + } else { + y[ 1 ] = -fw; + } + return n & 7; +} + + +/** +* Computes `x - nπ/2 = r`. +* +* ## Notes +* +* - Returns `n` and stores the remainder `r` as two numbers `rem1` and `rem2`, such that `rem1+rem2 = r`. +* +* @param x input value +* @param rem1 remainder element 1 +* @param rem2 remainder element 2 +* @return factor of `π/2` +* +* @example +* #include +* +* double rem1; +* double rem2; +* int32_t n = stdlib_base_rempio2( 128.0, &rem1, &rem2 ); +*/ +int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ) { + double TX[ 3 ]; + double TY[ 2 ]; + uint32_t uhigh; + uint32_t ulow; + uint32_t uhx; + int32_t high; + int32_t low; + int32_t ix; + int32_t hx; + int32_t e0; + int32_t nx; + int32_t i; + int32_t j; + int32_t n; + double z; + double w; + double t; + double r; + + // high word of x + stdlib_base_float64_get_high_word( x, &uhx ); + hx = ( int32_t )uhx; + ix = hx & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK; + + // Case: |x| ~<= π/4 (no need for reduction) + if ( ix <= PIO4_HIGH_WORD ) { + *rem1 = x; + *rem2 = 0; + return 0; + } + // Case: |x| ~<= 5π/4 + if ( ix <= FIVE_PIO4_HIGH_WORD ) { + // Case: |x| ~= π/2 or π + if ( ( ix & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_SIGNIFICAND_MASK ) == PI_HIGH_WORD_SIGNIFICAND ) { + // Cancellation => use medium case + goto medium; + } + // Case: |x| ~<= 3π/4 + if ( ix <= THREE_PIO4_HIGH_WORD ) { + if ( hx > 0 ) { + // one round good to 85 bits + z = x - PIO2_1; + *rem1 = z - PIO2_1T; + *rem2 = ( z - *rem1 ) - PIO2_1T; + return 1; + } else { + z = x + PIO2_1; + *rem1 = z + PIO2_1T; + *rem2 = ( z - *rem1 ) + PIO2_1T; + return -1; + } + } else { + if ( hx > 0 ) { + z = x - ( 2.0 * PIO2_1 ); + *rem1 = z - ( 2 * PIO2_1T ); + *rem2 = ( z - *rem1 ) - ( 2 * PIO2_1T ); + return 2; + } else { + z = x + ( 2.0 * PIO2_1 ); + *rem1 = z + ( 2.0 * PIO2_1T ); + *rem2 = ( z - *rem1 ) + ( 2.0 * PIO2_1T ); + return -2; + } + } + } + // Case: |x| ~<= 9π/4 + if ( ix <= NINE_PIO4_HIGH_WORD ) { + // Case: |x| ~<= 7π/4 + if ( ix <= SEVEN_PIO4_HIGH_WORD ) { + // Case: |x| ~= 3π/2 + if ( ix == THREE_PIO2_HIGH_WORD ) { + goto medium; + } + if ( hx > 0 ) { + z = x - ( 3 * PIO2_1 ); + *rem1 = z - ( 3 * PIO2_1T ); + *rem2 = ( z - *rem1 ) - ( 3 * PIO2_1T ); + return 3; + } else { + z = x + ( 3 * PIO2_1 ); + *rem1 = z + ( 3 * PIO2_1T ); + *rem2 = ( z - *rem1 ) + ( 3.0 * PIO2_1T ); + return -3; + } + } else { + // Case: |x| ~= 4π/2 + if ( ix == TWO_PI_HIGH_WORD ) { + goto medium; + } + if ( hx > 0 ) { + z = x - ( 4 * PIO2_1 ); + *rem1 = z - ( 4 * PIO2_1T ); + *rem2 = ( z - *rem1 ) - ( 4 * PIO2_1T ); + return 4; + } else { + z = x + ( 4 * PIO2_1 ); + *rem1 = z + ( 4 * PIO2_1T ); + *rem2 = ( z - *rem1 ) + ( 4 * PIO2_1T ); + return -4; + } + } + } + // Case: |x| ~< 2^20*π/2 (medium size) + if ( ix < MEDIUM ) { +medium: + n = stdlib_base_round( x * INVPIO2 ); + r = x - ( n * PIO2_1 ); + w = n * PIO2_1T; + + // First rounding (good to 85 bits)... + j = ix >> 20; + *rem1 = r - w; + stdlib_base_float64_get_high_word( *rem1, &uhigh ); + high = ( int32_t )uhigh; + i = j - ( ( high >> 20 ) & EXPONENT_MASK ); + + // Check if a second iteration is needed (good to 118 bits)... + if ( i > 16 ) { + t = r; + w = n * PIO2_2; + r = t - w; + w = ( n * PIO2_2T ) - ( ( t - r ) - w ); + *rem1 = r - w; + stdlib_base_float64_get_high_word( *rem1, &uhigh ); + high = ( int32_t )uhigh; + i = j - ( ( high >> 20 ) & EXPONENT_MASK ); + + // Check if a third iteration is needed (151 bits accumulated)... + if ( i > 49 ) { + // will cover all possible cases + t = r; + w = n * PIO2_3; + r = t - w; + w = ( n * PIO2_3T ) - ( ( t - r ) - w ); + *rem1 = r - w; + } + } + *rem2 = ( r - *rem1 ) - w; + return n; + } + // Case: x is NaN or infinity + if( ix >= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) { + *rem1 = 0.0 / 0.0; // NaN + *rem2 = 0.0 / 0.0; // NaN + return 0; + } + // Set z = scalbn(|x|, ilogb(x)-23)... + stdlib_base_float64_get_low_word( x, &ulow ); + low = ( int32_t )ulow; + e0 = ( ix >> 20 ) - 1046; // `e0 = ilogb(z) - 23` => unbiased exponent minus 23 + stdlib_base_float64_from_words( ix - ( int32_t ) ( e0 << 20 ), low, &z ); + for ( i = 0; i < 2; i++ ) { + TX[ i ] = ( double )( ( int32_t )z ); + z = ( z - TX[ i ] ) * TWO24; + } + TX[ 2 ] = z; + nx = 3; + while ( TX[ nx - 1 ] == ZERO ) { + // Skip zero term... + nx--; + } + n = rempio2Kernel( TX, TY, e0, nx); + if ( hx < 0 ) { + *rem1 = -TY[ 0 ]; + *rem2 = -TY[ 1 ]; + return -n; + } + *rem1 = TY[ 0 ]; + *rem2 = TY[ 1 ]; + return n; +} diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js new file mode 100644 index 000000000000..432dabcc8c30 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js @@ -0,0 +1,266 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isInteger = require( '@stdlib/assert/is-integer' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrspace = require( '@stdlib/array/base/incrspace' ); +var linspace = require( '@stdlib/array/base/linspace' ); +var randu = require( '@stdlib/random/base/randu' ); +var abs = require( '@stdlib/math/base/special/absf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var PIO2 = require( '@stdlib/constants/float32/half-pi' ); +var PIO4 = require( '@stdlib/constants/float32/fourth-pi' ); +var rempio2 = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof rempio2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided `NaN`', function test( t ) { + var y = [ 0.0 ]; + var n = rempio2( NaN, y ); + t.strictEqual( n, 0.0, 'returns expected value' ); + t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided positive or negative infinity', function test( t ) { + var y = [ 0.0 ]; + var n = rempio2( PINF, y ); + t.strictEqual( n, 0.0, 'returns expected value' ); + t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + + y = [ 0.0 ]; + n = rempio2( NINF, y ); + t.strictEqual( n, 0.0, 'returns expected value' ); + t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (positive)', function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = [ 0.0 ]; + for ( i = 0; i < 200; i++ ) { + x = float64ToFloat32( randu()*100.0 ); + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[ 0 ] ), true, 'returns expected value' ); + + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny positive)', function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = [ 0.0 ]; + for ( i = 0; i < 200; i++ ) { + x = float64ToFloat32( randu()*1.0e-100 ); + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (negative)', function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = [ 0.0 ]; + for ( i = 0; i < 200; i++ ) { + x = float64ToFloat32( -100.0 * randu() ); + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny negative)', function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = [ 0.0 ]; + for ( i = 0; i < 200; i++ ) { + x = float64ToFloat32( -1.0e-100 * randu() ); + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (multiples of π/4)', function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + x = incrspace( -10.0*PIO4, 10.0*PIO4, PIO4 ); + y = [ 0.0 ]; + for ( i = 0; i < x.length; i++ ) { + x[i] = float64ToFloat32( x[i] ); + n = rempio2( x[i], y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = abs( z - x[i] ); + tol = EPS * abs( x[i] ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); + } + t.end(); +}); + +tape( 'for large positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( pow( 2.0, 28 )*PIO2, pow( 2.0, 60 )*PIO2, 4000 ); + y = [ 0.0 ]; + for ( i = 0; i < x.length; i++ ) { + x[i] = float64ToFloat32( x[i] ); + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'for large negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( -pow( 2.0, 28 )*PIO2, -pow( 2.0, 60 )*PIO2, 4000 ); + y = [ 0.0 ]; + for ( i = 0; i < x.length; i++ ) { + x[i] = float64ToFloat32( x[i] ); + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'for huge positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 1020 )*PIO2, 6000 ); + y = [ 0.0 ]; + for ( i = 0; i < x.length; i++ ) { + x[i] = float64ToFloat32( x[i] ); + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'for huge negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 1020 )*PIO2, 6000 ); + y = [ 0.0 ]; + for ( i = 0; i < x.length; i++ ) { + x[i] = float64ToFloat32( x[i] ); + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js new file mode 100644 index 000000000000..aebecf791c36 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js @@ -0,0 +1,282 @@ +/** +* @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 isInteger = require( '@stdlib/assert/is-integer' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrspace = require( '@stdlib/array/base/incrspace' ); +var linspace = require( '@stdlib/array/base/linspace' ); +var randu = require( '@stdlib/random/base/randu' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var PIO2 = require( '@stdlib/constants/float64/half-pi' ); +var PIO4 = require( '@stdlib/constants/float64/fourth-pi' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var rempio2 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( rempio2 instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof rempio2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided `NaN`', opts, function test( t ) { + var y = new Float64Array( [ 0.0, 0.0 ] ); + var n = rempio2( NaN, y ); + t.strictEqual( n, 0.0, 'returns expected value' ); + t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[1] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided positive or negative infinity', opts, function test( t ) { + var y = new Float64Array( [ 0.0, 0.0 ] ); + var n = rempio2( PINF, y ); + t.strictEqual( n, 0.0, 'returns expected value' ); + t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[1] ), true, 'returns expected value' ); + + y = new Float64Array( [ 0.0, 0.0 ] ); + n = rempio2( NINF, y ); + t.strictEqual( n, 0.0, 'returns expected value' ); + t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[1] ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (positive)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < 200; i++ ) { + x = randu()*100.0; + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + + z = ( PIO2*n ) + ( y[0]+y[1] ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.strictEqual( delta <= tol, true, 'can recover input value' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny positive)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < 200; i++ ) { + x = randu()*1.0e-100; + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + + z = ( PIO2*n ) + ( y[0]+y[1] ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.strictEqual( delta <= tol, true, 'can recover input value' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (negative)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < 200; i++ ) { + x = -100.0 * randu(); + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + + z = ( PIO2*n ) + ( y[0]+y[1] ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.strictEqual( delta <= tol, true, 'can recover input value' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny negative)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < 200; i++ ) { + x = -1.0e-100 * randu(); + n = rempio2( x, y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + + z = ( PIO2*n ) + ( y[0]+y[1] ); + delta = abs( z - x ); + tol = EPS * abs( x ); + t.strictEqual( delta <= tol, true, 'can recover input value' ); + } + t.end(); +}); + +tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (multiples of π/4)', opts, function test( t ) { + var delta; + var tol; + var x; + var y; + var z; + var n; + var i; + + x = incrspace( -10.0*PIO4, 10.0*PIO4, PIO4 ); + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[i], y ); + + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + + z = ( PIO2*n ) + ( y[0]+y[1] ); + delta = abs( z - x[i] ); + tol = EPS * abs( x[i] ); + t.strictEqual( delta <= tol, true, 'can recover input value' ); + } + t.end(); +}); + +tape( 'for large positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( pow( 2.0, 20 )*PIO2, pow( 2.0, 60 )*PIO2, 4000 ); + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'for large negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( -pow( 2.0, 20 )*PIO2, -pow( 2.0, 60 )*PIO2, 4000 ); + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'for huge positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 1020 )*PIO2, 6000 ); + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); + +tape( 'for huge negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { + var x; + var y; + var n; + var i; + + x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 1020 )*PIO2, 6000 ); + y = new Float64Array( [ 0.0, 0.0 ] ); + for ( i = 0; i < x.length; i++ ) { + n = rempio2( x[i], y ); + t.strictEqual( isInteger( n ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + t.strictEqual( n < 8, true, 'returns expected value' ); + } + t.end(); +}); From 66e81289f5c0200d6c9fd031da261f1ff1328df3 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 17 Mar 2025 23:17:57 -0700 Subject: [PATCH 2/6] feat: add implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../math/base/special/rempio2f/README.md | 76 +++--- .../special/rempio2f/benchmark/benchmark.js | 18 +- .../rempio2f/benchmark/benchmark.native.js | 21 +- .../rempio2f/benchmark/c/native/benchmark.c | 21 +- .../math/base/special/rempio2f/docs/repl.txt | 13 +- .../special/rempio2f/docs/types/index.d.ts | 26 +- .../base/special/rempio2f/docs/types/test.ts | 32 +-- .../special/rempio2f/examples/c/example.c | 11 +- .../base/special/rempio2f/examples/index.js | 8 +- .../base/special/{rempio2.h => rempio2f.h} | 10 +- .../math/base/special/rempio2f/lib/index.js | 17 +- .../{kernel_rempio2.js => kernel_rempio2f.js} | 19 +- .../math/base/special/rempio2f/lib/main.js | 36 ++- .../math/base/special/rempio2f/lib/native.js | 15 +- .../special/rempio2f/lib/rempio2_medium.js | 126 --------- .../math/base/special/rempio2f/manifest.json | 38 ++- .../math/base/special/rempio2f/package.json | 3 +- .../math/base/special/rempio2f/src/addon.c | 8 +- .../math/base/special/rempio2f/src/main.c | 248 +++--------------- .../math/base/special/rempio2f/test/test.js | 80 +++--- .../base/special/rempio2f/test/test.native.js | 168 ++++++------ 21 files changed, 318 insertions(+), 676 deletions(-) rename lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/{rempio2.h => rempio2f.h} (78%) rename lib/node_modules/@stdlib/math/base/special/rempio2f/lib/{kernel_rempio2.js => kernel_rempio2f.js} (97%) delete mode 100644 lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md b/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md index 978033ba6f65..aa8b330348d8 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md @@ -18,56 +18,47 @@ limitations under the License. --> -# rempio2 +# rempio2f -> Compute `x - nπ/2 = r`. +> Compute `x - nπ/2 = r` (single-precision).
## Usage ```javascript -var rempio2 = require( '@stdlib/math/base/special/rempio2' ); +var rempio2f = require( '@stdlib/math/base/special/rempio2f' ); ``` -#### rempio2( x, y ) +#### rempio2f( x, y ) Computes `x - nπ/2 = r`. ```javascript -var y = [ 0.0, 0.0 ]; -var n = rempio2( 128.0, y ); +var y = [ 0.0 ]; +var n = rempio2f( 128.0, y ); // returns 81 var y1 = y[ 0 ]; // returns ~0.765 - -var y2 = y[ 1 ]; -// returns ~3.618e-17 ``` -When `x` is `NaN` or infinite, the function returns `0` and sets the elements of `y` to `NaN`. +When `x` is `NaN` or infinite, the function returns `0` and sets `y[0]` to `NaN`. ```javascript -var y = [ 0.0, 0.0 ]; -var n = rempio2( NaN, y ); +var y = [ 0.0 ]; +var n = rempio2f( NaN, y ); // returns 0 var y1 = y[ 0 ]; // returns NaN -var y2 = y[ 1 ]; -// returns NaN - -y = [ 0.0, 0.0 ]; -n = rempio2( Infinity, y ); +y = [ 0.0 ]; +n = rempio2f( Infinity, y ); // returns 0 y1 = y[ 0 ]; // returns NaN - -y2 = y[ 1 ]; -// returns NaN ```
@@ -80,8 +71,8 @@ y2 = y[ 1 ]; ## Notes -- The function returns `n` and stores the remainder `r` as two numbers in `y`, such that `y[0]+y[1] = r`. -- For input values larger than `2^20*π/2` in magnitude, the function **only** returns the last three binary digits of `n` and not the full result. +- The function returns `n` and stores the remainder `r` as `y[0]`. +- For input values larger than `2^28*π/2` in magnitude, the function **only** returns the last three binary digits of `n` and not the full result. @@ -95,16 +86,16 @@ y2 = y[ 1 ]; ```javascript var linspace = require( '@stdlib/array/base/linspace' ); -var rempio2 = require( '@stdlib/math/base/special/rempio2' ); +var rempio2f = require( '@stdlib/math/base/special/rempio2f' ); var x = linspace( 0.0, 100.0, 100 ); -var y = [ 0.0, 0.0 ]; +var y = [ 0.0 ]; var n; var i; for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[ i ], y ); - console.log( '%d - %dπ/2 = %d + %d', x[ i ], n, y[ 0 ], y[ 1 ] ); + n = rempio2f( x[ i ], y ); + console.log( '%d - %dπ/2 = %d', x[ i ], n, y[ 0 ] ); } ``` @@ -135,30 +126,28 @@ for ( i = 0; i < x.length; i++ ) { ### Usage ```c -#include "stdlib/math/base/special/rempio2.h" +#include "stdlib/math/base/special/rempio2f.h" ``` -#### stdlib_base_rempio2( x, &rem1, &rem2 ) +#### stdlib_base_rempio2f( x, &rem ) -Computes `x - nπ/2 = r`. +Computes `x - nπ/2 = r` (single-precision). ```c #include -double rem1; -double rem2; +double rem; -int32_t n = stdlib_base_rempio2( 4.0, &rem1, &rem2 ); +int32_t n = stdlib_base_rempio2f( 4.0f, &rem ); ``` The function accepts the following arguments: -- **x**: `[in] double` input value. -- **rem1**: `[out] double*` destination for first remainder number. -- **rem2**: `[out] double*` destination for second remainder number. +- **x**: `[in] float` input value. +- **rem**: `[out] double*` destination for the remainder. ```c -int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ); +int32_t stdlib_base_rempio2f( const float x, double *rem ); ``` @@ -169,10 +158,6 @@ int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 );
-### Notes - -- The function returns `n` and stores the remainder `r` as two numbers in `rem1` and `rem2`, respectively, such that `rem1+rem2 = r`. -
@@ -184,21 +169,20 @@ int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ); ### Examples ```c -#include "stdlib/math/base/special/rempio2.h" +#include "stdlib/math/base/special/rempio2f.h" #include #include #include int main( void ) { - const double x[] = { 0.0, 1.0, 4.0, 128.0 }; + const double x[] = { 0.0f, 1.0f, 4.0f, 128.0f }; - double rem1; - double rem2; + double rem; int32_t n; int i; for ( i = 0; i < 4; i++ ) { - n = stdlib_base_rempio2( x[ i ], &rem1, &rem2 ); - printf( "%lf - %"PRId32"π/2 = %lf + %lf\n", x[ i ], n, rem1, rem2 ); + n = stdlib_base_rempio2f( x[ i ], &rem ); + printf( "%lf - %"PRId32"π/2 = %lf\n", x[ i ], n, rem ); } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js index c654c7d2a26c..b6a6f212d261 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js @@ -21,10 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/array/uniform' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pkg = require( './../package.json' ).name; -var rempio2 = require( './../lib' ); +var rempio2f = require( './../lib' ); // MAIN // @@ -35,18 +35,20 @@ bench( pkg, function benchmark( b ) { var n; var i; - y = [ 0.0, 0.0 ]; - x = randu( 100, -100.0, 100.0 ); + y = [ 0.0 ]; + x = uniform( 100, -100.0, 100.0, { + 'dtype': 'float32' + }); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - n = rempio2( x[ i % x.length ], y ); - if ( isnan( n ) ) { + n = rempio2f( x[ i % x.length ], y ); + if ( isnanf( n ) || isnanf( y[0] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( n ) || isnan( y[0] ) || isnan( y[1] ) ) { + if ( isnanf( n ) || isnanf( y[0] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js index d231943ea28c..6bec8c48eb6c 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js @@ -22,17 +22,18 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/array/uniform' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; // VARIABLES // -var rempio2 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var rempio2f = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': ( rempio2 instanceof Error ) + 'skip': ( rempio2f instanceof Error ) }; @@ -44,18 +45,20 @@ bench( pkg+'::native', opts, function benchmark( b ) { var n; var i; - y = [ 0.0, 0.0 ]; - x = randu( 100, -100.0, 100.0 ); + y = new Float64Array( [ 0.0 ] ); + x = uniform( 100, -100.0, 100.0, { + 'dtype': 'float32' + }); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - n = rempio2( x[ i % x.length ], y ); - if ( isnan( n ) ) { + n = rempio2f( x[ i % x.length ], y ); + if ( isnanf( n ) || isnanf( y[0] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( n ) || isnan( y[0] ) || isnan( y[1] ) ) { + if ( isnanf( n ) || isnanf( y[0] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c index 293062cc950f..b88bea2af24d 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c @@ -16,14 +16,14 @@ * limitations under the License. */ -#include "stdlib/math/base/special/rempio2.h" +#include "stdlib/math/base/special/rempio2f.h" #include #include #include #include #include -#define NAME "rempio2" +#define NAME "rempio2f" #define ITERATIONS 1000000 #define REPEATS 3 @@ -79,9 +79,9 @@ static double tic( void ) { * * @return random number */ -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 ); } /** @@ -90,28 +90,27 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { - double x[ 100 ]; + float x[ 100 ]; double elapsed; - double rem1; - double rem2; + double rem; double y; double t; int i; for ( i = 0; i < 100; i++ ) { - x[ i ] = ( rand_double() * 200.0 ) - 100.0; + x[ i ] = ( rand_float() * 200.0f ) - 100.0f; } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_rempio2( x[ i % 100 ], &rem1, &rem2 ); - if ( y != y ) { + y = stdlib_base_rempio2f( x[ i%100 ], &rem ); + if ( y != y && rem != rem ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( y != y ) { + if ( y != y && rem != rem ) { printf( "should not return NaN\n" ); } return elapsed; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt index 30267fa19272..d538e68333da 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/repl.txt @@ -1,11 +1,10 @@ {{alias}}( x, y ) - Computes `x - nπ/2 = r`. + Computes `x - nπ/2 = r` (single-precision). - The function returns `n` and stores the remainder `r` as the two numbers - `y[0]` and `y[1]`, such that `y[0] + y[1] = r`. + The function returns `n` and stores the remainder `r` as `y[0]`. - For input values larger than `2^20 * π/2` in magnitude, the function only + For input values larger than `2^28 * π/2` in magnitude, the function only returns the last three binary digits of `n` and not the full result. Parameters @@ -14,7 +13,7 @@ Input value. y: Array|TypedArray|Object - Remainder elements. + Remainder element. Returns ------- @@ -23,13 +22,11 @@ Examples -------- - > var y = [ 0.0, 0.0 ]; + > var y = [ 0.0 ]; > var n = {{alias}}( 128.0, y ) 81 > var y1 = y[ 0 ] ~0.765 - > var y2 = y[ 1 ] - ~3.618e-17 See Also diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts index b99a2f922ea9..ce985c1a8008 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts @@ -23,42 +23,36 @@ import { Collection } from '@stdlib/types/array'; /** -* Computes `x - nπ/2 = r`. +* Computes `x - nπ/2 = r` (single-precision). * * ## Notes * -* - The function returns `n` and stores the remainder `r` as the two numbers `y[0]` and `y[1]`, such that `y[0] + y[1] = r`. -* - For input values larger than `2^20 * π/2` in magnitude, the function only returns the last three binary digits of `n` and not the full result. +* - The function returns `n` and stores the remainder `r` as `y[0]`. +* - For input values larger than `2^28 * π/2` in magnitude, the function only returns the last three binary digits of `n` and not the full result. * * @param x - input value -* @param y - remainder elements +* @param y - remainder element * @returns factor of `π/2` * * @example -* var y = [ 0.0, 0.0 ]; -* var n = rempio2( 128.0, y ); +* var y = [ 0.0 ]; +* var n = rempio2f( 128.0, y ); * // returns 81 * * var y1 = y[ 0 ]; * // returns ~0.765 * -* var y2 = y[ 1 ]; -* // returns ~3.618e-17 -* * @example -* var y = [ 0.0, 0.0 ]; -* var n = rempio2( NaN, y ); +* var y = [ 0.0 ]; +* var n = rempio2f( NaN, y ); * // returns 0 * * var y1 = y[ 0 ]; * // returns NaN -* -* var y2 = y[ 1 ]; -* // returns NaN */ -declare function rempio2( x: number, y: Collection ): number; +declare function rempio2f( x: number, y: Collection ): number; // EXPORTS // -export = rempio2; +export = rempio2f; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts index 75954335dd45..2760b8a4afbb 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts @@ -19,38 +19,38 @@ /// import { Collection } from '@stdlib/types/array'; -import rempio2 = require( './index' ); +import rempio2f = require( './index' ); // TESTS // // The function returns a number... { - const y: Collection = [ 0.0, 0.0 ]; - rempio2( 128, y ); // $ExpectType number + const y: Collection = [ 0.0 ]; + rempio2f( 128, y ); // $ExpectType number } // The compiler throws an error if the function is provided a value other than a number as its first argument... { - const y: Collection = [ 0.0, 0.0 ]; - rempio2( true, y ); // $ExpectError - rempio2( false, y ); // $ExpectError - rempio2( '5', y ); // $ExpectError - rempio2( [], y ); // $ExpectError - rempio2( {}, y ); // $ExpectError - rempio2( ( x: number ): number => x, y ); // $ExpectError + const y: Collection = [ 0.0 ]; + rempio2f( true, y ); // $ExpectError + rempio2f( false, y ); // $ExpectError + rempio2f( '5', y ); // $ExpectError + rempio2f( [], y ); // $ExpectError + rempio2f( {}, y ); // $ExpectError + rempio2f( ( x: number ): number => x, y ); // $ExpectError } // The compiler throws an error if the function is provided a value other than a collection as its second argument... { - rempio2( 128, true ); // $ExpectError - rempio2( 128, false ); // $ExpectError - rempio2( 128, 3 ); // $ExpectError - rempio2( 128, {} ); // $ExpectError + rempio2f( 128, true ); // $ExpectError + rempio2f( 128, false ); // $ExpectError + rempio2f( 128, 3 ); // $ExpectError + rempio2f( 128, {} ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { - rempio2(); // $ExpectError - rempio2( 3 ); // $ExpectError + rempio2f(); // $ExpectError + rempio2f( 3 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c index 4b314d364054..1e3f0d3d4c1a 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c @@ -16,20 +16,19 @@ * limitations under the License. */ -#include "stdlib/math/base/special/rempio2.h" +#include "stdlib/math/base/special/rempio2f.h" #include #include #include int main( void ) { - const double x[] = { 0.0, 1.0, 4.0, 128.0 }; + const double x[] = { 0.0f, 1.0f, 4.0f, 128.0f }; - double rem1; - double rem2; + double rem; int32_t n; int i; for ( i = 0; i < 4; i++ ) { - n = stdlib_base_rempio2( x[ i ], &rem1, &rem2 ); - printf( "%lf - %"PRId32"π/2 = %lf + %lf\n", x[ i ], n, rem1, rem2 ); + n = stdlib_base_rempio2f( x[ i ], &rem ); + printf( "%lf - %"PRId32"π/2 = %lf\n", x[ i ], n, rem ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js index 47d7f6950973..5147c46fbdba 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js @@ -19,14 +19,14 @@ 'use strict'; var linspace = require( '@stdlib/array/base/linspace' ); -var rempio2 = require( './../lib' ); +var rempio2f = require( './../lib' ); var x = linspace( 0.0, 100.0, 100 ); -var y = [ 0.0, 0.0 ]; +var y = [ 0.0 ]; var n; var i; for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[ i ], y ); - console.log( '%d - %dπ/2 = %d + %d', x[ i ], n, y[ 0 ], y[ 1 ] ); + n = rempio2f( x[ i ], y ); + console.log( '%d - %dπ/2 = %d', x[ i ], n, y[ 0 ] ); } diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2.h b/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h similarity index 78% rename from lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2.h rename to lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h index ede33ed50dfd..a0b879526a67 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2.h +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h @@ -16,8 +16,8 @@ * limitations under the License. */ -#ifndef STDLIB_MATH_BASE_SPECIAL_REMPIO2_H -#define STDLIB_MATH_BASE_SPECIAL_REMPIO2_H +#ifndef STDLIB_MATH_BASE_SPECIAL_REMPIO2F_H +#define STDLIB_MATH_BASE_SPECIAL_REMPIO2F_H #include @@ -29,12 +29,12 @@ extern "C" { #endif /** -* Computes `x - nπ/2 = r`. +* Computes `x - nπ/2 = r` (single-precision). */ -int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ); +int32_t stdlib_base_rempio2f( const float x, double *rem ); #ifdef __cplusplus } #endif -#endif // !STDLIB_MATH_BASE_SPECIAL_REMPIO2_H +#endif // !STDLIB_MATH_BASE_SPECIAL_REMPIO2F_H diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js index 00c5a6e6c928..1d259dde62d8 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js @@ -19,29 +19,26 @@ 'use strict'; /** -* Compute `x - nπ/2 = r`. +* Compute `x - nπ/2 = r` (single precision). * -* @module @stdlib/math/base/special/rempio2 +* @module @stdlib/math/base/special/rempio2f * * @example -* var rempio2 = require( '@stdlib/math/base/special/rempio2' ); +* var rempio2f = require( '@stdlib/math/base/special/rempio2f' ); * -* var y = [ 0.0, 0.0 ]; -* var n = rempio2( 128.0, y ); +* var y = [ 0.0 ]; +* var n = rempio2f( 128.0, y ); * // returns 81 * * var y1 = y[ 0 ]; * // returns ~0.765 -* -* var y2 = y[ 1 ]; -* // returns ~3.618e-17 */ // MODULES // -var rempio2 = require( './main.js' ); +var rempio2f = require( './main.js' ); // EXPORTS // -module.exports = rempio2; +module.exports = rempio2f; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js similarity index 97% rename from lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js rename to lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js index 6417f94af16d..d75712c15248 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js @@ -92,7 +92,7 @@ var IQ = zeros( 20 ); // FUNCTIONS // /** -* Performs the computation for `kernelRempio2()`. +* Performs the computation for `kernelRempio2f()`. * * @private * @param {PositiveNumber} x - input value @@ -250,15 +250,6 @@ function compute( x, y, jz, q, q0, jk, jv, jx, f ) { } else { y[ 0 ] = -fw; } - fw = FQ[ 0 ] - fw; - for ( i = 1; i <= jz; i++ ) { - fw += FQ[i]; - } - if ( ih === 0 ) { - y[ 1 ] = fw; - } else { - y[ 1 ] = -fw; - } return ( n & 7 ); } @@ -266,7 +257,7 @@ function compute( x, y, jz, q, q0, jk, jv, jx, f ) { // MAIN // /** -* Returns the last three binary digits of `N` with `y = x - Nπ/2` so that `|y| < π/2`. +* Returns the last three binary digits of `N` with `y = x - Nπ/2` so that `|y| < π/2` (single precision). * * ## Method * @@ -372,12 +363,12 @@ function compute( x, y, jz, q, q0, jk, jv, jx, f ) { * * @private * @param {PositiveNumber} x - input value -* @param {(Array|TypedArray|Object)} y - remainder elements +* @param {(Array|TypedArray|Object)} y - remainder element * @param {PositiveInteger} e0 - the exponent of `x[0]` (must be <= 16360) * @param {PositiveInteger} nx - dimension of `x[]` * @returns {number} last three binary digits of `N` */ -function kernelRempio2( x, y, e0, nx ) { +function kernelRempio2f( x, y, e0, nx ) { var fw; var jk; var jv; @@ -425,4 +416,4 @@ function kernelRempio2( x, y, e0, nx ) { // EXPORTS // -module.exports = kernelRempio2; +module.exports = kernelRempio2f; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js index 2550886ba19b..0057c5f5f804 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js @@ -42,7 +42,7 @@ var roundf = require( '@stdlib/math/base/special/roundf' ); var fromWordf = require( '@stdlib/number/float32/base/from-word' ); var toWordf = require( '@stdlib/number/float32/base/to-word' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var rempio2Kernel = require( './kernel_rempio2.js' ); +var rempio2Kernelf = require( './kernel_rempio2f.js' ); // VARIABLES // @@ -56,7 +56,7 @@ var PIO2_1 = 1.57079631090164184570e+00; // 0x3FF921FB, 0x50000000 // PIO2_1T = π/2 - PIO2_1: var PIO2_1T = 1.58932547735281966916e-08; // 0x3E5110b4, 0x611A6263 -// 2^28*π/2 = 1647099.3291652855 => 0100000100111001001000011111101101010100010001000010110100011000 => high word => 0x4dc90fdb = 1305022427 => 01001101110010010000111111011011 +// 2^28*π/2 = 421657428.2663131 => 0100000110111001001000011111101101010100010001000010110100011000 => high word => 0x4dc90fdb = 1102651899 => 01000001101110010010000111111011 var MEDIUM = 0x4dc90fdb|0; // asm type annotation // Arrays for storing temporary values: @@ -67,39 +67,33 @@ var TY = [ 0.0 ]; // MAIN // /** -* Computes `x - nπ/2 = r`. +* Computes `x - nπ/2 = r` (single precision). * * ## Notes * -* - Returns `n` and stores the remainder `r` as two numbers `y[0]` and `y[1]`, such that `y[0]+y[1] = r`. +* - Returns `n` and stores the remainder `r` as `y[0]`. * * @param {number} x - input value -* @param {(Array|TypedArray|Object)} y - remainder elements +* @param {(Array|TypedArray|Object)} y - remainder element * @returns {integer} factor of `π/2` * * @example -* var y = [ 0.0, 0.0 ]; -* var n = rempio2( 128.0, y ); +* var y = [ 0.0 ]; +* var n = rempio2f( 128.0, y ); * // returns 81 * * var y1 = y[ 0 ]; * // returns ~0.765 * -* var y2 = y[ 1 ]; -* // returns ~3.618e-17 -* * @example -* var y = [ 0.0, 0.0 ]; -* var n = rempio2( NaN, y ); +* var y = [ 0.0 ]; +* var n = rempio2f( NaN, y ); * // returns 0 * * var y1 = y[ 0 ]; * // returns NaN -* -* var y2 = y[ 1 ]; -* // returns NaN */ -function rempio2( x, y ) { +function rempio2f( x, y ) { var e0; var hx; var ix; @@ -108,12 +102,12 @@ function rempio2( x, y ) { var w; var z; + x = float64ToFloat32( x ); hx = toWordf( x ); ix = (hx & ABS_MASK)|0; // asm type annotation // Case: |x| ~< 2^28*π/2 (medium size) if ( ix < MEDIUM ) { - x = float64ToFloat32( x ); n = roundf( float64ToFloat32( x * INVPIO2 ) ); r = x - ( n * PIO2_1 ); w = n * PIO2_1T; @@ -123,14 +117,14 @@ function rempio2( x, y ) { // Case: x is NaN or infinity if ( ix >= EXPONENT_MASK ) { y[ 0 ] = NaN; - return 0.0; + return 0; } // Set z = scalbn(|x|, ilogb(|x|)-23)... e0 = (ix >> 23) - 150; // `e0 = ilogb(|x|) - 23` => unbiased exponent minus 23 z = fromWordf( ix - ((e0 << 23)|0) ); TX[ 0 ] = z; - n = rempio2Kernel( TX, TY, e0, 1 ); - if ( hx < 0.0 ) { + n = rempio2Kernelf( TX, TY, e0, 1 ); + if ( hx < 0 ) { y[ 0 ] = -TY[ 0 ]; return -n; } @@ -141,4 +135,4 @@ function rempio2( x, y ) { // EXPORTS // -module.exports = rempio2; +module.exports = rempio2f; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js index ab9ea199ea87..0e590406aa69 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js @@ -26,31 +26,28 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes `x - nπ/2 = r`. +* Computes `x - nπ/2 = r` (single precision). * * @private * @param {number} x - input value -* @param {Float64Array} y - remainder elements +* @param {Float64Array} y - remainder element * @returns {integer} factor of `π/2` * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var y = new Float64Array( [ 0.0, 0.0 ] ); -* var n = rempio2( 128.0, y ); +* var y = new Float64Array( [ 0.0 ] ); +* var n = rempio2f( 128.0, y ); * // returns 81 * * var y1 = y[ 0 ]; * // returns ~0.765 -* -* var y2 = y[ 1 ]; -* // returns ~3.618e-17 */ -function rempio2( x, y ) { +function rempio2f( x, y ) { return addon( x, y ); } // EXPORTS // -module.exports = rempio2; +module.exports = rempio2f; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js deleted file mode 100644 index 66c55c8db2cb..000000000000 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/rempio2_medium.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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. -* -* -* ## Notice -* -* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/k_rem_pio2.c}. The implementation follows the original, but has been modified for JavaScript. -* -* ```text -* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. -* -* Developed at SunPro, a Sun Microsystems, Inc. business. -* Permission to use, copy, modify, and distribute this -* software is freely granted, provided that this notice -* is preserved. -* ``` -*/ - -'use strict'; - -// MODULES // - -var round = require( '@stdlib/math/base/special/round' ); -var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var getHighWord = require( '@stdlib/number/float64/base/get-high-word' ); - - -// VARIABLES // - -// 53 bits of 2/π: -var INVPIO2 = 6.36619772367581382433e-01; // 0x3FE45F30, 0x6DC9C883 - -// First 25 bits of π/2: -var PIO2_1 = 1.57079631090164184570e+00; // 0x3FF921FB, 0x50000000 - -// PIO2_1T = π/2 - PIO2_1: -var PIO2_1T = 1.58932547735281966916e-08; // 0x3E5110b4, 0x611A6263 - -// // Another 33 bits of π/2: -// var PIO2_2 = 6.07710050630396597660e-11; // 0x3DD0B461, 0x1A600000 - -// // PIO2_2T = π/2 - ( PIO2_1 + PIO2_2 ): -// var PIO2_2T = 2.02226624879595063154e-21; // 0x3BA3198A, 0x2E037073 - -// // Another 33 bits of π/2: -// var PIO2_3 = 2.02226624871116645580e-21; // 0x3BA3198A, 0x2E000000 - -// // PIO2_3T = π/2 - ( PIO2_1 + PIO2_2 + PIO2_3 ): -// var PIO2_3T = 8.47842766036889956997e-32; // 0x397B839A, 0x252049C1 - -// // Exponent mask (2047 => 0x7ff): -// var EXPONENT_MASK = 0x7ff|0; // asm type annotation - - -// MAIN // - -/** -* Computes `x - nπ/2 = r` for medium-sized inputs. -* -* @private -* @param {number} x - input value -* @param {uint32} ix - high word of `x` -* @param {(Array|TypedArray|Object)} y - remainder elements -* @returns {integer} factor of `π/2` -*/ -function rempio2Medium( x, ix, y ) { - var high; - var n; - var t; - var r; - var w; - var i; - var j; - - x = float64ToFloat32( x ); - n = round( float64ToFloat32( x * INVPIO2 ) ); - r = x - ( n * PIO2_1 ); - w = n * PIO2_1T; - - // First rounding (good to 85 bits)... - j = (ix >> 20)|0; // asm type annotation - y[ 0 ] = r - w; - high = getHighWord( y[0] ); - i = j - ( (high >> 20) & EXPONENT_MASK ); - - // Check if a second iteration is needed (good to 118 bits)... - if ( i > 16 ) { - t = r; - w = n * PIO2_2; - r = t - w; - w = (n * PIO2_2T) - ((t-r) - w); - y[ 0 ] = r - w; - high = getHighWord( y[0] ); - i = j - ( (high >> 20) & EXPONENT_MASK ); - - // Check if a third iteration is needed (151 bits accumulated)... - if ( i > 49 ) { - t = r; - w = n * PIO2_3; - r = t - w; - w = (n * PIO2_3T) - ((t-r) - w); - y[ 0 ] = r - w; - } - } - y[ 1 ] = (r - y[0]) - w; - return n; -} - - -// EXPORTS // - -module.exports = rempio2Medium; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json b/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json index 69ce750a6ce5..c9316fb43303 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/manifest.json @@ -37,19 +37,17 @@ "libpath": [], "dependencies": [ "@stdlib/napi/argv", - "@stdlib/napi/argv-double", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-float64array", "@stdlib/napi/create-double", "@stdlib/napi/export", - "@stdlib/math/base/special/round", + "@stdlib/math/base/special/roundf", "@stdlib/math/base/special/floor", "@stdlib/math/base/special/ldexp", - "@stdlib/number/float64/base/get-high-word", - "@stdlib/number/float64/base/get-low-word", - "@stdlib/number/float64/base/from-words", - "@stdlib/constants/float64/high-word-abs-mask", - "@stdlib/constants/float64/high-word-exponent-mask", - "@stdlib/constants/float64/high-word-significand-mask" + "@stdlib/number/float32/base/from-word", + "@stdlib/number/float32/base/to-word", + "@stdlib/constants/float32/abs-mask", + "@stdlib/constants/float32/exponent-mask" ] }, { @@ -63,15 +61,13 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/special/round", + "@stdlib/math/base/special/roundf", "@stdlib/math/base/special/floor", "@stdlib/math/base/special/ldexp", - "@stdlib/number/float64/base/get-high-word", - "@stdlib/number/float64/base/get-low-word", - "@stdlib/number/float64/base/from-words", - "@stdlib/constants/float64/high-word-abs-mask", - "@stdlib/constants/float64/high-word-exponent-mask", - "@stdlib/constants/float64/high-word-significand-mask" + "@stdlib/number/float32/base/from-word", + "@stdlib/number/float32/base/to-word", + "@stdlib/constants/float32/abs-mask", + "@stdlib/constants/float32/exponent-mask" ] }, { @@ -85,15 +81,13 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/special/round", + "@stdlib/math/base/special/roundf", "@stdlib/math/base/special/floor", "@stdlib/math/base/special/ldexp", - "@stdlib/number/float64/base/get-high-word", - "@stdlib/number/float64/base/get-low-word", - "@stdlib/number/float64/base/from-words", - "@stdlib/constants/float64/high-word-abs-mask", - "@stdlib/constants/float64/high-word-exponent-mask", - "@stdlib/constants/float64/high-word-significand-mask" + "@stdlib/number/float32/base/from-word", + "@stdlib/number/float32/base/to-word", + "@stdlib/constants/float32/abs-mask", + "@stdlib/constants/float32/exponent-mask" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json b/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json index 5e5ac0a6d2d2..f93396d27ede 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/math/base/special/rempio2", + "name": "@stdlib/math/base/special/rempio2f", "version": "0.0.0", "description": "Compute `x - nπ/2 = r`.", "license": "Apache-2.0", @@ -60,6 +60,7 @@ "division", "pi", "pio2", + "pio2f", "precision" ] } diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c index ca49f1877cf8..881de4bed14c 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c @@ -16,9 +16,9 @@ * limitations under the License. */ -#include "stdlib/math/base/special/rempio2.h" +#include "stdlib/math/base/special/rempio2f.h" #include "stdlib/napi/argv.h" -#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_float.h" #include "stdlib/napi/argv_float64array.h" #include "stdlib/napi/create_double.h" #include "stdlib/napi/export.h" @@ -33,9 +33,9 @@ */ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 2 ); - STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, x, argv, 0 ); STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, y, ylen, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_rempio2( x, &y[0], &y[1] ), n ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_rempio2f( x, &y[0] ), n ); return n; } diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c index 0384913710a3..ae547a0061b3 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c @@ -18,7 +18,7 @@ * * ## Notice * -* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_rem_pio2.c}. The implementation follows the original, but has been modified according to project conventions. +* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_rem_pio2f.c}. The implementation follows the original, but has been modified according to project conventions. * * ```text * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -30,58 +30,25 @@ * ``` */ -#include "stdlib/math/base/special/rempio2.h" -#include "stdlib/math/base/special/round.h" +#include "stdlib/math/base/special/rempio2f.h" +#include "stdlib/math/base/special/roundf.h" #include "stdlib/math/base/special/floor.h" #include "stdlib/math/base/special/ldexp.h" -#include "stdlib/number/float64/base/get_high_word.h" -#include "stdlib/number/float64/base/get_low_word.h" -#include "stdlib/number/float64/base/from_words.h" -#include "stdlib/constants/float64/high_word_abs_mask.h" -#include "stdlib/constants/float64/high_word_exponent_mask.h" -#include "stdlib/constants/float64/high_word_significand_mask.h" +#include "stdlib/number/float32/base/from_word.h" +#include "stdlib/number/float32/base/to_word.h" +#include "stdlib/constants/float32/abs_mask.h" +#include "stdlib/constants/float32/exponent_mask.h" #include static const double ZERO = 0.00000000000000000000e+00; // 0x00000000, 0x00000000 static const double TWO24 = 1.67772160000000000000e+07; // 0x41700000, 0x00000000 static const double TWON24 = 5.96046447753906250000e-08; // 0x3E700000, 0x00000000 static const double INVPIO2 = 6.36619772367581382433e-01; // 0x3FE45F30, 0x6DC9C883 -static const double PIO2_1 = 1.57079632673412561417e+00; // 0x3FF921FB, 0x54400000 -static const double PIO2_1T = 6.07710050650619224932e-11; // 0x3DD0B461, 0x1A626331 -static const double PIO2_2 = 6.07710050630396597660e-11; // 0x3DD0B461, 0x1A600000 -static const double PIO2_2T = 2.02226624879595063154e-21; // 0x3BA3198A, 0x2E037073 -static const double PIO2_3 = 2.02226624871116645580e-21; // 0x3BA3198A, 0x2E000000 -static const double PIO2_3T = 8.47842766036889956997e-32; // 0x397B839A, 0x252049C1 +static const double PIO2_1 = 1.57079631090164184570e+00; // 0x3FF921FB, 0x50000000 +static const double PIO2_1T = 1.58932547735281966916e-08; // 0x3E5110b4, 0x611A6263 -// High word significand for π and π/2: 0x921fb = 598523 => 00000000000010010010000111111011 -static const int32_t PI_HIGH_WORD_SIGNIFICAND = 0x921fb; - -// High word for π/4: 0x3fe921fb = 1072243195 => 00111111111010010010000111111011 -static const int32_t PIO4_HIGH_WORD = 0x3fe921fb; - -// High word for 3π/4: 0x4002d97c = 1073928572 => 01000000000000101101100101111100 -static const int32_t THREE_PIO4_HIGH_WORD = 0x4002d97c; - -// High word for 5π/4: 0x400f6a7a = 1074752122 => 01000000000011110110101001111010 -static const int32_t FIVE_PIO4_HIGH_WORD = 0x400f6a7a; - -// High word for 6π/4: 0x4012d97c = 1074977148 => 01000000000100101101100101111100 -static const int32_t THREE_PIO2_HIGH_WORD = 0x4012d97c; - -// High word for 7π/4: 0x4015fdbc = 1075183036 => 01000000000101011111110110111100 -static const int32_t SEVEN_PIO4_HIGH_WORD = 0x4015fdbc; - -// High word for 8π/4: 0x401921fb = 1075388923 => 01000000000110010010000111111011 -static const int32_t TWO_PI_HIGH_WORD = 0x401921fb; - -// High word for 9π/4: 0x401c463b = 1075594811 => 01000000000111000100011000111011 -static const int32_t NINE_PIO4_HIGH_WORD = 0x401c463b; - -// 2^20*π/2 = 1647099.3291652855 => 0100000100111001001000011111101101010100010001000010110100011000 => high word => 0x413921fb = 1094263291 => 01000001001110010010000111111011 -static const int32_t MEDIUM = 0x413921fb; - -// Exponent mask (2047 => 0x7ff): -static const int32_t EXPONENT_MASK = 0x7ff; +// 2^28*π/2 = 421657428.2663131 => 0100000110111001001000011111101101010100010001000010110100011000 => high word => 0x4dc90fdb = 1102651899 => 01000001101110010010000111111011 +static const int32_t MEDIUM = 0x4dc90fdb; /* @@ -122,7 +89,7 @@ static const double PIO2[] = { }; /** -* Returns the last three binary digits of `N` with `y = x - Nπ/2` so that `|y| < π/2`. +* Returns the last three binary digits of `N` with `y = x - Nπ/2` so that `|y| < π/2` (single-precision). * * ## Method * @@ -232,7 +199,7 @@ static const double PIO2[] = { * @param nx dimension of `x[]` * @return last 3 binary digits */ -int32_t rempio2Kernel( const double* x, double *y, int32_t e0, int32_t nx ) { +int32_t rempio2fKernel( const double* x, double *y, int32_t e0, int32_t nx ) { double F[ 20 ] = { 0.0 }; double Q[ 20 ] = { 0.0 }; int32_t IQ[ 20 ]; @@ -420,207 +387,62 @@ int32_t rempio2Kernel( const double* x, double *y, int32_t e0, int32_t nx ) { } else { y[ 0 ] = -fw; } - fw = FQ[ 0 ] - fw; - for ( i = 1; i <= jz; i++ ) { - fw += FQ[i]; - } - if ( ih == 0 ) { - y[ 1 ] = fw; - } else { - y[ 1 ] = -fw; - } return n & 7; } /** -* Computes `x - nπ/2 = r`. -* -* ## Notes -* -* - Returns `n` and stores the remainder `r` as two numbers `rem1` and `rem2`, such that `rem1+rem2 = r`. +* Computes `x - nπ/2 = r` (single-precision). * * @param x input value -* @param rem1 remainder element 1 -* @param rem2 remainder element 2 +* @param rem remainder element * @return factor of `π/2` * * @example * #include * -* double rem1; -* double rem2; -* int32_t n = stdlib_base_rempio2( 128.0, &rem1, &rem2 ); +* double rem; +* int32_t n = stdlib_base_rempio2f( 128.0f, &rem ); */ -int32_t stdlib_base_rempio2( const double x, double *rem1, double *rem2 ) { - double TX[ 3 ]; - double TY[ 2 ]; - uint32_t uhigh; - uint32_t ulow; +int32_t stdlib_base_rempio2f( const float x, double *rem ) { + double TX[ 1 ]; + double TY[ 1 ]; uint32_t uhx; - int32_t high; - int32_t low; int32_t ix; int32_t hx; int32_t e0; - int32_t nx; - int32_t i; - int32_t j; int32_t n; - double z; double w; - double t; double r; + float z; // high word of x - stdlib_base_float64_get_high_word( x, &uhx ); + stdlib_base_float32_to_word( x, &uhx ); hx = ( int32_t )uhx; - ix = hx & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK; + ix = hx & STDLIB_CONSTANT_FLOAT32_ABS_MASK; - // Case: |x| ~<= π/4 (no need for reduction) - if ( ix <= PIO4_HIGH_WORD ) { - *rem1 = x; - *rem2 = 0; - return 0; - } - // Case: |x| ~<= 5π/4 - if ( ix <= FIVE_PIO4_HIGH_WORD ) { - // Case: |x| ~= π/2 or π - if ( ( ix & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_SIGNIFICAND_MASK ) == PI_HIGH_WORD_SIGNIFICAND ) { - // Cancellation => use medium case - goto medium; - } - // Case: |x| ~<= 3π/4 - if ( ix <= THREE_PIO4_HIGH_WORD ) { - if ( hx > 0 ) { - // one round good to 85 bits - z = x - PIO2_1; - *rem1 = z - PIO2_1T; - *rem2 = ( z - *rem1 ) - PIO2_1T; - return 1; - } else { - z = x + PIO2_1; - *rem1 = z + PIO2_1T; - *rem2 = ( z - *rem1 ) + PIO2_1T; - return -1; - } - } else { - if ( hx > 0 ) { - z = x - ( 2.0 * PIO2_1 ); - *rem1 = z - ( 2 * PIO2_1T ); - *rem2 = ( z - *rem1 ) - ( 2 * PIO2_1T ); - return 2; - } else { - z = x + ( 2.0 * PIO2_1 ); - *rem1 = z + ( 2.0 * PIO2_1T ); - *rem2 = ( z - *rem1 ) + ( 2.0 * PIO2_1T ); - return -2; - } - } - } - // Case: |x| ~<= 9π/4 - if ( ix <= NINE_PIO4_HIGH_WORD ) { - // Case: |x| ~<= 7π/4 - if ( ix <= SEVEN_PIO4_HIGH_WORD ) { - // Case: |x| ~= 3π/2 - if ( ix == THREE_PIO2_HIGH_WORD ) { - goto medium; - } - if ( hx > 0 ) { - z = x - ( 3 * PIO2_1 ); - *rem1 = z - ( 3 * PIO2_1T ); - *rem2 = ( z - *rem1 ) - ( 3 * PIO2_1T ); - return 3; - } else { - z = x + ( 3 * PIO2_1 ); - *rem1 = z + ( 3 * PIO2_1T ); - *rem2 = ( z - *rem1 ) + ( 3.0 * PIO2_1T ); - return -3; - } - } else { - // Case: |x| ~= 4π/2 - if ( ix == TWO_PI_HIGH_WORD ) { - goto medium; - } - if ( hx > 0 ) { - z = x - ( 4 * PIO2_1 ); - *rem1 = z - ( 4 * PIO2_1T ); - *rem2 = ( z - *rem1 ) - ( 4 * PIO2_1T ); - return 4; - } else { - z = x + ( 4 * PIO2_1 ); - *rem1 = z + ( 4 * PIO2_1T ); - *rem2 = ( z - *rem1 ) + ( 4 * PIO2_1T ); - return -4; - } - } - } - // Case: |x| ~< 2^20*π/2 (medium size) + // Case: |x| ~< 2^28*π/2 (medium size) if ( ix < MEDIUM ) { -medium: - n = stdlib_base_round( x * INVPIO2 ); + n = stdlib_base_roundf( x * INVPIO2 ); r = x - ( n * PIO2_1 ); w = n * PIO2_1T; - - // First rounding (good to 85 bits)... - j = ix >> 20; - *rem1 = r - w; - stdlib_base_float64_get_high_word( *rem1, &uhigh ); - high = ( int32_t )uhigh; - i = j - ( ( high >> 20 ) & EXPONENT_MASK ); - - // Check if a second iteration is needed (good to 118 bits)... - if ( i > 16 ) { - t = r; - w = n * PIO2_2; - r = t - w; - w = ( n * PIO2_2T ) - ( ( t - r ) - w ); - *rem1 = r - w; - stdlib_base_float64_get_high_word( *rem1, &uhigh ); - high = ( int32_t )uhigh; - i = j - ( ( high >> 20 ) & EXPONENT_MASK ); - - // Check if a third iteration is needed (151 bits accumulated)... - if ( i > 49 ) { - // will cover all possible cases - t = r; - w = n * PIO2_3; - r = t - w; - w = ( n * PIO2_3T ) - ( ( t - r ) - w ); - *rem1 = r - w; - } - } - *rem2 = ( r - *rem1 ) - w; + *rem = r - w; return n; } // Case: x is NaN or infinity - if( ix >= STDLIB_CONSTANT_FLOAT64_HIGH_WORD_EXPONENT_MASK ) { - *rem1 = 0.0 / 0.0; // NaN - *rem2 = 0.0 / 0.0; // NaN + if( ix >= STDLIB_CONSTANT_FLOAT32_EXPONENT_MASK ) { + *rem = 0.0 / 0.0; // NaN return 0; } - // Set z = scalbn(|x|, ilogb(x)-23)... - stdlib_base_float64_get_low_word( x, &ulow ); - low = ( int32_t )ulow; - e0 = ( ix >> 20 ) - 1046; // `e0 = ilogb(z) - 23` => unbiased exponent minus 23 - stdlib_base_float64_from_words( ix - ( int32_t ) ( e0 << 20 ), low, &z ); - for ( i = 0; i < 2; i++ ) { - TX[ i ] = ( double )( ( int32_t )z ); - z = ( z - TX[ i ] ) * TWO24; - } - TX[ 2 ] = z; - nx = 3; - while ( TX[ nx - 1 ] == ZERO ) { - // Skip zero term... - nx--; - } - n = rempio2Kernel( TX, TY, e0, nx); + // Set z = scalbn(|x|, ilogb(|x|)-23)... + e0 = ( ix >> 23 ) - 150; // `e0 = ilogb(|x|) - 23` => unbiased exponent minus 23 + stdlib_base_float32_from_word( ix - ( int32_t ) ( e0 << 23 ), &z ); + TX[ 0 ] = z; + n = rempio2fKernel( TX, TY, e0, 1 ); if ( hx < 0 ) { - *rem1 = -TY[ 0 ]; - *rem2 = -TY[ 1 ]; + *rem = -TY[ 0 ]; return -n; } - *rem1 = TY[ 0 ]; - *rem2 = TY[ 1 ]; + *rem = TY[ 0 ]; return n; } diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js index 432dabcc8c30..1bcd0f5fc964 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js @@ -23,11 +23,11 @@ var tape = require( 'tape' ); var isInteger = require( '@stdlib/assert/is-integer' ); var isNumber = require( '@stdlib/assert/is-number' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var incrspace = require( '@stdlib/array/base/incrspace' ); var linspace = require( '@stdlib/array/base/linspace' ); var randu = require( '@stdlib/random/base/randu' ); -var abs = require( '@stdlib/math/base/special/absf' ); +var absf = require( '@stdlib/math/base/special/absf' ); var pow = require( '@stdlib/math/base/special/pow' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); @@ -35,39 +35,39 @@ var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); var PIO2 = require( '@stdlib/constants/float32/half-pi' ); var PIO4 = require( '@stdlib/constants/float32/fourth-pi' ); -var rempio2 = require( './../lib' ); +var rempio2f = require( './../lib' ); // TESTS // tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof rempio2, 'function', 'main export is a function' ); + t.strictEqual( typeof rempio2f, 'function', 'main export is a function' ); t.end(); }); -tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided `NaN`', function test( t ) { +tape( 'the function returns `0` and sets `y[0]` to `NaN` if provided `NaN`', function test( t ) { var y = [ 0.0 ]; - var n = rempio2( NaN, y ); + var n = rempio2f( NaN, y ); t.strictEqual( n, 0.0, 'returns expected value' ); - t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.strictEqual( isnanf( y[0] ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided positive or negative infinity', function test( t ) { +tape( 'the function returns `0` and sets `y[0]` to `NaN` if provided positive or negative infinity', function test( t ) { var y = [ 0.0 ]; - var n = rempio2( PINF, y ); + var n = rempio2f( PINF, y ); t.strictEqual( n, 0.0, 'returns expected value' ); - t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.strictEqual( isnanf( y[0] ), true, 'returns expected value' ); y = [ 0.0 ]; - n = rempio2( NINF, y ); + n = rempio2f( NINF, y ); t.strictEqual( n, 0.0, 'returns expected value' ); - t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); + t.strictEqual( isnanf( y[0] ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (positive)', function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (positive)', function test( t ) { var delta; var tol; var x; @@ -79,20 +79,20 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating y = [ 0.0 ]; for ( i = 0; i < 200; i++ ) { x = float64ToFloat32( randu()*100.0 ); - n = rempio2( x, y ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[ 0 ] ), true, 'returns expected value' ); z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); - delta = abs( z - x ); - tol = EPS * abs( x ); + delta = absf( z - x ); + tol = EPS * absf( x ); t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny positive)', function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny positive)', function test( t ) { var delta; var tol; var x; @@ -104,20 +104,20 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating y = [ 0.0 ]; for ( i = 0; i < 200; i++ ) { x = float64ToFloat32( randu()*1.0e-100 ); - n = rempio2( x, y ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); - delta = abs( z - x ); - tol = EPS * abs( x ); + delta = absf( z - x ); + tol = EPS * absf( x ); t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (negative)', function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (negative)', function test( t ) { var delta; var tol; var x; @@ -129,20 +129,20 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating y = [ 0.0 ]; for ( i = 0; i < 200; i++ ) { x = float64ToFloat32( -100.0 * randu() ); - n = rempio2( x, y ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); - delta = abs( z - x ); - tol = EPS * abs( x ); + delta = absf( z - x ); + tol = EPS * absf( x ); t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny negative)', function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny negative)', function test( t ) { var delta; var tol; var x; @@ -154,20 +154,20 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating y = [ 0.0 ]; for ( i = 0; i < 200; i++ ) { x = float64ToFloat32( -1.0e-100 * randu() ); - n = rempio2( x, y ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); - delta = abs( z - x ); - tol = EPS * abs( x ); + delta = absf( z - x ); + tol = EPS * absf( x ); t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (multiples of π/4)', function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (multiples of π/4)', function test( t ) { var delta; var tol; var x; @@ -180,20 +180,20 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); - n = rempio2( x[i], y ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); - delta = abs( z - x[i] ); - tol = EPS * abs( x[i] ); + delta = absf( z - x[i] ); + tol = EPS * absf( x[i] ); t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'for large positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { +tape( 'for large positive input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', function test( t ) { var x; var y; var n; @@ -203,7 +203,7 @@ tape( 'for large positive input values, the function returns the last three bina y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); - n = rempio2( x[i], y ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); @@ -211,7 +211,7 @@ tape( 'for large positive input values, the function returns the last three bina t.end(); }); -tape( 'for large negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { +tape( 'for large negative input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', function test( t ) { var x; var y; var n; @@ -221,7 +221,7 @@ tape( 'for large negative input values, the function returns the last three bina y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); - n = rempio2( x[i], y ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); @@ -229,7 +229,7 @@ tape( 'for large negative input values, the function returns the last three bina t.end(); }); -tape( 'for huge positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { +tape( 'for huge positive input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', function test( t ) { var x; var y; var n; @@ -239,7 +239,7 @@ tape( 'for huge positive input values, the function returns the last three binar y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); - n = rempio2( x[i], y ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); @@ -247,7 +247,7 @@ tape( 'for huge positive input values, the function returns the last three binar t.end(); }); -tape( 'for huge negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', function test( t ) { +tape( 'for huge negative input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', function test( t ) { var x; var y; var n; @@ -257,7 +257,7 @@ tape( 'for huge negative input values, the function returns the last three binar y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); - n = rempio2( x[i], y ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js index aebecf791c36..84d1fcd53c6a 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js @@ -24,26 +24,27 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isInteger = require( '@stdlib/assert/is-integer' ); var isNumber = require( '@stdlib/assert/is-number' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var incrspace = require( '@stdlib/array/base/incrspace' ); var linspace = require( '@stdlib/array/base/linspace' ); var randu = require( '@stdlib/random/base/randu' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var absf = require( '@stdlib/math/base/special/absf' ); var pow = require( '@stdlib/math/base/special/pow' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); -var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var PIO2 = require( '@stdlib/constants/float64/half-pi' ); -var PIO4 = require( '@stdlib/constants/float64/fourth-pi' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var PIO2 = require( '@stdlib/constants/float32/half-pi' ); +var PIO4 = require( '@stdlib/constants/float32/fourth-pi' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); // VARIABLES // -var rempio2 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var rempio2f = tryRequire( resolve( __dirname, './../lib/native.js' ) ); var opts = { - 'skip': ( rempio2 instanceof Error ) + 'skip': ( rempio2f instanceof Error ) }; @@ -51,35 +52,32 @@ var opts = { tape( 'main export is a function', opts, function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof rempio2, 'function', 'main export is a function' ); + t.strictEqual( typeof rempio2f, 'function', 'main export is a function' ); t.end(); }); -tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided `NaN`', opts, function test( t ) { - var y = new Float64Array( [ 0.0, 0.0 ] ); - var n = rempio2( NaN, y ); +tape( 'the function returns `0` and sets `y[0]` to `NaN` if provided `NaN`', opts, function test( t ) { + var y = new Float64Array( [ 0.0 ] ); + var n = rempio2f( NaN, y ); t.strictEqual( n, 0.0, 'returns expected value' ); - t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( y[1] ), true, 'returns expected value' ); + t.strictEqual( isnanf( y[0] ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provided positive or negative infinity', opts, function test( t ) { - var y = new Float64Array( [ 0.0, 0.0 ] ); - var n = rempio2( PINF, y ); +tape( 'the function returns `0` and sets `y[0]` to `NaN` if provided positive or negative infinity', opts, function test( t ) { + var y = new Float64Array( [ 0.0 ] ); + var n = rempio2f( PINF, y ); t.strictEqual( n, 0.0, 'returns expected value' ); - t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( y[1] ), true, 'returns expected value' ); + t.strictEqual( isnanf( y[0] ), true, 'returns expected value' ); - y = new Float64Array( [ 0.0, 0.0 ] ); - n = rempio2( NINF, y ); + y = new Float64Array( [ 0.0 ] ); + n = rempio2f( NINF, y ); t.strictEqual( n, 0.0, 'returns expected value' ); - t.strictEqual( isnan( y[0] ), true, 'returns expected value' ); - t.strictEqual( isnan( y[1] ), true, 'returns expected value' ); + t.strictEqual( isnanf( y[0] ), true, 'returns expected value' ); t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (positive)', opts, function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (positive)', opts, function test( t ) { var delta; var tol; var x; @@ -88,24 +86,23 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating var n; var i; - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < 200; i++ ) { - x = randu()*100.0; - n = rempio2( x, y ); + x = float64ToFloat32( randu()*100.0 ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); + t.strictEqual( isNumber( y[ 0 ] ), true, 'returns expected value' ); - z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = absf( z - x ); + tol = EPS * absf( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny positive)', opts, function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny positive)', opts, function test( t ) { var delta; var tol; var x; @@ -114,24 +111,23 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating var n; var i; - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < 200; i++ ) { - x = randu()*1.0e-100; - n = rempio2( x, y ); + x = float64ToFloat32( randu()*1.0e-100 ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); - z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = absf( z - x ); + tol = EPS * absf( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (negative)', opts, function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (negative)', opts, function test( t ) { var delta; var tol; var x; @@ -140,24 +136,23 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating var n; var i; - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < 200; i++ ) { - x = -100.0 * randu(); - n = rempio2( x, y ); + x = float64ToFloat32( -100.0 * randu() ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); - z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = absf( z - x ); + tol = EPS * absf( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny negative)', opts, function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (tiny negative)', opts, function test( t ) { var delta; var tol; var x; @@ -166,24 +161,23 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating var n; var i; - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < 200; i++ ) { - x = -1.0e-100 * randu(); - n = rempio2( x, y ); + x = float64ToFloat32( -1.0e-100 * randu() ); + n = rempio2f( x, y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); - z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = absf( z - x ); + tol = EPS * absf( x ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (multiples of π/4)', opts, function test( t ) { +tape( 'the function returns `n` and stores `r` as a double-precision floating point number in `y` such that `x - nπ/2 = r` (multiples of π/4)', opts, function test( t ) { var delta; var tol; var x; @@ -193,89 +187,89 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating var i; x = incrspace( -10.0*PIO4, 10.0*PIO4, PIO4 ); - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[i], y ); + x[i] = float64ToFloat32( x[i] ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); - z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x[i] ); - tol = EPS * abs( x[i] ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + z = float64ToFloat32( ( PIO2*n ) + ( y[0] ) ); + delta = absf( z - x[i] ); + tol = EPS * absf( x[i] ); + t.ok( delta <= tol, 'within tolerance. x: '+x+'. n: '+n+'. y: '+y+'. z: '+z+'. delta: '+delta+'. tol: '+tol+'.' ); } t.end(); }); -tape( 'for large positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { +tape( 'for large positive input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', opts, function test( t ) { var x; var y; var n; var i; - x = linspace( pow( 2.0, 20 )*PIO2, pow( 2.0, 60 )*PIO2, 4000 ); - y = new Float64Array( [ 0.0, 0.0 ] ); + x = linspace( pow( 2.0, 28 )*PIO2, pow( 2.0, 60 )*PIO2, 4000 ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[i], y ); + x[i] = float64ToFloat32( x[i] ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); } t.end(); }); -tape( 'for large negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { +tape( 'for large negative input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', opts, function test( t ) { var x; var y; var n; var i; - x = linspace( -pow( 2.0, 20 )*PIO2, -pow( 2.0, 60 )*PIO2, 4000 ); - y = new Float64Array( [ 0.0, 0.0 ] ); + x = linspace( -pow( 2.0, 28 )*PIO2, -pow( 2.0, 60 )*PIO2, 4000 ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[i], y ); + x[i] = float64ToFloat32( x[i] ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); } t.end(); }); -tape( 'for huge positive input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { +tape( 'for huge positive input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', opts, function test( t ) { var x; var y; var n; var i; x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 1020 )*PIO2, 6000 ); - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[i], y ); + x[i] = float64ToFloat32( x[i] ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); } t.end(); }); -tape( 'for huge negative input values, the function returns the last three binary digits of `n` and stores `r` as two double-precision floating point numbers in `y`', opts, function test( t ) { +tape( 'for huge negative input values, the function returns the last three binary digits of `n` and stores `r` as a double-precision floating point number in `y`', opts, function test( t ) { var x; var y; var n; var i; x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 1020 )*PIO2, 6000 ); - y = new Float64Array( [ 0.0, 0.0 ] ); + y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { - n = rempio2( x[i], y ); + x[i] = float64ToFloat32( x[i] ); + n = rempio2f( x[i], y ); t.strictEqual( isInteger( n ), true, 'returns expected value' ); t.strictEqual( isNumber( y[0] ), true, 'returns expected value' ); - t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); t.strictEqual( n < 8, true, 'returns expected value' ); } t.end(); From f36fdd0d3805b93e6d37e5ba4295d936d28a2483 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Tue, 18 Mar 2025 06:35:13 +0000 Subject: [PATCH 3/6] chore: update copyright years --- lib/node_modules/@stdlib/math/base/special/rempio2f/README.md | 2 +- .../@stdlib/math/base/special/rempio2f/benchmark/benchmark.js | 2 +- .../math/base/special/rempio2f/benchmark/benchmark.native.js | 2 +- .../math/base/special/rempio2f/benchmark/c/native/Makefile | 2 +- .../math/base/special/rempio2f/benchmark/c/native/benchmark.c | 2 +- lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp | 2 +- .../@stdlib/math/base/special/rempio2f/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/rempio2f/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/rempio2f/examples/c/Makefile | 2 +- .../@stdlib/math/base/special/rempio2f/examples/c/example.c | 2 +- .../@stdlib/math/base/special/rempio2f/examples/index.js | 2 +- .../@stdlib/math/base/special/rempio2f/include.gypi | 2 +- .../rempio2f/include/stdlib/math/base/special/rempio2f.h | 2 +- .../@stdlib/math/base/special/rempio2f/lib/index.js | 2 +- .../@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js | 2 +- lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js | 2 +- .../@stdlib/math/base/special/rempio2f/lib/native.js | 2 +- .../@stdlib/math/base/special/rempio2f/src/Makefile | 2 +- lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c | 2 +- lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c | 2 +- .../@stdlib/math/base/special/rempio2f/test/test.js | 2 +- .../@stdlib/math/base/special/rempio2f/test/test.native.js | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md b/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md index aa8b330348d8..3930f2d9b80a 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js index b6a6f212d261..30c551e3f1d6 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js index 6bec8c48eb6c..b1dbe21ad639 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile index f69e9da2b4d3..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c index b88bea2af24d..a93cbc3a6659 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/benchmark/c/native/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp b/lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp index ec3992233442..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts index ce985c1a8008..0c7f7e923d83 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts index 2760b8a4afbb..a69b1b3bfded 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile index 6aed70daf167..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c index 1e3f0d3d4c1a..dbf59c311e59 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js index 5147c46fbdba..4923ed319205 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi b/lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi index 575cb043c0bf..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h b/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h index a0b879526a67..130efc25faf5 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/include/stdlib/math/base/special/rempio2f.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js index 1d259dde62d8..bfeb6f7ef601 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js index d75712c15248..a6c92d4d49a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js index 0057c5f5f804..b5a49236e49d 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js index 0e590406aa69..7657084f4b54 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile index bcf18aa46655..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c index 881de4bed14c..580898e38dbb 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c index ae547a0061b3..df5b8ebdd9dd 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js index 1bcd0f5fc964..65a2121c8a33 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js index 84d1fcd53c6a..35702c569d1d 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 296b44758d01a9337cd25bfc8c6a18fb13450782 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 18 Mar 2025 00:15:17 -0700 Subject: [PATCH 4/6] chore: apply suggestions from review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/rempio2f/lib/main.js | 2 +- .../@stdlib/math/base/special/rempio2f/test/test.js | 4 ++-- .../@stdlib/math/base/special/rempio2f/test/test.native.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js index b5a49236e49d..68e565116c53 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/main.js @@ -18,7 +18,7 @@ * * ## Notice * -* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/e_rem_pio2.c}. The implementation follows the original, but has been modified for JavaScript. +* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_rem_pio2f.c}. The implementation follows the original, but has been modified for JavaScript. * * ```text * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js index 65a2121c8a33..afd61fce3234 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.js @@ -235,7 +235,7 @@ tape( 'for huge positive input values, the function returns the last three binar var n; var i; - x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 1020 )*PIO2, 6000 ); + x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 125 )*PIO2, 6000 ); y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); @@ -253,7 +253,7 @@ tape( 'for huge negative input values, the function returns the last three binar var n; var i; - x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 1020 )*PIO2, 6000 ); + x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 125 )*PIO2, 6000 ); y = [ 0.0 ]; for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js index 35702c569d1d..3e935a0bf446 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/test/test.native.js @@ -245,7 +245,7 @@ tape( 'for huge positive input values, the function returns the last three binar var n; var i; - x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 1020 )*PIO2, 6000 ); + x = linspace( pow( 2.0, 60 )*PIO2, pow( 2.0, 125 )*PIO2, 6000 ); y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); @@ -263,7 +263,7 @@ tape( 'for huge negative input values, the function returns the last three binar var n; var i; - x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 1020 )*PIO2, 6000 ); + x = linspace( -pow( 2.0, 60 )*PIO2, -pow( 2.0, 125 )*PIO2, 6000 ); y = new Float64Array( [ 0.0 ] ); for ( i = 0; i < x.length; i++ ) { x[i] = float64ToFloat32( x[i] ); From c5a33c66dc55d007a4604a028a02f97e02441265 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 18 Mar 2025 09:33:03 -0700 Subject: [PATCH 5/6] fix: initialisation of jk --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js | 2 +- lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js index a6c92d4d49a8..150d493508f4 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js @@ -380,7 +380,7 @@ function kernelRempio2f( x, y, e0, nx ) { var m; // Initialize `jk` for double-precision floating-point numbers: - jk = 4; + jk = 3; // Determine `jx`, `jv`, `q0` (note that `q0 < 3`): jx = nx - 1; diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c index df5b8ebdd9dd..e003bb73f5c2 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c @@ -221,7 +221,7 @@ int32_t rempio2fKernel( const double* x, double *y, int32_t e0, int32_t nx ) { double z; // Initialize `jk` for double-precision floating-point numbers: - jk = 4; + jk = 3; jp = jk; // Determine `jx`, `jv`, `q0` (note that `q0 < 3`): From 1aed4e0fde5ebc40bb4ec81b6c406d5af61db2d3 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 18 Mar 2025 09:43:55 -0700 Subject: [PATCH 6/6] chore: fix comment for jk --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../special/rempio2f/lib/kernel_rempio2f.js | 17 ++++------------- .../math/base/special/rempio2f/src/main.c | 17 ++++------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js index 150d493508f4..c7e9dbb7c7ba 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/lib/kernel_rempio2f.js @@ -52,20 +52,11 @@ var zeros = require( '@stdlib/array/base/zeros' ); * \operatorname{ipio2}[i] \cdot 2^{-24(i+1)} * ``` * -* This table must have at least `(e0-3)/24 + jk` terms. For quad precision (`e0 <= 16360`, `jk = 6`), this is `686`. +* This table must have at least `(e0-3)/24 + jk` terms. For single precision (`e0 <= 127`, `jk = 3`), this is `9`. */ var IPIO2 = [ 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, - 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, - 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, - 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, - 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, - 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, - 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, - 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, - 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, - 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, - 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B + 0x95993C, 0x439041, 0xFE5163 ]; // Double precision array, obtained by cutting `π/2` into `24` bits chunks... @@ -364,7 +355,7 @@ function compute( x, y, jz, q, q0, jk, jv, jx, f ) { * @private * @param {PositiveNumber} x - input value * @param {(Array|TypedArray|Object)} y - remainder element -* @param {PositiveInteger} e0 - the exponent of `x[0]` (must be <= 16360) +* @param {PositiveInteger} e0 - the exponent of `x[0]` (must be <= 127) * @param {PositiveInteger} nx - dimension of `x[]` * @returns {number} last three binary digits of `N` */ @@ -379,7 +370,7 @@ function kernelRempio2f( x, y, e0, nx ) { var j; var m; - // Initialize `jk` for double-precision floating-point numbers: + // Initialize `jk` for single-precision floating-point numbers: jk = 3; // Determine `jx`, `jv`, `q0` (note that `q0 < 3`): diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c index e003bb73f5c2..6291b52a4b7a 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/rempio2f/src/main.c @@ -60,20 +60,11 @@ static const int32_t MEDIUM = 0x4dc90fdb; * \operatorname{ipio2}[i] \cdot 2^{-24(i+1)} * ``` * -* This table must have at least `(e0-3)/24 + jk` terms. For quad precision (`e0 <= 16360`, `jk = 6`), this is `686`. +* This table must have at least `(e0-3)/24 + jk` terms. For single precision (`e0 <= 127`, `jk = 3`), this is `9`. */ static const int32_t IPIO2[] = { 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, - 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, - 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, - 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, - 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, - 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, - 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, - 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, - 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, - 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, - 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B + 0x95993C, 0x439041, 0xFE5163 }; // Double precision array, obtained by cutting `π/2` into `24` bits chunks... @@ -195,7 +186,7 @@ static const double PIO2[] = { * * @param x input value * @param y output array to store the remainder -* @param e0 the exponent of `x[0]` (must be <= 16360) +* @param e0 the exponent of `x[0]` (must be <= 127) * @param nx dimension of `x[]` * @return last 3 binary digits */ @@ -220,7 +211,7 @@ int32_t rempio2fKernel( const double* x, double *y, int32_t e0, int32_t nx ) { double fw; double z; - // Initialize `jk` for double-precision floating-point numbers: + // Initialize `jk` for single-precision floating-point numbers: jk = 3; jp = jk;