From 4dcf5220b7bd535ca402e5c56b8817ca0492e6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Sun, 27 Oct 2024 18:01:05 +0100 Subject: [PATCH] Change `_acb_set` to take real and imag part as tuple --- src/arb/ArbTypes.jl | 22 +++++++++++----------- src/arb/Complex.jl | 30 +++++++++++++++--------------- src/arb/ComplexMat.jl | 2 +- src/arb/acb.jl | 30 +++++++++++++++--------------- src/arb/acb_mat.jl | 2 +- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/arb/ArbTypes.jl b/src/arb/ArbTypes.jl index d5a66b99f..6a078ed14 100644 --- a/src/arb/ArbTypes.jl +++ b/src/arb/ArbTypes.jl @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/arb/Complex.jl b/src/arb/Complex.jl index 81189ca02..d7de364b7 100644 --- a/src/arb/Complex.jl +++ b/src/arb/Complex.jl @@ -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) @@ -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 ############################################################################### diff --git a/src/arb/ComplexMat.jl b/src/arb/ComplexMat.jl index fff7ab1e7..89f2e1a16 100644 --- a/src/arb/ComplexMat.jl +++ b/src/arb/ComplexMat.jl @@ -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 diff --git a/src/arb/acb.jl b/src/arb/acb.jl index 292d8227a..382724472 100644 --- a/src/arb/acb.jl +++ b/src/arb/acb.jl @@ -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) @@ -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 ############################################################################### diff --git a/src/arb/acb_mat.jl b/src/arb/acb_mat.jl index 1bf5111cb..aa544c74e 100644 --- a/src/arb/acb_mat.jl +++ b/src/arb/acb_mat.jl @@ -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