CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Large matricies

  1. #1
    Join Date
    Aug 2003
    Posts
    938

    Large matricies

    Hello.
    I need to make a large matrix. somethign of size 1024 by 1024 and i need a couple of them. THe code works fine when i do thsi:
    Code:
    int matrix[3][1024][1024];
    but when i make 3 arrays instead of a 3 dimensional array the program crashes.
    ex:
    Code:
    int matrix[1024][1024];
    int matrx[1024][1024];
    int matry[1024][1024];
    Any ideas how to circomvent this?
    Thx

  2. #2
    Join Date
    Jan 2004
    Location
    Düsseldorf, Germany
    Posts
    2,401

    Re: Large matricies

    Allocate memory on the heap instead:
    Code:
    int * matrix = new int[1024*1024];

  3. #3
    Join Date
    Feb 2006
    Location
    London
    Posts
    238

    Re: Large matricies

    Or even better: use std::vector instead.

  4. #4
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: Large matricies

    Or use global array. Or use vector (as a way of/instead of manually allocating memory).
    "Programs must be written for people to read, and only incidentally for machines to execute."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured