Can Eigen use symbolic arithmetic?

351 Views Asked by At

When I was using Eigen, I was attracted by its excellent library, especially the functions related to matrix calculations.

However, recently I want to use symbolic arithmetic in the matrix to perform calculations, just like what can be achieved in matlab. Through my search, I found that C++ has a framework like SymEngine that can provide symbolic operations, but it does not seem to be coupled with Eigen to achieve symbolic operations in the matrix.

I would like to ask everyone, have you encountered this kind of problem, or can you provide a corresponding solution? Or not based on these two frameworks?

Thanks!

1

There are 1 best solutions below

0
jwezorek On

Yes, there is no problem with using Eigen and SymEngine together.

I have done it -- it worked, but just be aware that as SymEngine expressions get large computations become slow, possibly prohibitively slow.

In any case, Eigen is a template library. All you have to do is use SymEngine expressions as the type parameter of Eigen matrices e.g.

using number = SymEngine::Expression;
using matrix = Eigen::Matrix<number, 3, 3>;