PDA

View Full Version : Arrays & Vectors Dimensions



lixo1
19th February 2009, 17:12
Hi everybody,

I have the following problem: My program is mathematical, so I need to use objects like

#define N 1000.....
.. double a[N]; double b[N][N]; ...
Now, my big problem is the N, if it's too big > 10000 on Windows (with VC++) it gives me application error (runtime error, as I understand the compiler cannot optimise the memory), so I need to use very small vectors/arrays.

My question is: Is there a Qt class that creates a vector like my example, and manage the memory of the PC to obtain an "indefinite" dimension vector/array?

Thank you very much for any kind of help.

talk2amulya
19th February 2009, 17:27
well, i cant definitelys say if it'll solve ur problem..but check out QVector

lixo1
19th February 2009, 17:39
Thank you to the fast reply,
QVector is a good solution I think, but do you know if we can use it as:

QVector<double> a(5)(3); //???
If no, what I can use to create: double a[][] ? (i.e. QMatrix?)

Sheng
19th February 2009, 17:44
Thank you to the fast reply,
QVector is a good solution I think, but do you know if we can use it as:

QVector<double> a(5)(3); //???
If no, what I can use to create: double a[][] ? (i.e. QMatrix?)

use QVector of QVector, such as QVector<QVector<double>> array;
remember resize array before you use it.

talk2amulya
19th February 2009, 17:54
no, QMatrix is entirely for different purpose and i dont think u can write


QVector<double> a(5)(3);

but most of the time, QT's container classes are so helpful that u wont need double-dimension array..here is a list of QT's container class and how they r implemented..u'll find it useful and hopefully it'll solve ur problem

http://doc.trolltech.com/4.4/containers.html

lixo1
19th February 2009, 19:55
Hi,
Thank you very much for all information and help, now it's clear!