11 #undef MC__DEBUG_EIGEN
16 extern "C" void dsyev_
17 (
const char&,
const char&,
const long int&,
double*,
const long int&,
18 double*,
double*,
const long int&,
long int& );
26 std::cout <<
"ENTER <1> TO CONTINUE" << std::endl;
30 template<
typename U >
inline void display
31 (
const unsigned int m,
const unsigned int n,
const U*a,
const unsigned int lda,
32 const std::string&stra, std::ostream&os )
34 os << stra <<
" =" << std::endl << std::scientific
35 << std::setprecision(5);
36 for(
unsigned int im=0; a && im<m; im++ ){
37 for(
unsigned int in=0; in<n; in++ ){
38 os << a[in*lda+im] <<
" ";
44 if( os == std::cout || os == std::cerr ) pause();
48 inline double* dsyev_wrapper
49 (
const unsigned int n,
double*A,
const bool eigv=
false )
52 double*D =
new double[n];
53 #ifdef MC__DEBUG_EIGEN
54 display( n, n, A, n,
"Matrix A", std::cout );
58 char JOBZ = (eigv?
'V':
'N'), UPLO =
'U';
61 dsyev_( JOBZ, UPLO, n, A, n, D, &worktmp, lwork, info );
65 double*work =
new double[lwork];
66 dsyev_( JOBZ, UPLO, n, A, n, D, work, lwork, info );
67 #ifdef MC__DEBUG_EIGEN
68 if( eigv ) TModel<T>::_display( n, n, A, n,
"Matrix U", std::cout );
69 display( 1, n, D, 1,
"Matrix D", std::cout );
73 #ifdef MC__DEBUG_EIGEN
74 std::cout <<
"INFO: " << info << std::endl;
77 if( info ){
delete[] D;
return 0; }
83 #include "cpplapack.h"
92 inline long dsysv(
const dsymatrix& mat, dsymatrix& mat_inv)
94 dsymatrix mat_cp(mat);
95 mat_inv.resize(mat.n);
98 long NRHS(mat.n), LDA(mat.n), *IPIV(
new long[mat.n]), LDB(mat.n), LWORK(-1), INFO(1);
99 double *WORK(
new double[1] );
100 dsysv_(UPLO, mat.n, NRHS, mat_cp.array, LDA, IPIV, mat_inv.array, LDB, WORK, LWORK, INFO);
102 LWORK = long(WORK[0]);
103 delete [] WORK; WORK =
new double[LWORK];
104 dsysv_(UPLO, mat.n, NRHS, mat_cp.array, LDA, IPIV, mat_inv.array, LDB, WORK, LWORK, INFO);
105 delete [] WORK;
delete [] IPIV;
109 std::cerr <<
"Serious trouble happend. INFO = " << INFO <<
"." << std::endl;