Re: [eigen] Using Triangular Views

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


It's not possible yet to multiply two triangular views.. One of the operands has to be a general full matrix.

Gael.

On Tue, Aug 30, 2016 at 2:09 PM, Brad Bell <bradbell@xxxxxxxxxx> wrote:
How does one multiply a lower triangular matrix times a lower triangular matrix and avoid multiplying the zeros in the lower triangular matrix ?

An attempt at this (see below) does not seem to compile when MULTIPLY_VIEW is non-zero: To be specific, I get the error message:

error: no match for ‘operator*’ (operand types are ‘const Eigen::TriangularView<Eigen::Matrix<double, 2, 2>, 1u>’ and ‘const Eigen::TriangularView<Eigen::Transpose<Eigen::Matrix<double, 2, 2> >, 2u>’)
    matrix B = view_L * view_L.transpose();

when I try to compile the program:
# include <Eigen/Core>
# include <iostream>

// code does not compile if you select MULTIPLY_VIEW equal to 1
# define MULTIPLY_VIEW 0

int main()
{   typedef Eigen::Matrix<double, 2, 2> matrix;
    using Eigen::Lower;
    using Eigen::TriangularView;

    matrix A;
    A <<
    1, 2,
    3, 4;
    //
    const TriangularView<matrix, Lower> view_L = A.triangularView<Lower>();
    matrix L = view_L;
    //
# if MULTIPLY_VIEW
    matrix B = view_L * view_L.transpose();
# else
    matrix B = view_L * L.transpose();
# endif
    //
    std::cout << "B =\n" << B << "\n";

    return 0;
}






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