public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Determinant of a matrix
@ 2002-10-22  3:12 Przemyslaw Sliwa
  2002-10-22  7:20 ` Gert Van den Eynde
  0 siblings, 1 reply; 5+ messages in thread
From: Przemyslaw Sliwa @ 2002-10-22  3:12 UTC (permalink / raw)
  To: gsl-discuss

Hello,

The determinant of a symmetric positive definite matrix is just the
product of the squares of the diagonal elements form the cholesky
decomposition (NAG documentation). So why I'm getting different
results form gsl_LU decomposition and the cholesky decomposition
of a 10*10 Hilbert matrix (elemenst i,j given by 1/(i+j-1)).
The results are not very big, but still they exist (determinant about 
0.5E+13 and
the difference 6.0E+1). Is it a bug, or the LU decomposition is unstable.
What should be suggested: determinant of a covariance matrix: its
Cholesky form or computation from LU decomposition.

Thanks for help

Przem


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determinant of a matrix
  2002-10-22  3:12 Determinant of a matrix Przemyslaw Sliwa
@ 2002-10-22  7:20 ` Gert Van den Eynde
  0 siblings, 0 replies; 5+ messages in thread
From: Gert Van den Eynde @ 2002-10-22  7:20 UTC (permalink / raw)
  To: Przemyslaw Sliwa; +Cc: gsl-discuss


Could you send us some lines of code that gives this behaviour and some more machine/compiler specs (see the Bug reporting part in the README file).

Remark 1: If I understand correctly, you calculate a determinant of 0.5E+13 and the error between Cholesky and LU is 6.0E+1 (a relative error of about 1.0E-11). 

Remark 2: The condition number of a Hilbert matrix of size 10 x 10 is about 1.0E+10. Roughly said, if you solve a linear system using LU factorisation (Gauss) with this matrix, you can loose about 10 decimal digits in your result... With the traditional double precision (u = 2.2E-16), this leaves you with 4 digits you can trust.... Hilbert matrices are *not* nice. 

Gert


On Tue, 22 Oct 2002 12:01:02 +0200
Przemyslaw Sliwa <sliwa@euv-frankfurt-o.de> wrote:

> Hello,
> 
> The determinant of a symmetric positive definite matrix is just the
> product of the squares of the diagonal elements form the cholesky
> decomposition (NAG documentation). So why I'm getting different
> results form gsl_LU decomposition and the cholesky decomposition
> of a 10*10 Hilbert matrix (elemenst i,j given by 1/(i+j-1)).
> The results are not very big, but still they exist (determinant about 
> 0.5E+13 and
> the difference 6.0E+1). 




> Is it a bug, or the LU decomposition is unstable.
> What should be suggested: determinant of a covariance matrix: its
> Cholesky form or computation from LU decomposition.
> 
> Thanks for help
> 
> Przem
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determinant of a matrix
  2002-07-23 10:03 Przemyslaw Sliwa
  2002-07-23 10:35 ` Alan Aspuru-Guzik
@ 2002-07-23 10:44 ` Dan, Ho-Jin
  1 sibling, 0 replies; 5+ messages in thread
From: Dan, Ho-Jin @ 2002-07-23 10:44 UTC (permalink / raw)
  To: sliwa; +Cc: gsl-discuss

You can decompose a symmetric matrix L D L^T which is not singular, 
where the value
of diagonal elements of L  is one. The determinamt of a matrix can be 
calculated by the
multiplication of all elements of  D. If a matrix is singular, the 
determinant is zero as you know.
I think this method is correct and can be generalized unsymmetric matirx.
But I'm not sure that this is the most efficient.

Please *check* the algebra text. I have no reference at near hand now.

Best Regards,
Dan, Ho-Jin

Przemyslaw Sliwa wrote:

> Does anyone know how to compute in an easy way the determinant of a 
> real matrix?
>
> Thanx for hinst.
>
> Przem
>
>
>


-- 
:wq



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determinant of a matrix
  2002-07-23 10:03 Przemyslaw Sliwa
@ 2002-07-23 10:35 ` Alan Aspuru-Guzik
  2002-07-23 10:44 ` Dan, Ho-Jin
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Aspuru-Guzik @ 2002-07-23 10:35 UTC (permalink / raw)
  To: Przemyslaw Sliwa; +Cc: gsl-discuss

I already answered the question to you before (the 28th of May)!
http://sources.redhat.com/ml/gsl-discuss/2002-q2/msg00197.html

There is a lot of stuff that you don't need in that code, but it is easy
to figure out... (here I tried to be more explicit than in the previous
post)

x ludecomp and matrix are matrices
x perm is a permutation
x det is a double, s is an integer

//this copies the matrix, I like this, so I can still have it afterwards
//otherwise you will get the LU decomposition and loose your original
//matrix
gsl_matrix_memcopy(ludecomp,matrix);

//get the LU decomposition
gsl_linalg_LU_decomp(ludecomp,perm,&s);
//get the determinant
det =gsl_linalg_LU_det(ludecomp,s);

Let me know if you have any problems,

Alan

On Tue, 23 Jul 2002, Przemyslaw Sliwa wrote:

> Does anyone know how to compute in an easy way the determinant of a real 
> matrix?
> 
> Thanx for hinst.
> 
> Przem
> 

-- 

Alan Aspuru-Guzik                    Dios mueve al jugador, y éste, la pieza.
(510)642-5911 UC Berkeley           ¿Qué Dios detrás de Dios la trama empieza
(925)422-8739 LLNL                de polvo y tiempo y sueño y agonías? -Borges

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Determinant of a matrix
@ 2002-07-23 10:03 Przemyslaw Sliwa
  2002-07-23 10:35 ` Alan Aspuru-Guzik
  2002-07-23 10:44 ` Dan, Ho-Jin
  0 siblings, 2 replies; 5+ messages in thread
From: Przemyslaw Sliwa @ 2002-07-23 10:03 UTC (permalink / raw)
  To: gsl-discuss

Does anyone know how to compute in an easy way the determinant of a real 
matrix?

Thanx for hinst.

Przem

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-10-22 10:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-22  3:12 Determinant of a matrix Przemyslaw Sliwa
2002-10-22  7:20 ` Gert Van den Eynde
  -- strict thread matches above, loose matches on Subject: below --
2002-07-23 10:03 Przemyslaw Sliwa
2002-07-23 10:35 ` Alan Aspuru-Guzik
2002-07-23 10:44 ` Dan, Ho-Jin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).