Skip to content

Commit

Permalink
4.10.9 Update
Browse files Browse the repository at this point in the history
Some updates mostly in IOTOOLS and LINALG.
* introduced to_lower and to_upper procedures to change case of a given alphabetic string
* fixed some bugs, extended functionalities and exported operator .kx. for Kronecker product
of matrices (used in lattice real-space DMRG).
  • Loading branch information
aamaricci committed Oct 6, 2023
1 parent ad85d7f commit 2dac4c7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 9 deletions.
35 changes: 34 additions & 1 deletion src/SF_IOTOOLS/IOFILE.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ module IOFILE
public :: str
public :: txtfy !obsolete
public :: reg
public :: to_lower
public :: to_upper
!
public :: file_size
public :: file_length
Expand All @@ -70,7 +72,7 @@ module IOFILE




!+-----------------------------------------------------------------+
!PURPOSE :
!+-----------------------------------------------------------------+
Expand Down Expand Up @@ -397,6 +399,37 @@ end subroutine create_data_dir



function to_upper(StrIn) result(StrOut)
character(len=*), intent(in) :: strIn
character(len=len(strIn)) :: strOut
integer :: i
do i = 1,len(StrIn)
select case(StrIn(i:i))
case("a":"z")
StrOut(i:i) = achar(iachar(StrIn(i:i))-32)
case default
StrOut(i:i) = StrIn(i:i)
end select
end do
end function to_upper

function to_lower(StrIn) result(StrOut)
character(len=*), intent(in) :: strIn
character(len=len(strIn)) :: strOut
integer :: i
do i = 1,len(StrIn)
select case(StrIn(i:i))
case("A":"Z")
StrOut(i:i) = achar(iachar(StrIn(i:i))+32)
case default
StrOut(i:i) = StrIn(i:i)
end select
end do
end function to_lower




! function i_to_ch(i4) result(string)
! character(len=32) :: string
! integer :: i4
Expand Down
2 changes: 2 additions & 0 deletions src/SF_IOTOOLS/SF_IOTOOLS.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ MODULE SF_IOTOOLS
public :: str
public :: txtfy !obsolete
public :: reg
public :: to_lower
public :: to_upper
!
public :: file_size
public :: file_length
Expand Down
24 changes: 18 additions & 6 deletions src/SF_LINALG/SF_LINALG.f90
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,35 @@ module SF_LINALG
!Kroenecker product of matrices
public :: kron
public :: kronecker_product
public :: kroenecker_product
public :: operator(.kx.)
!outer product of two 1d arrays to form a matrix
public :: outerprod
public :: cross_product
public :: s3_product
!
interface kron
module procedure i_kronecker_product,d_kronecker_product,c_kronecker_product
module procedure :: i_kronecker_product
module procedure :: d_kronecker_product
module procedure :: dc_kronecker_product
module procedure :: cd_kronecker_product
module procedure :: c_kronecker_product
end interface kron
!
interface kronecker_product
module procedure i_kronecker_product,d_kronecker_product,c_kronecker_product
module procedure :: i_kronecker_product
module procedure :: d_kronecker_product
module procedure :: dc_kronecker_product
module procedure :: cd_kronecker_product
module procedure :: c_kronecker_product
end interface kronecker_product
!
interface kroenecker_product
module procedure i_kronecker_product,d_kronecker_product,c_kronecker_product
end interface kroenecker_product
interface operator(.kx.)
module procedure :: i_kronecker_product
module procedure :: d_kronecker_product
module procedure :: dc_kronecker_product
module procedure :: cd_kronecker_product
module procedure :: c_kronecker_product
end interface operator(.kx.)
!
interface outerprod
module procedure outerprod_d,outerprod_c
Expand Down
34 changes: 32 additions & 2 deletions src/SF_LINALG/linalg_external_products.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,51 @@ function d_kronecker_product(A,B) result(AxB)
integer :: rowA,colA
integer :: rowB,colB
real(8) :: AxB(size(A,1)*size(B,1),size(A,2)*size(B,2))
AxB = 0
AxB = 0d0
rowA=size(A,1) ; colA=size(A,2)
rowB=size(B,1) ; colB=size(B,2)
forall(i=1:rowA,j=1:colA)
AxB(1+rowB*(i-1):rowB*i,1+colB*(j-1):colB*j) = A(i,j)*B(:,:)
end forall
end function d_kronecker_product
!
function dc_kronecker_product(A,B) result(AxB)
real(8),intent(in) :: A(:,:)
complex(8),intent(in) :: B(:,:)
integer :: i,j
integer :: rowA,colA
integer :: rowB,colB
complex(8) :: AxB(size(A,1)*size(B,1),size(A,2)*size(B,2))
AxB = zero
rowA=size(A,1) ; colA=size(A,2)
rowB=size(B,1) ; colB=size(B,2)
forall(i=1:rowA,j=1:colA)
AxB(1+rowB*(i-1):rowB*i,1+colB*(j-1):colB*j) = A(i,j)*B(:,:)
end forall
end function dc_kronecker_product
!
function cd_kronecker_product(A,B) result(AxB)
complex(8),intent(in) :: A(:,:)
real(8),intent(in) :: B(:,:)
integer :: i,j
integer :: rowA,colA
integer :: rowB,colB
complex(8) :: AxB(size(A,1)*size(B,1),size(A,2)*size(B,2))
AxB = zero
rowA=size(A,1) ; colA=size(A,2)
rowB=size(B,1) ; colB=size(B,2)
forall(i=1:rowA,j=1:colA)
AxB(1+rowB*(i-1):rowB*i,1+colB*(j-1):colB*j) = A(i,j)*B(:,:)
end forall
end function cd_kronecker_product
!
function c_kronecker_product(A,B) result(AxB)
complex(8),intent(in) :: A(:,:), B(:,:)
integer :: i,j
integer :: rowA,colA
integer :: rowB,colB
complex(8) :: AxB(size(A,1)*size(B,1),size(A,2)*size(B,2))
AxB = 0
AxB = zero
rowA=size(A,1) ; colA=size(A,2)
rowB=size(B,1) ; colB=size(B,2)
forall(i=1:rowA,j=1:colA)
Expand Down

0 comments on commit 2dac4c7

Please sign in to comment.