I'm sorry this is an extremely easy question for you guys however since I have no one I can talk to about it I thought I should ask it here. I've only been learning C++ for a few days now from a book and I am trying to define matrix elements through two loops for the matrix "Smat" as given in the code below. For each 'k' rows and 'j' columns I want the value "Stemp" to be put into the matrix value "Smat[k][j]". However, when I run the code below the code only uses k = 0 and ignores k = 1, k = 2, etc. (it does manage to go through all the j values thankfully). If someone can tell me where I went wrong I'd really appreciate it. This question is very trivial but unfortunately there's no one I can talk to about it in real life with. Thanks in advance.
unsigned long int j = 1;
unsigned long double M = pow(2, 8);
double T = 1;
double dW;
double dt = T / M;
double Smat[100][256]; // Define rows/cols of Smat
double sigma;
double c = -2;
double mu = 2;
double Stemp = S_0;
double theta = 0.01;
for (int k = 0; k < 100; k++) {
Stemp = S_0;
Smat[k][0] = Stemp; // All first rows of Smat start with S_0 value
for (j = 1; j < M; j++) {
double nrv = normaldist();
dW = sqrt(dt)*nrv;
sigma = sigatm + c /(max(sqrt(T), theta))* log(Stemp / S_0);
Stemp = Stemp + Stemp*mu*dt + Stemp*sigma*dW;
Smat[k][j] = Stemp;
}
}