Skip to content

Commit

Permalink
Change _acb_set to take real and imag part as tuple (#1928)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Oct 27, 2024
1 parent c8e30fc commit 2de7b3a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
22 changes: 11 additions & 11 deletions src/arb/ArbTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ mutable struct ComplexFieldElem <: FieldElem

function ComplexFieldElem(x::T, y::T, p::Int) where {T <: Union{Real, ZZRingElem, QQFieldElem, AbstractString, RealFieldElem}}
z = ComplexFieldElem()
_acb_set(z, x, y, p)
_acb_set(z, (x, y), p)
return z
end
end
Expand Down Expand Up @@ -393,13 +393,13 @@ mutable struct AcbFieldElem <: FieldElem

#function AcbFieldElem{T <: Union{Int, UInt, Float64, ZZRingElem, BigFloat, ArbFieldElem}}(x::T, y::T)
# z = AcbFieldElem()
# _acb_set(z, x, y)
# _acb_set(z, (x, y))
# return z
#end

function AcbFieldElem(x::T, y::T, p::Int) where {T <: Union{Real, ZZRingElem, QQFieldElem, AbstractString, ArbFieldElem}}
z = AcbFieldElem()
_acb_set(z, x, y, p)
_acb_set(z, (x, y), p)
return z
end
end
Expand Down Expand Up @@ -1115,7 +1115,7 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[i, j][1], arr[i,j][2], prec)
_acb_set(el, arr[i, j], prec)
end
end
return z
Expand All @@ -1126,7 +1126,7 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[i, j][1], arr[i,j][2], prec)
_acb_set(el, arr[i, j], prec)
end
end
return z
Expand All @@ -1137,7 +1137,7 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[(i-1)*c+j][1], arr[(i-1)*c+j][2], prec)
_acb_set(el, arr[(i-1)*c+j], prec)
end
end
return z
Expand All @@ -1148,7 +1148,7 @@ mutable struct ComplexMatrix <: MatElem{ComplexFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[(i-1)*c+j][1], arr[(i-1)*c+j][2], prec)
_acb_set(el, arr[(i-1)*c+j], prec)
end
end
return z
Expand Down Expand Up @@ -1305,7 +1305,7 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[i, j][1], arr[i,j][2], prec)
_acb_set(el, arr[i, j], prec)
end
end
return z
Expand All @@ -1316,7 +1316,7 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[i, j][1], arr[i,j][2], prec)
_acb_set(el, arr[i, j], prec)
end
end
return z
Expand All @@ -1327,7 +1327,7 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[(i-1)*c+j][1], arr[(i-1)*c+j][2], prec)
_acb_set(el, arr[(i-1)*c+j], prec)
end
end
return z
Expand All @@ -1338,7 +1338,7 @@ mutable struct AcbMatrix <: MatElem{AcbFieldElem}
GC.@preserve z for i = 1:r
for j = 1:c
el = mat_entry_ptr(z, i, j)
_acb_set(el, arr[(i-1)*c+j][1], arr[(i-1)*c+j][2], prec)
_acb_set(el, arr[(i-1)*c+j], prec)
end
end
return z
Expand Down
30 changes: 15 additions & 15 deletions src/arb/Complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1699,36 +1699,36 @@ function _acb_set(x::ComplexFieldElemOrPtr, y::BigFloat, p::Int)
zero!(i)
end

function _acb_set(x::ComplexFieldElemOrPtr, y::Int, z::Int, p::Int)
function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{Int,Int}, p::Int)
ccall((:acb_set_si_si, libflint), Nothing,
(Ref{ComplexFieldElem}, Int, Int), x, y, z)
(Ref{ComplexFieldElem}, Int, Int), x, yz[1], yz[2])
ccall((:acb_set_round, libflint), Nothing,
(Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p)
end

function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem, z::RealFieldElem)
function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{RealFieldElem,RealFieldElem})
ccall((:acb_set_arb_arb, libflint), Nothing,
(Ref{ComplexFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}), x, y, z)
(Ref{ComplexFieldElem}, Ref{RealFieldElem}, Ref{RealFieldElem}), x, yz[1], yz[2])
end

