Skip to content

Commit 0698ccd

Browse files
committed
refactor: 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 77cbbf7 commit 0698ccd

21 files changed

Lines changed: 649 additions & 198 deletions

File tree

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

Lines changed: 15 additions & 9 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, LDO )
39+
#### dcartesianPower( order, N, k, x, strideX, out, LDO )
4040

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

@@ -46,12 +46,13 @@ 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 );
49+
dcartesianPower( 'row-major', 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

5353
The function has the following parameters:
5454

55+
- **order**: storage layout.
5556
- **N**: number of indexed elements.
5657
- **k**: power.
5758
- **x**: input [`Float64Array`][@stdlib/array/float64].
@@ -67,7 +68,7 @@ var Float64Array = require( '@stdlib/array/float64' );
6768
var x = new Float64Array( [ 1.0, 0.0, 2.0, 0.0 ] );
6869
var out = new Float64Array( 8 );
6970

70-
dcartesianPower( 2, 2, x, 2, out, 2 );
71+
dcartesianPower( 'row-major', 2, 2, x, 2, out, 2 );
7172
// out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
7273
```
7374

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

88-
dcartesianPower( 2, 2, x1, 1, out0, 2 );
89+
dcartesianPower( 'row-major', 2, 2, x1, 1, out0, 2 );
8990
// out0 => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
9091
```
9192

@@ -136,6 +137,7 @@ dcartesianPower.ndarray( 2, 2, x, 1, 1, out, 2, 1, 0 );
136137

137138
- If `N <= 0` or `k <= 0`, both functions return `out` unchanged.
138139
- The output array must contain at least `N^k * k` elements.
140+
- The `LDO` parameter must be greater than or equal to `max(1, k)`.
139141

140142
</section>
141143

@@ -156,7 +158,7 @@ console.log( x );
156158

157159
var out = new Float64Array( 24 );
158160

159-
dcartesianPower( x.length, 3, x, 1, out, 3 );
161+
dcartesianPower( 'row-major', x.length, 3, x, 1, out, 3 );
160162
console.log( out );
161163
```
162164

@@ -192,21 +194,24 @@ console.log( out );
192194

193195
<!--lint disable maximum-heading-length-->
194196

195-
#### stdlib_strided_dcartesian_power( N, k, \*X, strideX, \*Out, LDO )
197+
#### stdlib_strided_dcartesian_power( order, N, k, \*X, strideX, \*Out, LDO )
196198

197199
<!--lint enable maximum-heading-length-->
198200

199201
Computes the Cartesian power for a double-precision floating-point strided array.
200202

201203
```c
204+
#include "stdlib/blas/base/shared.h"
205+
202206
const double X[] = { 1.0, 2.0 };
203207
double Out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
204208

205-
stdlib_strided_dcartesian_power( 2, 2, X, 1, Out, 2 );
209+
stdlib_strided_dcartesian_power( CblasRowMajor, 2, 2, X, 1, Out, 2 );
206210
```
207211
208212
The function accepts the following arguments:
209213
214+
- **order**: `[in] CBLAS_LAYOUT` storage layout.
210215
- **N**: `[in] CBLAS_INT` number of indexed elements.
211216
- **k**: `[in] CBLAS_INT` power.
212217
- **X**: `[in] double*` input array.
@@ -215,7 +220,7 @@ The function accepts the following arguments:
215220
- **LDO**: `[in] CBLAS_INT` stride length for the leading dimension of `Out`.
216221
217222
```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 LDO );
223+
void stdlib_strided_dcartesian_power( const CBLAS_LAYOUT order, const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO );
219224
```
220225

221226
<!--lint disable maximum-heading-length-->
@@ -269,6 +274,7 @@ void stdlib_strided_dcartesian_power_ndarray( const CBLAS_INT N, const CBLAS_INT
269274

270275
```c
271276
#include "stdlib/blas/ext/base/dcartesianpower.h"
277+
#include "stdlib/blas/base/shared.h"
272278
#include <stdio.h>
273279

