@stdlib/stats-base-ndarray-dminabs 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -118,6 +118,153 @@ console.log( v );
118
118
 
119
119
  <!-- /.examples -->
120
120
 
121
+ <!-- C interface documentation. -->
122
+
123
+ * * *
124
+
125
+ <section class="c">
126
+
127
+ ## C APIs
128
+
129
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
130
+
131
+ <section class="intro">
132
+
133
+ </section>
134
+
135
+ <!-- /.intro -->
136
+
137
+ <!-- C usage documentation. -->
138
+
139
+ <section class="usage">
140
+
141
+ ### Usage
142
+
143
+ ```c
144
+ #include "stdlib/stats/base/ndarray/dminabs.h"
145
+ ```
146
+
147
+ #### stdlib_stats_dminabs( arrays )
148
+
149
+ Computes the minimum absolute value of a one-dimensional double-precision floating-point ndarray.
150
+
151
+ ```c
152
+ #include "stdlib/ndarray/ctor.h"
153
+ #include "stdlib/ndarray/dtypes.h"
154
+ #include "stdlib/ndarray/index_modes.h"
155
+ #include "stdlib/ndarray/orders.h"
156
+ #include "stdlib/ndarray/base/bytes_per_element.h"
157
+ #include <stdint.h>
158
+
159
+ // Create an ndarray:
160
+ const double data[] = { 1.0, 2.0, 3.0, 4.0 };
161
+ int64_t shape[] = { 4 };
162
+ int64_t strides[] = { STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT };
163
+ int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR };
164
+
165
+ struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, 1, shape, strides, 0, STDLIB_NDARRAY_ROW_MAJOR, STDLIB_NDARRAY_INDEX_ERROR, 1, submodes );
166
+
167
+ // Compute the minimum absolute value:
168
+ const struct ndarray *arrays[] = { x };
169
+ double v = stdlib_stats_dminabs( arrays );
170
+ // returns 1.0
171
+
172
+ // Free allocated memory:
173
+ stdlib_ndarray_free( x );
174
+ ```
175
+
176
+ The function accepts the following arguments:
177
+
178
+ - **arrays**: `[in] struct ndarray**` list containing a one-dimensional input ndarray.
179
+
180
+ ```c
181
+ double stdlib_stats_dminabs( const struct ndarray *arrays[] );
182
+ ```
183
+
184
+ </section>
185
+
186
+ <!-- /.usage -->
187
+
188
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
189
+
190
+ <section class="notes">
191
+
192
+ </section>
193
+
194
+ <!-- /.notes -->
195
+
196
+ <!-- C API usage examples. -->
197
+
198
+ <section class="examples">
199
+
200
+ ### Examples
201
+
202
+ ```c
203
+ #include "stdlib/stats/base/ndarray/dminabs.h"
204
+ #include "stdlib/ndarray/ctor.h"
205
+ #include "stdlib/ndarray/dtypes.h"
206
+ #include "stdlib/ndarray/index_modes.h"
207
+ #include "stdlib/ndarray/orders.h"
208
+ #include "stdlib/ndarray/base/bytes_per_element.h"
209
+ #include <stdint.h>
210
+ #include <stdlib.h>
211
+ #include <stdio.h>
212
+
213
+ int main( void ) {
214
+ // Create a data buffer:
215
+ const double data[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };
216
+
217
+ // Specify the number of array dimensions:
218
+ const int64_t ndims = 1;
219
+
220
+ // Specify the array shape:
221
+ int64_t shape[] = { 4 };
222
+
223
+ // Specify the array strides:
224
+ int64_t strides[] = { 2*STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT };
225
+
226
+ // Specify the byte offset:
227
+ const int64_t offset = 0;
228
+
229
+ // Specify the array order:
230
+ const enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR;
231
+
232
+ // Specify the index mode:
233
+ const enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR;
234
+
235
+ // Specify the subscript index modes:
236
+ int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR };
237
+ const int64_t nsubmodes = 1;
238
+
239
+ // Create an ndarray:
240
+ struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes );
241
+ if ( x == NULL ) {
242
+ fprintf( stderr, "Error allocating memory.\n" );
243
+ exit( 1 );
244
+ }
245
+
246
+ // Define a list of ndarrays:
247
+ const struct ndarray *arrays[] = { x };
248
+
249
+ // Compute the minimum absolute value:
250
+ double v = stdlib_stats_dminabs( arrays );
251
+
252
+ // Print the result:
253
+ printf( "min: %lf\n", v );
254
+
255
+ // Free allocated memory:
256
+ stdlib_ndarray_free( x );
257
+ }
258
+ ```
259
+
260
+ </section>
261
+
262
+ <!-- /.examples -->
263
+
264
+ </section>
265
+
266
+ <!-- /.c -->
267
+
121
268
  <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
