From 8f895ae16080be2b98bacc8780e8dacaceda9216 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sat, 23 Mar 2024 08:06:38 +0000 Subject: [PATCH] Update artifacts --- .../special/fast/uint32-log2/coverage.ndjson | 1 + math/base/special/fast/uint32-log2/index.html | 146 ++++++ .../special/fast/uint32-log2/index.js.html | 223 +++++++++ .../special/fast/uint32-log2/main.js.html | 472 ++++++++++++++++++ .../special/fast/uint32-log2/native.js.html | 247 +++++++++ 5 files changed, 1089 insertions(+) create mode 100644 math/base/special/fast/uint32-log2/coverage.ndjson create mode 100644 math/base/special/fast/uint32-log2/index.html create mode 100644 math/base/special/fast/uint32-log2/index.js.html create mode 100644 math/base/special/fast/uint32-log2/main.js.html create mode 100644 math/base/special/fast/uint32-log2/native.js.html diff --git a/math/base/special/fast/uint32-log2/coverage.ndjson b/math/base/special/fast/uint32-log2/coverage.ndjson new file mode 100644 index 000000000..be43f4413 --- /dev/null +++ b/math/base/special/fast/uint32-log2/coverage.ndjson @@ -0,0 +1 @@ +[229,229,100,10,10,100,2,2,100,229,229,100,"c17484ad1830ddfdb3abbe96589b406096e389e1","2024-03-23 01:04:40 -0700"] diff --git a/math/base/special/fast/uint32-log2/index.html b/math/base/special/fast/uint32-log2/index.html new file mode 100644 index 000000000..34ef9c770 --- /dev/null +++ b/math/base/special/fast/uint32-log2/index.html @@ -0,0 +1,146 @@ + + + + +
++ 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% | +46/46 | +100% | +1/1 | +100% | +0/0 | +100% | +46/46 | +
main.js | +
+
+ |
+ 100% | +129/129 | +100% | +7/7 | +100% | +1/1 | +100% | +129/129 | +
native.js | +
+
+ |
+ 100% | +54/54 | +100% | +2/2 | +100% | +1/1 | +100% | +54/54 | +
+ 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 | 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) 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'; + +/** +* Integer binary logarithm (base two). +* +* @module @stdlib/math/base/special/fast/uint32-log2 +* +* @example +* var log2Uint32 = require( '@stdlib/math/base/special/fast/uint32-log2' ); +* +* var v = log2Uint32( 4 >>> 0 ); +* // returns 2 +* +* v = log2Uint32( 8 >>> 0 ); +* // returns 3 +* +* v = log2Uint32( 9 >>> 0 ); +* // returns 3 +*/ + +// MODULES // + +var log2Uint32 = require( './main.js' ); + + +// EXPORTS // + +module.exports = log2Uint32; + |
+ 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 | 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 +5032x +5032x +5032x +5032x +5032x +5032x +5014x +5014x +5014x +5032x +5032x +4974x +4974x +4974x +5032x +5032x +4426x +4426x +4426x +5032x +5032x +3000x +3000x +3000x +5032x +5032x +1707x +1707x +1707x +5032x +5032x +1x +1x +1x +1x +1x + | /** +* @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'; + +// VARIABLES // + +// 4294901760 => 0xFFFF0000 => 11111111111111110000000000000000 +var B4 = 0xFFFF0000 >>> 0; // asm type annotation + +// 65280 => 0xFF00 => 00000000000000001111111100000000 +var B3 = 0xFF00 >>> 0; // asm type annotation + +// 240 => 0xF0 => 00000000000000000000000011110000 +var B2 = 0xF0 >>> 0; // asm type annotation + +// 12 => 0xC => 00000000000000000000000000001100 +var B1 = 0xC >>> 0; // asm type annotation + +// 2 => 0x2 => 00000000000000000000000000000010 +var B0 = 0x2 >>> 0; // asm type annotation + +// 16 => 00000000000000000000000000010000 +var S4 = 16 >>> 0; // asm type annotation + +// 8 => 00000000000000000000000000001000 +var S3 = 8 >>> 0; // asm type annotation + +// 4 => 00000000000000000000000000000100 +var S2 = 4 >>> 0; // asm type annotation + +// 2 => 00000000000000000000000000000010 +var S1 = 2 >>> 0; // asm type annotation + +// 1 => 00000000000000000000000000000001 +var S0 = 1 >>> 0; // asm type annotation + + +// MAIN // + +/** +* Computes an integer binary logarithm (base two). +* +* ## Method +* +* 1. Note that the largest unsigned 32-bit integer is `4294967295`, which is `2^{32}-1`. Hence, the integer binary logarithm cannot exceed `31` (i.e., `16 + 8 + 4 + 2 + 1`), which corresponds to the bit sequence +* +* ```binarystring +* 00000000000000000000000000011111 +* ``` +* +* 2. Initialize a return variable with the value zero. +* +* 3. If at least one of the first sixteen most significant bits of the input 32-bit integer `x` is turned on, we know that the power to which the number `2` must be raised to obtain `x` is at least `16` (i.e., `x > 65536`). Hence, activate the corresponding bit of the return variable. Mutate `x` by shifting sixteen bits to the right, discarding the bits shifted off. +* +* 4. Carry out the following steps with `B` in `[ 8, 4, 2, 1 ]`: +* +* - If at least one of the next `B` most significant bits of the current `x` is turned on, we know that the power to which the number `2` must be raised to obtain `x` has to be increased by `B`. +* - Activate the bit of the return variable that corresponds to `B`. +* - Mutate `x` by shifting `B` bits to the right, discarding the bits shifted off. +* +* 5. The final value of the return variable is the integer binary logarithm of `x`. +* +* @param {uinteger32} x - input value +* @returns {uinteger32} integer binary logarithm +* +* @example +* var v = log2( 4 >>> 0 ); +* // returns 2 +* +* @example +* var v = log2( 8 >>> 0 ); +* // returns 3 +* +* @example +* var v = log2( 9 >>> 0 ); +* // returns 3 +*/ +function log2( x ) { + var out = 0 >>> 0; // asm type annotation + var y = x >>> 0; // asm type annotation + + // `x >= 65536`: + if ( y & B4 ) { + y >>>= S4; + out |= S4; + } + // `x >= 256`: + if ( y & B3 ) { + y >>>= S3; + out |= S3; + } + // `x >= 16`: + if ( y & B2 ) { + y >>>= S2; + out |= S2; + } + // `x >= 4`: + if ( y & B1 ) { + y >>>= S1; + out |= S1; + } + // `x >= 2`: + if ( y & B0 ) { + y >>>= S0; + out |= S0; + } + return out; +} + + +// EXPORTS // + +module.exports = log2; + |
+ 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 +5032x +5032x +5032x +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 an integer binary logarithm (base two). +* +* @private +* @param {uinteger32} x - input value +* @returns {uinteger32} integer binary logarithm +* +* @example +* var out = log2Uint32( 4 ); +* // returns 2 +* +* @example +* var out = log2Uint32( 8 ); +* // returns 3 +* +* @example +* var out = log2Uint32( 9 ); +* // returns 3 +*/ +function log2Uint32( x ) { + return addon( x ); +} + + +// EXPORTS // + +module.exports = log2Uint32; + |