Skip to content

Commit 709fa52

Browse files
chore: adding essential files
1 parent 04f0f1e commit 709fa52

File tree

29 files changed

+2703
-0
lines changed

29 files changed

+2703
-0
lines changed
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
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+
# Fibonaccif
22+
23+
> Compute the nth [Fibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
24+
25+
<section class="intro">
26+
27+
The [Fibonacci numbers][fibonacci-number] are the integer sequence
28+
29+
<!-- <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"> -->
30+
31+
```math
32+
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots
33+
```
34+
35+
<!-- <div class="equation" align="center" data-raw-text="0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, \ldots" data-equation="eq:fibonacci_sequence">
36+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_sequence.svg" alt="Fibonacci sequence">
37+
<br>
38+
</div> -->
39+
40+
<!-- </equation> -->
41+
42+
The sequence is defined by the recurrence relation
43+
44+
<!-- <equation class="equation" label="eq:fibonacci_recurrence_relation" align="center" raw="F_n = F_{n-1} + F_{n-2}" alt="Fibonacci sequence recurrence relation"> -->
45+
46+
```math
47+
F_n = F_{n-1} + F_{n-2}
48+
```
49+
50+
<!-- <div class="equation" align="center" data-raw-text="F_n = F_{n-1} + F_{n-2}" data-equation="eq:fibonacci_recurrence_relation">
51+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/fibonaccif/docs/img/equation_fibonacci_recurrence_relation.svg" alt="Fibonacci sequence recurrence relation">
52+
<br>
53+
</div> -->
54+
55+
<!-- </equation> -->
56+
57+
with seed values `F_0 = 0` and `F_1 = 1`.
58+
59+
</section>
60+
61+
<!-- /.intro -->
62+
63+
<section class="usage">
64+
65+
## Usage
66+
67+
```javascript
68+
var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' );
69+
```
70+
71+
#### fibonaccif( n )
72+
73+
Computes the nth [Fibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
74+
75+
```javascript
76+
var v = fibonaccif( 0 );
77+
// returns 0
78+
79+
v = fibonaccif( 1 );
80+
// returns 1
81+
82+
v = fibonaccif( 2 );
83+
// returns 1
84+
85+
v = fibonaccif( 3 );
86+
// returns 2
87+
88+
v = fibonaccif( 36 );
89+
// returns 14930352
90+
```
91+
92+
If `n > 36`, the function returns `NaN`, as larger [Fibonacci numbers][fibonacci-number] cannot be safely represented in [single-precision floating-point format][ieee754].
93+
94+
```javascript
95+
var v = fibonaccif( 37 );
96+
// returns NaN
97+
```
98+
99+
If not provided a nonnegative integer value, the function returns `NaN`.
100+
101+
```javascript
102+
var v = fibonaccif( 3.14 );
103+
// returns NaN
104+
105+
v = fibonaccif( -1 );
106+
// returns NaN
107+
```
108+
109+
If provided `NaN`, the function returns `NaN`.
110+
111+
```javascript
112+
var v = fibonaccif( NaN );
113+
// returns NaN
114+
```
115+
116+
</section>
117+
118+
<!-- /.usage -->
119+
120+
<section class="notes">
121+
122+
</section>
123+
124+
<!-- /.notes -->
125+
126+
<section class="examples">
127+
128+
## Examples
129+
130+
<!-- eslint no-undef: "error" -->
131+
132+
```javascript
133+
var fibonaccif = require( '@stdlib/math/base/special/fibonaccif' );
134+
135+
var v;
136+
var i;
137+
138+
for ( i = 0; i < 37; i++ ) {
139+
v = fibonaccif( i );
140+
console.log( v );
141+
}
142+
```
143+
144+
</section>
145+
146+
<!-- /.examples -->
147+
148+
<!-- C interface documentation. -->
149+
150+
* * *
151+
152+
<section class="c">
153+
154+
## C APIs
155+
156+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
157+
158+
<section class="intro">
159+
160+
</section>
161+
162+
<!-- /.intro -->
163+
164+
<!-- C usage documentation. -->
165+
166+
<section class="usage">
167+
168+
### Usage
169+
170+
```c
171+
#include "stdlib/math/base/special/fibonaccif.h"
172+
```
173+
174+
#### stdlib_base_fibonaccif( n )
175+
176+
Computes the nth [Fibonacci number][fibonacci-number] as a [single-precision floating-point number][ieee754].
177+
178+
```c
179+
float out = stdlib_base_fibonaccif( 0 );
180+
// returns 0
181+
182+
out = stdlib_base_fibonaccif( 1 );
183+
// returns 1
184+
```
185+
186+
The function accepts the following arguments:
187+
188+
- **n**: `[in] int32_t` input value.
189+
190+
```c
191+
float stdlib_base_fibonaccif( const int32_t n );
192+
```
193+
194+
</section>
195+
196+
<!-- /.usage -->
197+
198+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
199+
200+
<section class="notes">
201+
202+
</section>
203+
204+
<!-- /.notes -->
205+
206+
<!-- C API usage examples. -->
207+
208+
<section class="examples">
209+
210+
### Examples
211+
212+
```c
213+
#include "stdlib/math/base/special/fibonaccif.h"
214+
#include <stdio.h>
215+
#include <stdint.h>
216+
217+
int main( void ) {
218+
int32_t i;
219+
float v;
220+
221+
for ( i = 0; i < 37; i++ ) {
222+
v = stdlib_base_fibonaccif( i );
223+
printf( "fibonaccif(%d) = %f\n", i, v );
224+
}
225+
}
226+
```
227+
228+
</section>
229+
230+
<!-- /.examples -->
231+
232+
</section>
233+
234+
<!-- /.c -->
235+
236+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
237+
238+
<section class="related">
239+
240+
</section>
241+
242+
<!-- /.related -->
243+
244+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
245+
246+
<section class="links">
247+
248+
[fibonacci-number]: https://en.wikipedia.org/wiki/Fibonacci_number
249+
250+
[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
251+
252+
<!-- <related-links> -->
253+
254+
<!-- </related-links> -->
255+
256+
</section>
257+
258+
<!-- /.links -->

0 commit comments

Comments
 (0)