321321function NonlinearLeastSquaresProblem (f, u0, p = NullParameters (); kwargs... )
322322 return NonlinearLeastSquaresProblem (NonlinearFunction (f), u0, p; kwargs... )
323323end
324+
325+ @doc doc"""
326+
327+ Defines a nonlinear system problem.
328+ Documentation Page: [https://docs.sciml.ai/NonlinearSolve/stable/basics/nonlinear_problem/](https://docs.sciml.ai/NonlinearSolve/stable/basics/nonlinear_problem/)
329+
330+ ## Mathematical Specification of a Nonlinear Problem
331+
332+ To define a Nonlinear Problem, you simply need to give the function ``f``
333+ which defines the nonlinear system:
334+
335+ ```math
336+ f(u,p) = 0
337+ ```
338+
339+ and an initial guess ``u₀`` of where `f(u, p) = 0`. `f` should be specified as `f(u, p)`
340+ (or in-place as `f(du, u, p)`), and `u₀` should be an AbstractArray (or number)
341+ whose geometry matches the desired geometry of `u`. Note that we are not limited
342+ to numbers or vectors for `u₀`; one is allowed to provide `u₀` as arbitrary
343+ matrices / higher-dimension tensors as well.
344+
345+ ## Problem Type
346+
347+ ### Constructors
348+
349+ ```julia
350+ NonlinearProblem(f::NonlinearFunction, u0, p = NullParameters(); kwargs...)
351+ NonlinearProblem{isinplace}(f, u0, p = NullParameters(); kwargs...)
352+ ```
353+
354+ `isinplace` optionally sets whether the function is in-place or not. This is
355+ determined automatically, but not inferred.
356+
357+ Parameters are optional, and if not given, then a `NullParameters()` singleton
358+ will be used, which will throw nice errors if you try to index non-existent
359+ parameters. Any extra keyword arguments are passed on to the solvers. For example,
360+ if you set a `callback` in the problem, then that `callback` will be added in
361+ every solve call.
362+
363+ For specifying Jacobians and mass matrices, see the
364+ [NonlinearFunctions](@ref nonlinearfunctions) page.
365+
366+ ### Fields
367+
368+ * `f`: The function in the problem.
369+ * `u0`: The initial guess for the root.
370+ * `p`: The parameters for the problem. Defaults to `NullParameters`.
371+ * `kwargs`: The keyword arguments passed on to the solvers.
372+ """
373+ mutable struct SCCNonlinearProblem{uType, isinplace, P, F, K, PT} < :
374+ AbstractNonlinearProblem{uType, isinplace}
375+ f:: F
376+ u0:: uType
377+ p:: P
378+ problem_type:: PT
379+ kwargs:: K
380+ @add_kwonly function SCCNonlinearProblem {iip} (f:: Union{AbstractVector,Tuple} ,
381+ u0:: Union{AbstractVector,Tuple} ,
382+ p = NullParameters (),
383+ problem_type = StandardNonlinearProblem ();
384+ kwargs... ) where {iip}
385+ if ! (eltype (f) <: AbstractNonlinearFunction )
386+ f = NonlinearFunction {iip} .(f)
387+ end
388+
389+ eltype (u0) <: AbstractVector || error (" !(eltype(u0) <: AbstractVector) detected. SCC states must be vector." )
390+ length (f) != length (u0) && error (" Number of SCCs undefined. length(f) = $(length (f)) != $(length (u0)) == length(u0)" )
391+
392+ if haskey (kwargs, :p )
393+ error (" `p` specified as a keyword argument `p = $(kwargs[:p ]) ` to `NonlinearProblem`. This is not supported." )
394+ end
395+ warn_paramtype (p)
396+ new{typeof (u0), iip, typeof (p), typeof (f),
397+ typeof (kwargs), typeof (problem_type)}(f,
398+ u0,
399+ p,
400+ problem_type,
401+ kwargs)
402+ end
403+ end
404+
405+ """
406+ $(SIGNATURES)
407+ """
408+ function SCCNonlinearProblem (f:: Union{AbstractVector,Tuple} , u0:: Union{AbstractVector,Tuple} , p = NullParameters (); kwargs... )
409+ if ! (eltype (f) <: AbstractNonlinearFunction )
410+ f = NonlinearFunction .(f)
411+ end
412+ all (isinplace,f) || all (! inplace,f) || error (" All SCC Functions must match in-placeness" )
413+ iip = isinplace (f[1 ])
414+ SCCNonlinearProblem {iip} (f, u0, p; kwargs... )
415+ end
0 commit comments