File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 164164
165165MP. variables (c:: SA.AbstractCoefficients ) = MP. variables (SA. keys (c))
166166
167+ _lazy_collect (v:: AbstractVector ) = collect (v)
168+ _lazy_collect (v:: Vector ) = v
169+
167170function sparse_coefficients (p:: MP.AbstractPolynomial )
168- return SA. SparseCoefficients (MP. monomials (p), MP. coefficients (p))
171+ return SA. SparseCoefficients (
172+ _lazy_collect (MP. monomials (p)),
173+ _lazy_collect (MP. coefficients (p)),
174+ )
169175end
170176
171177function sparse_coefficients (t:: MP.AbstractTermLike )
@@ -178,7 +184,7 @@ function MA.promote_operation(
178184) where {P<: MP.AbstractPolynomialLike }
179185 M = MP. monomial_type (P)
180186 T = MP. coefficient_type (P)
181- return SA. SparseCoefficients{M,T,MP . monomial_vector_type (M) ,Vector{T}}
187+ return SA. SparseCoefficients{M,T,Vector{M} ,Vector{T}}
182188end
183189
184190function algebra_element (p:: MP.AbstractPolynomialLike )
Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
7878 @test MB. algebra_element (MB. Polynomial {B} (const_mono)) + const_mono == 2
7979 @test iszero (const_mono - MB. algebra_element (MB. Polynomial {B} (const_mono)))
8080 @test iszero (MB. algebra_element (MB. Polynomial {B} (const_mono)) - const_mono)
81+ @test typeof (MB. sparse_coefficients (sum (x))) ==
82+ MA. promote_operation (MB. sparse_coefficients, typeof (sum (x)))
83+ @test typeof (MB. algebra_element (sum (x))) ==
84+ MA. promote_operation (MB. algebra_element, typeof (sum (x)))
8185end
8286
8387function univ_orthogonal_test (
You can’t perform that action at this time.
0 commit comments