[136] | 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 Intel(R) MKL
|
---|
| 29 | * Complex Schur needed to complex unsymmetrical eigenvalues/eigenvectors.
|
---|
| 30 | ********************************************************************************
|
---|
| 31 | */
|
---|
| 32 |
|
---|
| 33 | #ifndef EIGEN_COMPLEX_SCHUR_MKL_H
|
---|
| 34 | #define EIGEN_COMPLEX_SCHUR_MKL_H
|
---|
| 35 |
|
---|
| 36 | #include "Eigen/src/Core/util/MKL_support.h"
|
---|
| 37 |
|
---|
| 38 | namespace Eigen {
|
---|
| 39 |
|
---|
| 40 | /** \internal Specialization for the data types supported by MKL */
|
---|
| 41 |
|
---|
| 42 | #define EIGEN_MKL_SCHUR_COMPLEX(EIGTYPE, MKLTYPE, MKLPREFIX, MKLPREFIX_U, EIGCOLROW, MKLCOLROW) \
|
---|
| 43 | template<> inline \
|
---|
| 44 | ComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >& \
|
---|
| 45 | ComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW>& matrix, bool computeU) \
|
---|
| 46 | { \
|
---|
| 47 | typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> MatrixType; \
|
---|
| 48 | typedef MatrixType::RealScalar RealScalar; \
|
---|
| 49 | typedef std::complex<RealScalar> ComplexScalar; \
|
---|
| 50 | \
|
---|
| 51 | eigen_assert(matrix.cols() == matrix.rows()); \
|
---|
| 52 | \
|
---|
| 53 | m_matUisUptodate = false; \
|
---|
| 54 | if(matrix.cols() == 1) \
|
---|
| 55 | { \
|
---|
| 56 | m_matT = matrix.cast<ComplexScalar>(); \
|
---|
| 57 | if(computeU) m_matU = ComplexMatrixType::Identity(1,1); \
|
---|
| 58 | m_info = Success; \
|
---|
| 59 | m_isInitialized = true; \
|
---|
| 60 | m_matUisUptodate = computeU; \
|
---|
| 61 | return *this; \
|
---|
| 62 | } \
|
---|
| 63 | lapack_int n = matrix.cols(), sdim, info; \
|
---|
| 64 | lapack_int lda = matrix.outerStride(); \
|
---|
| 65 | lapack_int matrix_order = MKLCOLROW; \
|
---|
| 66 | char jobvs, sort='N'; \
|
---|
| 67 | LAPACK_##MKLPREFIX_U##_SELECT1 select = 0; \
|
---|
| 68 | jobvs = (computeU) ? 'V' : 'N'; \
|
---|
| 69 | m_matU.resize(n, n); \
|
---|
| 70 | lapack_int ldvs = m_matU.outerStride(); \
|
---|
| 71 | m_matT = matrix; \
|
---|
| 72 | Matrix<EIGTYPE, Dynamic, Dynamic> w; \
|
---|
| 73 | w.resize(n, 1);\
|
---|
| 74 | info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)w.data(), (MKLTYPE*)m_matU.data(), ldvs ); \
|
---|
| 75 | if(info == 0) \
|
---|
| 76 | m_info = Success; \
|
---|
| 77 | else \
|
---|
| 78 | m_info = NoConvergence; \
|
---|
| 79 | \
|
---|
| 80 | m_isInitialized = true; \
|
---|
| 81 | m_matUisUptodate = computeU; \
|
---|
| 82 | return *this; \
|
---|
| 83 | \
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, ColMajor, LAPACK_COL_MAJOR)
|
---|
| 87 | EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, ColMajor, LAPACK_COL_MAJOR)
|
---|
| 88 | EIGEN_MKL_SCHUR_COMPLEX(dcomplex, MKL_Complex16, z, Z, RowMajor, LAPACK_ROW_MAJOR)
|
---|
| 89 | EIGEN_MKL_SCHUR_COMPLEX(scomplex, MKL_Complex8, c, C, RowMajor, LAPACK_ROW_MAJOR)
|
---|
| 90 |
|
---|
| 91 | } // end namespace Eigen
|
---|
| 92 |
|
---|
| 93 | #endif // EIGEN_COMPLEX_SCHUR_MKL_H
|
---|