c++ - segmentation fault when calling a function -


Segmentation error shows when calling Update_Multiplier and gdb debugger:

Program received signal SIGSEGV

< P>, division fault. Update_Multiplier () ()

  double roundabout = 116325; 0x080b74e8; Dual purpose = 1.1707e + 07; Int main () {Update_Multiplier (); } Zero Update_Multiplier () {cout & lt; & Lt; "Function 0" & lt; & Lt; Endl; // Detective vectors double gra [1000] [1000]; Double GRB [1000] [1000]; Double dum x = 0; Double step [1000] [1000]; Double tuning = 2; Double LReddom [1000] [1000]; Double LRBDIM [1000] [1000]; Cout & lt; & Lt; "Function 1" & lt; & Lt; Endl; // subgradient vectors for (last I = 1; i & lt; = noOfNodes; i ++) {for (int j = 1; j & lt; = noOfNodes; j ++) {if (c [i] [J]! = 0) {dumX = 0; For (int p = 1; p & lt; = noOfCommodity; p ++) {dumX + = X [i] [J] [P]; } Gra [i] [j] = dumX-u [i] [j] * y [i] [j] -q [i] [j]; GRB [I] [J] = Q [I] [J] -B [I] [J] * Y [I] [J]; }}} // update stepsize cout & lt; & Lt; "Function 2" & lt; & Lt; Endl; For (int i = 1; i & lt; = noOfNodes; i ++) {for (int j = 1; j & lt; = noOfNodes; j ++) {if (c [i] [j]! = 0) [stepsize [i] [j]] = (Tuning * (UpperBound-Objective)) / sqrt ((gra [i] [j] * gra [i] [ja]) * (GRB [i] [j] * GRB [i] [ja])); LRADum [i] [j] = LRA [i] [j] stepsize [i] [j] * gra [i] [j]; LRA [i] [j] = lradum [i] [j]; LRBDum [I] [J] = LRB [I] [J] stepsize [I] [J] * GRB [I] [J]; LRB [I] [J] = LRBDum [I] [J]; }}}}}  

I see two suspicious things in your code.

First of all, you are taking too many stack space (about ~ 40 MB). Secondly, you are starting the index of the array at 1, where it should be for <:

   

To change it:

 for  (int i = 0; i  
< / Div>

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -