10#include "blas/symv.hh"
68template <
typename TA,
typename TX,
typename TY>
73 blas::scalar_type<TA, TX, TY> alpha,
74 TA
const *A, int64_t lda,
75 TX
const *x, int64_t incx,
76 blas::scalar_type<TA, TX, TY> beta,
79 typedef blas::scalar_type<TA, TX, TY> scalar_t;
81 #define A(i_, j_) A[ (i_) + (j_)*lda ]
84 const scalar_t zero = 0;
85 const scalar_t one = 1;
88 blas_error_if( layout != Layout::ColMajor &&
89 layout != Layout::RowMajor );
90 blas_error_if( uplo != Uplo::Lower &&
91 uplo != Uplo::Upper );
92 blas_error_if( n < 0 );
93 blas_error_if( lda < n );
94 blas_error_if( incx == 0 );
95 blas_error_if( incy == 0 );
98 if (n == 0 || (alpha == zero && beta == one))
101 int64_t kx = (incx > 0 ? 0 : (-n + 1)*incx);
102 int64_t ky = (incy > 0 ? 0 : (-n + 1)*incy);
108 for (int64_t i = 0; i < n; ++i) {
113 for (int64_t i = 0; i < n; ++i) {
121 for (int64_t i = 0; i < n; ++i) {
127 for (int64_t i = 0; i < n; ++i) {
137 if (layout == Layout::ColMajor) {
138 if (uplo == Uplo::Upper) {
141 if (incx == 1 && incy == 1) {
143 for (int64_t j = 0; j < n; ++j) {
144 scalar_t tmp1 = alpha*x[j];
145 scalar_t tmp2 = zero;
146 for (int64_t i = 0; i < j; ++i) {
147 y[i] += tmp1 * A(i, j);
148 tmp2 += conj( A(i, j) ) * x[i];
150 y[j] += tmp1 * real( A(j, j) ) + alpha * tmp2;
157 for (int64_t j = 0; j < n; ++j) {
158 scalar_t tmp1 = alpha*x[jx];
159 scalar_t tmp2 = zero;
162 for (int64_t i = 0; i < j; ++i) {
163 y[iy] += tmp1 * A(i, j);
164 tmp2 += conj( A(i, j) ) * x[ix];
168 y[jy] += tmp1 * real( A(j, j) ) + alpha * tmp2;
174 else if (uplo == Uplo::Lower) {
177 if (incx == 1 && incy == 1) {
178 for (int64_t j = 0; j < n; ++j) {
179 scalar_t tmp1 = alpha*x[j];
180 scalar_t tmp2 = zero;
181 for (int64_t i = j+1; i < n; ++i) {
182 y[i] += tmp1 * A(i, j);
183 tmp2 += conj( A(i, j) ) * x[i];
185 y[j] += tmp1 * real( A(j, j) ) + alpha * tmp2;
191 for (int64_t j = 0; j < n; ++j) {
192 scalar_t tmp1 = alpha*x[jx];
193 scalar_t tmp2 = zero;
196 for (int64_t i = j+1; i < n; ++i) {
199 y[iy] += tmp1 * A(i, j);
200 tmp2 += conj( A(i, j) ) * x[ix];
202 y[jy] += tmp1 * real( A(j, j) ) + alpha * tmp2;
210 if (uplo == Uplo::Lower) {
213 if (incx == 1 && incy == 1) {
215 for (int64_t j = 0; j < n; ++j) {
216 scalar_t tmp1 = alpha*x[j];
217 scalar_t tmp2 = zero;
218 for (int64_t i = 0; i < j; ++i) {
219 y[i] += tmp1 * conj( A(i, j) );
220 tmp2 += A(i, j) * x[i];
222 y[j] += tmp1 * real( A(j, j) ) + alpha * tmp2;
229 for (int64_t j = 0; j < n; ++j) {
230 scalar_t tmp1 = alpha*x[jx];
231 scalar_t tmp2 = zero;
234 for (int64_t i = 0; i < j; ++i) {
235 y[iy] += tmp1 * conj( A(i, j) );
236 tmp2 += A(i, j) * x[ix];
240 y[jy] += tmp1 * real( A(j, j) ) + alpha * tmp2;
246 else if (uplo == Uplo::Upper) {
249 if (incx == 1 && incy == 1) {
250 for (int64_t j = 0; j < n; ++j) {
251 scalar_t tmp1 = alpha*x[j];
252 scalar_t tmp2 = zero;
253 for (int64_t i = j+1; i < n; ++i) {
254 y[i] += tmp1 * conj( A(i, j) );
255 tmp2 += A(i, j) * x[i];
257 y[j] += tmp1 * real( A(j, j) ) + alpha * tmp2;
263 for (int64_t j = 0; j < n; ++j) {
264 scalar_t tmp1 = alpha*x[jx];
265 scalar_t tmp2 = zero;
268 for (int64_t i = j+1; i < n; ++i) {
271 y[iy] += tmp1 * conj( A(i, j) );
272 tmp2 += A(i, j) * x[ix];
274 y[jy] += tmp1 * real( A(j, j) ) + alpha * tmp2;
void hemv(blas::Layout layout, blas::Uplo uplo, int64_t n, blas::scalar_type< TA, TX, TY > alpha, TA const *A, int64_t lda, TX const *x, int64_t incx, blas::scalar_type< TA, TX, TY > beta, TY *y, int64_t incy)
Hermitian matrix-vector multiply:
Definition hemv.hh:69