Skip to content

Commit 4cfd95f

Browse files
committed
preserve floatingpoint precision
1 parent dd24036 commit 4cfd95f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/expm.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ end
4949
@inbounds b = A[3]
5050
@inbounds d = A[4]
5151

52-
z = sqrt((a-d)*(a-d) + 4.0*b*c )
53-
e = exp(a/2.0 + d/2.0 - z/2.0)
54-
f = exp(a/2.0 + d/2.0 + z/2.0)
55-
zr = 1/z
52+
z = sqrt((a - d)*(a - d) + 4*b*c )
53+
e = exp((a + d - z)/2)
54+
f = exp((a + d + z)/2)
55+
zr = inv(z)
5656

57-
m11 = (-e*(a - d - z) + f*(a - d + z)) * 0.5 * zr
57+
m11 = (-e*(a - d - z) + f*(a - d + z)) * zr/2
5858
m12 = (f-e) * b * zr
5959
m21 = (f-e) * c * zr
60-
m22 = (-e*(-a + d - z) + f*(-a + d + z)) * 0.5 * zr
60+
m22 = (-e*(-a + d - z) + f*(-a + d + z)) * zr/2
6161

6262
(newtype)((m11, m21, m12, m22))
6363
end

0 commit comments

Comments
 (0)