Skip to content

Commit

Permalink
Fix polynomial for PolynomialVectorBasis
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Feb 17, 2020
1 parent ed34a58 commit 17d642d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MultivariateBases"
uuid = "be282fd4-ad43-11e9-1d11-8bd9d7e43378"
repo = "https://github.com/JuliaAlgebra/MultivariateBases.jl.git"
version = "0.1.1"
version = "0.1.2"

[deps]
MultivariatePolynomials = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3"
Expand Down
8 changes: 4 additions & 4 deletions src/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ function MP.polynomialtype(basis::AbstractPolynomialVectorBasis{PT}, T::Type) wh
return MP.polynomialtype(PT, V)
end
function MP.polynomial(f::Function, basis::AbstractPolynomialVectorBasis)
return mapreduce(ip -> f(ip[1]) * ip[2], MA.add!, enumerate(basis.polynomials))
return MP.polynomial(mapreduce(
ip -> f(ip[1]) * ip[2], MA.add!, enumerate(basis.polynomials)))
end

function MP.polynomial(Q::AbstractMatrix, basis::AbstractPolynomialVectorBasis,
T::Type)
n = length(basis)
@assert size(Q) == (n, n)
return mapreduce(row -> basis.polynomials[row] *
return MP.polynomial(mapreduce(row -> basis.polynomials[row] *
mapreduce(col -> Q[row, col] * basis.polynomials[col], MA.add!, 1:n),
MA.add!, 1:n)
return mapreduce()
MA.add!, 1:n), T)
end

"""
Expand Down
3 changes: 3 additions & 0 deletions test/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ end
basis = FixedPolynomialBasis([x])
@test polynomialtype(basis, Int) == polynomialtype(x, Int)
@test polynomial(i -> 5, basis) == 5x
@test typeof(polynomial(i -> 5, basis)) == polynomialtype(basis, Int)
@test typeof(polynomial(ones(Int, 1, 1), basis, Int)) <: AbstractPolynomial{Int}
@test typeof(polynomial(ones(Int, 1, 1), basis, Float64)) <: AbstractPolynomial{Float64}
end

2 comments on commit 17d642d

@blegat
Copy link
Member Author

@blegat blegat commented on 17d642d Feb 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/9627

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.2 -m "<description of version>" 17d642d9f238707b0bedbca2be58cf69fa471f1e
git push origin v0.1.2

Please sign in to comment.