[eigen] Assigning SelfAdjointView to dense matrix

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hello,

The Eigenvalues module contains two MatrixBase methods, eigenvalues() and operatorNorm(), which refer to the SelfAdjoint flag in the Flags member variable. As I understand it, this is still a relic from Eigen2 so I'm rewriting it to use SelfAdjointView. However, I am not sure I understand how to use that class properly.

The code fragment

  Matrix3d A = Matrix3d::Random(3,3);
  Matrix3d X = A.selfadjointView<Lower>();

triggers an run-time assertion failure in the current development version (revision 6532182d4c89):

/home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:343: static void Eigen::ei_triangular_assignment_selector<Derived1, Derived2, Mode, UnrollCount, ClearOpposite>::run(Derived1&, const Derived2&) [with Derived1 = Eigen::Matrix<double, 3, 3, 0, 3, 3>, Derived2 = Eigen::Matrix<double, 3, 3, 0, 3, 3>, unsigned int Mode = 17u, int UnrollCount = 1, bool ClearOpposite = true]: Assertion `Mode == Upper || Mode == Lower || Mode == StrictlyUpper || Mode == StrictlyLower || Mode == UnitUpper || Mode == UnitLower' failed.

The template is instantiated with Mode = 17 = SelfAdjoint|Lower, and from the source it seems that the possibility of assigning a fixed-size selfadjoint matrix to a dense matrix has simply not been implemented. If I replace Matrix3d with MatrixXd in the above code fragment, it works correctly. This suggests that I'm using the SelfAdjointClass correctly, but I'm not sure.

In case you need it, here is the backtrace. It's compiled with gcc 4.4.4 on 32-bits Linux with flags -msse2 -msse3 -mssse3 -Wall -O1 -g .

#0  0xb7fe1424 in __kernel_vsyscall ()
#1  0xb7d758e0 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0xb7d78e15 in *__GI_abort () at abort.c:88
#3  0xb7d6eace in *__GI___assert_fail (
    assertion=0x804a2ec "Mode == Upper || Mode == Lower || Mode == StrictlyUpper || Mode == StrictlyLower || Mode == UnitUpper || Mode == UnitLower", file=0x804a2a8 "/home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h", line=343,
    function=0x804a3a0 "static void Eigen::ei_triangular_assignment_selector<Derived1, Derived2, Mode, UnrollCount, ClearOpposite>::run(Derived1&, const Derived2&) [with Derived1 = Eigen::Matrix<double, 3, 3, 0, 3, 3>, Deriv"...) at assert.c:78
#4  0x080492f2 in Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 1, true>::run (this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:341
#5  Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 2, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#6  Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 3, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#7  Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 4, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#8  Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 5, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#9  Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 6, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#10 Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 7, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#11 Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 8, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#12 Eigen::ei_triangular_assignment_selector<Eigen::Matrix<double, 3, 3, 0, 3, 3>, Eigen::Matrix<double, 3, 3, 0, 3, 3>, 17u, 9, true>::run (
    this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:339
#13 Eigen::TriangularBase<Eigen::SelfAdjointView<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 1u> >::evalToLazy<Eigen::Matrix<double, 3, 3, 0, 3, 3> > (this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:606
#14 0x0804930a in Eigen::TriangularBase<Eigen::SelfAdjointView<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 1u> >::evalTo<Eigen::Matrix<double, 3, 3, 0, 3, 3> > (this=0xbffff38c, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/TriangularMatrix.h:593
#15 0x08049325 in Eigen::DenseBase<Eigen::Matrix<double, 3, 3, 0, 3, 3> >::operator=<Eigen::SelfAdjointView<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 1u> > (this=0xbffff2f8, other=...) at /home/jitse/misc/eigen-official/Eigen/src/Core/EigenBase.h:116
#16 0x0804922c in operator=<Eigen::SelfAdjointView<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 1u> > ()
    at /home/jitse/misc/eigen-official/Eigen/src/Core/DenseStorageBase.h:345
#17 operator=<Eigen::SelfAdjointView<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 1u> > ()
#18 Matrix<Eigen::SelfAdjointView<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 1u> > ()
    at /home/jitse/misc/eigen-official/Eigen/src/Core/Matrix.h:313
#19 main () at eigenbar.cc:11

Cheers,
Jitse



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/