[SciPy-user] differences between numpy.linalg.cholesky and scipy.linalg.cholesky?

0 views
Skip to first unread message

Emanuele Olivetti

unread,
Jan 5, 2008, 10:36:17 AM1/5/08
to SciPy Users List
I'm using cholesky decomposition a lot and trying both
numpy.linalgcholesky and scipy.linalg.cholesky on
hearmitean positive definite matrix. Sometimes I
get """<class 'numpy.linalg.linalg.LinAlgError'>:
Matrix is not positive definite -
Cholesky decomposition cannot be computed"""
when using numpy's cholesky. No problems with
scipy's cholesky. Why?

Thanks in advance,

Emanuele

_______________________________________________
SciPy-user mailing list
SciPy...@scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user

Dominique Orban

unread,
Jan 7, 2008, 12:48:44 PM1/7/08
to SciPy Users List
On 1/5/08, Emanuele Olivetti <eman...@relativita.com> wrote:
> I'm using cholesky decomposition a lot and trying both
> numpy.linalgcholesky and scipy.linalg.cholesky on
> hearmitean positive definite matrix. Sometimes I
> get """<class 'numpy.linalg.linalg.LinAlgError'>:
> Matrix is not positive definite -
> Cholesky decomposition cannot be computed"""
> when using numpy's cholesky. No problems with
> scipy's cholesky. Why?

Could you provide a small example?

Dominique

Emanuele Olivetti

unread,
Jan 9, 2008, 2:47:48 AM1/9/08
to SciPy Users List
Dominique Orban wrote:
> On 1/5/08, Emanuele Olivetti <eman...@relativita.com> wrote:
>
>> I'm using cholesky decomposition a lot and trying both
>> numpy.linalgcholesky and scipy.linalg.cholesky on
>> hearmitean positive definite matrix. Sometimes I
>> get """<class 'numpy.linalg.linalg.LinAlgError'>:
>> Matrix is not positive definite -
>> Cholesky decomposition cannot be computed"""
>> when using numpy's cholesky. No problems with
>> scipy's cholesky. Why?
>>
>
> Could you provide a small example?
>
>

Currently it is not so easy to provide a simple example. I'm using
Cholesky factorization on 1000x1000 matrix generated from
some large datasets and getting the error few times. But I'll try to
generate one small soon.

Looking in numpy/scipy source code I see that:
- numpy.linalg.cholesky wraps the fortran function "dpotrf"
- scipy.linalg.decomp wraps "potrf"

Which is the difference between 'dpotrf' and 'potrf' ?

Thanks,

Emanuele

Robert Kern

unread,
Jan 9, 2008, 2:58:19 AM1/9/08
to SciPy Users List
Emanuele Olivetti wrote:
> Looking in numpy/scipy source code I see that:
> - numpy.linalg.cholesky wraps the fortran function "dpotrf"
> - scipy.linalg.decomp wraps "potrf"
>
> Which is the difference between 'dpotrf' and 'potrf' ?

Most LAPACK subroutines have variants for each type specified by a single-letter
prefix in front of the subroutine name.

S = float32
D = float64
C = complex64
Z = complex128

One of the features of f2py, which is used to make scipy.linalg.decomp but not
numpy.linalg, is that it can have templated interface definitions so one
declaration will wrap all four variants.

If you call scipy.linalg.cholesky with a float64 array, it will ultimately call
DPOTRF, too.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Reply all
Reply to author
Forward
0 new messages