34#ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H
35#define EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H
38#include "../InternalHeaderCheck.h"
50template <
typename Scalar,
typename Index,
int StorageOrder,
int UpLo,
bool ConjugateLhs,
bool ConjugateRhs>
51struct selfadjoint_matrix_vector_product_symv
52 : selfadjoint_matrix_vector_product<Scalar, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs, BuiltIn> {};
54#define EIGEN_BLAS_SYMV_SPECIALIZE(Scalar) \
55 template <typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \
56 struct selfadjoint_matrix_vector_product<Scalar, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs, \
58 static void run(Index size, const Scalar* lhs, Index lhsStride, const Scalar* _rhs, Scalar* res, Scalar alpha) { \
59 enum { IsColMajor = StorageOrder == ColMajor }; \
60 EIGEN_IF_CONSTEXPR (IsColMajor == ConjugateLhs) { \
61 selfadjoint_matrix_vector_product<Scalar, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs, \
62 BuiltIn>::run(size, lhs, lhsStride, _rhs, res, alpha); \
64 selfadjoint_matrix_vector_product_symv<Scalar, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs>::run( \
65 size, lhs, lhsStride, _rhs, res, alpha); \
70EIGEN_BLAS_SYMV_SPECIALIZE(
double)
71EIGEN_BLAS_SYMV_SPECIALIZE(
float)
72EIGEN_BLAS_SYMV_SPECIALIZE(dcomplex)
73EIGEN_BLAS_SYMV_SPECIALIZE(scomplex)
75#define EIGEN_BLAS_SYMV_SPECIALIZATION(EIGTYPE, BLASTYPE, BLASFUNC) \
76 template <typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \
77 struct selfadjoint_matrix_vector_product_symv<EIGTYPE, Index, StorageOrder, UpLo, ConjugateLhs, ConjugateRhs> { \
78 typedef Matrix<EIGTYPE, Dynamic, 1, ColMajor> SYMVVector; \
80 static void run(Index size, const EIGTYPE* lhs, Index lhsStride, const EIGTYPE* _rhs, EIGTYPE* res, \
82 if (size == 0) return; \
83 enum { IsRowMajor = StorageOrder == RowMajor ? 1 : 0, IsLower = UpLo == Lower ? 1 : 0 }; \
84 BlasIndex n = convert_index<BlasIndex>(size), lda = convert_index<BlasIndex>(lhsStride), incx = 1, incy = 1; \
86 const EIGTYPE* x_ptr; \
87 char uplo = (IsRowMajor) ? (IsLower ? 'U' : 'L') : (IsLower ? 'L' : 'U'); \
89 EIGEN_IF_CONSTEXPR (ConjugateRhs) { \
90 Map<const SYMVVector, 0> map_x(_rhs, size, 1); \
91 x_tmp = map_x.conjugate(); \
92 x_ptr = x_tmp.data(); \
95 BLASFUNC(&uplo, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)lhs, &lda, \
96 (const BLASTYPE*)x_ptr, &incx, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &incy); \
101EIGEN_BLAS_SYMV_SPECIALIZATION(
double,
double, dsymv)
102EIGEN_BLAS_SYMV_SPECIALIZATION(
float,
float, ssymv)
103EIGEN_BLAS_SYMV_SPECIALIZATION(dcomplex, MKL_Complex16, zhemv)
104EIGEN_BLAS_SYMV_SPECIALIZATION(scomplex, MKL_Complex8, chemv)
106EIGEN_BLAS_SYMV_SPECIALIZATION(
double,
double, EIGEN_BLAS_SYM(dsymv))
107EIGEN_BLAS_SYMV_SPECIALIZATION(
float,
float, EIGEN_BLAS_SYM(ssymv))
108EIGEN_BLAS_SYMV_SPECIALIZATION(dcomplex,
double, EIGEN_BLAS_SYM(zhemv))
109EIGEN_BLAS_SYMV_SPECIALIZATION(scomplex,
float, EIGEN_BLAS_SYM(chemv))
112#undef EIGEN_BLAS_SYMV_SPECIALIZATION
113#undef EIGEN_BLAS_SYMV_SPECIALIZE