•

Check out our Community Blogs

Register and join over 40,000 other developers!

### Recent Blog Entries

• phi

I love this community !

• JackJames

hi i am jack i am seo expert jack james would love you to read new post

# How to calculate matrix determinant? n*n or just 5*5.

pascal matrix

CC Lurker

• Just Joined
• 2 posts

Posted 19 February 2011 - 08:19 AM

Hi, everyone. I need to find matrix n*n (or 5*5) determinant. I have a function translated from Pascal, but there's INDEX OUT OF RANGE EXCEPTION. Could somebody help me?
Here's my code:
public static double DET(double[,] a, int n)
{
int i, j, k;
double det = 0;
for (i = 0; i < n - 1; i++)
{
for (j = i + 1; j < n; j++)
{
det = a[j, i] / a[i, i];
for (k = i; k < n; k++)
a[j, k] = a[j, k] - det * a[i, k]; // Here's exception
}
}
det = 1;
for (i = 0; i < n; i++)
det = det * a[i, i];
return det;
}
Thanx for any help.
• 0

### #2 WingedPanther73

WingedPanther73

A spammer's worst nightmare

• Moderator
• 17757 posts
• Location:Upstate, South Carolina
• Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
• Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 20 February 2011 - 06:35 AM

Without seeing the code that is calling the above function, there's no way to know.
• 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

### Also tagged with one or more of these keywords: pascal, matrix

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download