Skip to content

feat: add lapack/base/dgttrf #5754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e31c8b8
feat: add base algorithm
aayush0325 Mar 2, 2025
4686b1a
fix: remove redundant code
aayush0325 Mar 2, 2025
7bcf93c
feat: complete initial implementation for dgttrf
aayush0325 Mar 2, 2025
43f57ea
docs: add ts declaration file and test.ts
aayush0325 Mar 3, 2025
13e7f57
docs: update descriptions as per lapack documentation
aayush0325 Mar 3, 2025
10f32ed
test: add initial tests
aayush0325 Mar 3, 2025
87e755f
chore: update copyright years
stdlib-bot Mar 3, 2025
1e5ea18
docs: shorter var names and add repl.txt
aayush0325 Mar 3, 2025
e88ffbe
test: add tests for dgttrf
aayush0325 Mar 3, 2025
b1bed1b
test: add complete tests for dgttrf
aayush0325 Mar 3, 2025
6e908a9
test: add ndarray tests
aayush0325 Mar 3, 2025
95bd130
fix: resolve lint error
aayush0325 Mar 4, 2025
89b7e76
test: complete all tests
aayush0325 Mar 4, 2025
50e4a64
docs: write some docs
aayush0325 Mar 4, 2025
6ab337b
docs: complete writing readme
aayush0325 Mar 4, 2025
90450eb
chore: cleaning up
aayush0325 Mar 4, 2025
27be42f
docs: add comments in base algo for better understanding
aayush0325 Mar 4, 2025
2e6fb17
docs: add notes in docs
aayush0325 Mar 4, 2025
7b8da2e
test: generate fixtures
aayush0325 Mar 5, 2025
78e0cfd
Update lib/node_modules/@stdlib/lapack/base/dgttrf/README.md
aayush0325 Mar 17, 2025
fef9486
test: use deepEqual instead of isApprox
aayush0325 Mar 22, 2025
a4fb01d
chore: spelling check
aayush0325 Mar 28, 2025
f5f0213
refactor: precompute indices
aayush0325 Mar 31, 2025
996cc82
chore: spell check
aayush0325 Apr 5, 2025
5c80a24
chore: self review
aayush0325 Apr 5, 2025
0387183
docs: add decimals
aayush0325 May 7, 2025
42f9f66
refactor: update base implementation
aayush0325 May 10, 2025
7f1a1c7
refactor: undo precomputing indices because its not performant
aayush0325 May 11, 2025
ba24b53
refactor: base implementation refactoring
aayush0325 May 11, 2025
3dc7e61
docs: update docs
aayush0325 May 11, 2025
d8d37d5
docs: update docs
aayush0325 May 11, 2025
0a8a2b2
docs: update docs
aayush0325 May 11, 2025
f61525e
bench: update benchmark failing condition
aayush0325 May 11, 2025
f26929a
docs: show matrix A in examples
aayush0325 May 11, 2025
48f0218
fix: fix linting
aayush0325 May 11, 2025
a27401d
fix: fix linting
aayush0325 May 11, 2025
797e985
fix: fix linting
aayush0325 May 11, 2025
e9c57eb
docs: update examples
aayush0325 May 11, 2025
0e9a8c5
docs: add tex eqns
aayush0325 May 11, 2025
acd5a7c
test: add representation of A in fixtures
aayush0325 May 11, 2025
b56430e
docs: add eqn divs
aayush0325 May 14, 2025
d384b87
Merge remote-tracking branch 'upstream/develop' into lapack-dgttrf
stdlib-bot May 16, 2025
fb47065
chore: code revieww
aayush0325 May 22, 2025
b49b2f8
chore: cleanup
aayush0325 May 22, 2025
5f561b2
chore: update tex eqns
aayush0325 May 22, 2025
53141ba
docs: update eqn divs
aayush0325 May 23, 2025
7816100
chore: cleanup
aayush0325 May 23, 2025
0403253
chore: clean-up
kgryte Jun 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
436 changes: 436 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dgttrf/README.md

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dgttrf/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var pow = require( '@stdlib/math/base/special/pow' );
var Int32Array = require( '@stdlib/array/int32' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dgttrf = require( './../lib/dgttrf.js' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var IPIV = new Int32Array( len );
var DU2 = new Float64Array( len-2 );
var DL = uniform( len-1, 0.0, 100.0, options );
var DU = uniform( len-1, 0.0, 100.0, options );
var D = uniform( len, 0.0, 100.0, options );
return benchmark;

function benchmark( b ) {
var d;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
d = dgttrf( len, DL, D, DU, DU2, IPIV );
if ( d < 0 ) {
b.fail( 'should return a success status code' );
}
}
b.toc();
if ( d < 0 ) {
b.fail( 'should return a success status code' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':len='+len, f );
}
}

main();
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var pow = require( '@stdlib/math/base/special/pow' );
var Int32Array = require( '@stdlib/array/int32' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dgttrf = require( './../lib/ndarray.js' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var IPIV = new Int32Array( len );
var DU2 = new Float64Array( len-2 );
var DL = uniform( len-1, 0.0, 100.0, options );
var DU = uniform( len-1, 0.0, 100.0, options );
var D = uniform( len, 0.0, 100.0, options );
return benchmark;

function benchmark( b ) {
var d;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
d = dgttrf( len, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 ); // eslint-disable-line max-len
if ( d < 0 ) {
b.fail( 'should return a success status code' );
}
}
b.toc();
if ( d < 0 ) {
b.fail( 'should return a success status code' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':ndarray:len='+len, f );
}
}

main();
195 changes: 195 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dgttrf/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@

{{alias}}( N, DL, D, DU, DU2, IPIV )
Computes an LU factorization of a real tridiagonal matrix `A` using
elimination with partial pivoting and row interchanges.

Indexing is relative to the first index. To introduce an offset, use typed
array views.

The function mutates `DL`, `D`, `DU`, `DU2`, and `IPIV`.

Parameters
----------
N: integer
Number of rows/columns in `A`.

DL: Float64Array
The first sub diagonal of `A`. Should have `N-1` indexed elements. `DL`
is overwritten by the multipliers that define the matrix `L` from the LU
factorization of `A`.

D: Float64Array
The diagonal of `A`. Should have `N` indexed elements. `D` is
overwritten by the diagonal elements of the upper triangular matrix `U`
from the LU factorization of `A`.

DU: Float64Array
The first super-diagonal of `A`. Should have `N-1` indexed elements.
`DU` is overwritten by the elements of the first super-diagonal of `U`.

DU2: Float64Array
The second super-diagonal of `U`. Should have `N-2` indexed elements.
`DU2` is overwritten by the elements of the second super-diagonal of
`U`.

IPIV: Int32Array
Vector of pivot indices. Should have `N` indexed elements.

Returns
-------
info: integer
Status code. The status code indicates the following conditions:

- if equal to zero, then the factorization was successful.
- if greater than zero, then `U(k, k)` is exactly zero the factorization
has been completed, but the factor `U` is exactly singular, and division
by zero will occur if it is used to solve a system of equations where
`k = StatusCode`.

Examples
--------
> var DL = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var D = new {{alias:@stdlib/array/float64}}( [ 2.0, 3.0, 1.0 ] );
> var DU = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var DU2 = new {{alias:@stdlib/array/float64}}( 1 );
> var IPIV = new {{alias:@stdlib/array/int32}}( 3 );
> {{alias}}( 3, DL, D, DU, DU2, IPIV )
0
> DL
<Float64Array>[ 0.5, 0.4 ]
> D
<Float64Array>[ 2.0, 2.5, 0.6 ]
> DU
<Float64Array>[ 1.0, 1.0 ]
> DU2
<Float64Array>[ 0.0 ]
> IPIV
<Int32Array>[ 0, 1, 2 ]

// Using typed array views:
> var DL0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] );
> var D0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 2.0, 3.0, 1.0 ] );
> var DU0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] );
> var DU20 = new {{alias:@stdlib/array/float64}}( 2 );
> var IPIV0 = new {{alias:@stdlib/array/int32}}( 4 );
> DL = new Float64Array( DL0.buffer, DL0.BYTES_PER_ELEMENT*1 );
> D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 );
> DU = new Float64Array( DU0.buffer, DU0.BYTES_PER_ELEMENT*1 );
> DU2 = new Float64Array( DU20.buffer, DU20.BYTES_PER_ELEMENT*1 );
> IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 );
> {{alias}}( 3, DL, D, DU, DU2, IPIV )
0
> DL0
<Float64Array>[ 0.0, 0.5, 0.4 ]
> D0
<Float64Array>[ 0.0, 2.0, 2.5, 0.6 ]
> DU0
<Float64Array>[ 0.0, 1.0, 1.0 ]
> DU20
<Float64Array>[ 0.0, 0.0 ]
> IPIV0
<Int32Array>[ 0, 0, 1, 2 ]


