From 71320675021472b2f97191ba514c651ceb8a1617 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Fri, 26 Oct 2007 16:18:28 +0000 Subject: added Schur factorization --- lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c | 49 +++++++++++++++++++++++++++ lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h | 4 +++ 2 files changed, 53 insertions(+) (limited to 'lib/Numeric/LinearAlgebra/LAPACK') diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c index 04ef416..cab3f5b 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c +++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c @@ -701,3 +701,52 @@ int hess_l_C(KCMAT(a), CVEC(tau), CMAT(r)) { free(WORK); OK } + +//////////////////// Schur factorization ///////////////////////// + +int schur_l_R(KDMAT(a), DMAT(u), DMAT(s)) { + integer m = ar; + integer n = ac; + REQUIRES(m>=1 && n==m && ur==n && uc==n && sr==n && sc==n, BAD_SIZE); + DEBUGMSG("schur_l_R"); + memcpy(sp,ap,n*n*sizeof(double)); + integer lwork = 6*n; // fixme + double *WORK = (double*)malloc(lwork*sizeof(double)); + double *WR = (double*)malloc(n*sizeof(double)); + double *WI = (double*)malloc(n*sizeof(double)); + // WR and WI not really required in this call + logical *BWORK = (logical*)malloc(n*sizeof(logical)); + integer res; + integer sdim; + dgees_ ("V","N",NULL,&n,sp,&n,&sdim,WR,WI,up,&n,WORK,&lwork,BWORK,&res); + CHECK(res,res); + free(WR); + free(WI); + free(BWORK); + free(WORK); + OK +} + +int schur_l_C(KCMAT(a), CMAT(u), CMAT(s)) { + integer m = ar; + integer n = ac; + REQUIRES(m>=1 && n==m && ur==n && uc==n && sr==n && sc==n, BAD_SIZE); + DEBUGMSG("schur_l_C"); + memcpy(sp,ap,n*n*sizeof(doublecomplex)); + integer lwork = 6*n; // fixme + doublecomplex *WORK = (doublecomplex*)malloc(lwork*sizeof(doublecomplex)); + doublecomplex *W = (doublecomplex*)malloc(n*sizeof(doublecomplex)); + // W not really required in this call + logical *BWORK = (logical*)malloc(n*sizeof(logical)); + double *RWORK = (double*)malloc(n*sizeof(double)); + integer res; + integer sdim; + zgees_ ("V","N",NULL,&n,(doublecomplex*)sp,&n,&sdim,W, + (doublecomplex*)up,&n, + WORK,&lwork,RWORK,BWORK,&res); + CHECK(res,res); + free(W); + free(BWORK); + free(WORK); + OK +} diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h index 52ac41e..e5d74d7 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h +++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.h @@ -48,3 +48,7 @@ int qr_l_C(KCMAT(a), CVEC(tau), CMAT(r)); int hess_l_R(KDMAT(a), DVEC(tau), DMAT(r)); int hess_l_C(KCMAT(a), CVEC(tau), CMAT(r)); + +int schur_l_R(KDMAT(a), DMAT(u), DMAT(s)); + +int schur_l_C(KCMAT(a), CMAT(u), CMAT(s)); -- cgit v1.2.3