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

Specialized Template Function for Block and Matrix

Tags: None
(comma "," separated)
Gabyx
Registered Member
Posts
10
Karma
0
Hello

I am trying to get the following behaviour with EIGEN:

I want a function like:

Code: Select all
template<typename Derived, int N>
void func( Matrix<Derived, 6 , N > & A)


I want that only Structures with a size 6xN can be supplied to the function.
But how can this work with expressions for example:

Code: Select all
func(  B.block<6,10>(0,0) )   


I dont want a general template for all structures like
Code: Select all
template<typename Derived>
void func( MatrixBase<Derived> & A)


Do I have to specialise the same function for Block and VectorBlock as well? So 3 overloads?
Code: Select all
template<typename Derived, int N>
void func( Block<Derived, 6 , N > & A) ;
void func( VectorBlock<Derived, 6 , N > & A) ;


What is the ellegant and correct solution?

Thanks for your help!!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
write a generic function for MatrixBase<> or even DenseBase<> objects, an then use a static assertion:

EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,6)

This is what we do in Eigen.

Another solution is to use the enable_if mechanism of boost.
Gabyx
Registered Member
Posts
10
Karma
0
Thanks alot!

Helped alot!


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar