Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 52x 48x 48x 52x 52x 52x 4x 4x 48x 48x 48x 48x 48x 48x 48x 52x 24x 24x 24x 24x 48x 48x 48x 48x 48x 48x 48x 48x 48x 48x 48x 48x 48x 48x 52x 24x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 96x 96x 96x 96x 96x 96x 96x 96x 96x 96x 96x 96x 80x 80x 80x 80x 80x 24x 24x 24x 24x 52x 80x 80x 80x 80x 80x 80x 80x 80x 80x 80x 96x 96x 96x 96x 96x 96x 96x 96x 96x 96x 96x 96x 80x 80x 80x 80x 80x 80x 80x 80x 24x 52x 3x 3x 3x 3x 3x | /**
* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' );
var cfill = require( '@stdlib/blas/ext/base/cfill' ).ndarray;
var cscal = require( '@stdlib/blas/base/cscal' ).ndarray;
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' );
var muladd = require( '@stdlib/complex/float32/base/mul-add' ).assign;
// MAIN //
/**
* Performs the matrix-vector operation `y = α*A*x + β*y`, where `α` and `β` are complex scalars, `x` and `y` are `N` element complex vectors, and `A` is an `N` by `N` Hermitian matrix supplied in packed form.
*
* @private
* @param {string} order - storage layout
* @param {string} uplo - specifies whether `A` is an upper or lower triangular part of matrix is supplied.
* @param {NonNegativeInteger} N - number of elements along each dimension of `A`
* @param {Complex64} alpha - complex scalar constant
* @param {Complex64Array} AP - complex input matrix in packed form
* @param {integer} strideAP - `AP` stride length
* @param {NonNegativeInteger} offsetAP - starting index for `AP`
* @param {Complex64Array} x - first complex input vector
* @param {integer} strideX - `x` stride length
* @param {NonNegativeInteger} offsetX - starting index for `x`
* @param {Complex64} beta - complex scalar constant
* @param {Complex64Array} y - second complex input vector
* @param {integer} strideY - `y` stride length
* @param {NonNegativeInteger} offsetY - starting index for `y`
* @returns {Complex64Array} `y`
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
*
* var AP = new Complex64Array( [ 1.0, 0.0, 2.0, -2.0, 4.0, 0.0, 3.0, -3.0, 5.0, -5.0, 6.0, 0.0 ] );
* var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] );
* var y = new Complex64Array( [ 3.0, 3.0, 2.0, 2.0, 1.0, 1.0 ] );
* var alpha = new Complex64( 0.5, 0.5 );
* var beta = new Complex64( 0.5, -0.5 );
*
* chpmv( 'row-major', 'lower', 3, alpha, AP, 1, 0, x, 1, 0, beta, y, 1, 0 );
* // y => <Complex64Array>[ -10.0, 14.0, -11.0, 25.0, 14.0, 31.0 ]
*/
function chpmv( order, uplo, N, alpha, AP, strideAP, offsetAP, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len
var realpha;
var imalpha;
var rebeta;
var imbeta;
var retmp1;
var imtmp1;
var retmp2;
var imtmp2;
var viewAP;
var viewX;
var viewY;
var cimap;
var isrm;
var sign;
var reap;
var imap;
var iap;
var sap;
var rex;
var imx;
var ix;
var jx;
var kx;
var iy;
var jy;
var ky;
var sx;
var sy;
var kk;
var k;
var j;
// Layout
isrm = isRowMajor( order );
// Decompose scalars
rebeta = realf( beta );
imbeta = imagf( beta );
realpha = realf( alpha );
imalpha = imagf( alpha );
// y = beta*y
if ( rebeta === 0.0 && imbeta === 0.0 ) {
cfill( N, 0.0, y, strideY, offsetY );
} else if ( rebeta !== 1.0 || imbeta !== 0.0 ) {
cscal( N, beta, y, strideY, offsetY );
}
// If alpha is zero, early return y
if ( realpha === 0.0 && imalpha === 0.0 ) {
return y;
}
// Reinterpret arrays to raw numeric views
viewAP = reinterpret( AP, 0 );
viewX = reinterpret( x, 0 );
viewY = reinterpret( y, 0 );
// Adjust sign to account for layout-dependent conjugation
if ( isrm ) {
sign = -1;
} else {
sign = 1;
}
// Vector indexing base
kk = offsetAP * 2;
kx = offsetX * 2;
ky = offsetY * 2;
// Vector strides
sx = strideX * 2;
sy = strideY * 2;
sap = strideAP * 2;
jx = kx;
jy = ky;
if ( ( isrm && uplo === 'upper' ) || ( !isrm && uplo === 'lower' ) ) {
for ( j = 0; j < N; j++ ) {
rex = viewX[ jx ];
imx = viewX[ jx + 1 ];
retmp1 = f32( ( realpha * rex ) - ( imalpha * imx ) );
imtmp1 = f32( ( realpha * imx ) + ( imalpha * rex ) );
retmp2 = 0.0;
imtmp2 = 0.0;
reap = viewAP[ kk ];
viewY[ jy ] += f32( retmp1 * reap );
viewY[ jy + 1 ] += f32( imtmp1 * reap );
ix = jx + sx;
iy = jy + sy;
iap = kk + sap;
for ( k = j + 1; k < N; k++ ) {
reap = viewAP[ iap ];
imap = viewAP[ iap + 1 ];
cimap = sign * imap;
muladd( retmp1, imtmp1, reap, cimap, viewY[ iy ], viewY[ iy + 1 ], viewY, 1, iy ); // eslint-disable-line max-len
rex = viewX[ ix ];
imx = viewX[ ix + 1 ];
retmp2 += f32( ( reap * rex ) + ( cimap * imx ) );
imtmp2 += f32( ( reap * imx ) - ( cimap * rex ) );
ix += sx;
iy += sy;
iap += sap;
}
muladd( realpha, imalpha, retmp2, imtmp2, viewY[ jy ], viewY[ jy + 1 ], viewY, 1, jy ); // eslint-disable-line max-len
jx += sx;
jy += sy;
kk += ( N - j ) * sap;
}
return y;
}
// ( isrm && uplo === 'lower' ) || ( !isrm && uplo === 'upper' )
for ( j = 0; j < N; j++ ) {
rex = viewX[ jx ];
imx = viewX[ jx + 1 ];
retmp1 = f32( ( realpha * rex ) - ( imalpha * imx ) );
imtmp1 = f32( ( realpha * imx ) + ( imalpha * rex ) );
retmp2 = 0.0;
imtmp2 = 0.0;
ix = kx;
iy = ky;
iap = kk;
for ( k = 0; k < j; k++ ) {
reap = viewAP[ iap ];
imap = viewAP[ iap + 1 ];
cimap = sign * imap;
muladd( retmp1, imtmp1, reap, cimap, viewY[ iy ], viewY[ iy + 1 ], viewY, 1, iy ); // eslint-disable-line max-len
rex = viewX[ ix ];
imx = viewX[ ix + 1 ];
retmp2 += f32( ( reap * rex ) + ( cimap * imx ) );
imtmp2 += f32( ( reap * imx ) - ( cimap * rex ) );
ix += sx;
iy += sy;
iap += sap;
}
reap = viewAP[ iap ];
viewY[ jy ] += f32( retmp1 * reap );
viewY[ jy + 1 ] += f32( imtmp1 * reap );
muladd( realpha, imalpha, retmp2, imtmp2, viewY[ jy ], viewY[ jy + 1 ], viewY, 1, jy ); // eslint-disable-line max-len
jx += sx;
jy += sy;
kk += ( j + 1 ) * sap;
}
return y;
}
// EXPORTS //
module.exports = chpmv;
|