Registered Member
|
Hello,
Which argument type should I use to pass either a SparseMatrix<> or a MappedSparseMatrix<> to functions/methods? I know dense matrices can use the Ref<> class, but it doesn't seem to work for sparse matrices. Additionally, I cannot use templates since some methods will implement purely virtual methods. For now I am considering using MappedSparseMatrix<> and converting any SparseMatrix<> to a MappedSparseMatrix<> since it only requires pointer copies. Is there an alternative in Eigen? Best regards, João Leal |
Moderator
|
Ref<SparseMatrix> is on the todo list. In the meantime, you can implement the MappedSparseMatrix version, and add an overload for SparseMatrix calling the MappedSparseMatrix method through the SparseMatrix::*Ptr() accessors.
|
Registered Member
|
Thank you for the reply!
I just realized that I have some issues doing operations with maps to const scalars and non-const. Sometimes I have access to pointers of const doubles which could be used to create a MappedSparseMatrix, but then I get errors. Here is an example.
There is an issue determining the resulting data type. I believe the important part of the error message is: /usr/include/eigen3/Eigen/src/Core/ProductBase.h:27:98: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<const double, double>’ typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; What is the best way to define this information? |
Registered Member
|
Currently I am using:
Not sure If this will have unforeseen side effects. |
Moderator
|
for the record, Ref<SparseMatrix<double> > and Ref<const SparseMatrix<double> > are now supported in the devel branch. Same for Map<SparseMatrix> and Map<const SparseMatrix>
MappedSparseMatrix is now deprecated and it does not accept const scalar types. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]