This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problem multiplying triangularView against a scalar

Tags: None
(comma "," separated)
jsanz
Registered Member
Posts
9
Karma
0
OS
Being L and elem to matrices of the same sizes and being elem a triangular matrix I am trying to multiply elem to an scalar but taking advantage of elem's triangularity like this:

Code: Select all
L.template triangularView<Lower>() +=  elem.template triangularView<Lower>() *N(i,0);

But I am getting the next error:

Code: Select all
error: no match for ‘operator*’ in ‘((Eigen::MatrixBase<Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >*)((Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>*)elem))->Eigen::MatrixBase<Derived>::triangularView [with unsigned int Mode = 1u, Derived = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]() * ((Eigen::DenseCoeffsBase<Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>, 1>*)((Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>*)N))->Eigen::DenseCoeffsBase<Derived, 1>::operator() [with Derived = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>](((long int)i), 0l)’
Eigen/src/Core/../plugins/CommonCwiseUnaryOps.h:95: note: candidates are: const Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple2_op<float, std::complex<float> >, const Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> > Eigen::operator*(const std::complex<float>&, const Eigen::MatrixBase<Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >&)
Eigen/src/Core/../plugins/CommonCwiseUnaryOps.h:91: note:                 const Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<float>, const Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> > Eigen::operator*(const float&, const Eigen::MatrixBase<Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >&)

Does anyone know a way of doing that operation?. I don't if it is possible, I've been googling for while and I haven't found any answer.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
not supported yet, simply nest the product inside the view:

L.template triangularView<Lower>() += (elem*N(i,0)).template triangularView<Lower>();
jsanz
Registered Member
Posts
9
Karma
0
OS
Thanks for the answer. No way I would have found out that by myself. Unfortunately it seems that the operator += is not supported somehow using your line of code.

Code: Select all
error: no match for ‘operator+=’ in ‘((Eigen::MatrixBase<Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >*)((Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>*)L))->Eigen::MatrixBase<Derived>::triangularView [with unsigned int Mode = 1u, Derived = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]() += Eigen::MatrixBase<Derived>::triangularView() const [with unsigned int Mode = 1u, Derived = Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, const Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >]()’


Right now this is what I am doing:

Code: Select all
L += (elem*N(i,0)).template triangularView<Lower>();
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
L.template triangularView<Lower>() += elem*N(i,0);

look at this section:
http://eigen.tuxfamily.org/dox-devel/Qu ... iagTriSymm
bouman
Registered Member
Posts
4
Karma
0
ggael wrote:not supported yet, simply nest the product inside the view:

L.template triangularView<Lower>() += (elem*N(i,0)).template triangularView<Lower>();


Dear ggael,

Are you planning to support this feature? (scalar multiplication with a triangularView)?

And how about the following work-around:
Code: Select all
(scalar * Matrix<...>::Identity(appropriate_rows, appropriate_cols)) * A.triangularView<Lower>();

Could that be preferred over your suggested workaround of nesting the product inside the view?

best,
Niek


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell