diff --git a/.github/.keepalive b/.github/.keepalive
deleted file mode 100644
index 95438be..0000000
--- a/.github/.keepalive
+++ /dev/null
@@ -1 +0,0 @@
-2024-12-30T02:54:33.647Z
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6186bae..7f5e85f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@
-## Unreleased (2024-12-30)
+## Unreleased (2025-01-11)
@@ -12,6 +12,7 @@
+- [`5cc2bcd`](https://github.com/stdlib-js/stdlib/commit/5cc2bcd36d944adfa4f4badea6fce5de223be3dd) - **refactor:** update `stats/base/dmeanvar` native addon from C++ to C [(#4648)](https://github.com/stdlib-js/stdlib/pull/4648) _(by Dhruv Arvind Singh)_
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
- [`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
@@ -27,9 +28,10 @@
### Contributors
-A total of 2 people contributed to this release. Thank you to the following contributors:
+A total of 3 people contributed to this release. Thank you to the following contributors:
- Athan Reines
+- Dhruv Arvind Singh
- Philipp Burckhardt
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 173c07b..92d7552 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -27,6 +27,7 @@ Daniel Killenberger
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
Debashis Maharana
Desh Deepak Kant <118960904+DeshDeepakKant@users.noreply.github.com>
+Dhruv Arvind Singh <154677013+DhruvArvindSingh@users.noreply.github.com>
Divyansh Seth <59174836+sethdivyansh@users.noreply.github.com>
Dominic Lim <46486515+domlimm@users.noreply.github.com>
Dominik Moritz
@@ -49,6 +50,7 @@ Joey Reed
Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
Joris Labie
Justin Dennison
+Karan Anand <119553199+anandkaranubc@users.noreply.github.com>
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
Kohantika Nath <145763549+kohantikanath@users.noreply.github.com>
Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
@@ -117,7 +119,7 @@ UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com>
Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com>
Varad Gupta
Vinit Pandit <106718914+MeastroZI@users.noreply.github.com>
-Vivek maurya <155618190+vivekmaurya001@users.noreply.github.com>
+Vivek Maurya
Xiaochuan Ye
Yaswanth Kosuru <116426380+yaswanthkosuru@users.noreply.github.com>
Yernar Yergaziyev
diff --git a/NOTICE b/NOTICE
index e6e7482..cbd3a29 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1 +1 @@
-Copyright (c) 2016-2024 The Stdlib Authors.
+Copyright (c) 2016-2025 The Stdlib Authors.
diff --git a/README.md b/README.md
index fa468ef..55435b9 100644
--- a/README.md
+++ b/README.md
@@ -319,7 +319,7 @@ See [LICENSE][stdlib-license].
## Copyright
-Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
+Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].
diff --git a/include.gypi b/include.gypi
index 2fa318f..9212937 100644
--- a/include.gypi
+++ b/include.gypi
@@ -36,7 +36,7 @@
# Source files:
'src_files': [
- '<(src_dir)/addon.cpp',
+ '<(src_dir)/addon.c',
'
+
+/**
+* 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 )
diff --git a/src/addon.cpp b/src/addon.cpp
deleted file mode 100644
index 06be1a6..0000000
--- a/src/addon.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
-* @license Apache-2.0
-*
-* Copyright (c) 2020 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
-#include
-#include
-#include
-#include
-
-/**
-* Add-on namespace.
-*/
-namespace stdlib_stats_base_dmeanvar {
-
- /**
- * Computes the mean and variance of a double-precision floating-point strided array.
- *
- * ## Notes
- *
- * - When called from JavaScript, the function expects six arguments:
- *
- * - `N`: number of indexed elements
- * - `correction`: degrees of freedom adjustment
- * - `X`: input array
- * - `strideX`: `X` stride length
- * - `Out`: output array
- * - `strideOut`: `Out` stride length
- */
- napi_value node_dmeanvar( napi_env env, napi_callback_info info ) {
- napi_status status;
-
- size_t argc = 6;
- napi_value argv[ 6 ];
- status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
- assert( status == napi_ok );
-
- if ( argc < 6 ) {
- napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." );
- return nullptr;
- }
-
- napi_valuetype vtype0;
- status = napi_typeof( env, argv[ 0 ], &vtype0 );
- assert( status == napi_ok );
- if ( vtype0 != napi_number ) {
- napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
- return nullptr;
- }
-
- napi_valuetype vtype1;
- status = napi_typeof( env, argv[ 1 ], &vtype1 );
- assert( status == napi_ok );
- if ( vtype1 != napi_number ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." );
- return nullptr;
- }
-
- bool res2;
- status = napi_is_typedarray( env, argv[ 2 ], &res2 );
- assert( status == napi_ok );
- if ( res2 == false ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." );
- return nullptr;
- }
-
- napi_valuetype vtype3;
- status = napi_typeof( env, argv[ 3 ], &vtype3 );
- assert( status == napi_ok );
- if ( vtype3 != napi_number ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." );
- return nullptr;
- }
-
- bool res4;
- status = napi_is_typedarray( env, argv[ 4 ], &res4 );
- assert( status == napi_ok );
- if ( res4 == false ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." );
- return nullptr;
- }
-
- napi_valuetype vtype5;
- status = napi_typeof( env, argv[ 5 ], &vtype5 );
- assert( status == napi_ok );
- if ( vtype5 != napi_number ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." );
- return nullptr;
- }
-
- int64_t N;
- status = napi_get_value_int64( env, argv[ 0 ], &N );
- assert( status == napi_ok );
-
- double correction;
- status = napi_get_value_double( env, argv[ 1 ], &correction );
- assert( status == napi_ok );
-
- int64_t strideX;
- status = napi_get_value_int64( env, argv[ 3 ], &strideX );
- assert( status == napi_ok );
-
- int64_t strideOut;
- status = napi_get_value_int64( env, argv[ 5 ], &strideOut );
- assert( status == napi_ok );
-
- napi_typedarray_type vtype2;
- size_t xlen;
- void *X;
- status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr );
- assert( status == napi_ok );
- if ( vtype2 != napi_float64_array ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." );
- return nullptr;
- }
- if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) {
- napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." );
- return nullptr;
- }
-
- napi_typedarray_type vtype4;
- size_t olen;
- void *Out;
- status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &olen, &Out, nullptr, nullptr );
- assert( status == napi_ok );
- if ( vtype4 != napi_float64_array ) {
- napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." );
- return nullptr;
- }
- if ( llabs(strideOut) > (int64_t)olen ) {
- napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the required number of output elements." );
- return nullptr;
- }
-
- stdlib_strided_dmeanvar( N, correction, (double *)X, strideX, (double *)Out, strideOut );
-
- return nullptr;
- }
-
- napi_value Init( napi_env env, napi_value exports ) {
- napi_status status;
- napi_value fcn;
- status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dmeanvar, NULL, &fcn );
- assert( status == napi_ok );
- return fcn;
- }
-
- NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
-} // end namespace stdlib_stats_base_dmeanvar
diff --git a/src/dmeanvar.c b/src/main.c
similarity index 100%
rename from src/dmeanvar.c
rename to src/main.c