-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmat_mul.f90
113 lines (74 loc) · 1.96 KB
/
mat_mul.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
! performs matrix-matrix multiply
! C=A*B
subroutine mat_mul(m, A, B, C)
use para, only : Dp, zzero, zone
implicit none
integer,intent(in) :: m
complex(Dp) :: ALPHA
complex(Dp) :: BETA
complex(Dp), intent(in) :: A(m, m)
complex(Dp), intent(in) :: B(m, m)
complex(Dp), intent(out) :: C(m, m)
ALPHA= zone
BETA = zzero
!C(:,:)= zzero
call ZGEMM('N','N',m,m,m,ALPHA, &
& A,m,B,m,BETA,C,m)
return
end subroutine mat_mul
! performs matrix-matrix multiply
! C=A*B'
subroutine mat_mul_c(m, A, B, C)
use para, only : Dp, zzero, zone
implicit none
integer,intent(in) :: m
complex(Dp) :: ALPHA
complex(Dp) :: BETA
complex(Dp), intent(in) :: A(m, m)
complex(Dp), intent(in) :: B(m, m)
complex(Dp), intent(out) :: C(m, m)
ALPHA= zone
BETA = zzero
!C(:,:)= zzero
call ZGEMM('N','C',m,m,m,ALPHA, &
& A,m,B,m,BETA,C,m)
return
end subroutine mat_mul_c
! performs matrix-matrix multiply
! C=A*B
! B is a diagnoal matrix
subroutine mat_mul_diagB(m, A, B, C)
use para, only : Dp
implicit none
integer,intent(in) :: m
complex(Dp), intent(in) :: A(m, m)
complex(Dp), intent(in) :: B(m)
complex(Dp), intent(out) :: C(m, m)
integer :: i
integer :: j
do i=1, m
do j=1, m
C(i,j)= A(i,j)*B(j)
enddo
enddo
return
end subroutine mat_mul_diagB
! performs matrix-matrix multiply
! C=A*B
! A is a diagnoal matrix
subroutine mat_mul_diagA(m, A, B, C)
use para, only : Dp
implicit none
integer,intent(in) :: m
complex(Dp), intent(in) :: A(m)
complex(Dp), intent(in) :: B(m, m)
complex(Dp), intent(out) :: C(m, m)
integer :: i
integer :: j
do i=1, m
do j=1, m
C(i,j)= A(i)*B(i,j)
enddo
enddo
return
end subroutine mat_mul_diagA