danny's code

an anonymous user · September 23, 2022
Fortran
program hello
    INTEGER :: i, id, n
    COMPLEX(4), ALLOCATABLE :: finput(:,:), h(:,:,:,:), hm(:,:), hevc(:,:), hevl(:)
    n=2
    ALLOCATE(finput(n,3), hm(n*3,n*3), hevc(n*3,n*3), hevl(n*3), h(n,3,n,3))

    do id=1,3
        do i=1,n
            finput(:,:)=0
            finput(i,id)=1
            call apply_h(finput, h(:,:,i,id), n)
        enddo
    enddo

print *,finp

contains
subroutine apply_h(finp, fout, n)
    INTEGER :: i, id, n
    COMPLEX(4) :: finp(n,3), fout(n,3), A(n,3,3)
    COMPLEX(4), ALLOCATABLE :: f(:,:), pf(:)
    ALLOCATE(pf(n), f(n,3))
    
    f=finp
    do id=1,3
        !print *, "f(:,id)", f(:,id)
        call apply_p(f(:,id), pf, n)
    enddo
end subroutine apply_h

subroutine apply_p(psi, ppsi, n)
    INTEGER :: i, j, id, n
    COMPLEX(4) :: psi(n,3), ppsi(n,3)
    do i=1,n
        do j=1,n
            if(i.ne.j) then
                ppsi(i,:) = ppsi(i,:)
                print *, "loop", i, ppsi(i,:)
                print *, "operation",ppsi(i,:) + ((-1)**(i-j)/dble(i-j)) * psi(j,:)
            endif
        enddo
    enddo
    
    
end subroutine apply_p


end program Hello
Output
(Run the program to view its output)

Comments

Please sign up or log in to contribute to the discussion.