Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
215 changes: 215 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlangt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
<!--

@license Apache-2.0

Copyright (c) 2026 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.

-->

# dlangt

> Return the value of the one-norm, Frobenius norm, infinity-norm, or the largest absolute value of any element of a real tridiagonal matrix.

<section class="usage">

## Usage

```javascript
var dlangt = require( '@stdlib/lapack/base/dlangt' );
```

#### dlangt( norm, N, DL, strideDL, D, strideD, DU, strideDU )

Returns the value of the specified norm of a real tridiagonal matrix `A`.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var DL = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0 ] );
var DU = new Float64Array( [ 1.0, 1.0, 1.0 ] );

var norm = dlangt( 'M', 4, DL, 1, D, 1, DU, 1 );
// returns 7.0
```

The function has the following parameters:

- **norm**: specifies the norm type (`'M'`/`'m'`: max norm, `'1'`/`'O'`/`'o'`: one norm, `'I'`/`'i'`: infinity norm, `'F'`/`'f'`/`'E'`/`'e'`: Frobenius norm).
- **N**: order of the matrix `A`. When `N = 0`, the function returns `0`.
- **DL**: [`Float64Array`][mdn-float64array] containing the `(N-1)` sub-diagonal elements.
- **strideDL**: stride length for `DL`.
- **D**: [`Float64Array`][mdn-float64array] containing the `N` diagonal elements.
- **strideD**: stride length for `D`.
- **DU**: [`Float64Array`][mdn-float64array] containing the `(N-1)` super-diagonal elements.
- **strideDU**: stride length for `DU`.

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

#### dlangt.ndarray( norm, N, DL, sdl, odl, D, sd, od, DU, sdu, odu )

Returns the value of the specified norm using alternative indexing semantics.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var DL = new Float64Array( [ 1.0, 2.0, 3.0 ] );
var D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0 ] );
var DU = new Float64Array( [ 1.0, 1.0, 1.0 ] );

var norm = dlangt.ndarray( 'M', 4, DL, 1, 0, D, 1, 0, DU, 1, 0 );
// returns 7.0
```

The function has the following additional parameters:

- **sdl**: stride length for `DL`.
- **odl**: starting index for `DL`.
- **sd**: stride length for `D`.
- **od**: starting index for `D`.
- **sdu**: stride length for `DU`.
- **odu**: starting index for `DU`.

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dlangt()` corresponds to the [LAPACK][LAPACK] function [`dlangt`][lapack-dlangt].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var dlangt = require( '@stdlib/lapack/base/dlangt' );

var DL = new Float64Array( [ 3.0, -2.0, 1.0, 4.0 ] );
var D = new Float64Array( [ -1.0, 5.0, -3.0, 2.0, 7.0 ] );
var DU = new Float64Array( [ 2.0, -1.0, 4.0, -3.0 ] );

console.log( 'Max norm:', dlangt( 'M', 5, DL, 1, D, 1, DU, 1 ) );
console.log( 'One norm:', dlangt( '1', 5, DL, 1, D, 1, DU, 1 ) );
console.log( 'Infinity norm:', dlangt( 'I', 5, DL, 1, D, 1, DU, 1 ) );
console.log( 'Frobenius norm:', dlangt( 'F', 5, DL, 1, D, 1, DU, 1 ) );
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
TODO
```

#### TODO

TODO.

```c
TODO
```

TODO

```c
TODO
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
TODO
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[lapack]: https://www.netlib.org/lapack/explore-html/

[lapack-dlangt]: https://netlib.org/lapack/explore-html/d5/d0e/group__langt.html

[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

</section>

<!-- /.links -->
109 changes: 109 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlangt/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var dlangt = require( './../lib/dlangt.js' );


// VARIABLES //

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


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - matrix order
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var DL;
var DU;
var D;

D = uniform( len, -100.0, 100.0, options );
DL = uniform( len - 1, -100.0, 100.0, options );
DU = uniform( len - 1, -100.0, 100.0, options );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var v;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = dlangt( 'M', len, DL, 1, D, 1, DU, 1 );
if ( isnan( v ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( v ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var max;
var min;
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( format( '%s:len=%d', pkg, len ), f );
}
}

main();
Loading