Skip to content

Commit 46c82f6

Browse files
committed
Auto-generated commit
1 parent e0f9897 commit 46c82f6

28 files changed

+435
-291
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-12-23)
7+
## Unreleased (2025-01-02)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`6b59072`](https://github.com/stdlib-js/stdlib/commit/6b5907250180eee4ea3c90a855e1aebbefdc2d2b) - add C ndarray interface and refactor implementation for `stats/base/dmaxabssorted` [(#4181)](https://github.com/stdlib-js/stdlib/pull/4181)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="commits">
1020

1121
### Commits
1222

1323
<details>
1424

25+
- [`6b59072`](https://github.com/stdlib-js/stdlib/commit/6b5907250180eee4ea3c90a855e1aebbefdc2d2b) - **feat:** add C ndarray interface and refactor implementation for `stats/base/dmaxabssorted` [(#4181)](https://github.com/stdlib-js/stdlib/pull/4181) _(by Aayush Khanna, stdlib-bot)_
1526
- [`62364f6`](https://github.com/stdlib-js/stdlib/commit/62364f62ea823a3b52c2ad25660ecd80c71f8f36) - **style:** fix C comment alignment _(by Philipp Burckhardt)_
1627
- [`e20fc92`](https://github.com/stdlib-js/stdlib/commit/e20fc92ffce656a95a804b2b72d822aad4e7b227) - **refactor:** update `stats/base/dmaxabssorted` native addon from C++ to C [(#4080)](https://github.com/stdlib-js/stdlib/pull/4080) _(by Aayush Khanna)_
1728
- [`9e689ff`](https://github.com/stdlib-js/stdlib/commit/9e689ffcb7c6223afc521f1e574b42f10921cf5e) - **chore:** fix indentation in manifest.json files _(by Philipp Burckhardt)_

README.md

Lines changed: 132 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ To view installation and usage instructions specific to each branch build, be su
6969
var dmaxabssorted = require( '@stdlib/stats-base-dmaxabssorted' );
7070
```
7171

72-
#### dmaxabssorted( N, x, stride )
72+
#### dmaxabssorted( N, x, strideX )
7373

7474
Computes the maximum absolute value of a sorted double-precision floating-point strided array `x`.
7575

@@ -89,18 +89,16 @@ The function has the following parameters:
8989

9090
- **N**: number of indexed elements.
9191
- **x**: sorted input [`Float64Array`][@stdlib/array/float64].
92-
- **stride**: index increment for `x`.
92+
- **strideX**: stride length for `x`.
9393

94-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the maximum absolute value of every other element in `x`,
94+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the maximum absolute value of every other element in `x`,
9595

9696
```javascript
9797
var Float64Array = require( '@stdlib/array-float64' );
98-
var floor = require( '@stdlib/math-base-special-floor' );
9998

10099
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, 3.0, 3.0, 4.0, 2.0 ] );
101-
var N = floor( x.length / 2 );
102100

103-
var v = dmaxabssorted( N, x, 2 );
101+
var v = dmaxabssorted( 4, x, 2 );
104102
// returns 4.0
105103
```
106104

@@ -110,18 +108,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [
110108

111109
```javascript
112110
var Float64Array = require( '@stdlib/array-float64' );
113-
var floor = require( '@stdlib/math-base-special-floor' );
114111

115112
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, -2.0, 2.0, 3.0, 4.0 ] );
116113
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
117114

118-
var N = floor( x0.length / 2 );
119-
120-
var v = dmaxabssorted( N, x1, 2 );
115+
var v = dmaxabssorted( 4, x1, 2 );
121116
// returns 4.0
122117
```
123118

124-
#### dmaxabssorted.ndarray( N, x, stride, offset )
119+
#### dmaxabssorted.ndarray( N, x, strideX, offsetX )
125120

126121
Computes the maximum absolute value of a sorted double-precision floating-point strided array using alternative indexing semantics.
127122

@@ -135,18 +130,16 @@ var v = dmaxabssorted.ndarray( x.length, x, 1, 0 );
135130

136131
The function has the following additional parameters:
137132

138-
- **offset**: starting index for `x`.
133+
- **offsetX**: starting index for `x`.
139134

140-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the maximum absolute value for every other value in `x` starting from the second value
135+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the maximum absolute value for every other element in `x` starting from the second element
141136

142137
```javascript
143138
var Float64Array = require( '@stdlib/array-float64' );
144-
var floor = require( '@stdlib/math-base-special-floor' );
145139