function _acb_set(x::ComplexFieldElemOrPtr, y::RealFieldElem, z::RealFieldElem, p::Int)
_acb_set(x, y, z)
function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{RealFieldElem,RealFieldElem}, p::Int)
_acb_set(x, yz)
ccall((:acb_set_round, libflint), Nothing,
(Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Int), x, x, p)
end

function _acb_set(x::ComplexFieldElemOrPtr, y::QQFieldElem, z::QQFieldElem, p::Int)
function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{QQFieldElem,QQFieldElem}, p::Int)
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)
end

function _acb_set(x::ComplexFieldElemOrPtr, y::T, z::T, p::Int) where {T <: AbstractString}
function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{AbstractString,AbstractString}, p::Int)
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)
end

function _acb_set(x::ComplexFieldElemOrPtr, y::Real, p::Int)
Expand All @@ -1745,11 +1745,11 @@ function _acb_set(x::ComplexFieldElemOrPtr, y::Complex, p::Int)
_arb_set(i, imag(y), p)
end

function _acb_set(x::ComplexFieldElemOrPtr, y::IntegerUnion, z::IntegerUnion, p::Int)
function _acb_set(x::ComplexFieldElemOrPtr, yz::Tuple{IntegerUnion,IntegerUnion}, p::Int)
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)
end

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/arb/ComplexMat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ for T in [Integer, Float64, ZZRingElem, QQFieldElem, RealFieldElem, BigFloat, Ab

GC.@preserve x begin
z = mat_entry_ptr(x, r, c)
_acb_set(z, y[1], y[2], precision(Balls))
_acb_set(z, y, precision(Balls))
end
end
end
Expand Down
30 changes: 15 additions & 15 deletions src/arb/acb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1694,36 +1694,36 @@ function _acb_set(x::AcbFieldElemOrPtr, y::BigFloat, p::Int)
zero!(i)
end

function _acb_set(x::AcbFieldElemOrPtr, y::Int, z::Int, p::Int)
function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{Int,Int}, p::Int)
ccall((:acb_set_si_si, libflint), Nothing,
(Ref{AcbFieldElem}, Int, Int), x, y, z)
(Ref{AcbFieldElem}, Int, Int), x, yz[1], yz[2])
ccall((:acb_set_round, libflint), Nothing,
(Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p)
end

function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem, z::ArbFieldElem)
function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{ArbFieldElem,ArbFieldElem})
ccall((:acb_set_arb_arb, libflint), Nothing,
(Ref{AcbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, y, z)
(Ref{AcbFieldElem}, Ref{ArbFieldElem}, Ref{ArbFieldElem}), x, yz[1], yz[2])
end

function _acb_set(x::AcbFieldElemOrPtr, y::ArbFieldElem, z::ArbFieldElem, p::Int)
_acb_set(x, y, z)
function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{ArbFieldElem,ArbFieldElem}, p::Int)
_acb_set(x, yz)
ccall((:acb_set_round, libflint), Nothing,
(Ref{AcbFieldElem}, Ref{AcbFieldElem}, Int), x, x, p)
end

function _acb_set(x::AcbFieldElemOrPtr, y::QQFieldElem, z::QQFieldElem, p::Int)
function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{QQFieldElem,QQFieldElem}, p::Int)
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)
end

function _acb_set(x::AcbFieldElemOrPtr, y::T, z::T, p::Int) where {T <: AbstractString}
function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{AbstractString,AbstractString}, p::Int)
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)
end

function _acb_set(x::AcbFieldElemOrPtr, y::Real, p::Int)
Expand All @@ -1740,11 +1740,11 @@ function _acb_set(x::AcbFieldElemOrPtr, y::Complex, p::Int)
_arb_set(i, imag(y), p)
end

function _acb_set(x::AcbFieldElemOrPtr, y::IntegerUnion, z::IntegerUnion, p::Int)
function _acb_set(x::AcbFieldElemOrPtr, yz::Tuple{IntegerUnion,IntegerUnion}, p::Int)
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)
end

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion src/arb/acb_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ for T in [Integer, Float64, ZZRingElem, QQFieldElem, ArbFieldElem, BigFloat, Abs

GC.@preserve x begin
z = mat_entry_ptr(x, r, c)
_acb_set(z, y[1], y[2], precision(base_ring(x)))
_acb_set(z, y, precision(base_ring(x)))
end
end
end
Expand Down

0 comments on commit 2de7b3a

Please sign in to comment.