00001 00033 #ifndef _MSC_VER 00034 # include <itpp/config.h> 00035 #else 00036 # include <itpp/config_msvc.h> 00037 #endif 00038 00039 #if defined(HAVE_LAPACK) 00040 # include <itpp/base/lapack.h> 00041 #endif 00042 00043 #include <itpp/base/cholesky.h> 00044 00045 00046 namespace itpp { 00047 00048 #if defined(HAVE_LAPACK) 00049 00050 bool chol(const mat &X, mat &F) 00051 { 00052 00053 char uplo='U'; 00054 int n, lda, info; 00055 n = lda = X.rows(); 00056 00057 F = X; // input matrix is overwritten 00058 00059 dpotrf_(&uplo, &n, F._data(), &lda, &info); 00060 00061 // Set lower part to zero 00062 for (int i=0; i<n; i++) 00063 for(int j=i+1; j<n; j++) 00064 F(j,i) = 0; 00065 00066 return (info==0); 00067 } 00068 00069 bool chol(const cmat &X, cmat &F) 00070 { 00071 char uplo='U'; 00072 int n, lda, info; 00073 n = lda = X.rows(); 00074 00075 F = X; // input matrix is overwritten 00076 00077 zpotrf_(&uplo, &n, F._data(), &lda, &info); 00078 00079 // Set lower part to zero 00080 for (int i=0; i<n; i++) 00081 for(int j=i+1; j<n; j++) 00082 F(j,i) = 0; 00083 00084 return (info==0); 00085 } 00086 00087 #else // HAVE_LAPACK 00088 00089 bool chol(const mat &X, mat &F) 00090 { 00091 it_error("LAPACK library is needed to use chol() function"); 00092 return false; 00093 } 00094 00095 bool chol(const cmat &X, cmat &F) 00096 { 00097 00098 it_error("LAPACK library is needed to use chol() function"); 00099 return false; 00100 } 00101 00102 #endif // HAVE_LAPACK 00103 00104 cmat chol(const cmat &X) 00105 { 00106 cmat F; 00107 if (!chol(X, F)) { 00108 it_warning("cholesky factorization didn't succeed"); 00109 } 00110 00111 return F; 00112 } 00113 00114 mat chol(const mat &X) 00115 { 00116 mat F; 00117 if (!chol(X, F)) { 00118 it_warning("cholesky factorization didn't succeed"); 00119 } 00120 00121 return F; 00122 } 00123 00124 } // namespace itpp
Generated on Thu Apr 19 14:14:56 2007 for IT++ by Doxygen 1.5.1