Skip to content

Commit 28af1a9

Browse files
committed
feat: add C implementation for math/base/special/falling-factorial
1 parent 3d0b53b commit 28af1a9

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

lib/node_modules/@stdlib/math/base/special/falling-factorial/benchmark/benchmark.native.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -20,17 +20,26 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( 'path' ).resolve;
2324
var bench = require( '@stdlib/bench' );
2425
var randu = require( '@stdlib/random/array/uniform' );
2526
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2627
var isnan = require( '@stdlib/math/base/assert/is-nan' );
28+
var tryRequire = require( '@stdlib/utils/try-require' );
2729
var pkg = require( './../package.json' ).name;
28-
var fallingFactorial = require( './../lib' );
30+
31+
32+
// VARIABLES //
33+
34+
var fallingFactorial = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( fallingFactorial instanceof Error )
37+
};
2938

3039

3140
// MAIN //
3241

33-
bench( pkg, function benchmark( b ) {
42+
bench( pkg+'::native', opts, function benchmark( b ) {
3443
var x;
3544
var n;
3645
var y;

lib/node_modules/@stdlib/math/base/special/falling-factorial/examples/c/Makefile

Whitespace-only changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
#include "stdlib/math/base/special/falling_factorial.h"
20+
#include <stdio.h>
21+
22+
int main( void ) {
23+
const double x[] = { -10.0, -7.78, -5.56, -3.33, -1.11, 1.11, 3.33, 5.56, 7.78, 10.0 };
24+
25+
double v;
26+
int i;
27+
for ( i = 0; i < 10; i++ ) {
28+
v = stdlib_base_falling_factorial( x[ i ] );
29+
printf( "x: %lf, falling_factorial(x): %lf\n", x[ i ], v );
30+
}
31+
}

0 commit comments

Comments
 (0)