274280
int main( void ) {
@@ -287,7 +293,7 @@ int main( void ) {
287293
const int LDO = 2;
288294

289295
// Compute the Cartesian power:
290-
stdlib_strided_dcartesian_power( N, k, X, strideX, out, LDO );
296+
stdlib_strided_dcartesian_power( CblasRowMajor, N, k, X, strideX, out, LDO );
291297

292298
// Print the result:
293299
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 );
70+
z = dcartesianPower( 'row-major', 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 );
75+
z = dcartesianPower( 'row-major', 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "stdlib/blas/ext/base/dcartesianpower.h"
20+
#include "stdlib/blas/base/shared.h"
2021
#include <stdlib.h>
2122
#include <stdio.h>
2223
#include <math.h>
@@ -114,7 +115,7 @@ static double benchmark1( int iterations, int len ) {
114115
}
115116
t = tic();
116117
for ( i = 0; i < iterations; i++ ) {
117-
stdlib_strided_dcartesian_power( len, K, x, 1, out, K );
118+
stdlib_strided_dcartesian_power( CblasRowMajor, len, K, x, 1, out, K );
118119
if ( out[ 0 ] != out[ 0 ] ) {
119120
printf( "should not return NaN\n" );
120121
break;

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

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

@@ -9,6 +9,9 @@
99

1010
Parameters
1111
----------
12+
order: string
13+
Storage layout.
14+
1215
N: integer
1316
Number of indexed elements.
1417

@@ -37,13 +40,13 @@
3740
// Standard Usage:
3841
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] );
3942
> var out = new {{alias:@stdlib/array/float64}}( 8 );
40-
> {{alias}}( x.length, 2, x, 1, out, 2 )
43+
> {{alias}}( 'row-major', x.length, 2, x, 1, out, 2 )
4144
<Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
4245

4346
// Using `N` and stride parameters:
4447
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 0.0 ] );
4548
> out = new {{alias:@stdlib/array/float64}}( 8 );
46-
> {{alias}}( 2, 2, x, 2, out, 2 )
49+
> {{alias}}( 'row-major', 2, 2, x, 2, out, 2 )
4750
<Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
4851

4952

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818

1919
// TypeScript Version: 4.1
2020

21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Layout } from '@stdlib/types/blas';
24+
2125
/**
2226
* Interface describing `dcartesianPower`.
2327
*/
2428
interface Routine {
2529
/**
2630
* Computes the Cartesian power for a double-precision floating-point strided array.
2731
*
32+
* @param order - storage layout
2833
* @param N - number of indexed elements
2934
* @param k - power
3035
* @param x - input array
@@ -39,10 +44,10 @@ interface Routine {
3944
* var x = new Float64Array( [ 1.0, 2.0 ] );
4045
* var out = new Float64Array( 8 );
4146
*
42-
* dcartesianPower( x.length, 2, x, 1, out, 2 );
47+
* dcartesianPower( 'row-major', x.length, 2, x, 1, out, 2 );
4348
* // out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
4449
*/
45-
( N: number, k: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array;
50+
( order: Layout, N: number, k: number, x: Float64Array, strideX: number, out: Float64Array, LDO: number ): Float64Array;
4651

4752
/**
4853
* Computes the Cartesian power for a double-precision floating-point strided array using alternative indexing semantics.
@@ -73,6 +78,7 @@ interface Routine {
7378
/**
7479
* Computes the Cartesian power for a double-precision floating-point strided array.
7580
*
81+
* @param order - storage layout
7682
* @param N - number of indexed elements
7783
* @param k - power
7884
* @param x - input array
@@ -87,7 +93,7 @@ interface Routine {
8793
* var x = new Float64Array( [ 1.0, 2.0 ] );
8894
* var out = new Float64Array( 8 );
8995
*
90-
* dcartesianPower( x.length, 2, x, 1, out, 2 );
96+
* dcartesianPower( 'row-major', x.length, 2, x, 1, out, 2 );
9197
* // out => <Float64Array>[ 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 2.0, 2.0 ]
9298
*
9399
* @example

0 commit comments

Comments
 (0)