1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-06-13 16:55:35 +02:00
qmckl/org/qmckl_utils.org

6.1 KiB

Utility functions

Matrix operations

qmckl_transpose

Transposes a matrix: $B_{ji} = A_{ij}$

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
double A[][lda] in Array containing the $m \times n$ matrix $A$
int64_t lda in Leading dimension of array A
double B[][ldb] out Array containing the $n \times m$ matrix $B$
int64_t ldb in Leading dimension of array B

Requirements

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

C header

qmckl_exit_code qmckl_transpose (
      const qmckl_context context,
      const int64_t m,
      const int64_t n,
      const double* A,
      const int64_t lda,
      double* const B,
      const int64_t ldb );

Source

integer function qmckl_transpose_f(context, m, n, A, LDA, B, LDB) &
 result(info)
use qmckl
implicit none
integer(qmckl_context)  , intent(in)  :: context
integer*8  , intent(in)  :: m, n
integer*8  , intent(in)  :: lda
real*8     , intent(in)  :: A(lda,*)
integer*8  , intent(in)  :: ldb
real*8     , intent(out) :: B(ldb,*)

integer*8 :: i,j

info = QMCKL_SUCCESS

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

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

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

if (LDA < m) then
 info = QMCKL_INVALID_ARG_5
 return
endif

if (LDB < n) then
 info = QMCKL_INVALID_ARG_7
 return
endif

do j=1,m
 do i=1,n
   B(i,j) = A(j,i)
end do
end do

end function qmckl_transpose_f