Skip to content

Commit

Permalink
Use views in helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmul1114 committed Mar 15, 2024
1 parent 18f8573 commit 6a163e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gcp-algorithms/fastals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ function FastALS_mttkrps_helper!(Zn, U, n_star, n, side, N, Jns, Kns, buffers)
if side == "right"
khatrirao!(buffers.helper_buffers_descending[n_star-n+1], U[reverse(1:n-1)]...)
for r in 1:size(U[n])[2]
U[n][:, r] = reshape(view(Zn, :, r), (Jns[n-1], size(U[n])[1]))' * buffers.helper_buffers_descending[n_star-n+1][:, r]
mul!(view(U[n], :, r), reshape(view(Zn, :, r), (Jns[n-1], size(U[n])[1]))', view(buffers.helper_buffers_descending[n_star-n+1], :, r))
end
elseif side == "left"
khatrirao!(buffers.helper_buffers_ascending[n-n_star], U[reverse(n+1:N)]...)
for r in 1:size(U[n])[2]
U[n][:, r] = reshape(view(Zn, :, r), (size(U[n])[1], Kns[n])) * buffers.helper_buffers_ascending[n-n_star][:, r]
mul!(view(U[n], :, r), reshape(view(Zn, :, r), (size(U[n])[1], Kns[n])), view(buffers.helper_buffers_ascending[n-n_star], :, r))
end
end
end
Expand Down

0 comments on commit 6a163e3

Please sign in to comment.