Skip to content

Commit

Permalink
Fixes for Julia v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 16, 2018
1 parent 70c4684 commit 59e5edd
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.6
MultivariatePolynomials 0.1.0
Compat 0.68
Compat 1.0
1 change: 1 addition & 0 deletions src/SemialgebraicSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __precompile__()
module SemialgebraicSets

using Compat
using Compat.Random

using MultivariatePolynomials
const MP = MultivariatePolynomials
Expand Down
4 changes: 2 additions & 2 deletions src/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ end
function BasicSemialgebraicSet{T, PT}() where {T, PT<:APL{T}}
BasicSemialgebraicSet(AlgebraicSet{T, PT}(), PT[])
end
function BasicSemialgebraicSet(V::AlgebraicSet{T, PT, S}, p::Vector{PS}) where {T, PT, PS, S}
function BasicSemialgebraicSet(V::AlgebraicSet{T, PT, A, S}, p::Vector{PS}) where {T, PT, PS, A, S}
PU = promote_type(PT, PS)
BasicSemialgebraicSet(AlgebraicSet{T, PU, S}(V), Vector{PU}(p))
BasicSemialgebraicSet(convert(AlgebraicSet{T, PU, A, S}, V), Vector{PU}(p))
end
#BasicSemialgebraicSet{T, PT<:APL{T}}(V::AlgebraicSet{T, PT}, p::Vector{PT}) = BasicSemialgebraicSet{T, PT}(V, p)
function basicsemialgebraicset(V, p)
Expand Down
4 changes: 2 additions & 2 deletions src/ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ function monomialbasis(I, vars=variables(I))
if d == maximum(exponents(m))
# univariate monomial
if iszero(d)
lv[:] = 0
lv[:] .= 0
else
lv[indmax(exponents(m))] = d
lv[argmax(exponents(m))] = d
end
end
end
Expand Down
16 changes: 9 additions & 7 deletions src/schur.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ end
function conditionnumber(sf::Schur, I)
n = length(sf.values)
select = zeros(BlasInt, n)
select[I] = 1
for i in I
select[i] = 1
end
_trsen!('E', 'N', select, copy(sf.T), copy(sf.Z))[4]
end

Expand All @@ -78,21 +80,21 @@ end
function clusterordschur(M::AbstractMatrix{<:Real}, ɛ)
if isempty(M)
# See bug JuliaLang/julia#...
return Matrix{float(eltype(M))}(0, 0), Vector{Int}[]
return Matrix{float(eltype(M))}(undef, 0, 0), Vector{Int}[]
else
_clusterordschur(M, ɛ)
end
end
function _clusterordschur(M::AbstractMatrix{<:Real}, ɛ)
# M = Z * T * Z' and "values" gives the eigenvalues
if VERSION <= v"0.7-"
sf = schurfact(M)
Z = sf[:Z]
v = sf[:values]
else
if VERSION >= v"0.7-"
sf = schur(M)
Z = sf.Z
v = sf.values
else
sf = schurfact(M)
Z = sf[:Z]
v = sf[:values]
end
# documentation says that the error on the eigenvalues is ɛ * norm(T) / conditionnumber
nT = norm(sf.T)
Expand Down
4 changes: 2 additions & 2 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ include("schur.jl")
"""
Corless, R. M.; Gianni, P. M. & Trager, B. M. A reordered Schur factorization method for zero-dimensional polynomial systems with multiple roots Proceedings of the 1997 international symposium on Symbolic and algebraic computation, 1997, 133-140
"""
struct ReorderedSchurMultiplicationMatricesSolver{T, RNGT <: AbstractRNG} <: AbstractMultiplicationMatricesSolver
struct ReorderedSchurMultiplicationMatricesSolver{T, RNGT <: Compat.Random.AbstractRNG} <: AbstractMultiplicationMatricesSolver
ɛ::T
rng::RNGT
end
ReorderedSchurMultiplicationMatricesSolver(ɛ) = ReorderedSchurMultiplicationMatricesSolver(ɛ, Base.GLOBAL_RNG)
ReorderedSchurMultiplicationMatricesSolver(ɛ) = ReorderedSchurMultiplicationMatricesSolver(ɛ, Compat.Random.GLOBAL_RNG)
ReorderedSchurMultiplicationMatricesSolver{T}() where T = ReorderedSchurMultiplicationMatricesSolver(Base.rtoldefault(real(T)))

function solvemultiplicationmatrices(Ms::AbstractVector{<:AbstractMatrix{T}}, solver::ReorderedSchurMultiplicationMatricesSolver) where T
Expand Down
2 changes: 1 addition & 1 deletion src/variety.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ end

Base.eltype(V::AlgebraicSet{T}) where T = Vector{T}

for f in [:length, :start, :endof, :next, :done, :getindex]
for f in ((VERSION >= v"0.7-") ? [:length, :iterate, :lastindex, :getindex] : [:length, :start, :endof, :next, :done, :getindex])
@eval begin
function Base.$f(V::AlgebraicSet, args...)
computeelements!(V)
Expand Down
6 changes: 5 additions & 1 deletion test/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ solver = ReorderedSchurMultiplicationMatricesSolver(sqrt(eps(Float64)), Mersenne
Mod.@polyvar x y z
V = @set x == y
@test !iszerodimensional(V)
@test_throws ErrorException start(V)
@static if VERSION >= v"0.7-"
@test_throws ErrorException iterate(V)
else
@test_throws ErrorException start(V)
end
@test_throws ErrorException length(V)
V = @set 4x^2 == -5x && 3x^3 == 0 solver
@test V.solver.solver === solver
Expand Down

0 comments on commit 59e5edd

Please sign in to comment.