Skip to content

Commit 7fb09ef

Browse files
committed
feat: add main exports
--- 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: na - 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 22eb89d commit 7fb09ef

File tree

4 files changed

+266
-0
lines changed

4 files changed

+266
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' );
25+
var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' );
26+
var max = require( '@stdlib/math/base/special/max' );
27+
var format = require( '@stdlib/string/format' );
28+
var base = require( './base.js' );
29+
30+
31+
// MAIN //
32+
33+
/**
34+
* Given a 2-by-2 or a 3-by-3 matrix, this function sets `V` to a scalar multiple of the first column of `K` where `K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I)`.
35+
*
36+
* ## Notes
37+
*
38+
* - It is expected that either `sr1 = sr2` and `si1 + si2 = 0` or `si1 = si2 = 0` (i.e., they represent complex conjugate values).
39+
* - This is useful for starting double implicit shift bulges in the QR algorithm.
40+
* - `H` should be an upper hessenberg matrix if it's a 3-by-3 matrix.
41+
* - `V` should have at least `N` indexed elements.
42+
*
43+
* @param {string} order - storage layout
44+
* @param {PositiveInteger} N - number of row/columns in `H`
45+
* @param {Float64Array} H - input matrix
46+
* @param {PositiveInteger} LDH - stride of the first dimension of `H` (a.k.a., leading dimension of the matrix `H`)
47+
* @param {number} sr1 - real part of the first conjugate complex shift
48+
* @param {number} si1 - imaginary part of the first conjugate complex shift
49+
* @param {number} sr2 - real part of the second conjugate complex shift
50+
* @param {number} si2 - imaginary part of the second conjugate complex shift
51+
* @param {Float64Array} V - output array
52+
* @throws {RangeError} first argument must be either 2 or 3
53+
* @throws {TypeError} first argument must be a valid order
54+
* @throws {RangeError} fourth argument must be greater than or equal to max(1,N)
55+
* @returns {Float64Array} `V`
56+
*
57+
* @example
58+
* var Float64Array = require( '@stdlib/array/float64' );
59+
*
60+
* var H = new Float64Array( [ 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ]
61+
* var V = new Float64Array( 3 );
62+
*
63+
* var out = dlaqr1( 'row-major', 3, H, 3, 1.5, 0.0, 2.5, 0.0, V );
64+
* // returns <Float64Array>[ ~1.93, ~0.57, ~2.86 ]
65+
*/
66+
function dlaqr1( order, N, H, LDH, sr1, si1, sr2, si2, V ) {
67+
var sh1;
68+
var sh2;
69+
70+
if ( !isLayout( order ) ) {
71+
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
72+
}
73+
if ( isRowMajor( order ) && LDH < max( 1, N ) ) {
74+
throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDH ) );
75+
}
76+
if ( N !== 2 && N !== 3 ) {
77+
throw new RangeError( format( 'invalid argument. First argument must be either %d or %d. Value: `%d`.', 2, 3, N ) );
78+
}
79+
if ( isColumnMajor( order ) ) {
80+
sh1 = 1;
81+
sh2 = LDH;
82+
} else { // order === 'row-major'
83+
sh1 = LDH;
84+
sh2 = 1;
85+
}
86+
return base( N, H, sh1, sh2, 0, sr1, si1, sr2, si2, V, 1, 0 );
87+
}
88+
89+
90+
// EXPORTS //
91+
92+
module.exports = dlaqr1;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
/**
22+
* Given a 2-by-2 or a 3-by-3 matrix, this LAPACK routine sets `V` to a scalar multiple of the first column of `K` where `K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I)`.
23+
*
24+
* ## Notes
25+
*
26+
* - It is expected that either `sr1 = sr2` and `si1 + si2 = 0` or `si1 = si2 = 0` (i.e., they represent complex conjugate values).
27+
* - This is useful for starting double implicit shift bulges in the QR algorithm.
28+
* - `H` should be an upper hessenberg matrix if it's a 3-by-3 matrix.
29+
* - `V` should have at least `N` indexed elements.
30+
*
31+
* @module @stdlib/lapack/base/dlaqr1
32+
*
33+
* @example
34+
* var Float64Array = require( '@stdlib/array/float64' );
35+
* var dlaqr1 = require( '@stdlib/lapack/base/dlaqr1' );
36+
*
37+
* var H = new Float64Array( [ 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ]
38+
* var V = new Float64Array( 3 );
39+
*
40+
* var out = dlaqr1( 'row-major', 3, H, 3, 1.5, 0.0, 2.5, 0.0, V );
41+
* // returns <Float64Array>[ ~1.93, ~0.57, ~2.86 ]
42+
*/
43+
44+
// MODULES //
45+
46+
var join = require( 'path' ).join;
47+
var tryRequire = require( '@stdlib/utils/try-require' );
48+
var isError = require( '@stdlib/assert/is-error' );
49+
var main = require( './main.js' );
50+
51+
52+
// MAIN //
53+
54+
var dlaqr1;
55+
var tmp = tryRequire( join( __dirname, './native.js' ) );
56+
if ( isError( tmp ) ) {
57+
dlaqr1 = main;
58+
} else {
59+
dlaqr1 = tmp;
60+
}
61+
62+
63+
// EXPORTS //
64+
65+
module.exports = dlaqr1;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
24+
var dlaqr1 = require( './dlaqr1.js' );
25+
var ndarray = require( './ndarray.js' );
26+
27+
28+
// MAIN //
29+
30+
setReadOnly( dlaqr1, 'ndarray', ndarray );
31+
32+
33+
// EXPORTS //
34+
35+
module.exports = dlaqr1;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 format = require( '@stdlib/string/format' );
24+
var base = require( './base.js' );
25+
26+
27+
// MAIN //
28+
29+
/**
30+
* Given a 2-by-2 or a 3-by-3 matrix, this function sets `V` to a scalar multiple of the first column of `K` where `K = (H - (sr1 + i*si1)*I)*(H - (sr2 + i*si2)*I)` using alternative indexing semantics.
31+
*
32+
* ## Notes
33+
*
34+
* - It is expected that either `sr1 = sr2` and `si1 + si2 = 0` or `si1 = si2 = 0` (i.e., they represent complex conjugate values).
35+
* - This is useful for starting double implicit shift bulges in the QR algorithm.
36+
* - `H` should be an upper hessenberg matrix if it's a 3-by-3 matrix.
37+
* - `V` should have at least `N` indexed elements.
38+
*
39+
* @param {PositiveInteger} N - number of row/columns in `H`
40+
* @param {Float64Array} H - input matrix
41+
* @param {integer} strideH1 - stride of the first dimension of `H`
42+
* @param {integer} strideH2 - stride of the second dimension of `H`
43+
* @param {NonNegativeInteger} offsetH - index offset for `H`
44+
* @param {number} sr1 - real part of the first conjugate complex shift
45+
* @param {number} si1 - imaginary part of the first conjugate complex shift
46+
* @param {number} sr2 - real part of the second conjugate complex shift
47+
* @param {number} si2 - imaginary part of the second conjugate complex shift
48+
* @param {Float64Array} V - output array
49+
* @param {integer} strideV - stride length for `V`
50+
* @param {NonNegativeInteger} offsetV - index offset for `V`
51+
* @throws {RangeError} first argument must be either 2 or 3
52+
* @returns {Float64Array} `V`
53+
*
54+
* @example
55+
* var Float64Array = require( '@stdlib/array/float64' );
56+
*
57+
* var H = new Float64Array( [ 1.0, 3.0, 2.0, 2.0, 4.0, 6.0, 0.0, 5.0, 7.0 ] ); // => [ [ 1.0, 3.0, 2.0 ], [ 2.0, 4.0, 6.0 ], [ 0.0, 5.0, 7.0 ] ]
58+
* var V = new Float64Array( 3 );
59+
*
60+
* var out = dlaqr1( 3, H, 3, 1, 0, 1.5, 0.0, 2.5, 0.0, V, 1, 0 );
61+
* // returns <Float64Array>[ ~1.93, ~0.57, ~2.86 ]
62+
*/
63+
function dlaqr1( N, H, strideH1, strideH2, offsetH, sr1, si1, sr2, si2, V, strideV, offsetV ) { // eslint-disable-line max-len, max-params
64+
if ( N !== 2 && N !== 3 ) {
65+
throw new RangeError( format( 'invalid argument. First argument must be either %d or %d. Value: `%d`.', 2, 3, N ) );
66+
}
67+
68+
return base( N, H, strideH1, strideH2, offsetH, sr1, si1, sr2, si2, V, strideV, offsetV ); // eslint-disable-line max-len
69+
}
70+
71+
72+
// EXPORTS //
73+
74+
module.exports = dlaqr1;

0 commit comments

Comments
 (0)