# [Fwd: Re: Cholesky Decomposition in JAMA vs Matlab]

• Subject: [Fwd: Re: Cholesky Decomposition in JAMA vs Matlab]
• From: Ron Boisvert <boisvert@nist.gov>
• Date: Wed, 02 Apr 2008 10:38:56 -0400
• Content-Transfer-Encoding: 7bit
• Content-Type: text/plain; charset=ISO-8859-1; format=flowed
• User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)

```Sender: Sione <sionep@xtra.co.nz>
Subject: Re: Cholesky Decomposition in JAMA vs Matlab

I have this  [2 x 2]  matrix below :
--------------------------------

double[][] array = {{0.0442 ,  -0.0232},  {-0.0233 ,   0.0222}};
Matrix A = new Matrix(array);
CholeskyDecomposition  cholesky = new CholeskyDecomposition(A);
System.out.println(" Symmetric and positive definite = "+cholesky.isSPD());

-------------------------------
where the  isSPD method return a false, ie, matrix  A is   NOT
"Symmetric and positive definite".

In  Matlab , the same matrix gives  a   "p = 0" , which means that
matrix  A  is
"Symmetric and positive definite".

Why is the difference  Cleve ?

Any hint would be appreciated.

Cheers,
Sione.

Cleve Moler wrote:
> Yes, I can see why you were confused.
> You can always look at the result and see if R'*R is equal to A.
>  -- Cleve
>
> -----Original Message-----
> From: jama@nist.gov [mailto:jama@nist.gov] On Behalf Of Sione
> Sent: Monday, March 03, 2008 2:09 PM
> To: Multiple recipients of list
> Subject: Re: Cholesky Decomposition in JAMA vs Matlab
>
> I have just read the matlab user-guide carefully and concluded that :
>
> p = 0  in Cholesky to mean that  matrix  A is symmetric and positive
> definite which is "true" instead of being "false" (where a zero in
> matlab traditionally means "false").  So, the cholesky in JAMA has
> exactly the same output as in cholesky in Matlab, therefore my own
> question has been sorted.
>
> Cheers,
> Sione.
>
>
> Sione wrote:
>> Please discard my previous message as my example matrix was wrong.
>> Here is the correct codes:
>>
>> Does anyone know why the following output in JAMA is different from
>> that in Matlab for cholesky decomposition?
>>
>> JAMA:
>> ----
>> public static void main(String[] args){
>>    double[][] d = {{1,    -1},{ -1,     2}};
>>    Matrix A = new Matrix(d);
>>    CholeskyDecomposition chol = new CholeskyDecomposition(A);
>>    Matrix R = chol.getL();
>>    System.out.println(" chol.isSPD = "+chol.isSPD());
>>  }
>>
>> The output is :==>  "chol.isSPD = true"
>>
>>
>> Matlab:
>> ------
>>
>> A = [1    -1; -1     2];
>> [R,p] = chol(A);
>>
>> The output for 'p' is :==>  p = 0
>>
>>
>> In Matlab, anything that is zero is regarded as  false (logical
>> value), and this means that  'chol' function in matlab returns a
>> "FALSE" (ie, p=0)  that A is not symmetric and positive definite,
>> while that of  JAMA returns "TRUE".
>>
>> Is my interpretation of both the outputs in JAMA vs Matlab is correct
>> here, that they are different for the same matrix A?
>>
>> Any hint (perhaps from Cleve Moler) would be appreciated.
>>
>> Cheers,
>> Sione.
>>
>>
>>
>>
>>
>>
>
>
>
>
>
>
>
>

```

Date Index | Thread Index | Problems or questions? Contact list-master@nist.gov