Registered Member
|
Hi,
I'm trying to write a new constructor for my application. I need that the users can write a code like :
and A will be a matrix Nx1, but the constructor doesn't like this expression and returns me a YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX error. So I decided to add a new constructor in EIGEN_MATRIX_PLUGIN or EIGEN_MATRIXBASE_PLUGIN with no result. So I try to modify Matrix.h : I remove the constructor EIGEN_STRONG_INLINE explicit Matrix(int dim) and modify the other EIGEN_STRONG_INLINE Matrix(int x, int y) by adding and default value for y: EIGEN_STRONG_INLINE Matrix(int x, int y = 1), but it still doesn't work. I think it comes from ColsAtCompileTime but I don't know where that variable is updated. If you have any response or a better idea, I'm open Thanks |
Registered Member
|
If you want your own matrix class with custom constructors, the easiest way would be to define a new class inheriting Matrix. Since constructors aren't inherited, you could do whatever you want to.
http://eigen.tuxfamily.org/dox-devel/To ... FromMatrix
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Moderator
|
I'm puzzled, if you write:
MatrixXd A(n) then you know that A is a vector, so why not using a vector which will bring higher performance as a bonus ? |
Registered Member
|
Thank you, It can be a solution, but I think that will first add new problems ^^
But I've some questions : if I use a class, are the template preserve ? I mean if my new class is "matrix", and if i write matrix u = v + w; the asm code will be u[i] = v[i] + w[i] ? What are the functions i need to add ? (in the doc you said "a few members") for instance to avoid "impossible to convert 'const Eigen::CwiseNullaryOp<NullaryOp,MatrixType>' in 'matrix'" @ggael : I know that it's strange, but it's because i'm updating a previous library and thousands of lines of code already exist, and i can't rewrite all. For the future code, it will be naturally better to use Eigen syntax or at least vector instead of always matrix. EDIT : The error is corrected, I forget some constructors and operators = (for Scalar), (it's quit easy in fact !), but i've still my question about the template |
Registered Member
|
Yes, expression templates are still working. Just check it for yourself (look at the generated assembly!)
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Moderator
|
OK, I understand, inheriting Matrix is also what I did when starting to use Eigen and keep some minimal level of compatibility
|
Registered Member
|
@bjacob & ggael : Thank you for your answers I will check the assembly code but only when i'll go back on linux ^^ (i'm on windows for this project and it seems to be complicated to produce an asm file... (where is gcc -S ? ^^))
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]