Converting rowwise back to matrix

23 Views Asked by At

I am looking for an operation that creates a matrix from a colwise operation in Eigen.

I could not find an appropriate operation in VectorwiseOp (sorry if I overlooked one).

It seems that it is supported for some operations. First output compiles fine, second output gives an error. (https://www.godbolt.org/z/qrrfa1brx)

#include <Eigen/Core>
#include <iostream>

int main() {
    Eigen::Matrix3d m;

    m << 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0;

    std::cout << m + m.rowwise().sum().replicate(1, 3) << std::endl; // OK
    std::cout << m + m.rowwise() << std::endl;  // Failure: operator + not found.
}

In the context I want to apply this, it is not possible for me to use rowwise as an lhs operator. I want to apply other matrix operations on the result.

Maybe an matri() or array() method in the VectorwiseOp would solve this gap.

0

There are 0 best solutions below