Skip to content

Commit

Permalink
transpose crot to avoid temporary arrays in zmat reader
Browse files Browse the repository at this point in the history
  • Loading branch information
aoterodelaroza committed Mar 6, 2024
1 parent 138b041 commit 27245dc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -7444,18 +7444,18 @@ function zmat_step(x0_,x1_,x2_,d_,ang_,dieh_)
x2 = x2 - x0

! x1-x0 is aligned to z
crot(3,:) = x1 / norm2(x1)
crot(:,3) = x1 / norm2(x1)
xaux = (/0d0,0d0,1d0/)
crot(1,:) = cross(x1,xaux)
if (abs(norm2(crot(1,:))) < 1d-12) then
crot(:,1) = cross(x1,xaux)
if (abs(norm2(crot(:,1))) < 1d-12) then
xaux = (/0d0,1d0,0d0/)
crot(1,:) = cross(x1,xaux)
crot(:,1) = cross(x1,xaux)
end if
crot(1,:) = crot(1,:) / norm2(crot(1,:))
crot(2,:) = cross(crot(3,:),crot(1,:))
crot(:,1) = crot(:,1) / norm2(crot(:,1))
crot(:,2) = cross(crot(:,3),crot(:,1))

! transform x2 b transforming to spherical coordinates and back
x2p = matmul(crot,x2)
x2p = matmul(x2,crot)
call tosphere(x2p,r2,asph)
rf = d
phf = 0.5d0 * pi - ang
Expand All @@ -7464,7 +7464,7 @@ function zmat_step(x0_,x1_,x2_,d_,ang_,dieh_)
xf(2) = rf * cos(phf) * sin(thf)
xf(3) = rf * sin(phf)
call matinv(crot,3)
zmat_step = matmul(crot,xf) + x0
zmat_step = matmul(xf,crot) + x0

end function zmat_step

Expand Down

0 comments on commit 27245dc

Please sign in to comment.