-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_w.f90
50 lines (38 loc) · 1.05 KB
/
update_w.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
!
! File: distance.f90
! Author: peter
!
! Created on May 6, 2020, 12:49 PM
!
module update_w
use init
use init
use print_mat
use matrix_mult
use trans
use distance
use add_matrix
implicit none
private
public::w_update
interface w_update
procedure w_update
end interface w_update
contains
function w_update(W, H, A)result(W_up)
real, Dimension(:,:), intent(in)::A,H,W
! Shape is (A first and Rank or H first)
real, Dimension(size(A,1),size(H,1))::AH_T
real, Dimension(size(A,1),size(H,1))::WHH_T
real, Dimension(size(W,1),size(W,2))::W_up
integer::i,j
AH_T = matmul(A, TRANSPOSE(H))
WHH_T = matmul(matmul(W,H), TRANSPOSE(H))+0.0000000001
W_up = W
do i = 1, size(H,1)
do j = 1, size(H,2)
W_up(i, j) = W_up(i, j) * AH_T(i, j) / WHH_T(i, j)
end do
end do
end function w_update
end module update_w