Skip to content

Commit 77cbbf7

Browse files
committed
fix: apply suggestions from code review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent d49a25e commit 77cbbf7

21 files changed

Lines changed: 276 additions & 284 deletions

File tree

lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ limitations under the License.
3636
var dcartesianPower = require( '@stdlib/blas/ext/base/dcartesian-power' );
3737
```
3838

39-
#### dcartesianPower( N, k, x, strideX, out, strideOut1, strideOut2 )
39+
#### dcartesianPower( N, k, x, strideX, out, LDO )
4040

4141
Computes the Cartesian power for a double-precision floating-point strided array.
4242

@@ -46,7 +46,7 @@ var Float64Array = require( '@stdlib/array/float64' );
4646
var x = new Float64Array( [ 1.0, 2.0 ] );
4747
var out = new Float64Array( 8 );
4848

49-
dcartesianPower( x.length, 2, x, 1, out, 2, 1 );
49+
dcartesianPower( x.length, 2, x, 1, out, 2 );
5050
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
5151
```
5252

@@ -55,10 +55,9 @@ The function has the following parameters:
5555
- **N**: number of indexed elements.
5656
- **k**: power.
5757
- **x**: input [`Float64Array`][@stdlib/array/float64].
58-
- **strideX**: stride length.
58+
- **strideX**: stride length for `x`.
5959
- **out**: output [`Float64Array`][@stdlib/array/float64].
60-
- **strideOut1**: stride length between consecutive output pairs.
61-
- **strideOut2**: stride length between elements within each output pair.
60+
- **LDO**: stride length for the leading dimension of `out`.
6261

6362
The `N`, `k`, and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the Cartesian power of every other element:
6463

@@ -68,7 +67,7 @@ var Float64Array = require( '@stdlib/array/float64' );
6867
var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] );
6968
var out = new Float64Array( 8 );
7069

71-
dcartesianPower( 2, 2, x, 2, out, 2, 1 );
70+
dcartesianPower( 2, 2, x, 2, out, 2 );
7271
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
7372
```
7473

@@ -86,7 +85,7 @@ var out0 = new Float64Array( 8 );
8685
// Create offset views...
8786
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
8887

89-
dcartesianPower( 2, 2, x1, 1, out0, 2, 1 );
88+
dcartesianPower( 2, 2, x1, 1, out0, 2 );
9089
// out0 => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
9190
```
9291

@@ -110,8 +109,10 @@ dcartesianPower.ndarray( x.length, 2, x, 1, 0, out, 2, 1, 0 );
110109

111110
The function has the following additional parameters:
112111

113-
- **offsetX**: starting index.
114-
- **offsetOut**: starting index.
112+
- **offsetX**: starting index for `x`.
113+
- **strideOut1**: stride length for the first dimension of `out`.
114+
- **strideOut2**: stride length for the second dimension of `out`.
115+
- **offsetOut**: starting index for `out`.
115116

116117
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to compute the Cartesian power of every other value in the strided input array starting from the second value:
117118

@@ -134,7 +135,7 @@ dcartesianPower.ndarray( 2, 2, x, 1, 1, out, 2, 1, 0 );
134135
## Notes
135136

136137
- If `N <= 0` or `k <= 0`, both functions return `out` unchanged.
137-
- The output array must contain at least `N^k` elements.
138+
- The output array must contain at least `N^k * k` elements.
138139

139140
</section>
140141

@@ -155,7 +156,7 @@ console.log( x );
155156

156157
var out = new Float64Array( 24 );
157158

