From b04aaa0211ca53cd026b95852294f4a4d3f6b082 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sat, 13 Apr 2024 03:22:21 +0000 Subject: [PATCH] Update artifacts --- math/base/tools/lucaspoly/cache.js.html | 169 +++++++++ .../base/tools/lucaspoly/coefficients.js.html | 340 ++++++++++++++++++ math/base/tools/lucaspoly/coverage.ndjson | 1 + math/base/tools/lucaspoly/factory.js.html | 316 ++++++++++++++++ math/base/tools/lucaspoly/index.html | 176 +++++++++ math/base/tools/lucaspoly/index.js.html | 259 +++++++++++++ math/base/tools/lucaspoly/main.js.html | 265 ++++++++++++++ 7 files changed, 1526 insertions(+) create mode 100644 math/base/tools/lucaspoly/cache.js.html create mode 100644 math/base/tools/lucaspoly/coefficients.js.html create mode 100644 math/base/tools/lucaspoly/coverage.ndjson create mode 100644 math/base/tools/lucaspoly/factory.js.html create mode 100644 math/base/tools/lucaspoly/index.html create mode 100644 math/base/tools/lucaspoly/index.js.html create mode 100644 math/base/tools/lucaspoly/main.js.html diff --git a/math/base/tools/lucaspoly/cache.js.html b/math/base/tools/lucaspoly/cache.js.html new file mode 100644 index 000000000..10ae9458d --- /dev/null +++ b/math/base/tools/lucaspoly/cache.js.html @@ -0,0 +1,169 @@ + + + + +
++ 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 | 3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x + | /** +* @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'; + +// MAIN // + +var cache = {}; + + +// EXPORTS // + +module.exports = cache; + |
+ 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 | 3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +332x +332x +332x +332x +332x +332x +332x +332x +332x +332x +332x +332x +332x +162x +162x +162x +3x +162x +159x +6037x +6037x +159x +159x +159x +159x +3058x +3058x +3058x +3058x +3058x +159x +162x +162x +162x +332x +332x +3x +3x +3x +3x +3x + | /** +* @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 binomcoef = require( '@stdlib/math/base/special/binomcoef' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var ceil = require( '@stdlib/math/base/special/ceil' ); +var cache = require( './cache.js' ); + + +// MAIN // + +/** +* Computes polynomial coefficients. +* +* ## Notes +* +* - Coefficients are computed via a (1,2)-Pascal triangle (i.e., Lucas triangle). For more details, see [Lucas polynomials][oeis-lucas-polynomials] and [Lucas triangle][oeis-lucas-triangle]. +* +* [oeis-lucas-polynomials]: https://oeis.org/wiki/Lucas_polynomials +* [oeis-lucas-triangle]: https://oeis.org/wiki/Lucas_triangle +* +* @private +* @param {NonNegativeInteger} n - Lucas polynomial for which to compute coefficients +* @returns {NonNegativeIntegerArray} polynomial coefficients +*/ +function coefficients( n ) { + var coefs; + var half; + var high; + var low; + var p; + var a; + var b; + var m; + var i; + + coefs = cache[ n ]; + if ( coefs === void 0 ) { + m = n + 1; + coefs = new Array( m ); + if ( n === 0 ) { + coefs[ 0 ] = 2.0; + } else { + for ( i = 0; i < m; i++ ) { + coefs[ i ] = 0.0; + } + half = n / 2; + high = ceil( half ); + low = floor( half ); + for ( i = 0; i <= low; i++ ) { + p = (2*i) + (n%2); + a = 2.0 * binomcoef( high+i-1, low-i-1 ); + b = binomcoef( high+i-1, low-i ); + coefs[ p ] += a + b; + } + } + // Memoize the coefficients: + cache[ n ] = coefs; + } + return coefs; +} + + +// EXPORTS // + +module.exports = coefficients; + |
+ 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 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +162x +162x +162x +162x +162x +162x +162x +162x +162x +162x +162x +162x +124x +124x +38x +38x +38x +38x +38x +38x +38x +38x +38x +38x +38x +38x +162x +2x +2x +2x +2x +2x + | /** +* @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 evalpoly = require( '@stdlib/math/base/tools/evalpoly' ).factory; +var pow = require( '@stdlib/math/base/special/pow' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var coefficients = require( './coefficients.js' ); + + +// MAIN // + +/** +* Returns a function for evaluating a Lucas polynomial. +* +* @param {integer} n - Lucas polynomial to evaluate +* @returns {Function} function for evaluating a Lucas polynomial +* +* @example +* var polyval = factory( 5 ); +* +* var v = polyval( 1.0 ); +* // returns 11.0 +* +* v = polyval( 2.0 ); +* // returns 82.0 +*/ +function factory( n ) { + var coefs; + var an; + var f; + var s; + + an = abs( n ); + coefs = coefficients( an ); + + f = evalpoly( coefs ); + s = pow( -1.0, an ); + if ( n >= 0 || s === 1.0 ) { + return f; + } + return polyval; + + /** + * Evaluates a Lucas polynomial. + * + * @private + * @param {number} x - value at which to evaluate a Lucas polynomial + * @returns {number} result + */ + function polyval( x ) { + return -1.0 * f( x ); + } +} + + +// EXPORTS // + +module.exports = factory; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
cache.js | +
+
+ |
+ 100% | +28/28 | +100% | +1/1 | +100% | +0/0 | +100% | +28/28 | +
coefficients.js | +
+
+ |
+ 100% | +85/85 | +100% | +7/7 | +100% | +1/1 | +100% | +85/85 | +
factory.js | +
+
+ |
+ 100% | +77/77 | +100% | +6/6 | +100% | +2/2 | +100% | +77/77 | +
index.js | +
+
+ |
+ 100% | +58/58 | +100% | +1/1 | +100% | +0/0 | +100% | +58/58 | +
main.js | +
+
+ |
+ 100% | +60/60 | +100% | +4/4 | +100% | +1/1 | +100% | +60/60 | +
+ 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 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +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'; + +/** +* Evaluate a Lucas polynomial. +* +* @module @stdlib/math/base/tools/lucaspoly +* +* @example +* var lucaspoly = require( '@stdlib/math/base/tools/lucaspoly' ); +* +* var v = lucaspoly( 5, 1.0 ); +* // returns 11.0 +* +* @example +* var factory = require( '@stdlib/math/base/tools/lucaspoly' ).factory; +* +* var polyval = factory( 5 ); +* +* var v = polyval( 1.0 ); +* // returns 11.0 +* +* v = polyval( 2.0 ); +* // returns 82.0 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// 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 | 1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +161x +161x +161x +161x +161x +161x +161x +161x +161x +161x +85x +85x +76x +161x +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'; + +// MODULES // + +var evalpoly = require( '@stdlib/math/base/tools/evalpoly' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var coefficients = require( './coefficients.js' ); + + +// MAIN // + +/** +* Evaluates a Lucas polynomial. +* +* @param {integer} n - Lucas polynomial to evaluate +* @param {number} x - value at which to evaluate a Lucas polynomial +* @returns {number} result +* +* @example +* var v = lucaspoly( 5, 1.0 ); +* // returns 11.0 +*/ +function lucaspoly( n, x ) { + var coefs; + var an; + var v; + + an = abs( n ); + coefs = coefficients( an ); + + v = evalpoly( coefs, x ); + if ( n >= 0 ) { + return v; + } + return pow( -1.0, an ) * v; +} + + +// EXPORTS // + +module.exports = lucaspoly; + |