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

Global variables

Tags: None
(comma "," separated)
theokoles
Registered Member
Posts
6
Karma
0
OS

Global variables

Mon May 02, 2011 7:13 pm
hi,
thks in advance for answers

Q1/

I want to use global Eigen::VectordXd/MatrixXd in a external test.h file. thus I did :


Code: Select all
extern Eigen:: MatrixXd MyMatrix; // in my test.h file


I also :

Code: Select all
#include "test.h"
using namespace Eigen;

MatrixXd MyMatrix;  // in my test.cpp file


then I can use MyMatrix in my main.cpp (including test.h)

Actually, I just want to know if it's necessary to pass upon an other test.cpp file in order to use the Matrix in my main. I tried without --> failure mess compilation, MyMatrix was not declared in this scope ...
I dont understand why ... ?


Q2/

Using fullPivLU on a dense dynamic matrix (A) several times in a loop.
the matrix size evolves whithout exceeding a known dimension for exemple (3000x3000)

will I get faster results using the optional template parameters :

Matrix <double, Dynamic, Dynamic, 0, 3000,3000 > A;

should I avoid static fixed size on dense Matrices ?

thks,
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Global variables

Wed May 04, 2011 10:06 am
Q1: yes, MyMatrix have to be declared in one cpp file. It can be any cpp file of your project.

Q2: it is not a good idea to declare such a big matrix on the stack. The performance gain would be epsilon anyway.
theokoles
Registered Member
Posts
6
Karma
0
OS

Re: Global variables

Wed May 04, 2011 6:47 pm
Thks, =)


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora