This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Add extra methods to Matrix<double ...>

Tags: eigen eigen eigen
(comma "," separated)
kikiki
Registered Member
Posts
4
Karma
0
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient