Skip to content

Commit 7bcf93c

Browse files
committed
feat: complete initial implementation for dgttrf
--- 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 4686b1a commit 7bcf93c

File tree

4 files changed

+257
-0
lines changed

4 files changed

+257
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
* Computes an LU factorization of a real tri diagonal matrix A using elimination with partial pivoting and row interchanges.
31+
*
32+
* @param {NonNegativeInteger} N - order of `A`
33+
* @param {Float64Array} DL - sub diagonal elements of `A`
34+
* @param {Float64Array} D - diagonal elements of `A`
35+
* @param {Float64Array} DU - diagonal elements of `A`
36+
* @param {Float64Array} DU2 - diagonal elements of `A`
37+
* @param {Int32Array} IPIV - vector of pivot indices
38+
* @throws {RangeError} first argument must be a nonnegative integer
39+
* @returns {integer} status code
40+
*
41+
* @example
42+
* var Float64Array = require( '@stdlib/array/float64' );
43+
*
44+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
45+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
46+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
47+
* var DU2 = new Float64Array( [ 0.0 ] );
48+
* var IPIV = new Int32Array( [ 0, 1, 2 ] );
49+
*
50+
* dgttrf( 3, DL, D, DU, DU2, IPIV );
51+
* // DL => <Float64Array>[ 0.5, 0.4 ]
52+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
53+
* // DU => <Float64Array>[ 1, 1 ]
54+
* // DU2 => <Float64Array>[ 0 ]
55+
*/
56+
function dgttrf( N, DL, D, DU, DU2, IPIV ) {
57+
if ( N < 0 ) {
58+
throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) );
59+
}
60+
return base( N, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 );
61+
}
62+
63+
64+
// EXPORTS //
65+
66+
module.exports = dgttrf;
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+
/**
22+
* LAPACK routine to compute an LU factorization of a real tri diagonal matrix A using elimination with partial pivoting and row interchanges.
23+
*
24+
* @module @stdlib/lapack/base/dgttrf
25+
*
26+
* @example
27+
* var Float64Array = require( '@stdlib/array/float64' );
28+
* var dgttrf = require( '@stdlib/lapack/base/dgttrf' );
29+
*
30+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
31+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
32+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
33+
* var DU2 = new Float64Array( [ 0.0 ] );
34+
* var IPIV = new Int32Array( [ 0, 1, 2 ] );
35+
*
36+
* dgttrf( 3, DL, D, DU, DU2, IPIV );
37+
* // DL => <Float64Array>[ 0.5, 0.4 ]
38+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
39+
* // DU => <Float64Array>[ 1, 1 ]
40+
* // DU2 => <Float64Array>[ 0 ]
41+
*
42+
* @example
43+
* var Float64Array = require( '@stdlib/array/float64' );
44+
* var dgttrf = require( '@stdlib/lapack/base/dgttrf' );
45+
*
46+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
47+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
48+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
49+
* var DU2 = new Float64Array( [ 0.0 ] );
50+
* var IPIV = new Int32Array( [ 0, 1, 2 ] );
51+
*
52+
* dgttrf( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 );
53+
* // DL => <Float64Array>[ 0.5, 0.4 ]
54+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
55+
* // DU => <Float64Array>[ 1, 1 ]
56+
* // DU2 => <Float64Array>[ 0 ]
57+
*/
58+
59+
// MODULES //
60+
61+
var join = require( 'path' ).join;
62+
var tryRequire = require( '@stdlib/utils/try-require' );
63+
var isError = require( '@stdlib/assert/is-error' );
64+
var main = require( './main.js' );
65+
66+
67+
// MAIN //
68+
69+
var dgttrf;
70+
var tmp = tryRequire( join( __dirname, './native.js' ) );
71+
if ( isError( tmp ) ) {
72+
dgttrf = main;
73+
} else {
74+
dgttrf = tmp;
75+
}
76+
77+
78+
// EXPORTS //
79+
80+
module.exports = dgttrf;
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 dgttrf = require( './dgttrf.js' );
25+
var ndarray = require( './ndarray.js' );
26+
27+
28+
// MAIN //
29+
30+
setReadOnly( dgttrf, 'ndarray', ndarray );
31+
32+
33+
// EXPORTS //
34+
35+
module.exports = dgttrf;
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+
// MODULES //
22+
23+
var format = require( '@stdlib/string/format' );
24+
var base = require( './base.js' );
25+
26+
27+
// MAIN //
28+
29+
/**
30+
* Computes an LU factorization of a real tri diagonal matrix A using elimination with partial pivoting and row interchanges.
31+
*
32+
* @param {NonNegativeInteger} N - order of `A`
33+
* @param {Float64Array} DL - sub diagonal elements of `A`
34+
* @param {integer} strideDL - stride of the sub diagonal elements of `A`
35+
* @param {NonNegativeInteger} offsetDL - offset of the sub diagonal elements of `A`
36+
* @param {Float64Array} D - diagonal elements of `A`
37+
* @param {integer} strideD - stride of the diagonal elements of `A`
38+
* @param {NonNegativeInteger} offsetD - offset of the diagonal elements of `A`
39+
* @param {Float64Array} DU - diagonal elements of `A`
40+
* @param {integer} strideDU - stride of the first super diagonal elements of `A`
41+
* @param {NonNegativeInteger} offsetDU - offset of the first super diagonal elements of `A`
42+
* @param {Float64Array} DU2 - diagonal elements of `A`
43+
* @param {integer} strideDU2 - stride of the second super diagonal elements of `A`
44+
* @param {NonNegativeInteger} offsetDU2 - offset of the second super diagonal elements of `A`
45+
* @param {Int32Array} IPIV - vector of pivot indices
46+
* @param {integer} strideIPIV - `IPIV` stride length
47+
* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV`
48+
* @throws {RangeError} first argument must be a nonnegative integer
49+
* @returns {integer} status code
50+
*
51+
* @example
52+
* var Float64Array = require( '@stdlib/array/float64' );
53+
*
54+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
55+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
56+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
57+
* var DU2 = new Float64Array( [ 0.0 ] );
58+
* var IPIV = new Int32Array( [ 0, 1, 2 ] );
59+
*
60+
* dgttrf( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 );
61+
* // DL => <Float64Array>[ 0.5, 0.4 ]
62+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
63+
* // DU => <Float64Array>[ 1, 1 ]
64+
* // DU2 => <Float64Array>[ 0 ]
65+
*/
66+
function dgttrf( N, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, offsetDU, DU2, strideDU2, offsetDU2, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
67+
if ( N < 0 ) {
68+
throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) );
69+
}
70+
return base( N, DL, strideDL, offsetDL, D, strideD, offsetD, DU, strideDU, offsetDU, DU2, strideDU2, offsetDU2, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len
71+
}
72+
73+
74+
// EXPORTS //
75+
76+
module.exports = dgttrf;

0 commit comments

Comments
 (0)