Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unroll some @eval loops around _arb_set code #1922

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 109 additions & 115 deletions src/arb/Complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1619,143 +1619,137 @@
_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)

Check warning on line 1641 in src/arb/Complex.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1640-L1641

Added lines #L1640 - L1641 were not covered by tests
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)

Check warning on line 1692 in src/arb/Complex.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1688-L1692

Added lines #L1688 - L1692 were not covered by tests
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,

Check warning on line 1703 in src/arb/Complex.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1702-L1703

Added lines #L1702 - L1703 were not covered by tests
(Ref{ComplexFieldElem}, Int, Int), x, y, z)
ccall((:acb_set_round, libflint), Nothing,

Check warning on line 1705 in src/arb/Complex.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1705

Added line #L1705 was not covered by tests
(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)

Check warning on line 1724 in src/arb/Complex.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1720-L1724

Added lines #L1720 - L1724 were not covered by tests
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)

Check warning on line 1752 in src/arb/Complex.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1748-L1752

Added lines #L1748 - L1752 were not covered by tests
end

###############################################################################
Expand Down
Loading
Loading