Skip to content

Commit

Permalink
Update ComplexElliptic.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
tinatorabi authored Feb 22, 2024
1 parent e815699 commit 3c673a5
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/ComplexElliptic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module ComplexElliptic
Author: Tina Torabi
Year: 2023
"""

function ellipkkp(L)
# Complete elliptic integral of the first kind, with complement.
if L > 10
Expand All @@ -26,7 +25,7 @@ function ellipkkp(L)
c1 = (a0 - b0) / 2
i1 += 1
w1 = 2^i1 * c1^2
mm = maximum(w1)
mm = maximum([w1]) # Ensure w1 is in an array for maximum to work correctly
s0 += w1
a0 = a1
b0 = b1
Expand All @@ -37,30 +36,27 @@ function ellipkkp(L)
K = Inf
end

if nargout() > 1
a0 = 1.0
b0 = sqrt(m)
a1=0
s0 = 1 - m
i1 = 0
mm = 1.0
while mm > eps()
a1 = (a0 + b0) / 2
b1 = sqrt(a0 * b0)
c1 = (a0 - b0) / 2
i1 += 1
w1 = 2^i1 * c1^2
mm = maximum(w1)
s0 += w1
a0 = a1
b0 = b1
end
Kp = π / (2 * a1)
if m == 0
Kp = Inf
end
else
Kp = nothing
# Recalculate for Kp using the complement
a0 = 1.0
b0 = sqrt(m)
a1 = 0
s0 = 1 - m
i1 = 0
mm = 1.0
while mm > eps()
a1 = (a0 + b0) / 2
b1 = sqrt(a0 * b0)
c1 = (a0 - b0) / 2
i1 += 1
w1 = 2^i1 * c1^2
mm = maximum([w1]) # Ensure w1 is in an array for maximum to work correctly
s0 += w1
a0 = a1
b0 = b1
end
Kp = π / (2 * a1)
if m == 0
Kp = Inf
end

return K, Kp
Expand Down

2 comments on commit 3c673a5

@tinatorabi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Version 1.0.2 already exists

Please sign in to comment.