@stdlib/math-iter-sequences-continued-fraction 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -352,7 +352,7 @@ See [LICENSE][stdlib-license].
352
352
 
353
353
  ## Copyright
354
354
 
355
- Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
355
+ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
356
356
 
357
357
  </section>
358
358
 
@@ -365,8 +365,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
365
365
  [npm-image]: http://img.shields.io/npm/v/@stdlib/math-iter-sequences-continued-fraction.svg
366
366
  [npm-url]: https://npmjs.org/package/@stdlib/math-iter-sequences-continued-fraction
367
367
 
368
- [test-image]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml/badge.svg?branch=v0.2.1
369
- [test-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml?query=branch:v0.2.1
368
+ [test-image]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml/badge.svg?branch=v0.2.3
369
+ [test-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml?query=branch:v0.2.3
370
370
 
371
371
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-iter-sequences-continued-fraction/main.svg
372
372
  [coverage-url]: https://codecov.io/github/stdlib-js/math-iter-sequences-continued-fraction?branch=main
@@ -378,8 +378,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
378
378
 
379
379
  -->
380
380
 
381
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
382
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
381
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
382
+ [chat-url]: https://stdlib.zulipchat.com
383
383
 
384
384
  [stdlib]: https://github.com/stdlib-js/stdlib
385
385
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";var P=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var I=P(function(rr,j){
2
2
  var Y=require('@stdlib/assert-is-plain-object/dist'),T=require('@stdlib/assert-has-own-property/dist'),_=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,k=require('@stdlib/assert-is-finite/dist').isPrimitive,p=require('@stdlib/error-tools-fmtprodmsg/dist'),N=["terms","convergents","*"];function z(r,e){return Y(e)?T(e,"iter")&&(r.iter=e.iter,!_(e.iter))?new TypeError(p('0Zv2t',"iter",e.iter)):T(e,"tol")&&(r.tol=e.tol,!k(e.tol)||e.tol<=0)?new TypeError(p('0Zv4R',"tol",e.tol)):T(e,"returns")&&(r.returns=e.returns,N.indexOf(e.returns)===-1)?new TypeError(p('0Zv4S',"returns",N.join('", "'),e.returns)):null:new TypeError(p('0Zv2V',e));}j.exports=z
3
3
  });var U=P(function(er,R){
4
- var y=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),A=require('@stdlib/assert-is-finite/dist').isPrimitive,S=require('@stdlib/symbol-iterator/dist'),B=require('@stdlib/error-tools-fmtprodmsg/dist'),F=require('@stdlib/math-base-special-floor/dist'),H=require('@stdlib/math-base-special-abs/dist'),J=require('@stdlib/constants-float64-eps/dist'),K=require('@stdlib/utils-fifo/dist'),M=I(),C=1e-50,Q={terms:W,convergents:X,"*":Z};function W(r,e,u){return u&&r>0?-r:r}function X(r,e,u){return u&&r>0?-e:e}function Z(r,e,u){return u&&r>0?[-r,-e]:[r,e]}function L(r,e){var u,h,E,l,v,a,b,d,i,f,m,s,n,g,q,w;if(!A(r))throw new TypeError(B('0Zv4Q',r));if(l={iter:1e308,tol:J,returns:"terms"},arguments.length>1&&(b=M(l,e),b))throw b;if(u=Q[l.returns],a=0,E=r,r<0?(d=!0,r=-r):d=!1,w=0,v={},y(v,"next",V),y(v,"return",D),S&&y(v,S,G),n=new K,i=F(r),n.push([i,i]),i===r||i===0&&(r=1/r,i=F(r),n.push([i,1/i]),i===r))return a=1,v;return q=r-i,g=1/q,f=i,m=f,s=0,n.push(O()),n.push(O()),v;function O(){var t=f;return i=F(g),q=g-i,g=1/q,s+=i,s===0&&(s=C),m=i+1/m,m===0&&(m=C),s=1/s,h=m*s,f*=h,H(h-1)<=l.tol&&(a=1,t===f)?[-1,f]:[i,f]}function V(){var t,o,c;return w+=1,a>0?a===1&&n.length>0?(t=n.pop(),o=t[0],c=t[1],o===-1?{done:!0}:(t=n.first(),n.length===2&&t[0]===1&&(o+=1,c=t[1],n.clear()),{value:u(o,c,d),done:!1})):(a=2,{done:!0}):w===l.iter?(t=n.pop(),o=t[0],c=t[1],t=n.first(),t[0]===1&&(o+=1,c=t[1]),n.clear(),a=2,{value:u(o,c,d),done:!1}):(t=n.push(O()).pop(),{value:u(t[0],t[1],d),done:!1})}function D(t){return a=2,arguments.length?{value:t,done:!0}:{done:!0}}function G(){return L(E,l)}}R.exports=L
4
+ var y=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),A=require('@stdlib/assert-is-finite/dist').isPrimitive,S=require('@stdlib/symbol-iterator/dist'),B=require('@stdlib/error-tools-fmtprodmsg/dist'),F=require('@stdlib/math-base-special-floor/dist'),H=require('@stdlib/math-base-special-abs/dist'),J=require('@stdlib/constants-float64-eps/dist'),K=require('@stdlib/dstructs-fifo/dist'),M=I(),C=1e-50,Q={terms:W,convergents:X,"*":Z};function W(r,e,u){return u&&r>0?-r:r}function X(r,e,u){return u&&r>0?-e:e}function Z(r,e,u){return u&&r>0?[-r,-e]:[r,e]}function L(r,e){var u,h,E,l,v,a,b,d,i,f,m,s,n,g,q,w;if(!A(r))throw new TypeError(B('0Zv4Q',r));if(l={iter:1e308,tol:J,returns:"terms"},arguments.length>1&&(b=M(l,e),b))throw b;if(u=Q[l.returns],a=0,E=r,r<0?(d=!0,r=-r):d=!1,w=0,v={},y(v,"next",V),y(v,"return",D),S&&y(v,S,G),n=new K,i=F(r),n.push([i,i]),i===r||i===0&&(r=1/r,i=F(r),n.push([i,1/i]),i===r))return a=1,v;return q=r-i,g=1/q,f=i,m=f,s=0,n.push(O()),n.push(O()),v;function O(){var t=f;return i=F(g),q=g-i,g=1/q,s+=i,s===0&&(s=C),m=i+1/m,m===0&&(m=C),s=1/s,h=m*s,f*=h,H(h-1)<=l.tol&&(a=1,t===f)?[-1,f]:[i,f]}function V(){var t,o,c;return w+=1,a>0?a===1&&n.length>0?(t=n.pop(),o=t[0],c=t[1],o===-1?{done:!0}:(t=n.first(),n.length===2&&t[0]===1&&(o+=1,c=t[1],n.clear()),{value:u(o,c,d),done:!1})):(a=2,{done:!0}):w===l.iter?(t=n.pop(),o=t[0],c=t[1],t=n.first(),t[0]===1&&(o+=1,c=t[1]),n.clear(),a=2,{value:u(o,c,d),done:!1}):(t=n.push(O()).pop(),{value:u(t[0],t[1],d),done:!1})}function D(t){return a=2,arguments.length?{value:t,done:!0}:{done:!0}}function G(){return L(E,l)}}R.exports=L
5
5
  });var $=U();module.exports=$;
