1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-07-01 17:06:11 +02:00
qmckl/org/qmckl_blas.org
2021-12-12 11:28:57 +01:00

39 KiB

BLAS functions

Matrix operations

qmckl_dgemm

Matrix multiply: $C_{ij} = \beta C_{ij} + \alpha \sum_{k} A_{ik} \cdot B_{kj}$ using Fortran matmul function.

TODO: Add description about the external library dependence.

qmckl_context context in Global state
bool TransA in Number of rows of the input matrix
bool TransB in Number of rows of the input matrix
int64_t m in Number of rows of the input matrix
int64_t n in Number of columns of the input matrix
int64_t k in Number of columns of the input matrix
double alpha in Number of columns of the input matrix
double A[][lda] in Array containing the $m \times n$ matrix $A$
int64_t lda in Leading dimension of array A
double B[][ldb] in Array containing the $n \times m$ matrix $B$
int64_t ldb in Leading dimension of array B
double beta in Array containing the $n \times m$ matrix $B$
double C[][ldc] out Array containing the $n \times m$ matrix $B$
int64_t ldc in Leading dimension of array B

Requirements

  • context is not QMCKL_NULL_CONTEXT
  • m > 0
  • n > 0
  • k > 0
  • lda >= m
  • ldb >= n
  • ldc >= n
  • A is allocated with at least $m \times k \times 8$ bytes
  • B is allocated with at least $k \times n \times 8$ bytes
  • C is allocated with at least $m \times n \times 8$ bytes

C header

qmckl_exit_code qmckl_dgemm (
const qmckl_context context,
const bool TransA,
const bool TransB,
const int64_t m,
const int64_t n,
const int64_t k,
const double alpha,
const double* A,
const int64_t lda,
const double* B,
const int64_t ldb,
const double beta,
double* const C,
const int64_t ldc );

Source

integer function qmckl_dgemm_f(context, TransA, TransB, m, n, k, alpha, A, LDA, B, LDB, beta, C, LDC) &
 result(info)
use qmckl
implicit none
integer(qmckl_context)  , intent(in)  :: context
logical*8  , intent(in)  :: TransA, TransB
integer*8  , intent(in)  :: m, n, k
real*8     , intent(in)  :: alpha, beta
integer*8  , intent(in)  :: lda
real*8     , intent(in)  :: A(lda,*)
integer*8  , intent(in)  :: ldb
real*8     , intent(in)  :: B(ldb,*)
integer*8  , intent(in)  :: ldc
real*8     , intent(out) :: C(ldc,*)
real*8, allocatable      :: AT(:,:), BT(:,:), CT(:,:)
integer*4 :: qmckl_dgemm_N_N_f

integer*8 :: i,j,l, LDA_2, LDB_2

info = QMCKL_SUCCESS

if (TransA) then
allocate(AT(m,k))
do i = 1, k
  do j = 1, m
    AT(j,i) = A(i,j)
  end do
end do
LDA_2 = M
else
LDA_2 = LDA
endif

if (TransB) then
allocate(BT(k,n))
do i = 1, n
  do j = 1, k
    BT(j,i) = B(i,j)
  end do
end do
LDB_2 = K
else
LDB_2 = LDB
endif

if (context == QMCKL_NULL_CONTEXT) then
 info = QMCKL_INVALID_CONTEXT
 return
endif

if (m <= 0_8) then
 info = QMCKL_INVALID_ARG_4
 return
endif

if (n <= 0_8) then
 info = QMCKL_INVALID_ARG_5
 return
endif

if (k <= 0_8) then
 info = QMCKL_INVALID_ARG_6
 return
endif

if (LDA_2 /= m) then
 info = QMCKL_INVALID_ARG_9
 return
endif

if (LDB_2 /= k) then
 info = QMCKL_INVALID_ARG_10
 return
endif

if (LDC /= m) then
 info = QMCKL_INVALID_ARG_13
 return
endif

if (TransA) then
 info = qmckl_dgemm_N_N_f(context, m, n, k, alpha, AT, LDA_2, B, LDB_2, beta, c, LDC)
else if (TransB) then
 info = qmckl_dgemm_N_N_f(context, m, n, k, alpha, A, LDA_2, BT, LDB_2, beta, c, LDC)
else if (TransA .and. TransB) then
 info = qmckl_dgemm_N_N_f(context, m, n, k, alpha, AT, LDA_2, BT, LDB_2, beta, c, LDC)
else
 info = qmckl_dgemm_N_N_f(context, m, n, k, alpha, A, LDA_2, B, LDB_2, beta, c, LDC)
endif
end function qmckl_dgemm_f

