Skip to content
Snippets Groups Projects
Commit 0df916ac authored by Krueger Jasmin's avatar Krueger Jasmin
Browse files

added a function to replace zeros in a polynomial by a nonzero value and a...

added a function to replace zeros in a polynomial by a nonzero value and a function to extract the radii of the coefficients of an interval valued polynomial
parent 47759107
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,8 @@ function isless_coefficientwise(p::PolyElem{T},q::PolyElem{T}) where T <: arb_po ...@@ -57,6 +57,8 @@ function isless_coefficientwise(p::PolyElem{T},q::PolyElem{T}) where T <: arb_po
#print("[",Float64(coeff(coeff(p,i-1),j-1))-Float64(radius(coeff(coeff(p,i-1),j-1))),", ", Float64(coeff(coeff(p,i-1),j-1))+Float64(radius(coeff(coeff(p,i-1),j-1))), "] < [", Float64(coeff(coeff(q,i-1),j-1)) -Float64(radius(coeff(coeff(q,i-1),j-1))),", ", Float64(coeff(coeff(q,i-1),j-1)) +Float64(radius(coeff(coeff(q,i-1),j-1))), "] ?\n") #print("[",Float64(coeff(coeff(p,i-1),j-1))-Float64(radius(coeff(coeff(p,i-1),j-1))),", ", Float64(coeff(coeff(p,i-1),j-1))+Float64(radius(coeff(coeff(p,i-1),j-1))), "] < [", Float64(coeff(coeff(q,i-1),j-1)) -Float64(radius(coeff(coeff(q,i-1),j-1))),", ", Float64(coeff(coeff(q,i-1),j-1)) +Float64(radius(coeff(coeff(q,i-1),j-1))), "] ?\n")
if ((coeff(coeff(p,i-1),j-1) < coeff(coeff(q,i-1),j-1)) == false) if ((coeff(coeff(p,i-1),j-1) < coeff(coeff(q,i-1),j-1)) == false)
@show (coeff(coeff(p,i-1),j-1))
@show coeff(coeff(q,i-1),j-1)
return false return false
end end
end end
...@@ -339,3 +341,35 @@ function convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T}) where T ...@@ -339,3 +341,35 @@ function convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T}) where T
end end
pi pi
end end
function extract_radius(p::PolyElem{T}) where T
r = parent(p)(0)
d = degree(p)
for i in 0:d
if T <: PolyElem
set_coefficient!(r,i,extract_radius(coeff(p,i)))
else
set_coefficient!(r,i,mag(radius(coeff(p,i))))
end
end
r
end
function replace_zeros!(p::PolyElem{T}, d, dp = -1, k = -1) where T
if (T <: PolyElem)&&(dp == -1)
deg = degree(p)
elseif (T <: PolyElem)
deg = dp
else
deg = k
end
@show deg
for i in 0:deg
if T <: PolyElem
set_coefficient!(p,i,replace_zeros!(coeff(p,i),d,dp,k))
else
set_coefficient!(p,i,d)
end
end
p
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment