Skip to content

Commit d47e5a7

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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8c37f1e commit d47e5a7

6 files changed

Lines changed: 212 additions & 4 deletions

File tree

lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append
194194
*/
195195
function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) {
196196
var total;
197+
var io;
197198
var n;
198199
var i;
199200

@@ -212,10 +213,14 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap
212213
dcopy.ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut );
213214

214215
// Copy `x` into output array:
215-
dcopy.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut );
216+
io = offsetOut + ( N1 * strideOut );
217+
dcopy.ndarray( N, x, strideX, offsetX, out, strideOut, io );
216218

217219
// Copy `append` into output array:
218-
dcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, offsetOut );
220+
io = offsetOut + ( ( N1 + N ) * strideOut );
221+
dcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, io );
222+
223+
return out;
219224
}
220225

221226
if ( k === 1 ) {

lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *
197197
*/
198198
void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) {
199199
CBLAS_INT total;
200+
CBLAS_INT io;
200201
CBLAS_INT n;
201202
CBLAS_INT i;
202203

@@ -210,10 +211,12 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN
210211
c_dcopy_ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut );
211212

212213
// Copy `x` into output array:
213-
c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, offsetOut );
214+
io = offsetOut + ( N1 * strideOut );
215+
c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, io );
214216

215217
// Copy `append` into output array:
216-
c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, offsetOut );
218+
io = offsetOut + ( ( N1 + N ) * strideOut );
219+
c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, io );
217220
}
218221

219222
if ( k == 1 ) {

lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@ tape( 'the function has an arity of 14', function test( t ) {
3838
t.end();
3939
});
4040

41+
tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) {
42+
var expected;
43+
var out;
44+
var x;
45+
var p;
46+
var a;
47+
var o;
48+
var w;
49+
50+
x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] );
51+
p = new Float64Array( [ 10.0, 15.0 ] );
52+
a = new Float64Array( [ 30.0, 35.0 ] );
53+
o = new Float64Array( 8 );
54+
w = new Float64Array( 8 );
55+
56+
out = ddiff( x.length, 9, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 );
57+
expected = new Float64Array([
58+
0.0,
59+
0.0,
60+
0.0,
61+
0.0,
62+
0.0,
63+
0.0,
64+
0.0,
65+
0.0
66+
]);
67+
t.deepEqual( o, expected, 'returns expected value' );
68+
t.strictEqual( out, o, 'return expected value' );
69+
70+
t.end();
71+
});
72+
4173
tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) {
4274
var expected;
4375
var out;
@@ -112,6 +144,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double
112144
t.deepEqual( o, expected, 'returns expected value' );
113145
t.strictEqual( out, o, 'return expected value' );
114146

147+
o = new Float64Array( 9 );
148+
w = new Float64Array( 9 );
149+
150+
out = ddiff( x.length, 0, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 );
151+
expected = new Float64Array([
152+
10.0,
153+
15.0,
154+
4.0,
155+
8.0,
156+
12.0,
157+
16.0,
158+
20.0,
159+
30.0,
160+
35.0
161+
]);
162+
t.deepEqual( o, expected, 'returns expected value' );
163+
t.strictEqual( out, o, 'return expected value' );
164+
115165
t.end();
116166
});
117167

lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,38 @@ tape( 'the function has an arity of 14', opts, function test( t ) {
4747
t.end();
4848
});
4949

50+
tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) {
51+
var expected;
52+
var out;
53+
var x;
54+
var p;
55+
var a;
56+
var o;
57+
var w;
58+
59+
x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] );
60+
p = new Float64Array( [ 10.0, 15.0 ] );
61+
a = new Float64Array( [ 30.0, 35.0 ] );
62+
o = new Float64Array( 8 );
63+
w = new Float64Array( 8 );
64+
65+
out = ddiff( x.length, 9, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 );
66+
expected = new Float64Array([
67+
0.0,
68+
0.0,
69+
0.0,
70+
0.0,
71+
0.0,
72+
0.0,
73+
0.0,
74+
0.0
75+
]);
76+
t.deepEqual( o, expected, 'returns expected value' );
77+
t.strictEqual( out, o, 'return expected value' );
78+
79+
t.end();
80+
});
81+
5082
tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) {
5183
var expected;
5284
var out;
@@ -121,6 +153,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double
121153
t.deepEqual( o, expected, 'returns expected value' );
122154
t.strictEqual( out, o, 'return expected value' );
123155

156+
o = new Float64Array( 9 );
157+
w = new Float64Array( 9 );
158+
159+
out = ddiff( x.length, 0, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 );
160+
expected = new Float64Array([
161+
10.0,
162+
15.0,
163+
4.0,
164+
8.0,
165+
12.0,
166+
16.0,
167+
20.0,
168+
30.0,
169+
35.0
170+
]);
171+
t.deepEqual( o, expected, 'returns expected value' );
172+
t.strictEqual( out, o, 'return expected value' );
173+
124174
t.end();
125175
});
126176

lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,38 @@ tape( 'the function has an arity of 19', function test( t ) {
3838
t.end();
3939
});
4040

41+
tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) {
42+
var expected;
43+
var out;
44+
var x;
45+
var p;
46+
var a;
47+
var o;
48+
var w;
49+
50+
x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] );
51+
p = new Float64Array( [ 10.0, 15.0 ] );
52+
a = new Float64Array( [ 30.0, 35.0 ] );
53+
o = new Float64Array( 8 );
54+
w = new Float64Array( 8 );
55+
56+
out = ddiff( x.length, 9, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len
57+
expected = new Float64Array([
58+
0.0,
59+
0.0,
60+
0.0,
61+
0.0,
62+
0.0,
63+
0.0,
64+
0.0,
65+
0.0
66+
]);
67+
t.deepEqual( o, expected, 'returns expected value' );
68+
t.strictEqual( out, o, 'return expected value' );
69+
70+
t.end();
71+
});
72+
4173
tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) {
4274
var expected;
4375
var out;
@@ -112,6 +144,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double
112144
t.deepEqual( o, expected, 'returns expected value' );
113145
t.strictEqual( out, o, 'return expected value' );
114146

147+
o = new Float64Array( 9 );
148+
w = new Float64Array( 9 );
149+
150+
out = ddiff( x.length, 0, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len
151+
expected = new Float64Array([
152+
10.0,
153+
15.0,
154+
4.0,
155+
8.0,
156+
12.0,
157+
16.0,
158+
20.0,
159+
30.0,
160+
35.0
161+
]);
162+
t.deepEqual( o, expected, 'returns expected value' );
163+
t.strictEqual( out, o, 'return expected value' );
164+
115165
t.end();
116166
});
117167

lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,38 @@ tape( 'the function has an arity of 19', opts, function test( t ) {
4747
t.end();
4848
});
4949

50+
tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) {
51+
var expected;
52+
var out;
53+
var x;
54+
var p;
55+
var a;
56+
var o;
57+
var w;
58+
59+
x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] );
60+
p = new Float64Array( [ 10.0, 15.0 ] );
61+
a = new Float64Array( [ 30.0, 35.0 ] );
62+
o = new Float64Array( 8 );
63+
w = new Float64Array( 8 );
64+
65+
out = ddiff( x.length, 9, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len
66+
expected = new Float64Array([
67+
0.0,
68+
0.0,
69+
0.0,
70+
0.0,
71+
0.0,
72+
0.0,
73+
0.0,
74+
0.0
75+
]);
76+
t.deepEqual( o, expected, 'returns expected value' );
77+
t.strictEqual( out, o, 'return expected value' );
78+
79+
t.end();
80+
});
81+
5082
tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) {
5183
var expected;
5284
var out;
@@ -121,6 +153,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double
121153
t.deepEqual( o, expected, 'returns expected value' );
122154
t.strictEqual( out, o, 'return expected value' );
123155

156+
o = new Float64Array( 9 );
157+
w = new Float64Array( 9 );
158+
159+
out = ddiff( x.length, 0, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len
160+
expected = new Float64Array([
161+
10.0,
162+
15.0,
163+
4.0,
164+
8.0,
165+
12.0,
166+
16.0,
167+
20.0,
168+
30.0,
169+
35.0
170+
]);
171+
t.deepEqual( o, expected, 'returns expected value' );
172+
t.strictEqual( out, o, 'return expected value' );
173+
124174
t.end();
125175
});
126176

0 commit comments

Comments
 (0)