Re: [eigen] ordering of eigenvalues of EigenSolver |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] ordering of eigenvalues of EigenSolver
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 18 Feb 2011 10:59:35 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=77JFdXaYCEVpkdt84IJ/IQtLJ0z3mQn8Utz+eHKQ25s=; b=tsEVllORNOc+HZPVBop+/YqgyC3QGAS/5E4YM/XsISgvauNpooMvj/ckRHv+TxFbYy q0+K+OSKVvaKhL49dRTbZwliSlECVoE6Wmr8hNEuSrF9p/qxCIN97nHYVGo6gmAqsmxx KpGGUkE4AdUMOQ1LrmK0Vy6fcrM0lpmrUFBkw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=xbAqxSOo3DFmJoXod9nFDTC5EJs345vBKJQWOf7yEGkuohzifk8FA1hBkDKLTqnAfy NnT3KjX/AfE+IyGoYaA0RGoiOskcShG/OA0RdeJnirAVe2ipZNskt/F+VYRbgOAjUVfK ncT0d8OM6NS41HWv8uVWHjE7HXRJuigRRo5p0=
Hi,
Sorry for the belated answer, I hadn't actually checked carefully what
both Eigen and others (LAPACK) were doing until today.
As it turns out, we are doing exactly the same thing as LAPACK:
* for self-adjoint eigensolver, we sort eigenvalues in ascending
order. For LAPACK, see:
http://www.netlib.org/lapack/single/ssyev.f
* for SVD, we sort singular values in descending order. For SVD, see:
http://www.netlib.org/lapack/single/sgesvd.f
I agree that it's pretty weird to be using sometimes ascending and
sometimes descending order. But since that's what both LAPACK and
ourselves have been doing, we shouldn't change that now.
Benoit
2011/2/8 Susanne Suter <susanne.suter@xxxxxxxxx>:
> Hi
>
> Sorry, I accidently hit the "send button" too early. Here my complete
> messge again.
>
> I'm testing the Eigen library in order to use it for eigenvalue
> decomposition or SVD. In the end I need the eigenvectors (left
> singular vectors) and the eigenvalues (singular values).
>
> I noticed that when using the EigenSolver classes, the ordering of the
> eigenvalues is not as I expected. Normally, I would expect that I get
> an ordering analogous to the singular values, i.e., an ordering with
> the maximum absolute value first and then decreasing values ordered by
> their absolute value (sometimes also called "largest magnitude
> eigenvalues"). What I get now, looks a bit like an ordering
> considering the sign (SelfAdjointEigenSolver). I had similar issues
> with EigenSolver and ComplexEigenSolver (however, I found the ordering
> not consistent in all methods).
>
> ### SelfAdjointEigenSolver: eigenvalues of A are: -2.77687
> -1.50582 -0.0370092 0.848378
> ### ComplexEigenSolver: eigenvalues are: (-0.0370093,0) (0.848378,0)
> (-1.50582,0) (-2.77687,0)
> ### EigenSolver: eigenvalues are : (-2.77687,0) (-0.0370092,0)
> (0.848379,0) (-1.50582,0)
>
> However, I would expect
> ### eigenvalues of A are: -2.77687 -1.50582 0.848378 -0.0370092
>
> Until now, I only was using eigenvalue decompositions, which used the
> same ordering for eigenvalues as the SVD for the singular values (e.g.
> Matlab). Is there any reason why the implementation of Eigen is
> different? Or is there any option to change the ordering?
>
> I'm using the following test matrix:
>
> A =
>
> -2.0000 -0.6714 0.8698 0.5792
> -0.6714 -1.1242 -0.0365 -0.5731
> 0.8698 -0.0365 -0.4660 -0.8542
> 0.5792 -0.5731 -0.8542 0.1188
>
> and I test it with the following code (using the Eigen3 version).
>
> Eigen::SelfAdjointEigenSolver<Eigen::Matrix4f> es;
> es.compute(A);
> std::cout << "### SELFADJOINT EIGENVALUE DECOMPOSITION ### " << std::endl;
> std::cout << "** eigenvalues of A are: " <<
> es.eigenvalues().transpose() << std::endl;
> std::cout << "** eigenvectors of A are: " << std::endl <<
> es.eigenvectors() << std::endl;
>
> Thank you for any hints or advice on that topic.
>
> Best,
> Susanne
>
>
>