Click to See Complete Forum and Search --> : Large matricies


Quell
February 24th, 2006, 10:20 AM
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:

int matrix[3][1024][1024];

but when i make 3 arrays instead of a 3 dimensional array the program crashes.
ex:

int matrix[1024][1024];
int matrx[1024][1024];
int matry[1024][1024];

Any ideas how to circomvent this?
Thx

treuss
February 24th, 2006, 10:37 AM
Allocate memory on the heap instead:int * matrix = new int[1024*1024];

DragForce
February 24th, 2006, 11:27 AM
Or even better: use std::vector instead.

RoboTact
February 24th, 2006, 11:29 AM
Or use global array. Or use vector (as a way of/instead of manually allocating memory).