Visit Our UNIX and Linux User Community


How to define a very big matrix in C?


 
Thread Tools Search this Thread
Top Forums Programming How to define a very big matrix in C?
# 1  
Old 09-26-2009
How to define a very big matrix in C?

Hello!!
I need to do some performance test using a very big matrix (bi-dimensional array) but I have problems with this.
Is there any limitation in declarations? because if I do this:

Code:
int matriz[10000][10000];

It just don't work... it compiles but when i run the program it just closes.
Where can i read about this??

BTW I'am working on a windows xp 32bits pc with 3 gb of ram.

Thanks a lot!
# 2  
Old 09-26-2009
If you make it a local variable it will try to put the whole thing in stack space, fail, and quit, since Windows isn't going to let you have 400 megabytes of temporary variables. Try making it a global variable.
# 3  
Old 09-26-2009
great info, I made a matrix of 10001x3355 enough for my experiment!

thanks!!!
# 4  
Old 09-27-2009
Or you can create it on the heap using malloc().
# 5  
Old 10-02-2009
Quote:
Originally Posted by pludi
Or you can create it on the heap using malloc().
Good idea! that's what I did after reading you! Smilie

I leave the code here, maybe someone needs the same thing!

Code:
#define R 10000
#define P 10000

int main()
{      int **mat;
       int j;

       mat = (int **)malloc(R*sizeof(int*));
       for(j=0;j<R;j++)
              mat[j]=(int*)malloc(P*sizeof(int));
        
}

bye!!

Previous Thread | Next Thread
Test Your Knowledge in Computers #789
Difficulty: Medium
Steve Wozniak was employed at Sun Microsystems before he founded Apple Computers.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge multiple tables into big matrix

Hi all, I have a complex (beyond my biological expertise) problem at hand. I need to merge multiple files into 1 big matrix. Please help me with some code. Inp1 Ang_0 chr1 98 T A Ang_0 chr1 352 G A Ang_0 chr1 425 C T Ang_0 chr2 ... (1 Reply)
Discussion started by: newbie83
1 Replies

2. Shell Programming and Scripting

awk? adjacency matrix to adjacency list / correlation matrix to list

Hi everyone I am very new at awk but think that that might be the best strategy for this. I have a matrix very similar to a correlation matrix and in practical terms I need to convert it into a list containing the values from the matrix (one value per line) with the first field of the line (row... (5 Replies)
Discussion started by: stonemonkey
5 Replies

3. Ubuntu

How to convert full data matrix to linearised left data matrix?

Hi all, Is there a way to convert full data matrix to linearised left data matrix? e.g full data matrix Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7 Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245 Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Discussion started by: evoll
8 Replies

4. Programming

help with #define in C

if i do this in C #define NUM 1234512345 then how come i cant print it out using int main(int argc, char **argv) { printf("%d\n", NUM); return 0; } well the result is -1219236538, why isnt it 1234512345 ? (7 Replies)
Discussion started by: omega666
7 Replies

5. UNIX for Dummies Questions & Answers

How big is too big a config.log file?

I have a 5000 line config.log file with several "maybe" errors. Any reccomendations on finding solvable problems? (2 Replies)
Discussion started by: NeedLotsofHelp
2 Replies

6. Programming

#define

Hello, I would like to conditionaly comment in my code source some fields from arrays. So I use the property ## from the #define definition. my code: ... #define slet /##* #define etsl *##/ ... const T_SVT_ADLL_A653_DESC A_DESC = { { slet qwerty etsl SLICING,... (3 Replies)
Discussion started by: cypleen
3 Replies

7. Shell Programming and Scripting

diagonal matrix to square matrix

Hello, all! I am struggling with a short script to read a diagonal matrix for later retrieval. 1.000 0.234 0.435 0.123 0.012 0.102 0.325 0.412 0.087 0.098 1.000 0.111 0.412 0.115 0.058 0.091 0.190 0.045 0.058 1.000 0.205 0.542 0.335 0.054 0.117 0.203 0.125 1.000 0.587 0.159 0.357... (11 Replies)
Discussion started by: yifangt
11 Replies

8. UNIX for Dummies Questions & Answers

How to view a big file(143M big)

1 . Thanks everyone who read the post first. 2 . I have a log file which size is 143M , I can not use vi open it .I can not use xedit open it too. How to view it ? If I want to view 200-300 ,how can I implement it 3 . Thanks (3 Replies)
Discussion started by: chenhao_no1
3 Replies

Featured Tech Videos