I am running a c code that requires a matrix of size 2000*2000. I have used both malloc and direct allocation. But while compilation it shows "segmentation failure(core-dumped)". I am running it on the terminal of Linux system with 128 gb ram
The first code is below
#include<stdio.h>
int main(int argc,char ** argv){
int N = 2000;
int A[N][N];
}
The second one is
#include<stdio.h>
int main(int argc,char ** argv){
int i,j;
int Nx = 2000;
int Ny = 2000;
int npoint = Nx*Ny;
double** A =(double**) malloc(npoint*sizeof(double));
for (j = 0;j< npoint;j =j+1){
A[j] = (double*)malloc((npoint)*sizeof(double*));
}
for( j= 0;j<npoint;j++){
for (i=0;i<npoint;i++){
A[i][j] = 0;
}}
}
Using gcc to compile this the first one directly shows segmentation failure(core dumped) but the other one starts but after some time gets terminated.