Skip to content

Commit 885e738

Browse files
committed
add parametric types
1 parent bbe7b75 commit 885e738

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/utils/pdata_struct.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,26 @@ function solve_model(X::TPData, H, g, gNorm2, n1, n2, α) end
4848
PDataKARC(::Type{S}, ::Type{T}, n)
4949
Return a structure used for the preprocessing of ARCqK methods.
5050
"""
51-
mutable struct PDataKARC{T} <: PDataIter{T}
52-
d::Array{T,1} # (H+λI)\g ; on first call = g
51+
mutable struct PDataKARC{S,T,Fatol,Frtol} <: PDataIter{T}
52+
d::S # (H+λI)\g ; on first call = g
5353
λ::T # "active" value of λ; on first call = 0
5454
ζ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
5555
ξ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
5656
maxtol::T # Largest tolerance for Inexact Newton
5757
mintol::T # Smallest tolerance for Inexact Newton
58-
cgatol::Any
59-
cgrtol::Any
58+
cgatol::Fatol
59+
cgrtol::Frtol
6060

6161
indmin::Int # index of best shift value within "positive". On first call = 0
6262

6363
positives::Array{Bool,1} # indices of the shift values yielding (H+λI)⪰0
64-
xShift::Array{Array{T,1},1} # solutions for each shifted system
64+
xShift::Array{S,1} # solutions for each shifted system
6565
shifts::Array{T,1} # values of the shifts
6666
nshifts::Int # number of shifts
6767
norm_dirs::Array{T,1} # norms of xShifts
6868
OK::Bool # preprocess success
6969

70-
solver::CgLanczosShiftSolver
70+
solver::CgLanczosShiftSolver{T,T,S}
7171
end
7272

7373
function PDataKARC(
@@ -119,26 +119,26 @@ end
119119
PDataTRK(::Type{S}, ::Type{T}, n)
120120
Return a structure used for the preprocessing of TRK methods.
121121
"""
122-
mutable struct PDataTRK{T} <: PDataIter{T}
123-
d::Array{T,1} # (H+λI)\g ; on first call = g
122+
mutable struct PDataTRK{S,T,Fatol,Frtol} <: PDataIter{T}
123+
d::S # (H+λI)\g ; on first call = g
124124
λ::T # "active" value of λ; on first call = 0
125125
ζ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
126126
ξ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
127127
maxtol::T # Largest tolerance for Inexact Newton
128128
mintol::T # Smallest tolerance for Inexact Newton
129-
cgatol::Any
130-
cgrtol::Any
129+
cgatol::Fatol
130+
cgrtol::Frtol
131131

132132
indmin::Int # index of best shift value within "positive". On first call = 0
133133

134134
positives::Array{Bool,1} # indices of the shift values yielding (H+λI)⪰0
135-
xShift::Array{Array{T,1},1} # solutions for each shifted system
135+
xShift::Array{S,1} # solutions for each shifted system
136136
shifts::Array{T,1} # values of the shifts
137137
nshifts::Int # number of shifts
138138
norm_dirs::Array{T,1} # norms of xShifts
139139
OK::Bool # preprocess success
140140

141-
solver::CgLanczosShiftSolver
141+
solver::CgLanczosShiftSolver{T,T,S}
142142
end
143143

144144
function PDataTRK(
@@ -190,18 +190,18 @@ end
190190
PDataST(::Type{S}, ::Type{T}, n)
191191
Return a structure used for the preprocessing of Steihaug-Toint methods.
192192
"""
193-
mutable struct PDataST{S,T} <: PDataIter{T}
193+
mutable struct PDataST{S,T,Fatol,Frtol} <: PDataIter{T}
194194
d::S
195195
λ::T
196196
ζ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
197197
ξ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
198198
maxtol::T # Largest tolerance for Inexact Newton
199199
mintol::T # Smallest tolerance for Inexact Newton
200-
cgatol::Any
201-
cgrtol::Any
200+
cgatol::Fatol
201+
cgrtol::Frtol
202202

203203
OK::Bool # preprocess success
204-
solver::CgSolver
204+
solver::CgSolver{T,T,S}
205205
end
206206

207207
function PDataST(
@@ -227,18 +227,18 @@ end
227227
PDataNLSST(::Type{S}, ::Type{T}, n)
228228
Return a structure used for the preprocessing of Steihaug-Toint methods for Gauss-Newton approximation of nonlinear least squares.
229229
"""
230-
mutable struct PDataNLSST{S,T} <: PDataIterLS{T}
230+
mutable struct PDataNLSST{S,T,Fatol,Frtol} <: PDataIterLS{T}
231231
d::S
232232
λ::T
233233
ζ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
234234
ξ::T # Inexact Newton order parameter: stop when ||∇q|| < ξ * ||g||^(1+ζ)
235235
maxtol::T # Largest tolerance for Inexact Newton
236236
mintol::T # Smallest tolerance for Inexact Newton
237-
cgatol::Any
238-
cgrtol::Any
237+
cgatol::Fatol
238+
cgrtol::Frtol
239239

240240
OK::Bool # preprocess success
241-
solver::Union{CglsSolver,LsqrSolver}
241+
solver::Union{CglsSolver{T,T,S},LsqrSolver{T,T,S}}
242242
end
243243

244244
function PDataNLSST(

0 commit comments

Comments
 (0)