Skip to content

Commit 43f57ea

Browse files
committed
docs: add ts declaration file and test.ts
--- 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: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 7bcf93c commit 43f57ea

File tree

10 files changed

+969
-12
lines changed

10 files changed

+969
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var Int32Array = require( '@stdlib/array/int32' );
28+
var Float64Array = require( '@stdlib/array/float64' );
29+
var pkg = require( './../package.json' ).name;
30+
var dgttrf = require( './../lib/dgttrf.js' );
31+
32+
33+
// VARIABLES //
34+
35+
var options = {
36+
'dtype': 'float64'
37+
};
38+
39+
40+
// FUNCTIONS //
41+
42+
/**
43+
* Creates a benchmark function.
44+
*
45+
* @private
46+
* @param {PositiveInteger} len - array length
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( len ) {
50+
var IPIV = new Int32Array( len );
51+
var DU2 = new Float64Array( len-2 );
52+
var DL = uniform( len-1, 0.0, 100.0, options );
53+
var DU = uniform( len-1, 0.0, 100.0, options );
54+
var D = uniform( len, 0.0, 100.0, options );
55+
return benchmark;
56+
57+
function benchmark( b ) {
58+
var d;
59+
var i;
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
d = dgttrf( len, DL, D, DU, DU2, IPIV );
64+
if ( isnan( d ) ) {
65+
b.fail( 'should not return NaN' );
66+
}
67+
}
68+
b.toc();
69+
if ( isnan( d ) ) {
70+
b.fail( 'should not return NaN' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
}
75+
}
76+
77+
78+
// MAIN //
79+
80+
/**
81+
* Main execution sequence.
82+
*
83+
* @private
84+
*/
85+
function main() {
86+
var len;
87+
var min;
88+
var max;
89+
var f;
90+
var i;
91+
92+
min = 1; // 10^min
93+
max = 6; // 10^max
94+
95+
for ( i = min; i <= max; i++ ) {
96+
len = pow( 10, i );
97+
f = createBenchmark( len );
98+
bench( pkg+':len='+len, f );
99+
}
100+
}
101+
102+
main();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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 bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var pow = require( '@stdlib/math/base/special/pow' );
27+
var Int32Array = require( '@stdlib/array/int32' );
28+
var Float64Array = require( '@stdlib/array/float64' );
29+
var pkg = require( './../package.json' ).name;
30+
var dgttrf = require( './../lib/ndarray.js' );
31+
32+
33+
// VARIABLES //
34+
35+
var options = {
36+
'dtype': 'float64'
37+
};
38+
39+
40+
// FUNCTIONS //
41+
42+
/**
43+
* Creates a benchmark function.
44+
*
45+
* @private
46+
* @param {PositiveInteger} len - array length
47+
* @returns {Function} benchmark function
48+
*/
49+
function createBenchmark( len ) {
50+
var IPIV = new Int32Array( len );
51+
var DU2 = new Float64Array( len-2 );
52+
var DL = uniform( len-1, 0.0, 100.0, options );
53+
var DU = uniform( len-1, 0.0, 100.0, options );
54+
var D = uniform( len, 0.0, 100.0, options );
55+
return benchmark;
56+
57+
function benchmark( b ) {
58+
var d;
59+
var i;
60+
61+
b.tic();
62+
for ( i = 0; i < b.iterations; i++ ) {
63+
d = dgttrf( len, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // eslint-disable-line max-len
64+
if ( isnan( d ) ) {
65+
b.fail( 'should not return NaN' );
66+
}
67+
}
68+
b.toc();
69+
if ( isnan( d ) ) {
70+
b.fail( 'should not return NaN' );
71+
}
72+
b.pass( 'benchmark finished' );
73+
b.end();
74+
}
75+
}
76+
77+
78+
// MAIN //
79+
80+
/**
81+
* Main execution sequence.
82+
*
83+
* @private
84+
*/
85+
function main() {
86+
var len;
87+
var min;
88+
var max;
89+
var f;
90+
var i;
91+
92+
min = 1; // 10^min
93+
max = 6; // 10^max
94+
95+
for ( i = min; i <= max; i++ ) {
96+
len = pow( 10, i );
97+
f = createBenchmark( len );
98+
bench( pkg+':len='+len, f );
99+
}
100+
}
101+
102+
main();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Status code.
23+
*
24+
* ## Notes
25+
*
26+
* The status code indicates the following conditions:
27+
*
28+
* - if equal to zero, then the factorization was successful.
29+
* - if less than zero, then the k-th argument had an illegal value, where `k = -StatusCode`.
30+
* - if greater than zero, then the leading principal minor of order `k` is not positive, where `k = StatusCode`. If `k < N`, then the factorization could not be completed. If `k = N`, then the factorization was completed, but `D(N) <= 0`, meaning that the matrix `A` is not positive definite.
31+
*/
32+
type StatusCode = number;
33+
34+
/**
35+
* Interface describing `dgttrf`.
36+
*/
37+
interface Routine {
38+
/**
39+
* Computes an LU factorization of a real tri diagonal matrix A using elimination with partial pivoting and row interchanges.
40+
*
41+
* @param N - order of matrix `A`
42+
* @param DL - the `N-1` subdiagonal elements of `A`
43+
* @param D - the `N` diagonal elements of `A`
44+
* @param DU - the `N-1` superdiagonal elements of `A`
45+
* @param DU2 - the `N-2` elements of the second superdiagonal of `A`
46+
* @param IPIV - vector of pivot indices
47+
* @returns status code
48+
*
49+
* @example
50+
* var Float64Array = require( '@stdlib/array/float64' );
51+
* var Int32Array = require( '@stdlib/array/int32' );
52+
*
53+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
54+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
55+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
56+
* var DU2 = new Float64Array( 1 );
57+
* var IPIV = new Int32Array( 3 );
58+
*
59+
* dgttrf( 3, DL, D, DU, DU2, IPIV );
60+
* // DL => <Float64Array>[ 0.5, 0.4 ]
61+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
62+
* // DU => <Float64Array>[ 1, 1 ]
63+
* // DU2 => <Float64Array>[ 0 ]
64+
*/
65+
( N: number, DL: Float64Array, D: Float64Array, DU: Float64Array, DU2: Float64Array, IPIV: Int32Array ): StatusCode;
66+
67+
/**
68+
* Computes an LU factorization of a real tri diagonal matrix A using elimination with partial pivoting and row interchanges and alternative indexing semantics.
69+
*
70+
* @param N - order of matrix `A`
71+
* @param DL - the `N-1` subdiagonal elements of `A`
72+
* @param strideDL - stride of the subdiagonal elements of `A`
73+
* @param offsetDL - offset of the subdiagonal elements of `A`
74+
* @param D - the `N` diagonal elements of `A`
75+
* @param strideD - stride of the diagonal elements of `A`
76+
* @param offsetD - offset of the diagonal elements of `A`
77+
* @param DU - the `N-1` superdiagonal elements of `A`
78+
* @param strideDU - stride of the first superdiagonal elements of `A`
79+
* @param offsetDU - offset of the first superdiagonal elements of `A`
80+
* @param DU2 - the `N-2` elements of the second superdiagonal of `A`
81+
* @param strideDU2 - stride of the second superdiagonal elements of `A`
82+
* @param offsetDU2 - offset of the second superdiagonal elements of `A`
83+
* @param IPIV - vector of pivot indices
84+
* @param strideIPIV - `IPIV` stride length
85+
* @param offsetIPIV - index offset for `IPIV`
86+
* @returns status code
87+
*
88+
* @example
89+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
90+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
91+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
92+
* var DU2 = new Float64Array( 1 );
93+
* var IPIV = new Int32Array( 3 );
94+
*
95+
* dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 );
96+
* // DL => <Float64Array>[ 0.5, 0.4 ]
97+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
98+
* // DU => <Float64Array>[ 1, 1 ]
99+
* // DU2 => <Float64Array>[ 0 ]
100+
*/
101+
ndarray( N: number, DL: Float64Array, strideDL: number, offsetDL: number, D: Float64Array, strideD: number, offsetD: number, DU: Float64Array, strideDU: number, offsetDU: number, DU2: Float64Array, strideDU2: number, offsetDU2: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): StatusCode;
102+
}
103+
104+
/**
105+
* LAPACK routine to compute an LU factorization of a real tri diagonal matrix A using elimination with partial pivoting and row interchanges.
106+
*
107+
* @param N - order of matrix `A`
108+
* @param DL - the `N-1` subdiagonal elements of `A`
109+
* @param D - the `N` diagonal elements of `A`
110+
* @param DU - the `N-1` superdiagonal elements of `A`
111+
* @param DU2 - the `N-2` elements of the second superdiagonal of `A`
112+
* @param IPIV - vector of pivot indices
113+
* @returns status code
114+
*
115+
* @example
116+
* var Float64Array = require( '@stdlib/array/float64' );
117+
* var Int32Array = require( '@stdlib/array/int32' );
118+
*
119+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
120+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
121+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
122+
* var DU2 = new Float64Array( 1 );
123+
* var IPIV = new Int32Array( 3 );
124+
*
125+
* dgttrf( 3, DL, D, DU, DU2, IPIV );
126+
* // DL => <Float64Array>[ 0.5, 0.4 ]
127+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
128+
* // DU => <Float64Array>[ 1, 1 ]
129+
* // DU2 => <Float64Array>[ 0 ]
130+
*
131+
* @example
132+
* var Float64Array = require( '@stdlib/array/float64' );
133+
* var Int32Array = require( '@stdlib/array/int32' );
134+
*
135+
* var DL = new Float64Array( [ 1.0, 1.0 ] );
136+
* var D = new Float64Array( [ 2.0, 3.0, 1.0 ] );
137+
* var DU = new Float64Array( [ 1.0, 1.0 ] );
138+
* var DU2 = new Float64Array( 1 );
139+
* var IPIV = new Int32Array( 3 );
140+
*
141+
* dgttrf.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 );
142+
* // DL => <Float64Array>[ 0.5, 0.4 ]
143+
* // D => <Float64Array>[ 2, 2.5, 0.6 ]
144+
* // DU => <Float64Array>[ 1, 1 ]
145+
* // DU2 => <Float64Array>[ 0 ]
146+
*/
147+
declare var dgttrf: Routine;
148+
149+
150+
// EXPORTS //
151+
152+
export = dgttrf;

0 commit comments

Comments
 (0)