diff --git a/src/arb/Complex.jl b/src/arb/Complex.jl index 6d5e43773..81189ca02 100644 --- a/src/arb/Complex.jl +++ b/src/arb/Complex.jl @@ -1619,143 +1619,137 @@ end _real_ptr(x::ComplexFieldElemOrPtr) = @ccall libflint.acb_real_ptr(x::Ref{ComplexFieldElem})::Ptr{RealFieldElem} _imag_ptr(x::ComplexFieldElemOrPtr) = @ccall libflint.acb_imag_ptr(x::Ref{ComplexFieldElem})::Ptr{RealFieldElem} -for (typeofx, passtoc) in ((ComplexFieldElem, Ref{ComplexFieldElem}), (Ptr{ComplexFieldElem}, Ptr{ComplexFieldElem})) - for (f,t) in (("acb_set_si", Int), ("acb_set_ui", UInt), - ("acb_set_d", Float64)) - @eval begin - function _acb_set(x::($typeofx), y::($t)) - ccall(($f, libflint), Nothing, (($passtoc), ($t)), x, y) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Int) + ccall((:acb_set_si, libflint), Nothing, (Ref{ComplexFieldElem}, Int), x, y) +end - function _acb_set(x::($typeofx), y::($t), p::Int) - _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end - end - end +function _acb_set(x::ComplexFieldElemOrPtr, y::UInt) + ccall((:acb_set_ui, libflint), Nothing, (Ref{ComplexFieldElem}, UInt), x, y) +end - @eval begin - function _acb_set(x::($typeofx), y::ZZRingElem) - ccall((:acb_set_fmpz, libflint), Nothing, (($passtoc), Ref{ZZRingElem}), x, y) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Float64) + ccall((:acb_set_d, libflint), Nothing, (Ref{ComplexFieldElem}, Float64), x, y) +end - function _acb_set(x::($typeofx), y::ZZRingElem, p::Int) - ccall((:acb_set_round_fmpz, libflint), Nothing, - (($passtoc), Ref{ZZRingElem}, Int), x, y, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) + _acb_set(x, y) + ccall((:acb_set_round, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) +end - function _acb_set(x::($typeofx), y::QQFieldElem, p::Int) - ccall((:acb_set_fmpq, libflint), Nothing, - (($passtoc), Ref{QQFieldElem}, Int), x, y, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::ZZRingElem) + ccall((:acb_set_fmpz, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ZZRingElem}), x, y) +end - function _acb_set(x::($typeofx), y::RealFieldElem) - ccall((:acb_set_arb, libflint), Nothing, (($passtoc), Ref{RealFieldElem}), x, y) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::ZZRingElem, p::Int) + ccall((:acb_set_round_fmpz, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{ZZRingElem}, Int), x, y, p) +end - function _acb_set(x::($typeofx), y::RealFieldElem, p::Int) - _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::QQFieldElem, p::Int) + ccall((:acb_set_fmpq, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{QQFieldElem}, Int), x, y, p) +end - function _acb_set(x::($typeofx), y::ComplexFieldElemOrPtr) - ccall((:acb_set, libflint), Nothing, (($passtoc), Ref{ComplexFieldElem}), x, y) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem) + ccall((:acb_set_arb, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{RealFieldElem}), x, y) +end - function _acb_set(x::($typeofx), y::Ptr{acb_struct}) - ccall((:acb_set, libflint), Nothing, (($passtoc), Ptr{acb_struct}), x, y) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem, p::Int) + _acb_set(x, y) + ccall((:acb_set_round, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) +end - function _acb_set(x::Ptr{acb_struct}, y::($typeofx)) - ccall((:acb_set, libflint), Nothing, (Ptr{acb_struct}, ($passtoc)) , x, y) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::ComplexFieldElemOrPtr) + ccall((:acb_set, libflint), Nothing, (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}), x, y) +end - function _acb_set(x::($typeofx), y::ComplexFieldElemOrPtr, p::Int) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), Ref{ComplexFieldElem}, Int), x, y, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Ptr{acb_struct}) + ccall((:acb_set, libflint), Nothing, (Ref{ComplexFieldElem}, Ptr{acb_struct}), x, y) +end - function _acb_set(x::($typeofx), y::AbstractString, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::Ptr{acb_struct}, y::ComplexFieldElemOrPtr) + ccall((:acb_set, libflint), Nothing, (Ptr{acb_struct}, Ref{ComplexFieldElem}) , x, y) +end - function _acb_set(x::($typeofx), y::BigFloat) - r = _real_ptr(x) - _arb_set(r, y) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::ComplexFieldElemOrPtr, p::Int) + ccall((:acb_set_round, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, y, p) +end - function _acb_set(x::($typeofx), y::BigFloat, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::AbstractString, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + zero!(i) +end - function _acb_set(x::($typeofx), y::Int, z::Int, p::Int) - ccall((:acb_set_si_si, libflint), Nothing, - (($passtoc), Int, Int), x, y, z) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::BigFloat) + r = _real_ptr(x) + _arb_set(r, y) + i = _imag_ptr(x) + zero!(i) +end - function _acb_set(x::($typeofx), y::RealFieldElem, z::RealFieldElem) - ccall((:acb_set_arb_arb, libflint), Nothing, - (($passtoc), Ref{RealFieldElem}, Ref{RealFieldElem}), x, y, z) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::BigFloat, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + zero!(i) +end - function _acb_set(x::($typeofx), y::RealFieldElem, z::RealFieldElem, p::Int) - _acb_set(x, y, z) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Int, z::Int, p::Int) + ccall((:acb_set_si_si, libflint), Nothing, + (Ref{ComplexFieldElem}, Int, Int), x, y, z) + ccall((:acb_set_round, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) +end - function _acb_set(x::($typeofx), y::QQFieldElem, z::QQFieldElem, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - _arb_set(i, z, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem, z::RealFieldElem) + ccall((:acb_set_arb_arb, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}), x, y, z) +end - function _acb_set(x::($typeofx), y::T, z::T, p::Int) where {T <: AbstractString} - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - _arb_set(i, z, p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem, z::RealFieldElem, p::Int) + _acb_set(x, y, z) + ccall((:acb_set_round, libflint), Nothing, + (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p) +end - function _acb_set(x::($typeofx), y::Real, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::QQFieldElem, z::QQFieldElem, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + _arb_set(i, z, p) +end - function _acb_set(x::($typeofx), y::Complex, p::Int) - r = _real_ptr(x) - _arb_set(r, real(y), p) - i = _imag_ptr(x) - _arb_set(i, imag(y), p) - end +function _acb_set(x::ComplexFieldElemOrPtr, y::T, z::T, p::Int) where {T <: AbstractString} + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + _arb_set(i, z, p) +end - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Real, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + zero!(i) +end - for T in (Real, ZZRingElem) - @eval begin - function _acb_set(x::($typeofx), y::($T), z::($T), p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - _arb_set(i, z, p) - end - end - end +function _acb_set(x::ComplexFieldElemOrPtr, y::Complex, p::Int) + r = _real_ptr(x) + _arb_set(r, real(y), p) + i = _imag_ptr(x) + _arb_set(i, imag(y), p) +end + +function _acb_set(x::ComplexFieldElemOrPtr, y::IntegerUnion, z::IntegerUnion, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + _arb_set(i, z, p) end ############################################################################### diff --git a/src/arb/Real.jl b/src/arb/Real.jl index daf3cdf07..f9f0c3409 100644 --- a/src/arb/Real.jl +++ b/src/arb/Real.jl @@ -1958,95 +1958,94 @@ end # ################################################################################ -for (typeofx, passtoc) in ((RealFieldElem, Ref{RealFieldElem}), (Ptr{RealFieldElem}, Ptr{RealFieldElem})) - for (f,t) in (("arb_set_si", Int), ("arb_set_ui", UInt), - ("arb_set_d", Float64)) - @eval begin - function _arb_set(x::($typeofx), y::($t)) - ccall(($f, libflint), Nothing, (($passtoc), ($t)), x, y) - end - - function _arb_set(x::($typeofx), y::($t), p::Int) - _arb_set(x, y) - ccall((:arb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end - end - end +function _arb_set(x::RealFieldElemOrPtr, y::Int) + ccall((:arb_set_si, libflint), Nothing, (Ref{RealFieldElem}, Int), x, y) +end - @eval begin - function _arb_set(x::($typeofx), y::ZZRingElem) - ccall((:arb_set_fmpz, libflint), Nothing, (($passtoc), Ref{ZZRingElem}), x, y) - end +function _arb_set(x::RealFieldElemOrPtr, y::UInt) + ccall((:arb_set_ui, libflint), Nothing, (Ref{RealFieldElem}, UInt), x, y) +end - function _arb_set(x::($typeofx), y::ZZRingElem, p::Int) - ccall((:arb_set_round_fmpz, libflint), Nothing, - (($passtoc), Ref{ZZRingElem}, Int), x, y, p) - end +function _arb_set(x::RealFieldElemOrPtr, y::Float64) + ccall((:arb_set_d, libflint), Nothing, (Ref{RealFieldElem}, Float64), x, y) +end - function _arb_set(x::($typeofx), y::QQFieldElem, p::Int) - ccall((:arb_set_fmpq, libflint), Nothing, - (($passtoc), Ref{QQFieldElem}, Int), x, y, p) - end +function _arb_set(x::RealFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) + _arb_set(x, y) + ccall((:arb_set_round, libflint), Nothing, + (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), x, x, p) +end - function _arb_set(x::($typeofx), y::RealFieldElemOrPtr) - ccall((:arb_set, libflint), Nothing, (($passtoc), Ref{RealFieldElem}), x, y) - end +function _arb_set(x::RealFieldElemOrPtr, y::ZZRingElem) + ccall((:arb_set_fmpz, libflint), Nothing, (Ref{RealFieldElem}, Ref{ZZRingElem}), x, y) +end - function _arb_set(x::($typeofx), y::Ptr{arb_struct}) - ccall((:arb_set, libflint), Nothing, (($passtoc), Ptr{arb_struct}), x, y) - end +function _arb_set(x::RealFieldElemOrPtr, y::ZZRingElem, p::Int) + ccall((:arb_set_round_fmpz, libflint), Nothing, + (Ref{RealFieldElem}, Ref{ZZRingElem}, Int), x, y, p) +end - function _arb_set(x::Ptr{arb_struct}, y::($typeofx)) - ccall((:arb_set, libflint), Nothing, (Ptr{arb_struct}, ($passtoc)) , x, y) - end +function _arb_set(x::RealFieldElemOrPtr, y::QQFieldElem, p::Int) + ccall((:arb_set_fmpq, libflint), Nothing, + (Ref{RealFieldElem}, Ref{QQFieldElem}, Int), x, y, p) +end - function _arb_set(x::($typeofx), y::RealFieldElemOrPtr, p::Int) - ccall((:arb_set_round, libflint), Nothing, - (($passtoc), Ref{RealFieldElem}, Int), x, y, p) - end +function _arb_set(x::RealFieldElemOrPtr, y::RealFieldElemOrPtr) + ccall((:arb_set, libflint), Nothing, (Ref{RealFieldElem}, Ref{RealFieldElem}), x, y) +end - function _arb_set(x::($typeofx), y::AbstractString, p::Int) - s = string(y) - err = ccall((:arb_set_str, libflint), Int32, - (($passtoc), Ptr{UInt8}, Int), x, s, p) - err == 0 || error("Invalid real string: $(repr(s))") - end +function _arb_set(x::RealFieldElemOrPtr, y::Ptr{arb_struct}) + ccall((:arb_set, libflint), Nothing, (Ref{RealFieldElem}, Ptr{arb_struct}), x, y) +end - function _arb_set(x::($typeofx), y::BigFloat) - m = _mid_ptr(x) - r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) - end +function _arb_set(x::Ptr{arb_struct}, y::RealFieldElemOrPtr) + ccall((:arb_set, libflint), Nothing, (Ptr{arb_struct}, Ref{RealFieldElem}) , x, y) +end - function _arb_set(x::($typeofx), y::BigFloat, p::Int) - m = _mid_ptr(x) - r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) - ccall((:arb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _arb_set(x::RealFieldElemOrPtr, y::RealFieldElemOrPtr, p::Int) + ccall((:arb_set_round, libflint), Nothing, + (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), x, y, p) +end - function _arb_set(x::($typeofx), y::Integer) - _arb_set(x, ZZRingElem(y)) - end +function _arb_set(x::RealFieldElemOrPtr, y::AbstractString, p::Int) + s = string(y) + err = ccall((:arb_set_str, libflint), Int32, + (Ref{RealFieldElem}, Ptr{UInt8}, Int), x, s, p) + err == 0 || error("Invalid real string: $(repr(s))") +end - function _arb_set(x::($typeofx), y::Integer, p::Int) - _arb_set(x, ZZRingElem(y), p) - end +function _arb_set(x::RealFieldElemOrPtr, y::BigFloat) + m = _mid_ptr(x) + r = _rad_ptr(x) + ccall((:arf_set_mpfr, libflint), Nothing, + (Ptr{arf_struct}, Ref{BigFloat}), m, y) + ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) +end - function _arb_set(x::($typeofx), y::Real) - _arb_set(x, BigFloat(y)) - end +function _arb_set(x::RealFieldElemOrPtr, y::BigFloat, p::Int) + m = _mid_ptr(x) + r = _rad_ptr(x) + ccall((:arf_set_mpfr, libflint), Nothing, + (Ptr{arf_struct}, Ref{BigFloat}), m, y) + ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) + ccall((:arb_set_round, libflint), Nothing, + (Ref{RealFieldElem}, Ref{RealFieldElem}, Int), x, x, p) +end - function _arb_set(x::($typeofx), y::Real, p::Int) - _arb_set(x, BigFloat(y), p) - end - end +function _arb_set(x::RealFieldElemOrPtr, y::Integer) + _arb_set(x, ZZRingElem(y)) +end + +function _arb_set(x::RealFieldElemOrPtr, y::Integer, p::Int) + _arb_set(x, ZZRingElem(y), p) +end + +function _arb_set(x::RealFieldElemOrPtr, y::Real) + _arb_set(x, BigFloat(y)) +end + +function _arb_set(x::RealFieldElemOrPtr, y::Real, p::Int) + _arb_set(x, BigFloat(y), p) end ################################################################################ diff --git a/src/arb/acb.jl b/src/arb/acb.jl index 7e9edcab6..292d8227a 100644 --- a/src/arb/acb.jl +++ b/src/arb/acb.jl @@ -1614,143 +1614,137 @@ end _real_ptr(x::AcbFieldElemOrPtr) = @ccall libflint.acb_real_ptr(x::Ref{AcbFieldElem})::Ptr{ArbFieldElem} _imag_ptr(x::AcbFieldElemOrPtr) = @ccall libflint.acb_imag_ptr(x::Ref{AcbFieldElem})::Ptr{ArbFieldElem} -for (typeofx, passtoc) in ((AcbFieldElem, Ref{AcbFieldElem}), (Ptr{AcbFieldElem}, Ptr{AcbFieldElem})) - for (f,t) in (("acb_set_si", Int), ("acb_set_ui", UInt), - ("acb_set_d", Float64)) - @eval begin - function _acb_set(x::($typeofx), y::($t)) - ccall(($f, libflint), Nothing, (($passtoc), ($t)), x, y) - end +function _acb_set(x::AcbFieldElemOrPtr, y::Int) + ccall((:acb_set_si, libflint), Nothing, (Ref{AcbFieldElem}, Int), x, y) +end - function _acb_set(x::($typeofx), y::($t), p::Int) - _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end - end - end +function _acb_set(x::AcbFieldElemOrPtr, y::UInt) + ccall((:acb_set_ui, libflint), Nothing, (Ref{AcbFieldElem}, UInt), x, y) +end - @eval begin - function _acb_set(x::($typeofx), y::ZZRingElem) - ccall((:acb_set_fmpz, libflint), Nothing, (($passtoc), Ref{ZZRingElem}), x, y) - end +function _acb_set(x::AcbFieldElemOrPtr, y::Float64) + ccall((:acb_set_d, libflint), Nothing, (Ref{AcbFieldElem}, Float64), x, y) +end - function _acb_set(x::($typeofx), y::ZZRingElem, p::Int) - ccall((:acb_set_round_fmpz, libflint), Nothing, - (($passtoc), Ref{ZZRingElem}, Int), x, y, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) + _acb_set(x, y) + ccall((:acb_set_round, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) +end - function _acb_set(x::($typeofx), y::QQFieldElem, p::Int) - ccall((:acb_set_fmpq, libflint), Nothing, - (($passtoc), Ref{QQFieldElem}, Int), x, y, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::ZZRingElem) + ccall((:acb_set_fmpz, libflint), Nothing, (Ref{AcbFieldElem}, Ref{ZZRingElem}), x, y) +end - function _acb_set(x::($typeofx), y::ArbFieldElem) - ccall((:acb_set_arb, libflint), Nothing, (($passtoc), Ref{ArbFieldElem}), x, y) - end +function _acb_set(x::AcbFieldElemOrPtr, y::ZZRingElem, p::Int) + ccall((:acb_set_round_fmpz, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{ZZRingElem}, Int), x, y, p) +end - function _acb_set(x::($typeofx), y::ArbFieldElem, p::Int) - _acb_set(x, y) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::QQFieldElem, p::Int) + ccall((:acb_set_fmpq, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{QQFieldElem}, Int), x, y, p) +end - function _acb_set(x::($typeofx), y::AcbFieldElemOrPtr) - ccall((:acb_set, libflint), Nothing, (($passtoc), Ref{AcbFieldElem}), x, y) - end +function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem) + ccall((:acb_set_arb, libflint), Nothing, (Ref{AcbFieldElem}, Ref{ArbFieldElem}), x, y) +end - function _acb_set(x::($typeofx), y::Ptr{acb_struct}) - ccall((:acb_set, libflint), Nothing, (($passtoc), Ptr{acb_struct}), x, y) - end +function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem, p::Int) + _acb_set(x, y) + ccall((:acb_set_round, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) +end - function _acb_set(x::Ptr{acb_struct}, y::($typeofx)) - ccall((:acb_set, libflint), Nothing, (Ptr{acb_struct}, ($passtoc)) , x, y) - end +function _acb_set(x::AcbFieldElemOrPtr, y::AcbFieldElemOrPtr) + ccall((:acb_set, libflint), Nothing, (Ref{AcbFieldElem}, Ref{AcbFieldElem}), x, y) +end - function _acb_set(x::($typeofx), y::AcbFieldElemOrPtr, p::Int) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), Ref{AcbFieldElem}, Int), x, y, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::Ptr{acb_struct}) + ccall((:acb_set, libflint), Nothing, (Ref{AcbFieldElem}, Ptr{acb_struct}), x, y) +end - function _acb_set(x::($typeofx), y::AbstractString, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::Ptr{acb_struct}, y::AcbFieldElemOrPtr) + ccall((:acb_set, libflint), Nothing, (Ptr{acb_struct}, Ref{AcbFieldElem}) , x, y) +end - function _acb_set(x::($typeofx), y::BigFloat) - r = _real_ptr(x) - _arb_set(r, y) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::AcbFieldElemOrPtr, y::AcbFieldElemOrPtr, p::Int) + ccall((:acb_set_round, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, y, p) +end - function _acb_set(x::($typeofx), y::BigFloat, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::AcbFieldElemOrPtr, y::AbstractString, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + zero!(i) +end - function _acb_set(x::($typeofx), y::Int, z::Int, p::Int) - ccall((:acb_set_si_si, libflint), Nothing, - (($passtoc), Int, Int), x, y, z) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::BigFloat) + r = _real_ptr(x) + _arb_set(r, y) + i = _imag_ptr(x) + zero!(i) +end - function _acb_set(x::($typeofx), y::ArbFieldElem, z::ArbFieldElem) - ccall((:acb_set_arb_arb, libflint), Nothing, - (($passtoc), Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y, z) - end +function _acb_set(x::AcbFieldElemOrPtr, y::BigFloat, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + zero!(i) +end - function _acb_set(x::($typeofx), y::ArbFieldElem, z::ArbFieldElem, p::Int) - _acb_set(x, y, z) - ccall((:acb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::Int, z::Int, p::Int) + ccall((:acb_set_si_si, libflint), Nothing, + (Ref{AcbFieldElem}, Int, Int), x, y, z) + ccall((:acb_set_round, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) +end - function _acb_set(x::($typeofx), y::QQFieldElem, z::QQFieldElem, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - _arb_set(i, z, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem, z::ArbFieldElem) + ccall((:acb_set_arb_arb, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y, z) +end - function _acb_set(x::($typeofx), y::T, z::T, p::Int) where {T <: AbstractString} - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - _arb_set(i, z, p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem, z::ArbFieldElem, p::Int) + _acb_set(x, y, z) + ccall((:acb_set_round, libflint), Nothing, + (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p) +end - function _acb_set(x::($typeofx), y::Real, p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - zero!(i) - end +function _acb_set(x::AcbFieldElemOrPtr, y::QQFieldElem, z::QQFieldElem, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + _arb_set(i, z, p) +end - function _acb_set(x::($typeofx), y::Complex, p::Int) - r = _real_ptr(x) - _arb_set(r, real(y), p) - i = _imag_ptr(x) - _arb_set(i, imag(y), p) - end +function _acb_set(x::AcbFieldElemOrPtr, y::T, z::T, p::Int) where {T <: AbstractString} + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + _arb_set(i, z, p) +end - end +function _acb_set(x::AcbFieldElemOrPtr, y::Real, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + zero!(i) +end - for T in (Real, ZZRingElem) - @eval begin - function _acb_set(x::($typeofx), y::($T), z::($T), p::Int) - r = _real_ptr(x) - _arb_set(r, y, p) - i = _imag_ptr(x) - _arb_set(i, z, p) - end - end - end +function _acb_set(x::AcbFieldElemOrPtr, y::Complex, p::Int) + r = _real_ptr(x) + _arb_set(r, real(y), p) + i = _imag_ptr(x) + _arb_set(i, imag(y), p) +end + +function _acb_set(x::AcbFieldElemOrPtr, y::IntegerUnion, z::IntegerUnion, p::Int) + r = _real_ptr(x) + _arb_set(r, y, p) + i = _imag_ptr(x) + _arb_set(i, z, p) end ############################################################################### diff --git a/src/arb/arb.jl b/src/arb/arb.jl index 32df2456b..6f31026cb 100644 --- a/src/arb/arb.jl +++ b/src/arb/arb.jl @@ -1966,95 +1966,94 @@ end # ################################################################################ -for (typeofx, passtoc) in ((ArbFieldElem, Ref{ArbFieldElem}), (Ptr{ArbFieldElem}, Ptr{ArbFieldElem})) - for (f,t) in (("arb_set_si", Int), ("arb_set_ui", UInt), - ("arb_set_d", Float64)) - @eval begin - function _arb_set(x::($typeofx), y::($t)) - ccall(($f, libflint), Nothing, (($passtoc), ($t)), x, y) - end - - function _arb_set(x::($typeofx), y::($t), p::Int) - _arb_set(x, y) - ccall((:arb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end - end - end +function _arb_set(x::ArbFieldElemOrPtr, y::Int) + ccall((:arb_set_si, libflint), Nothing, (Ref{ArbFieldElem}, Int), x, y) +end - @eval begin - function _arb_set(x::($typeofx), y::ZZRingElem) - ccall((:arb_set_fmpz, libflint), Nothing, (($passtoc), Ref{ZZRingElem}), x, y) - end +function _arb_set(x::ArbFieldElemOrPtr, y::UInt) + ccall((:arb_set_ui, libflint), Nothing, (Ref{ArbFieldElem}, UInt), x, y) +end - function _arb_set(x::($typeofx), y::ZZRingElem, p::Int) - ccall((:arb_set_round_fmpz, libflint), Nothing, - (($passtoc), Ref{ZZRingElem}, Int), x, y, p) - end +function _arb_set(x::ArbFieldElemOrPtr, y::Float64) + ccall((:arb_set_d, libflint), Nothing, (Ref{ArbFieldElem}, Float64), x, y) +end - function _arb_set(x::($typeofx), y::QQFieldElem, p::Int) - ccall((:arb_set_fmpq, libflint), Nothing, - (($passtoc), Ref{QQFieldElem}, Int), x, y, p) - end +function _arb_set(x::ArbFieldElemOrPtr, y::Union{Int,UInt,Float64}, p::Int) + _arb_set(x, y) + ccall((:arb_set_round, libflint), Nothing, + (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), x, x, p) +end - function _arb_set(x::($typeofx), y::ArbFieldElemOrPtr) - ccall((:arb_set, libflint), Nothing, (($passtoc), Ref{ArbFieldElem}), x, y) - end +function _arb_set(x::ArbFieldElemOrPtr, y::ZZRingElem) + ccall((:arb_set_fmpz, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ZZRingElem}), x, y) +end - function _arb_set(x::($typeofx), y::Ptr{arb_struct}) - ccall((:arb_set, libflint), Nothing, (($passtoc), Ptr{arb_struct}), x, y) - end +function _arb_set(x::ArbFieldElemOrPtr, y::ZZRingElem, p::Int) + ccall((:arb_set_round_fmpz, libflint), Nothing, + (Ref{ArbFieldElem}, Ref{ZZRingElem}, Int), x, y, p) +end - function _arb_set(x::Ptr{arb_struct}, y::($typeofx)) - ccall((:arb_set, libflint), Nothing, (Ptr{arb_struct}, ($passtoc)) , x, y) - end +function _arb_set(x::ArbFieldElemOrPtr, y::QQFieldElem, p::Int) + ccall((:arb_set_fmpq, libflint), Nothing, + (Ref{ArbFieldElem}, Ref{QQFieldElem}, Int), x, y, p) +end - function _arb_set(x::($typeofx), y::ArbFieldElemOrPtr, p::Int) - ccall((:arb_set_round, libflint), Nothing, - (($passtoc), Ref{ArbFieldElem}, Int), x, y, p) - end +function _arb_set(x::ArbFieldElemOrPtr, y::ArbFieldElemOrPtr) + ccall((:arb_set, libflint), Nothing, (Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y) +end - function _arb_set(x::($typeofx), y::AbstractString, p::Int) - s = string(y) - err = ccall((:arb_set_str, libflint), Int32, - (($passtoc), Ptr{UInt8}, Int), x, s, p) - err == 0 || error("Invalid real string: $(repr(s))") - end +function _arb_set(x::ArbFieldElemOrPtr, y::Ptr{arb_struct}) + ccall((:arb_set, libflint), Nothing, (Ref{ArbFieldElem}, Ptr{arb_struct}), x, y) +end - function _arb_set(x::($typeofx), y::BigFloat) - m = _mid_ptr(x) - r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) - end +function _arb_set(x::Ptr{arb_struct}, y::ArbFieldElemOrPtr) + ccall((:arb_set, libflint), Nothing, (Ptr{arb_struct}, Ref{ArbFieldElem}) , x, y) +end - function _arb_set(x::($typeofx), y::BigFloat, p::Int) - m = _mid_ptr(x) - r = _rad_ptr(x) - ccall((:arf_set_mpfr, libflint), Nothing, - (Ptr{arf_struct}, Ref{BigFloat}), m, y) - ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) - ccall((:arb_set_round, libflint), Nothing, - (($passtoc), ($passtoc), Int), x, x, p) - end +function _arb_set(x::ArbFieldElemOrPtr, y::ArbFieldElemOrPtr, p::Int) + ccall((:arb_set_round, libflint), Nothing, + (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), x, y, p) +end - function _arb_set(x::($typeofx), y::Integer) - _arb_set(x, ZZRingElem(y)) - end +function _arb_set(x::ArbFieldElemOrPtr, y::AbstractString, p::Int) + s = string(y) + err = ccall((:arb_set_str, libflint), Int32, + (Ref{ArbFieldElem}, Ptr{UInt8}, Int), x, s, p) + err == 0 || error("Invalid real string: $(repr(s))") +end - function _arb_set(x::($typeofx), y::Integer, p::Int) - _arb_set(x, ZZRingElem(y), p) - end +function _arb_set(x::ArbFieldElemOrPtr, y::BigFloat) + m = _mid_ptr(x) + r = _rad_ptr(x) + ccall((:arf_set_mpfr, libflint), Nothing, + (Ptr{arf_struct}, Ref{BigFloat}), m, y) + ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) +end - function _arb_set(x::($typeofx), y::Real) - _arb_set(x, BigFloat(y)) - end +function _arb_set(x::ArbFieldElemOrPtr, y::BigFloat, p::Int) + m = _mid_ptr(x) + r = _rad_ptr(x) + ccall((:arf_set_mpfr, libflint), Nothing, + (Ptr{arf_struct}, Ref{BigFloat}), m, y) + ccall((:mag_zero, libflint), Nothing, (Ptr{mag_struct}, ), r) + ccall((:arb_set_round, libflint), Nothing, + (Ref{ArbFieldElem}, Ref{ArbFieldElem}, Int), x, x, p) +end - function _arb_set(x::($typeofx), y::Real, p::Int) - _arb_set(x, BigFloat(y), p) - end - end +function _arb_set(x::ArbFieldElemOrPtr, y::Integer) + _arb_set(x, ZZRingElem(y)) +end + +function _arb_set(x::ArbFieldElemOrPtr, y::Integer, p::Int) + _arb_set(x, ZZRingElem(y), p) +end + +function _arb_set(x::ArbFieldElemOrPtr, y::Real) + _arb_set(x, BigFloat(y)) +end + +function _arb_set(x::ArbFieldElemOrPtr, y::Real, p::Int) + _arb_set(x, BigFloat(y), p) end ################################################################################