|
| 1 | +/** |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2026 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +'use strict'; |
| 20 | + |
| 21 | +// MODULES // |
| 22 | + |
| 23 | +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); |
| 24 | +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); |
| 25 | +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); |
| 26 | +var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' ); |
| 27 | +var format = require( '@stdlib/string/format' ); |
| 28 | +var base = require( './base.js' ); |
| 29 | + |
| 30 | + |
| 31 | +// MAIN // |
| 32 | + |
| 33 | +/** |
| 34 | +* 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. |
| 35 | +* |
| 36 | +* @param {string} order - storage layout |
| 37 | +* @param {string} uplo - specifies whether `A` is an upper or lower triangular matrix |
| 38 | +* @param {string} trans - specifies whether `A` should be transposed, conjugate-transposed, or not transposed |
| 39 | +* @param {string} diag - specifies whether `A` has a unit diagonal |
| 40 | +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` |
| 41 | +* @param {Complex64Array} AP - packed form of a symmetric matrix `A` |
| 42 | +* @param {integer} strideAP - `AP` stride length |
| 43 | +* @param {NonNegativeInteger} offsetAP - starting index for `AP` |
| 44 | +* @param {Complex64Array} x - input vector |
| 45 | +* @param {integer} strideX - `x` stride length |
| 46 | +* @param {NonNegativeInteger} offsetX - starting index for `x` |
| 47 | +* @throws {TypeError} first argument must be a valid order |
| 48 | +* @throws {TypeError} second argument must specify whether a lower or upper triangular matrix is supplied |
| 49 | +* @throws {TypeError} third argument must be a valid transpose operation |
| 50 | +* @throws {TypeError} fourth argument must be a valid diagonal type |
| 51 | +* @throws {RangeError} fifth argument must be a nonnegative integer |
| 52 | +* @throws {RangeError} seventh argument must be non-zero |
| 53 | +* @throws {RangeError} tenth argument must be non-zero |
| 54 | +* @returns {Complex64Array} `x` |
| 55 | +* |
| 56 | +* @example |
| 57 | +* var Complex64Array = require( '@stdlib/array/complex64' ); |
| 58 | +* |
| 59 | +* 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 ] ); |
| 60 | +* var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); |
| 61 | +* |
| 62 | +* ctpmv( 'row-major', 'lower', 'no-transpose', 'non-unit', 3, AP, 1, 0, x, 1, 0 ); |
| 63 | +* // x => <Complex64Array>[ 0.0, 2.0, 0.0, 20.0, 0.0, 62.0 ] |
| 64 | +*/ |
| 65 | +function ctpmv( order, uplo, trans, diag, N, AP, strideAP, offsetAP, x, strideX, offsetX ) { // eslint-disable-line max-params, max-len |
| 66 | + if ( !isLayout( order ) ) { |
| 67 | + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); |
| 68 | + } |
| 69 | + if ( !isMatrixTriangle( uplo ) ) { |
| 70 | + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); |
| 71 | + } |
| 72 | + if ( !isTransposeOperation( trans ) ) { |
| 73 | + throw new TypeError( format( 'invalid argument. Third argument must be a valid transpose operation. Value: `%s`.', trans ) ); |
| 74 | + } |
| 75 | + if ( !isDiagonal( diag ) ) { |
| 76 | + throw new TypeError( format( 'invalid argument. Fourth argument must be a valid diagonal type. Value: `%s`.', diag ) ); |
| 77 | + } |
| 78 | + if ( N < 0 ) { |
| 79 | + throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', N ) ); |
| 80 | + } |
| 81 | + if ( strideAP === 0 ) { |
| 82 | + throw new RangeError( format( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideAP ) ); |
| 83 | + } |
| 84 | + if ( strideX === 0 ) { |
| 85 | + throw new RangeError( format( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideX ) ); |
| 86 | + } |
| 87 | + if ( N === 0 ) { |
| 88 | + return x; |
| 89 | + } |
| 90 | + return base( order, uplo, trans, diag, N, AP, strideAP, offsetAP, x, strideX, offsetX ); // eslint-disable-line max-len |
| 91 | +} |
| 92 | + |
| 93 | + |
| 94 | +// EXPORTS // |
| 95 | + |
| 96 | +module.exports = ctpmv; |
0 commit comments