Skip to content

Commit cabf621

Browse files
author
aayush0325
committed
feat: js files added
1 parent 4ecd2ff commit cabf621

File tree

4 files changed

+226
-0
lines changed

4 files changed

+226
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 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 negaLucas number in single-precision floating-point format.
23+
*
24+
* @module @stdlib/math/base/special/negalucasf
25+
*
26+
* @example
27+
* var negalucasf = require( '@stdlib/math/base/special/negalucasf' );
28+
*
29+
* var y = negalucasf( 0 );
30+
* // returns 2
31+
*
32+
* y = negalucasf( -1 );
33+
* // returns -1
34+
*
35+
* y = negalucasf( -2 );
36+
* // returns 3
37+
*
38+
* y = negalucasf( -3 );
39+
* // returns -4
40+
*
41+
* y = negalucasf( -4 );
42+
* // returns 7
43+
*
44+
* y = negalucasf( -5 );
45+
* // returns -11
46+
*
47+
* y = negalucasf( -6 );
48+
* // returns 18
49+
*/
50+
51+
// MODULES //
52+
53+
var main = require( './main.js' );
54+
55+
56+
// EXPORTS //
57+
58+
module.exports = main;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 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 isIntegerf = require( '@stdlib/math/base/assert/is-integerf' );
25+
var absf = require( '@stdlib/math/base/special/absf' );
26+
var NEGALUCAS = require( './negalucas.json' );
27+
28+
29+
// VARIABLES //
30+
31+
var MAX_LUCAS = 34;
32+
33+
34+
// MAIN //
35+
36+
/**
37+
* Computes the nth negalucas number in single-precision floating-point format.
38+
*
39+
* @param {NonPositiveInteger} n - the negalucas number to compute
40+
* @returns {integer} negalucas number
41+
*
42+
* @example
43+
* var y = negalucasf( 0 );
44+
* // returns 2
45+
*
46+
* @example
47+
* var y = negalucasf( -1 );
48+
* // returns -1
49+
*
50+
* @example
51+
* var y = negalucasf( -2 );
52+
* // returns 3
53+
*
54+
* @example
55+
* var y = negalucasf( -3 );
56+
* // returns -4
57+
*
58+
* @example
59+
* var y = negalucasf( -4 );
60+
* // returns 7
61+
*
62+
* @example
63+
* var y = negalucasf( -5 );
64+
* // returns -11
65+
*
66+
* @example
67+
* var y = negalucasf( -6 );
68+
* // returns 18
69+
*
70+
* @example
71+
* var y = negalucasf( NaN );
72+
* // returns NaN
73+
*
74+
* @example
75+
* var y = negalucasf( -3.14 );
76+
* // returns NaN
77+
*/
78+
function negalucasf( n ) {
79+
var an;
80+
if (
81+
isnanf( n ) ||
82+
isIntegerf( n ) === false ||
83+
n > 0
84+
) {
85+
return NaN;
86+
}
87+
an = absf( n );
88+
if ( an > MAX_LUCAS ) {
89+
return NaN;
90+
}
91+
return NEGALUCAS[ an ];
92+
}
93+
94+
95+
// EXPORTS //
96+
97+
module.exports = negalucasf;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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+
* Compute the nth negalucas number in single-precision floating-point format.
30+
*
31+
* @private
32+
* @param {NonPositiveInteger} n - the negalucas number to compute
33+
* @returns {integer} negalucas number
34+
*
35+
* @example
36+
* var y = negalucasf( 0 );
37+
* // returns 2
38+
*
39+
* @example
40+
* y = negalucasf( -1 );
41+
* // returns -1
42+
*
43+
* @example
44+
* y = negalucasf( -2 );
45+
* // returns 3
46+
*
47+
* @example
48+
* y = negalucasf( -3 );
49+
* // returns -4
50+
*
51+
* @example
52+
* y = negalucasf( -4 );
53+
* // returns 7
54+
*
55+
* @example
56+
* y = negalucasf( -5 );
57+
* // returns -11
58+
*
59+
* @example
60+
* y = negalucasf( -6 );
61+
* // returns 18
62+
*/
63+
function negalucasf( n ) {
64+
return addon( n );
65+
}
66+
67+
68+
// EXPORTS //
69+
70+
module.exports = negalucasf;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[2,-1,3,-4,7,-11,18,-29,47,-76,123,-199,322,-521,843,-1364,2207,-3571,5778,-9349,15127,-24476,39603,-64079,103682,-167761,271443,-439204,710647,-1149851,1860498,-3010349,4870847,-7881196,12752043]

0 commit comments

Comments
 (0)