Skip to content

Commit

Permalink
Change _acb_set to take real and imag part as tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 27, 2024
1 parent 13e29a5 commit 4dcf522
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)

Check warning on line 1118 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1118

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

Check warning on line 1129 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1129

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

Check warning on line 1140 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1140

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

Check warning on line 1151 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1151

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

Check warning on line 1308 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1308

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

Check warning on line 1319 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1319

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

Check warning on line 1330 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1330

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

Check warning on line 1341 in src/arb/ArbTypes.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ArbTypes.jl#L1341

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

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1702

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

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1720

Added line #L1720 was not covered by tests
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1722

Added line #L1722 was not covered by tests
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1724

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

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1748

Added line #L1748 was not covered by tests
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1750

Added line #L1750 was not covered by tests
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)

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

View check run for this annotation

Codecov / codecov/patch

src/arb/Complex.jl#L1752

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

Check warning on line 73 in src/arb/ComplexMat.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/ComplexMat.jl#L73

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

Check warning on line 1697 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1697

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

Check warning on line 1715 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1715

Added line #L1715 was not covered by tests
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)

Check warning on line 1717 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1717

Added line #L1717 was not covered by tests
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)

Check warning on line 1719 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1719

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

Check warning on line 1743 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1743

Added line #L1743 was not covered by tests
r = _real_ptr(x)
_arb_set(r, y, p)
_arb_set(r, yz[1], p)

Check warning on line 1745 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1745

Added line #L1745 was not covered by tests
i = _imag_ptr(x)
_arb_set(i, z, p)
_arb_set(i, yz[2], p)

Check warning on line 1747 in src/arb/acb.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb.jl#L1747

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

Check warning on line 76 in src/arb/acb_mat.jl

View check run for this annotation

Codecov / codecov/patch

src/arb/acb_mat.jl#L76

Added line #L76 was not covered by tests
end
end
end
Expand Down

0 comments on commit 4dcf522

Please sign in to comment.