Skip to content

Commit a16dc7c

Browse files
committed
fix: apply suggestions from code review
1 parent b70066c commit a16dc7c

6 files changed

Lines changed: 30 additions & 26 deletions

File tree

lib/node_modules/@stdlib/blas/ext/base/gcartesian-square/docs/repl.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
N: integer
2323
Number of indexed elements.
2424

25-
x: Array<number>|TypedArray
25+
x: ArrayLikeObject
2626
Input array.
2727

2828
strideX: integer
2929
Stride length for `x`.
3030

31-
out: Array<number>|TypedArray
31+
out: ArrayLikeObject
3232
Output array.
3333

3434
LDO: integer
@@ -37,7 +37,7 @@
3737

3838
Returns
3939
-------
40-
out: Array<number>|TypedArray
40+
out: ArrayLikeObject
4141
Output array.
4242

4343
Examples
@@ -82,7 +82,7 @@
8282
N: integer
8383
Number of indexed elements.
8484

85-
x: Array<number>|TypedArray
85+
x: ArrayLikeObject
8686
Input array.
8787

8888
sx: integer
@@ -91,7 +91,7 @@
9191
ox: integer
9292
Starting index for `x`.
9393

94-
out: Array<number>|TypedArray
94+
out: ArrayLikeObject
9595
Output array.
9696

9797
so1: integer
@@ -105,7 +105,7 @@
105105

106106
Returns
107107
-------
108-
out: Array<number>|TypedArray
108+
out: ArrayLikeObject
109109
Output array.
110110

111111
Examples

lib/node_modules/@stdlib/blas/ext/base/gcartesian-square/docs/types/index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
/// <reference types="@stdlib/types"/>
2222

2323
import { Layout } from '@stdlib/types/blas';
24-
import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
24+
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
2525

2626
/**
2727
* Input array.
2828
*/
29-
type InputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
29+
type InputArray<T> = Collection<T> | AccessorArrayLike<T>;
3030

3131
/**
3232
* Output array.
3333
*/
34-
type OutputArray = NumericArray | Collection<number> | AccessorArrayLike<number>;
34+
type OutputArray<T> = Collection<T> | AccessorArrayLike<T>;
3535

3636
/**
3737
* Interface describing `gcartesianSquare`.
@@ -55,7 +55,7 @@ interface Routine {
5555
* gcartesianSquare( 'row-major', x.length, x, 1, out, 2 );
5656
* // out => [ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
5757
*/
58-
<T extends OutputArray>( order: Layout, N: number, x: InputArray, strideX: number, out: T, LDO: number ): T;
58+
<T = unknown, U extends OutputArray<T> = OutputArray<T>>( order: Layout, N: number, x: InputArray<T>, strideX: number, out: U, LDO: number ): U;
5959

6060
/**
6161
* Computes the Cartesian square for a strided array using alternative indexing semantics.
@@ -77,7 +77,7 @@ interface Routine {
7777
* gcartesianSquare.ndarray( x.length, x, 1, 0, out, 2, 1, 0 );
7878
* // out => [ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
7979
*/
80-
ndarray<T extends OutputArray>( N: number, x: InputArray, strideX: number, offsetX: number, out: T, strideOut1: number, strideOut2: number, offsetOut: number ): T;
80+
ndarray<T = unknown, U extends OutputArray<T> = OutputArray<T>>( N: number, x: InputArray<T>, strideX: number, offsetX: number, out: U, strideOut1: number, strideOut2: number, offsetOut: number ): U;
8181
}
8282

