3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-07 06:33:48 +01:00

Optimized slightly orthogonalization routine

At one step of the orthogonaliztion procedure two matrix multiplications
have been replaced with one matrix multiplication and a element-wise
multiplication of a vector and a matrix.
This commit is contained in:
Oleg E. Peil 2015-11-21 14:23:30 +01:00
parent b2b25a9fd0
commit 7db721c8d1

View File

@ -240,14 +240,16 @@ class ProjectorGroup:
Orthogonalized projector matrix, initial overlap matrix and its eigenvalues.
"""
# TODO: check the precision of the calculations below,
# it seems to be inferior to that of Fortran implementation
# Overlap matrix O_{m m'} = \sum_{v} P_{m v} P^{*}_{v m'}
overlap = np.dot(p_matrix, p_matrix.conj().T)
# Calculate [O^{-1/2}]_{m m'}
eig, eigv = np.linalg.eigh(overlap)
assert np.all(eig > 0.0), ("Negative eigenvalues of the overlap matrix:"
"projectors are ill-defined")
sqrt_eig = np.diag(1.0 / np.sqrt(eig))
shalf = np.dot(eigv, np.dot(sqrt_eig, eigv.conj().T))
sqrt_eig = 1.0 / np.sqrt(eig)
shalf = np.dot(eigv * sqrt_eig, eigv.conj().T)
# Apply \tilde{P}_{m v} = \sum_{m'} [O^{-1/2}]_{m m'} P_{m' v}
p_ortho = np.dot(shalf, p_matrix)