6
6
  /** @license Apache-2.0 */
7
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/validate.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isFinite = require( '@stdlib/assert-is-finite' ).isPrimitive; // eslint-disable-line stdlib/no-redeclare\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar returns = [\n\t'terms',\n\t'convergents',\n\t'*'\n];\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {NonNegativeInteger} [options.iter] - maximum number of iterations\n* @param {PositiveNumber} [options.tol] - tolerance at which to terminate further evaluation of the continued fraction\n* @param {string} [options.returns] - specifies the type of result to return (must be one of `'terms'`, `'convergents'`, or `'*'`)\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'iter': 50\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isPlainObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( options.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'tol' ) ) {\n\t\topts.tol = options.tol;\n\t\tif ( !isFinite( options.tol ) || options.tol <= 0.0 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive finite number. Option: `%s`.', 'tol', options.tol ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'returns' ) ) {\n\t\topts.returns = options.returns;\n\t\tif ( returns.indexOf( options.returns ) === -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'returns', returns.join( '\", \"' ), options.returns ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar isFinite = require( '@stdlib/assert-is-finite' ).isPrimitive; // eslint-disable-line stdlib/no-redeclare\nvar iteratorSymbol = require( '@stdlib/symbol-iterator' );\nvar format = require( '@stdlib/string-format' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar abs = require( '@stdlib/math-base-special-abs' );\nvar EPS = require( '@stdlib/constants-float64-eps' );\nvar FIFO = require( '@stdlib/utils-fifo' );\nvar validate = require( './validate.js' );\n\n\n// VARIABLES //\n\nvar TINY = 1.0e-50;\nvar RESULT_FUNCTION = {\n\t'terms': terms,\n\t'convergents': convergents,\n\t'*': both\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns a continued fraction term result.\n*\n* @private\n* @param {number} term - continued fraction term\n* @param {number} convergent - continued fraction convergent\n* @param {boolean} negative - boolean indicating whether the input value is negative\n* @returns {number} term\n*/\nfunction terms( term, convergent, negative ) {\n\treturn ( negative && term > 0 ) ? -term : term;\n}\n\n/**\n* Returns a continued fraction convergent result.\n*\n* @private\n* @param {number} term - continued fraction term\n* @param {number} convergent - continued fraction convergent\n* @param {boolean} negative - boolean indicating whether the input value is negative\n* @returns {number} convergent\n*/\nfunction convergents( term, convergent, negative ) {\n\treturn ( negative && term > 0 ) ? -convergent : convergent;\n}\n\n/**\n* Returns a result as two-element array consisting of a continued fraction term and its associated convergent.\n*\n* @private\n* @param {number} term - continued fraction term\n* @param {number} convergent - continued fraction convergent\n* @param {boolean} negative - boolean indicating whether the input value is negative\n* @returns {Array<number>} result\n*/\nfunction both( term, convergent, negative ) {\n\treturn ( negative && term > 0 ) ? [ -term, -convergent ] : [ term, convergent ]; // eslint-disable-line max-len\n}\n\n\n// MAIN //\n\n/**\n* Returns an iterator which generates a list of all continued fraction terms which can be obtained given the precision of `x`.\n*\n* ## Notes\n*\n* - If an environment supports `Symbol.iterator`, the returned iterator is iterable.\n*\n* @param {number} x - input value\n* @param {Options} [options] - function options\n* @param {NonNegativeInteger} [options.iter=1e308] - maximum number of iterations\n* @param {PositiveNumber} [options.tol] - tolerance at which to terminate further evaluation of the continued fraction\n* @param {string} [options.returns='terms'] - specifies the type of result to return (must be one of `'terms'`, `'convergents'`, or `'*'`)\n* @throws {TypeError} first argument must be a finite number\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = iterContinuedFractionSeq( 3.245 );\n*\n* var v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 12\n*\n* v = iter.next().value;\n* // returns 4\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction iterContinuedFractionSeq( x, options ) {\n\tvar result;\n\tvar delta;\n\tvar orig;\n\tvar opts;\n\tvar iter;\n\tvar FLG;\n\tvar err;\n\tvar neg;\n\tvar bi;\n\tvar fi;\n\tvar Ci;\n\tvar Di;\n\tvar q;\n\tvar v;\n\tvar r;\n\tvar i;\n\n\tif ( !isFinite( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a finite number. Value: `%s`.', x ) );\n\t}\n\topts = {\n\t\t'iter': 1e308,\n\t\t'tol': EPS,\n\t\t'returns': 'terms'\n\t};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tresult = RESULT_FUNCTION[ opts.returns ];\n\tFLG = 0;\n\torig = x;\n\n\t// If `x < 0`, we choose to negate the terms (i.e., [b0; b1, b2, ..., bn] => [-b0; -b1, -b2, ..., -bn]), thus allowing the evaluation of those terms to return the input value. This differs from an alternative approach of having only a negative `b0` and the rest `{b1, ..., bn}` be positive. When doing the latter, floating-point rounding error can prevent recovering the original value...\n\tif ( x < 0 ) {\n\t\tneg = true;\n\t\tx = -x;\n\t} else {\n\t\tneg = false;\n\t}\n\ti = 0;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Continued fractions may not be unique (e.g., [b0; b1, ..., bn, 1] = [b0; b1, ..., bn+1]). Accordingly, in order to ensure we return a canonical representation (i.e., the shorter representation), returned values must lag by two terms, as we'll need to peek ahead to determine if we need to canonicalize before returning the last term. In which case, let's create a FIFO queue for storing terms and their associated convergents...\n\tq = new FIFO();\n\n\t// Extract the integer part of the provided value:\n\tbi = floor( x );\n\tq.push( [ bi, bi ] ); // b0 is both the first term and the first convergent\n\tif ( bi === x ) {\n\t\t// We've been provided an integer value, so no continued fractions to compute...\n\t\tFLG = 1;\n\t\treturn iter;\n\t}\n\t// For `0 < x < 1`, leverage the fact that continued fraction representations of a positive rational number and its reciprocal are identical, except for shifting one place to the right (i.e., [b0; b1, b1, ..., bn] and [0; b0, b1, b2, ..., bn] are reciprocals)...\n\tif ( bi === 0 ) {\n\t\tx = 1.0 / x;\n\t\tbi = floor( x );\n\t\tq.push( [ bi, 1.0/bi ] );\n\t\tif ( bi === x ) {\n\t\t\t// No more continued fractions to compute...\n\t\t\tFLG = 1;\n\t\t\treturn iter;\n\t\t}\n\t}\n\t// Compute the next term of the continued fraction...\n\tr = x - bi;\n\tv = 1.0 / r;\n\n\t// Initialize parameters of the modified Lentz's algorithm...\n\tfi = bi;\n\tCi = fi;\n\tDi = 0.0;\n\n\t// Compute the next two terms:\n\tq.push( nextTerm() );\n\tq.push( nextTerm() );\n\n\treturn iter;\n\n\t/**\n\t* Computes the next term of the continued fraction.\n\t*\n\t* @private\n\t* @returns {number} next term\n\t*/\n\tfunction nextTerm() {\n\t\tvar fj = fi;\n\n\t\t// Compute the next term of the continued fraction...\n\t\tbi = floor( v );\n\t\tr = v - bi;\n\t\tv = 1.0 / r;\n\n\t\t// Use the modified Lentz's algorithm to find the next convergent...\n\t\tDi += bi; // b_j + a_j*D_{j-1}, where a_j = 1.0 for all j\n\t\tif ( Di === 0.0 ) {\n\t\t\tDi = TINY;\n\t\t}\n\t\tCi = bi + ( 1.0/Ci ); // b_j + a_j/C_{j-1}, where a_j = 1.0 for all j\n\t\tif ( Ci === 0.0 ) {\n\t\t\tCi = TINY;\n\t\t}\n\t\tDi = 1.0 / Di;\n\t\tdelta = Ci * Di;\n\t\tfi *= delta;\n\n\t\t// Check whether we can terminate computation...\n\t\tif ( abs( delta - 1.0 ) <= opts.tol ) {\n\t\t\tFLG = 1;\n\t\t\tif ( fj === fi ) {\n\t\t\t\t// Return a sentinel value to indicate that the last term did not improve the approximation:\n\t\t\t\treturn [ -1, fi ];\n\t\t\t}\n\t\t}\n\t\treturn [ bi, fi ];\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar item;\n\t\tvar term;\n\t\tvar f;\n\n\t\ti += 1;\n\t\tif ( FLG > 0 ) {\n\t\t\tif ( FLG === 1 && q.length > 0 ) {\n\t\t\t\titem = q.pop();\n\t\t\t\tterm = item[ 0 ];\n\t\t\t\tf = item[ 1 ];\n\t\t\t\tif ( term === -1 ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t'done': true\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t// Check whether we need to adjust the current term to ensure canonical representation...\n\t\t\t\titem = q.first();\n\t\t\t\tif ( q.length === 2 && item[ 0 ] === 1 ) {\n\t\t\t\t\tterm += 1;\n\t\t\t\t\tf = item[ 1 ];\n\t\t\t\t\tq.clear();\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t'value': result( term, f, neg ),\n\t\t\t\t\t'done': false\n\t\t\t\t};\n\t\t\t}\n\t\t\tFLG = 2;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tif ( i === opts.iter ) {\n\t\t\titem = q.pop();\n\t\t\tterm = item[ 0 ];\n\t\t\tf = item[ 1 ];\n\n\t\t\t// Check whether we need to adjust the final term to ensure canonical representation...\n\t\t\titem = q.first();\n\t\t\tif ( item[ 0 ] === 1 ) {\n\t\t\t\tterm += 1;\n\t\t\t\tf = item[ 1 ];\n\t\t\t}\n\t\t\tq.clear();\n\t\t\tFLG = 2;\n\t\t\treturn {\n\t\t\t\t'value': result( term, f, neg ),\n\t\t\t\t'done': false\n\t\t\t};\n\t\t}\n\t\titem = q.push( nextTerm() ).pop();\n\t\treturn {\n\t\t\t'value': result( item[ 0 ], item[ 1 ], neg ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = 2;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn iterContinuedFractionSeq( orig, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterContinuedFractionSeq;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an iterator which generates a list of all continued fraction terms which can be obtained given the precision of `x`.\n*\n* @module @stdlib/math-iter-sequences-continued-fraction\n*\n* @example\n* var iterContinuedFractionSeq = require( '@stdlib/math-iter-sequences-continued-fraction' );\n*\n* var iter = iterContinuedFractionSeq( 3.245 );\n*\n* var v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 12\n*\n* v = iter.next().value;\n* // returns 4\n*\n* var bool = iter.next().done;\n* // returns true\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,iCAAkC,EACxDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAK1CC,EAAU,CACb,QACA,cACA,GACD,EA0BA,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAeQ,CAAQ,EAGxBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACN,EAAsBM,EAAQ,IAA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A0BK,EAAMC,CAAK,CAC7C,CACD,CAKAxB,EAAO,QAAUkB,IC7SjB,IAAI2B,EAAO,IAKX,OAAO,QAAUA",
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isFinite = require( '@stdlib/assert-is-finite' ).isPrimitive; // eslint-disable-line stdlib/no-redeclare\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar returns = [\n\t'terms',\n\t'convergents',\n\t'*'\n];\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {NonNegativeInteger} [options.iter] - maximum number of iterations\n* @param {PositiveNumber} [options.tol] - tolerance at which to terminate further evaluation of the continued fraction\n* @param {string} [options.returns] - specifies the type of result to return (must be one of `'terms'`, `'convergents'`, or `'*'`)\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'iter': 50\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isPlainObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( options.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'tol' ) ) {\n\t\topts.tol = options.tol;\n\t\tif ( !isFinite( options.tol ) || options.tol <= 0.0 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive finite number. Option: `%s`.', 'tol', options.tol ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'returns' ) ) {\n\t\topts.returns = options.returns;\n\t\tif ( returns.indexOf( options.returns ) === -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'returns', returns.join( '\", \"' ), options.returns ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar isFinite = require( '@stdlib/assert-is-finite' ).isPrimitive; // eslint-disable-line stdlib/no-redeclare\nvar iteratorSymbol = require( '@stdlib/symbol-iterator' );\nvar format = require( '@stdlib/string-format' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar abs = require( '@stdlib/math-base-special-abs' );\nvar EPS = require( '@stdlib/constants-float64-eps' );\nvar FIFO = require( '@stdlib/dstructs-fifo' );\nvar validate = require( './validate.js' );\n\n\n// VARIABLES //\n\nvar TINY = 1.0e-50;\nvar RESULT_FUNCTION = {\n\t'terms': terms,\n\t'convergents': convergents,\n\t'*': both\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns a continued fraction term result.\n*\n* @private\n* @param {number} term - continued fraction term\n* @param {number} convergent - continued fraction convergent\n* @param {boolean} negative - boolean indicating whether the input value is negative\n* @returns {number} term\n*/\nfunction terms( term, convergent, negative ) {\n\treturn ( negative && term > 0 ) ? -term : term;\n}\n\n/**\n* Returns a continued fraction convergent result.\n*\n* @private\n* @param {number} term - continued fraction term\n* @param {number} convergent - continued fraction convergent\n* @param {boolean} negative - boolean indicating whether the input value is negative\n* @returns {number} convergent\n*/\nfunction convergents( term, convergent, negative ) {\n\treturn ( negative && term > 0 ) ? -convergent : convergent;\n}\n\n/**\n* Returns a result as two-element array consisting of a continued fraction term and its associated convergent.\n*\n* @private\n* @param {number} term - continued fraction term\n* @param {number} convergent - continued fraction convergent\n* @param {boolean} negative - boolean indicating whether the input value is negative\n* @returns {Array<number>} result\n*/\nfunction both( term, convergent, negative ) {\n\treturn ( negative && term > 0 ) ? [ -term, -convergent ] : [ term, convergent ]; // eslint-disable-line max-len\n}\n\n\n// MAIN //\n\n/**\n* Returns an iterator which generates a list of all continued fraction terms which can be obtained given the precision of `x`.\n*\n* ## Notes\n*\n* - If an environment supports `Symbol.iterator`, the returned iterator is iterable.\n*\n* @param {number} x - input value\n* @param {Options} [options] - function options\n* @param {NonNegativeInteger} [options.iter=1e308] - maximum number of iterations\n* @param {PositiveNumber} [options.tol] - tolerance at which to terminate further evaluation of the continued fraction\n* @param {string} [options.returns='terms'] - specifies the type of result to return (must be one of `'terms'`, `'convergents'`, or `'*'`)\n* @throws {TypeError} first argument must be a finite number\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = iterContinuedFractionSeq( 3.245 );\n*\n* var v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 12\n*\n* v = iter.next().value;\n* // returns 4\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction iterContinuedFractionSeq( x, options ) {\n\tvar result;\n\tvar delta;\n\tvar orig;\n\tvar opts;\n\tvar iter;\n\tvar FLG;\n\tvar err;\n\tvar neg;\n\tvar bi;\n\tvar fi;\n\tvar Ci;\n\tvar Di;\n\tvar q;\n\tvar v;\n\tvar r;\n\tvar i;\n\n\tif ( !isFinite( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a finite number. Value: `%s`.', x ) );\n\t}\n\topts = {\n\t\t'iter': 1e308,\n\t\t'tol': EPS,\n\t\t'returns': 'terms'\n\t};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tresult = RESULT_FUNCTION[ opts.returns ];\n\tFLG = 0;\n\torig = x;\n\n\t// If `x < 0`, we choose to negate the terms (i.e., [b0; b1, b2, ..., bn] => [-b0; -b1, -b2, ..., -bn]), thus allowing the evaluation of those terms to return the input value. This differs from an alternative approach of having only a negative `b0` and the rest `{b1, ..., bn}` be positive. When doing the latter, floating-point rounding error can prevent recovering the original value...\n\tif ( x < 0 ) {\n\t\tneg = true;\n\t\tx = -x;\n\t} else {\n\t\tneg = false;\n\t}\n\ti = 0;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Continued fractions may not be unique (e.g., [b0; b1, ..., bn, 1] = [b0; b1, ..., bn+1]). Accordingly, in order to ensure we return a canonical representation (i.e., the shorter representation), returned values must lag by two terms, as we'll need to peek ahead to determine if we need to canonicalize before returning the last term. In which case, let's create a FIFO queue for storing terms and their associated convergents...\n\tq = new FIFO();\n\n\t// Extract the integer part of the provided value:\n\tbi = floor( x );\n\tq.push( [ bi, bi ] ); // b0 is both the first term and the first convergent\n\tif ( bi === x ) {\n\t\t// We've been provided an integer value, so no continued fractions to compute...\n\t\tFLG = 1;\n\t\treturn iter;\n\t}\n\t// For `0 < x < 1`, leverage the fact that continued fraction representations of a positive rational number and its reciprocal are identical, except for shifting one place to the right (i.e., [b0; b1, b1, ..., bn] and [0; b0, b1, b2, ..., bn] are reciprocals)...\n\tif ( bi === 0 ) {\n\t\tx = 1.0 / x;\n\t\tbi = floor( x );\n\t\tq.push( [ bi, 1.0/bi ] );\n\t\tif ( bi === x ) {\n\t\t\t// No more continued fractions to compute...\n\t\t\tFLG = 1;\n\t\t\treturn iter;\n\t\t}\n\t}\n\t// Compute the next term of the continued fraction...\n\tr = x - bi;\n\tv = 1.0 / r;\n\n\t// Initialize parameters of the modified Lentz's algorithm...\n\tfi = bi;\n\tCi = fi;\n\tDi = 0.0;\n\n\t// Compute the next two terms:\n\tq.push( nextTerm() );\n\tq.push( nextTerm() );\n\n\treturn iter;\n\n\t/**\n\t* Computes the next term of the continued fraction.\n\t*\n\t* @private\n\t* @returns {number} next term\n\t*/\n\tfunction nextTerm() {\n\t\tvar fj = fi;\n\n\t\t// Compute the next term of the continued fraction...\n\t\tbi = floor( v );\n\t\tr = v - bi;\n\t\tv = 1.0 / r;\n\n\t\t// Use the modified Lentz's algorithm to find the next convergent...\n\t\tDi += bi; // b_j + a_j*D_{j-1}, where a_j = 1.0 for all j\n\t\tif ( Di === 0.0 ) {\n\t\t\tDi = TINY;\n\t\t}\n\t\tCi = bi + ( 1.0/Ci ); // b_j + a_j/C_{j-1}, where a_j = 1.0 for all j\n\t\tif ( Ci === 0.0 ) {\n\t\t\tCi = TINY;\n\t\t}\n\t\tDi = 1.0 / Di;\n\t\tdelta = Ci * Di;\n\t\tfi *= delta;\n\n\t\t// Check whether we can terminate computation...\n\t\tif ( abs( delta - 1.0 ) <= opts.tol ) {\n\t\t\tFLG = 1;\n\t\t\tif ( fj === fi ) {\n\t\t\t\t// Return a sentinel value to indicate that the last term did not improve the approximation:\n\t\t\t\treturn [ -1, fi ];\n\t\t\t}\n\t\t}\n\t\treturn [ bi, fi ];\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar item;\n\t\tvar term;\n\t\tvar f;\n\n\t\ti += 1;\n\t\tif ( FLG > 0 ) {\n\t\t\tif ( FLG === 1 && q.length > 0 ) {\n\t\t\t\titem = q.pop();\n\t\t\t\tterm = item[ 0 ];\n\t\t\t\tf = item[ 1 ];\n\t\t\t\tif ( term === -1 ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t'done': true\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t// Check whether we need to adjust the current term to ensure canonical representation...\n\t\t\t\titem = q.first();\n\t\t\t\tif ( q.length === 2 && item[ 0 ] === 1 ) {\n\t\t\t\t\tterm += 1;\n\t\t\t\t\tf = item[ 1 ];\n\t\t\t\t\tq.clear();\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t'value': result( term, f, neg ),\n\t\t\t\t\t'done': false\n\t\t\t\t};\n\t\t\t}\n\t\t\tFLG = 2;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tif ( i === opts.iter ) {\n\t\t\titem = q.pop();\n\t\t\tterm = item[ 0 ];\n\t\t\tf = item[ 1 ];\n\n\t\t\t// Check whether we need to adjust the final term to ensure canonical representation...\n\t\t\titem = q.first();\n\t\t\tif ( item[ 0 ] === 1 ) {\n\t\t\t\tterm += 1;\n\t\t\t\tf = item[ 1 ];\n\t\t\t}\n\t\t\tq.clear();\n\t\t\tFLG = 2;\n\t\t\treturn {\n\t\t\t\t'value': result( term, f, neg ),\n\t\t\t\t'done': false\n\t\t\t};\n\t\t}\n\t\titem = q.push( nextTerm() ).pop();\n\t\treturn {\n\t\t\t'value': result( item[ 0 ], item[ 1 ], neg ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = 2;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn iterContinuedFractionSeq( orig, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterContinuedFractionSeq;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an iterator which generates a list of all continued fraction terms which can be obtained given the precision of `x`.\n*\n* @module @stdlib/math-iter-sequences-continued-fraction\n*\n* @example\n* var iterContinuedFractionSeq = require( '@stdlib/math-iter-sequences-continued-fraction' );\n*\n* var iter = iterContinuedFractionSeq( 3.245 );\n*\n* var v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 12\n*\n* v = iter.next().value;\n* // returns 4\n*\n* var bool = iter.next().done;\n* // returns true\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5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AM,CAAE,GAEbT,EAAE,MAAM,EACRP,EAAM,EACC,CACN,MAASL,EAAQN,EAAM4B,EAAGf,CAAI,EAC9B,KAAQ,EACT,IAEDc,EAAOT,EAAE,KAAMO,EAAS,CAAE,EAAE,IAAI,EACzB,CACN,MAASnB,EAAQqB,EAAM,CAAE,EAAGA,EAAM,CAAE,EAAGd,CAAI,EAC3C,KAAQ,EACT,EACD,CASA,SAASU,EAAKM,EAAQ,CAErB,OADAlB,EAAM,EACD,UAAU,OACP,CACN,MAASkB,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAASL,GAAU,CAClB,OAAOrB,EAA0BK,EAAMC,CAAK,CAC7C,CACD,CAKAxB,EAAO,QAAUkB,IC7SjB,IAAI2B,EAAO,IAKX,OAAO,QAAUA",
6
6
  "names": ["require_validate", "__commonJSMin", "exports", "module", "isPlainObject", "hasOwnProp", "isNonNegativeInteger", "isFinite", "format", "returns", "validate", "opts", "options", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "isFinite", "iteratorSymbol", "format", "floor", "abs", "EPS", "FIFO", "validate", "TINY", "RESULT_FUNCTION", "terms", "convergents", "both", "term", "convergent", "negative", "iterContinuedFractionSeq", "x", "options", "result", "delta", "orig", "opts", "iter", "FLG", "err", "neg", "bi", "fi", "Ci", "Di", "q", "v", "r", "i", "next", "end", "factory", "nextTerm", "fj", "item", "f", "value", "main"]
