Skip to content

Commit 1d4d0fa

Browse files
authored
Update nanminabs.js
Signed-off-by: Kaushikgtm <[email protected]>
1 parent 0dac229 commit 1d4d0fa

File tree

1 file changed

+18
-9
lines changed
  • lib/node_modules/@stdlib/stats/base/nanminabs/lib

1 file changed

+18
-9
lines changed

lib/node_modules/@stdlib/stats/base/nanminabs/lib/nanminabs.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
2222

2323
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2424
var abs = require( '@stdlib/math/base/special/abs' );
25+
var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
26+
var accessors = require( './accessors.js' );
2527

2628

2729
// MAIN //
@@ -31,7 +33,8 @@ var abs = require( '@stdlib/math/base/special/abs' );
3133
*
3234
* @param {PositiveInteger} N - number of indexed elements
3335
* @param {NumericArray} x - input array
34-
* @param {integer} stride - stride length
36+
* @param {integer} strideX - stride length
37+
* @param {NonNegativeInteger} offsetX - starting index for `x`
3538
* @returns {number} minimum absolute value
3639
*
3740
* @example
@@ -41,20 +44,26 @@ var abs = require( '@stdlib/math/base/special/abs' );
4144
* var v = nanminabs( N, x, 1 );
4245
* // returns 1.0
4346
*/
44-
function nanminabs( N, x, stride ) {
47+
function nanminabs( N, x, strideX, offsetX ) {
4548
var min;
49+
var o;
4650
var ix;
4751
var v;
4852
var i;
4953

5054
if ( N <= 0 ) {
5155
return NaN;
5256
}
53-
if ( N === 1 || stride === 0 ) {
54-
return abs( x[ 0 ] );
57+
o = arraylike2object( x );
58+
if ( o.accessorProtocol ) {
59+
return accessors( N, o, strideX, offsetX );
5560
}
56-
if ( stride < 0 ) {
57-
ix = (1-N) * stride;
61+
62+
if ( N === 1 || strideX === 0 ) {
63+
return x[ offsetX ];
64+
}
65+
if ( strideX < 0 ) {
66+
ix = (1-N) * strideX;
5867
} else {
5968
ix = 0;
6069
}
@@ -63,15 +72,15 @@ function nanminabs( N, x, stride ) {
6372
if ( v === v ) {
6473
break;
6574
}
66-
ix += stride;
75+
ix += strideX;
6776
}
6877
if ( i === N ) {
6978
return NaN;
7079
}
7180
min = abs( v );
7281
i += 1;
7382
for ( i; i < N; i++ ) {
74-
ix += stride;
83+
ix += strideX;
7584
v = abs( x[ ix ] );
7685
if ( isnan( v ) ) {
7786
continue;

0 commit comments

Comments
 (0)