Registered Member
|
http://eigen.tuxfamily.org/dox/TopicCustomizingEigen.html#ExtendingMatrixBase gives example about how to extend MatrixBase.
My situation is to add member methods only to double type matrix( Matrix.h instead of MatrixBase). So it is a partial specialization issue. I don't want to redefine the whole class. A workaround could be static_assert or any compile time check if _Scalar is double. However, as a drawback, Intellisense would display the method for unsupported types too. By the way, I have another problem about how to deal with non-contiguous memory. My implementation needs data stored in contiguous memory. So I can't add my methods in MatrixBase.h because innerStride of Block may be greater than 1. For const input of function(just reading access), Ref<const MatrixXd> seems able to do the job by making a copy if innerStride >1. For writable object, should I create a new object to do the calculation and then copy the calculated value back? I don't know the best practice. |
Moderator
|
I don't see any better solution that a static_assert. This is what we already do throughout Eigen, for instance for vector specific method, and/or size specific methods.
|
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient