SelfadjointMatrixVector_BLAS.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2011, Intel Corporation. All rights reserved.
3 
4  Redistribution and use in source and binary forms, with or without modification,
5  are permitted provided that the following conditions are met:
6 
7  * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice,
10  this list of conditions and the following disclaimer in the documentation
11  and/or other materials provided with the distribution.
12  * Neither the name of Intel Corporation nor the names of its contributors may
13  be used to endorse or promote products derived from this software without
14  specific prior written permission.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27  ********************************************************************************
28  * Content : Eigen bindings to BLAS F77
29  * Selfadjoint matrix-vector product functionality based on ?SYMV/HEMV.
30  ********************************************************************************
31 */
32 
33 #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H
34 #define EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H
35 
36 namespace Eigen {
37 
38 namespace internal {
39 
40 /**********************************************************************
41 * This file implements selfadjoint matrix-vector multiplication using BLAS
42 **********************************************************************/
43 
44 // symv/hemv specialization
45 
46 template<typename Scalar, typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs>
48  selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,BuiltIn> {};
49 
50 #define EIGEN_BLAS_SYMV_SPECIALIZE(Scalar) \
51 template<typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \
52 struct selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,Specialized> { \
53 static void run( \
54  Index size, const Scalar* lhs, Index lhsStride, \
55  const Scalar* _rhs, Scalar* res, Scalar alpha) { \
56  enum {\
57  IsColMajor = StorageOrder==ColMajor \
58  }; \
59  if (IsColMajor == ConjugateLhs) {\
60  selfadjoint_matrix_vector_product<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs,BuiltIn>::run( \
61  size, lhs, lhsStride, _rhs, res, alpha); \
62  } else {\
63  selfadjoint_matrix_vector_product_symv<Scalar,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs>::run( \
64  size, lhs, lhsStride, _rhs, res, alpha); \
65  }\
66  } \
67 }; \
68 
73 
74 #define EIGEN_BLAS_SYMV_SPECIALIZATION(EIGTYPE,BLASTYPE,BLASFUNC) \
75 template<typename Index, int StorageOrder, int UpLo, bool ConjugateLhs, bool ConjugateRhs> \
76 struct selfadjoint_matrix_vector_product_symv<EIGTYPE,Index,StorageOrder,UpLo,ConjugateLhs,ConjugateRhs> \
77 { \
78 typedef Matrix<EIGTYPE,Dynamic,1,ColMajor> SYMVVector;\
79 \
80 static void run( \
81 Index size, const EIGTYPE* lhs, Index lhsStride, \
82 const EIGTYPE* _rhs, EIGTYPE* res, EIGTYPE alpha) \
83 { \
84  enum {\
85  IsRowMajor = StorageOrder==RowMajor ? 1 : 0, \
86  IsLower = UpLo == Lower ? 1 : 0 \
87  }; \
88  BlasIndex n=convert_index<BlasIndex>(size), lda=convert_index<BlasIndex>(lhsStride), incx=1, incy=1; \
89  EIGTYPE beta(1); \
90  const EIGTYPE *x_ptr; \
91  char uplo=(IsRowMajor) ? (IsLower ? 'U' : 'L') : (IsLower ? 'L' : 'U'); \
92  SYMVVector x_tmp; \
93  if (ConjugateRhs) { \
94  Map<const SYMVVector, 0 > map_x(_rhs,size,1); \
95  x_tmp=map_x.conjugate(); \
96  x_ptr=x_tmp.data(); \
97  } else x_ptr=_rhs; \
98  BLASFUNC(&uplo, &n, (const BLASTYPE*)&numext::real_ref(alpha), (const BLASTYPE*)lhs, &lda, (const BLASTYPE*)x_ptr, &incx, (const BLASTYPE*)&numext::real_ref(beta), (BLASTYPE*)res, &incy); \
99 }\
100 };
101 
102 #ifdef EIGEN_USE_MKL
103 EIGEN_BLAS_SYMV_SPECIALIZATION(double, double, dsymv)
107 #else
108 EIGEN_BLAS_SYMV_SPECIALIZATION(double, double, dsymv_)
109 EIGEN_BLAS_SYMV_SPECIALIZATION(float, float, ssymv_)
112 #endif
113 
114 } // end namespace internal
115 
116 } // end namespace Eigen
117 
118 #endif // EIGEN_SELFADJOINT_MATRIX_VECTOR_BLAS_H
EIGEN_BLAS_SYMV_SPECIALIZATION
#define EIGEN_BLAS_SYMV_SPECIALIZATION(EIGTYPE, BLASTYPE, BLASFUNC)
Definition: SelfadjointMatrixVector_BLAS.h:74
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
ssymv
int BLASFUNC() ssymv(char *, int *, float *, float *, int *, float *, int *, float *, float *, int *)
chemv
int BLASFUNC() chemv(char *, int *, float *, float *, int *, float *, int *, float *, float *, int *)
Eigen::internal::selfadjoint_matrix_vector_product_symv
Definition: SelfadjointMatrixVector_BLAS.h:47
dsymv
int BLASFUNC() dsymv(char *, int *, double *, double *, int *, double *, int *, double *, double *, int *)
Eigen::scomplex
std::complex< float > scomplex
Definition: MKL_support.h:126
Eigen::dcomplex
std::complex< double > dcomplex
Definition: MKL_support.h:125
EIGEN_BLAS_SYMV_SPECIALIZE
#define EIGEN_BLAS_SYMV_SPECIALIZE(Scalar)
Definition: SelfadjointMatrixVector_BLAS.h:50
Eigen::internal::selfadjoint_matrix_vector_product
Definition: SelfadjointMatrixVector.h:24
zhemv
int BLASFUNC() zhemv(char *, int *, double *, double *, int *, double *, int *, double *, double *, int *)
internal
Definition: BandTriangularSolver.h:13


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:04:03