mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-18 14:34:17 +08:00
add lapack interface to real symmetric eigenvalue dec and enable building of the lapack shared library
This commit is contained in:
parent
d8ca948148
commit
390724b4b6
@ -29,6 +29,7 @@ set(EigenLapack_SRCS ${EigenLapack_SRCS}
|
||||
# reference/dpotrs.f reference/spotrs.f reference/zpotrs.f reference/cpotrs.f
|
||||
# reference/dgetrf.f reference/cgetrf.f reference/sgetrf.f reference/zgetrf.f
|
||||
# reference/cgetrs.f reference/dgetrs.f reference/sgetrs.f reference/zgetrs.f
|
||||
# reference/dsyev.f reference/ssyev.f
|
||||
|
||||
reference/dlamch.f reference/ilaver.f reference/lsame.f reference/slamch.f reference/second_NONE.f reference/dsecnd_NONE.f
|
||||
reference/cbdsqr.f reference/ctbrfs.f reference/dorml2.f reference/sla_porfsx_extended.f reference/zggglm.f
|
||||
@ -124,7 +125,7 @@ reference/cheevr.f reference/dgehd2.f reference/dste
|
||||
reference/cheevx.f reference/dgehrd.f reference/dsycon.f reference/sopgtr.f reference/zlagtm.f
|
||||
reference/chegs2.f reference/dgejsv.f reference/dsyequb.f reference/sopmtr.f reference/zla_heamv.f
|
||||
reference/chegst.f reference/dgelq2.f reference/dsyevd.f reference/sorg2l.f reference/zlahef.f
|
||||
reference/chegvd.f reference/dgelqf.f reference/dsyev.f reference/sorg2r.f reference/zla_hercond_c.f
|
||||
reference/chegvd.f reference/dgelqf.f reference/sorg2r.f reference/zla_hercond_c.f
|
||||
reference/chegv.f reference/dgelsd.f reference/dsyevr.f reference/sorgbr.f reference/zla_hercond_x.f
|
||||
reference/chegvx.f reference/dgels.f reference/dsyevx.f reference/sorghr.f reference/zla_herfsx_extended.f
|
||||
reference/cherfs.f reference/dgelss.f reference/dsygs2.f reference/sorgl2.f reference/zla_herpvgrw.f
|
||||
@ -230,7 +231,7 @@ reference/claqhp.f reference/dlamrg.f reference/sgee
|
||||
reference/claqp2.f reference/dlaneg.f reference/sgegs.f reference/ssycon.f reference/zpftri.f
|
||||
reference/claqps.f reference/dlangb.f reference/sgegv.f reference/ssyequb.f reference/zpftrs.f
|
||||
reference/claqr0.f reference/dlange.f reference/sgehd2.f reference/ssyevd.f reference/zpocon.f
|
||||
reference/claqr1.f reference/dlangt.f reference/sgehrd.f reference/ssyev.f reference/zpoequb.f
|
||||
reference/claqr1.f reference/dlangt.f reference/sgehrd.f reference/zpoequb.f
|
||||
reference/claqr2.f reference/dlanhs.f reference/sgejsv.f reference/ssyevr.f reference/zpoequ.f
|
||||
reference/claqr3.f reference/dlansb.f reference/sgelq2.f reference/ssyevx.f reference/zporfs.f
|
||||
reference/claqr4.f reference/dlansf.f reference/sgelqf.f reference/ssygs2.f reference/zporfsx.f
|
||||
@ -357,11 +358,11 @@ reference/ctbcon.f reference/dormhr.f reference/sla_
|
||||
endif()
|
||||
|
||||
add_library(eigen_lapack_static ${EigenLapack_SRCS})
|
||||
# add_library(eigen_lapack SHARED ${EigenLapack_SRCS})
|
||||
add_library(eigen_lapack SHARED ${EigenLapack_SRCS})
|
||||
|
||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||
target_link_libraries(eigen_lapack_static ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
||||
# target_link_libraries(eigen_lapack ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
||||
target_link_libraries(eigen_lapack ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
||||
endif()
|
||||
|
||||
# add_dependencies(lapack eigen_lapack eigen_lapack_static)
|
||||
|
@ -29,3 +29,4 @@
|
||||
|
||||
#include "cholesky.cpp"
|
||||
#include "lu.cpp"
|
||||
#include "eigenvalues.cpp"
|
||||
|
93
lapack/eigenvalues.cpp
Normal file
93
lapack/eigenvalues.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2011 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
//
|
||||
// Eigen is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Alternatively, you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of
|
||||
// the License, or (at your option) any later version.
|
||||
//
|
||||
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License and a copy of the GNU General Public License along with
|
||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "common.h"
|
||||
#include <Eigen/Eigenvalues>
|
||||
|
||||
// computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges
|
||||
EIGEN_LAPACK_FUNC(syev,(char *jobz, char *uplo, int* n, Scalar* a, int *lda, Scalar* w, Scalar* work, int* lwork, int *info))
|
||||
{
|
||||
bool query_size = *lwork==-1;
|
||||
|
||||
*info = 0;
|
||||
if(*jobz!='N' && *jobz!='V') *info = -1;
|
||||
else if(UPLO(*uplo)==INVALID) *info = -2;
|
||||
else if(*n<0) *info = -3;
|
||||
else if(*lda<std::max(1,*n)) *info = -5;
|
||||
else if((!query_size) && *lwork<std::max(1,3**n-1)) *info = -8;
|
||||
|
||||
// if(*info==0)
|
||||
// {
|
||||
// int nb = ILAENV( 1, 'SSYTRD', UPLO, N, -1, -1, -1 )
|
||||
// LWKOPT = MAX( 1, ( NB+2 )*N )
|
||||
// WORK( 1 ) = LWKOPT
|
||||
// *
|
||||
// IF( LWORK.LT.MAX( 1, 3*N-1 ) .AND. .NOT.LQUERY )
|
||||
// $ INFO = -8
|
||||
// END IF
|
||||
// *
|
||||
// IF( INFO.NE.0 ) THEN
|
||||
// CALL XERBLA( 'SSYEV ', -INFO )
|
||||
// RETURN
|
||||
// ELSE IF( LQUERY ) THEN
|
||||
// RETURN
|
||||
// END IF
|
||||
|
||||
if(*info!=0)
|
||||
{
|
||||
int e = -*info;
|
||||
return xerbla_(SCALAR_SUFFIX_UP"SYEV ", &e, 6);
|
||||
}
|
||||
|
||||
if(query_size)
|
||||
{
|
||||
*lwork = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(*n==0)
|
||||
return 0;
|
||||
|
||||
PlainMatrixType mat(*n,*n);
|
||||
if(UPLO(*uplo)==UP) mat = matrix(a,*n,*n,*lda).adjoint();
|
||||
else mat = matrix(a,*n,*n,*lda);
|
||||
|
||||
bool computeVectors = *jobz=='V' || *jobz=='v';
|
||||
SelfAdjointEigenSolver<PlainMatrixType> eig(mat,computeVectors?ComputeEigenvectors:EigenvaluesOnly);
|
||||
|
||||
if(eig.info()==NoConvergence)
|
||||
{
|
||||
vector(w,*n).setZero();
|
||||
if(computeVectors)
|
||||
matrix(a,*n,*n,*lda).setIdentity();
|
||||
//*info = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
vector(w,*n) = eig.eigenvalues();
|
||||
if(computeVectors)
|
||||
matrix(a,*n,*n,*lda) = eig.eigenvectors();
|
||||
|
||||
return 0;
|
||||
}
|
@ -29,3 +29,4 @@
|
||||
|
||||
#include "cholesky.cpp"
|
||||
#include "lu.cpp"
|
||||
#include "eigenvalues.cpp"
|
||||
|
Loading…
Reference in New Issue
Block a user