The behavior of `blaze::eigen()` does not match the documentation.

Issue #263 resolved
Mikhail Katliar created an issue

The documentation says:

In case A is a row-major matrix, the left eigenvectors are returned in the rows of V, in case A is a column-major matrix, the right eigenvectors are returned in the columns of V.

Example:

#include <blaze/Math.h>
#include <iostream>

int main(int, char * [])
{
    blaze::DynamicMatrix<double, blaze::columnMajor> A {
        {1., 3.},
        {4., 2.}
    };

    blaze::DynamicMatrix<std::complex<double>, blaze::columnMajor> V1;
    blaze::DynamicMatrix<std::complex<double>, blaze::rowMajor> V2;
    blaze::DynamicVector<std::complex<double>, blaze::rowVector> lam;

    eigen(A, lam, V1);
    eigen(A, lam, V2);

    std::cout << "V1:\n" << V1 << "\n";
    std::cout << "V2:\n" << V2 << "\n";

    return 0;
}

Output:

V1:
( (-0.707107,0)     (-0.6,0) )
( (0.707107,0)     (-0.8,0) )

V2:
( (-0.707107,0) (0.707107,0) )
(     (-0.6,0)     (-0.8,0) )

Apparently, the output of eigen() also depends on the storage order of the V argument. Either the documentation should be changed accordingly, of the function should be modified such that the result does not depend on the storage order of V.

Comments (5)

  1. Klaus Iglberger

    Hi Mikhail!

    Thanks a lot for creating this issue. You are correct, the documentation of the eigen() function does not match its current behavior. In this case the documentation is incorrect/incomplete. The correct statement in the documentation should be:

    … In case A is a row-major matrix, the function computes the left eigenvectors, in case A is a column-major matrix, the function returns the right eigenvectors. In case V is row-major, the eigenvectors are returned in the rows of V, in case V is column-major the eigenvectors are returned in the columns of V. …

    We apologize for the inconvenience and will fix the documentation as quickly as possible. Thanks again,

    Best regards,

    Klaus!

  2. Klaus Iglberger

    The documentation of the eigen() function and the tutorial have been updated accordingly. The final wording of both is

    … In case \a A is a row-major matrix, V will contain the left eigenvectors, otherwise V will contain the right eigenvectors. In case \a V is a row-major matrix the eigenvectors are returned in the rows of V, in case V is a column-major matrix the eigenvectors are returned in the columns of V. …

    The fix will be part of the next big push.

  3. Klaus Iglberger

    Commits 9cba549 and f69b021 fix the documentation of the eigen() function and the tutorial for the eigen() function, respectively. The fix is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.6.

  4. Log in to comment