integer function qmckl_dgemm_N_N_f(context, m, n, k, alpha, A, LDA, B, LDB, beta, C, LDC) &
 result(info)
use qmckl
implicit none
integer(qmckl_context)  , intent(in)  :: context
integer*8  , intent(in)  :: m, n, k
real*8     , intent(in)  :: alpha, beta
integer*8  , intent(in)  :: lda
real*8     , intent(in)  :: A(lda,k)
integer*8  , intent(in)  :: ldb
real*8     , intent(in)  :: B(ldb,n)
integer*8  , intent(in)  :: ldc
real*8     , intent(out) :: C(ldc,n)

integer*8 :: i,j,l, LDA_2, LDB_2

info = QMCKL_SUCCESS

if (context == QMCKL_NULL_CONTEXT) then
 info = QMCKL_INVALID_CONTEXT
 return
endif

if (m <= 0_8) then
 info = QMCKL_INVALID_ARG_4
 return
endif

if (n <= 0_8) then
 info = QMCKL_INVALID_ARG_5
 return
endif

if (k <= 0_8) then
 info = QMCKL_INVALID_ARG_6
 return
endif

if (LDA /= m) then
 info = QMCKL_INVALID_ARG_9
 return
endif

if (LDB /= k) then
 info = QMCKL_INVALID_ARG_10
 return
endif

if (LDC /= m) then
 info = QMCKL_INVALID_ARG_13
 return
endif

if (alpha == 1.0d0 .and. beta == 0.0d0) then
C = matmul(A,B)
else
C = beta*C + alpha*matmul(A,B)
endif
end function qmckl_dgemm_N_N_f

qmckl_adjoint

Matrix adjoint. Given a matrix M, returns a matrix M⁻¹ such that:

\[ M · M^{-1} = I \]

This is a native Fortran implementation hand written (by: A. Scemama) only for small matrices (<=5x5).

TODO: Add description about the external library dependence.

qmckl_context context in Global state
int64_t m in Number of rows of the input matrix
int64_t n in Number of columns of the input matrix
int64_t lda in Leading dimension of array A
double A[][lda] inout Array containing the $m \times n$ matrix $A$
double det_l inout determinant of A

Requirements

  • context is not QMCKL_NULL_CONTEXT
  • m > 0
  • n > 0
  • lda >= m
  • A is allocated with at least $m \times n \times 8$ bytes

C header

qmckl_exit_code qmckl_adjoint (
const qmckl_context context,
const int64_t m,
const int64_t n,
const int64_t lda,
double* A,
double det_l );

Source

integer function qmckl_adjoint_f(context, ma, na, LDA, A, det_l) &
 result(info)
