Brok Posted July 28, 2015 Share Posted July 28, 2015 I have something like: for(j=0; j<columnsNumber; j++) { for(i=0; i<rowsNumber; i++) { bufferMatix[j][i] = sourceMatrix[i][j]; } But it works only when rowsNumber=colsNumber Thanks! Quote Link to comment Share on other sites More sharing options...
Josh Posted July 29, 2015 Share Posted July 29, 2015 I think that will cause problems because you are copying things that were previously copied. You will need a temporary buffer. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andrr Posted July 29, 2015 Share Posted July 29, 2015 You can just swap matrix elements is memory like it's demonstrated here. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted July 29, 2015 Share Posted July 29, 2015 You still have a temporary variable, you're just using a lot of them in a function instead of one big buffer. Just for fun, there IS a way to switch to variables without declaring a third. int a = 3; int b = 7; a += b; b = a - b; a -= b; I don't recommend doing that because you could create a number that exceeds the range of your data type. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Brok Posted July 29, 2015 Author Share Posted July 29, 2015 Andrr, Josh Thank you! You're realy help me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.