File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -650,6 +650,37 @@ function isscheduled(sys::AbstractSystem)
650650 end
651651end
652652
653+ struct Initial <: Symbolics.Operator end
654+ Initial (x) = Initial ()(x)
655+ SymbolicUtils. promote_symtype (:: Type{Initial} , T) = T
656+ SymbolicUtils. isbinop (:: Initial ) = false
657+ Base. nameof (:: Initial ) = :Initial
658+ Base. show (io:: IO , x:: Initial ) = print (io, " Initial" )
659+ input_timedomain (:: Initial , _ = nothing ) = Continuous ()
660+ output_timedomain (:: Initial , _ = nothing ) = Continuous ()
661+
662+ function (f:: Initial )(x)
663+ iw = Symbolics. iswrapped (x)
664+ x = unwrap (x)
665+ if iscall (x) && operation (x) isa Differential
666+ x = default_toterm (x)
667+ end
668+ iscall (x) && operation (x) isa Initial && return x
669+ result = if symbolic_type (x) == ArraySymbolic ()
670+ Symbolics. array_term (f, toparam (x))
671+ elseif iscall (x) && operation (x) == getindex
672+ arr = arguments (x)[1 ]
673+ term (getindex, f (toparam (arr)), arguments (x)[2 : end ]. .. )
674+ else
675+ term (f, toparam (x))
676+ end
677+ result = toparam (result)
678+ if iw
679+ result = wrap (result)
680+ end
681+ return result
682+ end
683+
653684"""
654685$(TYPEDSIGNATURES)
655686
You can’t perform that action at this time.
0 commit comments