From 479bab59b145111665c66b0cf356dee34e722e86 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 14 Apr 2024 10:09:21 +0000 Subject: [PATCH] Update artifacts --- .../base/special/kernel-log1p/coverage.ndjson | 1 + math/base/special/kernel-log1p/index.html | 176 ++++++ math/base/special/kernel-log1p/index.js.html | 226 +++++++ math/base/special/kernel-log1p/main.js.html | 553 ++++++++++++++++++ math/base/special/kernel-log1p/native.js.html | 247 ++++++++ .../special/kernel-log1p/polyval_p.js.html | 226 +++++++ .../special/kernel-log1p/polyval_q.js.html | 226 +++++++ 7 files changed, 1655 insertions(+) create mode 100644 math/base/special/kernel-log1p/coverage.ndjson create mode 100644 math/base/special/kernel-log1p/index.html create mode 100644 math/base/special/kernel-log1p/index.js.html create mode 100644 math/base/special/kernel-log1p/main.js.html create mode 100644 math/base/special/kernel-log1p/native.js.html create mode 100644 math/base/special/kernel-log1p/polyval_p.js.html create mode 100644 math/base/special/kernel-log1p/polyval_q.js.html diff --git a/math/base/special/kernel-log1p/coverage.ndjson b/math/base/special/kernel-log1p/coverage.ndjson new file mode 100644 index 000000000..56eaa957d --- /dev/null +++ b/math/base/special/kernel-log1p/coverage.ndjson @@ -0,0 +1 @@ +[347,351,98.8604,9,11,81.8182,4,4,100,347,351,98.8604,"dc2cd2489fc809b2e5cc690f35839f9d35a5c27f","2024-04-14 03:06:55 -0700"] diff --git a/math/base/special/kernel-log1p/index.html b/math/base/special/kernel-log1p/index.html new file mode 100644 index 000000000..18393a0a0 --- /dev/null +++ b/math/base/special/kernel-log1p/index.html @@ -0,0 +1,176 @@ + + + + +
++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
index.js | +
+
+ |
+ 100% | +47/47 | +100% | +1/1 | +100% | +0/0 | +100% | +47/47 | +
main.js | +
+
+ |
+ 100% | +156/156 | +100% | +2/2 | +100% | +1/1 | +100% | +156/156 | +
native.js | +
+
+ |
+ 100% | +54/54 | +100% | +2/2 | +100% | +1/1 | +100% | +54/54 | +
polyval_p.js | +
+
+ |
+ 95.74% | +45/47 | +66.66% | +2/3 | +100% | +1/1 | +95.74% | +45/47 | +
polyval_q.js | +
+
+ |
+ 95.74% | +45/47 | +66.66% | +2/3 | +100% | +1/1 | +95.74% | +45/47 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + | /** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]`. +* +* @module @stdlib/math/base/special/kernel-log1p +* +* @example +* var sqrt = require( '@stdlib/math/base/special/sqrt' ); +* var kernelLog1p = require( '@stdlib/math/base/special/kernel-log1p' ); +* +* var v = kernelLog1p( 1.0 ); +* // returns ~0.1931 +* +* v = kernelLog1p( sqrt( 2.0 ) ); +* // returns ~0.4672 +* +* v = kernelLog1p( NaN ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +1x +1x +1x +1x +1x + | /** +* @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 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/k_log.h}. 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 polyvalP = require( './polyval_p.js' ); +var polyvalQ = require( './polyval_q.js' ); + + +// MAIN // + +/** +* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]`. +* +* ## Method +* +* This function is a helper function for computing logarithms in base \\(e\\), and what follows describes the overall strategy for doing so. The argument reduction and adding the final term of the polynomial are done by the caller for increased accuracy when different bases are used. +* +* 1. Argument Reduction. Find \\(k\\) and \\(f\\) such that +* +* ```tex +* x = 2^k \cdot (1+f) +* ``` +* +* where \\(\sqrt(2)/2 < 1+f < \sqrt(2)\\). +* +* 2. Approximation of \\(\operatorname{log}(1+f)\\). Let +* +* ```tex +* \begin{align*} +* s &= \frac{f}{2+f} \\ +* &= 2s + \frac{2}{3} s^3 + \frac{2}{5} s^5 + \ldots \\ +* &= 2s + s R +* \end{align*} +* ``` +* +* based on +* +* ```tex +* \operatorname{log}(1+f) &= \operatorname{log}(1+s) - \operatorname{log}(1-s) +* ``` +* +* We use a special Reme algorithm on \\(\[0,0.1716]\\) to generate a polynomial of degree \\(14\\) to approximate \\(R\\). The maximum error of this polynomial approximation is bounded by \\(2^{-58.45}\\). In other words, +* +* ```tex +* R(z) ~ L_{g1} s^2 + L_{g2} s^4 + L_{g3} s^6 + L_{g4} s^8 + L_{g5} s^{10} + L_{g6} s^{12} + L_{g7} s^{14} +* ``` +* +* where the values of \\(L_{g1}\\) to \\(L_{g7}\\) are the polynomial coefficients used in the program below and +* +* ```tex +* L_{g1} s^2 + \ldots + L_{g7} s^{14} - R(z) \leq 2^{-58.45} +* ``` +* +* Note that +* +* ```tex +* 2s = f - s \cdot f = f - h_{fsq} + (s \cdot h_{fsq}) +* ``` +* +* where \\(h_{fsq} = f^{2}/2\\). +* +* In order to guarantee an error in \\(\operatorname{log}\\) below 1 ulp, we compute \\(\operatorname{log}\\) by +* +* ```tex +* \begin{align*} +* \operatorname{log}(1+f) &= f - s (f - R) & \textrm{(if f is not too large)} \\ +* \operatorname{log}(1+f) &= f - (h_{fsq} - s (h_{fsq}+R)) & \textrm{(better accuracy)} +* \end{align*} +* +* 3. Finally, +* +* ```tex +* \begin{align*} +* \operatorname{log}(x) &= k \cdot \operatorname{ln2} + \operatorname{log}(1+f) \\ +* &= k \cdot \operatorname{ln2}_{hi} + (f-(h_{fsq}-(s \cdot (h_{fsq}+R) + k \cdot \operatorname{ln2}_{lo}))) +* \end{align*} +* ``` +* +* Here, \\(\operatorname{ln2}\\) is split into two floating point numbers: +* +* ```tex +* \operatorname{ln2} = \operatorname{ln2}_{hi} + \operatorname{ln2}_{lo} +* ``` +* +* where \\(n \cdot \operatorname{ln2}_{hi}\\) is always exact for \\(|n| < 2000\\). +* +* @param {number} f - input value +* @returns {number} function value +* +* @example +* var v = kernelLog1p( 1.0 ); +* // returns ~0.1931 +* +* @example +* var v = kernelLog1p( 1.4142135623730951 ); +* // returns ~0.4672 +* +* @example +* var v = kernelLog1p( NaN ); +* // returns NaN +*/ +function kernelLog1p( f ) { + var hfsq; + var t1; + var t2; + var s; + var z; + var R; + var w; + + s = f / ( 2.0 + f ); + z = s * s; + w = z * z; + t1 = w * polyvalP( w ); + t2 = z * polyvalQ( w ); + R = t2 + t1; + hfsq = 0.5 * f * f; + return s * ( hfsq + R ); +} + + +// EXPORTS // + +module.exports = kernelLog1p; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +2x +2x +2x +1x +1x +1x +1x +1x + | /** +* @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 `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]`. +* +* @private +* @param {number} f - input value +* @returns {number} function value +* +* @example +* var v = kernelLog1p( 1.0 ); +* // returns ~0.1931 +* +* @example +* var v = kernelLog1p( 1.4142135623730951 ); +* // returns ~0.4672 +* +* @example +* var v = kernelLog1p( NaN ); +* // returns NaN +*/ +function kernelLog1p( f ) { + return addon( f ); +} + + +// EXPORTS // + +module.exports = kernelLog1p; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +2x +2x + + +2x +2x +1x +1x +1x +1x +1x + | /** +* @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. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 0.3999999999940942; + } + return 0.3999999999940942 + (x * (0.22222198432149784 + (x * 0.15313837699209373))); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +2x +2x + + +2x +2x +1x +1x +1x +1x +1x + | /** +* @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. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 0.6666666666666735; + } + return 0.6666666666666735 + (x * (0.2857142874366239 + (x * (0.1818357216161805 + (x * 0.14798198605116586))))); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = evalpoly; + |