int si = 0, sj = 0;
for(int i=0; i < 4; i++)
{
for(int j=0; j < 4; j++)
{
assert(si < 3 && sj < 3);
if(j != 1) sj++;
}
if(i != 1) si++;
}
I always get this assertion message when I execute this. I found out, that sj gets incremented even if j == 1... strange, isn''t it? I want sj to be a maximum of 2! si is smaller than 3 but sj always gets incremented anyway. What''s wrong with this code?
Thanks,
Flo
WHY? Please help :(
Hi,
I''m just working on my matrix class and I have a strange problem. Check out this little code snippet:
Are you sure sj is incremented when j == 1 ?
I''m not surprised you hit the assertion, j will be incremented 12 times (3 (= 4 - 1) in the inner loop) times (4 in the main loop).
But what do you exactly want to do in fact ?
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.
The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
I''m not surprised you hit the assertion, j will be incremented 12 times (3 (= 4 - 1) in the inner loop) times (4 in the main loop).
But what do you exactly want to do in fact ?
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.
The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
Man, I''m so fu****g stupod 
You''re totally right, it get''s incremented 12 times *with-head-on-table-crash*
I was just wondering if this is a compiler error and I''m on updating it now. I''ll update anyway, because newslog says the new version will be much faster on x86 CPUs.
I have a m[4][4] array, that represents my matrix. Now I want to build a 3x3 submatrix and skip a certain row anc columb. This is why I check if j != 1. Actually it should be if(j != excluded_columb)
This thread is now open anyway (because I''m so stupid
), so you could help me how to do it without incrementing j 12 times 
Thanks rodzilla

You''re totally right, it get''s incremented 12 times *with-head-on-table-crash*

I was just wondering if this is a compiler error and I''m on updating it now. I''ll update anyway, because newslog says the new version will be much faster on x86 CPUs.
I have a m[4][4] array, that represents my matrix. Now I want to build a 3x3 submatrix and skip a certain row anc columb. This is why I check if j != 1. Actually it should be if(j != excluded_columb)

This thread is now open anyway (because I''m so stupid


Thanks rodzilla
Would this do what you want ?
(edited to add the source tags).
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.
The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
[edited by - rodzilla on September 13, 2003 12:13:00 PM]
float m1[4][4];float m2[3][3];for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { m2[i][j] = m1[(i<exclude_i)?i:i+1][(j<exclude_j)?j:j+1] }}
(edited to add the source tags).
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.
The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
[edited by - rodzilla on September 13, 2003 12:13:00 PM]
SaM3d!, a cross-platform API for 3d based on SDL and OpenGL.The trouble is that things never get better, they just stay the same, only more so. -- (Terry Pratchett, Eric)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement