Registered Member
|
I'm just getting started with Eigen3, and I really like it.
Here's a newby question: why does the following code not work? If I replace the static sized matrix with a dynamic sized via Eigen::MatrixXd m(2,2) it does work. I get a compiler error on the m.lpNorm<1>() call. I am using gcc 4.5 and the latest download of Eigen3 from the web page.
Thanks for a great library. |
Registered Member
|
Your program works fine here, also with gcc 4.5. What error do you get?
I don't know whether you noticed, but mat.lpNorm<1>() computes the L1 norm of the matrix considered as a vector, i.e. the sum of the absolute value of all the coefficients. This may not be what you want. |
Registered Member
|
You are correct. I was trying to excerpt a code snippet, and I didn't test it. The actual error was buried deep in some code, but I was able to extract out a simple case that showed the error. Here's the code that errors out:
The is the error message that g++ emits:
If you don't make the function a template, then the error goes away. Also, you can change the call to lpNorm<> to norm(), and it will compile. FYI, the error in my code is not in a template function, it is in a member function of a template class, so I don't think it is a template function problem. Thanks for the help. |
Registered Member
|
I don't have a compiler handy at the moment, but I think you're missing the 'template' keyword for calling template member functions of a dependent type.
If you add the word 'template' as shown below it should work (consult your favourite C++ reference to learn why). If not let me know, and I (or somebody else) will look into it further.
|
Registered Member
|
You are right. I have to say that I didn't know about that usage of the template keyword. I'll be looking that up tonight. Thank you.
|
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar