Skip to content

Commit 08cc97d

Browse files
committed
feat: add main export
--- 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 191fc91 commit 08cc97d

File tree

4 files changed

+287
-0
lines changed

4 files changed

+287
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' );
25+
var format = require( '@stdlib/string/format' );
26+
var base = require( './base.js' );
27+
28+
29+
// MAIN //
30+
31+
/**
32+
* Balances a general real matrix `A`.
33+
*
34+
* ## Notes
35+
*
36+
* The job parameter can be one of the following:
37+
*
38+
* - 'N': none, return immediately
39+
* - 'P': permute only
40+
* - 'S': scale only
41+
* - 'B': both permute and scale
42+
* - The matrix `A` is overwritten by the balanced matrix.
43+
*
44+
* @private
45+
* @param {string} order - storage layout of `A`
46+
* @param {string} job - indicates the operations to be performed
47+
* @param {NonNegativeInteger} N - number of rows/columns in matrix `A`
48+
* @param {Float64Array} A - input matrix to be balanced
49+
* @param {NonNegativeInteger} LDA - leading dimension of `A`
50+
* @param {Float64Array} out - stores the first and last row/column of the balanced submatrix
51+
* @param {Float64Array} scale - array containing permutation and scaling information
52+
* @throws {TypeError} first argument must be a valid order
53+
* @throws {TypeError} second argument must be a valid job
54+
* @throws {RangeError} fifth argument must be greater than or equal to `N`
55+
* @returns {integer} status code
56+
*
57+
* @example
58+
* var Float64Array = require( '@stdlib/array/float64' );
59+
*
60+
* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] );
61+
* var out = new Float64Array( 2 );
62+
* var scale = new Float64Array( 3 );
63+
*
64+
* dgebal( 'row-major', 'B', 3, A, 3, out, scale );
65+
* // A => <Float64Array>[ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ]
66+
* // out => <Float64Array>[ 0, 1 ]
67+
* // scale => <Float64Array>[ 8, 1, 2 ]
68+
*/
69+
function dgebal( order, job, N, A, LDA, out, scale ) {
70+
var sa1;
71+
var sa2;
72+
73+
if ( !isLayout( order ) ) {
74+
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
75+
}
76+
if ( job !== 'B' && job !== 'S' && job !== 'P' && job !== 'N' ) {
77+
throw new TypeError( format( 'invalid argument. Second argument must be one of the following: `B`, `S`, `P`, or `N`. Value: `%s`.', job ) );
78+
}
79+
if ( isColumnMajor( order ) ) {
80+
sa1 = 1;
81+
sa2 = LDA;
82+
} else { // order === 'row-major'
83+
if ( LDA < N ) {
84+
throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to %d. Value: `%d`.', N, LDA ) );
85+
}
86+
sa1 = LDA;
87+
sa2 = 1;
88+
}
89+
90+
return base( job, N, A, sa1, sa2, 0, out, 1, 0, scale, 1, 0 );
91+
}
92+
93+
94+
// EXPORTS //
95+
96+
module.exports = dgebal;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
* LAPACK routine to balance a general real matrix `A`.
23+
*
24+
* @module @stdlib/lapack/base/dgebal
25+
*
26+
* @example
27+
* var Float64Array = require( '@stdlib/array/float64' );
28+
* var dgebal = require( '@stdlib/lapack/base/dgebal' );
29+
*
30+
* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] );
31+
* var out = new Float64Array( 2 );
32+
* var scale = new Float64Array( 3 );
33+
*
34+
* dgebal( 'row-major', 'B', 3, A, 3, out, scale );
35+
* // A => <Float64Array>[ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ]
36+
* // out => <Float64Array>[ 0, 1 ]
37+
* // scale => <Float64Array>[ 8, 1, 2 ]
38+
*
39+
* @example
40+
* var Float64Array = require( '@stdlib/array/float64' );
41+
* var dgebal = require( '@stdlib/lapack/base/dgebal' );
42+
*
43+
* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] );
44+
* var out = new Float64Array( 2 );
45+
* var scale = new Float64Array( 3 );
46+
*
47+
* dgebal.ndarray( 'B', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 );
48+
* // A => <Float64Array>[ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ]
49+
* // out => <Float64Array>[ 0, 1 ]
50+
* // scale => <Float64Array>[ 8, 1, 2 ]
51+
*/
52+
53+
// MODULES //
54+
55+
var join = require( 'path' ).join;
56+
var tryRequire = require( '@stdlib/utils/try-require' );
57+
var isError = require( '@stdlib/assert/is-error' );
58+
var main = require( './main.js' );
59+
60+
61+
// MAIN //
62+
63+
var dgebal;
64+
var tmp = tryRequire( join( __dirname, './native.js' ) );
65+
if ( isError( tmp ) ) {
66+
dgebal = main;
67+
} else {
68+
dgebal = tmp;
69+
}
70+
71+
72+
// EXPORTS //
73+
74+
module.exports = dgebal;
75+
76+
// exports: { "ndarray": "dgebal.ndarray" }
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 dgebal = require( './dgebal.js' );
25+
var ndarray = require( './ndarray.js' );
26+
27+
28+
// MAIN //
29+
30+
setReadOnly( dgebal, 'ndarray', ndarray );
31+
32+
33+
// EXPORTS //
34+
35+
module.exports = dgebal;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
* Balances a general real matrix `A` using alternative indexing semantics.
31+
*
32+
* ## Notes
33+
*
34+
* The job parameter can be one of the following:
35+
*
36+
* - 'N': none, return immediately
37+
* - 'P': permute only
38+
* - 'S': scale only
39+
* - 'B': both permute and scale
40+
* - The matrix `A` is overwritten by the balanced matrix.
41+
*
42+
* @private
43+
* @param {string} job - indicates the operations to be performed
44+
* @param {NonNegativeInteger} N - number of rows/columns in matrix `A`
45+
* @param {Float64Array} A - input matrix to be balanced
46+
* @param {integer} strideA1 - stride of the first dimension of `A`
47+
* @param {integer} strideA2 - stride of the second dimension of `A`
48+
* @param {NonNegativeInteger} offsetA - starting index for `A`
49+
* @param {Float64Array} out - stores the first and last row/column of the balanced submatrix
50+
* @param {integer} strideOut - stride of `out`
51+
* @param {NonNegativeInteger} offsetOut - starting index for `out`
52+
* @param {Float64Array} scale - array containing permutation and scaling information
53+
* @param {integer} strideScale - stride of `scale`
54+
* @param {NonNegativeInteger} offsetScale - starting index for `scale`
55+
* @throws {TypeError} second argument must be a valid job
56+
* @returns {integer} status code
57+
*
58+
* @example
59+
* var Float64Array = require( '@stdlib/array/float64' );
60+
*
61+
* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] );
62+
* var out = new Float64Array( 2 );
63+
* var scale = new Float64Array( 3 );
64+
*
65+
* dgebal( 'B', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 );
66+
* // A => <Float64Array>[ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ]
67+
* // out => <Float64Array>[ 0, 1 ]
68+
* // scale => <Float64Array>[ 8, 1, 2 ]
69+
*/
70+
function dgebal( job, N, A, strideA1, strideA2, offsetA, out, strideOut, offsetOut, scale, strideScale, offsetScale ) { // eslint-disable-line max-len, max-params
71+
if ( job !== 'B' && job !== 'S' && job !== 'P' && job !== 'N' ) {
72+
throw new TypeError( format( 'invalid argument. Second argument must be one of the following: `B`, `S`, `P`, or `N`. Value: `%s`.', job ) );
73+
}
74+
return base( job, N, A, strideA1, strideA2, offsetA, out, strideOut, offsetOut, scale, strideScale, offsetScale ); // eslint-disable-line max-len
75+
}
76+
77+
78+
// EXPORTS //
79+
80+
module.exports = dgebal;

0 commit comments

Comments
 (0)