Skip to content

Commit 1447d13

Browse files
authored
Apply suggestions from code review
Signed-off-by: Athan <[email protected]>
1 parent 985c437 commit 1447d13

File tree

4 files changed

+24
-27
lines changed

4 files changed

+24
-27
lines changed

lib/node_modules/@stdlib/blas/base/igamax/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ The function has the following parameters:
4545

4646
- **N**: number of indexed elements.
4747
- **x**: input array.
48-
- **strideX**: index increment for `x`.
48+
- **strideX**: stride length for `x`.
4949

50-
The `N` and `strideX` parameters determine which elements in `x` are accessed at runtime. For example, to traverse every other value,
50+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to traverse every other value,
5151

5252
```javascript
5353
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
@@ -87,7 +87,7 @@ The function has the following additional parameters:
8787

8888
- **offsetX**: starting index.
8989

90-
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 start from the second index,
90+
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 start from the second index,
9191

9292
```javascript
9393
var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];

lib/node_modules/@stdlib/blas/base/igamax/docs/repl.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{{alias}}( N, x, strideX )
33
Finds the index of the first element having the maximum absolute value.
44

5-
The `N` and `strideX` parameters determine which elements in `x` are
6-
accessed at runtime.
5+
The `N` and stride parameters determine which elements in the strided array
6+
are accessed at runtime.
77

88
Indexing is relative to the first index. To introduce an offset, use typed
99
array views.
@@ -16,10 +16,10 @@
1616
Number of indexed elements.
1717

1818
x: Array<number>|TypedArray
19-
First input array.
19+
Input array.
2020

2121
strideX: integer
22-
Index increment for `x`.
22+
Stride length for `x`.
2323

2424
Returns
2525
-------
@@ -33,7 +33,7 @@
3333
> var idx = {{alias}}( x.length, x, 1 )
3434
3
3535

36-
// Using `N` and `strideX` parameters:
36+
// Using `N` and stride parameters:
3737
> x = [ -2.0, 1.0, 3.0, -5.0 ];
3838
> idx = {{alias}}( 2, x, 2 )
3939
1
@@ -50,19 +50,19 @@
5050
alternative indexing semantics.
5151

5252
While typed array views mandate a view offset based on the underlying
53-
buffer, the `offsetX` parameter supports indexing semantics based on a
54-
starting index.
53+
buffer, the offset parameter supports indexing semantics based on a starting
54+
index.
5555

5656
Parameters
5757
----------
5858
N: integer
5959
Number of indexed elements.
6060

6161
x: Array<number>|TypedArray
62-
First input array.
62+
Input array.
6363

6464
strideX: integer
65-
Index increment for `x`.
65+
Stride length for `x`.
6666

6767
offsetX: integer
6868
Starting index of `x`.
@@ -79,7 +79,7 @@
7979
> var idx = {{alias}}.ndarray( x.length, x, 1, 0 )
8080
3
8181

82-
// Using an index offset:
82+
// Using an offset:
8383
> x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
8484
> idx = {{alias}}.ndarray( 3, x, 2, 1 )
8585
2

lib/node_modules/@stdlib/blas/base/igamax/lib/accessors.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ var abs = require( '@stdlib/math/base/special/abs' );
4747
* // returns 4
4848
*/
4949
function igamax( N, x, strideX, offsetX ) {
50-
var dmax;
5150
var xbuf;
51+
var max;
5252
var idx;
5353
var get;
5454
var ix;
@@ -61,17 +61,14 @@ function igamax( N, x, strideX, offsetX ) {
6161
// Cache references to element accessors:
6262
get = x.accessors[ 0 ];
6363

64+
max = abs( get( xbuf, offsetX ) );
6465
idx = 0;
65-
if ( N === 1 ) {
66-
return idx;
67-
}
68-
dmax = abs( get( xbuf, offsetX ) );
6966
ix = offsetX + strideX;
7067
for ( i = 1; i < N; i++ ) {
7168
v = abs( get( xbuf, ix ) );
72-
if ( v > dmax ) {
69+
if ( v > max ) {
7370
idx = i;
74-
dmax = v;
71+
max = v;
7572
}
7673
ix += strideX;
7774
}

lib/node_modules/@stdlib/blas/base/igamax/lib/ndarray.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var accessors = require( './accessors.js' );
4343
* // returns 4
4444
*/
4545
function igamax( N, x, strideX, offsetX ) {
46-
var smax;
46+
var max;
4747
var idx;
4848
var ix;
4949
var ox;
@@ -53,21 +53,21 @@ function igamax( N, x, strideX, offsetX ) {
5353
if ( N < 1 ) {
5454
return -1;
5555
}
56+
if ( N === 1 ) {
57+
return 0;
58+
}
5659
ox = arraylike2object( x );
5760
if ( ox.accessorProtocol ) {
5861
return accessors( N, ox, strideX, offsetX );
5962
}
63+
max = abs( x[ offsetX ] );
6064
idx = 0;
61-
if ( N === 1 ) {
62-
return idx;
63-
}
64-
smax = abs( x[ offsetX ] );
6565
ix = offsetX + strideX;
6666
for ( i = 1; i < N; i++ ) {
6767
v = abs( x[ ix ] );
68-
if ( v > smax ) {
68+
if ( v > max ) {
6969
idx = i;
70-
smax = v;
70+
max = v;
7171
}
7272
ix += strideX;
7373
}

0 commit comments

Comments
 (0)