{{alias}}.ndarray(N, DL,sdl,odl, D,sd,od, DU,sdu,odu, DU2,sdu2,odu2, IPIV,si,oi)
Computes an LU factorization of a real tridiagonal matrix `A` using
elimination with partial pivoting and row interchanges and alternative
indexing semantics.

While typed array views mandate a view offset based on the underlying
buffer, the offset parameters support indexing semantics based on starting
indices.

The function mutates `DL`, `D`, `DU`, `DU2`, and `IPIV`.

Parameters
----------
N: integer
Number of rows/columns in `A`.

DL: Float64Array
The first sub diagonal of `A`. Should have `N-1` indexed elements. `DL`
is overwritten by the multipliers that define the matrix `L` from the LU
factorization of `A`.

sdl: integer
Stride length for `DL`.

odl: integer
Starting index for `DL`.

D: Float64Array
The diagonal of `A`. Should have `N` indexed elements. `D` is
overwritten by the diagonal elements of the upper triangular matrix `U`
from the LU factorization of `A`.

sd: integer
Stride length for `D`.

od: integer
Starting index for `D`.

DU: Float64Array
The first super-diagonal of `A`. Should have `N-1` indexed elements.
`DU` is overwritten by the elements of the first super-diagonal of `U`.

sdu: integer
Stride length for `DU`.