122
269
 
123
270
  <section class="related">
@@ -165,8 +312,8 @@ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
165
312
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-ndarray-dminabs.svg
166
313
  [npm-url]: https://npmjs.org/package/@stdlib/stats-base-ndarray-dminabs
167
314
 
168
- [test-image]: https://github.com/stdlib-js/stats-base-ndarray-dminabs/actions/workflows/test.yml/badge.svg?branch=v0.1.0
169
- [test-url]: https://github.com/stdlib-js/stats-base-ndarray-dminabs/actions/workflows/test.yml?query=branch:v0.1.0
315
+ [test-image]: https://github.com/stdlib-js/stats-base-ndarray-dminabs/actions/workflows/test.yml/badge.svg?branch=v0.1.1
316
+ [test-url]: https://github.com/stdlib-js/stats-base-ndarray-dminabs/actions/workflows/test.yml?query=branch:v0.1.1
170
317
 
171
318
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-ndarray-dminabs/main.svg
172
319
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-ndarray-dminabs?branch=main
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=a(function(c,i){
2
- var u=require('@stdlib/ndarray-base-numel-dimension/dist'),s=require('@stdlib/ndarray-base-stride/dist'),n=require('@stdlib/ndarray-base-offset/dist'),v=require('@stdlib/ndarray-base-data-buffer/dist'),q=require('@stdlib/stats-strided-dminabs/dist').ndarray;function d(e){var r=e[0];return q(u(r,0),v(r),s(r,0),n(r))}i.exports=d
3
- });var m=t();module.exports=m;
1
+ "use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=n(function(x,a){
2
+ var s=require('@stdlib/ndarray-base-numel-dimension/dist'),v=require('@stdlib/ndarray-base-stride/dist'),q=require('@stdlib/ndarray-base-offset/dist'),d=require('@stdlib/ndarray-base-data-buffer/dist'),m=require('@stdlib/stats-strided-dminabs/dist').ndarray;function o(e){var r=e[0];return m(s(r,0),d(r),v(r,0),q(r))}a.exports=o
3
+ });var f=require("path").join,c=require('@stdlib/utils-try-require/dist'),g=require('@stdlib/assert-is-error/dist'),j=t(),i,u=c(f(__dirname,"./native.js"));g(u)?i=j:i=u;module.exports=i;
4
4
  /** @license Apache-2.0 */
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar numelDimension = require( '@stdlib/ndarray-base-numel-dimension' );\nvar getStride = require( '@stdlib/ndarray-base-stride' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar strided = require( '@stdlib/stats-strided-dminabs' ).ndarray;\n\n\n// MAIN //\n\n/**\n* Computes the minimum absolute value of a one-dimensional double-precision floating-point ndarray.\n*\n* @param {ArrayLikeObject<Object>} arrays - array-like object containing an input ndarray\n* @returns {number} minimum absolute value\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var xbuf = new Float64Array( [ -1.0, 3.0, -4.0, 2.0 ] );\n* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );\n*\n* var v = dminabs( [ x ] );\n* // returns 1.0\n*/\nfunction dminabs( arrays ) {\n\tvar x = arrays[ 0 ];\n\treturn strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = dminabs;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute the minimum absolute value of a one-dimensional double-precision floating-point ndarray.\n*\n* @module @stdlib/stats-base-ndarray-dminabs\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n* var dminabs = require( '@stdlib/stats-base-ndarray-dminabs' );\n*\n* var xbuf = new Float64Array( [ -1.0, 3.0, -4.0, 2.0 ] );\n* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );\n*\n* var v = dminabs( [ x ] );\n* // returns 1.0\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAY,QAAS,6BAA8B,EACnDC,EAAY,QAAS,6BAA8B,EACnDC,EAAU,QAAS,kCAAmC,EACtDC,EAAU,QAAS,+BAAgC,EAAE,QAqBzD,SAASC,EAASC,EAAS,CAC1B,IAAIC,EAAID,EAAQ,CAAE,EAClB,OAAOF,EAASJ,EAAgBO,EAAG,CAAE,EAAGJ,EAASI,CAAE,EAAGN,EAAWM,EAAG,CAAE,EAAGL,EAAWK,CAAE,CAAE,CACzF,CAKAR,EAAO,QAAUM,IChBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_main", "__commonJSMin", "exports", "module", "numelDimension", "getStride", "getOffset", "getData", "strided", "dminabs", "arrays", "x", "main"]
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar numelDimension = require( '@stdlib/ndarray-base-numel-dimension' );\nvar getStride = require( '@stdlib/ndarray-base-stride' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar strided = require( '@stdlib/stats-strided-dminabs' ).ndarray;\n\n\n// MAIN //\n\n/**\n* Computes the minimum absolute value of a one-dimensional double-precision floating-point ndarray.\n*\n* @param {ArrayLikeObject<Object>} arrays - array-like object containing an input ndarray\n* @returns {number} minimum absolute value\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var xbuf = new Float64Array( [ -1.0, 3.0, -4.0, 2.0 ] );\n* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );\n*\n* var v = dminabs( [ x ] );\n* // returns 1.0\n*/\nfunction dminabs( arrays ) {\n\tvar x = arrays[ 0 ];\n\treturn strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = dminabs;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute the minimum absolute value of a one-dimensional double-precision floating-point ndarray.\n*\n* @module @stdlib/stats-base-ndarray-dminabs\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n* var dminabs = require( '@stdlib/stats-base-ndarray-dminabs' );\n*\n* var xbuf = new Float64Array( [ -1.0, 3.0, -4.0, 2.0 ] );\n* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );\n*\n* var v = dminabs( [ x ] );\n* // returns 1.0\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dminabs;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdminabs = main;\n} else {\n\tdminabs = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dminabs;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAY,QAAS,6BAA8B,EACnDC,EAAY,QAAS,6BAA8B,EACnDC,EAAU,QAAS,kCAAmC,EACtDC,EAAU,QAAS,+BAAgC,EAAE,QAqBzD,SAASC,EAASC,EAAS,CAC1B,IAAIC,EAAID,EAAQ,CAAE,EAClB,OAAOF,EAASJ,EAAgBO,EAAG,CAAE,EAAGJ,EAASI,CAAE,EAAGN,EAAWM,EAAG,CAAE,EAAGL,EAAWK,CAAE,CAAE,CACzF,CAKAR,EAAO,QAAUM,IChBjB,IAAIG,EAAO,QAAS,MAAO,EAAE,KACzBC,EAAa,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAUD,EAEVC,EAAUC,EAMX,OAAO,QAAUD",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "numelDimension", "getStride", "getOffset", "getData", "strided", "dminabs", "arrays", "x", "join", "tryRequire", "isError", "main", "dminabs", "tmp"]
7
7
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2026 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
+ #ifndef STDLIB_STATS_BASE_NDARRAY_DMINABS_H
20
+ #define STDLIB_STATS_BASE_NDARRAY_DMINABS_H
21
+
22
+ #include "stdlib/ndarray/ctor.h"
23
+
24
+ /*
25
+ * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
26
+ */
27
+ #ifdef __cplusplus
28
+ extern "C" {
29
+ #endif
30
+
31
+ /**
32
+ * Computes the minimum value of a one-dimensional double-precision floating-point ndarray.
33
+ */
34
+ double stdlib_stats_dminabs( const struct ndarray *arrays[] );
35
+
36
+ #ifdef __cplusplus
37
+ }
38
+ #endif
39
+
40
+ #endif // !STDLIB_STATS_BASE_NDARRAY_DMINABS_H
package/lib/index.js CHANGED
@@ -37,9 +37,23 @@
37
37
 
38
38
  // MODULES //
39
39
 
40
+ var join = require( 'path' ).join;
41
+ var tryRequire = require( '@stdlib/utils-try-require' );
42
+ var isError = require( '@stdlib/assert-is-error' );
40
43
  var main = require( './main.js' );
41
44
 
42
45
 
46
+ // MAIN //
47
+
48
+ var dminabs;
49
+ var tmp = tryRequire( join( __dirname, './native.js' ) );
50
+ if ( isError( tmp ) ) {
51
+ dminabs = main;
52
+ } else {
53
+ dminabs = tmp;
54
+ }
55
+
56
+
43
57
  // EXPORTS //
44
58
 
45
- module.exports = main;
59
+ module.exports = dminabs;
package/lib/native.js ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2026 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 serialize = require( '@stdlib/ndarray-base-serialize-meta-data' );
24
+ var getData = require( '@stdlib/ndarray-base-data-buffer' );
25
+ var addon = require( './../src/addon.node' );
26
+
27
+
28
+ // MAIN //
29
+
30
+ /**
31
+ * Computes the minimum absolute value of a one-dimensional double-precision floating-point ndarray.
32
+ *
33
+ * @private
34
+ * @param {ArrayLikeObject<Object>} arrays - array-like object containing an input ndarray
35
+ * @returns {number} minimum absolute value
36
+ *
37
+ * @example
38
+ * var Float64Array = require( '@stdlib/array-float64' );
39
+ * var ndarray = require( '@stdlib/ndarray-base-ctor' );
40
+ *
41
+ * var xbuf = new Float64Array( [ -1.0, 3.0, -4.0, 2.0 ] );
42
+ * var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
43
+ *
44
+ * var v = dminabs( [ x ] );
45
+ * // returns 1.0
46
+ */
47
+ function dminabs( arrays ) {
48
+ var x = arrays[ 0 ];
49
+ return addon( getData( x ), serialize( x ) );
50
+ }
51
+
52
+
53
+ // EXPORTS //
54
+
55
+ module.exports = dminabs;
package/manifest.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "options": {
3
+ "task": "build",
4
+ "wasm": false
5
+ },
6
+ "fields": [
7
+ {
8
+ "field": "src",
9
+ "resolve": true,
10
+ "relative": true
11
+ },
12
+ {
13
+ "field": "include",
14
+ "resolve": true,
15
+ "relative": true
16
+ },
17
+ {
18
+ "field": "libraries",
19
+ "resolve": false,
20
+ "relative": false
21
+ },
22
+ {
23
+ "field": "libpath",
24
+ "resolve": true,
25
+ "relative": false
26
+ }
27
+ ],
28
+ "confs": [
29
+ {
30
+ "task": "build",
31
+ "wasm": false,
32
+ "src": [
33
+ "./src/main.c"
34
+ ],
35
+ "include": [
36
+ "./include"
37
+ ],
38
+ "libraries": [],
39
+ "libpath": [],
40
+ "dependencies": [
41
+ "@stdlib/blas-base-shared",
42
+ "@stdlib/stats-strided-dminabs",
43
+ "@stdlib/ndarray-ctor",
44
+ "@stdlib/ndarray-base-napi-addon-arguments",
45
+ "@stdlib/napi-export",
46
+ "@stdlib/napi-argv",
47
+ "@stdlib/napi-create-double"
48
+ ]
49
+ },
50
+ {
51
+ "task": "benchmark",
52
+ "wasm": false,
53
+ "src": [
54
+ "./src/main.c"
55
+ ],
56
+ "include": [
57
+ "./include"
58
+ ],
59
+ "libraries": [],
60
+ "libpath": [],
61
+ "dependencies": [
62
+ "@stdlib/blas-base-shared",
63
+ "@stdlib/stats-strided-dminabs",
64
+ "@stdlib/ndarray-ctor",
65
+ "@stdlib/ndarray-dtypes",
66
+ "@stdlib/ndarray-index-modes",
67
+ "@stdlib/ndarray-orders",
68
+ "@stdlib/ndarray-base-bytes-per-element"
69
+ ]
70
+ },
71
+ {
72
+ "task": "examples",
73
+ "wasm": false,
74
+ "src": [
75
+ "./src/main.c"
76
+ ],
77
+ "include": [
78
+ "./include"
79
+ ],
80
+ "libraries": [],
81
+ "libpath": [],
82
+ "dependencies": [
83
+ "@stdlib/blas-base-shared",
84
+ "@stdlib/stats-strided-dminabs",
85
+ "@stdlib/ndarray-ctor",
86
+ "@stdlib/ndarray-dtypes",
87
+ "@stdlib/ndarray-index-modes",
88
+ "@stdlib/ndarray-orders",
89
+ "@stdlib/ndarray-base-bytes-per-element"
90
+ ]
91
+ },
92
+ {
93
+ "task": "",
94
+ "wasm": true,
95
+ "src": [
96
+ "./src/main.c"
97
+ ],
98
+ "include": [
99
+ "./include"
100
+ ],
101
+ "libraries": [],
102
+ "libpath": [],
103
+ "dependencies": [
104
+ "@stdlib/blas-base-shared",
105
+ "@stdlib/stats-strided-dminabs",
106
+ "@stdlib/ndarray-ctor"
107
+ ]
108
+ }
109
+ ]
110
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-base-ndarray-dminabs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Compute the minimum absolute value of a one-dimensional double-precision floating-point ndarray.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -14,9 +14,13 @@
14
14
  }
15
15
  ],
