11export LBFGS, update!
22
33"""
4- `LBFGS(x::Tuple, M::Integer)`
4+ `LBFGS(domainType::Type,dim_in::Tuple, M::Integer)`
5+
6+ `LBFGS(dim_in::Tuple, M::Integer)`
57
68`LBFGS(x::AbstractArray, M::Integer)`
79
@@ -28,34 +30,42 @@ mutable struct LBFGS{R, T <: BlockArray, M, I <: Integer} <: LinearOperator
2830 ys_M:: Array{R, 1}
2931 alphas:: Array{R, 1}
3032 H:: R
31- end
3233
33- function LBFGS (x:: T , M:: I ) where {T <: BlockArray , I <: Integer }
34- s_M = [blockzeros (x) for i = 1 : M]
35- y_M = [blockzeros (x) for i = 1 : M]
36- s = blockzeros (x)
37- y = blockzeros (x)
38- ys_M = zeros (M)
39- alphas = zeros (M)
40- R = real (eltype (x[1 ]))
41- LBFGS {R, T, M, I} (0 , 0 , s, y, s_M, y_M, ys_M, alphas, one (R))
34+ LBFGS (currmem:: I ,
35+ curridx:: I ,
36+ s:: T ,
37+ y:: T ,
38+ s_M:: Array{T,1} ,
39+ y_M:: Array{T,1} ,
40+ ys_M:: Array{R,1} ,
41+ alphas:: Array{R,1} ,
42+ H:: R ,
43+ M) where {R, T, I} =
44+ new {R,T,M,I} (currmem, curridx, s, y, s_M, y_M, ys_M,alphas, H)
45+
4246end
4347
44- function LBFGS (domainType:: D , dim:: T , M:: I ) where {D <: Type ,
45- T <: Tuple , I <: Integer }
46- x = blockzeros (domainType, dim)
47- return LBFGS (x,M)
48+ # default constructor
49+ function LBFGS (domainType, dim_in, M:: I ) where {I <: Integer }
50+ s_M = [blockzeros (domainType,dim_in) for i = 1 : M]
51+ y_M = [blockzeros (domainType,dim_in) for i = 1 : M]
52+ s = blockzeros (domainType,dim_in)
53+ y = blockzeros (domainType,dim_in)
54+ R = typeof (domainType) <: Tuple ? real (domainType[1 ]) : real (domainType)
55+ ys_M = zeros (R,M)
56+ alphas = zeros (R,M)
57+ LBFGS (0 , 0 , s, y, s_M, y_M, ys_M, alphas, one (R), M)
4858end
4959
50- function LBFGS (domainType:: D , dim:: T , M:: I ) where {N, D <: NTuple{N,Type} ,
51- T <: NTuple{N,Tuple} , I <: Integer }
52- x = blockzeros (domainType, dim)
53- return LBFGS (x,M)
60+ function LBFGS (dim_in, M:: I ) where {I <: Integer }
61+ domainType = eltype (dim_in) <: Integer ? Float64 : ([Float64 for i in eachindex (dim_in)]. .. )
62+ LBFGS (domainType,dim_in,M)
5463end
5564
56- function LBFGS (dim:: T , M:: I ) where {T <: Tuple , I <: Integer }
57- x = blockzeros (dim)
58- return LBFGS (x,M)
65+ function LBFGS (x:: T , M:: I ) where { T <: BlockArray , I <: Integer }
66+ domainType = blockeltype (x)
67+ dim_in = blocksize (x)
68+ LBFGS (domainType,dim_in,M)
5969end
6070
6171"""
0 commit comments