File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 2626function multdivmono! (output_variables:: Vector{PolyVar{true}} ,
2727 v:: Vector{PolyVar{true}} , x:: Monomial{true} , op)
2828 if v == x. vars
29- updatez! = (output, z) -> @. output = op (z, x. z)
29+ if output_variables == v
30+ updatez! = (output, z) -> begin
31+ @. output = op (z, x. z)
32+ return
33+ end
34+ else
35+ resize! (output_variables, length (v))
36+ copyto! (output_variables, v)
37+ updatez! = (output, z) -> begin
38+ resize! (output, length (output_variables))
39+ @. output = op (z, x. z)
40+ return
41+ end
42+ end
3043 else
31- w, maps = mergevars ( [v, x. vars])
44+ maps = mergevars_to! (output_variables, [v, x. vars])
3245 n = length (v)
33- resize! (output_variables, length (w))
34- output_variables[maps[1 ]] = v[1 : n]
3546 updatez! = (output, z) -> begin
36- resize! (output, length (w))
37- z[maps[1 ]] = z[1 : n]
47+ resize! (output, length (output_variables))
3848 I = maps[1 ]; i = 1 ; lI = length (I)
3949 J = maps[2 ]; j = 1 ; lJ = length (J)
4050 while i <= lI || j <= lJ
Original file line number Diff line number Diff line change @@ -71,12 +71,12 @@ _vars(v::PolyVar) = [v]
7171
7272iscomm (:: Type{PolyVar{C}} ) where {C} = C
7373
74- function mergevars (varsvec:: Vector{Vector{PV}} ) where {PV<: PolyVar }
74+ function mergevars_to! (vars:: Vector{PV} , varsvec:: Vector{Vector{PV}} ) where {PV<: PolyVar }
75+ empty! (vars)
7576 n = length (varsvec)
7677 is = ones (Int, n)
7778 maps = zeros .(Int, length .(varsvec))
7879 nonempty = BitSet (findall (! isempty, varsvec))
79- vars = Vector {PV} ()
8080 while ! isempty (nonempty)
8181 imin = 0
8282 for i in nonempty
@@ -97,5 +97,10 @@ function mergevars(varsvec::Vector{Vector{PV}}) where {PV<:PolyVar}
9797 end
9898 end
9999 end
100- vars, maps
100+ return maps
101+ end
102+ function mergevars (varsvec:: Vector{Vector{PV}} ) where {PV<: PolyVar }
103+ vars = PV[]
104+ maps = mergevars_to! (vars, varsvec)
105+ return vars, maps
101106end
You can’t perform that action at this time.
0 commit comments