16
16
  "main": "./lib",
17
+ "browser": "./lib/main.js",
18
+ "gypfile": false,
17
19
  "directories": {
18
20
  "doc": "./docs",
21
+ "include": "./include",
19
22
  "lib": "./lib",
23
+ "src": "./src",
20
24
  "dist": "./dist"
21
25
  },
22
26
  "types": "./docs/types",
@@ -30,11 +34,20 @@
30
34
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
35
  },
32
36
  "dependencies": {
33
- "@stdlib/ndarray-base-data-buffer": "^0.2.2",
37
+ "@stdlib/assert-is-error": "^0.2.3",
38
+ "@stdlib/blas-base-shared": "^0.2.1",
39
+ "@stdlib/napi-argv": "^0.2.3",
40
+ "@stdlib/napi-create-double": "^0.0.3",
41
+ "@stdlib/napi-export": "^0.3.1",
42
+ "@stdlib/ndarray-base-data-buffer": "^0.2.3",
43
+ "@stdlib/ndarray-base-napi-addon-arguments": "^0.2.3",
34
44
  "@stdlib/ndarray-base-numel-dimension": "^0.3.2",
35
- "@stdlib/ndarray-base-offset": "^0.2.2",
45
+ "@stdlib/ndarray-base-offset": "^0.2.3",
36
46
  "@stdlib/ndarray-base-stride": "^0.2.2",
37
- "@stdlib/stats-strided-dminabs": "^0.1.0"
47
+ "@stdlib/ndarray-ctor": "^0.3.0",
48
+ "@stdlib/stats-strided-dminabs": "^0.1.1",
49
+ "@stdlib/utils-library-manifest": "^0.2.4",
50
+ "@stdlib/utils-try-require": "^0.2.3"
38
51
  },
