Skip to content

Commit c9f4cb9

Browse files
committed
fix: add missing checks and tests
--- 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 4a3d3f0 commit c9f4cb9

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.native.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ var addon = require( './../src/addon.node' );
4444
* @throws {TypeError} first argument must specify whether to reference the lower or upper triangular matrix
4545
* @throws {RangeError} second argument must be a nonnegative integer
4646
* @throws {RangeError} fifth argument must be non-zero
47+
* @throws {RangeError} eighth argument must be non-zero
48+
* @throws {RangeError} ninth argument must be non-zero
4749
* @returns {Float64Array} `A`
4850
*
4951
* @example
@@ -65,6 +67,12 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse
6567
if ( strideX === 0 ) {
6668
throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) );
6769
}
70+
if ( strideA1 === 0 ) {
71+
throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideA1 ) );
72+
}
73+
if ( strideA2 === 0 ) {
74+
throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideA2 ) );
75+
}
6876
// Check if we can early return...
6977
if ( N === 0 || alpha === 0.0 ) {
7078
return A;

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

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var rl = require( './fixtures/row_major_l.json' );
3535
var rxp = require( './fixtures/row_major_xp.json' );
3636
var rxn = require( './fixtures/row_major_xn.json' );
3737
var roa = require( './fixtures/row_major_oa.json' );
38+
var rox = require( './fixtures/row_major_ox.json' );
3839
var rsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' );
3940
var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' );
4041
var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' );
@@ -46,6 +47,7 @@ var cl = require( './fixtures/column_major_l.json' );
4647
var cxp = require( './fixtures/column_major_xp.json' );
4748
var cxn = require( './fixtures/column_major_xn.json' );
4849
var coa = require( './fixtures/column_major_oa.json' );
50+
var cox = require( './fixtures/column_major_ox.json' );
4951
var csa1sa2 = require( './fixtures/column_major_sa1_sa2.json' );
5052
var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' );
5153
var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' );
@@ -148,6 +150,52 @@ tape( 'the function throws an error if provided an invalid fifth argument', opts
148150
}
149151
});
150152

153+
tape( 'the function throws an error if provided an invalid eighth argument', opts, function test( t ) {
154+
var values;
155+
var data;
156+
var i;
157+
158+
data = ru;
159+
160+
values = [
161+
0
162+
];
163+
164+
for ( i = 0; i < values.length; i++ ) {
165+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
166+
}
167+
t.end();
168+
169+
function badValue( value ) {
170+
return function badValue() {
171+
dsyr( data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), value, data.strideA2, data.offsetA );
172+
};
173+
}
174+
});
175+
176+
tape( 'the function throws an error if provided an invalid ninth argument', opts, function test( t ) {
177+
var values;
178+
var data;
179+
var i;
180+
181+
data = ru;
182+
183+
values = [
184+
0
185+
];
186+
187+
for ( i = 0; i < values.length; i++ ) {
188+
t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
189+
}
190+
t.end();
191+
192+
function badValue( value ) {
193+
return function badValue() {
194+
dsyr( data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, value, data.offsetA );
195+
};
196+
}
197+
});
198+
151199
tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (row-major, upper)', opts, function test( t ) {
152200
var expected;
153201
var data;
@@ -593,6 +641,48 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', o
593641
t.end();
594642
});
595643

644+
tape( 'the function supports specifying an `x` offset (row-major)', opts, function test( t ) {
645+
var expected;
646+
var data;
647+
var out;
648+
var a;
649+
var x;
650+
651+
data = rox;
652+
653+
a = new Float64Array( data.A );
654+
x = new Float64Array( data.x );
655+
656+
expected = new Float64Array( data.A_out );
657+
658+
out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA );
659+
t.strictEqual( out, a, 'returns expected value' );
660+
t.deepEqual( out, expected, 'returns expected value' );
661+
662+
t.end();
663+
});
664+
665+
tape( 'the function supports specifying an `x` offset (column-major)', opts, function test( t ) {
666+
var expected;
667+
var data;
668+
var out;
669+
var a;
670+
var x;
671+
672+
data = cox;
673+
674+
a = new Float64Array( data.A );
675+
x = new Float64Array( data.x );
676+
677+
expected = new Float64Array( data.A_out );
678+
679+
out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA );
680+
t.strictEqual( out, a, 'returns expected value' );
681+
t.deepEqual( out, expected, 'returns expected value' );
682+
683+
t.end();
684+
});
685+
596686
tape( 'the function supports complex access patterns (row-major)', opts, function test( t ) {
597687
var expected;
598688
var data;

0 commit comments

Comments
 (0)