7
7
  }
package/lib/main.js CHANGED
@@ -27,7 +27,7 @@ var format = require( '@stdlib/string-format' );
27
27
  var floor = require( '@stdlib/math-base-special-floor' );
28
28
  var abs = require( '@stdlib/math-base-special-abs' );
29
29
  var EPS = require( '@stdlib/constants-float64-eps' );
30
- var FIFO = require( '@stdlib/utils-fifo' );
30
+ var FIFO = require( '@stdlib/dstructs-fifo' );
31
31
  var validate = require( './validate.js' );
32
32
 
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/math-iter-sequences-continued-fraction",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Create an iterator which generates a list of all continued fraction terms which can be obtained given the precision of a provided number.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,17 +30,18 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/assert-has-own-property": "^0.2.1",
34
- "@stdlib/assert-is-finite": "^0.2.1",
35
- "@stdlib/assert-is-nonnegative-integer": "^0.2.1",
36
- "@stdlib/assert-is-plain-object": "^0.2.1",
37
- "@stdlib/constants-float64-eps": "^0.2.1",
38
- "@stdlib/math-base-special-abs": "^0.2.1",
39
- "@stdlib/math-base-special-floor": "^0.2.1",
40
- "@stdlib/string-format": "^0.2.1",
41
- "@stdlib/symbol-iterator": "^0.2.1",
42
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1",
43
- "@stdlib/utils-fifo": "^0.2.1"
33
+ "@stdlib/assert-has-own-property": "^0.2.3",
34
+ "@stdlib/assert-is-finite": "^0.2.3",
35
+ "@stdlib/assert-is-nonnegative-integer": "^0.2.3",
36
+ "@stdlib/assert-is-plain-object": "^0.2.3",
37
+ "@stdlib/constants-float64-eps": "^0.2.3",
38
+ "@stdlib/dstructs-fifo": "^0.1.0",
39
+ "@stdlib/math-base-special-abs": "^0.2.3",
40
+ "@stdlib/math-base-special-floor": "^0.2.4",
41
+ "@stdlib/string-format": "^0.2.3",
42
+ "@stdlib/symbol-iterator": "^0.2.2",
43
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
44
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.3"
44
45
  },
45
46
  "devDependencies": {},
46
47
  "engines": {