30int main(
int argc,
char** argv) {
32 return app.
Exec(argc, argv);
36 namespace propt = boost::program_options;
39 propt::value<double>()->default_value(0.0),
40 "regularization factor");
60 std::string imcfile =
OptionsMap()[
"imcfile"].as<std::string>();
61 std::string gmcfile =
OptionsMap()[
"gmcfile"].as<std::string>();
63 double reg =
OptionsMap()[
"regularization"].as<
double>();
75 Eigen::MatrixXd ATA = A.transpose() * A;
80 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(ATA);
82 Eigen::VectorXd inv_diag = Eigen::VectorXd::Zero(es.eigenvalues().size());
88 for (
votca::Index i = 0; i < es.eigenvalues().size(); i++) {
89 if (std::abs(es.eigenvalues()[i] + reg) < etol) {
92 inv_diag[i] = 1 / (es.eigenvalues()[i] + reg);
96 if (numerics_unstable > 0) {
98 <<
"Regularisation parameter was to small, a pseudo inverse was "
99 "constructed instead.\n Use a larger regularisation parameter R."
100 " Smallest (eigenvalue+R)="
101 << (es.eigenvalues().array() + reg).abs().minCoeff() <<
" Found "
102 << numerics_unstable <<
" eigenvalues of " << es.eigenvalues().size()
103 <<
" below " << etol << std::endl;
106 Eigen::MatrixXd inverse =
107 es.eigenvectors() * inv_diag.asDiagonal() * es.eigenvectors().transpose();
109 x.y() = -inverse * A.transpose() * B.
y();
111 std::string idxfile =
OptionsMap()[
"idxfile"].as<std::string>();
112 std::vector<std::pair<std::string, votca::tools::RangeParser> > ranges =
114 for (std::pair<std::string, votca::tools::RangeParser>& range : ranges) {
117 tbl.
push_back(x.x(r - 1), x.y(r - 1),
'i');
119 tbl.
Save(range.first +
".dpot.imc");
Solves linear system for IMCS.
void Initialize() override
Initialize application data.
void Run() override
Main body of application.
bool EvaluateOptions() override
Process command line options.
int main(int argc, char **argv)
std::vector< std::pair< std::string, tools::RangeParser > > imcio_read_index(const std::string &filename)
Eigen::MatrixXd imcio_read_matrix(const std::string &filename)