SelfAdjointEigenSolver_LAPACKE.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 LAPACKe
29  * Self-adjoint eigenvalues/eigenvectors.
30  ********************************************************************************
31 */
32 
33 #ifndef EIGEN_SAEIGENSOLVER_LAPACKE_H
34 #define EIGEN_SAEIGENSOLVER_LAPACKE_H
35 
36 namespace Eigen {
37 
40 #define EIGEN_LAPACKE_EIG_SELFADJ(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_NAME, EIGCOLROW, LAPACKE_COLROW ) \
41 template<> template<typename InputType> inline \
42 SelfAdjointEigenSolver<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >& \
43 SelfAdjointEigenSolver<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const EigenBase<InputType>& matrix, int options) \
44 { \
45  eigen_assert(matrix.cols() == matrix.rows()); \
46  eigen_assert((options&~(EigVecMask|GenEigMask))==0 \
47  && (options&EigVecMask)!=EigVecMask \
48  && "invalid option parameter"); \
49  bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors; \
50  lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), lda, matrix_order, info; \
51  m_eivalues.resize(n,1); \
52  m_subdiag.resize(n-1); \
53  m_eivec = matrix; \
54 \
55  if(n==1) \
56  { \
57  m_eivalues.coeffRef(0,0) = numext::real(m_eivec.coeff(0,0)); \
58  if(computeEigenvectors) m_eivec.setOnes(n,n); \
59  m_info = Success; \
60  m_isInitialized = true; \
61  m_eigenvectorsOk = computeEigenvectors; \
62  return *this; \
63  } \
64 \
65  lda = internal::convert_index<lapack_int>(m_eivec.outerStride()); \
66  matrix_order=LAPACKE_COLROW; \
67  char jobz, uplo='L'/*, range='A'*/; \
68  jobz = computeEigenvectors ? 'V' : 'N'; \
69 \
70  info = LAPACKE_##LAPACKE_NAME( matrix_order, jobz, uplo, n, (LAPACKE_TYPE*)m_eivec.data(), lda, (LAPACKE_RTYPE*)m_eivalues.data() ); \
71  m_info = (info==0) ? Success : NoConvergence; \
72  m_isInitialized = true; \
73  m_eigenvectorsOk = computeEigenvectors; \
74  return *this; \
75 }
76 
77 
78 EIGEN_LAPACKE_EIG_SELFADJ(double, double, double, dsyev, ColMajor, LAPACK_COL_MAJOR)
79 EIGEN_LAPACKE_EIG_SELFADJ(float, float, float, ssyev, ColMajor, LAPACK_COL_MAJOR)
82 
83 EIGEN_LAPACKE_EIG_SELFADJ(double, double, double, dsyev, RowMajor, LAPACK_ROW_MAJOR)
84 EIGEN_LAPACKE_EIG_SELFADJ(float, float, float, ssyev, RowMajor, LAPACK_ROW_MAJOR)
85 EIGEN_LAPACKE_EIG_SELFADJ(dcomplex, lapack_complex_double, double, zheev, RowMajor, LAPACK_ROW_MAJOR)
86 EIGEN_LAPACKE_EIG_SELFADJ(scomplex, lapack_complex_float, float, cheev, RowMajor, LAPACK_ROW_MAJOR)
87 
88 } // end namespace Eigen
89 
90 #endif // EIGEN_SAEIGENSOLVER_H
#define lapack_complex_float
Definition: lapacke.h:80
#define LAPACK_COL_MAJOR
Definition: lapacke.h:122
Definition: LDLT.h:16
std::complex< float > scomplex
Definition: MKL_support.h:114
std::complex< double > dcomplex
Definition: MKL_support.h:113
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:121
#define EIGEN_LAPACKE_EIG_SELFADJ(EIGTYPE, LAPACKE_TYPE, LAPACKE_RTYPE, LAPACKE_NAME, EIGCOLROW, LAPACKE_COLROW)
#define lapack_complex_double
Definition: lapacke.h:96


hebiros
Author(s): Xavier Artache , Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:45