Skip to content
Draft
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
239 changes: 239 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlansp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
<!--

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

-->

# dlansp

> Return the value of the one-norm, Frobenius norm, infinity-norm, or the largest absolute value of any element of a real symmetric matrix stored in packed form.

<section class="usage">

## Usage

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

#### dlansp( order, norm, uplo, N, AP )

Returns the value of the specified norm of a real symmetric matrix `A` stored in packed form `AP`.

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

// AP = [ 1.0, 2.0, 5.0 ] (2x2 symmetric packed column-major upper)
var AP = new Float64Array( [ 1.0, 2.0, 5.0 ] );

var v = dlansp( 'column-major', 'M', 'upper', 2, AP );
// returns 5.0
```

The function has the following parameters:

- **order**: storage layout (`'row-major'` or `'column-major'`).
- **norm**: specifies the norm type (`'M'`/`'m'`: max norm, `'1'`/`'O'`/`'o'`: one norm, `'I'`/`'i'`: infinity norm, `'F'`/`'f'`/`'E'`/`'e'`: Frobenius norm).
- **uplo**: specifies whether the upper or lower triangular part of `A` is supplied (`'upper'` or `'lower'`).
- **N**: order of the matrix `A`. When `N = 0`, the function returns `0`.
- **AP**: input [`Float64Array`][mdn-float64array] containing the symmetric matrix in packed form.

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

<!-- eslint-disable stdlib/capitalized-comments -->

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

// Initial array...
var AP0 = new Float64Array( [ 0.0, 1.0, 2.0, 5.0 ] );

// Create an offset view...
var AP1 = new Float64Array( AP0.buffer, AP0.BYTES_PER_ELEMENT*1 );

var v = dlansp( 'column-major', 'M', 'upper', 2, AP1 );
// returns 5.0
```

#### dlansp.ndarray( order, norm, uplo, N, AP, strideAP, offsetAP )

Returns the value of the specified norm of a real symmetric matrix `A` stored in packed form `AP` using alternative indexing semantics.

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

// AP = [ 1.0, 2.0, 5.0 ] (2x2 symmetric packed column-major upper)
var AP = new Float64Array( [ 1.0, 2.0, 5.0 ] );

var v = dlansp.ndarray( 'column-major', 'M', 'upper', 2, AP, 1, 0 );
// returns 5.0
```

The function has the following additional parameters:

- **strideAP**: stride length for `AP`.
- **offsetAP**: starting index for `AP`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on starting indices. For example,

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

var AP = new Float64Array( [ 0.0, 1.0, 2.0, 5.0 ] );

var v = dlansp.ndarray( 'column-major', 'M', 'upper', 2, AP, 1, 1 );
// returns 5.0
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `dlansp()` corresponds to the [LAPACK][lapack] routine [`dlansp`][lapack-dlansp].
- Since the matrix is symmetric, the one norm and infinity norm are equal.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var uniform = require( '@stdlib/random/array/discrete-uniform' );
var dlansp = require( '@stdlib/lapack/base/dlansp' );

var N = 4;
var AP = uniform( N * ( N + 1 ) / 2, -10, 10, {
'dtype': 'float64'
});
console.log( AP );

var v = dlansp( 'column-major', 'M', 'upper', N, AP );
console.log( 'Max norm: %d', v );

v = dlansp( 'column-major', '1', 'upper', N, AP );
console.log( 'One norm: %d', v );

v = dlansp( 'column-major', 'F', 'upper', N, AP );
console.log( 'Frobenius norm: %d', v );
```

</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]: http://www.netlib.org/lapack/

[lapack-dlansp]: http://www.netlib.org/lapack/explore-html/da/df5/group__lanhp_ga0e11da53350a7d0126a428d5842b8991.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 -->
104 changes: 104 additions & 0 deletions lib/node_modules/@stdlib/lapack/base/dlansp/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* @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 floor = require( '@stdlib/math/base/special/floor' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var dlansp = require( './../lib/dlansp.js' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} N - number of elements along each dimension
* @returns {Function} benchmark function
*/
function createBenchmark( N ) {
var opts;
var AP;

opts = {
'dtype': 'float64'
};

AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, opts );
return benchmark;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = dlansp( 'column-major', 'M', 'upper', N, AP );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

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

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

for ( i = min; i <= max; i++ ) {
N = floor( pow( pow( 10, i ), 1.0 / 2.0 ) );
f = createBenchmark( N );
bench( format( '%s:order=column-major,size=%d', pkg, N * ( N + 1 ) / 2 ), f );
}
}

main();
Loading