mirror of
https://github.com/TREX-CoE/Sherman-Morrison.git
synced 2025-01-13 14:29:15 +01:00
Prepared the example matrix of Example 8 of the paper and its
decomposition in the Fortran code and made a basic call to the subroutine MYSUBROUTINE, which is bound to the C++ void function 'Sherman-Morrison();. For now compilation fails with lots of undefined references.'
This commit is contained in:
parent
090847247d
commit
84fffdb7fa
23
Makefile
23
Makefile
@ -7,24 +7,33 @@ FFLAGS=-O0 -debug full -traceback
|
|||||||
## Deps & objs for the C++ stuff
|
## Deps & objs for the C++ stuff
|
||||||
cppDEPS = cppmain.cpp SM_MaponiA3.cpp SM_MaponiA3.hpp Helpers.hpp
|
cppDEPS = cppmain.cpp SM_MaponiA3.cpp SM_MaponiA3.hpp Helpers.hpp
|
||||||
cppOBJ = cppmain.o SM_MaponiA3.o
|
cppOBJ = cppmain.o SM_MaponiA3.o
|
||||||
|
|
||||||
## Deps & objs for the Fortran stuff
|
## Deps & objs for the Fortran stuff
|
||||||
fDEPS = fmain.f90 SM_MaponiA3_mod.f90
|
fDEPS = fmain.f90 SM_MaponiA3_mod.f90
|
||||||
fOBJ = SM_MaponiA3_mod.o fmain.o
|
fOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o fmain.o
|
||||||
|
|
||||||
|
## Compile recipes for C++ stuff
|
||||||
%.o: %.cpp $(cppDEPS)
|
%.o: %.cpp $(cppDEPS)
|
||||||
$(CXX) $(ARCH) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(ARCH) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
## Compile recepies for Fortran stuff
|
||||||
%.o: %.f90 $(fDEPS)
|
%.o: %.f90 $(fDEPS)
|
||||||
$(FC) $(ARCH) $(FFLAGS) -c -o $@ $<
|
$(FC) $(ARCH) $(FFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
.PHONY: all clean distclean
|
||||||
|
|
||||||
all: cppSherman-Morrison fSherman-Morrison
|
all: cppSherman-Morrison fSherman-Morrison
|
||||||
|
|
||||||
cppSherman-Morrison: $(cppOBJ)
|
|
||||||
$(CXX) $(ARCH) $(CXXFLAGS) -o $@ $^
|
|
||||||
|
|
||||||
fSherman-Morrison: $(fOBJ)
|
|
||||||
$(FC) $(ARCH) $(FFLAGS) -o $@ $^
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -vf *.o *.mod
|
@rm -vf *.o *.mod
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
@rm -vf cppSherman-Morrison fSherman-Morrison
|
||||||
|
|
||||||
|
## Linking the C++ example program
|
||||||
|
cppSherman-Morrison: $(cppOBJ)
|
||||||
|
$(CXX) $(ARCH) $(CXXFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
## Linking Fortran example program calling the C++ function 'Sherman_Morrison()'
|
||||||
|
fSherman-Morrison: $(fOBJ)
|
||||||
|
$(FC) $(ARCH) $(FFLAGS) -o $@ $^
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "SM_MaponiA3.hpp"
|
#include "SM_MaponiA3.hpp"
|
||||||
#include "Helpers.hpp"
|
#include "Helpers.hpp"
|
||||||
|
|
||||||
void Sherman_Morrison_(int **Slater0, double **Slater_inv, unsigned int *Dim, unsigned int *N_updates, int **Updates, unsigned int *Updates_index) {
|
void Sherman_Morrison(int **Slater0, double **Slater_inv, unsigned int *Dim, unsigned int *N_updates, int **Updates, unsigned int *Updates_index) {
|
||||||
unsigned int k, l, lbar, i, j, tmp, M = *Dim;
|
unsigned int k, l, lbar, i, j, tmp, M = *Dim;
|
||||||
unsigned int *p = new unsigned int[M+1];
|
unsigned int *p = new unsigned int[M+1];
|
||||||
unsigned int **Id = new unsigned int*[M];
|
unsigned int **Id = new unsigned int*[M];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// SM-MaponiA3.hpp
|
// SM-MaponiA3.hpp
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void Sherman_Morrison_(int **Slater0, double **Slater_inv, unsigned int *Dim, unsigned int *N_updates, int **Updates, unsigned int *Updates_index);
|
void Sherman_Morrison(int **Slater0, double **Slater_inv, unsigned int *Dim, unsigned int *N_updates, int **Updates, unsigned int *Updates_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ int main() {
|
|||||||
// Define pointers dim and n_updates to use in Sherman-Morrison(...) function call
|
// Define pointers dim and n_updates to use in Sherman-Morrison(...) function call
|
||||||
unsigned int *dim = new unsigned int(M);
|
unsigned int *dim = new unsigned int(M);
|
||||||
unsigned int *n_updates = new unsigned int(M);
|
unsigned int *n_updates = new unsigned int(M);
|
||||||
Sherman_Morrison_(A0, A0_inv, dim, n_updates, Ar, Ar_index);
|
Sherman_Morrison(A0, A0_inv, dim, n_updates, Ar, Ar_index);
|
||||||
showMatrix(A0_inv, M, "A0_inv");
|
showMatrix(A0_inv, M, "A0_inv");
|
||||||
|
|
||||||
// Deallocate all vectors and matrices
|
// Deallocate all vectors and matrices
|
||||||
|
25
fmain.f90
25
fmain.f90
@ -24,12 +24,29 @@ program Interface_test
|
|||||||
A(3,2) = 0
|
A(3,2) = 0
|
||||||
A(3,3) = -1
|
A(3,3) = -1
|
||||||
|
|
||||||
do i=1,3
|
!! Prepare the diagonal matrix A0 and the update matrix Ar
|
||||||
do j=1,3
|
do i=1,dim
|
||||||
write(*,"(I)", advance="no") A(i,j)
|
Ar_index(i) = i
|
||||||
|
do j=1,dim
|
||||||
|
if (i == j) then
|
||||||
|
A0(i,j) = A(i,j)
|
||||||
|
A0_inv(i,j) = 1.0d0 / A0(i,j)
|
||||||
|
else
|
||||||
|
A0(i,j) = 0
|
||||||
|
A0_inv(i,j) = 0.0d0
|
||||||
|
end if
|
||||||
|
Ar(i,j) = A(i,j) - A0(i,j)
|
||||||
end do
|
end do
|
||||||
write(*,*)
|
|
||||||
end do
|
end do
|
||||||
|
|
||||||
|
! do i=1,dim
|
||||||
|
! do j=1,dim
|
||||||
|
! write(*,"(I)", advance="no") Ar_index(i)
|
||||||
|
! end do
|
||||||
|
! write(*,*)
|
||||||
|
! end do
|
||||||
|
|
||||||
|
call MYSUBROUTINE(A0, A0_inv, dim, n_updates, Ar, Ar_index)
|
||||||
|
|
||||||
deallocate(Ar_index, A, A0, Ar, A0_inv)
|
deallocate(Ar_index, A, A0, Ar, A0_inv)
|
||||||
end program
|
end program
|
||||||
|
Loading…
x
Reference in New Issue
Block a user