@stdlib/math-iter-sequences-continued-fraction 0.0.5 → 0.2.0
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/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +40 -13
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/main.js +2 -1
- package/lib/validate.js +5 -4
- package/package.json +23 -20
- package/docs/repl.txt +0 -77
- package/docs/types/test.ts +0 -98
package/LICENSE
CHANGED
|
@@ -175,307 +175,3 @@
|
|
|
175
175
|
of your accepting any such warranty or additional liability.
|
|
176
176
|
|
|
177
177
|
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
182
|
-
|
|
183
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
184
|
-
obtaining a copy of the software and accompanying documentation covered by this
|
|
185
|
-
license (the "Software") to use, reproduce, display, distribute, execute, and
|
|
186
|
-
transmit the Software, and to prepare derivative works of the Software, and to
|
|
187
|
-
permit third-parties to whom the Software is furnished to do so, all subject to
|
|
188
|
-
the following:
|
|
189
|
-
|
|
190
|
-
The copyright notices in the Software and this entire statement, including the
|
|
191
|
-
above license grant, this restriction and the following disclaimer, must be
|
|
192
|
-
included in all copies of the Software, in whole or in part, and all derivative
|
|
193
|
-
works of the Software, unless such copies or derivative works are solely in the
|
|
194
|
-
form of machine-executable object code generated by a source language processor.
|
|
195
|
-
|
|
196
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
197
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
198
|
-
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
199
|
-
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
|
|
200
|
-
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
201
|
-
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
DEPENDENCIES
|
|
207
|
-
|
|
208
|
-
The library links against the following external libraries, which have their own
|
|
209
|
-
licenses:
|
|
210
|
-
|
|
211
|
-
* OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
|
|
212
|
-
def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
|
|
213
|
-
|
|
214
|
-
Copyright (c) 2011-2014, The OpenBLAS Project
|
|
215
|
-
All rights reserved.
|
|
216
|
-
|
|
217
|
-
Redistribution and use in source and binary forms, with or without
|
|
218
|
-
modification, are permitted provided that the following conditions are
|
|
219
|
-
met:
|
|
220
|
-
|
|
221
|
-
1. Redistributions of source code must retain the above copyright
|
|
222
|
-
notice, this list of conditions and the following disclaimer.
|
|
223
|
-
|
|
224
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
225
|
-
notice, this list of conditions and the following disclaimer in
|
|
226
|
-
the documentation and/or other materials provided with the
|
|
227
|
-
distribution.
|
|
228
|
-
|
|
229
|
-
3. Neither the name of the OpenBLAS project nor the names of
|
|
230
|
-
its contributors may be used to endorse or promote products
|
|
231
|
-
derived from this software without specific prior written
|
|
232
|
-
permission.
|
|
233
|
-
|
|
234
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
235
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
236
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
237
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
238
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
239
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
240
|
-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
241
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
242
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
243
|
-
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* Electron <https://raw.githubusercontent.com/electron/electron/
|
|
247
|
-
c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
|
|
248
|
-
|
|
249
|
-
Copyright (c) 2013-2017 GitHub Inc.
|
|
250
|
-
|
|
251
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
252
|
-
a copy of this software and associated documentation files (the
|
|
253
|
-
"Software"), to deal in the Software without restriction, including
|
|
254
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
255
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
256
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
257
|
-
the following conditions:
|
|
258
|
-
|
|
259
|
-
The above copyright notice and this permission notice shall be
|
|
260
|
-
included in all copies or substantial portions of the Software.
|
|
261
|
-
|
|
262
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
263
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
264
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
265
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
266
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
267
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
268
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* Boost <http://www.boost.org/LICENSE_1_0.txt>
|
|
272
|
-
|
|
273
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
274
|
-
|
|
275
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
276
|
-
obtaining a copy of the software and accompanying documentation covered by
|
|
277
|
-
this license (the "Software") to use, reproduce, display, distribute,
|
|
278
|
-
execute, and transmit the Software, and to prepare derivative works of the
|
|
279
|
-
Software, and to permit third-parties to whom the Software is furnished to
|
|
280
|
-
do so, all subject to the following:
|
|
281
|
-
|
|
282
|
-
The copyright notices in the Software and this entire statement, including
|
|
283
|
-
the above license grant, this restriction and the following disclaimer,
|
|
284
|
-
must be included in all copies of the Software, in whole or in part, and
|
|
285
|
-
all derivative works of the Software, unless such copies or derivative
|
|
286
|
-
works are solely in the form of machine-executable object code generated by
|
|
287
|
-
a source language processor.
|
|
288
|
-
|
|
289
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
290
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
291
|
-
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
292
|
-
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
293
|
-
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
294
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
295
|
-
DEALINGS IN THE SOFTWARE.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* Cephes <http://www.netlib.org/cephes/readme>
|
|
299
|
-
|
|
300
|
-
Copyright (c) 1984-2000 Stephen L. Moshier
|
|
301
|
-
|
|
302
|
-
Some software in this archive may be from the book _Methods and Programs for
|
|
303
|
-
Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
|
|
304
|
-
or from the Cephes Mathematical Library, a commercial product. In either event,
|
|
305
|
-
it is copyrighted by the author. What you see here may be used freely but it
|
|
306
|
-
comes with no support or guarantee.
|
|
307
|
-
|
|
308
|
-
Stephen L. Moshier
|
|
309
|
-
moshier@na-net.ornl.gov
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ATTRIBUTION
|
|
314
|
-
|
|
315
|
-
The library contains implementations from the following external libraries,
|
|
316
|
-
which have their own licenses:
|
|
317
|
-
|
|
318
|
-
* FreeBSD <https://svnweb.freebsd.org/>
|
|
319
|
-
|
|
320
|
-
Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
|
321
|
-
|
|
322
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
323
|
-
Permission to use, copy, modify, and distribute this
|
|
324
|
-
software is freely granted, provided that this notice
|
|
325
|
-
is preserved.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
* FDLIBM <http://www.netlib.org/fdlibm/>
|
|
329
|
-
|
|
330
|
-
Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
|
331
|
-
|
|
332
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
333
|
-
Permission to use, copy, modify, and distribute this
|
|
334
|
-
software is freely granted, provided that this notice
|
|
335
|
-
is preserved.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
|
|
339
|
-
|
|
340
|
-
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
341
|
-
|
|
342
|
-
Redistribution and use in source and binary forms, with or without
|
|
343
|
-
modification, are permitted provided that the following conditions are
|
|
344
|
-
met:
|
|
345
|
-
|
|
346
|
-
* Redistributions of source code must retain the above copyright
|
|
347
|
-
notice, this list of conditions and the following disclaimer.
|
|
348
|
-
* Redistributions in binary form must reproduce the above
|
|
349
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
350
|
-
in the documentation and/or other materials provided with the
|
|
351
|
-
distribution.
|
|
352
|
-
* Neither the name of Google Inc. nor the names of its
|
|
353
|
-
contributors may be used to endorse or promote products derived from
|
|
354
|
-
this software without specific prior written permission.
|
|
355
|
-
|
|
356
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
357
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
358
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
359
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
360
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
361
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
362
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
363
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
364
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
365
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
366
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
|
|
370
|
-
|
|
371
|
-
Public domain.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
* ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
|
|
375
|
-
|
|
376
|
-
Copyright JS Foundation and other contributors, https://js.foundation
|
|
377
|
-
|
|
378
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
379
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
380
|
-
in the Software without restriction, including without limitation the rights
|
|
381
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
382
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
383
|
-
furnished to do so, subject to the following conditions:
|
|
384
|
-
|
|
385
|
-
The above copyright notice and this permission notice shall be included in
|
|
386
|
-
all copies or substantial portions of the Software.
|
|
387
|
-
|
|
388
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
389
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
390
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
391
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
392
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
393
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
394
|
-
THE SOFTWARE.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
|
|
398
|
-
e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
|
|
399
|
-
|
|
400
|
-
Copyright (c) 2015: Dahua Lin.
|
|
401
|
-
|
|
402
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
403
|
-
a copy of this software and associated documentation files (the
|
|
404
|
-
"Software"), to deal in the Software without restriction, including
|
|
405
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
406
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
407
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
408
|
-
the following conditions:
|
|
409
|
-
|
|
410
|
-
The above copyright notice and this permission notice shall be
|
|
411
|
-
included in all copies or substantial portions of the Software.
|
|
412
|
-
|
|
413
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
414
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
415
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
416
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
417
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
418
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
419
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
|
|
423
|
-
SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
|
|
424
|
-
|
|
425
|
-
The MIT License (MIT)
|
|
426
|
-
|
|
427
|
-
Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
|
|
428
|
-
|
|
429
|
-
https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
|
|
430
|
-
|
|
431
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
432
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
433
|
-
in the Software without restriction, including without limitation the rights
|
|
434
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
435
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
436
|
-
furnished to do so, subject to the following conditions:
|
|
437
|
-
|
|
438
|
-
The above copyright notice and this permission notice shall be included in all
|
|
439
|
-
copies or substantial portions of the Software.
|
|
440
|
-
|
|
441
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
442
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
443
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
444
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
445
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
446
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
447
|
-
SOFTWARE.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
|
|
451
|
-
mt19937ar.c>
|
|
452
|
-
|
|
453
|
-
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
|
454
|
-
All rights reserved.
|
|
455
|
-
|
|
456
|
-
Redistribution and use in source and binary forms, with or without
|
|
457
|
-
modification, are permitted provided that the following conditions
|
|
458
|
-
are met:
|
|
459
|
-
|
|
460
|
-
1. Redistributions of source code must retain the above copyright
|
|
461
|
-
notice, this list of conditions and the following disclaimer.
|
|
462
|
-
|
|
463
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
464
|
-
notice, this list of conditions and the following disclaimer in the
|
|
465
|
-
documentation and/or other materials provided with the distribution.
|
|
466
|
-
|
|
467
|
-
3. The names of its contributors may not be used to endorse or promote
|
|
468
|
-
products derived from this software without specific prior written
|
|
469
|
-
permission.
|
|
470
|
-
|
|
471
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
472
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
473
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
474
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
475
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
476
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
477
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
478
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
479
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
480
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
481
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# iterContinuedFractionSeq
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -35,7 +46,7 @@ A **generalized continued fraction** has the form
|
|
|
35
46
|
<div class="equation" align="center" data-raw-text="x = b_0 + \frac{a_1}{b_1+\frac{a_2}{b_2+\frac{a_3}{b_3+\frac{a_4}{b_4+\ldots}}}}" data-equation="eq:continued_fraction">
|
|
36
47
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@b05b08e74e5706e091431f99b26166caea11fed9/lib/node_modules/@stdlib/math/iter/sequences/continued-fraction/docs/img/equation_continued_fraction.svg" alt="Continued fraction">
|
|
37
48
|
<br>
|
|
38
|
-
</div>
|
|
49
|
+
</div> -->
|
|
39
50
|
|
|
40
51
|
<!-- </equation> -->
|
|
41
52
|
|
|
@@ -43,10 +54,10 @@ If `a_i = 1` for all `i`, the above expression reduces to a **simple continued f
|
|
|
43
54
|
|
|
44
55
|
<!-- <equation class="equation" label="eq:simple_continued_fraction" align="center" raw="x = b_0 + \frac{1}{b_1+\frac{1}{b_2+\frac{1}{b_3+\frac{1}{b_4+\ldots}}}}" alt="Simple continued fraction"> -->
|
|
45
56
|
|
|
46
|
-
<div class="equation" align="center" data-raw-text="x = b_0 + \frac{1}{b_1+\frac{1}{b_2+\frac{1}{b_3+\frac{1}{b_4+\ldots}}}}" data-equation="eq:simple_continued_fraction">
|
|
57
|
+
<!-- <div class="equation" align="center" data-raw-text="x = b_0 + \frac{1}{b_1+\frac{1}{b_2+\frac{1}{b_3+\frac{1}{b_4+\ldots}}}}" data-equation="eq:simple_continued_fraction">
|
|
47
58
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@b05b08e74e5706e091431f99b26166caea11fed9/lib/node_modules/@stdlib/math/iter/sequences/continued-fraction/docs/img/equation_simple_continued_fraction.svg" alt="Simple continued fraction">
|
|
48
59
|
<br>
|
|
49
|
-
</div>
|
|
60
|
+
</div> -->
|
|
50
61
|
|
|
51
62
|
<!-- </equation> -->
|
|
52
63
|
|
|
@@ -54,7 +65,7 @@ where the values `b_i` are called the **coefficients** or **terms** of the conti
|
|
|
54
65
|
|
|
55
66
|
<!-- <equation class="equation" label="eq:simple_continued_fraction_convergents" align="center" raw="b_0, b_0 + \frac{1}{b_1},b_0 + \frac{1}{b_1 + \frac{1}{b2}},b_0 + \frac{1}{b_1 + \frac{1}{b2+\frac{1}{b3}}},\ldots" alt="Simple continued fraction convergents"> -->
|
|
56
67
|
|
|
57
|
-
<div class="equation" align="center" data-raw-text="b_0, b_0 + \frac{1}{b_1},b_0 + \frac{1}{b_1 + \frac{1}{b2}},b_0 + \frac{1}{b_1 + \frac{1}{b2+\frac{1}{b3}}},\ldots" data-equation="eq:simple_continued_fraction_convergents">
|
|
68
|
+
<!-- <div class="equation" align="center" data-raw-text="b_0, b_0 + \frac{1}{b_1},b_0 + \frac{1}{b_1 + \frac{1}{b2}},b_0 + \frac{1}{b_1 + \frac{1}{b2+\frac{1}{b3}}},\ldots" data-equation="eq:simple_continued_fraction_convergents">
|
|
58
69
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@6be2d95d94757e01f8e07117664fdf14b5f82777/lib/node_modules/@stdlib/math/iter/sequences/continued-fraction/docs/img/equation_simple_continued_fraction_convergents.svg" alt="Simple continued fraction convergents">
|
|
59
70
|
<br>
|
|
60
71
|
</div>
|
|
@@ -305,6 +316,12 @@ console.log( 'computed: %d', evaluate( terms ) );
|
|
|
305
316
|
|
|
306
317
|
<section class="related">
|
|
307
318
|
|
|
319
|
+
* * *
|
|
320
|
+
|
|
321
|
+
## See Also
|
|
322
|
+
|
|
323
|
+
- <span class="package-name">[`@stdlib/math-iter/utils/continued-fraction`][@stdlib/math/iter/utils/continued-fraction]</span><span class="delimiter">: </span><span class="description">evaluate the terms of a continued fraction.</span>
|
|
324
|
+
|
|
308
325
|
</section>
|
|
309
326
|
|
|
310
327
|
<!-- /.related -->
|
|
@@ -335,7 +352,7 @@ See [LICENSE][stdlib-license].
|
|
|
335
352
|
|
|
336
353
|
## Copyright
|
|
337
354
|
|
|
338
|
-
Copyright © 2016-
|
|
355
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
339
356
|
|
|
340
357
|
</section>
|
|
341
358
|
|
|
@@ -348,8 +365,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
348
365
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-iter-sequences-continued-fraction.svg
|
|
349
366
|
[npm-url]: https://npmjs.org/package/@stdlib/math-iter-sequences-continued-fraction
|
|
350
367
|
|
|
351
|
-
[test-image]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
352
|
-
[test-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml?query=branch:v0.0
|
|
368
|
+
[test-image]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
369
|
+
[test-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/actions/workflows/test.yml?query=branch:v0.2.0
|
|
353
370
|
|
|
354
371
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-iter-sequences-continued-fraction/main.svg
|
|
355
372
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-iter-sequences-continued-fraction?branch=main
|
|
@@ -361,23 +378,33 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
361
378
|
|
|
362
379
|
-->
|
|
363
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
|
|
383
|
+
|
|
384
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
385
|
+
|
|
386
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
387
|
+
|
|
364
388
|
[umd]: https://github.com/umdjs/umd
|
|
365
389
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
366
390
|
|
|
367
391
|
[deno-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/tree/deno
|
|
392
|
+
[deno-readme]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/blob/deno/README.md
|
|
368
393
|
[umd-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/tree/umd
|
|
394
|
+
[umd-readme]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/blob/umd/README.md
|
|
369
395
|
[esm-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/tree/esm
|
|
396
|
+
[esm-readme]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/blob/esm/README.md
|
|
397
|
+
[branches-url]: https://github.com/stdlib-js/math-iter-sequences-continued-fraction/blob/main/branches.md
|
|
370
398
|
|
|
371
|
-
[
|
|
372
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
399
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-iter-sequences-continued-fraction/main/LICENSE
|
|
373
400
|
|
|
374
|
-
[stdlib]: https://
|
|
401
|
+
[@stdlib/constants/float64/eps]: https://www.npmjs.com/package/@stdlib/constants-float64-eps
|
|
375
402
|
|
|
376
|
-
|
|
403
|
+
<!-- <related-links> -->
|
|
377
404
|
|
|
378
|
-
[stdlib-
|
|
405
|
+
[@stdlib/math/iter/utils/continued-fraction]: https://www.npmjs.com/package/@stdlib/math-iter-utils-continued-fraction
|
|
379
406
|
|
|
380
|
-
|
|
407
|
+
<!-- </related-links> -->
|
|
381
408
|
|
|
382
409
|
</section>
|
|
383
410
|
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
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
|
+
});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
|
|
5
|
+
});var $=U();module.exports=$;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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": "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",
|
|
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
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
@@ -79,7 +79,7 @@ interface Options {
|
|
|
79
79
|
* var bool = iter.next().done;
|
|
80
80
|
* // returns true
|
|
81
81
|
*/
|
|
82
|
-
declare function iterContinuedFractionSeq( x: number, options?: Options ): Iterator;
|
|
82
|
+
declare function iterContinuedFractionSeq( x: number, options?: Options ): Iterator;
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
// EXPORTS //
|
package/lib/index.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
24
24
|
var isFinite = require( '@stdlib/assert-is-finite' ).isPrimitive; // eslint-disable-line stdlib/no-redeclare
|
|
25
25
|
var iteratorSymbol = require( '@stdlib/symbol-iterator' );
|
|
26
|
+
var format = require( '@stdlib/string-format' );
|
|
26
27
|
var floor = require( '@stdlib/math-base-special-floor' );
|
|
27
28
|
var abs = require( '@stdlib/math-base-special-abs' );
|
|
28
29
|
var EPS = require( '@stdlib/constants-float64-eps' );
|
|
@@ -138,7 +139,7 @@ function iterContinuedFractionSeq( x, options ) {
|
|
|
138
139
|
var i;
|
|
139
140
|
|
|
140
141
|
if ( !isFinite( x ) ) {
|
|
141
|
-
throw new TypeError( 'invalid argument. First argument must be a finite number. Value:
|
|
142
|
+
throw new TypeError( format( 'invalid argument. First argument must be a finite number. Value: `%s`.', x ) );
|
|
142
143
|
}
|
|
143
144
|
opts = {
|
|
144
145
|
'iter': 1e308,
|
package/lib/validate.js
CHANGED
|
@@ -24,6 +24,7 @@ var isPlainObject = require( '@stdlib/assert-is-plain-object' );
|
|
|
24
24
|
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
|
|
25
25
|
var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
|
|
26
26
|
var isFinite = require( '@stdlib/assert-is-finite' ).isPrimitive; // eslint-disable-line stdlib/no-redeclare
|
|
27
|
+
var format = require( '@stdlib/string-format' );
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
// VARIABLES //
|
|
@@ -60,24 +61,24 @@ var returns = [
|
|
|
60
61
|
*/
|
|
61
62
|
function validate( opts, options ) {
|
|
62
63
|
if ( !isPlainObject( options ) ) {
|
|
63
|
-
return new TypeError( 'invalid argument. Options argument must be an object. Value:
|
|
64
|
+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
|
|
64
65
|
}
|
|
65
66
|
if ( hasOwnProp( options, 'iter' ) ) {
|
|
66
67
|
opts.iter = options.iter;
|
|
67
68
|
if ( !isNonNegativeInteger( options.iter ) ) {
|
|
68
|
-
return new TypeError( 'invalid option. `
|
|
69
|
+
return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
if ( hasOwnProp( options, 'tol' ) ) {
|
|
72
73
|
opts.tol = options.tol;
|
|
73
74
|
if ( !isFinite( options.tol ) || options.tol <= 0.0 ) {
|
|
74
|
-
return new TypeError( 'invalid option. `
|
|
75
|
+
return new TypeError( format( 'invalid option. `%s` option must be a positive finite number. Option: `%s`.', 'tol', options.tol ) );
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
if ( hasOwnProp( options, 'returns' ) ) {
|
|
78
79
|
opts.returns = options.returns;
|
|
79
80
|
if ( returns.indexOf( options.returns ) === -1 ) {
|
|
80
|
-
return new TypeError( 'invalid option. `
|
|
81
|
+
return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'returns', returns.join( '", "' ), options.returns ) );
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/math-iter-sequences-continued-fraction",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
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": {
|
|
@@ -37,28 +37,31 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-has-own-property": "^0.
|
|
41
|
-
"@stdlib/assert-is-finite": "^0.0
|
|
42
|
-
"@stdlib/assert-is-nonnegative-integer": "^0.0
|
|
43
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
44
|
-
"@stdlib/constants-float64-eps": "^0.0
|
|
45
|
-
"@stdlib/math-base-special-abs": "^0.0
|
|
46
|
-
"@stdlib/math-base-special-floor": "^0.0
|
|
47
|
-
"@stdlib/
|
|
48
|
-
"@stdlib/
|
|
49
|
-
"@stdlib/
|
|
50
|
-
"@stdlib/utils-
|
|
40
|
+
"@stdlib/assert-has-own-property": "^0.1.1",
|
|
41
|
+
"@stdlib/assert-is-finite": "^0.2.0",
|
|
42
|
+
"@stdlib/assert-is-nonnegative-integer": "^0.2.0",
|
|
43
|
+
"@stdlib/assert-is-plain-object": "^0.2.0",
|
|
44
|
+
"@stdlib/constants-float64-eps": "^0.2.0",
|
|
45
|
+
"@stdlib/math-base-special-abs": "^0.2.0",
|
|
46
|
+
"@stdlib/math-base-special-floor": "^0.2.0",
|
|
47
|
+
"@stdlib/string-format": "^0.2.0",
|
|
48
|
+
"@stdlib/symbol-iterator": "^0.2.0",
|
|
49
|
+
"@stdlib/types": "^0.3.1",
|
|
50
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0",
|
|
51
|
+
"@stdlib/utils-fifo": "^0.2.0",
|
|
52
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.1"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@stdlib/assert-is-array": "^0.
|
|
54
|
-
"@stdlib/assert-is-iterator-like": "^0.0
|
|
55
|
-
"@stdlib/
|
|
56
|
-
"@stdlib/
|
|
57
|
-
"@stdlib/math-base-assert-is-nan": "^0.0.x",
|
|
55
|
+
"@stdlib/assert-is-array": "^0.1.1",
|
|
56
|
+
"@stdlib/assert-is-iterator-like": "^0.2.0",
|
|
57
|
+
"@stdlib/constants-float64-pi": "^0.1.1",
|
|
58
|
+
"@stdlib/math-base-assert-is-nan": "^0.1.1",
|
|
58
59
|
"proxyquire": "^2.0.0",
|
|
59
60
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
60
61
|
"istanbul": "^0.4.1",
|
|
61
|
-
"tap-
|
|
62
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
63
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
64
|
+
"@stdlib/bench": "^0.3.1"
|
|
62
65
|
},
|
|
63
66
|
"engines": {
|
|
64
67
|
"node": ">=0.10.0",
|
|
@@ -89,7 +92,7 @@
|
|
|
89
92
|
"iter"
|
|
90
93
|
],
|
|
91
94
|
"funding": {
|
|
92
|
-
"type": "
|
|
93
|
-
"url": "https://
|
|
95
|
+
"type": "opencollective",
|
|
96
|
+
"url": "https://opencollective.com/stdlib"
|
|
94
97
|
}
|
|
95
98
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( x[, options] )
|
|
3
|
-
Returns an iterator which generates a list of all continued fraction terms
|
|
4
|
-
which can be obtained given the precision of `x`.
|
|
5
|
-
|
|
6
|
-
If an environment supports Symbol.iterator, the returned iterator is
|
|
7
|
-
iterable.
|
|
8
|
-
|
|
9
|
-
Parameters
|
|
10
|
-
----------
|
|
11
|
-
x: number
|
|
12
|
-
Input value.
|
|
13
|
-
|
|
14
|
-
options: Object (optional)
|
|
15
|
-
Function options.
|
|
16
|
-
|
|
17
|
-
options.iter: integer (optional)
|
|
18
|
-
Maximum number of iterations. Default: 1e308.
|
|
19
|
-
|
|
20
|
-
options.tol: number (optional)
|
|
21
|
-
Tolerance at which to terminate further evaluation of the continued
|
|
22
|
-
fraction. Default: floating-point epsilon.
|
|
23
|
-
|
|
24
|
-
options.returns: string (optional)
|
|
25
|
-
Specifies the type of result to return. Must be one of
|
|
26
|
-
|
|
27
|
-
- terms: return continued fraction terms
|
|
28
|
-
- convergents: return continued fraction convergents
|
|
29
|
-
- *: return both continued fraction terms and their associated
|
|
30
|
-
convergents as a two-element array.
|
|
31
|
-
|
|
32
|
-
Default: 'terms'.
|
|
33
|
-
|
|
34
|
-
Returns
|
|
35
|
-
-------
|
|
36
|
-
iterator: Object
|
|
37
|
-
Iterator.
|
|
38
|
-
|
|
39
|
-
iterator.next(): Function
|
|
40
|
-
Returns an iterator protocol-compliant object containing the next
|
|
41
|
-
iterated value (if one exists) and a boolean flag indicating whether the
|
|
42
|
-
iterator is finished.
|
|
43
|
-
|
|
44
|
-
iterator.return( [value] ): Function
|
|
45
|
-
Finishes an iterator and returns a provided value.
|
|
46
|
-
|
|
47
|
-
Examples
|
|
48
|
-
--------
|
|
49
|
-
// Return continued fraction terms...
|
|
50
|
-
> var it = {{alias}}( 3.245 );
|
|
51
|
-
> var v = it.next().value
|
|
52
|
-
3
|
|
53
|
-
> v = it.next().value
|
|
54
|
-
4
|
|
55
|
-
> v = it.next().value
|
|
56
|
-
12
|
|
57
|
-
> v = it.next().value
|
|
58
|
-
4
|
|
59
|
-
> var bool = it.next().done
|
|
60
|
-
true
|
|
61
|
-
|
|
62
|
-
// Return continued fraction convergents...
|
|
63
|
-
> it = {{alias}}( 3.245, { 'returns': 'convergents' } );
|
|
64
|
-
> v = it.next().value
|
|
65
|
-
3.0
|
|
66
|
-
> v = it.next().value
|
|
67
|
-
3.25
|
|
68
|
-
> v = it.next().value
|
|
69
|
-
~3.2449
|
|
70
|
-
> v = it.next().value
|
|
71
|
-
3.245
|
|
72
|
-
> bool = it.next().done
|
|
73
|
-
true
|
|
74
|
-
|
|
75
|
-
See Also
|
|
76
|
-
--------
|
|
77
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2022 The Stdlib Authors.
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import iterContinuedFractionSeq = require( './index' );
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// TESTS //
|
|
23
|
-
|
|
24
|
-
// The function returns an iterator...
|
|
25
|
-
{
|
|
26
|
-
iterContinuedFractionSeq( 3.14 ); // $ExpectType Iterator
|
|
27
|
-
iterContinuedFractionSeq( 3.14, {} ); // $ExpectType Iterator
|
|
28
|
-
iterContinuedFractionSeq( 3.14, { 'iter': 10 } ); // $ExpectType Iterator
|
|
29
|
-
iterContinuedFractionSeq( 3.14, { 'tol': 1.0e-10 } ); // $ExpectType Iterator
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// The compiler throws an error if the function is provided a first argument which is not a number...
|
|
33
|
-
{
|
|
34
|
-
iterContinuedFractionSeq( '5' ); // $ExpectError
|
|
35
|
-
iterContinuedFractionSeq( true ); // $ExpectError
|
|
36
|
-
iterContinuedFractionSeq( false ); // $ExpectError
|
|
37
|
-
iterContinuedFractionSeq( null ); // $ExpectError
|
|
38
|
-
iterContinuedFractionSeq( [] ); // $ExpectError
|
|
39
|
-
iterContinuedFractionSeq( {} ); // $ExpectError
|
|
40
|
-
iterContinuedFractionSeq( ( x: number ): number => x ); // $ExpectError
|
|
41
|
-
|
|
42
|
-
iterContinuedFractionSeq( '5', {} ); // $ExpectError
|
|
43
|
-
iterContinuedFractionSeq( true, {} ); // $ExpectError
|
|
44
|
-
iterContinuedFractionSeq( false, {} ); // $ExpectError
|
|
45
|
-
iterContinuedFractionSeq( null, {} ); // $ExpectError
|
|
46
|
-
iterContinuedFractionSeq( [], {} ); // $ExpectError
|
|
47
|
-
iterContinuedFractionSeq( {}, {} ); // $ExpectError
|
|
48
|
-
iterContinuedFractionSeq( ( x: number ): number => x, {} ); // $ExpectError
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// The compiler throws an error if the function is provided a second argument which is not an options object...
|
|
52
|
-
{
|
|
53
|
-
iterContinuedFractionSeq( 3.14, '5' ); // $ExpectError
|
|
54
|
-
iterContinuedFractionSeq( 3.14, 5 ); // $ExpectError
|
|
55
|
-
iterContinuedFractionSeq( 3.14, true ); // $ExpectError
|
|
56
|
-
iterContinuedFractionSeq( 3.14, false ); // $ExpectError
|
|
57
|
-
iterContinuedFractionSeq( 3.14, null ); // $ExpectError
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// The compiler throws an error if the function is provided an `iter` option which is not a number...
|
|
61
|
-
{
|
|
62
|
-
iterContinuedFractionSeq( 3.14, { 'iter': '5' } ); // $ExpectError
|
|
63
|
-
iterContinuedFractionSeq( 3.14, { 'iter': true } ); // $ExpectError
|
|
64
|
-
iterContinuedFractionSeq( 3.14, { 'iter': false } ); // $ExpectError
|
|
65
|
-
iterContinuedFractionSeq( 3.14, { 'iter': null } ); // $ExpectError
|
|
66
|
-
iterContinuedFractionSeq( 3.14, { 'iter': [] } ); // $ExpectError
|
|
67
|
-
iterContinuedFractionSeq( 3.14, { 'iter': {} } ); // $ExpectError
|
|
68
|
-
iterContinuedFractionSeq( 3.14, { 'iter': ( x: number ): number => x } ); // $ExpectError
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// The compiler throws an error if the function is provided a `tol` option which is not a number...
|
|
72
|
-
{
|
|
73
|
-
iterContinuedFractionSeq( 3.14, { 'tol': '5' } ); // $ExpectError
|
|
74
|
-
iterContinuedFractionSeq( 3.14, { 'tol': true } ); // $ExpectError
|
|
75
|
-
iterContinuedFractionSeq( 3.14, { 'tol': false } ); // $ExpectError
|
|
76
|
-
iterContinuedFractionSeq( 3.14, { 'tol': null } ); // $ExpectError
|
|
77
|
-
iterContinuedFractionSeq( 3.14, { 'tol': [] } ); // $ExpectError
|
|
78
|
-
iterContinuedFractionSeq( 3.14, { 'tol': {} } ); // $ExpectError
|
|
79
|
-
iterContinuedFractionSeq( 3.14, { 'tol': ( x: number ): number => x } ); // $ExpectError
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// The compiler throws an error if the function is provided a `returns` option which is not a supported value...
|
|
83
|
-
{
|
|
84
|
-
iterContinuedFractionSeq( 3.14, { 'returns': '5' } ); // $ExpectError
|
|
85
|
-
iterContinuedFractionSeq( 3.14, { 'returns': 5 } ); // $ExpectError
|
|
86
|
-
iterContinuedFractionSeq( 3.14, { 'returns': true } ); // $ExpectError
|
|
87
|
-
iterContinuedFractionSeq( 3.14, { 'returns': false } ); // $ExpectError
|
|
88
|
-
iterContinuedFractionSeq( 3.14, { 'returns': null } ); // $ExpectError
|
|
89
|
-
iterContinuedFractionSeq( 3.14, { 'returns': [] } ); // $ExpectError
|
|
90
|
-
iterContinuedFractionSeq( 3.14, { 'returns': {} } ); // $ExpectError
|
|
91
|
-
iterContinuedFractionSeq( 3.14, { 'returns': ( x: number ): number => x } ); // $ExpectError
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
95
|
-
{
|
|
96
|
-
iterContinuedFractionSeq(); // $ExpectError
|
|
97
|
-
iterContinuedFractionSeq( 3.14, {}, {} ); // $ExpectError
|
|
98
|
-
}
|