Skip to content

Commit

Permalink
refactor: update stats/base/dmeanvar native addon from C++ to C
Browse files Browse the repository at this point in the history
PR-URL: stdlib-js#4648

Reviewed-by: Philipp Burckhardt <[email protected]>
  • Loading branch information
DhruvArvindSingh authored and Neerajpathak07 committed Jan 23, 2025
1 parent 15cf8d2 commit 509f9b3
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 167 deletions.
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/stats/base/dmeanvar/include.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Source files:
'src_files': [
'<(src_dir)/addon.cpp',
'<(src_dir)/addon.c',
'<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
],

Expand Down
45 changes: 43 additions & 2 deletions lib/node_modules/@stdlib/stats/base/dmeanvar/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,8 +26,47 @@
],
"confs": [
{
"task": "build",
"src": [
"./src/dmeanvar.c"
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-double",
"@stdlib/napi/argv-strided-float64array",
"@stdlib/blas/base/shared",
"@stdlib/stats/base/dmeanvarpn"
]
},
{
"task": "benchmark",
"src": [
"./src/main.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/stats/base/dmeanvarpn"
]
},
{
"task": "examples",
"src": [
"./src/main.c"
],
"include": [
"./include"
Expand Down
47 changes: 47 additions & 0 deletions lib/node_modules/@stdlib/stats/base/dmeanvar/src/addon.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "stdlib/stats/base/dmeanvar.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_int64.h"
#include "stdlib/napi/argv_double.h"
#include "stdlib/napi/argv_strided_float64array.h"
#include <node_api.h>

/**
* Receives JavaScript callback invocation data.
*
* @param env environment under which the function is invoked
* @param info callback data
* @return Node-API value
*/
static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV( env, info, argv, argc, 6 );
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 5 );
STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 );
API_SUFFIX(stdlib_strided_dmeanvar)( N, correction, X, strideX, Out, strideOut );
return NULL;
}

STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
164 changes: 0 additions & 164 deletions lib/node_modules/@stdlib/stats/base/dmeanvar/src/addon.cpp

This file was deleted.

0 comments on commit 509f9b3

Please sign in to comment.