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
51 changes: 51 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlantr/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
This package adapts the DLANTR algorithm and interface from LAPACK.
Reference: https://github.com/Reference-LAPACK/lapack/blob/master/SRC/dlantr.f

Copyright (c) 1992-2025 The University of Tennessee and The University
of Tennessee Research Foundation. All rights
reserved.
Copyright (c) 2000-2025 The University of California Berkeley. All
rights reserved.
Copyright (c) 2006-2025 The University of Colorado Denver. All rights
reserved.

$COPYRIGHT$

Additional copyrights may follow

$HEADER$

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer listed
in this license in the documentation and/or other materials
provided with the distribution.

- Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

The copyright holders provide no reassurances that the source code
provided does not infringe any patent, copyright, or any other
intellectual property rights of third parties. The copyright holders
disclaim any liability to any recipient for claims brought against
recipient by any third party for infringement of that parties
intellectual property rights.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
231 changes: 231 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlantr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<!--

@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.

-->

# dlantr

> Compute a norm of a double-precision triangular or trapezoidal matrix.

<section class="usage">

## Usage

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

#### dlantr( order, norm, uplo, diag, M, N, A, LDA, work )

Computes a norm of an `M` by `N` triangular or trapezoidal matrix `A`.

- `order`: storage layout, either `'row-major'` or `'column-major'` (or the corresponding BLAS enumeration).
- `norm`: `'max'` for the largest absolute entry, `'one'` for the maximum column sum, `'infinity'` for the maximum row sum, or `'frobenius'` for the square root of the sum of squared entries.
- `uplo`: either `'upper'` or `'lower'` (or the corresponding BLAS enumeration).
- `diag`: either `'unit'` or `'non-unit'` (or the corresponding BLAS enumeration).
- `M`, `N`: nonnegative integer dimensions. Upper trapezoidal matrices require `M <= N`; lower trapezoidal matrices require `N <= M`.
- `A`: a `Float64Array` containing the rectangular matrix storage, including the unused triangle.
- `LDA`: leading dimension, at least `max(1,N)` for row-major storage or `max(1,M)` for column-major storage.
- `work`: scratch `Float64Array` with at least `M` elements for the infinity norm. Other norms do not reference workspace storage.

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

var A = new Float64Array( [ 2.0, -3.0, 4.0, NaN, 5.0, -6.0 ] );
var work = new Float64Array( 2 );

var v = dlantr( 'row-major', 'max', 'upper', 'non-unit', 2, 3, A, 3, work );
// returns 6.0

v = dlantr( 'row-major', 'one', 'upper', 'non-unit', 2, 3, A, 3, work );
// returns 10.0

v = dlantr( 'row-major', 'infinity', 'upper', 'non-unit', 2, 3, A, 3, work );
// returns 11.0

v = dlantr( 'row-major', 'frobenius', 'upper', 'non-unit', 2, 3, A, 3, work );
// returns ~9.487
```

When `diag` is `'unit'`, diagonal elements are implicitly one and are never read from `A`. The opposite triangle and storage padding are also not referenced.

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

var A = new Float64Array( [ NaN, -3.0, 4.0, NaN, NaN, -6.0 ] );
var work = new Float64Array( 2 );

var v = dlantr( 'row-major', 'infinity', 'upper', 'unit', 2, 3, A, 3, work );
// returns 8.0
```

The function throws an error for invalid options, dimensions, leading dimensions, matrix storage, or required workspace storage.

#### dlantr.ndarray( norm, uplo, diag, M, N, A, sa1, sa2, oa, work, sw, ow )

Computes a matrix norm using alternative indexing semantics. `strideA1` and `strideA2` are row and column strides, and `offsetA` is the index of the first logical matrix element. Matrix strides may be positive, negative, or zero. For the infinity norm, `strideWork` must be a nonzero integer and `offsetWork` must locate sufficient workspace entries.

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

var A = new Float64Array( [ -6.0, 5.0, NaN, 4.0, -3.0, 2.0 ] );
var work = new Float64Array( [ 0.0, 0.0 ] );

var v = dlantr.ndarray( 'infinity', 'upper', 'non-unit', 2, 3, A, -3, -1, 5, work, -1, 1 );
// returns 11.0
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- The matrix is not mutated. For the infinity norm, only the `M` indexed workspace entries are overwritten; workspace must not overlap the referenced input matrix storage.
- If `M` or `N` is zero, the function returns positive zero without accessing either array.
- Non-infinity norms ignore workspace storage and its indexing metadata. An empty workspace array is sufficient.
- A referenced `NaN` propagates to the result, including when other entries are infinite. Unreferenced `NaN` values do not affect the result.
- Frobenius accumulation uses scaled sums of squares to avoid unnecessary overflow and underflow. An infinite referenced entry yields infinity unless a referenced `NaN` is present.
- The JavaScript interface accepts only the four documented norm names. The C interface accepts LAPACK character aliases, as documented below.
- Test fixtures were generated independently using SciPy 1.17.0 and LAPACK. To regenerate their expected norms from the stored input matrices, run `python3 test/fixtures/scipy/runner.py` from this package directory with NumPy and SciPy installed.
- Input storage must contain the full indexed rectangular view. The function does not read the ignored triangle or unit diagonal, but bounds validation still covers the rectangular view.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

