Do you want to know how to write a 1d matrix out to that file or read the file into the 1d matrix?
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
My quess is it depends on what N and M are...
matrix[i*N+j] = (double) array[i+j];
----^---
Why? Aren't they both doubles?
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Oops, I just saw the problem.
During the loop, what does i+j equal? Print it in your cout
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Think about it! What did you do for matrix?
Write the loop out on a piece of paper and follow it with a pencil, changing i,j,and the index and you'll see what's wrong.
This is called desk checking and is the single greatest debugging aid you can use. Printing the values like you did is the second.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Thoughts? =)
Either.
Which seems easier? More straight-forward?
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
So when you get there, you can continue with this program, eh? :icon_wink:
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944