Skip to content

Commit d3dbc84

Browse files
committed
test: add test cases for blas/base/dgemm
--- 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: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent a2ab0a6 commit d3dbc84

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ function dgemm( transA, transB, M, N, K, alpha, A, strideA1, strideA2, offsetA,
8282
if ( K < 0 ) {
8383
throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', K ) );
8484
}
85+
if ( strideA1 === 0 ) {
86+
throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero.', strideA1 ) );
87+
}
88+
if ( strideA2 === 0 ) {
89+
throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero.', strideA2 ) );
90+
}
91+
if ( strideB1 === 0 ) {
92+
throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero.', strideB1 ) );
93+
}
94+
if ( strideB2 === 0 ) {
95+
throw new RangeError( format( 'invalid argument. Thirteenth argument must be non-zero.', strideB2 ) );
96+
}
97+
if ( strideC1 === 0 ) {
98+
throw new RangeError( format( 'invalid argument. Seventeenth argument must be non-zero.', strideC1 ) );
99+
}
100+
if ( strideC2 === 0 ) {
101+
throw new RangeError( format( 'invalid argument. Eighteenth argument must be non-zero.', strideC2 ) );
102+
}
85103
return base( transA, transB, M, N, K, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB, beta, C, strideC1, strideC2, offsetC ); // eslint-disable-line max-len
86104
}
87105

lib/node_modules/@stdlib/blas/base/dgemm/test/test.ndarray.js

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,144 @@ tape( 'the function throws an error if provided an invalid fifth argument', func
224224
}
225225
});
226226

227+
tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) {
228+
var values;
229+
var data;
230+
var i;
231+
232+
data = rarbrcntantb;
233+
234+
values = [
235+
0
236+
];
237+
238+
for ( i = 0; i < values.length; i++ ) {
239+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
240+
}
241+
t.end();
242+
243+
function badValue( value ) {
244+
return function badValue() {
245+
dgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, new Float64Array( data.A ), value, data.strideA2, data.offsetA, new Float64Array( data.B ), data.strideB1, data.strideB2, data.offsetB, data.beta, new Float64Array( data.C ), data.strideC1, data.strideC2, data.offsetC );
246+
};
247+
}
248+
});
249+
250+
tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) {
251+
var values;
252+
var data;
253+
var i;
254+
255+
data = rarbrcntantb;
256+
257+
values = [
258+
0
259+
];
260+
261+
for ( i = 0; i < values.length; i++ ) {
262+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
263+
}
264+
t.end();
265+
266+
function badValue( value ) {
267+
return function badValue() {
268+
dgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, new Float64Array( data.A ), data.strideA1, value, data.offsetA, new Float64Array( data.B ), data.strideB1, data.strideB2, data.offsetB, data.beta, new Float64Array( data.C ), data.strideC1, data.strideC2, data.offsetC );
269+
};
270+
}
271+
});
272+
273+
tape( 'the function throws an error if provided an invalid twelfth argument', function test( t ) {
274+
var values;
275+
var data;
276+
var i;
277+
278+
data = rarbrcntantb;
279+
280+
values = [
281+
0
282+
];
283+
284+
for ( i = 0; i < values.length; i++ ) {
285+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
286+
}
287+
t.end();
288+
289+
function badValue( value ) {
290+
return function badValue() {
291+
dgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.B ), value, data.strideB2, data.offsetB, data.beta, new Float64Array( data.C ), data.strideC1, data.strideC2, data.offsetC );
292+
};
293+
}
294+
});
295+
296+
tape( 'the function throws an error if provided an invalid thirteenth argument', function test( t ) {
297+
var values;
298+
var data;
299+
var i;
300+
301+
data = rarbrcntantb;
302+
303+
values = [
304+
0
305+
];
306+
307+
for ( i = 0; i < values.length; i++ ) {
308+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
309+
}
310+
t.end();
311+
312+
function badValue( value ) {
313+
return function badValue() {
314+
dgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.B ), data.strideB1, value, data.offsetB, data.beta, new Float64Array( data.C ), data.strideC1, data.strideC2, data.offsetC );
315+
};
316+
}
317+
});
318+
319+
tape( 'the function throws an error if provided an invalid seventeenth argument', function test( t ) {
320+
var values;
321+
var data;
322+
var i;
323+
324+
data = rarbrcntantb;
325+
326+
values = [
327+
0
328+
];
329+
330+
for ( i = 0; i < values.length; i++ ) {
331+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
332+
}
333+
t.end();
334+
335+
function badValue( value ) {
336+
return function badValue() {
337+
dgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.B ), data.strideB1, data.strideB2, data.offsetB, data.beta, new Float64Array( data.C ), value, data.strideC2, data.offsetC );
338+
};
339+
}
340+
});
341+
342+
tape( 'the function throws an error if provided an invalid eighteenth argument', function test( t ) {
343+
var values;
344+
var data;
345+
var i;
346+
347+
data = rarbrcntantb;
348+
349+
values = [
350+
0
351+
];
352+
353+
for ( i = 0; i < values.length; i++ ) {
354+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
355+
}
356+
t.end();
357+
358+
function badValue( value ) {
359+
return function badValue() {
360+
dgemm( data.transA, data.transB, data.M, data.N, data.K, data.alpha, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA, new Float64Array( data.B ), data.strideB1, data.strideB2, data.offsetB, data.beta, new Float64Array( data.C ), data.strideC1, value, data.offsetC );
361+
};
362+
}
363+
});
364+
227365
tape( 'the function performs the matrix-matrix operation `C = α*op(A)*op(B) + β*C` (column_major, column_major, column_major, no-transpose, no-transpose)', function test( t ) {
228366
var expected;
229367
var data;

0 commit comments

Comments
 (0)