Hey guys.
Yet again, I have this type of problem, I was wondering if anyone could give me a hand with it?
The problem lies on line 69, "sum += matrix[i][j] * y[i];", more specifically at "matrix[i][j]". This is basically a function that retrieves the matrix and the size of the matrix from a text file, then applies the Jacobi iterative method.
Everything seems to work fine, with the exception of the app crashing whenever it hits that part.
Here's the code (the part that matters): code removed. will add it back once I deliver the assigment
Any idea what the problem could be?
Matrix has the size[n,n] so this makes absolutely no sense - to me that is.
nmax is never set to anything besides 0 in the code you show, so we're missing some relevant code. The size of vector x is nmax, so if nmax is less than n then you will be accessing out of range in vectors x and y in that loop.
There is also the possibility that you exceed the bounds of tmp in the while (isstream) loop, since you make no effort to ensure it stays in bounds. You also don't check, in the same code, to make sure there were no less than 3 istringstream extractions. There is also no attempt to make sure the bounds for vector matrix are observed at line 29.
Line 14 assumes the input extraction on line 11 was correct, but you don't check to see if it was.
@cire - As stupid as it sounds, I actually figured out the issue whilst reading your comment. Don't worry, nmax and epsilon are user inputted values and they are never 0. Problem was a missspecification, I actually checked everything but that,jeez.