146140
var x = new Float64Array( [ 2.0, 1.0, 2.0, 2.0, -2.0, 2.0, 3.0, 4.0 ] );
147-
var N = floor( x.length / 2 );
148141

149-
var v = dmaxabssorted.ndarray( N, x, 2, 1 );
142+
var v = dmaxabssorted.ndarray( 4, x, 2, 1 );
150143
// returns 4.0
151144
```
152145

@@ -172,16 +165,13 @@ var v = dmaxabssorted.ndarray( N, x, 2, 1 );
172165
<!-- eslint no-undef: "error" -->
173166

174167
```javascript
175-
var Float64Array = require( '@stdlib/array-float64' );
168+
var linspace = require( '@stdlib/array-linspace' );
176169
var dmaxabssorted = require( '@stdlib/stats-base-dmaxabssorted' );
177170

178-
var x;
179-
var i;
180-
181-
x = new Float64Array( 10 );
182-
for ( i = 0; i < x.length; i++ ) {
183-
x[ i ] = i - 5.0;
184-
}
171+
var options = {
172+
'dtype': 'float64'
173+
};
174+
var x = linspace( -5.0, 5.0, 10, options );
185175
console.log( x );
186176

187177
var v = dmaxabssorted( x.length, x, 1 );
@@ -192,6 +182,123 @@ console.log( v );
192182

193183
<!-- /.examples -->
194184

185+
<!-- C interface documentation. -->
186+
187+
* * *
188+
189+
<section class="c">
190+
191+
## C APIs
192+
193+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
194+
195+
<section class="intro">
196+
197+
</section>
198+
199+
<!-- /.intro -->
200+
201+
<!-- C usage documentation. -->
202+
203+
<section class="usage">
204+
205+
### Usage
206+
207+
```c
208+
#include "stdlib/stats/base/dmaxabssorted.h"
209+
```
210+
211+
#### stdlib_strided_dmaxabssorted( N, \*X, strideX )
212+
213+
Computes the maximum absolute value of a sorted double-precision floating-point strided array.
214+
215+
```c
216+
const double x[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 };
217+
218+
double v = stdlib_strided_dmaxabssorted( 4, x, 2 );
219+
// returns 7.0
220+
```
221+
222+
The function accepts the following arguments:
223+
224+
- **N**: `[in] CBLAS_INT` number of indexed elements.
225+
- **X**: `[in] double*` input array.
226+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
227+
228+
```c
229+
double stdlib_strided_dmaxabssorted( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
230+
```
231+
232+
#### stdlib_strided_dmaxabssorted_ndarray( N, \*X, strideX, offsetX )
233+
234+
Computes the maximum absolute value of a sorted double-precision floating-point strided array using alternative indexing semantics.
235+
236+
```c
237+
const double x[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 };
238+
239+
double v = stdlib_strided_dmaxabssorted_ndarray( 4, x, 2, 0 );
240+
// returns 7.0
241+
```
242+
243+
The function accepts the following arguments:
244+
245+
- **N**: `[in] CBLAS_INT` number of indexed elements.
246+
- **X**: `[in] double*` input array.
247+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
248+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
249+
250+
```c
251+
double stdlib_strided_dmaxabssorted_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
252+
```
253+
254+
</section>
255+
256+
<!-- /.usage -->
257+
258+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
259+
260+
<section class="notes">
261+
262+
</section>
263+
264+
<!-- /.notes -->
265+
266+
<!-- C API usage examples. -->
267+
268+
<section class="examples">
269+
270+
### Examples
271+
272+
```c
273+
#include "stdlib/stats/base/dmaxabssorted.h"
274+
#include <stdio.h>
275+
276+
int main( void ) {
277+
// Create a strided array:
278+
const double x[] = { -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 };
279+
280+
// Specify the number of elements:
281+
const int N = 4;
282+
283+
// Specify the stride length:
284+
const int strideX = 2;
285+
286+
// Compute the maximum absolute value:
287+
double v = stdlib_strided_dmaxabssorted( N, x, strideX );
288+
289+
// Print the result:
290+
printf( "maxabs: %lf\n", v );
291+
}
292+
```
293+
294+
</section>
295+
296+
<!-- /.examples -->
297+
298+
</section>
299+
300+
<!-- /.c -->
301+
195302
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
196303
197304
<section class="related">
@@ -234,7 +341,7 @@ See [LICENSE][stdlib-license].
234341
235342
## Copyright
236343
237-
Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
344+
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].
238345
239346
</section>
240347

benchmark/benchmark.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@
2222

