Skip to content

Commit e9b893a

Browse files
committed
format code, fix typos/thinkos
1 parent 473f676 commit e9b893a

File tree

5 files changed

+46
-45
lines changed

5 files changed

+46
-45
lines changed

docs/src/index.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# InverseLaplace
22

3-
*Numerical inverse Laplace transform.*
3+
*Numerical inverse Laplace transform*
44

55
The source repository is [https://github.com/jlapeyre/InverseLaplace.jl](https://github.com/jlapeyre/InverseLaplace.jl).
66

7-
This package provides three numerical algorithms for numerically inverting Laplace transforms.
8-
InverseLaplace v0.1.0 is the last version that supports Julia v0.6.
7+
This package provides three algorithms for numerically inverting Laplace transforms.
8+
`InverseLaplace` v0.1.0 is the last version that supports Julia v0.6.
99
Optimization of the Weeks method is temporarily disabled for Julia v0.7.
1010

1111
## Contents
@@ -18,29 +18,30 @@ Optimization of the Weeks method is temporarily disabled for Julia v0.7.
1818
```@index
1919
```
2020

21-
## Inverse Laplace transform methods
21+
## Inverse Laplace transform algorithms
2222

23-
Constructing these Julia types, corresponding to different numerical methods,
24-
returns a callable object that evaluates the inverse transform at specified points.
23+
Constructing these Julia types, corresponding to different numerical algorithms,
24+
returns a callable object that evaluates the inverse Laplace transform at specified points.
2525

2626
```@docs
27-
ILT
2827
Talbot
28+
ILT
2929
GWR
3030
Weeks
3131
WeeksErr
3232
```
3333

3434
## Setting parameters
3535

36-
The inverse Laplace tranform routines should not be treated as black boxes. They are prone to instability and can give inaccurate or
37-
wrong results. There are some parameters you can set to try to minimize these problems.
36+
The inverse Laplace tranform routines should not be treated as black boxes. They are
37+
prone to instability and can give inaccurate or wrong results. There are some
38+
parameters you can set to try to minimize these problems.
3839

3940
```@docs
40-
setNterms
41-
optimize
42-
opteval
43-
setparameters
41+
InverseLaplace.setNterms
42+
InverseLaplace.optimize
43+
InverseLaplace.opteval
44+
InverseLaplace.setparameters
4445
```
4546

4647
## Analzying accuracy
@@ -63,13 +64,11 @@ gwr
6364
InverseLaplace.talbotarr
6465
```
6566

66-
6767
## References
6868

6969
J.A.C Weideman, *Algorithms for Parameter Selection in the Weeks Method for Inverting the Laplace Transform,
7070
SIAM Journal on Scientific Computing*, Vol. 21, pp. 111-128 **(1999)**
7171

72-
7372
Abate, J. and Valkó, P.P., *Multi-precision Laplace transform inversion
7473
International Journal for Numerical Methods in Engineering*, Vol. 60 (Iss. 5-7) pp 979–993 **(2004)**
7574

src/InverseLaplace.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ abstract type AbstractILt end
1717
"""
1818
ft::Talbot = Talbot(func::Function, Nterms::Integer=32)
1919
20-
return `ft`, which estimates the inverse Laplace transform of `func` with
20+
Return `ft`, which estimates the inverse Laplace transform of `func` with
2121
the fixed Talbot algorithm. `ft(t)` evaluates the transform at `t`. You may
2222
want to tune `Nterms` together with `setprecision(BigFloat, x)`.
2323
2424
# Example
2525
2626
Compute the inverse transform of the transform of `cos` at argument `pi/2`.
2727
```julia-repl
28-
julia> ft = Talbot(s -> s/(s^2 + 1), 80);
28+
julia> ft = Talbot(s -> s / (s^2 + 1), 80);
2929
30-
julia> ft(pi/2)
30+
julia> ft(pi / 2)
3131
-3.5366510684573195e-5
3232
```
3333
3434
Note that given `Float64` input, the precision of the returned value may not be satisfactory.
3535
```julia-repl
36-
julia> Float64(ft(big(pi)/2))
36+
julia> Float64(ft(big(pi) / 2))
3737
2.114425886215604e-49
3838
```
3939
@@ -53,16 +53,16 @@ Talbot(Laplace_space_func::Base.Callable) = Talbot(Laplace_space_func, talbot_de
5353
"""
5454
ft::GWR = GWR(func::Function, Nterms::Integer=16)
5555
56-
return `ft`, which estimates the inverse Laplace transform of `func` with
56+
Return `ft`, which estimates the inverse Laplace transform of `func` with
5757
the GWR algorithm. `ft(t)` evaluates the transform at `t`.
5858
5959
# Example
6060
61-
Compute the inverse transform of the transform of `cos` at argument `pi/2`.
61+
Compute the inverse transform of the transform of `cos` at argument `pi / 2`.
6262
```
63-
julia> ft = GWR(s -> s/(s^2 + 1), 16);
63+
julia> ft = GWR(s -> s / (s^2 + 1), 16);
6464
65-
julia> ft(pi/2)
65+
julia> ft(pi / 2)
6666
-0.001
6767
```
6868
"""
@@ -85,7 +85,7 @@ function Base.show(io::IO, ailt::AbstractILt)
8585
print(io, string(typeof(ailt)), "(Nterms=", ailt.Nterms, ')')
8686
end
8787

88-
# TODO get rid of this in favor of above.
88+
# TODO: get rid of this in favor of above.
8989
# Rely on broadcasting, as well.
9090
struct ILt{T<:Base.Callable, V<:Base.Callable} <: AbstractILt
9191
Laplace_space_func::T
@@ -98,7 +98,7 @@ end
9898
9999
* deprecated. Use, ILT, Talbot, GWR, or Weeks instead *
100100
101-
return an object that estimates the inverse Laplace transform of
101+
Return an object that estimates the inverse Laplace transform of
102102
the function `func` using the algorithm implemented by function `iltfunc`.
103103
`itrans(t)` estimates the inverse transform for argument `t`. The
104104
accuracy of the estimates depends strongly on the choice of `iltfunc`, `t`, `Nterms`,

src/fixed_talbot.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
Evaluate the inverse Laplace transform of `func` at the point `t`. Use `M` terms in the algorithm.
1111
For `typeof(t)` is `Float64`, the default for `M` is `32`. For `BigFloat` the default is `64`.
1212
13-
If `BigFloat` precision is larger than default, try increasing `M`. `talbot is vectorized over `t`.
13+
If `BigFloat` precision is larger than default, try increasing `M`.
1414
1515
# Example
1616
1717
```jldoctest
18-
julia> InverseLaplace.talbot( s -> 1/s^3, 3)
18+
julia> InverseLaplace.talbot(s -> 1 / s^3, 3)
1919
4.50000000000153
2020
```
2121
@@ -50,10 +50,10 @@ talbot(func, t::Rational, args...) = talbot(func, BigFloat(t), args...)
5050
"""
5151
talbotarr(func, ta::AbstractArray, M)
5252
53-
inverse Laplace transform vectorized over `ta`. Each evaluation
54-
of `func(s)` is used for all elements of `ta`. This may be faster
55-
than a vectorized application of `talbot`, but is in general, less accurate.
56-
`talbotarr` uses the "fixed" Talbot method.
53+
Compute the inverse Laplace transform for each element in `ta`. Each evaluation
54+
of `func(s)` is used for all elements of `ta`. This may be faster than a
55+
broadcast application of `talbot` (i.e. `talbot.(...`) , but is in general, less
56+
accurate. `talbotarr` uses the "fixed" Talbot method.
5757
"""
5858
function talbotarr(func, t::AbstractArray, M)
5959
tt = typeof(t[1])
@@ -75,10 +75,12 @@ function talbotarr(func, t::AbstractArray, M)
7575
end
7676
end
7777
for j in 1:length(terms)
78-
terms[j] *= 2/(5 * tmax)
78+
terms[j] *= 2 / (5 * tmax)
7979
end
8080
return terms
8181
end
8282

8383
talbotarr(func, t::AbstractArray) = talbotarr(func, t, talbot_default_num_terms)
8484
talbotarr(func, t::Vector{BigFloat}) = talbotarr(func, t, talbot_BigFloat_default_num_terms)
85+
86+
# LocalWords: talbotarr func talbot

src/gwr.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ julia> InverseLaplace.gwr( s -> 1/s^3, 3.0)
3333
function gwr(func, t, M)
3434
Dt = typeof(t)
3535
bM = convert(Dt, M)
36-
tau = log(convert(Dt, 2))/t
36+
tau = log(convert(Dt, 2)) / t
3737
broken = false
3838
Fi = Array{Dt}(undef, 2 * M)
3939
@inbounds for i in 1: 2 * M
@@ -55,13 +55,13 @@ function gwr(func, t, M)
5555
Gp = zeros(Dt, M1 + 1)
5656
best = G0[M1]
5757
for k in 0:M1-2
58-
for n in (M1-2-k):-1:0
58+
for n in (M1 - 2 - k):-1:0
5959
expr = G0[n + 2] - G0[n + 1]
6060
if expr == 0
6161
broken = true
6262
break
6363
end
64-
expr = Gm[n + 2] + (k + 1)/expr
64+
expr = Gm[n + 2] + (k + 1) / expr
6565
Gp[n + 1] = expr
6666
if isodd(k) && n == M1 - 2 - k
6767
best = expr

src/weeks.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ end
7575
"""
7676
optimize(w::AbstractWeeks, t, Nterms)
7777
78-
optimize the parameters of the inverse Laplace transform `w` at the
78+
Optimize the parameters of the inverse Laplace transform `w` at the
7979
argument `t`. If `Nterms` is ommitted, the current value of `w.Nterms`
8080
is retained.
8181
@@ -87,36 +87,36 @@ the inverse transform that are extremely inaccurate.
8787
`optimize` is expensive in CPU time and allocation, it performs nested single-parameter
8888
optimization over two parameterss.
8989
"""
90-
function optimize(w::AbstractWeeks, t, N)
91-
w.Nterms = N
92-
return optimize(w,t)
90+
function optimize(w::AbstractWeeks, t, Nterms)
91+
w.Nterms = Nterms
92+
return optimize(w, t)
9393
end
9494

9595
"""
96-
opteval{T<:AbstractWeeks}(w::T, t, Nterms)
96+
opteval(w::AbstractWeeks, t, Nterms)
9797
9898
estimate an inverse Laplace transform at argument `t` using `w` after
9999
optimizing the parameters for `t`. If `Nterms` is omitted, then the
100100
current value of `w.Nterms` is used.
101101
102102
Use `Weeks` or `WeeksErr` to create `w`.
103103
"""
104-
function opteval(w::AbstractWeeks, t, N)
105-
optimize(w,t, N)
104+
function opteval(w::AbstractWeeks, t, Nterms)
105+
optimize(w, t, Nterms)
106106
return w(t)
107107
end
108108

109-
opteval(w::AbstractWeeks, t) = opteval(w,t,w.Nterms)
109+
opteval(w::AbstractWeeks, t) = opteval(w, t, w.Nterms)
110110

111111
"""
112-
setparameters{T<:AbstractWeeks}(w::T, sigma, b, Nterms)
112+
setparameters(w::AbstractWeeks, sigma, b, Nterms)
113113
114114
Set the parameters for the inverse Laplace transform object `w` and recompute
115115
the internal data. Subsequent calls `w(t)` will use these parameters. If `Nterms`
116116
or both `Nterms` and `b` are omitted, then their current values are retained.
117117
"""
118118
function setparameters(w::AbstractWeeks, sigma, b, Nterms)
119-
(w.sigma, w.b, w.Nterms) = (sigma,b,Nterms)
119+
(w.sigma, w.b, w.Nterms) = (sigma, b, Nterms)
120120
_set_coefficients(w)
121121
return w
122122
end

0 commit comments

Comments
 (0)