Skip to content

Commit 181951d

Browse files
committed
feat: 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 64bc335 commit 181951d

40 files changed

+7049
-41
lines changed

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

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var dtrmm = require( './dtrmm.js' );
6666
* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] );
6767
* var work = new Float64Array( 9 );
6868
*
69-
* dlarfb( 'left', 'transpose', 'forward', 'column-major', 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0 );
69+
* dlarfb( 'left', 'transpose', 'forward', 'columns', 3, 3, 3, V, 3, 1, 0, T, 3, 1, 0, C, 3, 1, 0, work, 3, 1, 0 );
7070
*
7171
* // C => <Float64Array>[ -1350.00, -1400.00, -1450.00, -30961.00, -32102.00, -33243.00, -266612.00, -275464.00, -284316.00 ]
7272
*/
@@ -89,17 +89,19 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
8989
transt = 'no-transpose';
9090
}
9191

92-
if ( storev === 'column-major' ) {
92+
if ( storev === 'columns' ) {
9393
if ( direct === 'forward' ) {
94-
// Let V = ( V1 ) (first K rows)
95-
// ( V2 )
96-
// Where V1 is unit lower triangular.
94+
/* Let V = ( V1 ) (first K rows)
95+
* ( V2 )
96+
* Where V1 is unit lower triangular.
97+
*/
9798

9899
if ( side === 'left' ) {
99-
// Form H * C or H ^ T * C where C = ( C1 )
100-
// ( C2 )
101-
// W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK)
102-
// W := C1**T
100+
/* Form H * C or H ^ T * C where C = ( C1 )
101+
* ( C2 )
102+
* W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK)
103+
* W := C1**T
104+
*/
103105
for ( j = 0; j < K; j++ ) {
104106
cOffset = offsetC + ( j * strideC1 ); // C( j, 1 ) - 0 based index
105107
wOffset = offsetWork + ( j * strideWork2 ); // W( 1, j ) - 0 based index
@@ -135,9 +137,10 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
135137
}
136138
}
137139
} else if ( side === 'right' ) {
138-
// Form C * H or C * H ^ T where C = ( C1 C2 )
139-
// W := C * V = (C1*V1 + C2*V2) (stored in WORK)
140-
// W := C1
140+
/* Form C * H or C * H ^ T where C = ( C1 C2 )
141+
* W := C * V = (C1*V1 + C2*V2) (stored in WORK)
142+
* W := C1
143+
*/
141144
for ( j = 0; j < K; j++ ) {
142145
cOffset = offsetC + ( j * strideC2 ); // C( 1, j ) - 0 based index
143146
wOffset = offsetWork + ( j * strideWork2 ); // W( 1, j ) - 0 based index
@@ -174,15 +177,17 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
174177
}
175178
}
176179
} else {
177-
// Let V = ( V1 )
178-
// ( V2 ) (last K rows)
179-
// Where V2 is unit upper triangular.
180+
/* Let V = ( V1 )
181+
* ( V2 ) (last K rows)
182+
* Where V2 is unit upper triangular.
183+
*/
180184

181185
if ( side === 'left' ) {
182-
// Form H * C or H ^ T * C where C = ( C1 )
183-
// ( C2 )
184-
// W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK)
185-
// W := C2**T
186+
/* Form H * C or H ^ T * C where C = ( C1 )
187+
* ( C2 )
188+
* W := C**T * V = (C1**T * V1 + C2**T * V2) (stored in WORK)
189+
* W := C2**T
190+
*/
186191
for ( j = 0; j < K; j++ ) {
187192
cOffset = offsetC + ( (M-K+j) * strideC1 );
188193
wOffset = offsetWork + ( j * strideWork2 );
@@ -216,9 +221,10 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
216221
}
217222
}
218223
} else if ( side === 'right' ) {
219-
// Form C * H or C * H ^ T where C = ( C1 C2 )
220-
// W := C * V = (C1*V1 + C2*V2) (stored in WORK)
221-
// W := C2
224+
/* Form C * H or C * H ^ T where C = ( C1 C2 )
225+
* W := C * V = (C1*V1 + C2*V2) (stored in WORK)
226+
* W := C2
227+
*/
222228
for ( j = 0; j < K; j++ ) {
223229
cOffset = offsetC + ( (N-K+j) * strideC2 );
224230
wOffset = offsetWork + ( j * strideWork2 );
@@ -253,15 +259,17 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
253259
}
254260
}
255261
}
256-
} else if ( storev === 'row-major' ) {
262+
} else if ( storev === 'rows' ) {
257263
if ( direct === 'forward' ) {
258-
// Let V = ( V1 V2 ) (V1: first K columns)
259-
// Where V1 is unit upper triangular.
264+
/* Let V = ( V1 V2 ) (V1: first K columns)
265+
* Where V1 is unit upper triangular.
266+
*/
260267
if ( side === 'left' ) {
261-
// Form H * C or H ^ T * C where C = ( C1 )
262-
// ( C2 )
263-
// W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in WORK)
264-
// W := C1**T
268+
/* Form H * C or H ^ T * C where C = ( C1 )
269+
* ( C2 )
270+
* W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in work)
271+
* W := C1**T
272+
*/
265273
for ( j = 0; j < K; j++ ) {
266274
cOffset = offsetC + ( j * strideC1 );
267275
wOffset = offsetWork + ( j * strideWork2 );
@@ -297,9 +305,10 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
297305
}
298306
}
299307
} else if ( side === 'right' ) {
300-
// Form C * H or C * H ^ T where C = ( C1 C2 )
301-
// W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK)
302-
// W := C1
308+
/* Form C * H or C * H ^ T where C = ( C1 C2 )
309+
* W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK)
310+
* W := C1
311+
*/
303312
for ( j = 0; j < K; j++ ) {
304313
cOffset = offsetC + ( j * strideC2 );
305314
wOffset = offsetWork + ( j * strideWork2 );
@@ -336,13 +345,15 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
336345
}
337346
}
338347
} else {
339-
// Let V = ( V1 V2 ) (V2: last K columns)
340-
// Where V2 is unit lower triangular.
348+
/* Let V = ( V1 V2 ) (V2: last K columns)
349+
* Where V2 is unit lower triangular.
350+
*/
341351
if ( side === 'left' ) {
342-
// Form H * C or H ^ T * C where C = ( C1 )
343-
// ( C2 )
344-
// W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in WORK)
345-
// W := C2**T
352+
/* Form H * C or H ^ T * C where C = ( C1 )
353+
* ( C2 )
354+
* W := C**T * V**T = (C1**T * V1**T + C2**T * V2**T) (stored in WORK)
355+
* W := C2**T
356+
*/
346357
for ( j = 0; j < K; j++ ) {
347358
cOffset = offsetC + ( (M-K+j) * strideC1 );
348359
wOffset = offsetWork + ( j * strideWork2 );
@@ -376,9 +387,10 @@ function dlarfb( side, trans, direct, storev, M, N, K, V, strideV1, strideV2, of
376387
}
377388
}
378389
} else if ( side === 'right' ) {
379-
// Form C * H or C * H ^ T where C = ( C1 C2 )
380-
// W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK)
381-
// W := C2
390+
/* Form C * H or C * H ^ T where C = ( C1 C2 )
391+
* W := C * V**T = (C1*V1**T + C2*V2**T) (stored in WORK)
392+
* W := C2
393+
*/
382394
for ( j = 0; j < K; j++ ) {
383395
cOffset = offsetC + ( (N-K+j) * strideC2 );
384396
wOffset = offsetWork + ( j * strideWork2 );
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
24+
var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' );
25+
var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' );
26+
var isMatrixOrientation = require( '@stdlib/blas/base/assert/is-matrix-orientation' );
27+
var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' );
28+
var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' );
29+
var max = require( '@stdlib/math/base/special/max' );
30+
var format = require( '@stdlib/string/format' );
31+
var base = require( './base.js' );
32+
33+
34+
// MAIN //
35+
36+
/**
37+
* Applies a real block reflector `H` or its transpose `H ^ T` to a real `M` by `N` matrix `C`, from either the left or the right.
38+
*
39+
* @param {string} order - storage layout
40+
* @param {string} side - specifies whether `H` or `H ^ T` is applied from the left or right
41+
* @param {string} trans - specifies whether to apply `H` or `H ^ T` (`'no-transpose'` or `'transpose'`)
42+
* @param {string} direct - indicates how `H` is formed from a product of elementary reflectors (`'forward'` or `'backward'`)
43+
* @param {string} storev - indicates how the vectors which define the elementary reflectors are stored (`'column-major'` or `'row-major'`)
44+
* @param {NonNegativeInteger} M - number of rows of the matrix `C`
45+
* @param {NonNegativeInteger} N - number of columns of the matrix `C`
46+
* @param {NonNegativeInteger} K - order of the matrix `T`
47+
* @param {Float64Array} V - input matrix
48+
* @param {PositiveInteger} LDV - leading dimension of `V`
49+
* @param {Float64Array} T - input matrix (upper/lower triangular as dictated by `direct`/`storev`)
50+
* @param {PositiveInteger} LDT - leading dimension of `T` (must be ≥ max(1,K))
51+
* @param {Float64Array} C - input/output matrix
52+
* @param {PositiveInteger} LDC - leading dimension of `C`
53+
* @param {Float64Array} work - work array
54+
* @param {PositiveInteger} LDWORK - leading dimension of `work`
55+
* @throws {TypeError} first argument must be a valid order
56+
* @throws {TypeError} invalid `side`
57+
* @throws {TypeError} invalid `trans`
58+
* @throws {TypeError} invalid `direct`
59+
* @throws {TypeError} invalid `storev`
60+
* @throws {RangeError} invalid leading dimension(s)
61+
* @returns {Float64Array} updated matrix `C`
62+
*
63+
* @example
64+
* var Float64Array = require( '@stdlib/array/float64' );
65+
*
66+
* var V = new Float64Array( [ 10.0, 40.0, 70.0, 20.0, 50.0, 80.0, 30.0, 60.0, 90.0 ] );
67+
* var T = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] );
68+
* var C = new Float64Array( [ 11.0, 12.0, 13.0, 21.0, 22.0, 23.0, 31.0, 32.0, 33.0 ] );
69+
* var work = new Float64Array( 9 );
70+
*
71+
* dlarfb( 'row-major', 'left', 'transpose', 'forward', 'columns', 3, 3, 3, V, 3, T, 3, C, 3, work, 3 );
72+
*
73+
* // C => <Float64Array>[ -1350.00, -1400.00, -1450.00, -30961.00, -32102.00, -33243.00, -266612.00, -275464.00, -284316.00 ]
74+
*/
75+
function dlarfb( order, side, trans, direct, storev, M, N, K, V, LDV, T, LDT, C, LDC, work, LDWORK ) { // eslint-disable-line max-params, max-len
76+
var requiredLdwork;
77+
var sv1;
78+
var sv2;
79+
var st1;
80+
var st2;
81+
var sc1;
82+
var sc2;
83+
var sw1;
84+
var sw2;
85+
86+
if ( !isLayout( order ) ) {
87+
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
88+
}
89+
if ( !isOperationSide( side ) ) {
90+
throw new TypeError( format( 'invalid argument. Second argument must be a valid BLAS operation side. Value: `%s`.', side ) );
91+
}
92+
if ( !isTransposeOperation( trans ) ) {
93+
throw new TypeError( format( 'invalid argument. Third argument must be a valid BLAS transpose operation. Value: `%s`.', trans ) );
94+
}
95+
if ( direct !== 'forward' && direct !== 'backward' ) {
96+
throw new TypeError( format( 'invalid argument. Fourth argument must be either `forward` or `backward`. Value: `%s`.', direct ) );
97+
}
98+
if ( !isMatrixOrientation( storev ) ) {
99+
throw new TypeError( format( 'invalid argument. Fifth argument must be a valid matrix orientation. Value: `%s`.', storev ) );
100+
}
101+
102+
if ( isRowMajor( order ) ) {
103+
if ( LDC < max( 1, N ) ) {
104+
throw new RangeError( format( 'invalid argument. Thirteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDC ) );
105+
}
106+
if ( LDT < max( 1, K ) ) {
107+
throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDT ) );
108+
}
109+
if ( storev === 'columns' ) {
110+
if ( LDV < max( 1, K ) ) {
111+
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDV ) );
112+
}
113+
} else if ( storev === 'rows' ) {
114+
if ( side === 'left' ) {
115+
if ( LDV < max( 1, M ) ) {
116+
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDV ) );
117+
}
118+
} else if ( side === 'right' ) {
119+
if ( LDV < max( 1, N ) ) {
120+
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDV ) );
121+
}
122+
}
123+
}
124+
if ( LDWORK < max( 1, K ) ) {
125+
throw new RangeError( format( 'invalid argument. Fifteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDWORK ) );
126+
}
127+
} else if ( isColumnMajor( order ) ) {
128+
if ( LDC < max( 1, M ) ) {
129+
throw new RangeError( format( 'invalid argument. Thirteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDC ) );
130+
}
131+
if ( LDT < max( 1, K ) ) {
132+
throw new RangeError( format( 'invalid argument. Twelfth argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDT ) );
133+
}
134+
if ( storev === 'columns' ) {
135+
if ( side === 'left' ) {
136+
if ( LDV < max( 1, M ) ) {
137+
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDV ) );
138+
}
139+
} else if ( side === 'right' ) {
140+
if ( LDV < max( 1, N ) ) {
141+
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDV ) );
142+
}
143+
}
144+
} else if ( storev === 'rows' ) {
145+
if ( LDV < max( 1, K ) ) {
146+
throw new RangeError( format( 'invalid argument. Eleventh argument must be greater than or equal to max(1,%d). Value: `%d`.', K, LDV ) );
147+
}
148+
}
149+
if ( side === 'left' ) {
150+
requiredLdwork = N;
151+
} else {
152+
requiredLdwork = M;
153+
}
154+
if ( LDWORK < max( 1, requiredLdwork ) ) {
155+
throw new RangeError( format( 'invalid argument. Fifteenth argument must be greater than or equal to max(1,%d). Value: `%d`.', requiredLdwork, LDWORK ) );
156+
}
157+
}
158+
159+
if ( isColumnMajor( order ) ) {
160+
sv1 = 1;
161+
sv2 = LDV;
162+
st1 = 1;
163+
st2 = LDT;
164+
sc1 = 1;
165+
sc2 = LDC;
166+
sw1 = 1;
167+
sw2 = LDWORK;
168+
} else {
169+
sv1 = LDV;
170+
sv2 = 1;
171+
st1 = LDT;
172+
st2 = 1;
173+
sc1 = LDC;
174+
sc2 = 1;
175+
sw1 = LDWORK;
176+
sw2 = 1;
177+
}
178+
179+
return base( side, trans, direct, storev, M, N, K, V, sv1, sv2, 0, T, st1, st2, 0, C, sc1, sc2, 0, work, sw1, sw2, 0 ); // eslint-disable-line max-len
180+
}
181+
182+
183+
// EXPORTS //
184+
185+
module.exports = dlarfb;

0 commit comments

Comments
 (0)