2323
var bench = require( '@stdlib/bench-harness' );
2424
var isnan = require( '@stdlib/math-base-assert-is-nan' );
25+
var linspace = require( '@stdlib/array-linspace' );
2526
var pow = require( '@stdlib/math-base-special-pow' );
26-
var Float64Array = require( '@stdlib/array-float64' );
2727
var pkg = require( './../package.json' ).name;
2828
var dmaxabssorted = require( './../lib/dmaxabssorted.js' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float64'
35+
};
36+
37+
3138
// FUNCTIONS //
3239

3340
/**
@@ -38,13 +45,7 @@ var dmaxabssorted = require( './../lib/dmaxabssorted.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = new Float64Array( len );
45-
for ( i = 0; i < x.length; i++ ) {
46-
x[ i ] = i - (len/2);
47-
}
48+
var x = linspace( -len/2, len/2, len, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

benchmark/benchmark.native.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
26+
var linspace = require( '@stdlib/array-linspace' );
2627
var pow = require( '@stdlib/math-base-special-pow' );
27-
var Float64Array = require( '@stdlib/array-float64' );
2828
var tryRequire = require( '@stdlib/utils-try-require' );
2929
var pkg = require( './../package.json' ).name;
3030

@@ -35,6 +35,9 @@ var dmaxabssorted = tryRequire( resolve( __dirname, './../lib/dmaxabssorted.nati
3535
var opts = {
3636
'skip': ( dmaxabssorted instanceof Error )
3737
};
38+
var options = {
39+
'dtype': 'float64'
40+
};
3841

3942

4043
// FUNCTIONS //
@@ -47,13 +50,7 @@ var opts = {
4750
* @returns {Function} benchmark function
4851
*/
4952
function createBenchmark( len ) {
50-
var x;
51-
var i;
52-
53-
x = new Float64Array( len );
54-
for ( i = 0; i < x.length; i++ ) {
55-
x[ i ] = i - (len/2);
56-
}
53+
var x = linspace( -len/2, len/2, len, options );
5754
return benchmark;
5855

5956
function benchmark( b ) {

benchmark/benchmark.ndarray.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,19 @@
2222

2323
var bench = require( '@stdlib/bench-harness' );
2424
var isnan = require( '@stdlib/math-base-assert-is-nan' );
25+
var linspace = require( '@stdlib/array-linspace' );
2526
var pow = require( '@stdlib/math-base-special-pow' );
26-
var Float64Array = require( '@stdlib/array-float64' );
2727
var pkg = require( './../package.json' ).name;
2828
var dmaxabssorted = require( './../lib/ndarray.js' );
2929

3030

31+
// VARIABLES //
32+
33+
var options = {
34+
'dtype': 'float64'
35+
};
36+
37+
3138
// FUNCTIONS //
3239

3340
/**
@@ -38,13 +45,7 @@ var dmaxabssorted = require( './../lib/ndarray.js' );
3845
* @returns {Function} benchmark function
3946
*/
4047
function createBenchmark( len ) {
41-
var x;
42-
var i;
43-
44-
x = new Float64Array( len );
45-
for ( i = 0; i < x.length; i++ ) {
46-
x[ i ] = i - (len/2);
47-
}
48+
var x = linspace( -len/2, len/2, len, options );
4849
return benchmark;
4950

5051
function benchmark( b ) {

benchmark/benchmark.ndarray.native.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench-harness' );
2525
var isnan = require( '@stdlib/math-base-assert-is-nan' );
26+
var linspace = require( '@stdlib/array-linspace' );
2627
var pow = require( '@stdlib/math-base-special-pow' );
27-
var Float64Array = require( '@stdlib/array-float64' );
2828
var tryRequire = require( '@stdlib/utils-try-require' );
2929
var pkg = require( './../package.json' ).name;
3030

@@ -35,6 +35,9 @@ var dmaxabssorted = tryRequire( resolve( __dirname, './../lib/ndarray.native.js'
3535
var opts = {
3636
'skip': ( dmaxabssorted instanceof Error )
3737
};
38+
var options = {
39+
'dtype': 'float64'
40+
};
3841

3942

4043
// FUNCTIONS //
@@ -47,13 +50,7 @@ var opts = {
4750
* @returns {Function} benchmark function
4851
*/
4952
function createBenchmark( len ) {
50-
var x;
51-
var i;
52-
53-
x = new Float64Array( len );
54-
for ( i = 0; i < x.length; i++ ) {
55-
x[ i ] = i - (len/2);
56-
}
53+
var x = linspace( -len/2, len/2, len, options );
5754
return benchmark;
5855

5956
function benchmark( b ) {

0 commit comments

Comments
 (0)