@@ -33,6 +33,12 @@ function isless_coefficientwise(p::PolyElem{S},q::PolyElem{T}) where {S <: Union
...
@@ -33,6 +33,12 @@ function isless_coefficientwise(p::PolyElem{S},q::PolyElem{T}) where {S <: Union
returntrue
returntrue
end
end
"""
isless_coefficientwise(p::PolyElem{S},q::PolyElem{T}) where {S <: PolyElem, T <: PolyElem}
Return true if all coefficients of p are smaller than their corresponding coefficient of q.
Return false else.
"""
function isless_coefficientwise(p::PolyElem{S},q::PolyElem{T})where{S<:PolyElem,T<:PolyElem}
function isless_coefficientwise(p::PolyElem{S},q::PolyElem{T})where{S<:PolyElem,T<:PolyElem}
print("isless()\n")
print("isless()\n")
d=max(degree(p),degree(q))
d=max(degree(p),degree(q))
...
@@ -49,6 +55,12 @@ function isless_coefficientwise(p::PolyElem{S},q::PolyElem{T}) where {S <: PolyE
...
@@ -49,6 +55,12 @@ function isless_coefficientwise(p::PolyElem{S},q::PolyElem{T}) where {S <: PolyE
returntrue
returntrue
end
end
"""
isless_coefficientwise(p::PolyElem{T},q::PolyElem{T}) where T <: arb_poly
Return true if all coefficients of p are smaller than their corresponding coefficient of q.
Return false else.
"""
function isless_coefficientwise(p::PolyElem{T},q::PolyElem{T})whereT<:arb_poly
function isless_coefficientwise(p::PolyElem{T},q::PolyElem{T})whereT<:arb_poly
d=max(degree(p),degree(q))
d=max(degree(p),degree(q))
foriin1:d+1
foriin1:d+1
...
@@ -119,6 +131,11 @@ function nonzeroMin(d::PolyElem{T}) where T <: Union{FieldElem, AbstractFloat}
...
@@ -119,6 +131,11 @@ function nonzeroMin(d::PolyElem{T}) where T <: Union{FieldElem, AbstractFloat}
min
min
end
end
"""
range_of_coefficients(p::PolyElem{T}) where T
Return the smallest (nonzero) and highest absolute value of the coefficients of p
"""
function range_of_coefficients(p::PolyElem{T})whereT
function range_of_coefficients(p::PolyElem{T})whereT
dp=degree(p)
dp=degree(p)
min=0.0
min=0.0
...
@@ -142,17 +159,11 @@ function range_of_coefficients(p::PolyElem{T}) where T
...
@@ -142,17 +159,11 @@ function range_of_coefficients(p::PolyElem{T}) where T
(min,max)
(min,max)
end
end
#=
"""
function multiply(p::PolyElem{T},q::PolyElem{T}) where T <: Union{PolyRingElem{ArbField}, PolyRingElem{RealField}}
convert_float_to_balls(p::PolyElem{T}) where T <: PolyElem
end
function kronecker_evaluation(p::PolyElem)
end
=#
Convert a real polynomial p to a polynomial with thin intervals around the coefficients of p.
"""
function convert_float_to_balls(p::PolyElem{T})whereT<:PolyElem
function convert_float_to_balls(p::PolyElem{T})whereT<:PolyElem
dp=degree(p)
dp=degree(p)
RR=ArbField(53)
RR=ArbField(53)
...
@@ -166,6 +177,11 @@ function convert_float_to_balls(p::PolyElem{T}) where T <: PolyElem
...
@@ -166,6 +177,11 @@ function convert_float_to_balls(p::PolyElem{T}) where T <: PolyElem
q
q
end
end
"""
convert_float_to_balls(p::PolyElem{T}) where T<:Union{AbstractFloat, FieldElem}
Convert a real polynomial p to a polynomial with thin intervals around the coefficients of p.
"""
function convert_float_to_balls(p::PolyElem{T})whereT<:Union{AbstractFloat,FieldElem}
function convert_float_to_balls(p::PolyElem{T})whereT<:Union{AbstractFloat,FieldElem}
dp=degree(p)
dp=degree(p)
RR=ArbField(53)
RR=ArbField(53)
...
@@ -179,6 +195,11 @@ function convert_float_to_balls(p::PolyElem{T}) where T<:Union{AbstractFloat, F
...
@@ -179,6 +195,11 @@ function convert_float_to_balls(p::PolyElem{T}) where T<:Union{AbstractFloat, F
q
q
end
end
"""
convert_balls_to_Float(p::PolyElem{T}; rounding = RoundNearest) where T
Convert a polynomial p with interval coefficients into a polynomial with real coefficients. By definition the coefficients will be the interval midpoints, but with changes to the rounding methods, it can also return the upper bound or lower bound values of p.
"""
function convert_balls_to_Float(p::PolyElem{T};rounding=RoundNearest)whereT
function convert_balls_to_Float(p::PolyElem{T};rounding=RoundNearest)whereT
dp=degree(p)
dp=degree(p)
RX,_=PolynomialRing(RDF,"x")
RX,_=PolynomialRing(RDF,"x")
...
@@ -210,11 +231,21 @@ function convert_balls_to_lowerBound_Float(p::PolyElem{T}) where T
...
@@ -210,11 +231,21 @@ function convert_balls_to_lowerBound_Float(p::PolyElem{T}) where T
convert_balls_to_Float(p,rounding=RoundDown)
convert_balls_to_Float(p,rounding=RoundDown)
end
end
"""
mag(a::T) where T <: Union{arb,acb}
Return max(abs(a))
"""
function mag(a::T)whereT<:Union{arb,acb}
function mag(a::T)whereT<:Union{arb,acb}
m=abs(a)
m=abs(a)
m=RR(Float64(m,RoundUp))
m=RR(Float64(m,RoundUp))
end
end
"""
mag_coefficientwise(p::PolyElem{T}) where T
Apply max(abs(*)) on each coefficient of p.
"""
function mag_coefficientwise(p::PolyElem{T})whereT
function mag_coefficientwise(p::PolyElem{T})whereT
dp=degree(p)
dp=degree(p)
RR=ArbField(53)
RR=ArbField(53)
...
@@ -240,6 +271,11 @@ function printpoly(p::PolyElem)
...
@@ -240,6 +271,11 @@ function printpoly(p::PolyElem)
@showconvert_balls_to_upperBound_Float(p)
@showconvert_balls_to_upperBound_Float(p)
end
end
"""
comparepoly(p::PolyElem{T}, q::PolyElem{T}) where T <:Union{arb,arb_poly}
Prints indexes and corresponding coefficients of p and q in a line each.
"""
function comparepoly(p::PolyElem{T},q::PolyElem{T})whereT<:Union{arb,arb_poly}
function comparepoly(p::PolyElem{T},q::PolyElem{T})whereT<:Union{arb,arb_poly}
d=max(degree(p),degree(q))
d=max(degree(p),degree(q))
ifT<:PolyElem
ifT<:PolyElem
...
@@ -258,6 +294,11 @@ function comparepoly(p::PolyElem{T}, q::PolyElem{T}) where T <:Union{arb,arb_pol
...
@@ -258,6 +294,11 @@ function comparepoly(p::PolyElem{T}, q::PolyElem{T}) where T <:Union{arb,arb_pol
end
end
end
end
"""
comparepoly(p::PolyElem{T}, q::PolyElem{S}) where {T,S}
Prints indexes and corresponding coefficients of p and q in a line each.
"""
function comparepoly(p::PolyElem{T},q::PolyElem{S})where{T,S}
function comparepoly(p::PolyElem{T},q::PolyElem{S})where{T,S}
d=max(degree(p),degree(q))
d=max(degree(p),degree(q))
ifT<:PolyElem
ifT<:PolyElem
...
@@ -280,6 +321,11 @@ function sub(q,p)
...
@@ -280,6 +321,11 @@ function sub(q,p)
end
end
end
end
"""
subs(q::PolyElem{T},p::PolyElem) where {T<:Union{PolyElem,AbstractFloat}}
Subtract a polynomial p with rational coefficients from a polynomial q with real coefficients.
"""
function subs(q::PolyElem{T},p::PolyElem)where{T<:Union{PolyElem,AbstractFloat}}
function subs(q::PolyElem{T},p::PolyElem)where{T<:Union{PolyElem,AbstractFloat}}
d=max(degree(q),degree(p))
d=max(degree(q),degree(p))
FB=Nemo.AbstractAlgebra.Floats{BigFloat}()
FB=Nemo.AbstractAlgebra.Floats{BigFloat}()
...
@@ -300,6 +346,12 @@ function subs(q::PolyElem{T},p::PolyElem) where {T<:Union{PolyElem,AbstractFloat
...
@@ -300,6 +346,12 @@ function subs(q::PolyElem{T},p::PolyElem) where {T<:Union{PolyElem,AbstractFloat
r
r
end
end
"""
convert_polynomial(p::PolyElem{T},listOfRings, coeff_field) where {T <: Union{QQPolyRingElem,QQFieldElem}}
Convert a polynomial with rational coefficients to a polynomial with coefficients in coeff_field.
listOfRings includes an array of polynomial rings the polynomial should be converted to, starting with the outermost ring, followed by the polynomial ring of its coefficients, etc.
"""
function convert_polynomial(p::PolyElem{T},listOfRings,coeff_field)where{T<:Union{QQPolyRingElem,QQFieldElem}}
function convert_polynomial(p::PolyElem{T},listOfRings,coeff_field)where{T<:Union{QQPolyRingElem,QQFieldElem}}
d=degree(p)
d=degree(p)
q=(listOfRings[1])(0)
q=(listOfRings[1])(0)
...
@@ -319,6 +371,11 @@ function convert_polynomial(p::PolyElem{T},listOfRings, coeff_field) where {T <:
...
@@ -319,6 +371,11 @@ function convert_polynomial(p::PolyElem{T},listOfRings, coeff_field) where {T <:
q
q
end
end
"""
convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T}) where T
Return a polynomial with interval valued coefficients, whose coefficients are intervals around the coefficients of p with the radius being the coefficients of r.
"""
function convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T})whereT
function convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T})whereT
d=max(degree(p),degree(r))
d=max(degree(p),degree(r))
RR=ArbField(53)
RR=ArbField(53)
...
@@ -342,6 +399,11 @@ function convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T}) where T
...
@@ -342,6 +399,11 @@ function convert_polynomial_to_intervals(p::PolyElem{T},r::PolyElem{T}) where T
pi
pi
end
end
"""
extract_radius(p::PolyElem{T}) where T
Return a polynomial whose coefficients are the radii of the coefficients of the input polynomial p.
"""
function extract_radius(p::PolyElem{T})whereT
function extract_radius(p::PolyElem{T})whereT
r=parent(p)(0)
r=parent(p)(0)
d=degree(p)
d=degree(p)
...
@@ -355,6 +417,11 @@ function extract_radius(p::PolyElem{T}) where T
...
@@ -355,6 +417,11 @@ function extract_radius(p::PolyElem{T}) where T
r
r
end
end
"""
replace_zeros!(p::PolyElem{T}, d, dp = -1, k = -1) where T
Replaces zero coefficients in polynomial p by the value d, dp being the wanted degree of the output polynomial, and k the degree of the coefficients for bivariate input polynomials.
"""
function replace_zeros!(p::PolyElem{T},d,dp=-1,k=-1)whereT
function replace_zeros!(p::PolyElem{T},d,dp=-1,k=-1)whereT