use qmckl
implicit none
integer(qmckl_context)  , intent(in)  :: context
double precision, intent(inout) :: A (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: ma
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
integer :: i,j

info = QMCKL_SUCCESS

select case (na)
case default
print *," TODO: Implement general adjoint"
stop 0
case (5)
call adjoint5(a,LDA,na,det_l)
case (4)
call adjoint4(a,LDA,na,det_l)

case (3)
call adjoint3(a,LDA,na,det_l)
case (2)
call adjoint2(a,LDA,na,det_l)
case (1)
call adjoint1(a,LDA,na,det_l)
case (0)
det_l=1.d0
end select
end function qmckl_adjoint_f

subroutine adjoint1(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l

call cofactor1(a,LDA,na,det_l)
end

subroutine adjoint2(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(2,2)

call cofactor2(a,LDA,na,det_l)

! Calculate the transpose
b(1,1) = a(1,1)
b(1,2) = a(2,1)
b(2,1) = a(1,2)
b(2,2) = a(2,2)
a(1,1) = b(1,1)
a(1,2) = b(1,2)
a(2,1) = b(2,1)
a(2,2) = b(2,2)
end

subroutine adjoint3(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(3,3)

call cofactor3(a,LDA,na,det_l)

! Calculate the transpose
b(1,1) = a(1,1)
b(1,2) = a(2,1)
b(1,3) = a(3,1)
b(2,1) = a(1,2)
b(2,2) = a(2,2)
b(2,3) = a(3,2)
b(3,1) = a(1,3)
b(3,2) = a(2,3)
b(3,3) = a(3,3)
! copy
a(1,1) = b(1,1)
a(2,1) = b(2,1)
a(3,1) = b(3,1)
a(1,2) = b(1,2)
a(2,2) = b(2,2)
a(3,2) = b(3,2)
a(1,3) = b(1,3)
a(2,3) = b(2,3)
a(3,3) = b(3,3)
end

subroutine adjoint4(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(4,4)

call cofactor4(a,LDA,na,det_l)

! Calculate the transpose
b(1,1) = a(1,1)
b(1,2) = a(2,1)
b(1,3) = a(3,1)
b(1,4) = a(4,1)
b(2,1) = a(1,2)
b(2,2) = a(2,2)
b(2,3) = a(3,2)
b(2,4) = a(4,2)
b(3,1) = a(1,3)
b(3,2) = a(2,3)
b(3,3) = a(3,3)
b(3,4) = a(4,3)
b(4,1) = a(1,4)
b(4,2) = a(2,4)
b(4,3) = a(3,4)
b(4,4) = a(4,4)
! copy
a(1,1) = b(1,1)
a(2,1) = b(2,1)
a(3,1) = b(3,1)
a(4,1) = b(4,1)
a(1,2) = b(1,2)
a(2,2) = b(2,2)
a(3,2) = b(3,2)
a(4,2) = b(4,2)
a(1,3) = b(1,3)
a(2,3) = b(2,3)
a(3,3) = b(3,3)
a(4,3) = b(4,3)
a(1,4) = b(1,4)
a(2,4) = b(2,4)
a(3,4) = b(3,4)
a(4,4) = b(4,4)
end

subroutine adjoint5(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(5,5)

call cofactor5(a,LDA,na,det_l)

! Calculate the transpose
b(1,1) = a(1,1)
b(1,2) = a(2,1)
b(1,3) = a(3,1)
b(1,4) = a(4,1)
b(1,5) = a(5,1)
b(2,1) = a(1,2)
b(2,2) = a(2,2)
b(2,3) = a(3,2)
b(2,4) = a(4,2)
b(2,5) = a(5,2)
b(3,1) = a(1,3)
b(3,2) = a(2,3)
b(3,3) = a(3,3)
b(3,4) = a(4,3)
b(3,5) = a(5,3)
b(4,1) = a(1,4)
b(4,2) = a(2,4)
b(4,3) = a(3,4)
b(4,4) = a(4,4)
b(4,5) = a(5,4)
b(5,1) = a(1,5)
b(5,2) = a(2,5)
b(5,3) = a(3,5)
b(5,4) = a(4,5)
b(5,5) = a(5,5)
! copy
a(1,1) = b(1,1)
a(2,1) = b(2,1)
a(3,1) = b(3,1)
a(4,1) = b(4,1)
a(5,1) = b(5,1)
a(1,2) = b(1,2)
a(2,2) = b(2,2)
a(3,2) = b(3,2)
a(4,2) = b(4,2)
a(5,2) = b(5,2)
a(1,3) = b(1,3)
a(2,3) = b(2,3)
a(3,3) = b(3,3)
a(4,3) = b(4,3)
a(5,3) = b(5,3)
a(1,4) = b(1,4)
a(2,4) = b(2,4)
a(3,4) = b(3,4)
a(4,4) = b(4,4)
a(5,4) = b(5,4)
a(1,5) = b(1,5)
a(2,5) = b(2,5)
a(3,5) = b(3,5)
a(4,5) = b(4,5)
a(5,5) = b(5,5)
end

subroutine cofactor1(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l

det_l = a(1,1)
a(1,1) = 1.d0
end

subroutine cofactor2(a,LDA,na,det_l)
implicit none
double precision :: a (LDA,na)
integer*8        :: LDA
integer*8        :: na
double precision :: det_l
double precision :: b(2,2)

b(1,1) = a(1,1)
b(2,1) = a(2,1)
b(1,2) = a(1,2)
b(2,2) = a(2,2)
det_l = a(1,1)*a(2,2) - a(1,2)*a(2,1)
a(1,1) = b(2,2)
a(2,1) = -b(2,1)
a(1,2) = -b(1,2)
a(2,2) = b(1,1)
end

subroutine cofactor3(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(4,3)
integer :: i
det_l = a(1,1)*(a(2,2)*a(3,3)-a(2,3)*a(3,2)) &
    -a(1,2)*(a(2,1)*a(3,3)-a(2,3)*a(3,1)) &
    +a(1,3)*(a(2,1)*a(3,2)-a(2,2)*a(3,1))
do i=1,4
b(i,1) = a(i,1)
b(i,2) = a(i,2)
b(i,3) = a(i,3)
end do
a(1,1) =  b(2,2)*b(3,3) - b(2,3)*b(3,2)
a(2,1) =  b(2,3)*b(3,1) - b(2,1)*b(3,3)
a(3,1) =  b(2,1)*b(3,2) - b(2,2)*b(3,1)

a(1,2) =  b(1,3)*b(3,2) - b(1,2)*b(3,3)
a(2,2) =  b(1,1)*b(3,3) - b(1,3)*b(3,1)
a(3,2) =  b(1,2)*b(3,1) - b(1,1)*b(3,2)

a(1,3) =  b(1,2)*b(2,3) - b(1,3)*b(2,2)
a(2,3) =  b(1,3)*b(2,1) - b(1,1)*b(2,3)
a(3,3) =  b(1,1)*b(2,2) - b(1,2)*b(2,1)

end

subroutine cofactor4(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(4,4)
integer :: i,j
det_l =  a(1,1)*(a(2,2)*(a(3,3)*a(4,4)-a(3,4)*a(4,3))  &
             -a(2,3)*(a(3,2)*a(4,4)-a(3,4)*a(4,2))  &
             +a(2,4)*(a(3,2)*a(4,3)-a(3,3)*a(4,2))) &
     -a(1,2)*(a(2,1)*(a(3,3)*a(4,4)-a(3,4)*a(4,3))  &
             -a(2,3)*(a(3,1)*a(4,4)-a(3,4)*a(4,1))  &
             +a(2,4)*(a(3,1)*a(4,3)-a(3,3)*a(4,1))) &
     +a(1,3)*(a(2,1)*(a(3,2)*a(4,4)-a(3,4)*a(4,2))  &
             -a(2,2)*(a(3,1)*a(4,4)-a(3,4)*a(4,1))  &
             +a(2,4)*(a(3,1)*a(4,2)-a(3,2)*a(4,1))) &
     -a(1,4)*(a(2,1)*(a(3,2)*a(4,3)-a(3,3)*a(4,2))  &
             -a(2,2)*(a(3,1)*a(4,3)-a(3,3)*a(4,1))  &
             +a(2,3)*(a(3,1)*a(4,2)-a(3,2)*a(4,1)))
do i=1,4
b(1,i) = a(1,i)
b(2,i) = a(2,i)
b(3,i) = a(3,i)
b(4,i) = a(4,i)
end do

a(1,1) =  b(2,2)*(b(3,3)*b(4,4)-b(3,4)*b(4,3))-b(2,3)*(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2,4)*b(4,3))+b(1,3)*(b(2,1)*b(4,4)-b(2,4)*b(4,1))-b(1,4)*(b(2,1)*b(4,3)-b(2,3)*b(4,1))
a(3,3) =  b(1,1)*(b(2,2)*b(4,4)-b(2,4)*b(4,2))-b(1,2)*(b(2,1)*b(4,4)-b(2,4)*b(4,1))+b(1,4)*(b(2,1)*b(4,2)-b(2,2)*b(4,1))
a(4,3) = -b(1,1)*(b(2,2)*b(4,3)-b(2,3)*b(4,2))+b(1,2)*(b(2,1)*b(4,3)-b(2,3)*b(4,1))-b(1,3)*(b(2,1)*b(4,2)-b(2,2)*b(4,1))

a(1,4) = -b(1,2)*(b(2,3)*b(3,4)-b(2,4)*b(3,3))+b(1,3)*(b(2,2)*b(3,4)-b(2,4)*b(3,2))-b(1,4)*(b(2,2)*b(3,3)-b(2,3)*b(3,2))
a(2,4) =  b(1,1)*(b(2,3)*b(3,4)-b(2,4)*b(3,3))-b(1,3)*(b(2,1)*b(3,4)-b(2,4)*b(3,1))+b(1,4)*(b(2,1)*b(3,3)-b(2,3)*b(3,1))
a(3,4) = -b(1,1)*(b(2,2)*b(3,4)-b(2,4)*b(3,2))+b(1,2)*(b(2,1)*b(3,4)-b(2,4)*b(3,1))-b(1,4)*(b(2,1)*b(3,2)-b(2,2)*b(3,1))
a(4,4) =  b(1,1)*(b(2,2)*b(3,3)-b(2,3)*b(3,2))-b(1,2)*(b(2,1)*b(3,3)-b(2,3)*b(3,1))+b(1,3)*(b(2,1)*b(3,2)-b(2,2)*b(3,1))

end

subroutine cofactor5(a,LDA,na,det_l)
implicit none
double precision, intent(inout) :: a (LDA,na)
integer*8, intent(in)             :: LDA
integer*8, intent(in)             :: na
double precision, intent(inout) :: det_l
double precision :: b(5,5)
integer :: i,j
det_l = a(1,1)*(a(2,2)*(a(3,3)*(a(4,4)*a(5,5)-a(4,5)*a(5,4))-a(3,4)*( &
a(4,3)*a(5,5)-a(4,5)*a(5,3))+a(3,5)*(a(4,3)*a(5,4)-a(4,4)*a(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