In 

srand(1);a=rand(2,2);a=a*a';cholfact!(a);logdet(a)

The issue is that cholfact!(a) destroys the data in a, you're not allowed 
to re-use it afterwords. You still need to save the result of cholfact! and 
use that object inside of logdet(), e.g.,

srand(1);a=rand(2,2);a=a*a';afact = cholfact!(a);logdet(afact)




On Saturday, October 18, 2014 7:47:59 PM UTC-4, Adam Check wrote:
>
> Hi,
>
> I am need to compute the cholesky decomposition of a matrix, and then use 
> the log determinant of the decomposition. I get different answers depending 
> on if I use cholfact vs. cholfact!
>
> The code below produces the same number for the logdet (-4.479)
>
> *srand(1);a=rand(2,2);a=a*a';logdet(cholfact(a))*
>
> *srand(1);a=rand(2,2);a=a*a';logdet(cholfact!(a))*
>
>
> However, the following code results in different values being reported:
>
> *srand(1);a=rand(2,2);a=a*a';a=cholfact(a);logdet(a)*
>
> *srand(1);a=rand(2,2);a=a*a';cholfact!(a);logdet(a)*
> with the second code reporting the (incorrect) value of -2.426, even 
> though the Cholfact object "a" appears identical in each case.
>
> This error happens consistently when implementing cholfact!() as in the 
> last line of code, and can result in an error when taking the logdet(): 
> *ERROR: 
> DomainError: determinant is negative*, even when no error results from 
> using the cholfact() function.
>
> I am currently using julia version 0.3.1, but I believe the problem has 
> been present in older versions as well.
>
> - Adam
>

Reply via email to