| 
67 | 67 |         f, u0, p, StandardNonlinearProblem(); kwargs...))  | 
68 | 68 | end  | 
69 | 69 | 
 
  | 
 | 70 | +@fallback_iip_specialize function SciMLBase.NonlinearLeastSquaresProblem{iip, spec}(  | 
 | 71 | +        sys::System, u0map, parammap = DiffEqBase.NullParameters(); check_length = false,  | 
 | 72 | +        check_compatibility = true, kwargs...) where {iip, spec}  | 
 | 73 | +    check_complete(sys, NonlinearLeastSquaresProblem)  | 
 | 74 | +    check_compatibility && check_compatible_system(NonlinearLeastSquaresProblem, sys)  | 
 | 75 | + | 
 | 76 | +    f, u0, p = process_SciMLProblem(NonlinearFunction{iip}, sys, u0map, parammap;  | 
 | 77 | +        check_length, kwargs...)  | 
 | 78 | + | 
 | 79 | +    kwargs = process_kwargs(sys; kwargs...)  | 
 | 80 | +    # Call `remake` so it runs initialization if it is trivial  | 
 | 81 | +    return remake(NonlinearLeastSquaresProblem{iip}(f, u0, p; kwargs...))  | 
 | 82 | +end  | 
 | 83 | + | 
70 | 84 | function check_compatible_system(  | 
71 |  | -        T::Union{Type{NonlinearFunction}, Type{NonlinearProblem}}, sys::System)  | 
 | 85 | +        T::Union{Type{NonlinearFunction}, Type{NonlinearProblem},  | 
 | 86 | +            Type{NonlinearLeastSquaresProblem}}, sys::System)  | 
72 | 87 |     check_time_independent(sys, T)  | 
73 | 88 |     check_not_dde(sys)  | 
74 | 89 |     check_no_cost(sys, T)  | 
75 | 90 |     check_no_constraints(sys, T)  | 
76 | 91 |     check_no_jumps(sys, T)  | 
77 | 92 |     check_no_noise(sys, T)  | 
78 | 93 | end  | 
 | 94 | + | 
 | 95 | +function calculate_resid_prototype(N, u0, p)  | 
 | 96 | +    u0ElType = u0 === nothing ? Float64 : eltype(u0)  | 
 | 97 | +    if SciMLStructures.isscimlstructure(p)  | 
 | 98 | +        u0ElType = promote_type(  | 
 | 99 | +            eltype(SciMLStructures.canonicalize(SciMLStructures.Tunable(), p)[1]),  | 
 | 100 | +            u0ElType)  | 
 | 101 | +    end  | 
 | 102 | +    return zeros(u0ElType, N)  | 
 | 103 | +end  | 
0 commit comments