1
- VERSION >= v " 0.4.0-dev+6521 " && __precompile__ ()
1
+ __precompile__ ()
2
2
3
3
module InverseLaplace
4
4
5
- using Compat
6
-
5
+ import SpecialFunctions
7
6
# I have to export everything in order for Documenter.jl to find
8
7
# the strings. A few hours of work would probably be enough to solve the problem.
9
8
export ILt, setNterms
10
- export Weeks, WeeksErr, optimize, opteval, setparameters
9
+ # export optimize, opteval # Broken at the moment
10
+ export Weeks, WeeksErr, setparameters
11
11
export Talbot, GWR, ILT
12
12
export TransformPair, ILtPair, abserr, iltpair_power
13
13
export ilt, talbot, gwr
14
14
15
- @compat abstract type AbstractILt end
15
+ abstract type AbstractILt end
16
16
17
17
"""
18
18
ft::Talbot = Talbot(func::Function, Nterms::Integer=32)
19
19
20
20
return `ft`, which estimates the inverse Laplace transform of `func` with
21
21
the fixed Talbot algorithm. `ft(t)` evaluates the transform at `t`. You may
22
- want to tune `Nterms` together with `setprecision(BigFloat,x)`.
22
+ want to tune `Nterms` together with `setprecision(BigFloat, x)`.
23
23
24
24
# Example
25
25
26
26
Compute the inverse transform of the transform of `cos` at argument `pi/2`.
27
27
```julia-repl
28
- julia> ft = Talbot(s -> s/(s^2+ 1), 80);
28
+ julia> ft = Talbot(s -> s/(s^2 + 1), 80);
29
29
30
30
julia> ft(pi/2)
31
31
-3.5366510684573195e-5
@@ -42,12 +42,13 @@ julia> Float64(ft(big(pi)/2))
42
42
function for complex arguments. The GWR method is, in general, less accurate and
43
43
less stable, but does not evaluate the Laplace transform function for complex arguments.
44
44
"""
45
- type Talbot{T<: Base.Callable } <: AbstractILt
46
- LSfunc :: T # Laplace space function
45
+ struct Talbot{T<: Base.Callable } <: AbstractILt
46
+ Laplace_space_func :: T # Laplace space function
47
47
Nterms:: Int
48
48
end
49
49
50
- Talbot (LSfunc:: Base.Callable ) = Talbot (LSfunc,32 )
50
+ const talbot_default_num_terms = 32
51
+ Talbot (Laplace_space_func:: Base.Callable ) = Talbot (Laplace_space_func, talbot_default_num_terms)
51
52
52
53
"""
53
54
ft::GWR = GWR(func::Function, Nterms::Integer=16)
@@ -59,18 +60,19 @@ the GWR algorithm. `ft(t)` evaluates the transform at `t`.
59
60
60
61
Compute the inverse transform of the transform of `cos` at argument `pi/2`.
61
62
```
62
- julia> ft = GWR(s -> s/(s^2+ 1), 16);
63
+ julia> ft = GWR(s -> s/(s^2 + 1), 16);
63
64
64
65
julia> ft(pi/2)
65
66
-0.001
66
67
```
67
68
"""
68
- type GWR{T<: Base.Callable } <: AbstractILt
69
- LSfunc :: T # Laplace space function
69
+ struct GWR{T<: Base.Callable } <: AbstractILt
70
+ Laplace_space_func :: T # Laplace space function
70
71
Nterms:: Int
71
72
end
72
73
73
- GWR (LSfunc:: Base.Callable ) = GWR (LSfunc,16 )
74
+ const gwr_default_num_terms = 16
75
+ GWR (Laplace_space_func:: Base.Callable ) = GWR (Laplace_space_func, gwr_default_num_terms)
74
76
75
77
"""
76
78
ILT(function, Nterms=32)
@@ -80,14 +82,13 @@ This is an alias for the default `Talbot()` method.
80
82
ILT (args... ) = Talbot (args... )
81
83
82
84
function Base. show (io:: IO , ailt:: AbstractILt )
83
- print (io, string (typeof (ailt)), " (Nterms=" , ailt. Nterms,' )' )
85
+ print (io, string (typeof (ailt)), " (Nterms=" , ailt. Nterms, ' )' )
84
86
end
85
87
86
88
# TODO get rid of this in favor of above.
87
89
# Rely on broadcasting, as well.
88
-
89
- type ILt{T<: Base.Callable , V<: Base.Callable } <: AbstractILt
90
- LSfunc:: T
90
+ struct ILt{T<: Base.Callable , V<: Base.Callable } <: AbstractILt
91
+ Laplace_space_func:: T
91
92
iltfunc:: V
92
93
Nterms:: Int
93
94
end
@@ -109,7 +110,7 @@ of `32` may give extremely inaccurate estimates.
109
110
## Example
110
111
111
112
```julia
112
- julia> itr = ILt( s -> 1/(1+ s^2), talbot);
113
+ julia> itr = ILt( s -> 1/(1 + s^2), talbot);
113
114
114
115
julia> itr([ pi/4, pi/2, 3*pi/4, -pi])
115
116
4-element Array{Float64,1}:
@@ -119,7 +120,7 @@ julia> itr([ pi/4, pi/2, 3*pi/4, -pi])
119
120
-3.66676e-12
120
121
```
121
122
"""
122
- ILt (func,iltfunc) = ILt (func, iltfunc, 32 )
123
+ ILt (func, iltfunc) = ILt (func, iltfunc, talbot_default_num_terms )
123
124
124
125
# Make this the default
125
126
"""
@@ -128,8 +129,7 @@ ILt(func,iltfunc) = ILt(func, iltfunc, 32)
128
129
`ilt` is an alias for the default inverse Laplace transform method `talbot`.
129
130
"""
130
131
ilt (args... ) = talbot (args... )
131
- ILt (func) = ILt (func, talbot, 32 )
132
-
132
+ ILt (func) = ILt (func, talbot, talbot_default_num_terms)
133
133
134
134
"""
135
135
setNterms(ailt::AbstractILt, Nterms::Integer)
@@ -140,18 +140,19 @@ calls `ailt(t)` reflect the new value of `Nterms`.
140
140
"""
141
141
setNterms (ailt:: AbstractILt , N:: Integer ) = (ailt. Nterms = N)
142
142
143
- (ailt:: ILt )(t) = ailt. iltfunc (ailt. LSfunc, t, ailt. Nterms)
144
- (ailt:: ILt )(t,N) = ailt. iltfunc (ailt. LSfunc, t, N)
143
+ # # Make the ILT data types callable.
144
+ (ailt:: ILt )(t) = ailt. iltfunc (ailt. Laplace_space_func, t, ailt. Nterms)
145
+ (ailt:: ILt )(t,N) = ailt. iltfunc (ailt. Laplace_space_func, t, N)
145
146
146
- (ailt:: Talbot )(t) = talbot (ailt. LSfunc , t, ailt. Nterms)
147
- (ailt:: Talbot )(t, n:: Integer ) = talbot (ailt. LSfunc , t, n)
147
+ (ailt:: Talbot )(t) = talbot (ailt. Laplace_space_func , t, ailt. Nterms)
148
+ (ailt:: Talbot )(t, n:: Integer ) = talbot (ailt. Laplace_space_func , t, n)
148
149
149
- (ailt:: GWR )(t) = gwr (ailt. LSfunc , t, ailt. Nterms)
150
- (ailt:: GWR )(t, n:: Integer ) = gwr (ailt. LSfunc , t, n)
150
+ (ailt:: GWR )(t) = gwr (ailt. Laplace_space_func , t, ailt. Nterms)
151
+ (ailt:: GWR )(t, n:: Integer ) = gwr (ailt. Laplace_space_func , t, n)
151
152
152
153
include (" fixed_talbot.jl" )
153
154
include (" gwr.jl" )
154
155
include (" weeks.jl" )
155
- include (" test .jl" )
156
+ include (" pairtest .jl" )
156
157
157
158
end # module
0 commit comments