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
279 changes: 279 additions & 0 deletions lib/node_modules/@stdlib/blas/base/ztpmv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
<!--

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

-->

# ztpmv

> Perform one of the matrix-vector operations `x = A*x` or `x = A^T*x` or `x = A**H*x`.

<section class="usage">

## Usage

```javascript
var ztpmv = require( '@stdlib/blas/base/ztpmv' );
```

#### ztpmv( order, uplo, trans, diag, N, AP, x, sx )

Performs one of the matrix-vector operations `x = A*x` or `x = A**T*x` or `x = A**H*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix, supplied in packed form.


<!-- eslint-disable max-len -->

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var AP = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );

ztpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, x, 1 );
// x => <Complex128Array>[ 0.0, 2.0, 0.0, 20.0, 0.0, 62.0 ]
```

The function has the following parameters:

- **order**: storage layout.
- **uplo**: specifies whether `A` is an upper or lower triangular matrix.
- **trans**: specifies whether `A` should be transposed, conjugate-transposed, or not transposed.
- **diag**: specifies whether `A` has a unit diagonal.
- **N**: number of elements along each dimension of `A`.
- **AP**: input matrix in packed form stored in linear memory as a [`Complex128Array`][@stdlib/array/complex128].
- **x**: input vector [`Complex128Array`][@stdlib/array/complex128].
- **sx**: stride length for `x`.

The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x` in reverse order,

<!-- eslint-disable max-len -->

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var AP = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex128Array( [ 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0, 3.0 ] );

ztpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, x, 2 );
// x => <Complex128Array>[ 0.0, 2.0, 0.0, 0.0, 0.0, 20.0, 0.0, 0.0, 0.0, 62.0 ]
```

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

<!-- eslint-disable max-len -->

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );

// Initial arrays...
var x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );
var AP = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] );

// Create offset views...
var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd complex element

ztpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, x1, 1 );
// x1 => <Complex128Array>[ 0.0, 2.0, 0.0, 20.0, 0.0, 62.0 ]
```

<!-- lint disable maximum-heading-length -->

#### ztpmv.ndarray( order, uplo, trans, diag, N, AP, sap, oap, x, sx, ox )

Performs one of the matrix-vector operations `x = A*x` or `x = A**T*x` or `x = A**H*x`, using alternative indexing semantics and where `x` is an `N` element complex vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix, supplied in packed form.

<!-- eslint-disable max-len -->

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var AP = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );

ztpmv.ndarray( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, 1, 0, x, 1, 0 );
// x => <Complex128Array>[ 0.0, 2.0, 0.0, 20.0, 0.0, 62.0 ]
```

The function has the following additional parameters:

- **sap**: `AP` stride length
- **oap**: starting index for `AP`.
- **ox**: starting index for `x`.

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

<!-- eslint-disable max-len -->

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var AP = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] );
var x = new Complex128Array( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] );

ztpmv.ndarray( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, 1, 0, x, -1, 2 );
// x => <Complex128Array>[ 0.0, 62.0, 0.0, 20.0, 0.0, 2.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- `ztpmv()` corresponds to the [BLAS][blas] level 2 function [`ztpmv`][ztpmv].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

<!-- eslint-disable max-len -->

```javascript
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var filledarrayBy = require( '@stdlib/array/filled-by' );
var logEach = require( '@stdlib/console/log-each' );
var ztpmv = require( '@stdlib/blas/base/ztpmv' );

function rand() {
return new Complex128( discreteUniform( 0, 255 ), discreteUniform( -128, 127 ) );
}

var N = 5;

var AP = filledarrayBy( N*(N+1)/2, 'complex128', rand );
var x = filledarrayBy( N, 'complex128', rand );

ztpmv( 'column-major', 'lower', 'no-transpose', 'non-unit', N, AP, x, 1 );

// Print the results:
logEach( '%s', x );

ztpmv.ndarray( 'row-major', 'upper', 'transpose', 'unit', N, AP, 1, 0, x, 1, 0 );

// Print the results:
logEach( '%s', x );
```

</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">

[blas]: http://www.netlib.org/blas

[ztpmv]: https://netlib.org/lapack/explore-html/db/d62/group__tpmv_gacbf0ca8bf0b638cc1df58818ae8a5614.html

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

[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128

</section>

<!-- /.links -->
114 changes: 114 additions & 0 deletions lib/node_modules/@stdlib/blas/base/ztpmv/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* @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 isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pow = require( '@stdlib/math/base/special/pow' );
var floor = require( '@stdlib/math/base/special/floor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var ztpmv = require( './../lib/ztpmv.js' );


// VARIABLES //

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


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} N - array length
* @returns {Function} benchmark function
*/
function createBenchmark( N ) {
var APbuf;
var xbuf;
var AP;
var x;

xbuf = uniform( N*2, -100.0, 100.0, options );
x = new Complex128Array( xbuf.buffer );
APbuf = uniform( ( N * ( N + 1 ) / 2 ) * 2, -100.0, 100.0, options );
AP = new Complex128Array( APbuf.buffer );

return benchmark;

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

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = ztpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', N, AP, x, 1 );
if ( isnanf( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( z[ i%z.length ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

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

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

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

main();
Loading