1
- # Copyright 2016 Martin Holters
1
+ # Copyright 2016, 2017 Martin Holters
2
2
# See accompanying license file.
3
3
4
4
export SimpleSolver, HomotopySolver, CachingSolver
@@ -12,12 +12,16 @@ type ParametricNonLinEq{F_eval<:Function,F_setp<:Function,F_calcjp<:Function,Scr
12
12
Jp:: Matrix{Float64}
13
13
J:: Matrix{Float64}
14
14
scratch:: Scratch
15
- function ParametricNonLinEq (func:: F_eval , set_p:: F_setp , calc_Jp:: F_calcjp ,
16
- scratch:: Scratch , nn:: Integer , np:: Integer )
15
+ @compat function (:: Type{ParametricNonLinEq{F_eval,F_setp,F_calcjp,Scratch}} ){
16
+ F_eval<: Function ,F_setp<: Function ,F_calcjp<: Function ,Scratch
17
+ }(
18
+ func:: F_eval , set_p:: F_setp , calc_Jp:: F_calcjp , scratch:: Scratch ,
19
+ nn:: Integer , np:: Integer
20
+ )
17
21
res = zeros (nn)
18
22
Jp = zeros (nn, np)
19
23
J = zeros (nn, nn)
20
- return new (func, set_p, calc_Jp, res, Jp, J, scratch)
24
+ return new {F_eval,F_setp,F_calcjp,Scratch} (func, set_p, calc_Jp, res, Jp, J, scratch)
21
25
end
22
26
end
23
27
ParametricNonLinEq{F_eval<: Function ,F_setp<: Function ,F_calcjp<: Function ,
@@ -113,8 +117,8 @@ type SimpleSolver{NLEQ<:ParametricNonLinEq}
113
117
tol:: Float64
114
118
tmp_nn:: Vector{Float64}
115
119
tmp_np:: Vector{Float64}
116
- function SimpleSolver (nleq :: NLEQ , initial_p :: Vector{Float64} ,
117
- initial_z:: Vector{Float64} )
120
+ @compat function ( :: Type{SimpleSolver{ NLEQ}} ){NLEQ <: ParametricNonLinEq }(
121
+ nleq :: NLEQ , initial_p :: Vector{Float64} , initial_z:: Vector{Float64} )
118
122
z = zeros (nn (nleq))
119
123
linsolver = LinearSolver (nn (nleq))
120
124
last_z = zeros (nn (nleq))
@@ -123,8 +127,8 @@ type SimpleSolver{NLEQ<:ParametricNonLinEq}
123
127
last_linsolver = LinearSolver (nn (nleq))
124
128
tmp_nn = zeros (nn (nleq))
125
129
tmp_np = zeros (np (nleq))
126
- solver = new (nleq, z, linsolver, last_z, last_p, last_Jp, last_linsolver ,
127
- 0 , 0.0 , 1e-20 , tmp_nn, tmp_np)
130
+ solver = new {NLEQ} (nleq, z, linsolver, last_z, last_p, last_Jp,
131
+ last_linsolver, 0 , 0.0 , 1e-20 , tmp_nn, tmp_np)
128
132
set_extrapolation_origin (solver, initial_p, initial_z)
129
133
return solver
130
134
end
@@ -201,12 +205,13 @@ type HomotopySolver{BaseSolver}
201
205
start_p:: Vector{Float64}
202
206
pa:: Vector{Float64}
203
207
iters:: Int
204
- function HomotopySolver (basesolver:: BaseSolver , np:: Integer )
205
- return new (basesolver, zeros (np), zeros (np), 0 )
208
+ @compat function (:: Type{HomotopySolver{BaseSolver}} ){BaseSolver}(
209
+ basesolver:: BaseSolver , np:: Integer )
210
+ return new {BaseSolver} (basesolver, zeros (np), zeros (np), 0 )
206
211
end
207
- function HomotopySolver (nleq :: ParametricNonLinEq ,
208
- initial_p:: Vector{Float64} ,
209
- initial_z:: Vector{Float64} )
212
+ @compat function ( :: Type{HomotopySolver{BaseSolver}} ){BaseSolver}(
213
+ nleq :: ParametricNonLinEq , initial_p:: Vector{Float64} ,
214
+ initial_z:: Vector{Float64} )
210
215
basesolver = BaseSolver (nleq, initial_p, initial_z)
211
216
return HomotopySolver {typeof(basesolver)} (basesolver, np (nleq))
212
217
end
@@ -274,15 +279,15 @@ type CachingSolver{BaseSolver}
274
279
new_count:: Int
275
280
new_count_limit:: Int
276
281
alts:: Alts{Float64}
277
- function CachingSolver (basesolver :: BaseSolver , initial_p :: Vector{Float64} ,
278
- initial_z:: Vector{Float64} , nn:: Integer )
282
+ @compat function ( :: Type{CachingSolver{ BaseSolver}} ){BaseSolver}(basesolver :: BaseSolver ,
283
+ initial_p :: Vector{Float64} , initial_z:: Vector{Float64} , nn:: Integer )
279
284
ps_tree = KDTree (hcat (initial_p))
280
285
zs = reshape (copy (initial_z), nn, 1 )
281
286
alts = Alts (initial_p)
282
- return new (basesolver, ps_tree, zs, 1 , 0 , 2 , alts)
287
+ return new {BaseSolver} (basesolver, ps_tree, zs, 1 , 0 , 2 , alts)
283
288
end
284
- function CachingSolver (nleq:: ParametricNonLinEq , initial_p :: Vector{Float64} ,
285
- initial_z:: Vector{Float64} )
289
+ @compat function ( :: Type{ CachingSolver{BaseSolver}} ){BaseSolver} (nleq:: ParametricNonLinEq ,
290
+ initial_p :: Vector{Float64} , initial_z:: Vector{Float64} )
286
291
basesolver = BaseSolver (nleq, initial_p, initial_z)
287
292
return CachingSolver {typeof(basesolver)} (basesolver, initial_p, initial_z, nn (nleq))
288
293
end
0 commit comments