Skip to content

Commit c943f02

Browse files
author
Michele Mesiti
committed
ABM algs: use Base.@kwdef for consistency
Instead of having a lame external constructor
1 parent b92befb commit c943f02

File tree

1 file changed

+26
-62
lines changed

1 file changed

+26
-62
lines changed

lib/OrdinaryDiffEqAdamsBashforthMoulton/src/algorithms.jl

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct AB3{Thread} <: OrdinaryDiffEqAlgorithm
1414
thread::Thread
1515
end
1616

17-
function AB3()
18-
AB3(False())
17+
Base.@kwdef struct AB3{Thread} <: OrdinaryDiffEqAlgorithm
18+
thread::Thread = False()
1919
end
2020

2121
@doc generic_solver_docstring("The 4-step fourth order multistep method.
@@ -25,11 +25,8 @@ end
2525
reference,
2626
"",
2727
"")
28-
struct AB4{Thread} <: OrdinaryDiffEqAlgorithm
29-
thread::Thread
30-
end
31-
function AB4()
32-
AB4(False())
28+
Base.@kwdef struct AB4{Thread} <: OrdinaryDiffEqAlgorithm
29+
thread::Thread = False()
3330
end
3431

3532
@doc generic_solver_docstring("The 5-step fifth order multistep method.
@@ -39,11 +36,8 @@ end
3936
reference,
4037
"",
4138
"")
42-
struct AB5{Thread} <: OrdinaryDiffEqAlgorithm
43-
thread::Thread
44-
end
45-
function AB5()
46-
AB5(False())
39+
Base.@kwdef struct AB5{Thread} <: OrdinaryDiffEqAlgorithm
40+
thread::Thread = False()
4741
end
4842

4943
@doc generic_solver_docstring("It is third order method.
@@ -54,11 +48,8 @@ end
5448
reference,
5549
"",
5650
"")
57-
struct ABM32{Thread} <: OrdinaryDiffEqAlgorithm
58-
thread::Thread
59-
end
60-
function ABM32()
61-
ABM32(False())
51+
Base.@kwdef struct ABM32{Thread} <: OrdinaryDiffEqAlgorithm
52+
thread::Thread = False()
6253
end
6354

6455
@doc generic_solver_docstring("It is fourth order method.
@@ -69,11 +60,8 @@ end
6960
reference,
7061
"",
7162
"")
72-
struct ABM43{Thread} <: OrdinaryDiffEqAlgorithm
73-
thread::Thread
74-
end
75-
function ABM43()
76-
ABM43(False())
63+
Base.@kwdef struct ABM43{Thread} <: OrdinaryDiffEqAlgorithm
64+
thread::Thread = False()
7765
end
7866

7967
@doc generic_solver_docstring("It is fifth order method.
@@ -84,11 +72,8 @@ end
8472
reference,
8573
"",
8674
"")
87-
struct ABM54{Thread} <: OrdinaryDiffEqAlgorithm
88-
thread::Thread
89-
end
90-
function ABM54()
91-
ABM54(False())
75+
Base.@kwdef struct ABM54{Thread} <: OrdinaryDiffEqAlgorithm
76+
thread::Thread = False()
9277
end
9378

9479
# Variable Step Size Adams methods
@@ -100,11 +85,8 @@ end
10085
reference,
10186
"",
10287
"")
103-
struct VCAB3{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
104-
thread::Thread
105-
end
106-
function VCAB3()
107-
VCAB3(False())
88+
Base.@kwdef struct VCAB3{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
89+
thread::Thread = False()
10890
end
10991

11092
@doc generic_solver_docstring("The 4th order Adams method.
@@ -114,11 +96,8 @@ end
11496
reference,
11597
"",
11698
"")
117-
struct VCAB4{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
118-
thread::Thread
119-
end
120-
function VCAB4()
121-
VCAB4(False())
99+
Base.@kwdef struct VCAB4{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
100+
thread::Thread = False()
122101
end
123102

124103
@doc generic_solver_docstring("The 5th order Adams method.
@@ -128,11 +107,8 @@ end
128107
reference,
129108
"",
130109
"")
131-
struct VCAB5{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
132-
thread::Thread
133-
end
134-
function VCAB5()
135-
VCAB5(False())
110+
Base.@kwdef struct VCAB5{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
111+
thread::Thread = False()
136112
end
137113

138114
@doc generic_solver_docstring("The 3rd order Adams-Moulton method.
@@ -142,11 +118,8 @@ end
142118
reference,
143119
"",
144120
"")
145-
struct VCABM3{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
146-
thread::Thread
147-
end
148-
function VCABM3()
149-
VCABM3(False())
121+
Base.@kwdef struct VCABM3{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
122+
thread::Thread = False()
150123
end
151124

152125
@doc generic_solver_docstring("The 4th order Adams-Moulton method.
@@ -156,11 +129,8 @@ end
156129
reference,
157130
"",
158131
"")
159-
struct VCABM4{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
160-
thread::Thread
161-
end
162-
function VCABM4()
163-
VCABM4(False())
132+
Base.@kwdef struct VCABM4{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
133+
thread::Thread = False()
164134
end
165135

166136
@doc generic_solver_docstring("The 5th order Adams-Moulton method.
@@ -170,11 +140,8 @@ end
170140
reference,
171141
"",
172142
"")
173-
struct VCABM5{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
174-
thread::Thread
175-
end
176-
function VCABM5()
177-
VCABM5(False())
143+
Base.@kwdef struct VCABM5{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
144+
thread::Thread = False()
178145
end
179146

180147
# Variable Order and Variable Step Size Adams methods
@@ -186,9 +153,6 @@ end
186153
reference,
187154
"",
188155
"")
189-
struct VCABM{Thread} <: OrdinaryDiffEqAdamsVarOrderVarStepAlgorithm
190-
thread::Thread
191-
end
192-
function VCABM()
193-
VCABM(False())
156+
Base.@kwdef struct VCABM{Thread} <: OrdinaryDiffEqAdamsVarOrderVarStepAlgorithm
157+
thread::Thread = False()
194158
end

0 commit comments

Comments
 (0)