You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A = SymbolicUtils.simplify.(to_symbolic.(A), polynorm=true)
81
-
b = SymbolicUtils.simplify.(to_symbolic.(b), polynorm=true)
82
-
SymbolicUtils.simplify.(ldiv(sym_lu(A), b))
91
+
A = SymbolicUtils.simplify.(Num.(A), polynorm=true)
92
+
b = SymbolicUtils.simplify.(Num.(b), polynorm=true)
93
+
value.(SymbolicUtils.simplify.(sym_lu(A)\ b))
83
94
end
84
95
_solve(a, b) =value(SymbolicUtils.simplify(b/a, polynorm=true))
85
96
86
97
# ldiv below
87
98
88
99
_iszero(x::Number) =iszero(x)
89
100
_isone(x::Number) =isone(x)
90
-
_iszero(::Term) =false
91
-
_isone(::Term) =false
92
-
93
-
functionsimplifying_dot(x,y)
94
-
isempty(x) &&return0
95
-
muls =map(x,y) do xi,yi
96
-
_isone(xi) ? yi :_isone(yi) ? xi :_iszero(xi) ?0:_iszero(yi) ?0: xi * yi
101
+
_iszero(::Symbolic) =false
102
+
_isone(::Symbolic) =false
103
+
_iszero(x::Num) =_iszero(value(x))
104
+
_isone(x::Num) =_isone(value(x))
105
+
106
+
LinearAlgebra.ldiv!(A::UpperTriangular{<:Union{Symbolic,Num}}, b::AbstractVector{<:Union{Symbolic,Num}}, x::AbstractVector{<:Union{Symbolic,Num}}= b) =symsub!(A, b, x)
107
+
functionsymsub!(A::UpperTriangular, b::AbstractVector, x::AbstractVector= b)
108
+
LinearAlgebra.require_one_based_indexing(A, b, x)
109
+
n =size(A, 2)
110
+
if!(n ==length(b) ==length(x))
111
+
throw(DimensionMismatch("second dimension of left hand side A, $n, length of output x, $(length(x)), and length of right hand side b, $(length(b)), must be equal"))
x[i] =_isone(den) ? x[i] :_isone(-den) ?-x[i] : x[i] / den
126
+
LinearAlgebra.ldiv!(A::UnitLowerTriangular{<:Union{Symbolic,Num}}, b::AbstractVector{<:Union{Symbolic,Num}}, x::AbstractVector{<:Union{Symbolic,Num}}= b) =symsub!(A, b, x)
127
+
functionsymsub!(A::UnitLowerTriangular, b::AbstractVector, x::AbstractVector= b)
128
+
LinearAlgebra.require_one_based_indexing(A, b, x)
129
+
n =size(A, 2)
130
+
if!(n ==length(b) ==length(x))
131
+
throw(DimensionMismatch("second dimension of left hand side A, $n, length of output x, $(length(x)), and length of right hand side b, $(length(b)), must be equal"))
114
132
end
115
-
116
-
# unit lower triangular solve first:
117
-
for i=1:n
118
-
sub =simplifying_dot(b[1:i-1], L[i, 1:i-1]) # this should be `b` not x
0 commit comments