8383
/**

lib/node_modules/@stdlib/blas/ext/base/gcartesian-square/docs/types/test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import gcartesianSquare = require( './index' );
2424

2525
// TESTS //
2626

27-
// The function returns a numeric array...
27+
// The function returns a collection...
2828
{
2929
const x = new Float64Array( 10 );
3030
const out = new Float64Array( 200 );
@@ -63,7 +63,7 @@ import gcartesianSquare = require( './index' );
6363
gcartesianSquare( 'row-major', ( x: number ): number => x, x, 1, out, 2 ); // $ExpectError
6464
}
6565

66-
// The compiler throws an error if the function is provided a third argument which is not a numeric array...
66+
// The compiler throws an error if the function is provided a third argument which is not a collection...
6767
{
6868
const out = new Float64Array( 200 );
6969

@@ -92,7 +92,7 @@ import gcartesianSquare = require( './index' );
9292
gcartesianSquare( 'row-major', 10, x, ( x: number ): number => x, out, 2 ); // $ExpectError
9393
}
9494

95-
// The compiler throws an error if the function is provided a fifth argument which is not a numeric array...
95+
// The compiler throws an error if the function is provided a fifth argument which is not a collection...
9696
{
9797
const x = new Float64Array( 10 );
9898

@@ -135,7 +135,7 @@ import gcartesianSquare = require( './index' );
135135
gcartesianSquare( 'row-major', 10, x, 1, out, 2, 10 ); // $ExpectError
136136
}
137137

138-
// Attached to main export is an `ndarray` method which returns a numeric array...
138+
// Attached to main export is an `ndarray` method which returns a collection...
139139
{
140140
const x = new Float64Array( 10 );
141141
const out = new Float64Array( 200 );
@@ -159,7 +159,7 @@ import gcartesianSquare = require( './index' );
159159
gcartesianSquare.ndarray( ( x: number ): number => x, x, 1, 0, out, 2, 1, 0 ); // $ExpectError
160160
}
161161

162-
// The compiler throws an error if the `ndarray` method is provided a second argument which is not a numeric array...
162+
// The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection...
163163
{
164164
const out = new Float64Array( 200 );
165165

@@ -203,7 +203,7 @@ import gcartesianSquare = require( './index' );
203203
gcartesianSquare.ndarray( 10, x, 1, ( x: number ): number => x, out, 2, 1, 0 ); // $ExpectError
204204
}
205205

206-
// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a numeric array...
206+
// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a collection...
207207
{
208208
const x = new Float64Array( 10 );
209209

lib/node_modules/@stdlib/blas/ext/base/gcartesian-square/lib/accessors.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' );
2626
// MAIN //
2727

2828
/**
29-
* Computes the Cartesian square for a strided array using accessor arrays.
29+
* Computes the Cartesian square for a strided accessor array.
3030
*
3131
* @private
3232
* @param {NonNegativeInteger} N - number of indexed elements
3333
* @param {Object} x - input array object
34+
* @param {Collection} x.data - input array data
35+
* @param {Array<Function>} x.accessors - array element accessors
3436
* @param {integer} strideX - stride length for `x`
3537
* @param {NonNegativeInteger} offsetX - starting index for `x`
3638
* @param {Object} out - output array object
39+
* @param {Collection} out.data - output array data
40+
* @param {Array<Function>} out.accessors - array element accessors
3741
* @param {integer} strideOut1 - stride length for the first dimension of `out`
3842
* @param {integer} strideOut2 - stride length for the second dimension of `out`
3943
* @param {NonNegativeInteger} offsetOut - starting index for `out`
@@ -85,7 +89,7 @@ function gcartesianSquare( N, x, strideX, offsetX, out, strideOut1, strideOut2,
8589
return obuf;
8690
}
8791
// Column-major...
88-
for ( i = 0; i < N; i++ ) {
92+
for ( i = 0; i < N; i++ ) { // Note: these loops inline the equivalent of `gfill` to avoid the overhead of intermediate object creation and accessor dispatch on each call...
8993
v = xget( xbuf, ix );
9094
for ( j = 0; j < N; j++ ) {
9195
oset( obuf, io, v );
@@ -94,7 +98,7 @@ function gcartesianSquare( N, x, strideX, offsetX, out, strideOut1, strideOut2,
9498
ix += strideX;
9599
}
96100
io = offsetOut + strideOut2;
97-
for ( i = 0; i < N; i++ ) {
101+
for ( i = 0; i < N; i++ ) { // Note: these loops inline the equivalent of `gcopy` to avoid the overhead of intermediate object creation and accessor dispatch on each call...
98102
jx = offsetX;
99103
for ( j = 0; j < N; j++ ) {
100104
oset( obuf, io, xget( xbuf, jx ) );

lib/node_modules/@stdlib/blas/ext/base/gcartesian-square/lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ var ndarray = require( './ndarray.js' );
3535
*
3636
* @param {string} order - storage layout
3737
* @param {NonNegativeInteger} N - number of indexed elements
38-
* @param {NumericArray} x - input array
38+
* @param {Collection} x - input array
3939
* @param {integer} strideX - stride length for `x`
40-
* @param {NumericArray} out - output array
40+
* @param {Collection} out - output array
4141
* @param {integer} LDO - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`)
4242
* @throws {TypeError} first argument must be a valid order
4343
* @throws {RangeError} sixth argument must be a valid stride length
44-
* @returns {NumericArray} output array
44+
* @returns {Collection} output array
4545
*
4646
* @example
4747
* var x = [ 1.0, 2.0 ];

lib/node_modules/@stdlib/blas/ext/base/gcartesian-square/lib/ndarray.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ var accessors = require( './accessors.js' );
3737
* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element.
3838
*
3939
* @param {NonNegativeInteger} N - number of indexed elements
40-
* @param {NumericArray} x - input array
40+
* @param {Collection} x - input array
4141
* @param {integer} strideX - stride length for `x`
4242
* @param {NonNegativeInteger} offsetX - starting index for `x`
43-
* @param {NumericArray} out - output array
43+
* @param {Collection} out - output array
4444
* @param {integer} strideOut1 - stride length for the first dimension of `out`
4545
* @param {integer} strideOut2 - stride length for the second dimension of `out`
4646
* @param {NonNegativeInteger} offsetOut - starting index for `out`
47-
* @returns {NumericArray} output array
47+
* @returns {Collection} output array
4848
*
4949
* @example
5050
* var x = [ 1.0, 2.0 ];

0 commit comments

Comments
 (0)