summaryrefslogtreecommitdiff
path: root/lib/LAPACK
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-09-29 10:45:19 +0000
committerAlberto Ruiz <aruiz@um.es>2007-09-29 10:45:19 +0000
commit59e449d624d5313660848dd0e58fe95dc482f9ca (patch)
tree9d7581f6504ffbe1bf28fe45ac89a3e5a6c71a4d /lib/LAPACK
parent3815bc25f62124063e02af83fe3c907336dc86f5 (diff)
LAPACK cholesky
Diffstat (limited to 'lib/LAPACK')
-rw-r--r--lib/LAPACK/lapack-aux.c42
-rw-r--r--lib/LAPACK/lapack-aux.h4
2 files changed, 46 insertions, 0 deletions
diff --git a/lib/LAPACK/lapack-aux.c b/lib/LAPACK/lapack-aux.c
index c7d6d86..5781cd1 100644
--- a/lib/LAPACK/lapack-aux.c
+++ b/lib/LAPACK/lapack-aux.c
@@ -28,6 +28,7 @@
28#define BAD_FILE 2003 28#define BAD_FILE 2003
29#define SINGULAR 2004 29#define SINGULAR 2004
30#define NOCONVER 2005 30#define NOCONVER 2005
31#define NODEFPOS 2006
31 32
32//////////////////// real svd //////////////////////////////////// 33//////////////////// real svd ////////////////////////////////////
33 34
@@ -577,3 +578,44 @@ int linearSolveSVDC_l(double rcond, KCMAT(a),KCMAT(b),CMAT(x)) {
577 free(AC); 578 free(AC);
578 OK 579 OK
579} 580}
581
582//////////////////// Cholesky factorization /////////////////////////
583
584int chol_l_H(KCMAT(a),CMAT(l)) {
585 integer n = ar;
586 REQUIRES(n>=1 && ac == n && lr==n && lc==n,BAD_SIZE);
587 DEBUGMSG("chol_l_H");
588 memcpy(lp,ap,n*n*sizeof(doublecomplex));
589 char uplo = 'U';
590 integer res;
591 zpotrf_ (&uplo,&n,(doublecomplex*)lp,&n,&res);
592 CHECK(res>0,NODEFPOS);
593 CHECK(res,res);
594 doublecomplex zero = {0.,0.};
595 int r,c;
596 for (r=0; r<lr-1; r++) {
597 for(c=r+1; c<lc; c++) {
598 ((doublecomplex*)lp)[r*lc+c] = zero;
599 }
600 }
601 OK
602}
603
604int chol_l_S(KDMAT(a),DMAT(l)) {
605 integer n = ar;
606 REQUIRES(n>=1 && ac == n && lr==n && lc==n,BAD_SIZE);
607 DEBUGMSG("chol_l_S");
608 memcpy(lp,ap,n*n*sizeof(double));
609 char uplo = 'U';
610 integer res;
611 dpotrf_ (&uplo,&n,lp,&n,&res);
612 CHECK(res>0,NODEFPOS);
613 CHECK(res,res);
614 int r,c;
615 for (r=0; r<lr-1; r++) {
616 for(c=r+1; c<lc; c++) {
617 lp[r*lc+c] = 0.;
618 }
619 }
620 OK
621}
diff --git a/lib/LAPACK/lapack-aux.h b/lib/LAPACK/lapack-aux.h
index 869eabb..c5bf3cc 100644
--- a/lib/LAPACK/lapack-aux.h
+++ b/lib/LAPACK/lapack-aux.h
@@ -36,3 +36,7 @@ int linearSolveLSC_l(KCMAT(a),KCMAT(b),CMAT(x));
36int linearSolveSVDR_l(double,KDMAT(a),KDMAT(b),DMAT(x)); 36int linearSolveSVDR_l(double,KDMAT(a),KDMAT(b),DMAT(x));
37 37
38int linearSolveSVDC_l(double,KCMAT(a),KCMAT(b),CMAT(x)); 38int linearSolveSVDC_l(double,KCMAT(a),KCMAT(b),CMAT(x));
39
40int chol_l_H(KCMAT(a),CMAT(r));
41
42int chol_l_S(KDMAT(a),DMAT(r));