@stdlib/math-base-special-fibonaccif 0.1.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 +177 -0
- package/NOTICE +1 -0
- package/README.md +328 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/img/equation_fibonacci_recurrence_relation.svg +34 -0
- package/docs/img/equation_fibonacci_sequence.svg +63 -0
- package/docs/types/index.d.ts +77 -0
- package/include/stdlib/math/base/special/fibonaccif.h +38 -0
- package/lib/fibonacci.json +1 -0
- package/lib/index.js +58 -0
- package/lib/main.js +91 -0
- package/lib/native.js +74 -0
- package/manifest.json +75 -0
- package/package.json +74 -0
- package/src/addon.c +22 -0
- package/src/main.c +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
package/NOTICE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
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
|
+
|
|
32
|
+
# Fibonaccif
|
|
33
|
+
|
|
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
|
+
|
|
36
|
+
> Compute the nth [Fibonacci number][fibonacci-number] as a single-precision floating-point number.
|
|
37
|
+
|
|
38
|
+
<section class="intro">
|
|
39
|
+
|
|
40
|
+
The [Fibonacci numbers][fibonacci-number] are the integer sequence
|
|
41
|
+
|
|
42
|
+
<!-- <equation class="equation" label="eq:fibonacci_sequence" align="center" raw="0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots" alt="Fibonacci sequence"> -->
|
|
43
|
+
|
|
44
|
+
<!-- </equation> -->
|
|
45
|
+
|
|
46
|
+
The sequence is defined by the recurrence relation
|
|
47
|
+
|
|
48
|
+
<!-- <equation class="equation" label="eq:fibonacci_recurrence_relation" align="center" raw="F_n = F_{n-1} + F_{n-2}" alt="Fibonacci sequence recurrence relation"> -->
|
|
49
|
+
|
|
50
|
+
<!-- </equation> -->
|
|
51
|
+
|
|
52
|
+
with seed values `F_0 = 0` and `F_1 = 1`.
|
|
53
|
+
|
|
54
|
+
</section>
|
|
55
|
+
|
|
56
|
+
<!-- /.intro -->
|
|
57
|
+
|
|
58
|
+
<section class="installation">
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install @stdlib/math-base-special-fibonaccif
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
</section>
|
|
67
|
+
|
|
68
|
+
<section class="usage">
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
var fibonaccif = require( '@stdlib/math-base-special-fibonaccif' );
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### fibonaccif( n )
|
|
77
|
+
|
|
78
|
+
Computes the nth [Fibonacci number][fibonacci-number] as a single-precision floating-point number.
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
var v = fibonaccif( 0 );
|
|
82
|
+
// returns 0
|
|
83
|
+
|
|
84
|
+
v = fibonaccif( 1 );
|
|
85
|
+
// returns 1
|
|
86
|
+
|
|
87
|
+
v = fibonaccif( 2 );
|
|
88
|
+
// returns 1
|
|
89
|
+
|
|
90
|
+
v = fibonaccif( 3 );
|
|
91
|
+
// returns 2
|
|
92
|
+
|
|
93
|
+
v = fibonaccif( 36 );
|
|
94
|
+
// returns 14930352
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If `n > 36`, the function returns `NaN`, as larger [Fibonacci numbers][fibonacci-number] cannot be safely represented in [single-precision floating-point format][ieee754].
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
var v = fibonaccif( 37 );
|
|
101
|
+
// returns NaN
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If not provided a nonnegative integer value, the function returns `NaN`.
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
var v = fibonaccif( 3.14 );
|
|
108
|
+
// returns NaN
|
|
109
|
+
|
|
110
|
+
v = fibonaccif( -1 );
|
|
111
|
+
// returns NaN
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
If provided `NaN`, the function returns `NaN`.
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
var v = fibonaccif( NaN );
|
|
118
|
+
// returns NaN
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
</section>
|
|
122
|
+
|
|
123
|
+
<!-- /.usage -->
|
|
124
|
+
|
|
125
|
+
<section class="notes">
|
|
126
|
+
|
|
127
|
+
</section>
|
|
128
|
+
|
|
129
|
+
<!-- /.notes -->
|
|
130
|
+
|
|
131
|
+
<section class="examples">
|
|
132
|
+
|
|
133
|
+
## Examples
|
|
134
|
+
|
|
135
|
+
<!-- eslint no-undef: "error" -->
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
|
|
139
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
140
|
+
var fibonaccif = require( '@stdlib/math-base-special-fibonaccif' );
|
|
141
|
+
|
|
142
|
+
var x = discreteUniform( 10, 0, 36 );
|
|
143
|
+
|
|
144
|
+
logEachMap( 'fibonaccif(%d) = %0.1f', x, fibonaccif );
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
</section>
|
|
148
|
+
|
|
149
|
+
<!-- /.examples -->
|
|
150
|
+
|
|
151
|
+
<!-- C interface documentation. -->
|
|
152
|
+
|
|
153
|
+
* * *
|
|
154
|
+
|
|
155
|
+
<section class="c">
|
|
156
|
+
|
|
157
|
+
## C APIs
|
|
158
|
+
|
|
159
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
160
|
+
|
|
161
|
+
<section class="intro">
|
|
162
|
+
|
|
163
|
+
</section>
|
|
164
|
+
|
|
165
|
+
<!-- /.intro -->
|
|
166
|
+
|
|
167
|
+
<!-- C usage documentation. -->
|
|
168
|
+
|
|
169
|
+
<section class="usage">
|
|
170
|
+
|
|
171
|
+
### Usage
|
|
172
|
+
|
|
173
|
+
```c
|
|
174
|
+
#include "stdlib/math/base/special/fibonaccif.h"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### stdlib_base_fibonaccif( n )
|
|
178
|
+
|
|
179
|
+
Computes the nth [Fibonacci number][fibonacci-number] as a single-precision floating-point number.
|
|
180
|
+
|
|
181
|
+
```c
|
|
182
|
+
float out = stdlib_base_fibonaccif( 0.0f );
|
|
183
|
+
// returns 0.0f
|
|
184
|
+
|
|
185
|
+
out = stdlib_base_fibonaccif( 1.0f );
|
|
186
|
+
// returns 1.0f
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The function accepts the following arguments:
|
|
190
|
+
|
|
191
|
+
- **n**: `[in] float` input value.
|
|
192
|
+
|
|
193
|
+
```c
|
|
194
|
+
float stdlib_base_fibonaccif( const float n );
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
</section>
|
|
198
|
+
|
|
199
|
+
<!-- /.usage -->
|
|
200
|
+
|
|
201
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
202
|
+
|
|
203
|
+
<section class="notes">
|
|
204
|
+
|
|
205
|
+
</section>
|
|
206
|
+
|
|
207
|
+
<!-- /.notes -->
|
|
208
|
+
|
|
209
|
+
<!-- C API usage examples. -->
|
|
210
|
+
|
|
211
|
+
<section class="examples">
|
|
212
|
+
|
|
213
|
+
### Examples
|
|
214
|
+
|
|
215
|
+
```c
|
|
216
|
+
#include "stdlib/math/base/special/fibonaccif.h"
|
|
217
|
+
#include <stdio.h>
|
|
218
|
+
|
|
219
|
+
int main( void ) {
|
|
220
|
+
float i;
|
|
221
|
+
float v;
|
|
222
|
+
|
|
223
|
+
for ( i = 0.0f; i < 37.0f; i++ ) {
|
|
224
|
+
v = stdlib_base_fibonaccif( i );
|
|
225
|
+
printf( "fibonaccif(%f) = %f\n", i, v );
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
</section>
|
|
231
|
+
|
|
232
|
+
<!-- /.examples -->
|
|
233
|
+
|
|
234
|
+
</section>
|
|
235
|
+
|
|
236
|
+
<!-- /.c -->
|
|
237
|
+
|
|
238
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
239
|
+
|
|
240
|
+
<section class="related">
|
|
241
|
+
|
|
242
|
+
</section>
|
|
243
|
+
|
|
244
|
+
<!-- /.related -->
|
|
245
|
+
|
|
246
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
<section class="main-repo" >
|
|
250
|
+
|
|
251
|
+
* * *
|
|
252
|
+
|
|
253
|
+
## Notice
|
|
254
|
+
|
|
255
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
256
|
+
|
|
257
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
258
|
+
|
|
259
|
+
#### Community
|
|
260
|
+
|
|
261
|
+
[![Chat][chat-image]][chat-url]
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
See [LICENSE][stdlib-license].
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
## Copyright
|
|
271
|
+
|
|
272
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
273
|
+
|
|
274
|
+
</section>
|
|
275
|
+
|
|
276
|
+
<!-- /.stdlib -->
|
|
277
|
+
|
|
278
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
279
|
+
|
|
280
|
+
<section class="links">
|
|
281
|
+
|
|
282
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-special-fibonaccif.svg
|
|
283
|
+
[npm-url]: https://npmjs.org/package/@stdlib/math-base-special-fibonaccif
|
|
284
|
+
|
|
285
|
+
[test-image]: https://github.com/stdlib-js/math-base-special-fibonaccif/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
286
|
+
[test-url]: https://github.com/stdlib-js/math-base-special-fibonaccif/actions/workflows/test.yml?query=branch:v0.1.0
|
|
287
|
+
|
|
288
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-special-fibonaccif/main.svg
|
|
289
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-special-fibonaccif?branch=main
|
|
290
|
+
|
|
291
|
+
<!--
|
|
292
|
+
|
|
293
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/math-base-special-fibonaccif.svg
|
|
294
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/math-base-special-fibonaccif/main
|
|
295
|
+
|
|
296
|
+
-->
|
|
297
|
+
|
|
298
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
299
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
300
|
+
|
|
301
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
302
|
+
|
|
303
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
304
|
+
|
|
305
|
+
[umd]: https://github.com/umdjs/umd
|
|
306
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
307
|
+
|
|
308
|
+
[deno-url]: https://github.com/stdlib-js/math-base-special-fibonaccif/tree/deno
|
|
309
|
+
[deno-readme]: https://github.com/stdlib-js/math-base-special-fibonaccif/blob/deno/README.md
|
|
310
|
+
[umd-url]: https://github.com/stdlib-js/math-base-special-fibonaccif/tree/umd
|
|
311
|
+
[umd-readme]: https://github.com/stdlib-js/math-base-special-fibonaccif/blob/umd/README.md
|
|
312
|
+
[esm-url]: https://github.com/stdlib-js/math-base-special-fibonaccif/tree/esm
|
|
313
|
+
[esm-readme]: https://github.com/stdlib-js/math-base-special-fibonaccif/blob/esm/README.md
|
|
314
|
+
[branches-url]: https://github.com/stdlib-js/math-base-special-fibonaccif/blob/main/branches.md
|
|
315
|
+
|
|
316
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-base-special-fibonaccif/main/LICENSE
|
|
317
|
+
|
|
318
|
+
[fibonacci-number]: https://en.wikipedia.org/wiki/Fibonacci_number
|
|
319
|
+
|
|
320
|
+
[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
|
|
321
|
+
|
|
322
|
+
<!-- <related-links> -->
|
|
323
|
+
|
|
324
|
+
<!-- </related-links> -->
|
|
325
|
+
|
|
326
|
+
</section>
|
|
327
|
+
|
|
328
|
+
<!-- /.links -->
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(I,s){s.exports=[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352]});var u=i(function(C,a){
|
|
2
|
+
var n=require('@stdlib/math-base-assert-is-nanf/dist'),f=require('@stdlib/math-base-assert-is-nonnegative-integerf/dist'),v=require('@stdlib/constants-float32-max-safe-nth-fibonacci/dist'),N=t();function c(r){return n(r)||!f(r)||r>v?NaN:N[r]}a.exports=c
|
|
3
|
+
});var o=u();module.exports=o;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/fibonacci.json", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352]\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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 isnanf = require( '@stdlib/math-base-assert-is-nanf' );\nvar isNonNegativeIntegerf = require( '@stdlib/math-base-assert-is-nonnegative-integerf' );\nvar MAX_FIBONACCI = require( '@stdlib/constants-float32-max-safe-nth-fibonacci' );\nvar FIBONACCI = require( './fibonacci.json' );\n\n\n// MAIN //\n\n/**\n* Computes the nth Fibonacci number as a single-precision floating-point number.\n*\n* @param {NonNegativeInteger} n - the Fibonacci number to compute\n* @returns {NonNegativeInteger} Fibonacci number\n*\n* @example\n* var y = fibonaccif( 0 );\n* // returns 0\n*\n* @example\n* var y = fibonaccif( 1 );\n* // returns 1\n*\n* @example\n* var y = fibonaccif( 2 );\n* // returns 1\n*\n* @example\n* var y = fibonaccif( 3 );\n* // returns 2\n*\n* @example\n* var y = fibonaccif( 4 );\n* // returns 3\n*\n* @example\n* var y = fibonaccif( 5 );\n* // returns 5\n*\n* @example\n* var y = fibonaccif( 6 );\n* // returns 8\n*\n* @example\n* var y = fibonaccif( NaN );\n* // returns NaN\n*\n* @example\n* var y = fibonaccif( 3.14 );\n* // returns NaN\n*\n* @example\n* var y = fibonaccif( -1.0 );\n* // returns NaN\n*/\nfunction fibonaccif( n ) {\n\tif (\n\t\tisnanf( n ) ||\n\t\t!isNonNegativeIntegerf( n ) ||\n\t\tn > MAX_FIBONACCI\n\t) {\n\t\treturn NaN;\n\t}\n\treturn FIBONACCI[ n ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = fibonaccif;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Compute the nth Fibonacci number as a single-precision floating-point number.\n*\n* @module @stdlib/math-base-special-fibonaccif\n*\n* @example\n* var fibonaccif = require( '@stdlib/math-base-special-fibonaccif' );\n*\n* var y = fibonaccif( 0 );\n* // returns 0\n*\n* y = fibonaccif( 1 );\n* // returns 1\n*\n* y = fibonaccif( 2 );\n* // returns 1\n*\n* y = fibonaccif( 3 );\n* // returns 2\n*\n* y = fibonaccif( 4 );\n* // returns 3\n*\n* y = fibonaccif( 5 );\n* // returns 5\n*\n* y = fibonaccif( 6 );\n* // returns 8\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,EAAAC,EAAA,CAAAA,EAAA,SAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,ICAvL,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,kCAAmC,EACrDC,EAAwB,QAAS,kDAAmD,EACpFC,EAAgB,QAAS,kDAAmD,EAC5EC,EAAY,IAmDhB,SAASC,EAAYC,EAAI,CACxB,OACCL,EAAQK,CAAE,GACV,CAACJ,EAAuBI,CAAE,GAC1BA,EAAIH,EAEG,IAEDC,EAAWE,CAAE,CACrB,CAKAN,EAAO,QAAUK,ICtCjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_fibonacci", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "isnanf", "isNonNegativeIntegerf", "MAX_FIBONACCI", "FIBONACCI", "fibonaccif", "n", "main"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="18.279ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 7870.1 1080.4" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title">
|
|
2
|
+
<title id="MathJax-SVG-1-Title">upper F Subscript n Baseline equals upper F Subscript n minus 1 Baseline plus upper F Subscript n minus 2</title>
|
|
3
|
+
<defs aria-hidden="true">
|
|
4
|
+
<path stroke-width="1" id="E1-MJMATHI-46" d="M48 1Q31 1 31 11Q31 13 34 25Q38 41 42 43T65 46Q92 46 125 49Q139 52 144 61Q146 66 215 342T285 622Q285 629 281 629Q273 632 228 634H197Q191 640 191 642T193 659Q197 676 203 680H742Q749 676 749 669Q749 664 736 557T722 447Q720 440 702 440H690Q683 445 683 453Q683 454 686 477T689 530Q689 560 682 579T663 610T626 626T575 633T503 634H480Q398 633 393 631Q388 629 386 623Q385 622 352 492L320 363H375Q378 363 398 363T426 364T448 367T472 374T489 386Q502 398 511 419T524 457T529 475Q532 480 548 480H560Q567 475 567 470Q567 467 536 339T502 207Q500 200 482 200H470Q463 206 463 212Q463 215 468 234T473 274Q473 303 453 310T364 317H309L277 190Q245 66 245 60Q245 46 334 46H359Q365 40 365 39T363 19Q359 6 353 0H336Q295 2 185 2Q120 2 86 2T48 1Z"></path>
|
|
5
|
+
<path stroke-width="1" id="E1-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"></path>
|
|
6
|
+
<path stroke-width="1" id="E1-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path>
|
|
7
|
+
<path stroke-width="1" id="E1-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path>
|
|
8
|
+
<path stroke-width="1" id="E1-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path>
|
|
9
|
+
<path stroke-width="1" id="E1-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"></path>
|
|
10
|
+
<path stroke-width="1" id="E1-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"></path>
|
|
11
|
+
</defs>
|
|
12
|
+
<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
|
|
13
|
+
<use xlink:href="#E1-MJMATHI-46" x="0" y="0"></use>
|
|
14
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="910" y="-213"></use>
|
|
15
|
+
<use xlink:href="#E1-MJMAIN-3D" x="1445" y="0"></use>
|
|
16
|
+
<g transform="translate(2502,0)">
|
|
17
|
+
<use xlink:href="#E1-MJMATHI-46" x="0" y="0"></use>
|
|
18
|
+
<g transform="translate(643,-150)">
|
|
19
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="0" y="0"></use>
|
|
20
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMAIN-2212" x="600" y="0"></use>
|
|
21
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMAIN-31" x="1379" y="0"></use>
|
|
22
|
+
</g>
|
|
23
|
+
</g>
|
|
24
|
+
<use xlink:href="#E1-MJMAIN-2B" x="4796" y="0"></use>
|
|
25
|
+
<g transform="translate(5797,0)">
|
|
26
|
+
<use xlink:href="#E1-MJMATHI-46" x="0" y="0"></use>
|
|
27
|
+
<g transform="translate(643,-150)">
|
|
28
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMATHI-6E" x="0" y="0"></use>
|
|
29
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMAIN-2212" x="600" y="0"></use>
|
|
30
|
+
<use transform="scale(0.707)" xlink:href="#E1-MJMAIN-32" x="1379" y="0"></use>
|
|
31
|
+
</g>
|
|
32
|
+
</g>
|
|
33
|
+
</g>
|
|
34
|
+
</svg>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="39.414ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 16969.7 1080.4" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title">
|
|
2
|
+
<title id="MathJax-SVG-1-Title">0 comma 1 comma 1 comma 2 comma 3 comma 5 comma 8 comma 13 comma 21 comma 34 comma 55 comma 89 comma 144 comma ellipsis</title>
|
|
3
|
+
<defs aria-hidden="true">
|
|
4
|
+
<path stroke-width="1" id="E1-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"></path>
|
|
5
|
+
<path stroke-width="1" id="E1-MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z"></path>
|
|
6
|
+
<path stroke-width="1" id="E1-MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path>
|
|
7
|
+
<path stroke-width="1" id="E1-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"></path>
|
|
8
|
+
<path stroke-width="1" id="E1-MJMAIN-33" d="M127 463Q100 463 85 480T69 524Q69 579 117 622T233 665Q268 665 277 664Q351 652 390 611T430 522Q430 470 396 421T302 350L299 348Q299 347 308 345T337 336T375 315Q457 262 457 175Q457 96 395 37T238 -22Q158 -22 100 21T42 130Q42 158 60 175T105 193Q133 193 151 175T169 130Q169 119 166 110T159 94T148 82T136 74T126 70T118 67L114 66Q165 21 238 21Q293 21 321 74Q338 107 338 175V195Q338 290 274 322Q259 328 213 329L171 330L168 332Q166 335 166 348Q166 366 174 366Q202 366 232 371Q266 376 294 413T322 525V533Q322 590 287 612Q265 626 240 626Q208 626 181 615T143 592T132 580H135Q138 579 143 578T153 573T165 566T175 555T183 540T186 520Q186 498 172 481T127 463Z"></path>
|
|
9
|
+
<path stroke-width="1" id="E1-MJMAIN-35" d="M164 157Q164 133 148 117T109 101H102Q148 22 224 22Q294 22 326 82Q345 115 345 210Q345 313 318 349Q292 382 260 382H254Q176 382 136 314Q132 307 129 306T114 304Q97 304 95 310Q93 314 93 485V614Q93 664 98 664Q100 666 102 666Q103 666 123 658T178 642T253 634Q324 634 389 662Q397 666 402 666Q410 666 410 648V635Q328 538 205 538Q174 538 149 544L139 546V374Q158 388 169 396T205 412T256 420Q337 420 393 355T449 201Q449 109 385 44T229 -22Q148 -22 99 32T50 154Q50 178 61 192T84 210T107 214Q132 214 148 197T164 157Z"></path>
|
|
10
|
+
<path stroke-width="1" id="E1-MJMAIN-38" d="M70 417T70 494T124 618T248 666Q319 666 374 624T429 515Q429 485 418 459T392 417T361 389T335 371T324 363L338 354Q352 344 366 334T382 323Q457 264 457 174Q457 95 399 37T249 -22Q159 -22 101 29T43 155Q43 263 172 335L154 348Q133 361 127 368Q70 417 70 494ZM286 386L292 390Q298 394 301 396T311 403T323 413T334 425T345 438T355 454T364 471T369 491T371 513Q371 556 342 586T275 624Q268 625 242 625Q201 625 165 599T128 534Q128 511 141 492T167 463T217 431Q224 426 228 424L286 386ZM250 21Q308 21 350 55T392 137Q392 154 387 169T375 194T353 216T330 234T301 253T274 270Q260 279 244 289T218 306L210 311Q204 311 181 294T133 239T107 157Q107 98 150 60T250 21Z"></path>
|
|
11
|
+
<path stroke-width="1" id="E1-MJMAIN-34" d="M462 0Q444 3 333 3Q217 3 199 0H190V46H221Q241 46 248 46T265 48T279 53T286 61Q287 63 287 115V165H28V211L179 442Q332 674 334 675Q336 677 355 677H373L379 671V211H471V165H379V114Q379 73 379 66T385 54Q393 47 442 46H471V0H462ZM293 211V545L74 212L183 211H293Z"></path>
|
|
12
|
+
<path stroke-width="1" id="E1-MJMAIN-39" d="M352 287Q304 211 232 211Q154 211 104 270T44 396Q42 412 42 436V444Q42 537 111 606Q171 666 243 666Q245 666 249 666T257 665H261Q273 665 286 663T323 651T370 619T413 560Q456 472 456 334Q456 194 396 97Q361 41 312 10T208 -22Q147 -22 108 7T68 93T121 149Q143 149 158 135T173 96Q173 78 164 65T148 49T135 44L131 43Q131 41 138 37T164 27T206 22H212Q272 22 313 86Q352 142 352 280V287ZM244 248Q292 248 321 297T351 430Q351 508 343 542Q341 552 337 562T323 588T293 615T246 625Q208 625 181 598Q160 576 154 546T147 441Q147 358 152 329T172 282Q197 248 244 248Z"></path>
|
|
13
|
+
<path stroke-width="1" id="E1-MJMAIN-2026" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60ZM525 60Q525 84 542 102T585 120Q609 120 627 104T646 61Q646 36 629 18T586 0T543 17T525 60ZM972 60Q972 84 989 102T1032 120Q1056 120 1074 104T1093 61Q1093 36 1076 18T1033 0T990 17T972 60Z"></path>
|
|
14
|
+
</defs>
|
|
15
|
+
<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
|
|
16
|
+
<use xlink:href="#E1-MJMAIN-30" x="0" y="0"></use>
|
|
17
|
+
<use xlink:href="#E1-MJMAIN-2C" x="500" y="0"></use>
|
|
18
|
+
<use xlink:href="#E1-MJMAIN-31" x="945" y="0"></use>
|
|
19
|
+
<use xlink:href="#E1-MJMAIN-2C" x="1446" y="0"></use>
|
|
20
|
+
<use xlink:href="#E1-MJMAIN-31" x="1891" y="0"></use>
|
|
21
|
+
<use xlink:href="#E1-MJMAIN-2C" x="2391" y="0"></use>
|
|
22
|
+
<use xlink:href="#E1-MJMAIN-32" x="2836" y="0"></use>
|
|
23
|
+
<use xlink:href="#E1-MJMAIN-2C" x="3337" y="0"></use>
|
|
24
|
+
<use xlink:href="#E1-MJMAIN-33" x="3782" y="0"></use>
|
|
25
|
+
<use xlink:href="#E1-MJMAIN-2C" x="4283" y="0"></use>
|
|
26
|
+
<use xlink:href="#E1-MJMAIN-35" x="4728" y="0"></use>
|
|
27
|
+
<use xlink:href="#E1-MJMAIN-2C" x="5228" y="0"></use>
|
|
28
|
+
<use xlink:href="#E1-MJMAIN-38" x="5674" y="0"></use>
|
|
29
|
+
<use xlink:href="#E1-MJMAIN-2C" x="6174" y="0"></use>
|
|
30
|
+
<g transform="translate(6619,0)">
|
|
31
|
+
<use xlink:href="#E1-MJMAIN-31"></use>
|
|
32
|
+
<use xlink:href="#E1-MJMAIN-33" x="500" y="0"></use>
|
|
33
|
+
</g>
|
|
34
|
+
<use xlink:href="#E1-MJMAIN-2C" x="7620" y="0"></use>
|
|
35
|
+
<g transform="translate(8065,0)">
|
|
36
|
+
<use xlink:href="#E1-MJMAIN-32"></use>
|
|
37
|
+
<use xlink:href="#E1-MJMAIN-31" x="500" y="0"></use>
|
|
38
|
+
</g>
|
|
39
|
+
<use xlink:href="#E1-MJMAIN-2C" x="9066" y="0"></use>
|
|
40
|
+
<g transform="translate(9512,0)">
|
|
41
|
+
<use xlink:href="#E1-MJMAIN-33"></use>
|
|
42
|
+
<use xlink:href="#E1-MJMAIN-34" x="500" y="0"></use>
|
|
43
|
+
</g>
|
|
44
|
+
<use xlink:href="#E1-MJMAIN-2C" x="10513" y="0"></use>
|
|
45
|
+
<g transform="translate(10958,0)">
|
|
46
|
+
<use xlink:href="#E1-MJMAIN-35"></use>
|
|
47
|
+
<use xlink:href="#E1-MJMAIN-35" x="500" y="0"></use>
|
|
48
|
+
</g>
|
|
49
|
+
<use xlink:href="#E1-MJMAIN-2C" x="11959" y="0"></use>
|
|
50
|
+
<g transform="translate(12404,0)">
|
|
51
|
+
<use xlink:href="#E1-MJMAIN-38"></use>
|
|
52
|
+
<use xlink:href="#E1-MJMAIN-39" x="500" y="0"></use>
|
|
53
|
+
</g>
|
|
54
|
+
<use xlink:href="#E1-MJMAIN-2C" x="13405" y="0"></use>
|
|
55
|
+
<g transform="translate(13850,0)">
|
|
56
|
+
<use xlink:href="#E1-MJMAIN-31"></use>
|
|
57
|
+
<use xlink:href="#E1-MJMAIN-34" x="500" y="0"></use>
|
|
58
|
+
<use xlink:href="#E1-MJMAIN-34" x="1001" y="0"></use>
|
|
59
|
+
</g>
|
|
60
|
+
<use xlink:href="#E1-MJMAIN-2C" x="15351" y="0"></use>
|
|
61
|
+
<use xlink:href="#E1-MJMAIN-2026" x="15797" y="0"></use>
|
|
62
|
+
</g>
|
|
63
|
+
</svg>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Computes the nth Fibonacci number as a single-precision floating-point number.
|
|
23
|
+
*
|
|
24
|
+
* ## Notes
|
|
25
|
+
*
|
|
26
|
+
* - If `n` is greater than `36`, the function returns `NaN`, as larger Fibonacci numbers cannot be accurately represented due to limitations of single-precision floating-point format.
|
|
27
|
+
* - If not provided a nonnegative integer value, the function returns `NaN`.
|
|
28
|
+
*
|
|
29
|
+
* @param n - the Fibonacci number to compute
|
|
30
|
+
* @returns Fibonacci number
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* var y = fibonaccif( 0 );
|
|
34
|
+
* // returns 0
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var y = fibonaccif( 1 );
|
|
38
|
+
* // returns 1
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var y = fibonaccif( 2 );
|
|
42
|
+
* // returns 1
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var y = fibonaccif( 3 );
|
|
46
|
+
* // returns 2
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var y = fibonaccif( 4 );
|
|
50
|
+
* // returns 3
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* var y = fibonaccif( 5 );
|
|
54
|
+
* // returns 5
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* var y = fibonaccif( 6 );
|
|
58
|
+
* // returns 8
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* var y = fibonaccif( NaN );
|
|
62
|
+
* // returns NaN
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* var y = fibonaccif( 3.14 );
|
|
66
|
+
* // returns NaN
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* var y = fibonaccif( -1.0 );
|
|
70
|
+
* // returns NaN
|
|
71
|
+
*/
|
|
72
|
+
declare function fibonaccif( n: number ): number;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
// EXPORTS //
|
|
76
|
+
|
|
77
|
+
export = fibonaccif;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
#ifndef STDLIB_MATH_BASE_SPECIAL_FIBONACCIF_H
|
|
20
|
+
#define STDLIB_MATH_BASE_SPECIAL_FIBONACCIF_H
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
24
|
+
*/
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Computes the nth Fibonacci number as a single-precision floating-point number.
|
|
31
|
+
*/
|
|
32
|
+
float stdlib_base_fibonaccif( const float n );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_MATH_BASE_SPECIAL_FIBONACCIF_H
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352]
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Compute the nth Fibonacci number as a single-precision floating-point number.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/math-base-special-fibonaccif
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var fibonaccif = require( '@stdlib/math-base-special-fibonaccif' );
|
|
28
|
+
*
|
|
29
|
+
* var y = fibonaccif( 0 );
|
|
30
|
+
* // returns 0
|
|
31
|
+
*
|
|
32
|
+
* y = fibonaccif( 1 );
|
|
33
|
+
* // returns 1
|
|
34
|
+
*
|
|
35
|
+
* y = fibonaccif( 2 );
|
|
36
|
+
* // returns 1
|
|
37
|
+
*
|
|
38
|
+
* y = fibonaccif( 3 );
|
|
39
|
+
* // returns 2
|
|
40
|
+
*
|
|
41
|
+
* y = fibonaccif( 4 );
|
|
42
|
+
* // returns 3
|
|
43
|
+
*
|
|
44
|
+
* y = fibonaccif( 5 );
|
|
45
|
+
* // returns 5
|
|
46
|
+
*
|
|
47
|
+
* y = fibonaccif( 6 );
|
|
48
|
+
* // returns 8
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
// MODULES //
|
|
52
|
+
|
|
53
|
+
var main = require( './main.js' );
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// EXPORTS //
|
|
57
|
+
|
|
58
|
+
module.exports = main;
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var isnanf = require( '@stdlib/math-base-assert-is-nanf' );
|
|
24
|
+
var isNonNegativeIntegerf = require( '@stdlib/math-base-assert-is-nonnegative-integerf' );
|
|
25
|
+
var MAX_FIBONACCI = require( '@stdlib/constants-float32-max-safe-nth-fibonacci' );
|
|
26
|
+
var FIBONACCI = require( './fibonacci.json' );
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// MAIN //
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Computes the nth Fibonacci number as a single-precision floating-point number.
|
|
33
|
+
*
|
|
34
|
+
* @param {NonNegativeInteger} n - the Fibonacci number to compute
|
|
35
|
+
* @returns {NonNegativeInteger} Fibonacci number
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = fibonaccif( 0 );
|
|
39
|
+
* // returns 0
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = fibonaccif( 1 );
|
|
43
|
+
* // returns 1
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = fibonaccif( 2 );
|
|
47
|
+
* // returns 1
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = fibonaccif( 3 );
|
|
51
|
+
* // returns 2
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = fibonaccif( 4 );
|
|
55
|
+
* // returns 3
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var y = fibonaccif( 5 );
|
|
59
|
+
* // returns 5
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var y = fibonaccif( 6 );
|
|
63
|
+
* // returns 8
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* var y = fibonaccif( NaN );
|
|
67
|
+
* // returns NaN
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* var y = fibonaccif( 3.14 );
|
|
71
|
+
* // returns NaN
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* var y = fibonaccif( -1.0 );
|
|
75
|
+
* // returns NaN
|
|
76
|
+
*/
|
|
77
|
+
function fibonaccif( n ) {
|
|
78
|
+
if (
|
|
79
|
+
isnanf( n ) ||
|
|
80
|
+
!isNonNegativeIntegerf( n ) ||
|
|
81
|
+
n > MAX_FIBONACCI
|
|
82
|
+
) {
|
|
83
|
+
return NaN;
|
|
84
|
+
}
|
|
85
|
+
return FIBONACCI[ n ];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// EXPORTS //
|
|
90
|
+
|
|
91
|
+
module.exports = fibonaccif;
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var addon = require( './../src/addon.node' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Computes the nth Fibonacci number as a single-precision floating-point number.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {NonNegativeInteger} n - the Fibonacci number to compute
|
|
33
|
+
* @returns {NonNegativeInteger} Fibonacci number
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var y = fibonaccif( 0 );
|
|
37
|
+
* // returns 0
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* var y = fibonaccif( 1 );
|
|
41
|
+
* // returns 1
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* var y = fibonaccif( 2 );
|
|
45
|
+
* // returns 1
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var y = fibonaccif( 3 );
|
|
49
|
+
* // returns 2
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* var y = fibonaccif( 4 );
|
|
53
|
+
* // returns 3
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* var y = fibonaccif( 5 );
|
|
57
|
+
* // returns 5
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* var y = fibonaccif( 6 );
|
|
61
|
+
* // returns 8
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* var y = fibonaccif( -1 );
|
|
65
|
+
* // returns NaN
|
|
66
|
+
*/
|
|
67
|
+
function fibonaccif( n ) {
|
|
68
|
+
return addon( n );
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// EXPORTS //
|
|
73
|
+
|
|
74
|
+
module.exports = fibonaccif;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {
|
|
3
|
+
"task": "build"
|
|
4
|
+
},
|
|
5
|
+
"fields": [
|
|
6
|
+
{
|
|
7
|
+
"field": "src",
|
|
8
|
+
"resolve": true,
|
|
9
|
+
"relative": true
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"field": "include",
|
|
13
|
+
"resolve": true,
|
|
14
|
+
"relative": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"field": "libraries",
|
|
18
|
+
"resolve": false,
|
|
19
|
+
"relative": false
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"field": "libpath",
|
|
23
|
+
"resolve": true,
|
|
24
|
+
"relative": false
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"confs": [
|
|
28
|
+
{
|
|
29
|
+
"task": "build",
|
|
30
|
+
"src": [
|
|
31
|
+
"./src/main.c"
|
|
32
|
+
],
|
|
33
|
+
"include": [
|
|
34
|
+
"./include"
|
|
35
|
+
],
|
|
36
|
+
"libraries": [],
|
|
37
|
+
"libpath": [],
|
|
38
|
+
"dependencies": [
|
|
39
|
+
"@stdlib/math-base-napi-unary",
|
|
40
|
+
"@stdlib/math-base-assert-is-nonnegative-integerf",
|
|
41
|
+
"@stdlib/constants-float32-max-safe-nth-fibonacci"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"task": "benchmark",
|
|
46
|
+
"src": [
|
|
47
|
+
"./src/main.c"
|
|
48
|
+
],
|
|
49
|
+
"include": [
|
|
50
|
+
"./include"
|
|
51
|
+
],
|
|
52
|
+
"libraries": [],
|
|
53
|
+
"libpath": [],
|
|
54
|
+
"dependencies": [
|
|
55
|
+
"@stdlib/math-base-assert-is-nonnegative-integerf",
|
|
56
|
+
"@stdlib/constants-float32-max-safe-nth-fibonacci"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"task": "examples",
|
|
61
|
+
"src": [
|
|
62
|
+
"./src/main.c"
|
|
63
|
+
],
|
|
64
|
+
"include": [
|
|
65
|
+
"./include"
|
|
66
|
+
],
|
|
67
|
+
"libraries": [],
|
|
68
|
+
"libpath": [],
|
|
69
|
+
"dependencies": [
|
|
70
|
+
"@stdlib/math-base-assert-is-nonnegative-integerf",
|
|
71
|
+
"@stdlib/constants-float32-max-safe-nth-fibonacci"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/math-base-special-fibonaccif",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Compute the nth Fibonacci number as a single-precision floating-point number.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
18
|
+
"directories": {
|
|
19
|
+
"doc": "./docs",
|
|
20
|
+
"include": "./include",
|
|
21
|
+
"lib": "./lib",
|
|
22
|
+
"src": "./src",
|
|
23
|
+
"dist": "./dist"
|
|
24
|
+
},
|
|
25
|
+
"types": "./docs/types",
|
|
26
|
+
"scripts": {},
|
|
27
|
+
"homepage": "https://stdlib.io",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git://github.com/stdlib-js/math-base-special-fibonaccif.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@stdlib/constants-float32-max-safe-nth-fibonacci": "github:stdlib-js/constants-float32-max-safe-nth-fibonacci#main",
|
|
37
|
+
"@stdlib/math-base-assert-is-nanf": "^0.2.2",
|
|
38
|
+
"@stdlib/math-base-assert-is-nonnegative-integerf": "^0.1.0",
|
|
39
|
+
"@stdlib/math-base-napi-unary": "^0.2.4",
|
|
40
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=0.10.0",
|
|
45
|
+
"npm": ">2.7.0"
|
|
46
|
+
},
|
|
47
|
+
"os": [
|
|
48
|
+
"aix",
|
|
49
|
+
"darwin",
|
|
50
|
+
"freebsd",
|
|
51
|
+
"linux",
|
|
52
|
+
"macos",
|
|
53
|
+
"openbsd",
|
|
54
|
+
"sunos",
|
|
55
|
+
"win32",
|
|
56
|
+
"windows"
|
|
57
|
+
],
|
|
58
|
+
"keywords": [
|
|
59
|
+
"stdlib",
|
|
60
|
+
"stdmath",
|
|
61
|
+
"mathematics",
|
|
62
|
+
"math",
|
|
63
|
+
"special functions",
|
|
64
|
+
"special",
|
|
65
|
+
"function",
|
|
66
|
+
"fibonacci",
|
|
67
|
+
"fib",
|
|
68
|
+
"number"
|
|
69
|
+
],
|
|
70
|
+
"funding": {
|
|
71
|
+
"type": "opencollective",
|
|
72
|
+
"url": "https://opencollective.com/stdlib"
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
#include "stdlib/math/base/special/fibonaccif.h"
|
|
20
|
+
#include "stdlib/math/base/napi/unary.h"
|
|
21
|
+
|
|
22
|
+
STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_fibonaccif )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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
|
+
#include "stdlib/math/base/special/fibonaccif.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nonnegative_integerf.h"
|
|
21
|
+
#include "stdlib/constants/float32/max_safe_nth_fibonacci.h"
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
#include <stdlib.h>
|
|
24
|
+
|
|
25
|
+
static const int32_t fibonacci_value[ 37 ] = {
|
|
26
|
+
0,
|
|
27
|
+
1,
|
|
28
|
+
1,
|
|
29
|
+
2,
|
|
30
|
+
3,
|
|
31
|
+
5,
|
|
32
|
+
8,
|
|
33
|
+
13,
|
|
34
|
+
21,
|
|
35
|
+
34,
|
|
36
|
+
55,
|
|
37
|
+
89,
|
|
38
|
+
144,
|
|
39
|
+
233,
|
|
40
|
+
377,
|
|
41
|
+
610,
|
|
42
|
+
987,
|
|
43
|
+
1597,
|
|
44
|
+
2584,
|
|
45
|
+
4181,
|
|
46
|
+
6765,
|
|
47
|
+
10946,
|
|
48
|
+
17711,
|
|
49
|
+
28657,
|
|
50
|
+
46368,
|
|
51
|
+
75025,
|
|
52
|
+
121393,
|
|
53
|
+
196418,
|
|
54
|
+
317811,
|
|
55
|
+
514229,
|
|
56
|
+
832040,
|
|
57
|
+
1346269,
|
|
58
|
+
2178309,
|
|
59
|
+
3524578,
|
|
60
|
+
5702887,
|
|
61
|
+
9227465,
|
|
62
|
+
14930352
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Computes the nth Fibonacci number as a single-precision floating-point number.
|
|
67
|
+
*
|
|
68
|
+
* @param n input value
|
|
69
|
+
* @return output value
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* float out = stdlib_base_fibonaccif( 1.0f );
|
|
73
|
+
* // returns 1.0f
|
|
74
|
+
*/
|
|
75
|
+
float stdlib_base_fibonaccif( const float n ) {
|
|
76
|
+
if ( !stdlib_base_is_nonnegative_integerf( n ) || n > STDLIB_CONSTANT_FLOAT32_MAX_SAFE_NTH_FIBONACCI ) {
|
|
77
|
+
return 0.0f / 0.0f; // NaN
|
|
78
|
+
}
|
|
79
|
+
return fibonacci_value[ (size_t)n ];
|
|
80
|
+
}
|