Skip to content

Commit

Permalink
Merge pull request #169 from tjjarvinen/use_views
Browse files Browse the repository at this point in the history
Use views instead of slicing
  • Loading branch information
cortner committed Sep 13, 2023
2 parents cdb8902 + 314b2cf commit 3e4b060
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mlips.jl
Expand Up @@ -216,7 +216,7 @@ function energy(shipB::IPBasis, at::AbstractAtoms{T}) where {T}
j, R, Z = neigsz!(tmpRZ, nlist, at, i)
fill!(B, 0)
evaluate!(B, tmp, shipB, R, Z, at.Z[i])
E[:] .+= B[:]
E .+= B
end
return E
end
Expand Down Expand Up @@ -246,8 +246,8 @@ function forces_inner!(shipB::IPBasis, at::AbstractAtoms{T},
fill!(B, 0)
evaluate_d!(dB, tmp, shipB, R, Z, at.Z[i])
for a = 1:length(R)
F[j[a], :] .-= dB[:, a]
F[i, :] .+= dB[:, a]
F[j[a], :] .-= @view dB[:, a]
F[i, :] .+= @view dB[:, a]
end
end
return [ F[:, iB] for iB = 1:length(shipB) ]
Expand All @@ -271,7 +271,7 @@ function virial(shipB::IPBasis, at::AbstractAtoms{T}) where {T}
fill!(dB, zero(JVec{T}))
evaluate_d!(dB, tmp, shipB, R, Z, at.Z[i])
for iB = 1:length(shipB)
V[iB] += site_virial(dB[iB, :], R)
V[iB] += site_virial( view( dB, iB, : ), R)
end
end
return V
Expand Down

0 comments on commit 3e4b060

Please sign in to comment.