Welcome to the KDE Community Forums, the official forum board for KDE.
You are currently viewing the forums as an unregistered user. Registration allows you to post and discuss topics, receive private messages, vote on ideas, subscribe to topics and many such great features. Registration is a simple process and completely free. So register now and be a part of the community!
You are currently viewing the forums as an unregistered user. Registration allows you to post and discuss topics, receive private messages, vote on ideas, subscribe to topics and many such great features. Registration is a simple process and completely free. So register now and be a part of the community!
help running simple example codes from the Documentation
4 posts • Page 1 of 1
help running simple example codes from the Documentation
Guys, i ran the simple SVD code from the examples and i get the following error:
I am using Ubuntu 9.1 with g++ compiler and i have pretty much forgotten c++
What simple stuff i am missing. Some other examples did work by the way.
Following is the code:
#include </home/syed/eigen2/Eigen/Core>
#include </home/syed/eigen2/Eigen/Array>
#include </home/syed/eigen2/Eigen/SVD>
MatrixXf A = MatrixXf::Random(20,20);
VectorXf b = VectorXf::Random(20);
VectorXf x;
A.svd().solve(b, &x);
SVD<MatrixXf> svdOfA(A);
svdOfA.solve(b, &x);
This is what i get:
syed@syed-desktop:~/eigen2$ g++ lu.cpp -o lu.exe
lu.cpp:5: error: expected constructor, destructor, or type conversion before ‘=’ token
lu.cpp:6: error: expected constructor, destructor, or type conversion before ‘=’ token
lu.cpp:7: error: ‘VectorXf’ does not name a type
lu.cpp:8: error: expected constructor, destructor, or type conversion before ‘.’ token
lu.cpp:9: error: expected constructor, destructor, or type conversion before ‘<’ token
lu.cpp:10: error: expected constructor, destructor, or type conversion before ‘.’ token
I am using Ubuntu 9.1 with g++ compiler and i have pretty much forgotten c++
What simple stuff i am missing. Some other examples did work by the way.
Following is the code:
#include </home/syed/eigen2/Eigen/Core>
#include </home/syed/eigen2/Eigen/Array>
#include </home/syed/eigen2/Eigen/SVD>
MatrixXf A = MatrixXf::Random(20,20);
VectorXf b = VectorXf::Random(20);
VectorXf x;
A.svd().solve(b, &x);
SVD<MatrixXf> svdOfA(A);
svdOfA.solve(b, &x);
This is what i get:
syed@syed-desktop:~/eigen2$ g++ lu.cpp -o lu.exe
lu.cpp:5: error: expected constructor, destructor, or type conversion before ‘=’ token
lu.cpp:6: error: expected constructor, destructor, or type conversion before ‘=’ token
lu.cpp:7: error: ‘VectorXf’ does not name a type
lu.cpp:8: error: expected constructor, destructor, or type conversion before ‘.’ token
lu.cpp:9: error: expected constructor, destructor, or type conversion before ‘<’ token
lu.cpp:10: error: expected constructor, destructor, or type conversion before ‘.’ token
Re: help running simple example codes from the Documentation
Just put:
Looking at the docs, i dont think they need to be fixed, the code doesn't claim to be anything more than an incomplete snippet.
- Code: Select all
using namespace Eigen;
Looking at the docs, i dont think they need to be fixed, the code doesn't claim to be anything more than an incomplete snippet.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
Have a serious interest in Eigen? Then join the mailing list!
Re: help running simple example codes from the Documentation
Well i added the code "using namespace Eigen;" and now i am getting the following error. So whats wrong now:
CODE:
#include </home/syed/eigen2/Eigen/Core>
#include </home/syed/eigen2/Eigen/Array>
#include </home/syed/eigen2/Eigen/SVD>
using namespace Eigen;
MatrixXf A = MatrixXf::Random(20,20);
VectorXf b = VectorXf::Random(20);
VectorXf x;
A.svd().solve(b, &x);
SVD<MatrixXf> svdOfA(A);
svdOfA.solve(b, &x);
ERROR:
svd1.cpp:8: error: expected constructor, destructor, or type conversion before ‘.’ token
svd1.cpp:10: error: expected constructor, destructor, or type conversion before ‘.’ token
CODE:
#include </home/syed/eigen2/Eigen/Core>
#include </home/syed/eigen2/Eigen/Array>
#include </home/syed/eigen2/Eigen/SVD>
using namespace Eigen;
MatrixXf A = MatrixXf::Random(20,20);
VectorXf b = VectorXf::Random(20);
VectorXf x;
A.svd().solve(b, &x);
SVD<MatrixXf> svdOfA(A);
svdOfA.solve(b, &x);
ERROR:
svd1.cpp:8: error: expected constructor, destructor, or type conversion before ‘.’ token
svd1.cpp:10: error: expected constructor, destructor, or type conversion before ‘.’ token
Re: help running simple example codes from the Documentation
Indeed you get these erros when you try to compile this code as-is... that's because you need to put the code in a main() function! So just put int main() {........} and that works.
The tutorials, and more generally using Eigen, requires some familiarity with c++, that's true.
The tutorials, and more generally using Eigen, requires some familiarity with c++, that's true.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
Have a serious interest in Eigen? Then join the mailing list!
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests

Search
FAQ
Policy
KDE.org
KDE.news
Planet KDE
More 
Ubuntu