Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 3, 2025
1 parent 2a2bca0 commit 23f1dee
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 70 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<section class="release" id="unreleased">

## Unreleased (2025-01-02)
## Unreleased (2025-01-03)

<section class="packages">

Expand Down Expand Up @@ -2767,13 +2767,14 @@ A total of 2 issues were closed in this release:

### Contributors

A total of 5 people contributed to this release. Thank you to the following contributors:
A total of 6 people contributed to this release. Thank you to the following contributors:

- Aayush Khanna
- Athan Reines
- Gunj Joshi
- Gururaj Gurram
- Philipp Burckhardt
- Vivek Maurya

</section>

Expand All @@ -2785,6 +2786,7 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`861cd7f`](https://github.com/stdlib-js/stdlib/commit/861cd7fe43675fb2d0c964415f117c3f36e3d5bf) - **refactor:** update `math/base/assert/is-even` to follow latest project conventions [(#4183)](https://github.com/stdlib-js/stdlib/pull/4183) _(by Vivek Maurya, Athan Reines)_
- [`14706e4`](https://github.com/stdlib-js/stdlib/commit/14706e4baccbf3b827e12cae163d7b98a96b0fa8) - **docs:** update related packages sections [(#4445)](https://github.com/stdlib-js/stdlib/pull/4445) _(by stdlib-bot)_
- [`b518ff1`](https://github.com/stdlib-js/stdlib/commit/b518ff110e120612be4d53b9f124a3c210711610) - **feat:** add C implementation for `math/base/special/falling-factorial` _(by Gunj Joshi, stdlib-bot, Philipp Burckhardt)_
- [`0d52a8a`](https://github.com/stdlib-js/stdlib/commit/0d52a8a0eec7221c0147185c4ce3317db0458498) - **chore:** minor clean-up _(by Philipp Burckhardt)_
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Daniel Killenberger <[email protected]>
Daniel Yu <[email protected]>
Debashis Maharana <[email protected]>
Desh Deepak Kant <[email protected]>
Dhruv/ <[email protected]>
Divyansh Seth <[email protected]>
Dominic Lim <[email protected]>
Dominik Moritz <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2016-2024 The Stdlib Authors.
Copyright (c) 2016-2025 The Stdlib Authors.
10 changes: 6 additions & 4 deletions base/assert/is-even/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( './../../../../base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var isEven = require( './../lib' );
Expand All @@ -31,14 +30,17 @@ var isEven = require( './../lib' );
// MAIN //

bench( pkg, function benchmark( b ) {
var len;
var x;
var y;
var i;

len = 100;
x = discreteUniform( len, 0, 1000 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = round( (randu()*1.0e7) - 5.0e6 );
y = isEven( x );
y = isEven( x[ i % len ] );
if ( typeof y !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
Expand Down
10 changes: 6 additions & 4 deletions base/assert/is-even/benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( './../../../../base/special/round' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -40,14 +39,17 @@ var opts = {
// MAIN //

bench( pkg+'::native', opts, function benchmark( b ) {
var len;
var x;
var y;
var i;

len = 100;
x = discreteUniform( len, 0, 1000 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = round( (randu()*1.0e7) - 5.0e6 );
y = isEven( x );
y = isEven( x[ i % len ] );
if ( typeof y !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
Expand Down
9 changes: 6 additions & 3 deletions base/assert/is-even/benchmark/c/native/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,18 @@ static double rand_double( void ) {
*/
static double benchmark( void ) {
double elapsed;
double x;
double x[ 100 ];
double t;
bool b;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = round( (rand_double()*200.0) - 100.0 );
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( rand_double() * 200.0 ) - 100.0;
b = stdlib_base_is_even( x );
b = stdlib_base_is_even( x[ i%100 ] );
if ( b != true && b != false ) {
printf( "should return either true or false\n" );
break;
Expand Down
41 changes: 40 additions & 1 deletion base/assert/is-even/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"options": {},
"options": {
"task": "build"
},
"fields": [
{
"field": "src",
Expand All @@ -24,6 +26,43 @@
],
"confs": [
{
"task": "build",
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-integer",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
"@stdlib/napi/create-int32"
]
},
{
"task": "benchmark",
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-integer"
]
},
{
"task": "examples",
"src": [
"./src/main.c"
],
Expand Down
64 changes: 9 additions & 55 deletions base/assert/is-even/src/addon.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
*/

#include "stdlib/math/base/assert/is_even.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_double.h"
#include "stdlib/napi/create_int32.h"
#include "stdlib/napi/export.h"
#include <node_api.h>
#include <stdint.h>
#include <assert.h>

/**
* Receives JavaScript callback invocation data.
Expand All @@ -29,60 +32,11 @@
* @return Node-API value
*/
static napi_value addon( napi_env env, napi_callback_info info ) {
napi_status status;

// Get callback arguments:
size_t argc = 1;
napi_value argv[ 1 ];
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
assert( status == napi_ok );

// Check whether we were provided the correct number of arguments:
if ( argc < 1 ) {
status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." );
assert( status == napi_ok );
return NULL;
}
if ( argc > 1 ) {
status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." );
assert( status == napi_ok );
return NULL;
}

napi_valuetype vtype0;
status = napi_typeof( env, argv[ 0 ], &vtype0 );
assert( status == napi_ok );
if ( vtype0 != napi_number ) {
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." );
assert( status == napi_ok );
return NULL;
}

double x;
status = napi_get_value_double( env, argv[ 0 ], &x );
assert( status == napi_ok );

bool result = stdlib_base_is_even( x );

napi_value v;
status = napi_create_int32( env, (int32_t)result, &v );
assert( status == napi_ok );

return v;
STDLIB_NAPI_ARGV( env, info, argv, argc, 1 );
STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 );
STDLIB_NAPI_CREATE_INT32( env, (int32_t)stdlib_base_is_even( x ), out );
return out;
}

/**
* Initializes a Node-API module.
*
* @param env environment under which the function is invoked
* @param exports exports object
* @return main export
*/
static napi_value init( napi_env env, napi_value exports ) {
napi_value fcn;
napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn );
assert( status == napi_ok );
return fcn;
}
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )

NAPI_MODULE( NODE_GYP_MODULE_NAME, init )

0 comments on commit 23f1dee

Please sign in to comment.