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!


sfhaider

Registered Member

Posts: 3

Karma: 0

Gender:  Male

OS: Ubuntu Ubuntu

United States

help running simple example codes from the Documentation

Post Wed Nov 04, 2009 1:46 am

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

Moderator User avatar

bjacob

Moderator

Posts: 293

Karma: 0

France

Re: help running simple example codes from the Documentation

Post Wed Nov 04, 2009 1:57 am

Just put:
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!



sfhaider

Registered Member

Posts: 3

Karma: 0

Gender:  Male

OS: Ubuntu Ubuntu

United States

Re: help running simple example codes from the Documentation

Post Wed Nov 04, 2009 3:45 am

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

Moderator User avatar

bjacob

Moderator

Posts: 293

Karma: 0

France

Re: help running simple example codes from the Documentation

Post Wed Nov 04, 2009 5:31 am

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.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Who is online

Users browsing this forum: No registered users and 4 guests