Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a08a9e4
add license
DivitJain26 Apr 9, 2026
550593f
test: add branch 1 fixtures
DivitJain26 Apr 10, 2026
5afed2b
feat: add branch 1 logic in base.js
DivitJain26 Apr 10, 2026
b9d31fa
feat: add branch 2 logic in base.js
DivitJain26 Apr 10, 2026
4a060f3
test: add branch 2 fixtures
DivitJain26 Apr 10, 2026
97965ed
feat: add branch 2 logic in base.js
DivitJain26 Apr 10, 2026
c057b66
feat: add branch 3 logic in base.js
DivitJain26 Apr 10, 2026
b1b38aa
test: add branch 3 fixtures
DivitJain26 Apr 10, 2026
993b4e6
feat: add branch 4 logic in base.js
DivitJain26 Apr 10, 2026
0995395
test: add branch 4 fixtures
DivitJain26 Apr 10, 2026
cc7283a
chore: add package.json
DivitJain26 Apr 10, 2026
029620e
feat: add wappers and entry point
DivitJain26 Apr 11, 2026
a895d02
test: add conjuate transpose fixtures
DivitJain26 Apr 11, 2026
b71516b
test: add vector offset fixtures
DivitJain26 Apr 11, 2026
479ea07
test: add vector stride specific fixtures
DivitJain26 Apr 11, 2026
8a5ba72
test: add AP offset fixtures
DivitJain26 Apr 11, 2026
ce663a6
test: add AP stride specific fixtures
DivitJain26 Apr 11, 2026
2f56e6c
test: add complex access pattern fixtures
DivitJain26 Apr 11, 2026
1c245cb
test: add test suites
DivitJain26 Apr 11, 2026
5b7d50d
refactor: remove unutilised conditions
DivitJain26 Apr 11, 2026
d903f03
docs: add types and test
DivitJain26 Apr 11, 2026
262b819
docs: add repl file
DivitJain26 Apr 11, 2026
50a151f
docs: add example
DivitJain26 Apr 11, 2026
e7c6415
bench: add benchmarks
DivitJain26 Apr 11, 2026
650c260
docs: add readme file
DivitJain26 Apr 11, 2026
8eab5bd
Merge branch 'develop' into blas/base/ctpmv
DivitJain26 Apr 11, 2026
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
267 changes: 267 additions & 0 deletions lib/node_modules/@stdlib/blas/base/ctpmv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
<!--

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

-->

# ctpmv

> Perform one of the matrix-vector operations `x = A*x` or `x = A^T*x`, or `x = A**H*x` for complex-valued data.

<section class="usage">

## Usage

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

#### ctpmv( 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 complex vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular complex matrix, supplied in packed form.


```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var AP = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] ); // eslint-disable-line max-params, max-len
var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );

ctpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, x, 1 );
// x => <Complex64Array>[ 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**: Complex input matrix in packed form stored in linear memory as a [`Complex64Array`][@stdlib/array/complex64].
- **x**: complex input vector [`Complex64Array`][@stdlib/array/complex64].
- **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,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var AP = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] ); // eslint-disable-line max-params, max-len
var x = new Complex64Array( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] );

ctpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, x, -1 );
// x => <Complex64Array>[ 0.0, 62.0, 0.0, 20.0, 0.0, 2.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 -->

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

// Initial arrays...
var x0 = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );
var AP = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] ); // eslint-disable-line max-params, max-len

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

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

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

#### ctpmv.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 complex matrix, supplied in packed form.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var AP = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] ); // eslint-disable-line max-params, max-len
var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); // eslint-disable-line max-params, max-len

ctpmv.ndarray( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, 1, 0, x, 1, 0 ); // eslint-disable-line max-params, max-len
// x => <Complex64Array>[ 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,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var AP = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0 ] ); // eslint-disable-line max-params, max-len
var x = new Complex64Array( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] );

ctpmv.ndarray( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, 1, 0, x, -1, 2 ); // eslint-disable-line max-params, max-len
// x => <Complex64Array>[ 0.0, 62.0, 0.0, 20.0, 0.0, 2.0 ]
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

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

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

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

function rand() {
return new Complex64( discreteUniform( 0, 255 ), discreteUniform( -128, 127 ) ); // eslint-disable-line max-params, max-len
}

var N = 5;

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

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

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

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

[ctpmv]: https://www.netlib.org/lapack/explore-html/db/d62/group__tpmv_ga335745d930cd7eb4003c95dd3a9121bd.html#ga335745d930cd7eb4003c95dd3a9121bd

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

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

</section>

<!-- /.links -->
114 changes: 114 additions & 0 deletions lib/node_modules/@stdlib/blas/base/ctpmv/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 Complex64Array = require( '@stdlib/array/complex64' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var ctpmv = require( './../lib/ctpmv.js' );


// VARIABLES //

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


// 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 Complex64Array( xbuf.buffer );
APbuf = uniform( (N*(N+1)/2)*2, -100.0, 100.0, options );
AP = new Complex64Array( 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 = ctpmv( '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