help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: chol2inv for Octave?


From: Michael Creel
Subject: Re: chol2inv for Octave?
Date: Fri, 06 May 2005 09:47:18 +0200
User-agent: KMail/1.8

On Friday 06 May 2005 06:59, Mike Miller wrote:
> A friend who uses R a lot was just showing me that to compute the inverse
> of a symmetric positive-definite matrix, R has the function "chol2inv"
> which takes the Cholesky upper triangle of the symmetric PD matrix as
> input and returns the inverse of the symmetric PD matrix as output.
> Thus, one may get the inverse of a symmetric PD matrix 'M' by doing this:
>
> chol2inv(chol(M))
>
> In R, this runs twice as fast as solve(M), which is R's command for
> computing the inverse.  Comparing R to Octave on the same machine and
> using a 1000 x 1000 matrix M, I find that R's solve(M) is slower by about
> 25% than Octave's inv(M), but R's chol2inv(chol(M)) is much faster.  In
> fact, chol2inv(chol(M) in R is about as fast as inv(chol(M)) in Octave,
> but R is computing the inverse of M and Octave is computing the inverse of
> chol(M).
>
> So I'm wondering why Octave doesn't have a chol2inv function!  ;-)
> Maybe it has one and I just can't find it.
>
> Regards,
>
> Mike
>

Hi,

function a_inv = chol2inv(a)
    b = inv(chol(a));
    a_inv = b*b';
endfunction


That'll be 25 cents, please. Next?

:-)


        



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]