C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

function that returns the determinant of a matrix

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
rikstick
Guest





PostPosted: Mon Dec 20, 2004 12:48 am    Post subject: function that returns the determinant of a matrix Reply with quote



Does anyone know of a function that will return the determinant of a
double scripted matrix with dimensions of 3x3 or greater? I would
really appreciate the source code if you know of such a function.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
NJS
Guest





PostPosted: Tue Dec 21, 2004 10:31 am    Post subject: Re: function that returns the determinant of a matrix Reply with quote



Type in "determinant cofactor expansion" into google, and you'll get
links to a technique for solving determinants for arbitrary NxN
matrices. There are probably numerically better ways of doing this.
Personally, I would just use a linear algebra package; try searching on
"LAPACK".

- Niek Sanders


rikstick wrote:
Quote:
Does anyone know of a function that will return the determinant of a
double scripted matrix with dimensions of 3x3 or greater? I would
really appreciate the source code if you know of such a function.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Branimir Maksimovic
Guest





PostPosted: Tue Dec 21, 2004 10:33 am    Post subject: Re: function that returns the determinant of a matrix Reply with quote




rikstick wrote:
Quote:
Does anyone know of a function that will return the determinant of a
double scripted matrix with dimensions of 3x3 or greater? I would
really appreciate the source code if you know of such a function.

One of my first steps in c++ back in 1994 was writing
matrix class and calculating determinant, inverse matrix
and such things. Is this some homework question ?
Just look at the neariest math book and write that
thing as you already know what is double scripted matrix.
Greetings, Bane.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Francis Glassborow
Guest





PostPosted: Wed Dec 22, 2004 2:54 am    Post subject: Re: function that returns the determinant of a matrix Reply with quote

In article <1103561473.539641.158930 (AT) z14g2000cwz (DOT) googlegroups.com>, NJS
<njs8030 (AT) yahoo (DOT) com> writes
Quote:
Type in "determinant cofactor expansion" into google, and you'll get
links to a technique for solving determinants for arbitrary NxN
matrices. There are probably numerically better ways of doing this.
Personally, I would just use a linear algebra package; try searching on
"LAPACK".

Many years ago I came across the case of a student at an Australian
university doing an engineering degree who kept exceeding his resource
limits. He was very puzzled because he had tested his code for
evaluating an n by n determinant and it worked fine. However, whenever
he tried to apply it to his engineering problem he exceeded his resource
allowance and had to go to his supervisor for more. The third time this
happened his supervisor asked to see the code.

He had written a simple recursive expansion using co-factors. Tested it
with 3x3, 4x4 and 5x5 test cases. He then tried to apply it to the real
problem that was a 24x24. I seriously doubt that there is any machine in
existence today that could evaluate a 24x24 determinant by cofactor
expansion.

C++ is not a miracle language. Solving problems requires expertise in
the problem domain as well as in C++. The OP will need to study a bit
more math before cutting code.


--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
NJS
Guest





PostPosted: Thu Dec 23, 2004 9:13 pm    Post subject: Re: function that returns the determinant of a matrix Reply with quote

You're right about cofactor expansion being the wrong tool for the job.
I knew using cofactors would be expensive, but it didn't occur to me
that the algorithm is factorial.

According to Maple and my friendly linear algebra textbook, a more
reasonable approach is using gaussian elimination (through LU
decomposition), which leads to a polynomial time algorithm.

- Niek


Francis Glassborow wrote:
[snip]
Quote:

He had written a simple recursive expansion using co-factors. Tested
it
with 3x3, 4x4 and 5x5 test cases. He then tried to apply it to the
real
problem that was a 24x24. I seriously doubt that there is any machine
in
existence today that could evaluate a 24x24 determinant by cofactor
expansion.

[snip]



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.