158-
dcartesianPower( x.length, 3, x, 1, out, 3, 1 );
159+
dcartesianPower( x.length, 3, x, 1, out, 3 );
159160
console.log( out );
160161
```
161162

@@ -191,7 +192,7 @@ console.log( out );
191192

192193
<!--lint disable maximum-heading-length-->
193194

194-
#### stdlib_strided_dcartesian_power( N, k, \*X, strideX, \*Out, strideOut1, strideOut2 )
195+
#### stdlib_strided_dcartesian_power( N, k, \*X, strideX, \*Out, LDO )
195196

196197
<!--lint enable maximum-heading-length-->
197198

@@ -201,21 +202,20 @@ Computes the Cartesian power for a double-precision floating-point strided array
201202
const double X[] = { 1.0, 2.0 };
202203
double Out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
203204

204-
stdlib_strided_dcartesian_power( 2, 2, X, 1, Out, 2, 1 );
205+
stdlib_strided_dcartesian_power( 2, 2, X, 1, Out, 2 );
205206
```
206207
207208
The function accepts the following arguments:
208209
209210
- **N**: `[in] CBLAS_INT` number of indexed elements.
210211
- **k**: `[in] CBLAS_INT` power.
211212
- **X**: `[in] double*` input array.
212-
- **strideX**: `[in] CBLAS_INT` stride length.
213+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
213214
- **Out**: `[out] double*` output array.
214-
- **strideOut1**: `[in] CBLAS_INT` stride length between consecutive output pairs.
215-
- **strideOut2**: `[in] CBLAS_INT` stride length between elements within each output pair.
215+
- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`.
216216
217217
```c
218-
void stdlib_strided_dcartesian_power( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2 );
218+
void stdlib_strided_dcartesian_power( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO );
219219
```
220220

221221
<!--lint disable maximum-heading-length-->
@@ -238,12 +238,12 @@ The function accepts the following arguments:
238238
- **N**: `[in] CBLAS_INT` number of indexed elements.
239239
- **k**: `[in] CBLAS_INT` power.
240240
- **X**: `[in] double*` input array.
241-
- **strideX**: `[in] CBLAS_INT` stride length.
242-
- **offsetX**: `[in] CBLAS_INT` starting index.
241+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
242+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
243243
- **Out**: `[out] double*` output array.
244-
- **strideOut1**: `[in] CBLAS_INT` stride length between consecutive output pairs.
245-
- **strideOut2**: `[in] CBLAS_INT` stride length between elements within each output pair.
246-
- **offsetOut**: `[in] CBLAS_INT` starting index.
244+
- **strideOut1**: `[in] CBLAS_INT` stride length for the first dimension of `Out`.
245+
- **strideOut2**: `[in] CBLAS_INT` stride length for the second dimension of `Out`.
246+
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.
247247
248248
```c
249249
void stdlib_strided_dcartesian_power_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut );
@@ -284,11 +284,10 @@ int main( void ) {
284284

285285
// Specify strides:
286286
const int strideX = 1;
287-
const int strideOut1 = 2;
288-
const int strideOut2 = 1;
287+
const int LDO = 2;
289288

290289
// Compute the Cartesian power:
291-
stdlib_strided_dcartesian_power( N, k, X, strideX, out, strideOut1, strideOut2 );
290+
stdlib_strided_dcartesian_power( N, k, X, strideX, out, LDO );
292291

293292
// Print the result:
294293
for ( int i = 0; i < N*N; i++ ) {

lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function createBenchmark( len ) {
6767

6868
b.tic();
6969
for ( i = 0; i < b.iterations; i++ ) {
70-
z = dcartesianPower( x.length, K, x, 1, out, K, 1 );
70+
z = dcartesianPower( x.length, K, x, 1, out, K );
7171
if ( isnan( z[ 0 ] ) ) {
7272
b.fail( 'should not return NaN' );
7373
}

lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/benchmark/benchmark.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function createBenchmark( len ) {
7272

7373
b.tic();
7474
for ( i = 0; i < b.iterations; i++ ) {
75-
z = dcartesianPower( x.length, K, x, 1, out, K, 1 );
75+
z = dcartesianPower( x.length, K, x, 1, out, K );
7676
if ( isnan( z[ 0 ] ) ) {
7777
b.fail( 'should not return NaN' );
7878
}

lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/benchmark/c/benchmark.length.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ static double rand_double( void ) {
9898
static double benchmark1( int iterations, int len ) {
9999
double elapsed;
100100
double *out;
101+
int outlen;
101102
double *x;
102103
double t;
103-
int outlen;
104104
int i;
105105

106106
x = (double *) malloc( len * sizeof( double ) );
@@ -114,7 +114,7 @@ static double benchmark1( int iterations, int len ) {
114114
}
115115
t = tic();
116116
for ( i = 0; i < iterations; i++ ) {
117-
stdlib_strided_dcartesian_power( len, K, x, 1, out, K, 1 );
117+
stdlib_strided_dcartesian_power( len, K, x, 1, out, K );
118118
if ( out[ 0 ] != out[ 0 ] ) {
119119
printf( "should not return NaN\n" );
120120
break;
@@ -139,9 +139,9 @@ static double benchmark1( int iterations, int len ) {
139139
static double benchmark2( int iterations, int len ) {
140140
double elapsed;
141141
double *out;
142+
int outlen;
142143
double *x;
143144
double t;
144-
int outlen;
145145
int i;
146146

147147
x = (double *) malloc( len * sizeof( double ) );

lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/docs/repl.txt

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{alias}}( N, k, x, strideX, out, strideOut1, strideOut2 )
1+
{{alias}}( N, k, x, strideX, out, LDO )
22
Computes the Cartesian power for a double-precision floating-point strided
33
array.
44

@@ -19,16 +19,13 @@
1919
Input array.
2020

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

2424
out: Float64Array
2525
Output array.
2626

27-
strideOut1: integer
28-
Stride length between consecutive output pairs.
29-
30-
strideOut2: integer
31-
Stride length between elements within each output pair.
27+
LDO: integer
28+
Stride length for the leading dimension of `out`.
3229

3330
Returns
3431
-------
@@ -40,17 +37,17 @@
4037
// Standard Usage:
4138
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] );
4239
> var out = new {{alias:@stdlib/array/float64}}( 8 );
43-
> {{alias}}( x.length, 2, x, 1, out, 2, 1 )
40+
> {{alias}}( x.length, 2, x, 1, out, 2 )
4441
<Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
4542

4643
// Using `N` and stride parameters:
4744
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0 ] );
4845
> out = new {{alias:@stdlib/array/float64}}( 8 );
49-
> {{alias}}( 2, 2, x, 2, out, 2, 1 )
46+
> {{alias}}( 2, 2, x, 2, out, 2 )
5047
<Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
5148

5249

53-
{{alias}}.ndarray( N, k, x, strideX, offsetX, out, sO1, sO2, offsetOut )
50+
{{alias}}.ndarray( N, k, x, strideX, offsetX, out, so1, so2, oo )
5451
Computes the Cartesian power for a double-precision floating-point strided
5552
array using alternative indexing semantics.
5653

@@ -70,22 +67,22 @@
7067
Input array.
7168

7269
strideX: integer
73-
Stride length.
70+
Stride length for `x`.
7471

7572
offsetX: integer
76-
Starting index.
73+
Starting index for `x`.
7774

7875
out: Float64Array
7976
Output array.
8077

81-
sO1: integer
82-
Stride length between consecutive output pairs.
78+
so1: integer
79+
Stride length for the first dimension of `out`.
8380

84-
sO2: integer
85-
Stride length between elements within each output pair.
81+
so2: integer
82+
Stride length for the second dimension of `out`.
8683

87-
offsetOut: integer
88-
Starting index.
84+
oo: integer
85+
Starting index for `out`.
8986

9087
Returns
9188
-------

lib/node_modules/@stdlib/blas/ext/base/dcartesian-power/docs/types/index.d.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ interface Routine {
2828
* @param N - number of indexed elements
2929
* @param k - power
3030
* @param x - input array
31-
* @param strideX - stride length
31+
* @param strideX - stride length for `x`
3232
* @param out - output array
33-
* @param strideOut1 - stride length between consecutive output pairs
34-
* @param strideOut2 - stride length between elements within each output pair
33+
* @param LDO - stride length for the leading dimension of `out`
3534
* @returns output array
3635
*
3736
* @example
@@ -40,23 +39,23 @@ interface Routine {
4039
* var x = new Float64Array( [ 1.0, 2.0 ] );
4140
* var out = new Float64Array( 8 );
4241
*
43-
* dcartesianPower( x.length, 2, x, 1, out, 2, 1 );
42+
* dcartesianPower( x.length, 2, x, 1, out, 2 );
4443
* // out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
4544
*/
46-
( N: number, k: number, x: Float64Array, strideX: number, out: Float64Array, strideOut1: number, strideOut2: number ): Float64Array;
45+
( N: number, k: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array;
4746

4847
/**
4948
* Computes the Cartesian power for a double-precision floating-point strided array using alternative indexing semantics.
5049
*
5150
* @param N - number of indexed elements
5251
* @param k - power
5352
* @param x - input array
54-
* @param strideX - stride length
55-
* @param offsetX - starting index
53+
* @param strideX - stride length for `x`
54+
* @param offsetX - starting index for `x`
5655
* @param out - output array
57-
* @param strideOut1 - stride length between consecutive output pairs
58-
* @param strideOut2 - stride length between elements within each output pair
59-
* @param offsetOut - starting index
56+
* @param strideOut1 - stride length for the first dimension of `out`
57+
* @param strideOut2 - stride length for the second dimension of `out`
58+
* @param offsetOut - starting index for `out`
6059
* @returns output array
6160
*
6261
* @example
@@ -77,10 +76,9 @@ interface Routine {
7776
* @param N - number of indexed elements
7877
* @param k - power
7978
* @param x - input array
80-
* @param strideX - stride length
79+
* @param strideX - stride length for `x`
8180
* @param out - output array
82-
* @param strideOut1 - stride length between consecutive output pairs
83-
* @param strideOut2 - stride length between elements within each output pair
81+
* @param LDO - stride length for the leading dimension of `out`
8482
* @returns output array
8583
*
8684
* @example
@@ -89,7 +87,7 @@ interface Routine {
8987
* var x = new Float64Array( [ 1.0, 2.0 ] );
9088
* var out = new Float64Array( 8 );
9189
*
92-
* dcartesianPower( x.length, 2, x, 1, out, 2, 1 );
90+
* dcartesianPower( x.length, 2, x, 1, out, 2 );
9391
* // out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
9492
*
9593
* @example

0 commit comments

Comments
 (0)