Results 1 to 6 of 6

Thread: Arrays & Vectors Dimensions

  1. #1
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    20
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Arrays & Vectors Dimensions

    Hi everybody,

    I have the following problem: My program is mathematical, so I need to use objects like
    Qt Code:
    1. #define N 1000.....
    2. .. double a[N]; double b[N][N]; ...
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Arrays & Vectors Dimensions

    well, i cant definitelys say if it'll solve ur problem..but check out QVector

  3. The following user says thank you to talk2amulya for this useful post:

    lixo1 (19th February 2009)

  4. #3
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    20
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Arrays & Vectors Dimensions

    Thank you to the fast reply,
    QVector is a good solution I think, but do you know if we can use it as:
    Qt Code:
    1. QVector<double> a(5)(3); //???
    To copy to clipboard, switch view to plain text mode 
    If no, what I can use to create: double a[][] ? (i.e. QMatrix?)

  5. #4
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Arrays & Vectors Dimensions

    Quote Originally Posted by lixo1 View Post
    Thank you to the fast reply,
    QVector is a good solution I think, but do you know if we can use it as:
    Qt Code:
    1. QVector<double> a(5)(3); //???
    To copy to clipboard, switch view to plain text mode 
    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.

  6. The following user says thank you to Sheng for this useful post:

    lixo1 (19th February 2009)

  7. #5
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Arrays & Vectors Dimensions

    no, QMatrix is entirely for different purpose and i dont think u can write

    Qt Code:
    1. QVector<double> a(5)(3);
    To copy to clipboard, switch view to plain text mode 

    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

  8. The following user says thank you to talk2amulya for this useful post:

    lixo1 (19th February 2009)

  9. #6
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    20
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Arrays & Vectors Dimensions

    Hi,
    Thank you very much for all information and help, now it's clear!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.