Skip to content

Commit b4ae739

Browse files
author
Roberto Di Remigio
committed
Use LLt Cholesky instead of LDLt
1 parent 86d96f1 commit b4ae739

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
### Changed
88

9+
- [Cholesky decomposition](http://eigen.tuxfamily.org/dox/classEigen_1_1LLT.html) is used
10+
whenever the inverse of the S matrix has to be calculated.
11+
The S matrix is self-adjoint, positive-definite and the LLT decomposition is
12+
faster than LDLT.
13+
914
### Deprecated
1015

1116
### Removed

src/solver/CPCMSolver.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
/*
33
* PCMSolver, an API for the Polarizable Continuum Model
44
* Copyright (C) 2013-2016 Roberto Di Remigio, Luca Frediani and contributors
5-
*
5+
*
66
* This file is part of PCMSolver.
7-
*
7+
*
88
* PCMSolver is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Lesser General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* PCMSolver is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Lesser General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Lesser General Public License
1919
* along with PCMSolver. If not, see <http://www.gnu.org/licenses/>.
20-
*
20+
*
2121
* For information on the complete list of contributors to the
2222
* PCMSolver API, see: <http://pcmsolver.readthedocs.io/>
2323
*/
@@ -38,7 +38,6 @@
3838
#include "cavity/Element.hpp"
3939
#include "green/IGreensFunction.hpp"
4040
#include "utils/MathUtils.hpp"
41-
#include "SolverImpl.hpp"
4241

4342
void CPCMSolver::buildSystemMatrix_impl(const Cavity & cavity, const IGreensFunction & gf_i, const IGreensFunction & gf_o)
4443
{
@@ -79,7 +78,7 @@ Eigen::VectorXd CPCMSolver::computeCharge_impl(const Eigen::VectorXd & potential
7978
int nrBlocks = blockS_.size();
8079
int irrDim = fullDim/nrBlocks;
8180
charge.segment(irrep*irrDim, irrDim) =
82-
- blockS_[irrep].ldlt().solve(potential.segment(irrep*irrDim, irrDim));
81+
- blockS_[irrep].llt().solve(potential.segment(irrep*irrDim, irrDim));
8382

8483
return charge;
8584
}

src/solver/SolverImpl.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
/*
33
* PCMSolver, an API for the Polarizable Continuum Model
44
* Copyright (C) 2013-2016 Roberto Di Remigio, Luca Frediani and contributors
5-
*
5+
*
66
* This file is part of PCMSolver.
7-
*
7+
*
88
* PCMSolver is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Lesser General Public License as published by
1010
* the Free Software Foundation, either version 3 of the License, or
1111
* (at your option) any later version.
12-
*
12+
*
1313
* PCMSolver is distributed in the hope that it will be useful,
1414
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1515
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1616
* GNU Lesser General Public License for more details.
17-
*
17+
*
1818
* You should have received a copy of the GNU Lesser General Public License
1919
* along with PCMSolver. If not, see <http://www.gnu.org/licenses/>.
20-
*
20+
*
2121
* For information on the complete list of contributors to the
2222
* PCMSolver API, see: <http://pcmsolver.readthedocs.io/>
2323
*/
@@ -27,6 +27,7 @@
2727

2828
#include "Config.hpp"
2929

30+
#include <Eigen/Cholesky>
3031
#include <Eigen/Core>
3132
#include <Eigen/LU>
3233

@@ -104,7 +105,7 @@ inline Eigen::MatrixXd anisotropicIEFMatrix(const Cavity & cav, const IGreensFun
104105
TIMER_OFF("Assemble T matrix");
105106

106107
TIMER_ON("Assemble R matrix");
107-
Eigen::MatrixXd R = ((2 * M_PI * Id - DE * a) - SE * SI.ldlt().solve((2 * M_PI * Id - DI * a)));
108+
Eigen::MatrixXd R = ((2 * M_PI * Id - DE * a) - SE * SI.llt().solve((2 * M_PI * Id - DI * a)));
108109
TIMER_OFF("Assemble R matrix");
109110

110111
TIMER_ON("Assemble T^-1R matrix");
@@ -312,7 +313,7 @@ inline Eigen::MatrixXd anisotropicRinfinity(const Cavity & cav, const IGreensFun
312313
Eigen::MatrixXd Id = Eigen::MatrixXd::Identity(cavitySize, cavitySize);
313314

314315
// Form R
315-
return ((2 * M_PI * Id - DE * a) - SE * SI.ldlt().solve((2 * M_PI * Id - DI * a)));
316+
return ((2 * M_PI * Id - DE * a) - SE * SI.llt().solve((2 * M_PI * Id - DI * a)));
316317
}
317318

318319
/*! \brief Builds the **isotropic** \f$ \mathbf{R}_\infty \f$ matrix

0 commit comments

Comments
 (0)