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

Another question on functions taking Eigen templatized types

Tags: None
(comma "," separated)
linello
Registered Member
Posts
56
Karma
0
OS
Hi, I have a simple question.

I want to define a function taking a Eigen matrix (a kernel matrix K) and if that kernel matrix is separable (i.e. rank(K)==1), returns the column and row vectors respectively X,Y such that K=X*Y but I want to do it in a templatized and more general possible way.

Code: Select all
template <typename Derived >
void separateKernel(  MatrixBase<Derived>& kernel, [b]EIGENROWVECTORTYPE[/b] & rowVector, [b]EIGENCOLUMNVECTORTYPE[/b] & columnVector )
{
// some computations
}


where clearly the EIGENCOLUMNVECTORTYPE and EIGENROWVECTORTYPE words are placeholders for the correct inferred type.

In the case kernel matrix is of type Matrix<float,10,10> for example, row vector should be Matrix<float,1,10> and column vector Matrix<float,10,1>.

How can I do that? Is it possible in a templatized fashion?

Otherwise other prototypes are warmly welcome ;)
di4jc8732
Registered Member
Posts
11
Karma
0
I second this question. I too would like to tighten declaration, which now reads
Code: Select all
template <typename Derived>
Derived::Scalar fcn(MatrixBase<Derived> const& lhs, MatrixBase<Derived> const& rhs){
...
}

to some thing like
Code: Select all
Derived::Scalar fcn(VectorExpression const& lhs, VectorExpression const& rhs){...}


It is not obvious to me this is possible, but I would love to be proven wrong.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Matrix<typename Derived::Scalar,1,Derived::ColsAtCompileTime>

but that prevent to call the function with e.g., blocks or arrays.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]