By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 2,075 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

My determinant code isn't working

P: n/a
i have been trying to get the correct code for a 3x3 matrix and upon checking for information from the net, i realised it was almost like my code..i mean the logic was the same but when i run it, i get a random negative number which is far from the answer.
Below is the code snippet for that portion:
Expand|Select|Wrap|Line Numbers
  1. double determinant =(x[0][0]*x[1][1]*x[2][2]) + (x[0][1]*x[1][2]*x[2][0]) + (x[0][2]*x[1][0]*x[2][1]) - 
  2. (x[0][0]*x[1][2]*x[2][1]) - (x[0][1]*x[1][0]*x[2][2]) -
  3.        (x[0][2]*x[1][1]*x[2][0]);
i hope i can get help from here
Oct 11 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
Your calculation looks OK but you don't show your matrix.

A random negative value usually means uninitialized variables.
Oct 11 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.