var A = new Float64Array( [ 1.0e300, 0.0, NaN, 1.0e300 ] );
var work = new Float64Array( 0 );

var v = dlantr( 'row-major', 'frobenius', 'upper', 'non-unit', 2, 2, A, 2, work );
console.log( v );
// => ~1.414e300
```

</section>

<!-- /.examples -->

<!-- C APIs -->

<section class="c">

## C APIs

<section class="usage">

### Usage

```c
#include "stdlib/lapack/base/dlantr.h"
```

#### c_dlantr( layout, norm, uplo, diag, M, N, A, LDA, work )

Computes a triangular or trapezoidal matrix norm. `layout`, `uplo`, and `diag` are the corresponding `LAPACK_LAYOUT`, `LAPACK_UPLO`, and `LAPACK_DIAGONAL` enumerations. Dimensions and indices use `LAPACK_INT`.

`norm` accepts the following case-insensitive LAPACK characters:

- `'M'`: largest absolute entry.
- `'1'` or `'O'`: maximum column sum.
- `'I'`: maximum row sum.
- `'F'` or `'E'`: Frobenius norm.

```c
const double A[] = { 2.0, -3.0, 4.0, 0.0, 5.0, -6.0 };
double work[ 2 ];

double v = c_dlantr( LAPACK_ROW_MAJOR, 'I', LAPACK_UPPER_TRIANGLE, LAPACK_NON_UNIT_DIAGONAL, 2, 3, A, 3, work );
```

The leading dimension and trapezoidal dimension constraints match the JavaScript interface. Workspace must provide `M` elements for the infinity norm, must not overlap input storage, and may be `NULL` for other norms. Invalid options or dimensions yield `NaN`. The caller must supply valid indexed storage.

#### c_dlantr_ndarray( norm, uplo, diag, M, N, A, sa1, sa2, oa, work, sw, ow )

Computes a matrix norm using alternative indexing semantics. Strides and offsets are in elements. For the infinity norm, workspace entries must be distinct and `strideWork` must be nonzero. Other norms do not reference workspace storage or its indices.

```c
const double A[] = { -6.0, 5.0, 0.0, 4.0, -3.0, 2.0 };
double work[ 2 ];

double v = c_dlantr_ndarray( 'I', LAPACK_UPPER_TRIANGLE, LAPACK_NON_UNIT_DIAGONAL, 2, 3, A, -3, -1, 5, work, -1, 1 );
```

</section>

<!-- /.usage -->

<section class="examples">

### Examples

```c
#include "stdlib/lapack/base/dlantr.h"
#include <stdio.h>

int main( void ) {
const double A[] = { 2.0, -3.0, 4.0, 0.0, 5.0, -6.0 };
double work[ 2 ];
double v = c_dlantr( LAPACK_ROW_MAJOR, 'I', LAPACK_UPPER_TRIANGLE, LAPACK_NON_UNIT_DIAGONAL, 2, 3, A, 3, work );
printf( "%f\n", v );
return 0;
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<section class="references">

## References

- LAPACK. "DLANTR." [Reference-LAPACK][lapack-dlantr]. Adaptation provenance and the LAPACK redistribution terms are retained in the accompanying `NOTICE`.

</section>

<!-- /.references -->


<section class="related">

</section>

<!-- /.related -->

<section class="links">

[lapack-dlantr]: https://github.com/Reference-LAPACK/lapack/blob/master/SRC/dlantr.f

</section>

<!-- /.links -->
94 changes: 94 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlantr/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @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 Float64Array = require( '@stdlib/array/float64' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var dlantr = require( './../lib/main.js' );


// VARIABLES //

var sizes = [ 10, 100 ];
var norms = [ 'max', 'one', 'infinity', 'frobenius' ];
var i;
var j;


// FUNCTIONS //

/**
* Creates a matrix norm benchmark.
*
* @private
* @param {PositiveInteger} N - matrix dimension
* @param {string} norm - norm type
* @returns {Function} benchmark function
*/
function createBenchmark( N, norm ) {
var work;
var A;
var i;

A = new Float64Array( N*N );
work = new Float64Array( N );
for ( i = 0; i < A.length; i++ ) {
A[i] = (i%19) - 9;
}
return benchmark;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = dlantr( 'row-major', norm, 'upper', 'non-unit', N, N, A, N, work );
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

for ( i = 0; i < sizes.length; i++ ) {
for ( j = 0; j < norms.length; j++ ) {
bench( format( '%s::norm=%s,N=%d', pkg, norms[j], sizes[i] ), createBenchmark( sizes[i], norms[j] ) );
}
}
Loading
Loading