odu: integer
Starting index for `DU2`.

DU2: Float64Array
The second super-diagonal of `U`. Should have `N-2` indexed elements.
`DU2` is overwritten by the elements of the second super-diagonal of
`U`.

sdu2: integer
Stride length for `DU2`.

odu2: integer
Starting index for `DU2`.

IPIV: Int32Array
Vector of pivot indices. Should have `N` indexed elements.

si: integer
Stride length for `IPIV`.

oi: integer
Starting index for `IPIV`.

Returns
-------
info: integer
Status code. The status code indicates the following conditions:

- if equal to zero, then the factorization was successful.
- if greater than zero, then `U(k, k)` is exactly zero the factorization
has been completed, but the factor `U` is exactly singular, and division
by zero will occur if it is used to solve a system of equations where
`k = StatusCode`.

Examples
--------
> var DL = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var D = new {{alias:@stdlib/array/float64}}( [ 2.0, 3.0, 1.0 ] );
> var DU = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
> var DU2 = new {{alias:@stdlib/array/float64}}( 1 );
> var IPIV = new {{alias:@stdlib/array/int32}}( 3 );
> {{alias}}.ndarray( 3, DL, 1, 0, D, 1, 0, DU, 1, 0, DU2, 1, 0, IPIV, 1, 0 )
0
> DL
<Float64Array>[ 0.5, 0.4 ]
> D
<Float64Array>[ 2.0, 2.5, 0.6 ]
> DU
<Float64Array>[ 1.0, 1.0 ]
> DU2
<Float64Array>[ 0.0 ]
> IPIV
<Int32Array>[ 0, 1, 2 ]

See Also
--------

Loading