Registered Member
|
I would like to be able to write some C++ code that takes two pointers to Eigen matrices of unspecified type, either dense or sparse, do some matrix arithmetic (let's say matrix multiply), and store the result. And I would like to write the code as a simple matrix multiply operation and rely on polymorphism to keep track of the kinds of matrices that are involved, so that Eigen arranges for a sparse/sparse multiply if both matrices are sparse, a dense/sparse multiply if one if dense and the other sparse, and a dense/dense multiply if they are both dense. Likewise for other matrix manipulations.
If the sparse and dense matrix classes had a common base class with a virtual matrix multiply method I think this would be simple enough. However, as far as I can tell, that is not the situation. Is there a clean, simple way to accomplish this with Eigen? jjo |
Moderator
|
Indeed, Eigen takes numerous decisions at compile-time starting by the return-type. So if you cannot make your function template and really need to take runtime decisions, then maybe one solution would be to still write such a template function internally, and then dispatch to the actual instantiation with a if/then/else.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]