Skip to content

Commit e833c89

Browse files
committed
test: add 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 cd982b0 commit e833c89

File tree

6 files changed

+251
-12
lines changed

6 files changed

+251
-12
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,18 @@ function dlascl( type, KL, KU, CFROM, CTO, M, N, A, strideA1, strideA2, offsetA
210210
}
211211

212212
if ( type === 'symmetric-banded-lower' ) {
213+
ia = offsetA;
214+
k3 = KL + 1;
215+
k4 = N;
216+
213217
if ( isRowMajor( [ strideA1, strideA2 ] ) ) {
214-
ia = offsetA;
215-
k3 = KL + 1;
216-
k4 = N;
217218
for ( i1 = 0; i1 < M; i1++ ) {
218-
for ( i0 = max( 0, i1 - KL ); i0 < min( k4, i1 + 1 ); i0++ ) {
219-
A[ ia+( ( i1-i0 ) * strideA2) ] *= mul;
219+
for ( i0 = 0; i0 < ( N - i1 ); i0++ ) {
220+
A[ ia + ( i0 * strideA2 ) ] *= mul;
220221
}
221222
ia += strideA1;
222223
}
223224
} else {
224-
ia = offsetA;
225225
for ( i1 = 0; i1 < N; i1++ ) {
226226
for ( i0 = 0; i0 < min( k3, k4 - i1 ); i0++ ) {
227227
A[ ia+(i0*strideA1) ] *= mul;
@@ -232,19 +232,18 @@ function dlascl( type, KL, KU, CFROM, CTO, M, N, A, strideA1, strideA2, offsetA
232232
}
233233

234234
if ( type === 'symmetric-banded-upper' ) {
235-
k1 = KU + 1;
236235
ia = offsetA;
237236

238237
if ( isRowMajor( [ strideA1, strideA2 ] ) ) {
239-
for ( i1 = 0; i1 < M; i1++ ) {
240-
for ( i0 = i1; i0 < min( N, i1 + k1 ); i0++ ) {
241-
A[ ia + ( (i0-i1) * strideA2) ] *= mul;
238+
for ( i1 = 0; i1 <= KU; i1++ ) {
239+
for ( i0 = max( KU-i1, 0 ); i0 < N; i0++ ) {
240+
A[ ia + ( i0 * strideA2) ] *= mul;
242241
}
243242
ia += strideA1;
244243
}
245244
} else {
246245
for ( i1 = 0; i1 < N; i1++ ) {
247-
for ( i0 = max( k1 - i1, 0 ); i0 < k1; i0++ ) {
246+
for ( i0 = max( KU - i1, 0 ); i0 <= KU; i0++ ) {
248247
A[ ia+(i0*strideA1) ] *= mul;
249248
}
250249
ia += strideA2;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"order": "column-major",
3+
"type": "symmetric-banded-lower",
4+
"M": 5,
5+
"N": 5,
6+
"KL": 2,
7+
"KU": 2,
8+
"CFROM": 1.0,
9+
"CTO": 10.0,
10+
"A": [
11+
1.1, 6.1, 10.1,
12+
2.2, 7.2, 11.2,
13+
3.3, 8.3, 12.3,
14+
4.4, 9.4, 0.0,
15+
5.5, 0.0, 0.0
16+
],
17+
"A_mat": [
18+
[ 1.1, 6.1, 10.1, 0.0, 0.0 ],
19+
[ 6.1, 2.2, 7.2, 11.2, 0.0 ],
20+
[ 10.1, 7.2, 3.3, 8.3, 12.3 ],
21+
[ 0.0, 11.2, 8.3, 4.4, 9.4 ],
22+
[ 0.0, 0.0, 12.3, 9.4, 5.5 ]
23+
],
24+
"LDA": 3,
25+
"strideA1": 1,
26+
"strideA2": 3,
27+
"offsetA": 0,
28+
"A_out": [
29+
11.0, 61.0, 101.0,
30+
22.0, 72.0, 112.0,
31+
33.0, 83.0, 123.0,
32+
44.0, 94.0, 0.0,
33+
55.0, 0.0, 0.0
34+
],
35+
"A_out_mat": [
36+
[ 11.0, 61.0, 101.0, 0.0, 0.0 ],
37+
[ 61.0, 22.0, 72.0, 112.0, 0.0 ],
38+
[101.0, 72.0, 33.0, 83.0, 123.0 ],
39+
[ 0.0, 112.0, 83.0, 44.0, 94.0 ],
40+
[ 0.0, 0.0, 123.0, 94.0, 55.0 ]
41+
]
42+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"order": "row-major",
3+
"type": "symmetric-banded-lower",
4+
"M": 5,
5+
"N": 5,
6+
"KL": 2,
7+
"KU": 2,
8+
"CFROM": 1.0,
9+
"CTO": 10.0,
10+
"A": [
11+
1.1, 2.2, 3.3, 4.4, 5.5,
12+
6.1, 7.2, 8.3, 9.4, 0.0,
13+
10.1, 11.2, 12.3, 0.0, 0.0
14+
],
15+
"A_mat": [
16+
[ 1.1, 6.1, 10.1, 0.0, 0.0 ],
17+
[ 6.1, 2.2, 7.2, 11.2, 0.0 ],
18+
[ 10.1, 7.2, 3.3, 8.3, 12.3 ],
19+
[ 0.0, 11.2, 8.3, 4.4, 9.4 ],
20+
[ 0.0, 0.0, 12.3, 9.4, 5.5 ]
21+
],
22+
"LDA": 5,
23+
"strideA1": 5,
24+
"strideA2": 1,
25+
"offsetA": 0,
26+
"A_out": [
27+
11.0, 22.0, 33.0, 44.0, 55.0,
28+
61.0, 72.0, 83.0, 94.0, 0.0,
29+
101.0, 112.0, 123.0, 0.0, 0.0
30+
],
31+
"A_out_mat": [
32+
[ 11.0, 61.0, 101.0, 0.0, 0.0 ],
33+
[ 61.0, 22.0, 72.0, 112.0, 0.0 ],
34+
[101.0, 72.0, 33.0, 83.0, 123.0 ],
35+
[ 0.0, 112.0, 83.0, 44.0, 94.0 ],
36+
[ 0.0, 0.0, 123.0, 94.0, 55.0 ]
37+
]
38+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"order": "column-major",
3+
"type": "symmetric-banded-upper",
4+
"M": 5,
5+
"N": 5,
6+
"KL": 2,
7+
"KU": 2,
8+
"CFROM": 1.0,
9+
"CTO": 10.0,
10+
"A": [
11+
0.0, 0.0, 1.1,
12+
0.0, 6.1, 2.2,
13+
10.1, 7.2, 3.3,
14+
11.2, 8.3, 4.4,
15+
12.3, 9.4, 5.5
16+
],
17+
"A_mat": [
18+
[ 1.1, 6.1, 10.1, 0.0, 0.0 ],
19+
[ 6.1, 2.2, 7.2, 11.2, 0.0 ],
20+
[ 10.1, 7.2, 3.3, 8.3, 12.3 ],
21+
[ 0.0, 11.2, 8.3, 4.4, 9.4 ],
22+
[ 0.0, 0.0, 12.3, 9.4, 5.5 ]
23+
],
24+
"LDA": 3,
25+
"strideA1": 1,
26+
"strideA2": 3,
27+
"offsetA": 0,
28+
"A_out": [
29+
0.0, 0.0, 11.0,
30+
0.0, 61.0, 22.0,
31+
101.0, 72.0, 33.0,
32+
112.0, 83.0, 44.0,
33+
123.0, 94.0, 55.0
34+
],
35+
"A_out_mat": [
36+
[ 11.0, 61.0, 101.0, 0.0, 0.0 ],
37+
[ 61.0, 22.0, 72.0, 112.0, 0.0 ],
38+
[101.0, 72.0, 33.0, 83.0, 123.0 ],
39+
[ 0.0, 112.0, 83.0, 44.0, 94.0 ],
40+
[ 0.0, 0.0, 123.0, 94.0, 55.0 ]
41+
]
42+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"order": "row-major",
3+
"type": "symmetric-banded-upper",
4+
"M": 5,
5+
"N": 5,
6+
"KL": 2,
7+
"KU": 2,
8+
"CFROM": 1.0,
9+
"CTO": 10.0,
10+
"A": [
11+
0.0, 0.0, 10.1, 11.2, 12.3,
12+
0.0, 6.1, 7.2, 8.3, 9.4,
13+
1.1, 2.2, 3.3, 4.4, 5.5
14+
],
15+
"A_mat": [
16+
[ 1.1, 6.1, 10.1, 0.0, 0.0 ],
17+
[ 6.1, 2.2, 7.2, 11.2, 0.0 ],
18+
[ 10.1, 7.2, 3.3, 8.3, 12.3 ],
19+
[ 0.0, 11.2, 8.3, 4.4, 9.4 ],
20+
[ 0.0, 0.0, 12.3, 9.4, 5.5 ]
21+
],
22+
"LDA": 5,
23+
"strideA1": 5,
24+
"strideA2": 1,
25+
"offsetA": 0,
26+
"A_out": [
27+
0.0, 0.0, 101.0, 112.0, 123.0,
28+
0.0, 61.0, 72.0, 83.0, 94.0,
29+
11.0, 22.0, 33.0, 44.0, 55.0
30+
],
31+
"A_out_mat": [
32+
[ 11.0, 61.0, 101.0, 0.0, 0.0 ],
33+
[ 61.0, 22.0, 72.0, 112.0, 0.0 ],
34+
[101.0, 72.0, 33.0, 83.0, 123.0 ],
35+
[ 0.0, 112.0, 83.0, 44.0, 94.0 ],
36+
[ 0.0, 0.0, 123.0, 94.0, 55.0 ]
37+
]
38+
}

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

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable max-len */
19+
/* eslint-disable max-len, id-length */
2020

2121
'use strict';
2222

@@ -37,6 +37,10 @@ var LOWER_COL_MAJOR = require( './fixtures/lower_row_major.json' );
3737
var LOWER_ROW_MAJOR = require( './fixtures/lower_row_major.json' );
3838
var BANDED_COL_MAJOR = require( './fixtures/banded_column_major.json' );
3939
var BANDED_ROW_MAJOR = require( './fixtures/banded_row_major.json' );
40+
var SYMMETRIC_BANDED_LOWER_ROW_MAJOR = require( './fixtures/symmetric_banded_lower_row_major.json' );
41+
var SYMMETRIC_BANDED_LOWER_COL_MAJOR = require( './fixtures/symmetric_banded_lower_column_major.json' );
42+
var SYMMETRIC_BANDED_UPPER_ROW_MAJOR = require( './fixtures/symmetric_banded_upper_row_major.json' );
43+
var SYMMETRIC_BANDED_UPPER_COL_MAJOR = require( './fixtures/symmetric_banded_upper_column_major.json' );
4044

4145

4246
// TESTS //
@@ -458,3 +462,79 @@ tape( 'the function scales a banded matrix (row-major)', function test( t ) {
458462

459463
t.end();
460464
});
465+
466+
tape( 'the function scales a symmetric banded matrix where the lower half is stored (column-major)', function test( t ) {
467+
var expected;
468+
var data;
469+
var out;
470+
var A;
471+
472+
data = SYMMETRIC_BANDED_LOWER_COL_MAJOR;
473+
474+
A = new Float64Array( data.A );
475+
476+
expected = new Float64Array( data.A_out );
477+
478+
out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA );
479+
t.strictEqual( out, A, 'returns expected value' );
480+
t.deepEqual( out, expected, 'returns expected value' );
481+
482+
t.end();
483+
});
484+
485+
tape( 'the function scales symmetric banded matrix where the lower half is stored (row-major)', function test( t ) {
486+
var expected;
487+
var data;
488+
var out;
489+
var A;
490+
491+
data = SYMMETRIC_BANDED_LOWER_ROW_MAJOR;
492+
493+
A = new Float64Array( data.A );
494+
495+
expected = new Float64Array( data.A_out );
496+
497+
out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA );
498+
t.strictEqual( out, A, 'returns expected value' );
499+
t.deepEqual( out, expected, 'returns expected value' );
500+
501+
t.end();
502+
});
503+
504+
tape( 'the function scales a symmetric banded matrix where the upper half is stored (column-major)', function test( t ) {
505+
var expected;
506+
var data;
507+
var out;
508+
var A;
509+
510+
data = SYMMETRIC_BANDED_UPPER_COL_MAJOR;
511+
512+
A = new Float64Array( data.A );
513+
514+
expected = new Float64Array( data.A_out );
515+
516+
out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA );
517+
t.strictEqual( out, A, 'returns expected value' );
518+
t.deepEqual( out, expected, 'returns expected value' );
519+
520+
t.end();
521+
});
522+
523+
tape( 'the function scales symmetric banded matrix where the upper half is stored (row-major)', function test( t ) {
524+
var expected;
525+
var data;
526+
var out;
527+
var A;
528+
529+
data = SYMMETRIC_BANDED_UPPER_ROW_MAJOR;
530+
531+
A = new Float64Array( data.A );
532+
533+
expected = new Float64Array( data.A_out );
534+
535+
out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA );
536+
t.strictEqual( out, A, 'returns expected value' );
537+
t.deepEqual( out, expected, 'returns expected value' );
538+
539+
t.end();
540+
});

0 commit comments

Comments
 (0)