39
52
  "devDependencies": {},
40
53
  "engines": {
package/src/addon.c ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2026 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/stats/base/ndarray/dminabs.h"
20
+ #include "stdlib/ndarray/ctor.h"
21
+ #include "stdlib/ndarray/base/napi/addon_arguments.h"
22
+ #include "stdlib/napi/export.h"
23
+ #include "stdlib/napi/argv.h"
24
+ #include "stdlib/napi/create_double.h"
25
+ #include <node_api.h>
26
+ #include <assert.h>
27
+
28
+ /**
29
+ * Receives JavaScript callback invocation data.
30
+ *
31
+ * @param env environment under which the function is invoked
32
+ * @param info callback data
33
+ * @return Node-API value
34
+ */
35
+ static napi_value addon( napi_env env, napi_callback_info info ) {
36
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 2 );
37
+
38
+ // Process provided arguments:
39
+ struct ndarray *arrays[ 1 ];
40
+ napi_value err;
41
+ napi_status status = stdlib_ndarray_napi_addon_arguments( env, argv, 2, 1, arrays, &err );
42
+ assert( status == napi_ok );
43
+ if ( err != NULL ) {
44
+ status = napi_throw( env, err );
45
+ assert( status == napi_ok );
46
+ return NULL;
47
+ }
48
+ // Perform computation:
49
+ STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_stats_dminabs( arrays ), v );
50
+
51
+ // Free allocated memory:
52
+ stdlib_ndarray_free( arrays[ 0 ] );
53
+ arrays[ 0 ] = NULL;
54
+
55
+ return v;
56
+ }
57
+
58
+ STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
package/src/main.c ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2026 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/stats/base/ndarray/dminabs.h"
20
+ #include "stdlib/stats/strided/dminabs.h"
21
+ #include "stdlib/ndarray/ctor.h"
22
+ #include "stdlib/blas/base/shared.h"
23
+
24
+ /**
25
+ * Computes the minimum absolute value of a one-dimensional double-precision floating-point ndarray.
26
+ *
27
+ * @param arrays list containing an input ndarray
28
+ * @return minimum value
29
+ */
30
+ double stdlib_stats_dminabs( const struct ndarray *arrays[] ) {
31
+ const struct ndarray *x = arrays[ 0 ];
32
+ return API_SUFFIX(stdlib_strided_dminabs_ndarray)( stdlib_ndarray_dimension( x, 0 ), (const double *)stdlib_ndarray_data( x ), stdlib_ndarray_stride_elements( x, 0 ), stdlib_ndarray_offset_elements( x ) );
33
+ }