Skip to content

Commit 826c766

Browse files
committed
test: add scaled 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 2fc31d0 commit 826c766

File tree

4 files changed

+126
-1
lines changed

4 files changed

+126
-1
lines changed

lib/node_modules/@stdlib/lapack/base/dlatrs/lib/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ function dlatrs( uplo, trans, diag, normin, N, A, strideA1, strideA2, offsetA, X
319319

320320
for ( j = jfirst; (jinc > 0) ? j <= jlast : j >= jlast; j += jinc ) {
321321
xj = abs( X[ ix ] );
322+
GOTO = false;
322323
if ( diag === 'non-unit' ) {
323324
tjjs = A[ ia ] * tscal;
324325
} else {
325326
tjjs = tscal;
326-
GOTO = false;
327327
if ( tscal === 1.0 ) {
328328
GOTO = true;
329329
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"order": "column-major",
3+
4+
"uplo": "lower",
5+
"trans": "no-transpose",
6+
"diag": "non-unit",
7+
"normin": "no",
8+
9+
"N": 3,
10+
"LDA": 3,
11+
12+
"A": [ 1.0, 2.0, 3.0, 0.0, 0.1, 4.0, 0.0, 0.0, 0.01 ],
13+
"strideA1": 1,
14+
"strideA2": 3,
15+
"offsetA": 0,
16+
17+
"A_mat": [
18+
[ 1.0, 0.0, 0.0 ],
19+
[ 2.0, 0.1, 0.0 ],
20+
[ 3.0, 4.0, 0.01 ]
21+
],
22+
23+
"X": [ 1.0e308, 1.0e308, 1.0e308 ],
24+
"strideX": 1,
25+
"offsetX": 0,
26+
27+
"CNORM": [ 0.0, 0.0, 0.0 ],
28+
"strideCNORM": 1,
29+
"offsetCNORM": 0,
30+
31+
"expectedX": [ 0.5, -5.0, 1900.0 ],
32+
"expectedCNORM": [ 5.0, 4.0, 0.0 ],
33+
"scale": 4.9999999999999995e-309
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"order": "row-major",
3+
4+
"uplo": "lower",
5+
"trans": "no-transpose",
6+
"diag": "non-unit",
7+
"normin": "no",
8+
9+
"N": 3,
10+
"LDA": 3,
11+
12+
"A": [ 1.0, 0.0, 0.0, 2.0, 0.1, 0.0, 3.0, 4.0, 0.01 ],
13+
"strideA1": 3,
14+
"strideA2": 1,
15+
"offsetA": 0,
16+
17+
"A_mat": [
18+
[ 1.0, 0.0, 0.0 ],
19+
[ 2.0, 0.1, 0.0 ],
20+
[ 3.0, 4.0, 0.01 ]
21+
],
22+
23+
"X": [ 1.0e308, 1.0e308, 1.0e308 ],
24+
"strideX": 1,
25+
"offsetX": 0,
26+
27+
"CNORM": [ 0.0, 0.0, 0.0 ],
28+
"strideCNORM": 1,
29+
"offsetCNORM": 0,
30+
31+
"expectedX": [ 0.5, -5.0, 1900.0 ],
32+
"expectedCNORM": [ 5.0, 4.0, 0.0 ],
33+
"scale": 4.9999999999999995e-309
34+
}

lib/node_modules/@stdlib/lapack/base/dlatrs/test/test.dlatrs.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ var UNIT_TRANS_LOWER_COL_MAJOR = require( './fixtures/unit_trans_lower_col_major
4949
var UNIT_TRANS_UPPER_ROW_MAJOR = require( './fixtures/unit_trans_upper_row_major.json' );
5050
var UNIT_TRANS_UPPER_COL_MAJOR = require( './fixtures/unit_trans_upper_col_major.json' );
5151

52+
var SCALED_NON_UNIT_NO_TRANS_LOWER_ROW_MAJOR = require( './fixtures/scaled_non_unit_no_trans_lower_row_major.json' );
53+
var SCALED_NON_UNIT_NO_TRANS_LOWER_COL_MAJOR = require( './fixtures/scaled_non_unit_no_trans_lower_col_major.json' );
54+
5255

5356
// TESTS //
5457

@@ -763,3 +766,57 @@ tape( 'the function returns expected output for normal values (column-major) (up
763766

764767
t.end();
765768
});
769+
770+
tape.only( 'the function returns expected output for large values (row-major) (lower triangular) (no-transpose) (non-unit)', function test( t ) {
771+
var expectedCNORM;
772+
var expectedX;
773+
var scale;
774+
var CNORM;
775+
var data;
776+
var A;
777+
var X;
778+
779+
data = SCALED_NON_UNIT_NO_TRANS_LOWER_ROW_MAJOR;
780+
781+
A = new Float64Array( data.A );
782+
CNORM = new Float64Array( data.CNORM );
783+
X = new Float64Array( data.X );
784+
785+
expectedCNORM = new Float64Array( data.expectedCNORM );
786+
expectedX = new Float64Array( data.expectedX );
787+
788+
scale = dlatrs( data.order, data.uplo, data.trans, data.diag, data.normin, data.N, A, data.LDA, X, CNORM );
789+
790+
t.strictEqual( scale, data.scale, 'returns expected value' );
791+
t.deepEqual( X, expectedX, 'returns expected value' );
792+
t.deepEqual( CNORM, expectedCNORM, 'returns expected value' );
793+
794+
t.end();
795+
});
796+
797+
tape( 'the function returns expected output for large values (column-major) (lower triangular) (no-transpose) (non-unit)', function test( t ) {
798+
var expectedCNORM;
799+
var expectedX;
800+
var scale;
801+
var CNORM;
802+
var data;
803+
var A;
804+
var X;
805+
806+
data = SCALED_NON_UNIT_NO_TRANS_LOWER_COL_MAJOR;
807+
808+
A = new Float64Array( data.A );
809+
CNORM = new Float64Array( data.CNORM );
810+
X = new Float64Array( data.X );
811+
812+
expectedCNORM = new Float64Array( data.expectedCNORM );
813+
expectedX = new Float64Array( data.expectedX );
814+
815+
scale = dlatrs( data.order, data.uplo, data.trans, data.diag, data.normin, data.N, A, data.LDA, X, CNORM );
816+
817+
t.strictEqual( scale, data.scale, 'returns expected value' );
818+
t.deepEqual( X, expectedX, 'returns expected value' );
819+
t.deepEqual( CNORM, expectedCNORM, 'returns expected value' );
820+
821+
t.end();
822+
});

0 commit comments

Comments
 (0)