mirror of
https://github.com/TREX-CoE/Sherman-Morrison.git
synced 2024-12-25 13:53:56 +01:00
Moved common MaponiA3 functions to SM_Helpers.{cpp,hpp} to prepare for MaponiA3+Slagel splitting.
This commit is contained in:
parent
ab9d13180a
commit
991f40a605
5
Makefile
5
Makefile
@ -28,7 +28,7 @@ FLIBS = -lstdc++
|
||||
|
||||
## Includes and dependencies
|
||||
INCLUDE = -I $(INC_DIR)/
|
||||
DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o $(OBJ_DIR)/SM_Standard.o
|
||||
DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o $(OBJ_DIR)/SM_Standard.o $(OBJ_DIR)/SM_Helpers.o
|
||||
DEPS_F = $(DEPS_CXX) $(OBJ_DIR)/SM_MaponiA3_mod.o $(OBJ_DIR)/Helpers_mod.o
|
||||
|
||||
## Directory structure
|
||||
@ -66,6 +66,9 @@ $(BIN_DIR) $(OBJ_DIR):
|
||||
$(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR)
|
||||
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR)
|
||||
$(CXX) $(CXXFLAGS) -fPIE $(INCLUDE) -c -o $@ $<
|
||||
|
||||
## HDF5/C++ objects
|
||||
$(OBJ_DIR)/%_h5.o: $(TST_DIR)/%_h5.cpp $(INC_DIR)/* | $(OBJ_DIR)
|
||||
$(H5CXX) $(H5CXXFLAGS) $(INCLUDE) -c -o $@ $<
|
||||
|
@ -9,7 +9,7 @@ CXXFLAGS = -O0 -g $(H5FLAGS)
|
||||
FFLAGS = -O0 -g $(H5FLAGS)
|
||||
|
||||
INCLUDE = -I $(INC_DIR)/
|
||||
DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o $(OBJ_DIR)/SM_Standard.o
|
||||
DEPS_CXX = $(OBJ_DIR)/SM_MaponiA3.o $(OBJ_DIR)/SM_Standard.o $(OBJ_DIR)/SM_Helpers.o
|
||||
DEPS_F = $(DEPS_CXX) $(OBJ_DIR)/SM_MaponiA3_mod.o $(OBJ_DIR)/Helpers_mod.o
|
||||
FLIBS = -lstdc++
|
||||
|
||||
@ -49,6 +49,9 @@ $(BIN_DIR) $(OBJ_DIR):
|
||||
$(OBJ_DIR)/%.o: $(TST_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR)
|
||||
$(CXX) $(CXXFLAGS) $(ARCH) $(INCLUDE) -c -o $@ $<
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INC_DIR)/* | $(OBJ_DIR)
|
||||
$(CXX) $(CXXFLAGS) -fPIE $(INCLUDE) -c -o $@ $<
|
||||
|
||||
## HDF5/C++ objects
|
||||
$(OBJ_DIR)/%_h5.o: $(TST_DIR)/%_h5.cpp $(INC_DIR)/* | $(OBJ_DIR)
|
||||
$(H5CXX) $(H5CXXFLAGS) $(INCLUDE) -c -o $@ $<
|
||||
|
@ -5,6 +5,12 @@
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
void Switch(unsigned int *p, unsigned int l, unsigned int lbar);
|
||||
|
||||
void selectLargestDenominator(unsigned int l, unsigned int N_updates,
|
||||
unsigned int *Updates_index, unsigned int *p,
|
||||
double ***ylk);
|
||||
|
||||
template<typename T>
|
||||
void showScalar(T scalar, std::string name) {
|
||||
std::cout << name << " = " << scalar << std::endl << std::endl;
|
||||
|
31
src/SM_Helpers.cpp
Normal file
31
src/SM_Helpers.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "SM_Helpers.hpp"
|
||||
|
||||
void Switch(unsigned int *p, unsigned int l, unsigned int lbar) {
|
||||
unsigned int tmp = p[l+1];
|
||||
p[l+1] = p[lbar];
|
||||
p[lbar] = tmp;
|
||||
}
|
||||
|
||||
void selectLargestDenominator(unsigned int l, unsigned int N_updates,
|
||||
unsigned int *Updates_index, unsigned int *p,
|
||||
double ***ylk) {
|
||||
unsigned int lbar = l+1, max =0;
|
||||
unsigned int index = 0, component = 0;
|
||||
unsigned int tmp = 0;
|
||||
double breakdown = 0;
|
||||
for (unsigned int j = lbar; j < N_updates + 1; j++) {
|
||||
index = p[j];
|
||||
component = Updates_index[index - 1];
|
||||
breakdown = abs(1 + ylk[l][index][component]);
|
||||
#ifdef DEBUG
|
||||
std::cout << "Inside selectLargestDenominator()" << std::endl;
|
||||
std::cout << "breakdown = abs(1 + ylk[" << l << "][" << index << "][" << component << "]) = " << breakdown << std::endl;
|
||||
std::cout << std::endl;
|
||||
#endif
|
||||
if (breakdown > max) {
|
||||
max = breakdown;
|
||||
lbar = j;
|
||||
}
|
||||
}
|
||||
Switch(p, l, lbar);
|
||||
}
|
@ -6,36 +6,6 @@
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
void Switch(unsigned int *p, unsigned int l, unsigned int lbar) {
|
||||
unsigned int tmp = p[l+1];
|
||||
p[l+1] = p[lbar];
|
||||
p[lbar] = tmp;
|
||||
}
|
||||
|
||||
void selectLargestDenominator(unsigned int l, unsigned int N_updates,
|
||||
unsigned int *Updates_index, unsigned int *p,
|
||||
double ***ylk) {
|
||||
unsigned int lbar = l+1, max =0;
|
||||
unsigned int index = 0, component = 0;
|
||||
unsigned int tmp = 0;
|
||||
double breakdown = 0;
|
||||
for (unsigned int j = lbar; j < N_updates + 1; j++) {
|
||||
index = p[j];
|
||||
component = Updates_index[index - 1];
|
||||
breakdown = abs(1 + ylk[l][index][component]);
|
||||
#ifdef DEBUG
|
||||
std::cout << "Inside selectLargestDenominator()" << std::endl;
|
||||
std::cout << "breakdown = abs(1 + ylk[" << l << "][" << index << "][" << component << "]) = " << breakdown << std::endl;
|
||||
std::cout << std::endl;
|
||||
#endif
|
||||
if (breakdown > max) {
|
||||
max = breakdown;
|
||||
lbar = j;
|
||||
}
|
||||
}
|
||||
Switch(p, l, lbar);
|
||||
}
|
||||
|
||||
void MaponiA3(double *Slater_inv, unsigned int Dim,
|
||||
unsigned int N_updates, double *Updates,
|
||||
unsigned int *Updates_index) {
|
||||
|
Loading…
Reference in New Issue
Block a user