mirror of
https://github.com/TREX-CoE/Sherman-Morrison.git
synced 2024-12-25 13:53:56 +01:00
Added LAPACK option to test_h5.cpp to compare residuals and number of operations.
This commit is contained in:
parent
ab661ad785
commit
6c9c68c93d
14
Makefile
14
Makefile
@ -21,11 +21,13 @@ else
|
||||
$(error No valid compiler environment set in $$ENV. \
|
||||
First run: $$ source smvars.sh {intel | llvm | gnu})
|
||||
endif
|
||||
CXXFLAGS = $(OPT) $(ARCH) $(DEBUG) -fPIC $(THRESHOLD)
|
||||
CXXFLAGS = $(OPT) $(ARCH) $(DEBUG) $(THRESHOLD) -fPIC
|
||||
FFLAGS = $(CXXFLAGS)
|
||||
H5CXX = h5c++
|
||||
H5CXXFLAGS = $(CXXFLAGS)
|
||||
FLIBS = -lstdc++
|
||||
LFLAGS = -mkl=sequential
|
||||
H5LFLAGS = -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl
|
||||
|
||||
## Includes and dependencies
|
||||
INCLUDE = -I $(INC_DIR)/
|
||||
@ -93,16 +95,16 @@ $(OBJ_DIR)/%.o: $(TST_DIR)/%.f90 | $(OBJ_DIR)
|
||||
|
||||
#### LINKING
|
||||
$(BIN_DIR)/cMaponiA3_test_3x3_3: $(OBJ_DIR)/cMaponiA3_test_3x3_3.o $(DEPS_CXX) | $(BIN_DIR)
|
||||
$(CXX) -o $@ $^
|
||||
$(CXX) $(LFLAGS) -o $@ $^
|
||||
|
||||
$(BIN_DIR)/test_h5: $(OBJ_DIR)/test_h5.o $(DEPS_CXX) | $(BIN_DIR)
|
||||
$(H5CXX) -o $@ $^
|
||||
$(H5CXX) $(H5LFLAGS) -o $@ $^
|
||||
|
||||
$(BIN_DIR)/fMaponiA3_test_3x3_3: $(DEPS_F) $(OBJ_DIR)/fMaponiA3_test_3x3_3.o | $(BIN_DIR)
|
||||
$(FC) $(FLIBS) -o $@ $^
|
||||
$(FC) $(LFLAGS) $(FLIBS) -o $@ $^
|
||||
|
||||
$(BIN_DIR)/fMaponiA3_test_4x4_2: $(DEPS_F) $(OBJ_DIR)/fMaponiA3_test_4x4_2.o | $(BIN_DIR)
|
||||
$(FC) $(FLIBS) -o $@ $^
|
||||
$(FC) $(LFLAGS) $(FLIBS) -o $@ $^
|
||||
|
||||
$(BIN_DIR)/QMCChem_dataset_test: $(DEPS_F) $(OBJ_DIR)/QMCChem_dataset_test.o | $(BIN_DIR)
|
||||
$(FC) $(FLIBS) -o $@ $^
|
||||
$(FC) $(LFLAGS) $(FLIBS) -o $@ $^
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <mkl_lapacke.h>
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
@ -18,6 +19,8 @@ void selectLargestDenominator(unsigned int l, unsigned int N_updates,
|
||||
unsigned int *Updates_index, unsigned int *p,
|
||||
double ***ylk);
|
||||
|
||||
lapack_int inverse(double *A, unsigned n);
|
||||
|
||||
template <typename T> void showScalar(T scalar, std::string name) {
|
||||
std::cout << name << " = " << scalar << std::endl << std::endl;
|
||||
}
|
||||
|
@ -39,3 +39,21 @@ void selectLargestDenominator(unsigned int l, unsigned int N_updates,
|
||||
}
|
||||
Switch(p, l, lbar);
|
||||
}
|
||||
|
||||
// Inplace inverse n x n matrix A.
|
||||
// returns:
|
||||
// ret = 0 on success
|
||||
// ret < 0 illegal argument value
|
||||
// ret > 0 singular matrix
|
||||
lapack_int inverse(double *A, unsigned n) {
|
||||
int ipiv[n + 1];
|
||||
lapack_int ret;
|
||||
|
||||
ret = LAPACKE_dgetrf(LAPACK_COL_MAJOR, n, n, A, n, ipiv);
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = LAPACKE_dgetri(LAPACK_COL_MAJOR, n, A, n, ipiv);
|
||||
return ret;
|
||||
}
|
||||
|
@ -81,6 +81,9 @@ int test_cycle(H5File file, int cycle, std::string version, double tolerance) {
|
||||
SM3(slater_inverse, dim, nupdates, u, col_update_index);
|
||||
} else if (version == "sm4") {
|
||||
SM4(slater_inverse, dim, nupdates, u, col_update_index);
|
||||
} else if (version == "lapack") {
|
||||
memcpy(slater_inverse, slater_matrix, dim * dim * sizeof(double));
|
||||
inverse(slater_inverse, dim);
|
||||
} else {
|
||||
std::cerr << "Unknown version " << version << std::endl;
|
||||
exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user