diff --git a/docs/src/matrix.md b/docs/src/matrix.md index 8b1411567..3f6603ac1 100644 --- a/docs/src/matrix.md +++ b/docs/src/matrix.md @@ -26,11 +26,11 @@ $\mathbb{Z}/n\mathbb{Z}$ (large $n$) | Flint | `ZZModMatrix` $\mathbb{Q}$ | Flint | `QQMatrix` | `QQMatrixSpace` $\mathbb{Z}/p\mathbb{Z}$ (small $p$) | Flint | `fpMatrix` | `fpMatrixSpace` $\mathbb{F}_{p^n}$ (small $p$) | Flint | `fqPolyRepMatrix` | `fqPolyRepMatrixSpace` -$\mathbb{F}_{p^n}$ (large $p$) | Flint | `FqPolyRepMatrix` | `FqPolyRepMatrixSpace -$\mathbb{R}$ (arbitrary precision) | Arb | `RealMat` | `RealMatSpace` -$\mathbb{C}$ (arbitrary precision) | Arb | `ComplexMat` | `ComplexMatSpace` -$\mathbb{R}$ (fixed precision) | Arb | `ArbMatrix` | `ArbMatSpace` -$\mathbb{C}$ (fixed precision) | Arb | `AcbMatrix` | `AcbMatSpace` +$\mathbb{F}_{p^n}$ (large $p$) | Flint | `FqPolyRepMatrix` | `FqPolyRepMatrixSpace` +$\mathbb{R}$ (arbitrary precision) | Arb | `RealMatrix` | `RealMatrixSpace` +$\mathbb{C}$ (arbitrary precision) | Arb | `ComplexMatrix` | `ComplexMatrixSpace` +$\mathbb{R}$ (fixed precision) | Arb | `ArbMatrix` | `ArbMatrixSpace` +$\mathbb{C}$ (fixed precision) | Arb | `AcbMatrix` | `AcbMatrixSpace` The dimensions and base ring $R$ of a generic matrix are stored in its parent object. @@ -59,19 +59,19 @@ matrix functionality, for specific rings in Nemo. ### Comparison operators ```@docs -overlaps(::RealMat, ::RealMat) +overlaps(::RealMatrix, ::RealMatrix) ``` ```@docs -overlaps(::ComplexMat, ::ComplexMat) +overlaps(::ComplexMatrix, ::ComplexMatrix) ``` ```@docs -contains(::RealMat, ::RealMat) +contains(::RealMatrix, ::RealMatrix) ``` ```@docs -contains(::ComplexMat, ::ComplexMat) +contains(::ComplexMatrix, ::ComplexMatrix) ``` In addition we have the following ad hoc comparison operators. @@ -488,11 +488,11 @@ julia> B = exp(A) ### Norm ```@docs -bound_inf_norm(::RealMat) +bound_inf_norm(::RealMatrix) ``` ```@docs -bound_inf_norm(::ComplexMat) +bound_inf_norm(::ComplexMatrix) ``` **Examples** @@ -559,9 +559,9 @@ In case the matrix cannot be converted without loss, an `InexactError` is thrown ### Eigenvalues and Eigenvectors (experimental) ```@docs -eigenvalues(::ComplexMat) -eigenvalues_with_multiplicities(::ComplexMat) -eigenvalues_simple(a::ComplexMat) +eigenvalues(::ComplexMatrix) +eigenvalues_with_multiplicities(::ComplexMatrix) +eigenvalues_simple(a::ComplexMatrix) ``` ```jldoctest; setup = :(CC = ComplexField()) diff --git a/docs/src/polynomial.md b/docs/src/polynomial.md index 33a1f1ff9..13bfc1bb0 100644 --- a/docs/src/polynomial.md +++ b/docs/src/polynomial.md @@ -30,8 +30,8 @@ $\mathbb{Z}/p\mathbb{Z}$ (small prime $p$) | Flint | `fpPolyRingE $\mathbb{Z}/p\mathbb{Z}$ (large prime $p$) | Flint | `FpPolyRingElem` | `FpPolyRing` $\mathbb{F}_{p^n}$ (small $p$) | Flint | `fqPolyRepPolyRingElem` | `fqPolyRepPolyRing` $\mathbb{F}_{p^n}$ (large $p$) | Flint | `FqPolyRepPolyRingElem` | `FqPolyRepPolyRing` -$\mathbb{R}$ (arbitrary precision) | Arb | `RealPoly` | `RealPolyRing` -$\mathbb{C}$ (arbitrary precision) | Arb | `ComplexPoly` | `ComplexPolyRing` +$\mathbb{R}$ (arbitrary precision) | Arb | `RealPolyRingElem` | `RealPolyRing` +$\mathbb{C}$ (arbitrary precision) | Arb | `ComplexPolyRingElem` | `ComplexPolyRing` $\mathbb{R}$ (fixed precision) | Arb | `ArbPolyRingElem` | `ArbPolyRing` $\mathbb{C}$ (fixed precision) | Arb | `AcbPolyRingElem` | `AcbPolyRing` @@ -57,11 +57,11 @@ AbstractAlgebra.jl, for specific coefficient rings. ### Remove and valuation ```@docs -evaluate2(::RealPoly, ::RealFieldElem) +evaluate2(::RealPolyRingElem, ::RealFieldElem) ``` ```@docs -evaluate2(::ComplexPoly, ::ComplexFieldElem) +evaluate2(::ComplexPolyRingElem, ::ComplexFieldElem) ``` **Examples** @@ -90,7 +90,7 @@ signature(::QQPolyRingElem) ### Root finding ```@docs -roots(::ComplexPoly) +roots(::ComplexPolyRingElem) ``` **Examples** @@ -160,8 +160,8 @@ true ### Bounding absolute values of roots ```@docs -roots_upper_bound(::RealPoly) -roots_upper_bound(::ComplexPoly) +roots_upper_bound(::RealPolyRingElem) +roots_upper_bound(::ComplexPolyRingElem) ``` ### Lifting @@ -202,28 +202,28 @@ or contain other exact or inexact polynomials. The following functions are provided for this purpose. ```@docs -overlaps(::RealPoly, ::RealPoly) -overlaps(::ComplexPoly, ::ComplexPoly) +overlaps(::RealPolyRingElem, ::RealPolyRingElem) +overlaps(::ComplexPolyRingElem, ::ComplexPolyRingElem) ``` ```@docs -contains(::RealPoly, ::RealPoly) -contains(::ComplexPoly, ::ComplexPoly) +contains(::RealPolyRingElem, ::RealPolyRingElem) +contains(::ComplexPolyRingElem, ::ComplexPolyRingElem) ``` ```@docs -contains(::RealPoly, ::ZZPolyRingElem) -contains(::RealPoly, ::QQPolyRingElem) -contains(::ComplexPoly, ::ZZPolyRingElem) -contains(::ComplexPoly, ::QQPolyRingElem) +contains(::RealPolyRingElem, ::ZZPolyRingElem) +contains(::RealPolyRingElem, ::QQPolyRingElem) +contains(::ComplexPolyRingElem, ::ZZPolyRingElem) +contains(::ComplexPolyRingElem, ::QQPolyRingElem) ``` It is sometimes also useful to be able to determine if there is a unique integer contained in the coefficient of an inexact constant polynomial. ```@docs -unique_integer(::RealPoly) -unique_integer(::ComplexPoly) +unique_integer(::RealPolyRingElem) +unique_integer(::ComplexPolyRingElem) ``` **Examples** diff --git a/docs/src/types.md b/docs/src/types.md index 6431faf48..ce7d55bce 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -65,8 +65,8 @@ parent objects of the given rings and structures. - `AcbFieldElem` (`AcbField`) - `ArbPolyRingElem` (`ArbPolyRing`) - `AcbPolyRingElem` (`AcbPolyRing`) - - `ArbMatrix` (`ArbMatSpace`) - - `AcbMatrix` (`AcbMatSpace`) + - `ArbMatrix` (`ArbMatrixSpace`) + - `AcbMatrix` (`AcbMatrixSpace`) - Calcium diff --git a/src/Deprecations.jl b/src/Deprecations.jl index 8011bede5..0afce3271 100644 --- a/src/Deprecations.jl +++ b/src/Deprecations.jl @@ -7,7 +7,14 @@ # ALL aliases here are only a temporary measure to allow for a smooth transition downstream. # they will be replaced by deprecations eventually -#= currently none =# +@alias ComplexPoly ComplexPolyRingElem +@alias RealPoly RealPolyRingElem +@alias ComplexMat ComplexMatrix +@alias RealMat RealMatrix +@alias AcbMatSpace AcbMatrixSpace +@alias ComplexMatSpace ComplexMatrixSpace +@alias ArbMatSpace ArbMatrixSpace +@alias RealMatSpace RealMatrixSpace ############################################################################### # diff --git a/src/Exports.jl b/src/Exports.jl index 22f7359e7..a23f2112b 100644 --- a/src/Exports.jl +++ b/src/Exports.jl @@ -11,7 +11,7 @@ export AbsSimpleNumFieldElem export AcbField export AcbFieldElem export AcbMatrix -export AcbMatSpace +export AcbMatrixSpace export AcbPolyRing export AcbPolyRingElem export accuracy_bits @@ -34,7 +34,7 @@ export angle export ArbField export ArbFieldElem export ArbMatrix -export ArbMatSpace +export ArbMatrixSpace export ArbPolyRing export ArbPolyRingElem export Array @@ -87,10 +87,10 @@ export compare_index export complex_normal_form export ComplexField export ComplexFieldElem -export ComplexMat -export ComplexMatSpace -export ComplexPoly +export ComplexMatrix +export ComplexMatrixSpace export ComplexPolyRing +export ComplexPolyRingElem export compose export conj export conjugates @@ -525,10 +525,10 @@ export rational_field export real export RealField export RealFieldElem -export RealMat -export RealMatSpace -export RealPoly +export RealMatrix +export RealMatrixSpace export RealPolyRing +export RealPolyRingElem export reconstruct export reduce_mod export reduce_mod! diff --git a/src/arb/ArbTypes.jl b/src/arb/ArbTypes.jl index cbe3b2969..225292497 100644 --- a/src/arb/ArbTypes.jl +++ b/src/arb/ArbTypes.jl @@ -441,68 +441,68 @@ end const RealPolyRingID = CacheDictType{Tuple{Symbol}, RealPolyRing}() -mutable struct RealPoly <: PolyRingElem{RealFieldElem} +mutable struct RealPolyRingElem <: PolyRingElem{RealFieldElem} coeffs::Ptr{Nothing} length::Int alloc::Int parent::RealPolyRing - function RealPoly() + function RealPolyRingElem() z = new() - ccall((:arb_poly_init, libflint), Nothing, (Ref{RealPoly}, ), z) + ccall((:arb_poly_init, libflint), Nothing, (Ref{RealPolyRingElem}, ), z) finalizer(_RealPoly_clear_fn, z) return z end - function RealPoly(x::RealFieldElem, p::Int) - z = RealPoly() + function RealPolyRingElem(x::RealFieldElem, p::Int) + z = RealPolyRingElem() ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{RealPoly}, Int, Ref{RealFieldElem}), z, 0, x) + (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, 0, x) return z end - function RealPoly(x::Vector{RealFieldElem}, p::Int) - z = RealPoly() + function RealPolyRingElem(x::Vector{RealFieldElem}, p::Int) + z = RealPolyRingElem() for i = 1:length(x) ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{RealPoly}, Int, Ref{RealFieldElem}), z, i - 1, x[i]) + (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, i - 1, x[i]) end return z end - function RealPoly(x::RealPoly) - z = RealPoly() - ccall((:arb_poly_set, libflint), Nothing, (Ref{RealPoly}, Ref{RealPoly}), z, x) + function RealPolyRingElem(x::RealPolyRingElem) + z = RealPolyRingElem() + ccall((:arb_poly_set, libflint), Nothing, (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), z, x) return z end - function RealPoly(x::RealPoly, p::Int) - z = RealPoly() + function RealPolyRingElem(x::RealPolyRingElem, p::Int) + z = RealPolyRingElem() ccall((:arb_poly_set_round, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Int), z, x, p) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, p) return z end - function RealPoly(x::ZZPolyRingElem, p::Int) - z = RealPoly() + function RealPolyRingElem(x::ZZPolyRingElem, p::Int) + z = RealPolyRingElem() ccall((:arb_poly_set_fmpz_poly, libflint), Nothing, - (Ref{RealPoly}, Ref{ZZPolyRingElem}, Int), z, x, p) + (Ref{RealPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, p) return z end - function RealPoly(x::QQPolyRingElem, p::Int) - z = RealPoly() + function RealPolyRingElem(x::QQPolyRingElem, p::Int) + z = RealPolyRingElem() ccall((:arb_poly_set_fmpq_poly, libflint), Nothing, - (Ref{RealPoly}, Ref{QQPolyRingElem}, Int), z, x, p) + (Ref{RealPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, p) return z end end -function _RealPoly_clear_fn(x::RealPoly) - ccall((:arb_poly_clear, libflint), Nothing, (Ref{RealPoly}, ), x) +function _RealPoly_clear_fn(x::RealPolyRingElem) + ccall((:arb_poly_clear, libflint), Nothing, (Ref{RealPolyRingElem}, ), x) end -parent(x::RealPoly) = x.parent +parent(x::RealPolyRingElem) = x.parent var(x::RealPolyRing) = x.S @@ -610,77 +610,77 @@ end const ComplexPolyRingID = CacheDictType{Tuple{Symbol}, ComplexPolyRing}() -mutable struct ComplexPoly <: PolyRingElem{ComplexFieldElem} +mutable struct ComplexPolyRingElem <: PolyRingElem{ComplexFieldElem} coeffs::Ptr{Nothing} length::Int alloc::Int parent::ComplexPolyRing - function ComplexPoly() + function ComplexPolyRingElem() z = new() - ccall((:acb_poly_init, libflint), Nothing, (Ref{ComplexPoly}, ), z) + ccall((:acb_poly_init, libflint), Nothing, (Ref{ComplexPolyRingElem}, ), z) finalizer(_acb_poly_clear_fn, z) return z end - function ComplexPoly(x::ComplexFieldElem, p::Int) - z = ComplexPoly() + function ComplexPolyRingElem(x::ComplexFieldElem, p::Int) + z = ComplexPolyRingElem() ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{ComplexPoly}, Int, Ref{ComplexFieldElem}), z, 0, x) + (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, 0, x) return z end - function ComplexPoly(x::Vector{ComplexFieldElem}, p::Int) - z = ComplexPoly() + function ComplexPolyRingElem(x::Vector{ComplexFieldElem}, p::Int) + z = ComplexPolyRingElem() for i = 1:length(x) ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{ComplexPoly}, Int, Ref{ComplexFieldElem}), z, i - 1, x[i]) + (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, i - 1, x[i]) end return z end - function ComplexPoly(x::ComplexPoly) - z = ComplexPoly() - ccall((:acb_poly_set, libflint), Nothing, (Ref{ComplexPoly}, Ref{ComplexPoly}), z, x) + function ComplexPolyRingElem(x::ComplexPolyRingElem) + z = ComplexPolyRingElem() + ccall((:acb_poly_set, libflint), Nothing, (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), z, x) return z end - function ComplexPoly(x::RealPoly, p::Int) - z = ComplexPoly() + function ComplexPolyRingElem(x::RealPolyRingElem, p::Int) + z = ComplexPolyRingElem() ccall((:acb_poly_set_arb_poly, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ArbPolyRingElem}, Int), z, x, p) + (Ref{ComplexPolyRingElem}, Ref{ArbPolyRingElem}, Int), z, x, p) ccall((:acb_poly_set_round, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, z, p) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, z, p) return z end - function ComplexPoly(x::ComplexPoly, p::Int) - z = ComplexPoly() + function ComplexPolyRingElem(x::ComplexPolyRingElem, p::Int) + z = ComplexPolyRingElem() ccall((:acb_poly_set_round, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, x, p) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, p) return z end - function ComplexPoly(x::ZZPolyRingElem, p::Int) - z = ComplexPoly() + function ComplexPolyRingElem(x::ZZPolyRingElem, p::Int) + z = ComplexPolyRingElem() ccall((:acb_poly_set_fmpz_poly, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ZZPolyRingElem}, Int), z, x, p) + (Ref{ComplexPolyRingElem}, Ref{ZZPolyRingElem}, Int), z, x, p) return z end - function ComplexPoly(x::QQPolyRingElem, p::Int) - z = ComplexPoly() + function ComplexPolyRingElem(x::QQPolyRingElem, p::Int) + z = ComplexPolyRingElem() ccall((:acb_poly_set_fmpq_poly, libflint), Nothing, - (Ref{ComplexPoly}, Ref{QQPolyRingElem}, Int), z, x, p) + (Ref{ComplexPolyRingElem}, Ref{QQPolyRingElem}, Int), z, x, p) return z end end -function _acb_poly_clear_fn(x::ComplexPoly) - ccall((:acb_poly_clear, libflint), Nothing, (Ref{ComplexPoly}, ), x) +function _acb_poly_clear_fn(x::ComplexPolyRingElem) + ccall((:acb_poly_clear, libflint), Nothing, (Ref{ComplexPolyRingElem}, ), x) end -parent(x::ComplexPoly) = x.parent +parent(x::ComplexPolyRingElem) = x.parent var(x::ComplexPolyRing) = x.S @@ -783,42 +783,42 @@ base_ring(a::AcbPolyRing) = a.base_ring ################################################################################ # -# Types and memory management for ArbMatSpace +# Types and memory management for ArbMatrixSpace # ################################################################################ -const RealMatSpace = AbstractAlgebra.Generic.MatSpace{RealFieldElem} +const RealMatrixSpace = AbstractAlgebra.Generic.MatSpace{RealFieldElem} -mutable struct RealMat <: MatElem{RealFieldElem} +mutable struct RealMatrix <: MatElem{RealFieldElem} entries::Ptr{Nothing} r::Int c::Int rows::Ptr{Nothing} #base_ring::ArbField - function RealMat(r::Int, c::Int) + function RealMatrix(r::Int, c::Int) z = new() - ccall((:arb_mat_init, libflint), Nothing, (Ref{RealMat}, Int, Int), z, r, c) + ccall((:arb_mat_init, libflint), Nothing, (Ref{RealMatrix}, Int, Int), z, r, c) finalizer(_arb_mat_clear_fn, z) return z end - function RealMat(a::ZZMatrix) - z = RealMat(a.r, a.c) + function RealMatrix(a::ZZMatrix) + z = RealMatrix(a.r, a.c) ccall((:arb_mat_set_fmpz_mat, libflint), Nothing, - (Ref{RealMat}, Ref{ZZMatrix}), z, a) + (Ref{RealMatrix}, Ref{ZZMatrix}), z, a) return z end - function RealMat(a::ZZMatrix, prec::Int) - z = RealMat(a.r, a.c) + function RealMatrix(a::ZZMatrix, prec::Int) + z = RealMatrix(a.r, a.c) ccall((:arb_mat_set_round_fmpz_mat, libflint), Nothing, - (Ref{RealMat}, Ref{ZZMatrix}, Int), z, a, prec) + (Ref{RealMatrix}, Ref{ZZMatrix}, Int), z, a, prec) return z end - function RealMat(r::Int, c::Int, arr::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, Float64, BigFloat, RealFieldElem}} - z = RealMat(r, c) + function RealMatrix(r::Int, c::Int, arr::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, Float64, BigFloat, RealFieldElem}} + z = RealMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -828,8 +828,8 @@ mutable struct RealMat <: MatElem{RealFieldElem} return z end - function RealMat(r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, Float64, BigFloat, RealFieldElem}} - z = RealMat(r, c) + function RealMatrix(r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, Float64, BigFloat, RealFieldElem}} + z = RealMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -839,8 +839,8 @@ mutable struct RealMat <: MatElem{RealFieldElem} return z end - function RealMat(r::Int, c::Int, arr::AbstractMatrix{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} - z = RealMat(r, c) + function RealMatrix(r::Int, c::Int, arr::AbstractMatrix{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} + z = RealMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -850,8 +850,8 @@ mutable struct RealMat <: MatElem{RealFieldElem} return z end - function RealMat(r::Int, c::Int, arr::AbstractVector{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} - z = RealMat(r, c) + function RealMatrix(r::Int, c::Int, arr::AbstractVector{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} + z = RealMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -861,21 +861,21 @@ mutable struct RealMat <: MatElem{RealFieldElem} return z end - function RealMat(a::QQMatrix, prec::Int) - z = RealMat(a.r, a.c) + function RealMatrix(a::QQMatrix, prec::Int) + z = RealMatrix(a.r, a.c) ccall((:arb_mat_set_fmpq_mat, libflint), Nothing, - (Ref{RealMat}, Ref{QQMatrix}, Int), z, a, prec) + (Ref{RealMatrix}, Ref{QQMatrix}, Int), z, a, prec) return z end end -function _arb_mat_clear_fn(x::RealMat) - ccall((:arb_mat_clear, libflint), Nothing, (Ref{RealMat}, ), x) +function _arb_mat_clear_fn(x::RealMatrix) + ccall((:arb_mat_clear, libflint), Nothing, (Ref{RealMatrix}, ), x) end # fixed precision -const ArbMatSpace = AbstractAlgebra.Generic.MatSpace{ArbFieldElem} +const ArbMatrixSpace = AbstractAlgebra.Generic.MatSpace{ArbFieldElem} mutable struct ArbMatrix <: MatElem{ArbFieldElem} entries::Ptr{Nothing} @@ -963,56 +963,56 @@ end ################################################################################ # -# Types and memory management for AcbMatSpace +# Types and memory management for AcbMatrixSpace # ################################################################################ -const ComplexMatSpace = AbstractAlgebra.Generic.MatSpace{ComplexFieldElem} +const ComplexMatrixSpace = AbstractAlgebra.Generic.MatSpace{ComplexFieldElem} -mutable struct ComplexMat <: MatElem{ComplexFieldElem} +mutable struct ComplexMatrix <: MatElem{ComplexFieldElem} entries::Ptr{Nothing} r::Int c::Int rows::Ptr{Nothing} #base_ring::AcbField - function ComplexMat(r::Int, c::Int) + function ComplexMatrix(r::Int, c::Int) z = new() - ccall((:acb_mat_init, libflint), Nothing, (Ref{ComplexMat}, Int, Int), z, r, c) + ccall((:acb_mat_init, libflint), Nothing, (Ref{ComplexMatrix}, Int, Int), z, r, c) finalizer(_acb_mat_clear_fn, z) return z end - function ComplexMat(a::ZZMatrix) - z = ComplexMat(a.r, a.c) + function ComplexMatrix(a::ZZMatrix) + z = ComplexMatrix(a.r, a.c) ccall((:acb_mat_set_fmpz_mat, libflint), Nothing, - (Ref{ComplexMat}, Ref{ZZMatrix}), z, a) + (Ref{ComplexMatrix}, Ref{ZZMatrix}), z, a) return z end - function ComplexMat(a::ZZMatrix, prec::Int) - z = ComplexMat(a.r, a.c) + function ComplexMatrix(a::ZZMatrix, prec::Int) + z = ComplexMatrix(a.r, a.c) ccall((:acb_mat_set_round_fmpz_mat, libflint), Nothing, - (Ref{ComplexMat}, Ref{ZZMatrix}, Int), z, a, prec) + (Ref{ComplexMatrix}, Ref{ZZMatrix}, Int), z, a, prec) return z end - function ComplexMat(a::RealMat) - z = ComplexMat(a.r, a.c) + function ComplexMatrix(a::RealMatrix) + z = ComplexMatrix(a.r, a.c) ccall((:acb_mat_set_arb_mat, libflint), Nothing, - (Ref{ComplexMat}, Ref{ArbMatrix}), z, a) + (Ref{ComplexMatrix}, Ref{ArbMatrix}), z, a) return z end - function ComplexMat(a::ArbMatrix, prec::Int) - z = ComplexMat(a.r, a.c) + function ComplexMatrix(a::ArbMatrix, prec::Int) + z = ComplexMatrix(a.r, a.c) ccall((:acb_mat_set_round_arb_mat, libflint), Nothing, - (Ref{ComplexMat}, Ref{ArbMatrix}, Int), z, a, prec) + (Ref{ComplexMatrix}, Ref{ArbMatrix}, Int), z, a, prec) return z end - function ComplexMat(r::Int, c::Int, arr::AbstractMatrix{T}) where {T <: Union{Int, UInt, Float64, ZZRingElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractMatrix{T}) where {T <: Union{Int, UInt, Float64, ZZRingElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1022,8 +1022,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractMatrix{T}) where {T <: Union{BigFloat, ComplexFieldElem, RealFieldElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractMatrix{T}) where {T <: Union{BigFloat, ComplexFieldElem, RealFieldElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1033,8 +1033,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{Int, UInt, Float64, ZZRingElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{Int, UInt, Float64, ZZRingElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1044,8 +1044,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{BigFloat, ComplexFieldElem, RealFieldElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{BigFloat, ComplexFieldElem, RealFieldElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1055,8 +1055,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractMatrix{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractMatrix{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1066,8 +1066,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractMatrix{T}, prec::Int) where {T <: Union{BigFloat, RealFieldElem, AbstractString, ComplexFieldElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractMatrix{T}, prec::Int) where {T <: Union{BigFloat, RealFieldElem, AbstractString, ComplexFieldElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1077,8 +1077,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractVector{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractVector{T}, prec::Int) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1088,8 +1088,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractVector{T}, prec::Int) where {T <: Union{BigFloat, RealFieldElem, AbstractString, ComplexFieldElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractVector{T}, prec::Int) where {T <: Union{BigFloat, RealFieldElem, AbstractString, ComplexFieldElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1099,8 +1099,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractMatrix{Tuple{T, T}}, prec::Int) where {T <: Union{Int, UInt, Float64, ZZRingElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractMatrix{Tuple{T, T}}, prec::Int) where {T <: Union{Int, UInt, Float64, ZZRingElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1110,8 +1110,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractMatrix{Tuple{T, T}}, prec::Int) where {T <: Union{QQFieldElem, BigFloat, RealFieldElem, AbstractString}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractMatrix{Tuple{T, T}}, prec::Int) where {T <: Union{QQFieldElem, BigFloat, RealFieldElem, AbstractString}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1121,8 +1121,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractVector{Tuple{T, T}}, prec::Int) where {T <: Union{Int, UInt, Float64, ZZRingElem}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractVector{Tuple{T, T}}, prec::Int) where {T <: Union{Int, UInt, Float64, ZZRingElem}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1132,8 +1132,8 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(r::Int, c::Int, arr::AbstractVector{Tuple{T, T}}, prec::Int) where {T <: Union{QQFieldElem, BigFloat, RealFieldElem, AbstractString}} - z = ComplexMat(r, c) + function ComplexMatrix(r::Int, c::Int, arr::AbstractVector{Tuple{T, T}}, prec::Int) where {T <: Union{QQFieldElem, BigFloat, RealFieldElem, AbstractString}} + z = ComplexMatrix(r, c) GC.@preserve z for i = 1:r for j = 1:c el = mat_entry_ptr(z, i, j) @@ -1143,21 +1143,21 @@ mutable struct ComplexMat <: MatElem{ComplexFieldElem} return z end - function ComplexMat(a::QQMatrix, prec::Int) - z = ComplexMat(a.r, a.c) + function ComplexMatrix(a::QQMatrix, prec::Int) + z = ComplexMatrix(a.r, a.c) ccall((:acb_mat_set_fmpq_mat, libflint), Nothing, - (Ref{ComplexMat}, Ref{QQMatrix}, Int), z, a, prec) + (Ref{ComplexMatrix}, Ref{QQMatrix}, Int), z, a, prec) return z end end -function _acb_mat_clear_fn(x::ComplexMat) - ccall((:acb_mat_clear, libflint), Nothing, (Ref{ComplexMat}, ), x) +function _acb_mat_clear_fn(x::ComplexMatrix) + ccall((:acb_mat_clear, libflint), Nothing, (Ref{ComplexMatrix}, ), x) end # fixed precision -const AcbMatSpace = AbstractAlgebra.Generic.MatSpace{AcbFieldElem} +const AcbMatrixSpace = AbstractAlgebra.Generic.MatSpace{AcbFieldElem} mutable struct AcbMatrix <: MatElem{AcbFieldElem} entries::Ptr{Nothing} @@ -1357,12 +1357,12 @@ const ArbFieldElemOrPtr = Union{ArbFieldElem, Ref{ArbFieldElem}, Ptr{ArbFieldEle const ComplexFieldElemOrPtr = Union{ComplexFieldElem, Ref{ComplexFieldElem}, Ptr{ComplexFieldElem}} const AcbFieldElemOrPtr = Union{AcbFieldElem, Ref{AcbFieldElem}, Ptr{AcbFieldElem}} -const RealPolyOrPtr = Union{RealPoly, Ref{RealPoly}, Ptr{RealPoly}} +const RealPolyRingElemOrPtr = Union{RealPolyRingElem, Ref{RealPolyRingElem}, Ptr{RealPolyRingElem}} const ArbPolyRingElemOrPtr = Union{ArbPolyRingElem, Ref{ArbPolyRingElem}, Ptr{ArbPolyRingElem}} -const ComplexPolyOrPtr = Union{ComplexPoly, Ref{ComplexPoly}, Ptr{ComplexPoly}} +const ComplexPolyRingElemOrPtr = Union{ComplexPolyRingElem, Ref{ComplexPolyRingElem}, Ptr{ComplexPolyRingElem}} const AcbPolyRingElemOrPtr = Union{AcbPolyRingElem, Ref{AcbPolyRingElem}, Ptr{AcbPolyRingElem}} -const RealMatOrPtr = Union{RealMat, Ref{RealMat}, Ptr{RealMat}} +const RealMatrixOrPtr = Union{RealMatrix, Ref{RealMatrix}, Ptr{RealMatrix}} const ArbMatrixOrPtr = Union{ArbMatrix, Ref{ArbMatrix}, Ptr{ArbMatrix}} -const ComplexMatOrPtr = Union{ComplexMat, Ref{ComplexMat}, Ptr{ComplexMat}} +const ComplexMatrixOrPtr = Union{ComplexMatrix, Ref{ComplexMatrix}, Ptr{ComplexMatrix}} const AcbMatrixOrPtr = Union{AcbMatrix, Ref{AcbMatrix}, Ptr{AcbMatrix}} diff --git a/src/arb/ComplexMat.jl b/src/arb/ComplexMat.jl index 2070e5b7f..723436e58 100644 --- a/src/arb/ComplexMat.jl +++ b/src/arb/ComplexMat.jl @@ -10,12 +10,12 @@ # ############################################################################### -function similar(::ComplexMat, R::ComplexField, r::Int, c::Int) - z = ComplexMat(r, c) +function similar(::ComplexMatrix, R::ComplexField, r::Int, c::Int) + z = ComplexMatrix(r, c) return z end -zero(m::ComplexMat, R::ComplexField, r::Int, c::Int) = similar(m, R, r, c) +zero(m::ComplexMatrix, R::ComplexField, r::Int, c::Int) = similar(m, R, r, c) ############################################################################### # @@ -23,11 +23,11 @@ zero(m::ComplexMat, R::ComplexField, r::Int, c::Int) = similar(m, R, r, c) # ############################################################################### -base_ring(a::ComplexMat) = ComplexField() +base_ring(a::ComplexMatrix) = ComplexField() -dense_matrix_type(::Type{ComplexFieldElem}) = ComplexMat +dense_matrix_type(::Type{ComplexFieldElem}) = ComplexMatrix -function getindex!(z::ComplexFieldElem, x::ComplexMat, r::Int, c::Int) +function getindex!(z::ComplexFieldElem, x::ComplexMatrix, r::Int, c::Int) GC.@preserve x begin v = mat_entry_ptr(x, r, c) ccall((:acb_set, libflint), Nothing, (Ref{ComplexFieldElem}, Ptr{ComplexFieldElem}), z, v) @@ -35,7 +35,7 @@ function getindex!(z::ComplexFieldElem, x::ComplexMat, r::Int, c::Int) return z end -@inline function getindex(x::ComplexMat, r::Int, c::Int) +@inline function getindex(x::ComplexMatrix, r::Int, c::Int) @boundscheck _checkbounds(x, r, c) z = base_ring(x)() @@ -48,7 +48,7 @@ end for T in [Integer, Float64, ZZRingElem, QQFieldElem, RealFieldElem, BigFloat, ComplexFieldElem, AbstractString] @eval begin - @inline function setindex!(x::ComplexMat, y::$T, r::Int, c::Int) + @inline function setindex!(x::ComplexMatrix, y::$T, r::Int, c::Int) @boundscheck _checkbounds(x, r, c) GC.@preserve x begin @@ -59,13 +59,13 @@ for T in [Integer, Float64, ZZRingElem, QQFieldElem, RealFieldElem, BigFloat, Co end end -Base.@propagate_inbounds setindex!(x::ComplexMat, y::Rational{T}, +Base.@propagate_inbounds setindex!(x::ComplexMatrix, y::Rational{T}, r::Int, c::Int) where {T <: Integer} = setindex!(x, QQFieldElem(y), r, c) for T in [Integer, Float64, ZZRingElem, QQFieldElem, RealFieldElem, BigFloat, AbstractString] @eval begin - @inline function setindex!(x::ComplexMat, y::Tuple{$T, $T}, r::Int, c::Int) + @inline function setindex!(x::ComplexMatrix, y::Tuple{$T, $T}, r::Int, c::Int) @boundscheck _checkbounds(x, r, c) GC.@preserve x begin @@ -76,22 +76,22 @@ for T in [Integer, Float64, ZZRingElem, QQFieldElem, RealFieldElem, BigFloat, Ab end end -setindex!(x::ComplexMat, y::Tuple{Rational{T}, Rational{T}}, r::Int, c::Int) where {T <: Integer} = +setindex!(x::ComplexMatrix, y::Tuple{Rational{T}, Rational{T}}, r::Int, c::Int) where {T <: Integer} = setindex!(x, map(QQFieldElem, y), r, c) -function one(x::ComplexMatSpace) +function one(x::ComplexMatrixSpace) z = x() - ccall((:acb_mat_one, libflint), Nothing, (Ref{ComplexMat}, ), z) + ccall((:acb_mat_one, libflint), Nothing, (Ref{ComplexMatrix}, ), z) return z end -number_of_rows(a::ComplexMat) = a.r +number_of_rows(a::ComplexMatrix) = a.r -number_of_columns(a::ComplexMat) = a.c +number_of_columns(a::ComplexMatrix) = a.c -function deepcopy_internal(x::ComplexMat, dict::IdDict) +function deepcopy_internal(x::ComplexMatrix, dict::IdDict) z = similar(x) - ccall((:acb_mat_set, libflint), Nothing, (Ref{ComplexMat}, Ref{ComplexMat}), z, x) + ccall((:acb_mat_set, libflint), Nothing, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), z, x) return z end @@ -101,9 +101,9 @@ end # ################################################################################ -function -(x::ComplexMat) +function -(x::ComplexMatrix) z = similar(x) - ccall((:acb_mat_neg, libflint), Nothing, (Ref{ComplexMat}, Ref{ComplexMat}), z, x) + ccall((:acb_mat_neg, libflint), Nothing, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), z, x) return z end @@ -113,10 +113,10 @@ end # ################################################################################ -function transpose(x::ComplexMat) +function transpose(x::ComplexMatrix) z = similar(x, ncols(x), nrows(x)) ccall((:acb_mat_transpose, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}), z, x) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}), z, x) return z end @@ -126,29 +126,29 @@ end # ################################################################################ -function +(x::ComplexMat, y::ComplexMat) +function +(x::ComplexMatrix, y::ComplexMatrix) check_parent(x, y) z = similar(x) ccall((:acb_mat_add, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y, precision(Balls)) return z end -function -(x::ComplexMat, y::ComplexMat) +function -(x::ComplexMatrix, y::ComplexMatrix) check_parent(x, y) z = similar(x) ccall((:acb_mat_sub, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y, precision(Balls)) return z end -function *(x::ComplexMat, y::ComplexMat) +function *(x::ComplexMatrix, y::ComplexMatrix) ncols(x) != nrows(y) && error("Matrices have wrong dimensions") z = similar(x, nrows(x), ncols(y)) ccall((:acb_mat_mul, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y, precision(Balls)) return z end @@ -159,78 +159,78 @@ end # ################################################################################ -function ^(x::ComplexMat, y::UInt) +function ^(x::ComplexMatrix, y::UInt) nrows(x) != ncols(x) && error("Matrix must be square") z = similar(x) ccall((:acb_mat_pow_ui, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, UInt, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, UInt, Int), z, x, y, precision(Balls)) return z end -function *(x::ComplexMat, y::Int) +function *(x::ComplexMatrix, y::Int) z = similar(x) ccall((:acb_mat_scalar_mul_si, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Int, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int, Int), z, x, y, precision(Balls)) return z end -*(x::Int, y::ComplexMat) = y*x +*(x::Int, y::ComplexMatrix) = y*x -function *(x::ComplexMat, y::ZZRingElem) +function *(x::ComplexMatrix, y::ZZRingElem) z = similar(x) ccall((:acb_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ZZRingElem}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ZZRingElem}, Int), z, x, y, precision(Balls)) return z end -*(x::ZZRingElem, y::ComplexMat) = y*x +*(x::ZZRingElem, y::ComplexMatrix) = y*x -function *(x::ComplexMat, y::RealFieldElem) +function *(x::ComplexMatrix, y::RealFieldElem) z = similar(x) ccall((:acb_mat_scalar_mul_arb, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{RealFieldElem}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{RealFieldElem}, Int), z, x, y, precision(Balls)) return z end -*(x::RealFieldElem, y::ComplexMat) = y*x +*(x::RealFieldElem, y::ComplexMatrix) = y*x -function *(x::ComplexMat, y::ComplexFieldElem) +function *(x::ComplexMatrix, y::ComplexFieldElem) z = similar(x) ccall((:acb_mat_scalar_mul_acb, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexFieldElem}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexFieldElem}, Int), z, x, y, precision(Balls)) return z end -*(x::ComplexFieldElem, y::ComplexMat) = y*x +*(x::ComplexFieldElem, y::ComplexMatrix) = y*x -*(x::Integer, y::ComplexMat) = ZZRingElem(x) * y +*(x::Integer, y::ComplexMatrix) = ZZRingElem(x) * y -*(x::ComplexMat, y::Integer) = y * x +*(x::ComplexMatrix, y::Integer) = y * x -*(x::QQFieldElem, y::ComplexMat) = base_ring(y)(x) * y +*(x::QQFieldElem, y::ComplexMatrix) = base_ring(y)(x) * y -*(x::ComplexMat, y::QQFieldElem) = y * x +*(x::ComplexMatrix, y::QQFieldElem) = y * x -*(x::Float64, y::ComplexMat) = base_ring(y)(x) * y +*(x::Float64, y::ComplexMatrix) = base_ring(y)(x) * y -*(x::ComplexMat, y::Float64) = y * x +*(x::ComplexMatrix, y::Float64) = y * x -*(x::BigFloat, y::ComplexMat) = base_ring(y)(x) * y +*(x::BigFloat, y::ComplexMatrix) = base_ring(y)(x) * y -*(x::ComplexMat, y::BigFloat) = y * x +*(x::ComplexMatrix, y::BigFloat) = y * x -*(x::Rational{T}, y::ComplexMat) where T <: Union{Int, BigInt} = QQFieldElem(x) * y +*(x::Rational{T}, y::ComplexMatrix) where T <: Union{Int, BigInt} = QQFieldElem(x) * y -*(x::ComplexMat, y::Rational{T}) where T <: Union{Int, BigInt} = y * x +*(x::ComplexMatrix, y::Rational{T}) where T <: Union{Int, BigInt} = y * x for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem] @eval begin - function +(x::ComplexMat, y::$T) + function +(x::ComplexMatrix, y::$T) z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] += y @@ -238,9 +238,9 @@ for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem] return z end - +(x::$T, y::ComplexMat) = y + x + +(x::$T, y::ComplexMatrix) = y + x - function -(x::ComplexMat, y::$T) + function -(x::ComplexMatrix, y::$T) z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] -= y @@ -248,7 +248,7 @@ for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem] return z end - function -(x::$T, y::ComplexMat) + function -(x::$T, y::ComplexMatrix) z = -y for i = 1:min(nrows(y), ncols(y)) z[i, i] += x @@ -258,7 +258,7 @@ for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem] end end -function +(x::ComplexMat, y::Rational{T}) where T <: Union{Int, BigInt} +function +(x::ComplexMatrix, y::Rational{T}) where T <: Union{Int, BigInt} z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] += y @@ -266,9 +266,9 @@ function +(x::ComplexMat, y::Rational{T}) where T <: Union{Int, BigInt} return z end -+(x::Rational{T}, y::ComplexMat) where T <: Union{Int, BigInt} = y + x ++(x::Rational{T}, y::ComplexMatrix) where T <: Union{Int, BigInt} = y + x -function -(x::ComplexMat, y::Rational{T}) where T <: Union{Int, BigInt} +function -(x::ComplexMatrix, y::Rational{T}) where T <: Union{Int, BigInt} z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] -= y @@ -276,7 +276,7 @@ function -(x::ComplexMat, y::Rational{T}) where T <: Union{Int, BigInt} return z end -function -(x::Rational{T}, y::ComplexMat) where T <: Union{Int, BigInt} +function -(x::Rational{T}, y::ComplexMatrix) where T <: Union{Int, BigInt} z = -y for i = 1:min(nrows(y), ncols(y)) z[i, i] += x @@ -290,10 +290,10 @@ end # ############################################################################### -function ldexp(x::ComplexMat, y::Int) +function ldexp(x::ComplexMatrix, y::Int) z = similar(x) ccall((:acb_mat_scalar_mul_2exp_si, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Int), z, x, y) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y) return z end @@ -304,50 +304,50 @@ end ############################################################################### @doc raw""" - isequal(x::ComplexMat, y::ComplexMat) + isequal(x::ComplexMatrix, y::ComplexMatrix) Return `true` if the matrices of balls $x$ and $y$ are precisely equal, i.e. if all matrix entries have the same midpoints and radii. """ -function isequal(x::ComplexMat, y::ComplexMat) +function isequal(x::ComplexMatrix, y::ComplexMatrix) r = ccall((:acb_mat_equal, libflint), Cint, - (Ref{ComplexMat}, Ref{ComplexMat}), x, y) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) return Bool(r) end -function ==(x::ComplexMat, y::ComplexMat) +function ==(x::ComplexMatrix, y::ComplexMatrix) fl = check_parent(x, y, false) !fl && return false - r = ccall((:acb_mat_eq, libflint), Cint, (Ref{ComplexMat}, Ref{ComplexMat}), x, y) + r = ccall((:acb_mat_eq, libflint), Cint, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) return Bool(r) end -function !=(x::ComplexMat, y::ComplexMat) - r = ccall((:acb_mat_ne, libflint), Cint, (Ref{ComplexMat}, Ref{ComplexMat}), x, y) +function !=(x::ComplexMatrix, y::ComplexMatrix) + r = ccall((:acb_mat_ne, libflint), Cint, (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) return Bool(r) end @doc raw""" - overlaps(x::ComplexMat, y::ComplexMat) + overlaps(x::ComplexMatrix, y::ComplexMatrix) Returns `true` if all entries of $x$ overlap with the corresponding entry of $y$, otherwise return `false`. """ -function overlaps(x::ComplexMat, y::ComplexMat) +function overlaps(x::ComplexMatrix, y::ComplexMatrix) r = ccall((:acb_mat_overlaps, libflint), Cint, - (Ref{ComplexMat}, Ref{ComplexMat}), x, y) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) return Bool(r) end @doc raw""" - contains(x::ComplexMat, y::ComplexMat) + contains(x::ComplexMatrix, y::ComplexMatrix) Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ -function contains(x::ComplexMat, y::ComplexMat) +function contains(x::ComplexMatrix, y::ComplexMatrix) r = ccall((:acb_mat_contains, libflint), Cint, - (Ref{ComplexMat}, Ref{ComplexMat}), x, y) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}), x, y) return Bool(r) end @@ -358,36 +358,36 @@ end ################################################################################ @doc raw""" - contains(x::ComplexMat, y::ZZMatrix) + contains(x::ComplexMatrix, y::ZZMatrix) Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ -function contains(x::ComplexMat, y::ZZMatrix) +function contains(x::ComplexMatrix, y::ZZMatrix) r = ccall((:acb_mat_contains_fmpz_mat, libflint), Cint, - (Ref{ComplexMat}, Ref{ZZMatrix}), x, y) + (Ref{ComplexMatrix}, Ref{ZZMatrix}), x, y) return Bool(r) end @doc raw""" - contains(x::ComplexMat, y::QQMatrix) + contains(x::ComplexMatrix, y::QQMatrix) Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ -function contains(x::ComplexMat, y::QQMatrix) +function contains(x::ComplexMatrix, y::QQMatrix) r = ccall((:acb_mat_contains_fmpq_mat, libflint), Cint, - (Ref{ComplexMat}, Ref{QQMatrix}), x, y) + (Ref{ComplexMatrix}, Ref{QQMatrix}), x, y) return Bool(r) end -==(x::ComplexMat, y::ZZMatrix) = x == parent(x)(y) +==(x::ComplexMatrix, y::ZZMatrix) = x == parent(x)(y) -==(x::ZZMatrix, y::ComplexMat) = y == x +==(x::ZZMatrix, y::ComplexMatrix) = y == x -==(x::ComplexMat, y::RealMat) = x == parent(x)(y) +==(x::ComplexMatrix, y::RealMatrix) = x == parent(x)(y) -==(x::RealMat, y::ComplexMat) = y == x +==(x::RealMatrix, y::ComplexMatrix) = y == x ################################################################################ # @@ -395,8 +395,8 @@ end # ################################################################################ -isreal(x::ComplexMat) = -Bool(ccall((:acb_mat_is_real, libflint), Cint, (Ref{ComplexMat}, ), x)) +isreal(x::ComplexMatrix) = +Bool(ccall((:acb_mat_is_real, libflint), Cint, (Ref{ComplexMatrix}, ), x)) ############################################################################### # @@ -405,23 +405,23 @@ Bool(ccall((:acb_mat_is_real, libflint), Cint, (Ref{ComplexMat}, ), x)) ############################################################################### @doc raw""" - inv(x::ComplexMat) + inv(x::ComplexMatrix) Given a $n\times n$ matrix of type `AcbMatrix`, return an $n\times n$ matrix $X$ such that $AX$ contains the identity matrix. If $A$ cannot be inverted numerically an exception is raised. """ -function inv(x::ComplexMat) +function inv(x::ComplexMatrix) fl, z = is_invertible_with_inverse(x) fl && return z error("Matrix singular or cannot be inverted numerically") end -function is_invertible_with_inverse(x::ComplexMat) +function is_invertible_with_inverse(x::ComplexMatrix) ncols(x) != nrows(x) && return false, x z = similar(x) r = ccall((:acb_mat_inv, libflint), Cint, - (Ref{ComplexMat}, Ref{ComplexMat}, Int), z, x, precision(Balls)) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, precision(Balls)) return Bool(r), z end @@ -431,7 +431,7 @@ end # ############################################################################### -function divexact(x::ComplexMat, y::ComplexMat; check::Bool=true) +function divexact(x::ComplexMatrix, y::ComplexMatrix; check::Bool=true) ncols(x) != ncols(y) && error("Incompatible matrix dimensions") x*inv(y) end @@ -442,46 +442,46 @@ end # ############################################################################### -function divexact(x::ComplexMat, y::Int; check::Bool=true) +function divexact(x::ComplexMatrix, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = similar(x) ccall((:acb_mat_scalar_div_si, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Int, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int, Int), z, x, y, precision(Balls)) return z end -function divexact(x::ComplexMat, y::ZZRingElem; check::Bool=true) +function divexact(x::ComplexMatrix, y::ZZRingElem; check::Bool=true) z = similar(x) ccall((:acb_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ZZRingElem}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ZZRingElem}, Int), z, x, y, precision(Balls)) return z end -function divexact(x::ComplexMat, y::RealFieldElem; check::Bool=true) +function divexact(x::ComplexMatrix, y::RealFieldElem; check::Bool=true) z = similar(x) ccall((:acb_mat_scalar_div_arb, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{RealFieldElem}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{RealFieldElem}, Int), z, x, y, precision(Balls)) return z end -function divexact(x::ComplexMat, y::ComplexFieldElem; check::Bool=true) +function divexact(x::ComplexMatrix, y::ComplexFieldElem; check::Bool=true) z = similar(x) ccall((:acb_mat_scalar_div_acb, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexFieldElem}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexFieldElem}, Int), z, x, y, precision(Balls)) return z end -divexact(x::ComplexMat, y::Float64; check::Bool=true) = divexact(x, base_ring(x)(y); check=check) +divexact(x::ComplexMatrix, y::Float64; check::Bool=true) = divexact(x, base_ring(x)(y); check=check) -divexact(x::ComplexMat, y::BigFloat; check::Bool=true) = divexact(x, base_ring(x)(y); check=check) +divexact(x::ComplexMatrix, y::BigFloat; check::Bool=true) = divexact(x, base_ring(x)(y); check=check) -divexact(x::ComplexMat, y::Integer; check::Bool=true) = divexact(x, ZZRingElem(y); check=check) +divexact(x::ComplexMatrix, y::Integer; check::Bool=true) = divexact(x, ZZRingElem(y); check=check) -divexact(x::ComplexMat, y::Rational{T}; check::Bool=true) where T <: Union{Int, BigInt} = divexact(x, QQFieldElem(y); check=check) +divexact(x::ComplexMatrix, y::Rational{T}; check::Bool=true) where T <: Union{Int, BigInt} = divexact(x, QQFieldElem(y); check=check) ################################################################################ # @@ -489,11 +489,11 @@ divexact(x::ComplexMat, y::Rational{T}; check::Bool=true) where T <: Union{Int, # ################################################################################ -function charpoly(x::AcbPolyRing, y::ComplexMat, prec::Int = precision(Balls)) +function charpoly(x::AcbPolyRing, y::ComplexMatrix, prec::Int = precision(Balls)) base_ring(x) != base_ring(y) && error("Base rings must coincide") z = x() ccall((:acb_mat_charpoly, libflint), Nothing, - (Ref{AcbPolyRingElem}, Ref{ComplexMat}, Int), z, y, prec) + (Ref{AcbPolyRingElem}, Ref{ComplexMatrix}, Int), z, y, prec) return z end @@ -503,11 +503,11 @@ end # ################################################################################ -function det(x::ComplexMat, prec::Int = precision(Balls)) +function det(x::ComplexMatrix, prec::Int = precision(Balls)) ncols(x) != nrows(x) && error("Matrix must be square") z = base_ring(x)() ccall((:acb_mat_det, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexMat}, Int), z, x, prec) + (Ref{ComplexFieldElem}, Ref{ComplexMatrix}, Int), z, x, prec) return z end @@ -517,11 +517,11 @@ end # ################################################################################ -function Base.exp(x::ComplexMat) +function Base.exp(x::ComplexMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x) ccall((:acb_mat_exp, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Int), z, x, precision(Balls)) + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, precision(Balls)) return z end @@ -531,10 +531,10 @@ end # ############################################################################### -function lu!(P::Perm, x::ComplexMat) +function lu!(P::Perm, x::ComplexMatrix) P.d .-= 1 r = ccall((:acb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), P.d, x, x, precision(Balls)) r == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 @@ -542,30 +542,30 @@ function lu!(P::Perm, x::ComplexMat) return min(nrows(x), ncols(x)) end -function _solve!(z::ComplexMat, x::ComplexMat, y::ComplexMat) +function _solve!(z::ComplexMatrix, x::ComplexMatrix, y::ComplexMatrix) r = ccall((:acb_mat_solve, libflint), Cint, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y, precision(Balls)) r == 0 && error("Matrix cannot be inverted numerically") nothing end -function _solve_lu_precomp!(z::ComplexMat, P::Perm, LU::ComplexMat, y::ComplexMat) +function _solve_lu_precomp!(z::ComplexMatrix, P::Perm, LU::ComplexMatrix, y::ComplexMatrix) Q = inv(P) ccall((:acb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{ComplexMat}, Ptr{Int}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, Q.d .- 1, LU, y, precision(Balls)) nothing end -function _solve_lu_precomp(P::Perm, LU::ComplexMat, y::ComplexMat) +function _solve_lu_precomp(P::Perm, LU::ComplexMatrix, y::ComplexMatrix) ncols(LU) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) _solve_lu_precomp!(z, P, LU, y) return z end -function Solve._can_solve_internal_no_check(A::ComplexMat, b::ComplexMat, task::Symbol; side::Symbol = :left) +function Solve._can_solve_internal_no_check(A::ComplexMatrix, b::ComplexMatrix, task::Symbol; side::Symbol = :left) nrows(A) != ncols(A) && error("Only implemented for square matrices") if side === :left fl, sol, K = Solve._can_solve_internal_no_check(transpose(A), transpose(b), task, side = :right) @@ -574,7 +574,7 @@ function Solve._can_solve_internal_no_check(A::ComplexMat, b::ComplexMat, task:: x = similar(A, ncols(A), ncols(b)) fl = ccall((:acb_mat_solve, libflint), Cint, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), x, A, b, precision(Balls)) fl == 0 && error("Matrix cannot be inverted numerically") if task === :only_check || task === :with_solution @@ -590,7 +590,7 @@ end # ################################################################################ -AbstractAlgebra.solve_context_type(::Type{ComplexFieldElem}) = Solve.SolveCtx{ComplexFieldElem, ComplexMat, ComplexMat, ComplexMat} +AbstractAlgebra.solve_context_type(::Type{ComplexFieldElem}) = Solve.SolveCtx{ComplexFieldElem, ComplexMatrix, ComplexMatrix, ComplexMatrix} function Solve._init_reduce(C::Solve.SolveCtx{ComplexFieldElem}) if isdefined(C, :red) && isdefined(C, :lu_perm) @@ -604,7 +604,7 @@ function Solve._init_reduce(C::Solve.SolveCtx{ComplexFieldElem}) x = similar(A, nrows(A), ncols(A)) P.d .-= 1 fl = ccall((:acb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), P.d, x, A, precision(Balls)) fl == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 @@ -627,7 +627,7 @@ function Solve._init_reduce_transpose(C::Solve.SolveCtx{ComplexFieldElem}) x = similar(A, nrows(A), ncols(A)) P.d .-= 1 fl = ccall((:acb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), P.d, x, A, precision(Balls)) fl == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 @@ -638,7 +638,7 @@ function Solve._init_reduce_transpose(C::Solve.SolveCtx{ComplexFieldElem}) return nothing end -function Solve._can_solve_internal_no_check(C::Solve.SolveCtx{ComplexFieldElem}, b::ComplexMat, task::Symbol; side::Symbol = :left) +function Solve._can_solve_internal_no_check(C::Solve.SolveCtx{ComplexFieldElem}, b::ComplexMatrix, task::Symbol; side::Symbol = :left) if side === :right LU = Solve.reduced_matrix(C) p = Solve.lu_permutation(C) @@ -650,7 +650,7 @@ function Solve._can_solve_internal_no_check(C::Solve.SolveCtx{ComplexFieldElem}, x = similar(b, ncols(C), ncols(b)) ccall((:acb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{ComplexMat}, Ptr{Int}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ptr{Int}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), x, inv(p).d .- 1, LU, b, precision(Balls)) if side === :left @@ -674,7 +674,7 @@ end # ################################################################################ -function swap_rows(x::ComplexMat, i::Int, j::Int) +function swap_rows(x::ComplexMatrix, i::Int, j::Int) _checkbounds(nrows(x), i) || throw(BoundsError()) _checkbounds(nrows(x), j) || throw(BoundsError()) z = deepcopy(x) @@ -682,9 +682,9 @@ function swap_rows(x::ComplexMat, i::Int, j::Int) return z end -function swap_rows!(x::ComplexMat, i::Int, j::Int) +function swap_rows!(x::ComplexMatrix, i::Int, j::Int) ccall((:acb_mat_swap_rows, libflint), Nothing, - (Ref{ComplexMat}, Ptr{Nothing}, Int, Int), + (Ref{ComplexMatrix}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) end @@ -695,17 +695,17 @@ end ################################################################################ @doc raw""" - bound_inf_norm(x::ComplexMat) + bound_inf_norm(x::ComplexMatrix) Returns a non-negative element $z$ of type `AcbFieldElem`, such that $z$ is an upper bound for the infinity norm for every matrix in $x$ """ -function bound_inf_norm(x::ComplexMat) +function bound_inf_norm(x::ComplexMatrix) z = RealFieldElem() GC.@preserve x z begin t = ccall((:arb_rad_ptr, libflint), Ptr{mag_struct}, (Ref{RealFieldElem}, ), z) ccall((:acb_mat_bound_inf_norm, libflint), Nothing, - (Ptr{mag_struct}, Ref{ComplexMat}), t, x) + (Ptr{mag_struct}, Ref{ComplexMatrix}), t, x) s = ccall((:arb_mid_ptr, libflint), Ptr{arf_struct}, (Ref{RealFieldElem}, ), z) ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) @@ -724,9 +724,9 @@ end for (s,f) in (("add!","acb_mat_add"), ("mul!","acb_mat_mul"), ("sub!","acb_mat_sub")) @eval begin - function ($(Symbol(s)))(z::ComplexMat, x::ComplexMat, y::ComplexMat, prec::Int = precision(Balls)) + function ($(Symbol(s)))(z::ComplexMatrix, x::ComplexMatrix, y::ComplexMatrix, prec::Int = precision(Balls)) ccall(($f, libflint), Nothing, - (Ref{ComplexMat}, Ref{ComplexMat}, Ref{ComplexMat}, Int), + (Ref{ComplexMatrix}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, Int), z, x, y, prec) return z end @@ -739,80 +739,80 @@ end # ############################################################################### -function (x::ComplexMatSpace)() - z = ComplexMat(nrows(x), ncols(x)) +function (x::ComplexMatrixSpace)() + z = ComplexMatrix(nrows(x), ncols(x)) return z end -function (x::ComplexMatSpace)(y::ZZMatrix) +function (x::ComplexMatrixSpace)(y::ZZMatrix) (ncols(x) != ncols(y) || nrows(x) != nrows(y)) && error("Dimensions are wrong") - z = ComplexMat(y, precision(Balls)) + z = ComplexMatrix(y, precision(Balls)) return z end -function (x::ComplexMatSpace)(y::RealMat) +function (x::ComplexMatrixSpace)(y::RealMatrix) (ncols(x) != ncols(y) || nrows(x) != nrows(y)) && error("Dimensions are wrong") - z = ComplexMat(y, precision(Balls)) + z = ComplexMatrix(y, precision(Balls)) return z end for T in [Float64, ZZRingElem, QQFieldElem, BigFloat, RealFieldElem, ComplexFieldElem, String] @eval begin - function (x::ComplexMatSpace)(y::AbstractMatrix{$T}) + function (x::ComplexMatrixSpace)(y::AbstractMatrix{$T}) _check_dim(nrows(x), ncols(x), y) - z = ComplexMat(nrows(x), ncols(x), y, precision(Balls)) + z = ComplexMatrix(nrows(x), ncols(x), y, precision(Balls)) return z end - function (x::ComplexMatSpace)(y::AbstractVector{$T}) + function (x::ComplexMatrixSpace)(y::AbstractVector{$T}) _check_dim(nrows(x), ncols(x), y) - z = ComplexMat(nrows(x), ncols(x), y, precision(Balls)) + z = ComplexMatrix(nrows(x), ncols(x), y, precision(Balls)) return z end end end -(x::ComplexMatSpace)(y::AbstractMatrix{T}) where {T <: Integer} = x(map(ZZRingElem, y)) +(x::ComplexMatrixSpace)(y::AbstractMatrix{T}) where {T <: Integer} = x(map(ZZRingElem, y)) -(x::ComplexMatSpace)(y::AbstractVector{T}) where {T <: Integer} = x(map(ZZRingElem, y)) +(x::ComplexMatrixSpace)(y::AbstractVector{T}) where {T <: Integer} = x(map(ZZRingElem, y)) -(x::ComplexMatSpace)(y::AbstractMatrix{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) +(x::ComplexMatrixSpace)(y::AbstractMatrix{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) -(x::ComplexMatSpace)(y::AbstractVector{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) +(x::ComplexMatrixSpace)(y::AbstractVector{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) for T in [Float64, ZZRingElem, QQFieldElem, BigFloat, RealFieldElem, String] @eval begin - function (x::ComplexMatSpace)(y::AbstractMatrix{Tuple{$T, $T}}) + function (x::ComplexMatrixSpace)(y::AbstractMatrix{Tuple{$T, $T}}) _check_dim(nrows(x), ncols(x), y) - z = ComplexMat(nrows(x), ncols(x), y, precision(Balls)) + z = ComplexMatrix(nrows(x), ncols(x), y, precision(Balls)) return z end - function (x::ComplexMatSpace)(y::AbstractVector{Tuple{$T, $T}}) + function (x::ComplexMatrixSpace)(y::AbstractVector{Tuple{$T, $T}}) _check_dim(nrows(x), ncols(x), y) - z = ComplexMat(nrows(x), ncols(x), y, precision(Balls)) + z = ComplexMatrix(nrows(x), ncols(x), y, precision(Balls)) return z end end end -(x::ComplexMatSpace)(y::AbstractMatrix{Tuple{T, T}}) where {T <: Integer} = +(x::ComplexMatrixSpace)(y::AbstractMatrix{Tuple{T, T}}) where {T <: Integer} = x(map(z -> (ZZRingElem(z[1]), ZZRingElem(z[2])), y)) -(x::ComplexMatSpace)(y::AbstractVector{Tuple{T, T}}) where {T <: Integer} = +(x::ComplexMatrixSpace)(y::AbstractVector{Tuple{T, T}}) where {T <: Integer} = x(map(z -> (ZZRingElem(z[1]), ZZRingElem(z[2])), y)) -(x::ComplexMatSpace)(y::AbstractMatrix{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = +(x::ComplexMatrixSpace)(y::AbstractMatrix{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = x(map(z -> (QQFieldElem(z[1]), QQFieldElem(z[2])), y)) -(x::ComplexMatSpace)(y::AbstractVector{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = +(x::ComplexMatrixSpace)(y::AbstractVector{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = x(map(z -> (QQFieldElem(z[1]), QQFieldElem(z[2])), y)) for T in [Integer, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, ComplexFieldElem, String] @eval begin - function (x::ComplexMatSpace)(y::$T) + function (x::ComplexMatrixSpace)(y::$T) z = x() for i in 1:nrows(z) for j = 1:ncols(z) @@ -828,7 +828,7 @@ for T in [Integer, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, Co end end -(x::ComplexMatSpace)(y::Rational{T}) where {T <: Integer} = x(QQFieldElem(y)) +(x::ComplexMatrixSpace)(y::Rational{T}) where {T <: Integer} = x(QQFieldElem(y)) ############################################################################### # @@ -837,13 +837,13 @@ end ############################################################################### function matrix(R::ComplexField, arr::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, ComplexFieldElem, AbstractString}} - z = ComplexMat(size(arr, 1), size(arr, 2), arr, precision(Balls)) + z = ComplexMatrix(size(arr, 1), size(arr, 2), arr, precision(Balls)) return z end function matrix(R::ComplexField, r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, ComplexFieldElem, AbstractString}} _check_dim(r, c, arr) - z = ComplexMat(r, c, arr, precision(Balls)) + z = ComplexMatrix(r, c, arr, precision(Balls)) return z end @@ -877,7 +877,7 @@ function zero_matrix(R::ComplexField, r::Int, c::Int) if r < 0 || c < 0 error("dimensions must not be negative") end - z = ComplexMat(r, c) + z = ComplexMatrix(r, c) return z end @@ -891,8 +891,8 @@ function identity_matrix(R::ComplexField, n::Int) if n < 0 error("dimension must not be negative") end - z = ComplexMat(n, n) - ccall((:acb_mat_one, libflint), Nothing, (Ref{ComplexMat}, ), z) + z = ComplexMatrix(n, n) + ccall((:acb_mat_one, libflint), Nothing, (Ref{ComplexMatrix}, ), z) return z end @@ -902,9 +902,9 @@ end # ################################################################################ -@inline mat_entry_ptr(A::ComplexMat, i::Int, j::Int) = +@inline mat_entry_ptr(A::ComplexMatrix, i::Int, j::Int) = ccall((:acb_mat_entry_ptr, libflint), - Ptr{ComplexFieldElem}, (Ref{ComplexMat}, Int, Int), A, i-1, j-1) + Ptr{ComplexFieldElem}, (Ref{ComplexMatrix}, Int, Int), A, i-1, j-1) @@ -914,23 +914,23 @@ ccall((:acb_mat_entry_ptr, libflint), # ############################################################################### -promote_rule(::Type{ComplexMat}, ::Type{T}) where {T <: Integer} = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{T}) where {T <: Integer} = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{Rational{T}}) where T <: Union{Int, BigInt} = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{Rational{T}}) where T <: Union{Int, BigInt} = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{ZZRingElem}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{ZZRingElem}) = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{QQFieldElem}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{QQFieldElem}) = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{ArbFieldElem}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{ArbFieldElem}) = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{ComplexFieldElem}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{ComplexFieldElem}) = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{ZZMatrix}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{ZZMatrix}) = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{QQMatrix}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{QQMatrix}) = ComplexMatrix -promote_rule(::Type{ComplexMat}, ::Type{ArbMatrix}) = ComplexMat +promote_rule(::Type{ComplexMatrix}, ::Type{ArbMatrix}) = ComplexMatrix ############################################################################### # @@ -938,16 +938,16 @@ promote_rule(::Type{ComplexMat}, ::Type{ArbMatrix}) = ComplexMat # ############################################################################### -function __approx_eig_qr!(v::Ptr{acb_struct}, R::ComplexMat, A::ComplexMat) +function __approx_eig_qr!(v::Ptr{acb_struct}, R::ComplexMatrix, A::ComplexMatrix) n = nrows(A) ccall((:acb_mat_approx_eig_qr, libflint), Cint, - (Ptr{acb_struct}, Ptr{Nothing}, Ref{ComplexMat}, - Ref{ComplexMat}, Ptr{Nothing}, Int, Int), + (Ptr{acb_struct}, Ptr{Nothing}, Ref{ComplexMatrix}, + Ref{ComplexMatrix}, Ptr{Nothing}, Int, Int), v, C_NULL, R, A, C_NULL, 0, precision(Balls)) return nothing end -function _approx_eig_qr(A::ComplexMat) +function _approx_eig_qr(A::ComplexMatrix) n = nrows(A) v = acb_vec(n) R = zero_matrix(base_ring(A), ncols(A), nrows(A)) @@ -957,14 +957,14 @@ function _approx_eig_qr(A::ComplexMat) return z, R end -function _eig_multiple(A::ComplexMat, check::Bool = true) +function _eig_multiple(A::ComplexMatrix, check::Bool = true) n = nrows(A) v = acb_vec(n) v_approx = acb_vec(n) R = zero_matrix(base_ring(A), n, n) __approx_eig_qr!(v, R, A) b = ccall((:acb_mat_eig_multiple, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMat}, Ptr{acb_struct}, Ref{ComplexMat}, Int), + (Ptr{acb_struct}, Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), v_approx, A, v, R, precision(Balls)) check && b == 0 && error("Could not isolate eigenvalues of matrix $A") z = array(base_ring(A), v, n) @@ -988,7 +988,7 @@ function _eig_multiple(A::ComplexMat, check::Bool = true) return res, R end -function _eig_simple(A::ComplexMat; check::Bool = true, algorithm::Symbol = :default) +function _eig_simple(A::ComplexMatrix; check::Bool = true, algorithm::Symbol = :default) n = nrows(A) v = acb_vec(n) v_approx = acb_vec(n) @@ -998,18 +998,18 @@ function _eig_simple(A::ComplexMat; check::Bool = true, algorithm::Symbol = :def __approx_eig_qr!(v, Rapprox, A) if algorithm == :vdhoeven_mourrain b = ccall((:acb_mat_eig_simple_vdhoeven_mourrain, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMat}, Ref{ComplexMat}, - Ref{ComplexMat}, Ptr{acb_struct}, Ref{ComplexMat}, Int), + (Ptr{acb_struct}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, + Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), v_approx, L, R, A, v, Rapprox, precision(Balls)) elseif algorithm == :rump b = ccall((:acb_mat_eig_simple_rump, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMat}, Ref{ComplexMat}, - Ref{ComplexMat}, Ptr{acb_struct}, Ref{ComplexMat}, Int), + (Ptr{acb_struct}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, + Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), v_approx, L, R, A, v, Rapprox, precision(Balls)) elseif algorithm == :default b = ccall((:acb_mat_eig_simple, libflint), Cint, - (Ptr{acb_struct}, Ref{ComplexMat}, Ref{ComplexMat}, - Ref{ComplexMat}, Ptr{acb_struct}, Ref{ComplexMat}, Int), + (Ptr{acb_struct}, Ref{ComplexMatrix}, Ref{ComplexMatrix}, + Ref{ComplexMatrix}, Ptr{acb_struct}, Ref{ComplexMatrix}, Int), v_approx, L, R, A, v, Rapprox, precision(Balls)) else error("Algorithm $algorithm not supported") @@ -1030,7 +1030,7 @@ function _eig_simple(A::ComplexMat; check::Bool = true, algorithm::Symbol = :def end @doc raw""" - eigenvalues_simple(A::ComplexMat, algorithm::Symbol = :default) + eigenvalues_simple(A::ComplexMatrix, algorithm::Symbol = :default) Returns the eigenvalues of `A` as a vector of `AcbFieldElem`. It is assumed that `A` has only simple eigenvalues. @@ -1040,13 +1040,13 @@ The algorithm used can be changed by setting the `algorithm` keyword to This function is experimental. """ -function eigenvalues_simple(A::ComplexMat, algorithm::Symbol = :default) +function eigenvalues_simple(A::ComplexMatrix, algorithm::Symbol = :default) E, _, _ = _eig_simple(A, algorithm = algorithm) return E end @doc raw""" - eigenvalues_with_multiplicities(A::ComplexMat) + eigenvalues_with_multiplicities(A::ComplexMatrix) Return the eigenvalues of `A` with their algebraic multiplicities as a vector of tuples `(ComplexFieldElem, Int)`. Each tuple `(z, k)` corresponds to a cluster @@ -1054,19 +1054,19 @@ of `k` eigenvalues of $A$. This function is experimental. """ -function eigenvalues_with_multiplicities(A::ComplexMat) +function eigenvalues_with_multiplicities(A::ComplexMatrix) e, _ = _eig_multiple(A) return e end @doc raw""" - eigenvalues(A::ComplexMat) + eigenvalues(A::ComplexMatrix) Return the eigenvalues of `A`. This function is experimental. """ -function eigenvalues(A::ComplexMat) +function eigenvalues(A::ComplexMatrix) e, _ = _eig_multiple(A) return [ x[1] for x in e ] end diff --git a/src/arb/ComplexPoly.jl b/src/arb/ComplexPoly.jl index 72e6b09cb..214223982 100644 --- a/src/arb/ComplexPoly.jl +++ b/src/arb/ComplexPoly.jl @@ -10,28 +10,28 @@ # ############################################################################### -parent_type(::Type{ComplexPoly}) = ComplexPolyRing +parent_type(::Type{ComplexPolyRingElem}) = ComplexPolyRing -elem_type(::Type{ComplexPolyRing}) = ComplexPoly +elem_type(::Type{ComplexPolyRing}) = ComplexPolyRingElem -dense_poly_type(::Type{ComplexFieldElem}) = ComplexPoly +dense_poly_type(::Type{ComplexFieldElem}) = ComplexPolyRingElem -length(x::ComplexPoly) = ccall((:acb_poly_length, libflint), Int, - (Ref{ComplexPoly},), x) +length(x::ComplexPolyRingElem) = ccall((:acb_poly_length, libflint), Int, + (Ref{ComplexPolyRingElem},), x) -function set_length!(x::ComplexPoly, n::Int) +function set_length!(x::ComplexPolyRingElem, n::Int) ccall((:_acb_poly_set_length, libflint), Nothing, - (Ref{ComplexPoly}, Int), x, n) + (Ref{ComplexPolyRingElem}, Int), x, n) return x end -degree(x::ComplexPoly) = length(x) - 1 +degree(x::ComplexPolyRingElem) = length(x) - 1 -function coeff(a::ComplexPoly, n::Int) +function coeff(a::ComplexPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) t = ComplexFieldElem() ccall((:acb_poly_get_coeff_acb, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexPoly}, Int), t, a, n) + (Ref{ComplexFieldElem}, Ref{ComplexPolyRingElem}, Int), t, a, n) return t end @@ -40,28 +40,28 @@ zero(a::ComplexPolyRing) = a(0) one(a::ComplexPolyRing) = a(1) function gen(a::ComplexPolyRing) - z = ComplexPoly() + z = ComplexPolyRingElem() ccall((:acb_poly_set_coeff_si, libflint), Nothing, - (Ref{ComplexPoly}, Int, Int), z, 1, 1) + (Ref{ComplexPolyRingElem}, Int, Int), z, 1, 1) z.parent = a return z end # todo: write a C function for this -function is_gen(a::ComplexPoly) +function is_gen(a::ComplexPolyRingElem) return isequal(a, gen(parent(a))) end -#function iszero(a::ComplexPoly) +#function iszero(a::ComplexPolyRingElem) # return length(a) == 0 #end -#function isone(a::ComplexPoly) +#function isone(a::ComplexPolyRingElem) # return isequal(a, one(parent(a))) #end -function deepcopy_internal(a::ComplexPoly, dict::IdDict) - z = ComplexPoly(a) +function deepcopy_internal(a::ComplexPolyRingElem, dict::IdDict) + z = ComplexPolyRingElem(a) z.parent = parent(a) return z end @@ -72,7 +72,7 @@ end # ############################################################################### -function Base.show(io::IO, a::ComplexPoly) +function Base.show(io::IO, a::ComplexPolyRingElem) print(io, AbstractAlgebra.obj_to_string(a, context = io)) end @@ -83,7 +83,7 @@ end ############################################################################### function similar(f::PolyRingElem, R::ComplexField, var::VarName=var(parent(f)); cached::Bool=true) - z = ComplexPoly() + z = ComplexPolyRingElem() z.parent = ComplexPolyRing(R, Symbol(var), cached) return z end @@ -97,7 +97,7 @@ end function polynomial(R::ComplexField, arr::Vector{T}, var::VarName=:x; cached::Bool=true) where T coeffs = map(R, arr) coeffs = length(coeffs) == 0 ? ComplexFieldElem[] : coeffs - z = ComplexPoly(coeffs, R.prec) + z = ComplexPolyRingElem(coeffs, R.prec) z.parent = ComplexPolyRing(R, Symbol(var), cached) return z end @@ -108,56 +108,56 @@ end # ############################################################################### -function isequal(x::ComplexPoly, y::ComplexPoly) +function isequal(x::ComplexPolyRingElem, y::ComplexPolyRingElem) return ccall((:acb_poly_equal, libflint), Bool, - (Ref{ComplexPoly}, Ref{ComplexPoly}), x, y) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), x, y) end @doc raw""" - overlaps(x::ComplexPoly, y::ComplexPoly) + overlaps(x::ComplexPolyRingElem, y::ComplexPolyRingElem) Return `true` if the coefficient boxes of $x$ overlap the coefficient boxes of $y$, otherwise return `false`. """ -function overlaps(x::ComplexPoly, y::ComplexPoly) +function overlaps(x::ComplexPolyRingElem, y::ComplexPolyRingElem) return ccall((:acb_poly_overlaps, libflint), Bool, - (Ref{ComplexPoly}, Ref{ComplexPoly}), x, y) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), x, y) end @doc raw""" - contains(x::ComplexPoly, y::ComplexPoly) + contains(x::ComplexPolyRingElem, y::ComplexPolyRingElem) Return `true` if the coefficient boxes of $x$ contain the corresponding coefficient boxes of $y$, otherwise return `false`. """ -function contains(x::ComplexPoly, y::ComplexPoly) +function contains(x::ComplexPolyRingElem, y::ComplexPolyRingElem) return ccall((:acb_poly_contains, libflint), Bool, - (Ref{ComplexPoly}, Ref{ComplexPoly}), x, y) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), x, y) end @doc raw""" - contains(x::ComplexPoly, y::ZZPolyRingElem) + contains(x::ComplexPolyRingElem, y::ZZPolyRingElem) Return `true` if the coefficient boxes of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ -function contains(x::ComplexPoly, y::ZZPolyRingElem) +function contains(x::ComplexPolyRingElem, y::ZZPolyRingElem) return ccall((:acb_poly_contains_fmpz_poly, libflint), Bool, - (Ref{ComplexPoly}, Ref{ZZPolyRingElem}), x, y) + (Ref{ComplexPolyRingElem}, Ref{ZZPolyRingElem}), x, y) end @doc raw""" - contains(x::ComplexPoly, y::QQPolyRingElem) + contains(x::ComplexPolyRingElem, y::QQPolyRingElem) Return `true` if the coefficient boxes of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ -function contains(x::ComplexPoly, y::QQPolyRingElem) +function contains(x::ComplexPolyRingElem, y::QQPolyRingElem) return ccall((:acb_poly_contains_fmpq_poly, libflint), Bool, - (Ref{ComplexPoly}, Ref{QQPolyRingElem}), x, y) + (Ref{ComplexPolyRingElem}, Ref{QQPolyRingElem}), x, y) end -function ==(x::ComplexPoly, y::ComplexPoly) +function ==(x::ComplexPolyRingElem, y::ComplexPolyRingElem) if length(x) != length(y) return false end @@ -169,7 +169,7 @@ function ==(x::ComplexPoly, y::ComplexPoly) return true end -function !=(x::ComplexPoly, y::ComplexPoly) +function !=(x::ComplexPolyRingElem, y::ComplexPolyRingElem) for i = 0:max(degree(x), degree(y)) if coeff(x, i) != coeff(y, i) return true @@ -179,21 +179,21 @@ function !=(x::ComplexPoly, y::ComplexPoly) end @doc raw""" - unique_integer(x::ComplexPoly) + unique_integer(x::ComplexPolyRingElem) Return a tuple `(t, z)` where $t$ is `true` if there is a unique integer contained in the (constant) polynomial $x$, along with that integer $z$ in case it is, otherwise sets $t$ to `false`. """ -function unique_integer(x::ComplexPoly) +function unique_integer(x::ComplexPolyRingElem) z = ZZPolyRing(ZZ, var(parent(x)))() unique = ccall((:acb_poly_get_unique_fmpz_poly, libflint), Int, - (Ref{ZZPolyRingElem}, Ref{ComplexPoly}), z, x) + (Ref{ZZPolyRingElem}, Ref{ComplexPolyRingElem}), z, x) return (unique != 0, z) end -function isreal(x::ComplexPoly) - return ccall((:acb_poly_is_real, libflint), Cint, (Ref{ComplexPoly}, ), x) != 0 +function isreal(x::ComplexPolyRingElem) + return ccall((:acb_poly_is_real, libflint), Cint, (Ref{ComplexPolyRingElem}, ), x) != 0 end ############################################################################### @@ -202,19 +202,19 @@ end # ############################################################################### -function shift_left(x::ComplexPoly, len::Int) +function shift_left(x::ComplexPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() ccall((:acb_poly_shift_left, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, x, len) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, len) return z end -function shift_right(x::ComplexPoly, len::Int) +function shift_right(x::ComplexPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() ccall((:acb_poly_shift_right, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, x, len) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, len) return z end @@ -224,9 +224,9 @@ end # ################################################################################ -function -(x::ComplexPoly) +function -(x::ComplexPolyRingElem) z = parent(x)() - ccall((:acb_poly_neg, libflint), Nothing, (Ref{ComplexPoly}, Ref{ComplexPoly}), z, x) + ccall((:acb_poly_neg, libflint), Nothing, (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}), z, x) return z end @@ -236,35 +236,35 @@ end # ################################################################################ -function +(x::ComplexPoly, y::ComplexPoly) +function +(x::ComplexPolyRingElem, y::ComplexPolyRingElem) z = parent(x)() ccall((:acb_poly_add, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, y, precision(Balls)) return z end -function *(x::ComplexPoly, y::ComplexPoly) +function *(x::ComplexPolyRingElem, y::ComplexPolyRingElem) z = parent(x)() ccall((:acb_poly_mul, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, y, precision(Balls)) return z end -function -(x::ComplexPoly, y::ComplexPoly) +function -(x::ComplexPolyRingElem, y::ComplexPolyRingElem) z = parent(x)() ccall((:acb_poly_sub, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, y, precision(Balls)) return z end -function ^(x::ComplexPoly, y::Int) +function ^(x::ComplexPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() ccall((:acb_poly_pow_ui, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, UInt, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, UInt, Int), z, x, y, precision(Balls)) return z end @@ -278,17 +278,17 @@ end # to avoid method ambiguity errors, include `AbstractFloat, Integer, Rational` in addition to `Real` for T in [Union{AbstractFloat, Integer, Rational}, Union{Integer, Rational}, Real, Complex, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem, ZZPolyRingElem, QQPolyRingElem] @eval begin - +(x::ComplexPoly, y::$T) = x + parent(x)(y) + +(x::ComplexPolyRingElem, y::$T) = x + parent(x)(y) - +(x::$T, y::ComplexPoly) = y + x + +(x::$T, y::ComplexPolyRingElem) = y + x - -(x::ComplexPoly, y::$T) = x - parent(x)(y) + -(x::ComplexPolyRingElem, y::$T) = x - parent(x)(y) - -(x::$T, y::ComplexPoly) = parent(y)(x) - y + -(x::$T, y::ComplexPolyRingElem) = parent(y)(x) - y - *(x::ComplexPoly, y::$T) = x * parent(x)(y) + *(x::ComplexPolyRingElem, y::$T) = x * parent(x)(y) - *(x::$T, y::ComplexPoly) = y * x + *(x::$T, y::ComplexPolyRingElem) = y * x end end @@ -301,11 +301,11 @@ end # to avoid method ambiguity errors, include `AbstractFloat, Integer, Rational` in addition to `Real` for T in [Union{AbstractFloat, Integer, Rational}, Union{Integer, Rational}, Real, Complex, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem] @eval begin - divexact(x::ComplexPoly, y::$T; check::Bool=true) = x * inv(base_ring(parent(x))(y)) + divexact(x::ComplexPolyRingElem, y::$T; check::Bool=true) = x * inv(base_ring(parent(x))(y)) - //(x::ComplexPoly, y::$T) = divexact(x, y) + //(x::ComplexPolyRingElem, y::$T) = divexact(x, y) - /(x::ComplexPoly, y::$T) = divexact(x, y) + /(x::ComplexPolyRingElem, y::$T) = divexact(x, y) end end @@ -315,12 +315,12 @@ end # ############################################################################### -function Base.divrem(x::ComplexPoly, y::ComplexPoly) +function Base.divrem(x::ComplexPolyRingElem, y::ComplexPolyRingElem) iszero(y) && throw(DivideError()) q = parent(x)() r = parent(x)() if (ccall((:acb_poly_divrem, libflint), Int, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), q, r, x, y, precision(Balls)) == 1) return (q, r) else @@ -328,11 +328,11 @@ function Base.divrem(x::ComplexPoly, y::ComplexPoly) end end -function mod(x::ComplexPoly, y::ComplexPoly) +function mod(x::ComplexPolyRingElem, y::ComplexPolyRingElem) return divrem(x, y)[2] end -function divexact(x::ComplexPoly, y::ComplexPoly; check::Bool=true) +function divexact(x::ComplexPolyRingElem, y::ComplexPolyRingElem; check::Bool=true) return divrem(x, y)[1] end @@ -342,7 +342,7 @@ end # ############################################################################### -function truncate(a::ComplexPoly, n::Int) +function truncate(a::ComplexPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) if length(a) <= n return a @@ -350,15 +350,15 @@ function truncate(a::ComplexPoly, n::Int) # todo: implement set_trunc in ArbFieldElem z = deepcopy(a) ccall((:acb_poly_truncate, libflint), Nothing, - (Ref{ComplexPoly}, Int), z, n) + (Ref{ComplexPolyRingElem}, Int), z, n) return z end -function mullow(x::ComplexPoly, y::ComplexPoly, n::Int, prec::Int = precision(Balls)) +function mullow(x::ComplexPolyRingElem, y::ComplexPolyRingElem, n::Int, prec::Int = precision(Balls)) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() ccall((:acb_poly_mullow, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int, Int), z, x, y, n, prec) return z end @@ -369,11 +369,11 @@ end # ############################################################################### -#function reverse(x::ComplexPoly, len::Int) +#function reverse(x::ComplexPolyRingElem, len::Int) # len < 0 && throw(DomainError()) # z = parent(x)() # ccall((:acb_poly_reverse, libflint), Nothing, -# (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, x, len) +# (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, len) # return z #end @@ -383,36 +383,36 @@ end # ############################################################################### -function evaluate(x::ComplexPoly, y::ComplexFieldElem, prec::Int = precision(Balls)) +function evaluate(x::ComplexPolyRingElem, y::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(y)() ccall((:acb_poly_evaluate, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexPoly}, Ref{ComplexFieldElem}, Int), + (Ref{ComplexFieldElem}, Ref{ComplexPolyRingElem}, Ref{ComplexFieldElem}, Int), z, x, y, prec) return z end -evaluate(x::ComplexPoly, y::RingElement, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) -evaluate(x::ComplexPoly, y::Integer, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) -evaluate(x::ComplexPoly, y::Rational, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) -evaluate(x::ComplexPoly, y::Float64, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) -evaluate(x::ComplexPoly, y::Any, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) +evaluate(x::ComplexPolyRingElem, y::RingElement, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) +evaluate(x::ComplexPolyRingElem, y::Integer, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) +evaluate(x::ComplexPolyRingElem, y::Rational, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) +evaluate(x::ComplexPolyRingElem, y::Float64, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) +evaluate(x::ComplexPolyRingElem, y::Any, prec::Int = precision(Balls)) = evaluate(x, base_ring(parent(x))(y), prec) @doc raw""" - evaluate2(x::ComplexPoly, y::RingElement; prec::Int = precision(Balls)) + evaluate2(x::ComplexPolyRingElem, y::RingElement; prec::Int = precision(Balls)) Return a tuple $p, q$ consisting of the polynomial $x$ evaluated at $y$ and its derivative evaluated at $y$. """ -function evaluate2(x::ComplexPoly, y::ComplexFieldElem, prec::Int = precision(Balls)) +function evaluate2(x::ComplexPolyRingElem, y::ComplexFieldElem, prec::Int = precision(Balls)) z = ComplexFieldElem() w = ComplexFieldElem() ccall((:acb_poly_evaluate2, libflint), Nothing, - (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexPoly}, Ref{ComplexFieldElem}, Int), + (Ref{ComplexFieldElem}, Ref{ComplexFieldElem}, Ref{ComplexPolyRingElem}, Ref{ComplexFieldElem}, Int), z, w, x, y, prec) return z, w end -function evaluate2(x::ComplexPoly, y::RingElement, prec::Int = precision(Balls)) +function evaluate2(x::ComplexPolyRingElem, y::RingElement, prec::Int = precision(Balls)) return evaluate2(x, base_ring(parent(x))(y), prec) end @@ -422,14 +422,14 @@ end # ############################################################################### -function compose(x::ComplexPoly, y::ComplexPoly, prec::Int = precision(Balls); inner::Symbol) +function compose(x::ComplexPolyRingElem, y::ComplexPolyRingElem, prec::Int = precision(Balls); inner::Symbol) if inner == :first x, y = y, x end @assert inner == :second z = parent(x)() ccall((:acb_poly_compose, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, y, prec) return z end @@ -440,17 +440,17 @@ end # ############################################################################### -function derivative(x::ComplexPoly, prec::Int = precision(Balls)) +function derivative(x::ComplexPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() ccall((:acb_poly_derivative, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, x, prec) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, prec) return z end -function integral(x::ComplexPoly, prec::Int = precision(Balls)) +function integral(x::ComplexPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() ccall((:acb_poly_integral, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Int), z, x, prec) + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, prec) return z end @@ -496,19 +496,19 @@ function from_roots(R::ComplexPolyRing, b::Vector{ComplexFieldElem}, prec::Int = z = R() tmp = acb_vec(b) ccall((:acb_poly_product_roots, libflint), Nothing, - (Ref{ComplexPoly}, Ptr{acb_struct}, Int, Int), z, tmp, length(b), prec) + (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Int, Int), z, tmp, length(b), prec) acb_vec_clear(tmp, length(b)) return z end -function evaluate_iter(x::ComplexPoly, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) +function evaluate_iter(x::ComplexPolyRingElem, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) return ComplexFieldElem[evaluate(x, b[i], prec) for i=1:length(b)] end -function evaluate_fast(x::ComplexPoly, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) +function evaluate_fast(x::ComplexPolyRingElem, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) tmp = acb_vec(b) ccall((:acb_poly_evaluate_vec_fast, libflint), Nothing, - (Ptr{acb_struct}, Ref{ComplexPoly}, Ptr{acb_struct}, Int, Int), + (Ptr{acb_struct}, Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Int, Int), tmp, x, tmp, length(b), prec) res = array(base_ring(parent(x)), tmp, length(b)) acb_vec_clear(tmp, length(b)) @@ -521,7 +521,7 @@ function interpolate_newton(R::ComplexPolyRing, xs::Vector{ComplexFieldElem}, ys xsv = acb_vec(xs) ysv = acb_vec(ys) ccall((:acb_poly_interpolate_newton, libflint), Nothing, - (Ref{ComplexPoly}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), + (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), z, xsv, ysv, length(xs), prec) acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) @@ -534,7 +534,7 @@ function interpolate_barycentric(R::ComplexPolyRing, xs::Vector{ComplexFieldElem xsv = acb_vec(xs) ysv = acb_vec(ys) ccall((:acb_poly_interpolate_barycentric, libflint), Nothing, - (Ref{ComplexPoly}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), + (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), z, xsv, ysv, length(xs), prec) acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) @@ -547,7 +547,7 @@ function interpolate_fast(R::ComplexPolyRing, xs::Vector{ComplexFieldElem}, ys:: xsv = acb_vec(xs) ysv = acb_vec(ys) ccall((:acb_poly_interpolate_fast, libflint), Nothing, - (Ref{ComplexPoly}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), + (Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Ptr{acb_struct}, Int, Int), z, xsv, ysv, length(xs), prec) acb_vec_clear(xsv, length(xs)) acb_vec_clear(ysv, length(ys)) @@ -560,7 +560,7 @@ function interpolate(R::ComplexPolyRing, xs::Vector{ComplexFieldElem}, ys::Vecto end # todo: cutoffs for fast algorithm -function evaluate(x::ComplexPoly, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) +function evaluate(x::ComplexPolyRingElem, b::Vector{ComplexFieldElem}, prec::Int = precision(Balls)) return evaluate_iter(x, b, prec) end @@ -571,7 +571,7 @@ end ############################################################################### @doc raw""" - roots(x::ComplexPoly; target=0, isolate_real=false, initial_prec=0, max_prec=0, max_iter=0) + roots(x::ComplexPolyRingElem; target=0, isolate_real=false, initial_prec=0, max_prec=0, max_iter=0) Attempts to isolate the complex roots of the complex polynomial $x$ by iteratively refining balls in which they lie. @@ -586,7 +586,7 @@ positive or negative real part. It is assumed that $x$ is squarefree. """ -function roots(x::ComplexPoly; target=0, isolate_real=false, initial_prec=0, max_prec=0, max_iter=0) +function roots(x::ComplexPolyRingElem; target=0, isolate_real=false, initial_prec=0, max_prec=0, max_iter=0) deg = degree(x) if deg <= 0 return Array{ComplexFieldElem}(undef, 0) @@ -603,7 +603,7 @@ function roots(x::ComplexPoly; target=0, isolate_real=false, initial_prec=0, max in_roots = (wp == initial_prec) ? C_NULL : roots step_max_iter = (max_iter >= 1) ? max_iter : min(max(deg, 32), wp) isolated = ccall((:acb_poly_find_roots, libflint), Int, - (Ptr{acb_struct}, Ref{ComplexPoly}, Ptr{acb_struct}, Int, Int), + (Ptr{acb_struct}, Ref{ComplexPolyRingElem}, Ptr{acb_struct}, Int, Int), roots, x, in_roots, step_max_iter, wp) wp = wp * 2 @@ -627,7 +627,7 @@ function roots(x::ComplexPoly; target=0, isolate_real=false, initial_prec=0, max if isreal(x) real_ok = ccall((:acb_poly_validate_real_roots, libflint), - Bool, (Ptr{acb_struct}, Ref{ComplexPoly}, Int), roots, x, wp) + Bool, (Ptr{acb_struct}, Ref{ComplexPolyRingElem}, Int), roots, x, wp) if isolate_real && !real_ok ok = false @@ -676,17 +676,17 @@ end ############################################################################### @doc raw""" - roots_upper_bound(x::ComplexPoly) -> ArbFieldElem + roots_upper_bound(x::ComplexPolyRingElem) -> ArbFieldElem Returns an upper bound for the absolute value of all complex roots of $x$. """ -function roots_upper_bound(x::ComplexPoly) +function roots_upper_bound(x::ComplexPolyRingElem) z = RealFieldElem() p = precision(Balls) GC.@preserve x z begin t = ccall((:arb_rad_ptr, libflint), Ptr{mag_struct}, (Ref{RealFieldElem}, ), z) ccall((:acb_poly_root_bound_fujiwara, libflint), Nothing, - (Ptr{mag_struct}, Ref{ComplexPoly}), t, x) + (Ptr{mag_struct}, Ref{ComplexPolyRingElem}), t, x) s = ccall((:arb_mid_ptr, libflint), Ptr{arf_struct}, (Ref{RealFieldElem}, ), z) ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) ccall((:arf_set_round, libflint), Nothing, @@ -702,46 +702,46 @@ end # ############################################################################### -function zero!(z::ComplexPoly) - ccall((:acb_poly_zero, libflint), Nothing, (Ref{ComplexPoly},), z) +function zero!(z::ComplexPolyRingElem) + ccall((:acb_poly_zero, libflint), Nothing, (Ref{ComplexPolyRingElem},), z) return z end -function fit!(z::ComplexPoly, n::Int) +function fit!(z::ComplexPolyRingElem, n::Int) ccall((:acb_poly_fit_length, libflint), Nothing, - (Ref{ComplexPoly}, Int), z, n) + (Ref{ComplexPolyRingElem}, Int), z, n) return nothing end -function setcoeff!(z::ComplexPoly, n::Int, x::ZZRingElem) +function setcoeff!(z::ComplexPolyRingElem, n::Int, x::ZZRingElem) ccall((:acb_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{ComplexPoly}, Int, Ref{ZZRingElem}), z, n, x) + (Ref{ComplexPolyRingElem}, Int, Ref{ZZRingElem}), z, n, x) return z end -function setcoeff!(z::ComplexPoly, n::Int, x::ComplexFieldElem) +function setcoeff!(z::ComplexPolyRingElem, n::Int, x::ComplexFieldElem) ccall((:acb_poly_set_coeff_acb, libflint), Nothing, - (Ref{ComplexPoly}, Int, Ref{ComplexFieldElem}), z, n, x) + (Ref{ComplexPolyRingElem}, Int, Ref{ComplexFieldElem}), z, n, x) return z end -function mul!(z::ComplexPoly, x::ComplexPoly, y::ComplexPoly) +function mul!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexPolyRingElem) ccall((:acb_poly_mul, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, y, precision(parent(z))) return z end -function addeq!(z::ComplexPoly, x::ComplexPoly) +function addeq!(z::ComplexPolyRingElem, x::ComplexPolyRingElem) ccall((:acb_poly_add, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, z, x, precision(parent(z))) return z end -function add!(z::ComplexPoly, x::ComplexPoly, y::ComplexPoly) +function add!(z::ComplexPolyRingElem, x::ComplexPolyRingElem, y::ComplexPolyRingElem) ccall((:acb_poly_add, libflint), Nothing, - (Ref{ComplexPoly}, Ref{ComplexPoly}, Ref{ComplexPoly}, Int), + (Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Ref{ComplexPolyRingElem}, Int), z, x, y, precision(parent(z))) return z end @@ -752,16 +752,16 @@ end # ############################################################################### -promote_rule(::Type{ComplexPoly}, ::Type{ZZPolyRingElem}) = ComplexPoly +promote_rule(::Type{ComplexPolyRingElem}, ::Type{ZZPolyRingElem}) = ComplexPolyRingElem -promote_rule(::Type{ComplexPoly}, ::Type{QQPolyRingElem}) = ComplexPoly +promote_rule(::Type{ComplexPolyRingElem}, ::Type{QQPolyRingElem}) = ComplexPolyRingElem -promote_rule(::Type{ComplexPoly}, ::Type{ArbPolyRingElem}) = ComplexPoly +promote_rule(::Type{ComplexPolyRingElem}, ::Type{ArbPolyRingElem}) = ComplexPolyRingElem -promote_rule(::Type{ComplexPoly}, ::Type{ComplexPoly}) = ComplexPoly +promote_rule(::Type{ComplexPolyRingElem}, ::Type{ComplexPolyRingElem}) = ComplexPolyRingElem -function promote_rule(::Type{ComplexPoly}, ::Type{T}) where {T} - return promote_rule(ComplexFieldElem, T) === ComplexFieldElem ? ComplexPoly : Union{} +function promote_rule(::Type{ComplexPolyRingElem}, ::Type{T}) where {T} + return promote_rule(ComplexFieldElem, T) === ComplexFieldElem ? ComplexPolyRingElem : Union{} end ################################################################################ @@ -771,7 +771,7 @@ end ################################################################################ function (a::ComplexPolyRing)() - z = ComplexPoly() + z = ComplexPolyRingElem() z.parent = a return z end @@ -779,7 +779,7 @@ end for T in [Real, Complex, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldElem] @eval begin function (a::ComplexPolyRing)(b::$T) - z = ComplexPoly(base_ring(a)(b), precision(Balls)) + z = ComplexPolyRingElem(base_ring(a)(b), precision(Balls)) z.parent = a return z end @@ -787,7 +787,7 @@ for T in [Real, Complex, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldEle end function (a::ComplexPolyRing)(b::Vector{ComplexFieldElem}) - z = ComplexPoly(b, precision(Balls)) + z = ComplexPolyRingElem(b, precision(Balls)) z.parent = a return z end @@ -799,25 +799,25 @@ for T in [Real, Complex, ZZRingElem, QQFieldElem, RealFieldElem, ComplexFieldEle end function (a::ComplexPolyRing)(b::ZZPolyRingElem) - z = ComplexPoly(b, precision(Balls)) + z = ComplexPolyRingElem(b, precision(Balls)) z.parent = a return z end function (a::ComplexPolyRing)(b::QQPolyRingElem) - z = ComplexPoly(b, precision(Balls)) + z = ComplexPolyRingElem(b, precision(Balls)) z.parent = a return z end -function (a::ComplexPolyRing)(b::RealPoly) - z = ComplexPoly(b, precision(Balls)) +function (a::ComplexPolyRing)(b::RealPolyRingElem) + z = ComplexPolyRingElem(b, precision(Balls)) z.parent = a return z end -function (a::ComplexPolyRing)(b::ComplexPoly) - z = ComplexPoly(b, precision(Balls)) +function (a::ComplexPolyRing)(b::ComplexPolyRingElem) + z = ComplexPolyRingElem(b, precision(Balls)) z.parent = a return z end diff --git a/src/arb/RealMat.jl b/src/arb/RealMat.jl index 3424c3cc5..369c0a99c 100644 --- a/src/arb/RealMat.jl +++ b/src/arb/RealMat.jl @@ -10,12 +10,12 @@ # ############################################################################### -function similar(::RealMat, R::RealField, r::Int, c::Int) - z = RealMat(r, c) +function similar(::RealMatrix, R::RealField, r::Int, c::Int) + z = RealMatrix(r, c) return z end -zero(m::RealMat, R::RealField, r::Int, c::Int) = similar(m, R, r, c) +zero(m::RealMatrix, R::RealField, r::Int, c::Int) = similar(m, R, r, c) ############################################################################### # @@ -23,11 +23,11 @@ zero(m::RealMat, R::RealField, r::Int, c::Int) = similar(m, R, r, c) # ############################################################################### -base_ring(a::RealMat) = RealField() +base_ring(a::RealMatrix) = RealField() -dense_matrix_type(::Type{RealFieldElem}) = RealMat +dense_matrix_type(::Type{RealFieldElem}) = RealMatrix -function getindex!(z::ArbFieldElem, x::RealMat, r::Int, c::Int) +function getindex!(z::ArbFieldElem, x::RealMatrix, r::Int, c::Int) GC.@preserve x begin v = mat_entry_ptr(x, r, c) ccall((:arb_set, libflint), Nothing, (Ref{RealFieldElem}, Ptr{RealFieldElem}), z, v) @@ -35,7 +35,7 @@ function getindex!(z::ArbFieldElem, x::RealMat, r::Int, c::Int) return z end -@inline function getindex(x::RealMat, r::Int, c::Int) +@inline function getindex(x::RealMatrix, r::Int, c::Int) @boundscheck _checkbounds(x, r, c) z = base_ring(x)() @@ -48,7 +48,7 @@ end for T in [Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString] @eval begin - @inline function setindex!(x::RealMat, y::$T, r::Int, c::Int) + @inline function setindex!(x::RealMatrix, y::$T, r::Int, c::Int) @boundscheck _checkbounds(x, r, c) GC.@preserve x begin @@ -59,27 +59,27 @@ for T in [Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, end end -Base.@propagate_inbounds setindex!(x::RealMat, y::Integer, +Base.@propagate_inbounds setindex!(x::RealMatrix, y::Integer, r::Int, c::Int) = setindex!(x, ZZRingElem(y), r, c) -Base.@propagate_inbounds setindex!(x::RealMat, y::Rational{T}, +Base.@propagate_inbounds setindex!(x::RealMatrix, y::Rational{T}, r::Int, c::Int) where {T <: Integer} = setindex!(x, ZZRingElem(y), r, c) -function one(x::RealMatSpace) +function one(x::RealMatrixSpace) z = x() - ccall((:arb_mat_one, libflint), Nothing, (Ref{RealMat}, ), z) + ccall((:arb_mat_one, libflint), Nothing, (Ref{RealMatrix}, ), z) return z end -number_of_rows(a::RealMat) = a.r +number_of_rows(a::RealMatrix) = a.r -number_of_columns(a::RealMat) = a.c +number_of_columns(a::RealMatrix) = a.c -function deepcopy_internal(x::RealMat, dict::IdDict) - z = RealMat(nrows(x), ncols(x)) - ccall((:arb_mat_set, libflint), Nothing, (Ref{RealMat}, Ref{RealMat}), z, x) +function deepcopy_internal(x::RealMatrix, dict::IdDict) + z = RealMatrix(nrows(x), ncols(x)) + ccall((:arb_mat_set, libflint), Nothing, (Ref{RealMatrix}, Ref{RealMatrix}), z, x) return z end @@ -89,9 +89,9 @@ end # ################################################################################ -function -(x::RealMat) +function -(x::RealMatrix) z = similar(x) - ccall((:arb_mat_neg, libflint), Nothing, (Ref{RealMat}, Ref{RealMat}), z, x) + ccall((:arb_mat_neg, libflint), Nothing, (Ref{RealMatrix}, Ref{RealMatrix}), z, x) return z end @@ -101,10 +101,10 @@ end # ################################################################################ -function transpose(x::RealMat) +function transpose(x::RealMatrix) z = similar(x, ncols(x), nrows(x)) ccall((:arb_mat_transpose, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}), z, x) + (Ref{RealMatrix}, Ref{RealMatrix}), z, x) return z end @@ -114,29 +114,29 @@ end # ################################################################################ -function +(x::RealMat, y::RealMat) +function +(x::RealMatrix, y::RealMatrix) check_parent(x, y) z = similar(x) ccall((:arb_mat_add, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y, precision(Balls)) return z end -function -(x::RealMat, y::RealMat) +function -(x::RealMatrix, y::RealMatrix) check_parent(x, y) z = similar(x) ccall((:arb_mat_sub, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y, precision(Balls)) return z end -function *(x::RealMat, y::RealMat) +function *(x::RealMatrix, y::RealMatrix) ncols(x) != nrows(y) && error("Matrices have wrong dimensions") z = similar(x, nrows(x), ncols(y)) ccall((:arb_mat_mul, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y, precision(Balls)) return z end @@ -147,52 +147,52 @@ end # ################################################################################ -function ^(x::RealMat, y::UInt) +function ^(x::RealMatrix, y::UInt) nrows(x) != ncols(x) && error("Matrix must be square") z = similar(x) ccall((:arb_mat_pow_ui, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, UInt, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, UInt, Int), z, x, y, precision(Balls)) return z end -function *(x::RealMat, y::Int) +function *(x::RealMatrix, y::Int) z = similar(x) ccall((:arb_mat_scalar_mul_si, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Int, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Int, Int), z, x, y, precision(Balls)) return z end -*(x::Int, y::RealMat) = y*x +*(x::Int, y::RealMatrix) = y*x -*(x::RealMat, y::QQFieldElem) = x*base_ring(x)(y) +*(x::RealMatrix, y::QQFieldElem) = x*base_ring(x)(y) -*(x::QQFieldElem, y::RealMat) = y*x +*(x::QQFieldElem, y::RealMatrix) = y*x -function *(x::RealMat, y::ZZRingElem) +function *(x::RealMatrix, y::ZZRingElem) z = similar(x) ccall((:arb_mat_scalar_mul_fmpz, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{ZZRingElem}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{ZZRingElem}, Int), z, x, y, precision(Balls)) return z end -*(x::ZZRingElem, y::RealMat) = y*x +*(x::ZZRingElem, y::RealMatrix) = y*x -function *(x::RealMat, y::ArbFieldElem) +function *(x::RealMatrix, y::ArbFieldElem) z = similar(x) ccall((:arb_mat_scalar_mul_arb, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{RealFieldElem}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealFieldElem}, Int), z, x, y, precision(Balls)) return z end -*(x::ArbFieldElem, y::RealMat) = y*x +*(x::ArbFieldElem, y::RealMatrix) = y*x for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem] @eval begin - function +(x::RealMat, y::$T) + function +(x::RealMatrix, y::$T) z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] += y @@ -200,9 +200,9 @@ for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem] return z end - +(x::$T, y::RealMat) = y + x + +(x::$T, y::RealMatrix) = y + x - function -(x::RealMat, y::$T) + function -(x::RealMatrix, y::$T) z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] -= y @@ -210,7 +210,7 @@ for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem] return z end - function -(x::$T, y::RealMat) + function -(x::$T, y::RealMatrix) z = -y for i = 1:min(nrows(y), ncols(y)) z[i, i] += x @@ -220,7 +220,7 @@ for T in [Integer, ZZRingElem, QQFieldElem, RealFieldElem] end end -function +(x::RealMat, y::Rational{T}) where T <: Union{Int, BigInt} +function +(x::RealMatrix, y::Rational{T}) where T <: Union{Int, BigInt} z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] += y @@ -228,9 +228,9 @@ function +(x::RealMat, y::Rational{T}) where T <: Union{Int, BigInt} return z end -+(x::Rational{T}, y::RealMat) where T <: Union{Int, BigInt} = y + x ++(x::Rational{T}, y::RealMatrix) where T <: Union{Int, BigInt} = y + x -function -(x::RealMat, y::Rational{T}) where T <: Union{Int, BigInt} +function -(x::RealMatrix, y::Rational{T}) where T <: Union{Int, BigInt} z = deepcopy(x) for i = 1:min(nrows(x), ncols(x)) z[i, i] -= y @@ -238,7 +238,7 @@ function -(x::RealMat, y::Rational{T}) where T <: Union{Int, BigInt} return z end -function -(x::Rational{T}, y::RealMat) where T <: Union{Int, BigInt} +function -(x::Rational{T}, y::RealMatrix) where T <: Union{Int, BigInt} z = -y for i = 1:min(nrows(y), ncols(y)) z[i, i] += x @@ -252,10 +252,10 @@ end # ############################################################################### -function ldexp(x::RealMat, y::Int) +function ldexp(x::RealMatrix, y::Int) z = similar(x) ccall((:arb_mat_scalar_mul_2exp_si, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Int), z, x, y) + (Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y) return z end @@ -266,50 +266,50 @@ end ############################################################################### @doc raw""" - isequal(x::RealMat, y::RealMat) + isequal(x::RealMatrix, y::RealMatrix) Return `true` if the matrices of balls $x$ and $y$ are precisely equal, i.e. if all matrix entries have the same midpoints and radii. """ -function isequal(x::RealMat, y::RealMat) +function isequal(x::RealMatrix, y::RealMatrix) r = ccall((:arb_mat_equal, libflint), Cint, - (Ref{RealMat}, Ref{RealMat}), x, y) + (Ref{RealMatrix}, Ref{RealMatrix}), x, y) return Bool(r) end -function ==(x::RealMat, y::RealMat) +function ==(x::RealMatrix, y::RealMatrix) fl = check_parent(x, y, false) !fl && return false - r = ccall((:arb_mat_eq, libflint), Cint, (Ref{RealMat}, Ref{RealMat}), x, y) + r = ccall((:arb_mat_eq, libflint), Cint, (Ref{RealMatrix}, Ref{RealMatrix}), x, y) return Bool(r) end -function !=(x::RealMat, y::RealMat) - r = ccall((:arb_mat_ne, libflint), Cint, (Ref{RealMat}, Ref{RealMat}), x, y) +function !=(x::RealMatrix, y::RealMatrix) + r = ccall((:arb_mat_ne, libflint), Cint, (Ref{RealMatrix}, Ref{RealMatrix}), x, y) return Bool(r) end @doc raw""" - overlaps(x::RealMat, y::RealMat) + overlaps(x::RealMatrix, y::RealMatrix) Returns `true` if all entries of $x$ overlap with the corresponding entry of $y$, otherwise return `false`. """ -function overlaps(x::RealMat, y::RealMat) +function overlaps(x::RealMatrix, y::RealMatrix) r = ccall((:arb_mat_overlaps, libflint), Cint, - (Ref{RealMat}, Ref{RealMat}), x, y) + (Ref{RealMatrix}, Ref{RealMatrix}), x, y) return Bool(r) end @doc raw""" - contains(x::RealMat, y::RealMat) + contains(x::RealMatrix, y::RealMatrix) Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ -function contains(x::RealMat, y::RealMat) +function contains(x::RealMatrix, y::RealMatrix) r = ccall((:arb_mat_contains, libflint), Cint, - (Ref{RealMat}, Ref{RealMat}), x, y) + (Ref{RealMatrix}, Ref{RealMatrix}), x, y) return Bool(r) end @@ -320,41 +320,41 @@ end ############################################################################### @doc raw""" - contains(x::RealMat, y::ZZMatrix) + contains(x::RealMatrix, y::ZZMatrix) Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ -function contains(x::RealMat, y::ZZMatrix) +function contains(x::RealMatrix, y::ZZMatrix) r = ccall((:arb_mat_contains_fmpz_mat, libflint), Cint, - (Ref{RealMat}, Ref{ZZMatrix}), x, y) + (Ref{RealMatrix}, Ref{ZZMatrix}), x, y) return Bool(r) end @doc raw""" - contains(x::RealMat, y::QQMatrix) + contains(x::RealMatrix, y::QQMatrix) Returns `true` if all entries of $x$ contain the corresponding entry of $y$, otherwise return `false`. """ -function contains(x::RealMat, y::QQMatrix) +function contains(x::RealMatrix, y::QQMatrix) r = ccall((:arb_mat_contains_fmpq_mat, libflint), Cint, - (Ref{RealMat}, Ref{QQMatrix}), x, y) + (Ref{RealMatrix}, Ref{QQMatrix}), x, y) return Bool(r) end -==(x::RealMat, y::Integer) = x == parent(x)(y) +==(x::RealMatrix, y::Integer) = x == parent(x)(y) -==(x::Integer, y::RealMat) = y == x +==(x::Integer, y::RealMatrix) = y == x -==(x::RealMat, y::ZZRingElem) = x == parent(x)(y) +==(x::RealMatrix, y::ZZRingElem) = x == parent(x)(y) -==(x::ZZRingElem, y::RealMat) = y == x +==(x::ZZRingElem, y::RealMatrix) = y == x -==(x::RealMat, y::ZZMatrix) = x == parent(x)(y) +==(x::RealMatrix, y::ZZMatrix) = x == parent(x)(y) -==(x::ZZMatrix, y::RealMat) = y == x +==(x::ZZMatrix, y::RealMatrix) = y == x ############################################################################### # @@ -363,23 +363,23 @@ end ############################################################################### @doc raw""" - inv(x::RealMat) + inv(x::RealMatrix) Given a $n\times n$ matrix of type `ArbMatrix`, return an $n\times n$ matrix $X$ such that $AX$ contains the identity matrix. If $A$ cannot be inverted numerically an exception is raised. """ -function inv(x::RealMat) +function inv(x::RealMatrix) fl, z = is_invertible_with_inverse(x) fl && return z error("Matrix singular or cannot be inverted numerically") end -function is_invertible_with_inverse(x::RealMat) +function is_invertible_with_inverse(x::RealMatrix) ncols(x) != nrows(x) && return false, x z = similar(x) r = ccall((:arb_mat_inv, libflint), Cint, - (Ref{RealMat}, Ref{RealMat}, Int), z, x, precision(Balls)) + (Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, precision(Balls)) return Bool(r), z end @@ -389,7 +389,7 @@ end # ############################################################################### -function divexact(x::RealMat, y::RealMat; check::Bool=true) +function divexact(x::RealMatrix, y::RealMatrix; check::Bool=true) ncols(x) != ncols(y) && error("Incompatible matrix dimensions") x*inv(y) end @@ -400,27 +400,27 @@ end # ############################################################################### -function divexact(x::RealMat, y::Int; check::Bool=true) +function divexact(x::RealMatrix, y::Int; check::Bool=true) y == 0 && throw(DivideError()) z = similar(x) ccall((:arb_mat_scalar_div_si, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Int, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Int, Int), z, x, y, precision(Balls)) return z end -function divexact(x::RealMat, y::ZZRingElem; check::Bool=true) +function divexact(x::RealMatrix, y::ZZRingElem; check::Bool=true) z = similar(x) ccall((:arb_mat_scalar_div_fmpz, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{ZZRingElem}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{ZZRingElem}, Int), z, x, y, precision(Balls)) return z end -function divexact(x::RealMat, y::ArbFieldElem; check::Bool=true) +function divexact(x::RealMatrix, y::ArbFieldElem; check::Bool=true) z = similar(x) ccall((:arb_mat_scalar_div_arb, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{RealFieldElem}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealFieldElem}, Int), z, x, y, precision(Balls)) return z end @@ -431,11 +431,11 @@ end # ################################################################################ -function charpoly(x::RealPolyRing, y::RealMat, prec::Int = precision(Balls)) +function charpoly(x::RealPolyRing, y::RealMatrix, prec::Int = precision(Balls)) base_ring(y) != base_ring(x) && error("Base rings must coincide") z = x() ccall((:arb_mat_charpoly, libflint), Nothing, - (Ref{RealPoly}, Ref{RealMat}, Int), z, y, prec) + (Ref{RealPolyRingElem}, Ref{RealMatrix}, Int), z, y, prec) return z end @@ -445,11 +445,11 @@ end # ############################################################################### -function det(x::RealMat, prec::Int = precision(Balls)) +function det(x::RealMatrix, prec::Int = precision(Balls)) ncols(x) != nrows(x) && error("Matrix must be square") z = base_ring(x)() ccall((:arb_mat_det, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealMat}, Int), z, x, prec) + (Ref{RealFieldElem}, Ref{RealMatrix}, Int), z, x, prec) return z end @@ -459,11 +459,11 @@ end # ################################################################################ -function Base.exp(x::RealMat) +function Base.exp(x::RealMatrix) ncols(x) != nrows(x) && error("Matrix must be square") z = similar(x) ccall((:arb_mat_exp, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Int), z, x, precision(Balls)) + (Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, precision(Balls)) return z end @@ -473,11 +473,11 @@ end # ############################################################################### -function lu!(P::Perm, x::RealMat) +function lu!(P::Perm, x::RealMatrix) parent(P).n != nrows(x) && error("Permutation does not match matrix") P.d .-= 1 r = ccall((:arb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{RealMat}, Ref{RealMat}, Int), + (Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), P.d, x, x, precision(Balls)) r == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 @@ -485,30 +485,30 @@ function lu!(P::Perm, x::RealMat) return min(nrows(x), ncols(x)) end -function _solve!(z::RealMat, x::RealMat, y::RealMat) +function _solve!(z::RealMatrix, x::RealMatrix, y::RealMatrix) r = ccall((:arb_mat_solve, libflint), Cint, - (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y, precision(Balls)) r == 0 && error("Matrix cannot be inverted numerically") nothing end -function _solve_lu_precomp!(z::RealMat, P::Perm, LU::RealMat, y::RealMat) +function _solve_lu_precomp!(z::RealMatrix, P::Perm, LU::RealMatrix, y::RealMatrix) Q = inv(P) ccall((:arb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{RealMat}, Ptr{Int}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), z, Q.d .- 1, LU, y, precision(Balls)) nothing end -function _solve_lu_precomp(P::Perm, LU::RealMat, y::RealMat) +function _solve_lu_precomp(P::Perm, LU::RealMatrix, y::RealMatrix) ncols(LU) != nrows(y) && error("Matrix dimensions are wrong") z = similar(y) _solve_lu_precomp!(z, P, LU, y) return z end -function Solve._can_solve_internal_no_check(A::RealMat, b::RealMat, task::Symbol; side::Symbol = :left) +function Solve._can_solve_internal_no_check(A::RealMatrix, b::RealMatrix, task::Symbol; side::Symbol = :left) nrows(A) != ncols(A) && error("Only implemented for square matrices") if side === :left fl, sol, K = Solve._can_solve_internal_no_check(transpose(A), transpose(b), task, side = :right) @@ -517,7 +517,7 @@ function Solve._can_solve_internal_no_check(A::RealMat, b::RealMat, task::Symbol x = similar(A, ncols(A), ncols(b)) fl = ccall((:arb_mat_solve, libflint), Cint, - (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), x, A, b, precision(Balls)) fl == 0 && error("Matrix cannot be inverted numerically") if task === :only_check || task === :with_solution @@ -533,7 +533,7 @@ end # ################################################################################ -AbstractAlgebra.solve_context_type(::Type{RealFieldElem}) = Solve.SolveCtx{RealFieldElem, RealMat, RealMat, RealMat} +AbstractAlgebra.solve_context_type(::Type{RealFieldElem}) = Solve.SolveCtx{RealFieldElem, RealMatrix, RealMatrix, RealMatrix} function Solve._init_reduce(C::Solve.SolveCtx{RealFieldElem}) if isdefined(C, :red) && isdefined(C, :lu_perm) @@ -547,7 +547,7 @@ function Solve._init_reduce(C::Solve.SolveCtx{RealFieldElem}) x = similar(A, nrows(A), ncols(A)) P.d .-= 1 fl = ccall((:arb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{RealMat}, Ref{RealMat}, Int), + (Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), P.d, x, A, precision(Balls)) fl == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 @@ -570,7 +570,7 @@ function Solve._init_reduce_transpose(C::Solve.SolveCtx{RealFieldElem}) x = similar(A, nrows(A), ncols(A)) P.d .-= 1 fl = ccall((:arb_mat_lu, libflint), Cint, - (Ptr{Int}, Ref{RealMat}, Ref{RealMat}, Int), + (Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), P.d, x, A, precision(Balls)) fl == 0 && error("Could not find $(nrows(x)) invertible pivot elements") P.d .+= 1 @@ -581,7 +581,7 @@ function Solve._init_reduce_transpose(C::Solve.SolveCtx{RealFieldElem}) return nothing end -function Solve._can_solve_internal_no_check(C::Solve.SolveCtx{RealFieldElem}, b::RealMat, task::Symbol; side::Symbol = :left) +function Solve._can_solve_internal_no_check(C::Solve.SolveCtx{RealFieldElem}, b::RealMatrix, task::Symbol; side::Symbol = :left) if side === :right LU = Solve.reduced_matrix(C) p = Solve.lu_permutation(C) @@ -593,7 +593,7 @@ function Solve._can_solve_internal_no_check(C::Solve.SolveCtx{RealFieldElem}, b: x = similar(b, ncols(C), ncols(b)) ccall((:arb_mat_solve_lu_precomp, libflint), Nothing, - (Ref{RealMat}, Ptr{Int}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ptr{Int}, Ref{RealMatrix}, Ref{RealMatrix}, Int), x, inv(p).d .- 1, LU, b, precision(Balls)) if side === :left @@ -617,7 +617,7 @@ end # ################################################################################ -function swap_rows(x::RealMat, i::Int, j::Int) +function swap_rows(x::RealMatrix, i::Int, j::Int) _checkbounds(nrows(x), i) || throw(BoundsError()) _checkbounds(nrows(x), j) || throw(BoundsError()) z = deepcopy(x) @@ -625,9 +625,9 @@ function swap_rows(x::RealMat, i::Int, j::Int) return z end -function swap_rows!(x::RealMat, i::Int, j::Int) +function swap_rows!(x::RealMatrix, i::Int, j::Int) ccall((:arb_mat_swap_rows, libflint), Nothing, - (Ref{RealMat}, Ptr{Nothing}, Int, Int), + (Ref{RealMatrix}, Ptr{Nothing}, Int, Int), x, C_NULL, i - 1, j - 1) end @@ -638,17 +638,17 @@ end ################################################################################ @doc raw""" - bound_inf_norm(x::RealMat) + bound_inf_norm(x::RealMatrix) Returns a non-negative element $z$ of type `ArbFieldElem`, such that $z$ is an upper bound for the infinity norm for every matrix in $x$ """ -function bound_inf_norm(x::RealMat) +function bound_inf_norm(x::RealMatrix) z = RealFieldElem() GC.@preserve x z begin t = ccall((:arb_rad_ptr, libflint), Ptr{mag_struct}, (Ref{RealFieldElem}, ), z) ccall((:arb_mat_bound_inf_norm, libflint), Nothing, - (Ptr{mag_struct}, Ref{RealMat}), t, x) + (Ptr{mag_struct}, Ref{RealMatrix}), t, x) s = ccall((:arb_mid_ptr, libflint), Ptr{arf_struct}, (Ref{RealFieldElem}, ), z) ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) @@ -667,9 +667,9 @@ end for (s,f) in (("add!","arb_mat_add"), ("mul!","arb_mat_mul"), ("sub!","arb_mat_sub")) @eval begin - function ($(Symbol(s)))(z::RealMat, x::RealMat, y::RealMat, prec::Int = precision(Balls)) + function ($(Symbol(s)))(z::RealMatrix, x::RealMatrix, y::RealMatrix, prec::Int = precision(Balls)) ccall(($f, libflint), Nothing, - (Ref{RealMat}, Ref{RealMat}, Ref{RealMat}, Int), + (Ref{RealMatrix}, Ref{RealMatrix}, Ref{RealMatrix}, Int), z, x, y, prec) return z end @@ -682,31 +682,31 @@ end # ############################################################################### -function (x::RealMatSpace)() - z = RealMat(nrows(x), ncols(x)) +function (x::RealMatrixSpace)() + z = RealMatrix(nrows(x), ncols(x)) return z end -function (x::RealMatSpace)(y::ZZMatrix) +function (x::RealMatrixSpace)(y::ZZMatrix) (ncols(x) != ncols(y) || nrows(x) != nrows(y)) && error("Dimensions are wrong") - z = RealMat(y, precision(Balls)) + z = RealMatrix(y, precision(Balls)) return z end -function (x::RealMatSpace)(y::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} +function (x::RealMatrixSpace)(y::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} _check_dim(nrows(x), ncols(x), y) - z = RealMat(nrows(x), ncols(x), y, precision(Balls)) + z = RealMatrix(nrows(x), ncols(x), y, precision(Balls)) return z end -function (x::RealMatSpace)(y::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} +function (x::RealMatrixSpace)(y::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} _check_dim(nrows(x), ncols(x), y) - z = RealMat(nrows(x), ncols(x), y, precision(Balls)) + z = RealMatrix(nrows(x), ncols(x), y, precision(Balls)) return z end -function (x::RealMatSpace)(y::Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, +function (x::RealMatrixSpace)(y::Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}) z = x() for i in 1:nrows(z) @@ -728,13 +728,13 @@ end ############################################################################### function matrix(R::RealField, arr::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} - z = RealMat(size(arr, 1), size(arr, 2), arr, precision(Balls)) + z = RealMatrix(size(arr, 1), size(arr, 2), arr, precision(Balls)) return z end function matrix(R::RealField, r::Int, c::Int, arr::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, RealFieldElem, AbstractString}} _check_dim(r, c, arr) - z = RealMat(r, c, arr, precision(Balls)) + z = RealMatrix(r, c, arr, precision(Balls)) return z end @@ -768,7 +768,7 @@ function zero_matrix(R::RealField, r::Int, c::Int) if r < 0 || c < 0 error("dimensions must not be negative") end - z = RealMat(r, c) + z = RealMatrix(r, c) return z end @@ -782,8 +782,8 @@ function identity_matrix(R::RealField, n::Int) if n < 0 error("dimension must not be negative") end - z = RealMat(n, n) - ccall((:arb_mat_one, libflint), Nothing, (Ref{RealMat}, ), z) + z = RealMatrix(n, n) + ccall((:arb_mat_one, libflint), Nothing, (Ref{RealMatrix}, ), z) return z end @@ -793,9 +793,9 @@ end # ################################################################################ -@inline mat_entry_ptr(A::RealMat, i::Int, j::Int) = +@inline mat_entry_ptr(A::RealMatrix, i::Int, j::Int) = ccall((:arb_mat_entry_ptr, libflint), - Ptr{RealFieldElem}, (Ref{RealMat}, Int, Int), A, i-1, j-1) + Ptr{RealFieldElem}, (Ref{RealMatrix}, Int, Int), A, i-1, j-1) ############################################################################### # @@ -803,20 +803,20 @@ ccall((:arb_mat_entry_ptr, libflint), # ############################################################################### -promote_rule(::Type{RealMat}, ::Type{T}) where {T <: Integer} = RealMat +promote_rule(::Type{RealMatrix}, ::Type{T}) where {T <: Integer} = RealMatrix -promote_rule(::Type{RealMat}, ::Type{Rational{T}}) where T <: Union{Int, BigInt} = RealMat +promote_rule(::Type{RealMatrix}, ::Type{Rational{T}}) where T <: Union{Int, BigInt} = RealMatrix -promote_rule(::Type{RealMat}, ::Type{ZZRingElem}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{ZZRingElem}) = RealMatrix -promote_rule(::Type{RealMat}, ::Type{QQFieldElem}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{QQFieldElem}) = RealMatrix -promote_rule(::Type{RealMat}, ::Type{RealFieldElem}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{RealFieldElem}) = RealMatrix -promote_rule(::Type{RealMat}, ::Type{Float64}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{Float64}) = RealMatrix -promote_rule(::Type{RealMat}, ::Type{BigFloat}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{BigFloat}) = RealMatrix -promote_rule(::Type{RealMat}, ::Type{ZZMatrix}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{ZZMatrix}) = RealMatrix -promote_rule(::Type{RealMat}, ::Type{QQMatrix}) = RealMat +promote_rule(::Type{RealMatrix}, ::Type{QQMatrix}) = RealMatrix diff --git a/src/arb/RealPoly.jl b/src/arb/RealPoly.jl index f824f8b78..5ec80cba0 100644 --- a/src/arb/RealPoly.jl +++ b/src/arb/RealPoly.jl @@ -10,28 +10,28 @@ # ############################################################################### -parent_type(::Type{RealPoly}) = RealPolyRing +parent_type(::Type{RealPolyRingElem}) = RealPolyRing -elem_type(::Type{RealPolyRing}) = RealPoly +elem_type(::Type{RealPolyRing}) = RealPolyRingElem -dense_poly_type(::Type{RealFieldElem}) = RealPoly +dense_poly_type(::Type{RealFieldElem}) = RealPolyRingElem -length(x::RealPoly) = ccall((:arb_poly_length, libflint), Int, - (Ref{RealPoly},), x) +length(x::RealPolyRingElem) = ccall((:arb_poly_length, libflint), Int, + (Ref{RealPolyRingElem},), x) -function set_length!(x::RealPoly, n::Int) +function set_length!(x::RealPolyRingElem, n::Int) ccall((:_arb_poly_set_length, libflint), Nothing, - (Ref{RealPoly}, Int), x, n) + (Ref{RealPolyRingElem}, Int), x, n) return x end -degree(x::RealPoly) = length(x) - 1 +degree(x::RealPolyRingElem) = length(x) - 1 -function coeff(a::RealPoly, n::Int) +function coeff(a::RealPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) t = base_ring(parent(a))() ccall((:arb_poly_get_coeff_arb, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealPoly}, Int), t, a, n) + (Ref{RealFieldElem}, Ref{RealPolyRingElem}, Int), t, a, n) return t end @@ -40,28 +40,28 @@ zero(a::RealPolyRing) = a(0) one(a::RealPolyRing) = a(1) function gen(a::RealPolyRing) - z = RealPoly() + z = RealPolyRingElem() ccall((:arb_poly_set_coeff_si, libflint), Nothing, - (Ref{RealPoly}, Int, Int), z, 1, 1) + (Ref{RealPolyRingElem}, Int, Int), z, 1, 1) z.parent = a return z end # todo: write a C function for this -function is_gen(a::RealPoly) +function is_gen(a::RealPolyRingElem) return isequal(a, gen(parent(a))) end -#function iszero(a::RealPoly) +#function iszero(a::RealPolyRingElem) # return length(a) == 0 #end -#function isone(a::RealPoly) +#function isone(a::RealPolyRingElem) # return strongequal(a, one(parent(a))) #end -function deepcopy_internal(a::RealPoly, dict::IdDict) - z = RealPoly(a) +function deepcopy_internal(a::RealPolyRingElem, dict::IdDict) + z = RealPolyRingElem(a) z.parent = parent(a) return z end @@ -73,7 +73,7 @@ end ############################################################################### function similar(f::PolyRingElem, R::RealField, var::VarName=var(parent(f)); cached::Bool=true) - z = RealPoly() + z = RealPolyRingElem() z.parent = RealPolyRing(R, Symbol(var), cached) return z end @@ -87,7 +87,7 @@ end function polynomial(R::RealField, arr::Vector{T}, var::VarName=:x; cached::Bool=true) where T coeffs = map(R, arr) coeffs = length(coeffs) == 0 ? RealFieldElem[] : coeffs - z = RealPoly(coeffs, precision(Balls)) + z = RealPolyRingElem(coeffs, precision(Balls)) z.parent = RealPolyRing(R, Symbol(var), cached) return z end @@ -98,56 +98,56 @@ end # ############################################################################### -function isequal(x::RealPoly, y::RealPoly) +function isequal(x::RealPolyRingElem, y::RealPolyRingElem) return ccall((:arb_poly_equal, libflint), Bool, - (Ref{RealPoly}, Ref{RealPoly}), x, y) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), x, y) end @doc raw""" - overlaps(x::RealPoly, y::RealPoly) + overlaps(x::RealPolyRingElem, y::RealPolyRingElem) Return `true` if the coefficient balls of $x$ overlap the coefficient balls of $y$, otherwise return `false`. """ -function overlaps(x::RealPoly, y::RealPoly) +function overlaps(x::RealPolyRingElem, y::RealPolyRingElem) return ccall((:arb_poly_overlaps, libflint), Bool, - (Ref{RealPoly}, Ref{RealPoly}), x, y) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), x, y) end @doc raw""" - contains(x::RealPoly, y::RealPoly) + contains(x::RealPolyRingElem, y::RealPolyRingElem) Return `true` if the coefficient balls of $x$ contain the corresponding coefficient balls of $y$, otherwise return `false`. """ -function contains(x::RealPoly, y::RealPoly) +function contains(x::RealPolyRingElem, y::RealPolyRingElem) return ccall((:arb_poly_contains, libflint), Bool, - (Ref{RealPoly}, Ref{RealPoly}), x, y) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), x, y) end @doc raw""" - contains(x::RealPoly, y::ZZPolyRingElem) + contains(x::RealPolyRingElem, y::ZZPolyRingElem) Return `true` if the coefficient balls of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ -function contains(x::RealPoly, y::ZZPolyRingElem) +function contains(x::RealPolyRingElem, y::ZZPolyRingElem) return ccall((:arb_poly_contains_fmpz_poly, libflint), Bool, - (Ref{RealPoly}, Ref{ZZPolyRingElem}), x, y) + (Ref{RealPolyRingElem}, Ref{ZZPolyRingElem}), x, y) end @doc raw""" - contains(x::RealPoly, y::QQPolyRingElem) + contains(x::RealPolyRingElem, y::QQPolyRingElem) Return `true` if the coefficient balls of $x$ contain the corresponding exact coefficients of $y$, otherwise return `false`. """ -function contains(x::RealPoly, y::QQPolyRingElem) +function contains(x::RealPolyRingElem, y::QQPolyRingElem) return ccall((:arb_poly_contains_fmpq_poly, libflint), Bool, - (Ref{RealPoly}, Ref{QQPolyRingElem}), x, y) + (Ref{RealPolyRingElem}, Ref{QQPolyRingElem}), x, y) end -function ==(x::RealPoly, y::RealPoly) +function ==(x::RealPolyRingElem, y::RealPolyRingElem) if length(x) != length(y) return false end @@ -159,7 +159,7 @@ function ==(x::RealPoly, y::RealPoly) return true end -function !=(x::RealPoly, y::RealPoly) +function !=(x::RealPolyRingElem, y::RealPolyRingElem) for i = 0:max(degree(x), degree(y)) if coeff(x, i) != coeff(y, i) return true @@ -169,16 +169,16 @@ function !=(x::RealPoly, y::RealPoly) end @doc raw""" - unique_integer(x::RealPoly) + unique_integer(x::RealPolyRingElem) Return a tuple `(t, z)` where $t$ is `true` if there is a unique integer contained in each of the coefficients of $x$, otherwise sets $t$ to `false`. In the former case, $z$ is set to the integer polynomial. """ -function unique_integer(x::RealPoly) +function unique_integer(x::RealPolyRingElem) z = ZZPolyRing(ZZ, var(parent(x)))() unique = ccall((:arb_poly_get_unique_fmpz_poly, libflint), Int, - (Ref{ZZPolyRingElem}, Ref{RealPoly}), z, x) + (Ref{ZZPolyRingElem}, Ref{RealPolyRingElem}), z, x) return (unique != 0, z) end @@ -188,19 +188,19 @@ end # ############################################################################### -function shift_left(x::RealPoly, len::Int) +function shift_left(x::RealPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() ccall((:arb_poly_shift_left, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Int), z, x, len) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, len) return z end -function shift_right(x::RealPoly, len::Int) +function shift_right(x::RealPolyRingElem, len::Int) len < 0 && throw(DomainError(len, "Shift must be non-negative")) z = parent(x)() ccall((:arb_poly_shift_right, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Int), z, x, len) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, len) return z end @@ -210,9 +210,9 @@ end # ################################################################################ -function -(x::RealPoly) +function -(x::RealPolyRingElem) z = parent(x)() - ccall((:arb_poly_neg, libflint), Nothing, (Ref{RealPoly}, Ref{RealPoly}), z, x) + ccall((:arb_poly_neg, libflint), Nothing, (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}), z, x) return z end @@ -222,35 +222,35 @@ end # ################################################################################ -function +(x::RealPoly, y::RealPoly) +function +(x::RealPolyRingElem, y::RealPolyRingElem) z = parent(x)() ccall((:arb_poly_add, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, y, precision(Balls)) return z end -function *(x::RealPoly, y::RealPoly) +function *(x::RealPolyRingElem, y::RealPolyRingElem) z = parent(x)() ccall((:arb_poly_mul, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, y, precision(Balls)) return z end -function -(x::RealPoly, y::RealPoly) +function -(x::RealPolyRingElem, y::RealPolyRingElem) z = parent(x)() ccall((:arb_poly_sub, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, y, precision(Balls)) return z end -function ^(x::RealPoly, y::Int) +function ^(x::RealPolyRingElem, y::Int) y < 0 && throw(DomainError(y, "Exponent must be non-negative")) z = parent(x)() ccall((:arb_poly_pow_ui, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, UInt, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, UInt, Int), z, x, y, precision(Balls)) return z end @@ -264,17 +264,17 @@ end # to avoid method ambiguity errors, include `AbstractFloat, Integer, Rational` in addition to `Real` for T in [Union{AbstractFloat, Integer, Rational}, Union{Integer, Rational}, Real, ZZRingElem, QQFieldElem, RealFieldElem, ZZPolyRingElem, QQPolyRingElem] @eval begin - +(x::RealPoly, y::$T) = x + parent(x)(y) + +(x::RealPolyRingElem, y::$T) = x + parent(x)(y) - +(x::$T, y::RealPoly) = y + x + +(x::$T, y::RealPolyRingElem) = y + x - -(x::RealPoly, y::$T) = x - parent(x)(y) + -(x::RealPolyRingElem, y::$T) = x - parent(x)(y) - -(x::$T, y::RealPoly) = parent(y)(x) - y + -(x::$T, y::RealPolyRingElem) = parent(y)(x) - y - *(x::RealPoly, y::$T) = x * parent(x)(y) + *(x::RealPolyRingElem, y::$T) = x * parent(x)(y) - *(x::$T, y::RealPoly) = y * x + *(x::$T, y::RealPolyRingElem) = y * x end end @@ -287,11 +287,11 @@ end # to avoid method ambiguity errors, include `AbstractFloat, Integer, Rational` in addition to `Real` for T in [Union{AbstractFloat, Integer, Rational}, Union{Integer, Rational}, Real, ZZRingElem, QQFieldElem, RealFieldElem] @eval begin - divexact(x::RealPoly, y::$T; check::Bool=true) = x * inv(base_ring(parent(x))(y)) + divexact(x::RealPolyRingElem, y::$T; check::Bool=true) = x * inv(base_ring(parent(x))(y)) - //(x::RealPoly, y::$T) = divexact(x, y) + //(x::RealPolyRingElem, y::$T) = divexact(x, y) - /(x::RealPoly, y::$T) = divexact(x, y) + /(x::RealPolyRingElem, y::$T) = divexact(x, y) end end @@ -301,12 +301,12 @@ end # ############################################################################### -function Base.divrem(x::RealPoly, y::RealPoly) +function Base.divrem(x::RealPolyRingElem, y::RealPolyRingElem) iszero(y) && throw(DivideError()) q = parent(x)() r = parent(x)() if (ccall((:arb_poly_divrem, libflint), Int, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), q, r, x, y, precision(Balls)) == 1) return (q, r) else @@ -314,11 +314,11 @@ function Base.divrem(x::RealPoly, y::RealPoly) end end -function mod(x::RealPoly, y::RealPoly) +function mod(x::RealPolyRingElem, y::RealPolyRingElem) return divrem(x, y)[2] end -function divexact(x::RealPoly, y::RealPoly; check::Bool=true) +function divexact(x::RealPolyRingElem, y::RealPolyRingElem; check::Bool=true) return divrem(x, y)[1] end @@ -328,7 +328,7 @@ end # ############################################################################### -function truncate(a::RealPoly, n::Int) +function truncate(a::RealPolyRingElem, n::Int) n < 0 && throw(DomainError(n, "Index must be non-negative")) if length(a) <= n return a @@ -336,15 +336,15 @@ function truncate(a::RealPoly, n::Int) # todo: implement set_trunc in ArbFieldElem z = deepcopy(a) ccall((:arb_poly_truncate, libflint), Nothing, - (Ref{RealPoly}, Int), z, n) + (Ref{RealPolyRingElem}, Int), z, n) return z end -function mullow(x::RealPoly, y::RealPoly, n::Int, prec::Int = precision(Balls)) +function mullow(x::RealPolyRingElem, y::RealPolyRingElem, n::Int, prec::Int = precision(Balls)) n < 0 && throw(DomainError(n, "Index must be non-negative")) z = parent(x)() ccall((:arb_poly_mullow, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int, Int), z, x, y, n, prec) return z end @@ -355,11 +355,11 @@ end # ############################################################################### -#function reverse(x::RealPoly, len::Int) +#function reverse(x::RealPolyRingElem, len::Int) # len < 0 && throw(DomainError()) # z = parent(x)() # ccall((:arb_poly_reverse, libflint), Nothing, -# (Ref{RealPoly}, Ref{RealPoly}, Int), z, x, len) +# (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, len) # return z #end @@ -369,53 +369,53 @@ end # ############################################################################### -function evaluate(x::RealPoly, y::RealFieldElem, prec::Int = precision(Balls)) +function evaluate(x::RealPolyRingElem, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() ccall((:arb_poly_evaluate, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealPoly}, Ref{RealFieldElem}, Int), + (Ref{RealFieldElem}, Ref{RealPolyRingElem}, Ref{RealFieldElem}, Int), z, x, y, prec) return z end -function evaluate(x::RealPoly, y::AcbFieldElem, prec::Int = precision(Balls)) +function evaluate(x::RealPolyRingElem, y::AcbFieldElem, prec::Int = precision(Balls)) z = parent(y)() ccall((:arb_poly_evaluate_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{RealPoly}, Ref{AcbFieldElem}, Int), + (Ref{AcbFieldElem}, Ref{RealPolyRingElem}, Ref{AcbFieldElem}, Int), z, x, y, prec) return z end -evaluate(x::RealPoly, y::RingElement) = evaluate(x, base_ring(parent(x))(y)) -evaluate(x::RealPoly, y::Integer) = evaluate(x, base_ring(parent(x))(y)) -evaluate(x::RealPoly, y::Rational) = evaluate(x, base_ring(parent(x))(y)) -evaluate(x::RealPoly, y::Float64) = evaluate(x, base_ring(parent(x))(y)) -evaluate(x::RealPoly, y::Any) = evaluate(x, base_ring(parent(x))(y)) +evaluate(x::RealPolyRingElem, y::RingElement) = evaluate(x, base_ring(parent(x))(y)) +evaluate(x::RealPolyRingElem, y::Integer) = evaluate(x, base_ring(parent(x))(y)) +evaluate(x::RealPolyRingElem, y::Rational) = evaluate(x, base_ring(parent(x))(y)) +evaluate(x::RealPolyRingElem, y::Float64) = evaluate(x, base_ring(parent(x))(y)) +evaluate(x::RealPolyRingElem, y::Any) = evaluate(x, base_ring(parent(x))(y)) @doc raw""" - evaluate2(x::RealPoly, y::RingElement) + evaluate2(x::RealPolyRingElem, y::RingElement) Return a tuple $p, q$ consisting of the polynomial $x$ evaluated at $y$ and its derivative evaluated at $y$. """ -function evaluate2(x::RealPoly, y::RealFieldElem, prec::Int = precision(Balls)) +function evaluate2(x::RealPolyRingElem, y::RealFieldElem, prec::Int = precision(Balls)) z = parent(y)() w = parent(y)() ccall((:arb_poly_evaluate2, libflint), Nothing, - (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealPoly}, Ref{RealFieldElem}, Int), + (Ref{RealFieldElem}, Ref{RealFieldElem}, Ref{RealPolyRingElem}, Ref{RealFieldElem}, Int), z, w, x, y, prec) return z, w end -function evaluate2(x::RealPoly, y::ComplexFieldElem, prec::Int = precision(Balls)) +function evaluate2(x::RealPolyRingElem, y::ComplexFieldElem, prec::Int = precision(Balls)) z = parent(y)() w = parent(y)() ccall((:arb_poly_evaluate2_acb, libflint), Nothing, - (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{RealPoly}, Ref{AcbFieldElem}, Int), + (Ref{AcbFieldElem}, Ref{AcbFieldElem}, Ref{RealPolyRingElem}, Ref{AcbFieldElem}, Int), z, w, x, y, prec) return z, w end -function evaluate2(x::RealPoly, y::RingElement) +function evaluate2(x::RealPolyRingElem, y::RingElement) return evaluate2(x, base_ring(parent(x))(y)) end @@ -425,7 +425,7 @@ end # ############################################################################### -function compose(x::RealPoly, y::RealPoly, prec::Int = precision(Balls); inner::Symbol) +function compose(x::RealPolyRingElem, y::RealPolyRingElem, prec::Int = precision(Balls); inner::Symbol) if inner == :first x, y = y, x end @@ -433,7 +433,7 @@ function compose(x::RealPoly, y::RealPoly, prec::Int = precision(Balls); inner:: z = parent(x)() ccall((:arb_poly_compose, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, y, prec) return z end @@ -444,17 +444,17 @@ end # ############################################################################### -function derivative(x::RealPoly, prec::Int = precision(Balls)) +function derivative(x::RealPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() ccall((:arb_poly_derivative, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Int), z, x, prec) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, prec) return z end -function integral(x::RealPoly, prec::Int = precision(Balls)) +function integral(x::RealPolyRingElem, prec::Int = precision(Balls)) z = parent(x)() ccall((:arb_poly_integral, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Int), z, x, prec) + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, prec) return z end @@ -500,19 +500,19 @@ function from_roots(R::RealPolyRing, b::Vector{RealFieldElem}, prec::Int = preci z = R() tmp = arb_vec(b) ccall((:arb_poly_product_roots, libflint), Nothing, - (Ref{RealPoly}, Ptr{arb_struct}, Int, Int), z, tmp, length(b), prec) + (Ref{RealPolyRingElem}, Ptr{arb_struct}, Int, Int), z, tmp, length(b), prec) arb_vec_clear(tmp, length(b)) return z end -function evaluate_iter(x::RealPoly, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) +function evaluate_iter(x::RealPolyRingElem, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) return RealFieldElem[evaluate(x, b[i]) for i=1:length(b)] end -function evaluate_fast(x::RealPoly, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) +function evaluate_fast(x::RealPolyRingElem, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) tmp = arb_vec(b) ccall((:arb_poly_evaluate_vec_fast, libflint), Nothing, - (Ptr{arb_struct}, Ref{RealPoly}, Ptr{arb_struct}, Int, Int), + (Ptr{arb_struct}, Ref{RealPolyRingElem}, Ptr{arb_struct}, Int, Int), tmp, x, tmp, length(b), prec) res = array(base_ring(parent(x)), tmp, length(b)) arb_vec_clear(tmp, length(b)) @@ -525,7 +525,7 @@ function interpolate_newton(R::RealPolyRing, xs::Vector{RealFieldElem}, ys::Vect xsv = arb_vec(xs) ysv = arb_vec(ys) ccall((:arb_poly_interpolate_newton, libflint), Nothing, - (Ref{RealPoly}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), + (Ref{RealPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), z, xsv, ysv, length(xs), prec) arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) @@ -538,7 +538,7 @@ function interpolate_barycentric(R::RealPolyRing, xs::Vector{RealFieldElem}, ys: xsv = arb_vec(xs) ysv = arb_vec(ys) ccall((:arb_poly_interpolate_barycentric, libflint), Nothing, - (Ref{RealPoly}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), + (Ref{RealPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), z, xsv, ysv, length(xs), prec) arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) @@ -551,7 +551,7 @@ function interpolate_fast(R::RealPolyRing, xs::Vector{RealFieldElem}, ys::Vector xsv = arb_vec(xs) ysv = arb_vec(ys) ccall((:arb_poly_interpolate_fast, libflint), Nothing, - (Ref{RealPoly}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), + (Ref{RealPolyRingElem}, Ptr{arb_struct}, Ptr{arb_struct}, Int, Int), z, xsv, ysv, length(xs), prec) arb_vec_clear(xsv, length(xs)) arb_vec_clear(ysv, length(ys)) @@ -564,7 +564,7 @@ function interpolate(R::RealPolyRing, xs::Vector{RealFieldElem}, ys::Vector{Real end # todo: cutoffs for fast algorithm -function evaluate(x::RealPoly, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) +function evaluate(x::RealPolyRingElem, b::Vector{RealFieldElem}, prec::Int = precision(Balls)) return evaluate_iter(x, b, prec) end @@ -575,17 +575,17 @@ end ############################################################################### @doc raw""" - roots_upper_bound(x::RealPoly) -> ArbFieldElem + roots_upper_bound(x::RealPolyRingElem) -> ArbFieldElem Returns an upper bound for the absolute value of all complex roots of $x$. """ -function roots_upper_bound(x::RealPoly) +function roots_upper_bound(x::RealPolyRingElem) z = base_ring(x)() p = precision(Balls) GC.@preserve x z begin t = ccall((:arb_rad_ptr, libflint), Ptr{mag_struct}, (Ref{RealFieldElem}, ), z) ccall((:arb_poly_root_bound_fujiwara, libflint), Nothing, - (Ptr{mag_struct}, Ref{RealPoly}), t, x) + (Ptr{mag_struct}, Ref{RealPolyRingElem}), t, x) s = ccall((:arb_mid_ptr, libflint), Ptr{arf_struct}, (Ref{RealFieldElem}, ), z) ccall((:arf_set_mag, libflint), Nothing, (Ptr{arf_struct}, Ptr{mag_struct}), s, t) ccall((:arf_set_round, libflint), Nothing, @@ -601,47 +601,47 @@ end # ############################################################################### -function zero!(z::RealPoly) +function zero!(z::RealPolyRingElem) ccall((:arb_poly_zero, libflint), Nothing, - (Ref{RealPoly}, ), z) + (Ref{RealPolyRingElem}, ), z) return z end -function fit!(z::RealPoly, n::Int) +function fit!(z::RealPolyRingElem, n::Int) ccall((:arb_poly_fit_length, libflint), Nothing, - (Ref{RealPoly}, Int), z, n) + (Ref{RealPolyRingElem}, Int), z, n) return nothing end -function setcoeff!(z::RealPoly, n::Int, x::ZZRingElem) +function setcoeff!(z::RealPolyRingElem, n::Int, x::ZZRingElem) ccall((:arb_poly_set_coeff_fmpz, libflint), Nothing, - (Ref{RealPoly}, Int, Ref{ZZRingElem}), z, n, x) + (Ref{RealPolyRingElem}, Int, Ref{ZZRingElem}), z, n, x) return z end -function setcoeff!(z::RealPoly, n::Int, x::RealFieldElem) +function setcoeff!(z::RealPolyRingElem, n::Int, x::RealFieldElem) ccall((:arb_poly_set_coeff_arb, libflint), Nothing, - (Ref{RealPoly}, Int, Ref{RealFieldElem}), z, n, x) + (Ref{RealPolyRingElem}, Int, Ref{RealFieldElem}), z, n, x) return z end -function mul!(z::RealPoly, x::RealPoly, y::RealPoly) +function mul!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem) ccall((:arb_poly_mul, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, y, precision(parent(z))) return z end -function addeq!(z::RealPoly, x::RealPoly) +function addeq!(z::RealPolyRingElem, x::RealPolyRingElem) ccall((:arb_poly_add, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, z, x, precision(parent(z))) return z end -function add!(z::RealPoly, x::RealPoly, y::RealPoly) +function add!(z::RealPolyRingElem, x::RealPolyRingElem, y::RealPolyRingElem) ccall((:arb_poly_add, libflint), Nothing, - (Ref{RealPoly}, Ref{RealPoly}, Ref{RealPoly}, Int), + (Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Ref{RealPolyRingElem}, Int), z, x, y, precision(parent(z))) return z end @@ -652,23 +652,23 @@ end # ############################################################################### -promote_rule(::Type{RealPoly}, ::Type{Float64}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{Float64}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{BigFloat}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{BigFloat}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{ZZRingElem}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{ZZRingElem}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{QQFieldElem}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{QQFieldElem}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{RealFieldElem}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{RealFieldElem}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{ZZPolyRingElem}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{ZZPolyRingElem}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{QQPolyRingElem}) = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{QQPolyRingElem}) = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{T}) where {T <: Integer} = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{T}) where {T <: Integer} = RealPolyRingElem -promote_rule(::Type{RealPoly}, ::Type{Rational{T}}) where T <: Union{Int, BigInt} = RealPoly +promote_rule(::Type{RealPolyRingElem}, ::Type{Rational{T}}) where T <: Union{Int, BigInt} = RealPolyRingElem ################################################################################ # @@ -677,7 +677,7 @@ promote_rule(::Type{RealPoly}, ::Type{Rational{T}}) where T <: Union{Int, BigInt ################################################################################ function (a::RealPolyRing)() - z = RealPoly() + z = RealPolyRingElem() z.parent = a return z end @@ -685,7 +685,7 @@ end for T in [Real, ZZRingElem, QQFieldElem, RealFieldElem] @eval begin function (a::RealPolyRing)(b::$T) - z = RealPoly(base_ring(a)(b), precision(Balls)) + z = RealPolyRingElem(base_ring(a)(b), precision(Balls)) z.parent = a return z end @@ -693,7 +693,7 @@ for T in [Real, ZZRingElem, QQFieldElem, RealFieldElem] end function (a::RealPolyRing)(b::Vector{RealFieldElem}) - z = RealPoly(b, precision(Balls)) + z = RealPolyRingElem(b, precision(Balls)) z.parent = a return z end @@ -705,19 +705,19 @@ for T in [Real, ZZRingElem, QQFieldElem, RealFieldElem] end function (a::RealPolyRing)(b::ZZPolyRingElem) - z = RealPoly(b, precision(Balls)) + z = RealPolyRingElem(b, precision(Balls)) z.parent = a return z end function (a::RealPolyRing)(b::QQPolyRingElem) - z = RealPoly(b, precision(Balls)) + z = RealPolyRingElem(b, precision(Balls)) z.parent = a return z end -function (a::RealPolyRing)(b::RealPoly) - z = RealPoly(b, precision(Balls)) +function (a::RealPolyRing)(b::RealPolyRingElem) + z = RealPolyRingElem(b, precision(Balls)) z.parent = a return z end diff --git a/src/arb/acb_mat.jl b/src/arb/acb_mat.jl index 53b95bdb1..f0b606435 100644 --- a/src/arb/acb_mat.jl +++ b/src/arb/acb_mat.jl @@ -28,7 +28,7 @@ base_ring(a::AcbMatrix) = a.base_ring dense_matrix_type(::Type{AcbFieldElem}) = AcbMatrix -precision(x::AcbMatSpace) = precision(base_ring(x)) +precision(x::AcbMatrixSpace) = precision(base_ring(x)) function getindex!(z::AcbFieldElem, x::AcbMatrix, r::Int, c::Int) GC.@preserve x begin @@ -82,7 +82,7 @@ end setindex!(x::AcbMatrix, y::Tuple{Rational{T}, Rational{T}}, r::Int, c::Int) where {T <: Integer} = setindex!(x, map(QQFieldElem, y), r, c) -function one(x::AcbMatSpace) +function one(x::AcbMatrixSpace) z = x() ccall((:acb_mat_one, libflint), Nothing, (Ref{AcbMatrix}, ), z) return z @@ -742,13 +742,13 @@ end # ############################################################################### -function (x::AcbMatSpace)() +function (x::AcbMatrixSpace)() z = AcbMatrix(nrows(x), ncols(x)) z.base_ring = x.base_ring return z end -function (x::AcbMatSpace)(y::ZZMatrix) +function (x::AcbMatrixSpace)(y::ZZMatrix) (ncols(x) != ncols(y) || nrows(x) != nrows(y)) && error("Dimensions are wrong") z = AcbMatrix(y, precision(x)) @@ -756,7 +756,7 @@ function (x::AcbMatSpace)(y::ZZMatrix) return z end -function (x::AcbMatSpace)(y::ArbMatrix) +function (x::AcbMatrixSpace)(y::ArbMatrix) (ncols(x) != ncols(y) || nrows(x) != nrows(y)) && error("Dimensions are wrong") z = AcbMatrix(y, precision(x)) @@ -766,14 +766,14 @@ end for T in [Float64, ZZRingElem, QQFieldElem, BigFloat, ArbFieldElem, AcbFieldElem, String] @eval begin - function (x::AcbMatSpace)(y::AbstractMatrix{$T}) + function (x::AcbMatrixSpace)(y::AbstractMatrix{$T}) _check_dim(nrows(x), ncols(x), y) z = AcbMatrix(nrows(x), ncols(x), y, precision(x)) z.base_ring = x.base_ring return z end - function (x::AcbMatSpace)(y::AbstractVector{$T}) + function (x::AcbMatrixSpace)(y::AbstractVector{$T}) _check_dim(nrows(x), ncols(x), y) z = AcbMatrix(nrows(x), ncols(x), y, precision(x)) z.base_ring = x.base_ring @@ -782,24 +782,24 @@ for T in [Float64, ZZRingElem, QQFieldElem, BigFloat, ArbFieldElem, AcbFieldElem end end -(x::AcbMatSpace)(y::AbstractMatrix{T}) where {T <: Integer} = x(map(ZZRingElem, y)) +(x::AcbMatrixSpace)(y::AbstractMatrix{T}) where {T <: Integer} = x(map(ZZRingElem, y)) -(x::AcbMatSpace)(y::AbstractVector{T}) where {T <: Integer} = x(map(ZZRingElem, y)) +(x::AcbMatrixSpace)(y::AbstractVector{T}) where {T <: Integer} = x(map(ZZRingElem, y)) -(x::AcbMatSpace)(y::AbstractMatrix{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) +(x::AcbMatrixSpace)(y::AbstractMatrix{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) -(x::AcbMatSpace)(y::AbstractVector{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) +(x::AcbMatrixSpace)(y::AbstractVector{Rational{T}}) where {T <: Integer} = x(map(QQFieldElem, y)) for T in [Float64, ZZRingElem, QQFieldElem, BigFloat, ArbFieldElem, String] @eval begin - function (x::AcbMatSpace)(y::AbstractMatrix{Tuple{$T, $T}}) + function (x::AcbMatrixSpace)(y::AbstractMatrix{Tuple{$T, $T}}) _check_dim(nrows(x), ncols(x), y) z = AcbMatrix(nrows(x), ncols(x), y, precision(x)) z.base_ring = x.base_ring return z end - function (x::AcbMatSpace)(y::AbstractVector{Tuple{$T, $T}}) + function (x::AcbMatrixSpace)(y::AbstractVector{Tuple{$T, $T}}) _check_dim(nrows(x), ncols(x), y) z = AcbMatrix(nrows(x), ncols(x), y, precision(x)) z.base_ring = x.base_ring @@ -808,21 +808,21 @@ for T in [Float64, ZZRingElem, QQFieldElem, BigFloat, ArbFieldElem, String] end end -(x::AcbMatSpace)(y::AbstractMatrix{Tuple{T, T}}) where {T <: Integer} = +(x::AcbMatrixSpace)(y::AbstractMatrix{Tuple{T, T}}) where {T <: Integer} = x(map(z -> (ZZRingElem(z[1]), ZZRingElem(z[2])), y)) -(x::AcbMatSpace)(y::AbstractVector{Tuple{T, T}}) where {T <: Integer} = +(x::AcbMatrixSpace)(y::AbstractVector{Tuple{T, T}}) where {T <: Integer} = x(map(z -> (ZZRingElem(z[1]), ZZRingElem(z[2])), y)) -(x::AcbMatSpace)(y::AbstractMatrix{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = +(x::AcbMatrixSpace)(y::AbstractMatrix{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = x(map(z -> (QQFieldElem(z[1]), QQFieldElem(z[2])), y)) -(x::AcbMatSpace)(y::AbstractVector{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = +(x::AcbMatrixSpace)(y::AbstractVector{Tuple{Rational{T}, Rational{T}}}) where {T <: Integer} = x(map(z -> (QQFieldElem(z[1]), QQFieldElem(z[2])), y)) for T in [Integer, ZZRingElem, QQFieldElem, Float64, BigFloat, ArbFieldElem, AcbFieldElem, String] @eval begin - function (x::AcbMatSpace)(y::$T) + function (x::AcbMatrixSpace)(y::$T) z = x() for i in 1:nrows(z) for j = 1:ncols(z) @@ -838,7 +838,7 @@ for T in [Integer, ZZRingElem, QQFieldElem, Float64, BigFloat, ArbFieldElem, Acb end end -(x::AcbMatSpace)(y::Rational{T}) where {T <: Integer} = x(QQFieldElem(y)) +(x::AcbMatrixSpace)(y::Rational{T}) where {T <: Integer} = x(QQFieldElem(y)) ############################################################################### # diff --git a/src/arb/arb_mat.jl b/src/arb/arb_mat.jl index b0357da4f..8f99e7a51 100644 --- a/src/arb/arb_mat.jl +++ b/src/arb/arb_mat.jl @@ -28,7 +28,7 @@ base_ring(a::ArbMatrix) = a.base_ring dense_matrix_type(::Type{ArbFieldElem}) = ArbMatrix -precision(x::ArbMatSpace) = precision(x.base_ring) +precision(x::ArbMatrixSpace) = precision(x.base_ring) function getindex!(z::ArbFieldElem, x::ArbMatrix, r::Int, c::Int) GC.@preserve x begin @@ -70,7 +70,7 @@ Base.@propagate_inbounds setindex!(x::ArbMatrix, y::Rational{T}, r::Int, c::Int) where {T <: Integer} = setindex!(x, ZZRingElem(y), r, c) -function one(x::ArbMatSpace) +function one(x::ArbMatrixSpace) z = x() ccall((:arb_mat_one, libflint), Nothing, (Ref{ArbMatrix}, ), z) return z @@ -709,13 +709,13 @@ end # ############################################################################### -function (x::ArbMatSpace)() +function (x::ArbMatrixSpace)() z = ArbMatrix(nrows(x), ncols(x)) z.base_ring = x.base_ring return z end -function (x::ArbMatSpace)(y::ZZMatrix) +function (x::ArbMatrixSpace)(y::ZZMatrix) (ncols(x) != ncols(y) || nrows(x) != nrows(y)) && error("Dimensions are wrong") z = ArbMatrix(y, precision(x)) @@ -723,14 +723,14 @@ function (x::ArbMatSpace)(y::ZZMatrix) return z end -function (x::ArbMatSpace)(y::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, ArbFieldElem, AbstractString}} +function (x::ArbMatrixSpace)(y::AbstractMatrix{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, ArbFieldElem, AbstractString}} _check_dim(nrows(x), ncols(x), y) z = ArbMatrix(nrows(x), ncols(x), y, precision(x)) z.base_ring = x.base_ring return z end -function (x::ArbMatSpace)(y::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, ArbFieldElem, AbstractString}} +function (x::ArbMatrixSpace)(y::AbstractVector{T}) where {T <: Union{Int, UInt, ZZRingElem, QQFieldElem, Float64, BigFloat, ArbFieldElem, AbstractString}} _check_dim(nrows(x), ncols(x), y) z = ArbMatrix(nrows(x), ncols(x), y, precision(x)) z.base_ring = x.base_ring diff --git a/src/matrix.jl b/src/matrix.jl index 046f7aea5..4ab4361ce 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -371,6 +371,6 @@ end # ############################################################################### -function norm(v::Union{AcbMatrix, ArbMatrix, ComplexMat, RealMat}) +function norm(v::Union{AcbMatrix, ArbMatrix, ComplexMatrix, RealMatrix}) return sqrt(sum(a^2 for a in v; init=zero(base_ring(v)))) end diff --git a/src/polysubst.jl b/src/polysubst.jl index a45cfdde9..d4ed10d2e 100644 --- a/src/polysubst.jl +++ b/src/polysubst.jl @@ -10,8 +10,8 @@ for T in [ FqPolyRingElem, AcbPolyRingElem, ArbPolyRingElem, - ComplexPoly, - RealPoly, + ComplexPolyRingElem, + RealPolyRingElem, ] (f::T)(a) = subst(f, a) diff --git a/test/Rings-test.jl b/test/Rings-test.jl index 464495623..1023963bb 100644 --- a/test/Rings-test.jl +++ b/test/Rings-test.jl @@ -6,8 +6,8 @@ const ring_to_mat = Dict(ZZ => ZZMatrix, finite_field(ZZRingElem(3), 2, "b")[1] => FqPolyRepMatrix, ArbField() => ArbMatrix, AcbField() => AcbMatrix, - RealField() => RealMat, - ComplexField() => ComplexMat, + RealField() => RealMatrix, + ComplexField() => ComplexMatrix, ) include("flint/fmpz-test.jl") diff --git a/test/arb/ComplexMat-test.jl b/test/arb/ComplexMat-test.jl index 768bf75b9..1eff58fad 100644 --- a/test/arb/ComplexMat-test.jl +++ b/test/arb/ComplexMat-test.jl @@ -1,24 +1,24 @@ CC = ComplexField() RR = RealField() -@testset "ComplexMat.constructors" begin +@testset "ComplexMatrix.constructors" begin @test_throws ErrorException matrix_space(CC, -1, 5) @test_throws ErrorException matrix_space(CC, 0, -2) @test_throws ErrorException matrix_space(CC, -3, -4) - @test_throws ErrorException ComplexMatSpace(CC, 2, -1) - @test_throws ErrorException ComplexMatSpace(CC, -1, 2) - @test_throws ErrorException ComplexMatSpace(CC, -1, -1) + @test_throws ErrorException ComplexMatrixSpace(CC, 2, -1) + @test_throws ErrorException ComplexMatrixSpace(CC, -1, 2) + @test_throws ErrorException ComplexMatrixSpace(CC, -1, -1) S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) - @test elem_type(S) == ComplexMat - @test elem_type(ComplexMatSpace) == ComplexMat - @test parent_type(ComplexMat) == ComplexMatSpace + @test elem_type(S) == ComplexMatrix + @test elem_type(ComplexMatrixSpace) == ComplexMatrix + @test parent_type(ComplexMatrix) == ComplexMatrixSpace @test nrows(S) == 3 @test ncols(S) == 3 - @test isa(S, ComplexMatSpace) + @test isa(S, ComplexMatrixSpace) f = S(ZZRingElem(3)) @@ -70,13 +70,13 @@ RR = RealField() for T in [ZZRingElem, QQFieldElem, Int, BigInt, Float64, BigFloat, RR, CC, string, Rational{Int}, Rational{BigInt}] M = matrix(CC, map(T, arr)) - @test isa(M, ComplexMat) + @test isa(M, ComplexMatrix) @test base_ring(M) == CC @test nrows(M) == 2 @test ncols(M) == 2 M2 = matrix(CC, 2, 3, map(T, arr2)) - @test isa(M2, ComplexMat) + @test isa(M2, ComplexMatrix) @test base_ring(M2) == CC @test nrows(M2) == 2 @test ncols(M2) == 3 @@ -86,12 +86,12 @@ RR = RealField() M3 = zero_matrix(CC, 2, 3) - @test isa(M3, ComplexMat) + @test isa(M3, ComplexMatrix) @test base_ring(M3) == CC M4 = identity_matrix(CC, 3) - @test isa(M4, ComplexMat) + @test isa(M4, ComplexMatrix) @test base_ring(M4) == CC a = zero_matrix(CC, 2, 2) @@ -101,16 +101,16 @@ RR = RealField() @test !(a in [b]) end -@testset "ComplexMat.similar" begin +@testset "ComplexMatrix.similar" begin S = matrix_space(CC, 3, 3) s = S(ZZRingElem(3)) t = similar(s) - @test t isa ComplexMat + @test t isa ComplexMatrix @test size(t) == size(s) t = similar(s, 2, 3) - @test t isa ComplexMat + @test t isa ComplexMatrix @test size(t) == (2, 3) for (R, M) in ring_to_mat @@ -128,7 +128,7 @@ end end end -@testset "ComplexMat.printing" begin +@testset "ComplexMatrix.printing" begin S = matrix_space(CC, 3, 3) f = S(ZZRingElem(3)) @@ -136,7 +136,7 @@ end @test !occursin(string(typeof(f)), string(f)) end -@testset "ComplexMat.manipulation" begin +@testset "ComplexMatrix.manipulation" begin S = matrix_space(CC, 3, 3) A = S([ZZRingElem(2) 3 5; 1 4 7; 9 6 3]) B = S([ZZRingElem(1) 4 7; 9 6 7; 4 3 3]) @@ -154,7 +154,7 @@ end @test deepcopy(A) == A end -@testset "ComplexMat.unary_ops" begin +@testset "ComplexMatrix.unary_ops" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -164,7 +164,7 @@ end @test contains(-A, B) end -@testset "ComplexMat.transpose" begin +@testset "ComplexMatrix.transpose" begin S = matrix_space(CC, 3, 3) T = matrix_space(ZZ, 3, 3) @@ -179,7 +179,7 @@ end @test overlaps(transpose(C), C) end -@testset "ComplexMat.binary_ops" begin +@testset "ComplexMatrix.binary_ops" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -193,7 +193,7 @@ end @test contains(A*B, R([49 41 50; 65 49 56; 75 81 114])) end -@testset "ComplexMat.adhoc_binary" begin +@testset "ComplexMatrix.adhoc_binary" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) T = matrix_space(QQ, 3, 3) @@ -254,7 +254,7 @@ end end end -@testset "ComplexMat.shifting" begin +@testset "ComplexMatrix.shifting" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -267,7 +267,7 @@ end @test contains(C, 16*B) end -@testset "ComplexMat.comparison" begin +@testset "ComplexMatrix.comparison" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -289,7 +289,7 @@ end @test contains(C, A) end -@testset "ComplexMat.adhoc_comparison" begin +@testset "ComplexMatrix.adhoc_comparison" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) T = matrix_space(QQ, 3, 3) @@ -310,7 +310,7 @@ end @test B == A end -@testset "ComplexMat.predicates" begin +@testset "ComplexMatrix.predicates" begin S = matrix_space(CC, 3, 3) A = S([1 2 1000; 0 3 1; 0 2 1]) @@ -321,7 +321,7 @@ end @test !isreal(A) end -@testset "ComplexMat.inversion" begin +@testset "ComplexMatrix.inversion" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -342,7 +342,7 @@ end @test_throws ErrorException inv(A) end -@testset "ComplexMat.divexact" begin +@testset "ComplexMatrix.divexact" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -353,7 +353,7 @@ end @test contains(divexact(one(S), A), B) end -@testset "ComplexMat.adhoc_divexact" begin +@testset "ComplexMatrix.adhoc_divexact" begin S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -368,7 +368,7 @@ end @test contains(divexact(A, CC("3.0 +/- 0.5")), B) end -@testset "ComplexMat.charpoly" begin +@testset "ComplexMatrix.charpoly" begin S = matrix_space(CC, 3, 3) R, x = polynomial_ring(CC, "x") ZZy, y = polynomial_ring(ZZ, "y") @@ -384,7 +384,7 @@ end @test contains(g, f) end -@testset "ComplexMat.det" begin +@testset "ComplexMatrix.det" begin S = matrix_space(CC, 3, 3) A = S(["2.0 +/- 0.1" "3.0 +/- 0.1" "5.0 +/- 0.1"; @@ -396,7 +396,7 @@ end @test contains(d, 24) end -@testset "ComplexMat.exp" begin +@testset "ComplexMatrix.exp" begin S = matrix_space(CC, 3, 3) A = S(["2.0 +/- 0.1" "0.0 +/- 0.1" "0.0 +/- 0.1"; @@ -410,7 +410,7 @@ end @test overlaps(B, C) end -@testset "ComplexMat.lu_nonsquare" begin +@testset "ComplexMatrix.lu_nonsquare" begin S = matrix_space(CC, 2, 3) A = S(["1.0 +/- 0.01" "1.0 +/- 0.01" "1.0 +/- 0.01"; @@ -422,7 +422,7 @@ end @test r == 2 end -@testset "ComplexMat.linear_solving" begin +@testset "ComplexMatrix.linear_solving" begin S = matrix_space(CC, 3, 3) T = matrix_space(ZZ, 3, 3) @@ -448,7 +448,7 @@ end @test contains(transpose(y), ZZ[1 1 1]) end -@testset "ComplexMat.Solve.solve" begin +@testset "ComplexMatrix.Solve.solve" begin S = matrix_space(CC, 3, 3) A = S(["1.0 +/- 0.01" "2.0 +/- 0.01" "3.0 +/- 0.01"; @@ -515,7 +515,7 @@ end @test contains(transpose(y), ZZ[2 2 2]) end -@testset "ComplexMat.bound_inf_norm" begin +@testset "ComplexMatrix.bound_inf_norm" begin S = matrix_space(CC, 3, 3) A = S([2 3 5; 1 4 7; 9 6 3]) @@ -529,7 +529,7 @@ end end end -@testset "ComplexMat.eigenvalues" begin +@testset "ComplexMatrix.eigenvalues" begin A = matrix(CC, 3, 3, [1, 2, 3, 0, 4, 5, 0, 0, 6]) E = @inferred eigenvalues(A) @@ -567,7 +567,7 @@ end @test_throws ErrorException @inferred eigenvalues_simple(A) end -@testset "ComplexMat.norm" begin +@testset "ComplexMatrix.norm" begin A = matrix(CC, [2 3 5; 1 4 7; 9 6 3]) @test contains(norm(A), sqrt(CC(230))) diff --git a/test/arb/ComplexPoly-test.jl b/test/arb/ComplexPoly-test.jl index 84497ec0b..b22cc803e 100644 --- a/test/arb/ComplexPoly-test.jl +++ b/test/arb/ComplexPoly-test.jl @@ -6,7 +6,7 @@ coeff_types = [Int8, Int, UInt, BigInt, Complex{Int8}, Complex{Float32}, Complex{BigInt}, Complex{Rational{BigInt}}, ZZRingElem, QQFieldElem] -@testset "ComplexPoly.constructors" begin +@testset "ComplexPolyRingElem.constructors" begin S1 = PolyRing(CC) S2 = PolyRing(CC) @@ -15,10 +15,10 @@ coeff_types = [Int8, Int, UInt, BigInt, R, x = polynomial_ring(CC, "x") - @test elem_type(R) == ComplexPoly - @test elem_type(ComplexPolyRing) == ComplexPoly - @test parent_type(ComplexPoly) == ComplexPolyRing - @test dense_poly_type(ComplexFieldElem) == ComplexPoly + @test elem_type(R) == ComplexPolyRingElem + @test elem_type(ComplexPolyRing) == ComplexPolyRingElem + @test parent_type(ComplexPolyRingElem) == ComplexPolyRing + @test dense_poly_type(ComplexFieldElem) == ComplexPolyRingElem @test typeof(R) <: ComplexPolyRing @@ -53,7 +53,7 @@ coeff_types = [Int8, Int, UInt, BigInt, end end -@testset "ComplexPoly.printing" begin +@testset "ComplexPolyRingElem.printing" begin R, x = polynomial_ring(CC, "x") f = x^3 + 2x^2 + x + 1 @@ -61,7 +61,7 @@ end @test occursin(r"2.[0]+", string(f)) end -@testset "ComplexPoly.manipulation" begin +@testset "ComplexPolyRingElem.manipulation" begin R, x = polynomial_ring(CC, "x") @test iszero(zero(R)) @@ -91,7 +91,7 @@ end @test characteristic(R) == 0 end -@testset "ComplexPoly.binary_ops" begin +@testset "ComplexPolyRingElem.binary_ops" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -104,7 +104,7 @@ end @test f - g == -x^3+x^2-x-1 end -@testset "ComplexPoly.adhoc_binary" begin +@testset "ComplexPolyRingElem.adhoc_binary" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -131,7 +131,7 @@ end end end -@testset "ComplexPoly.comparison" begin +@testset "ComplexPolyRingElem.comparison" begin R, x = polynomial_ring(CC, "x") Zx, zx = polynomial_ring(ZZ, "x") Qx, qx = polynomial_ring(QQ, "x") @@ -177,7 +177,7 @@ end @test !uniq end -@testset "ComplexPoly.adhoc_comparison" begin +@testset "ComplexPolyRingElem.adhoc_comparison" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -201,7 +201,7 @@ end @test R(7) == RR(7.0) end -@testset "ComplexPoly.unary_ops" begin +@testset "ComplexPolyRingElem.unary_ops" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -209,7 +209,7 @@ end @test -f == -x^2 - 2x - 1 end -@testset "ComplexPoly.truncation" begin +@testset "ComplexPolyRingElem.truncation" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -224,7 +224,7 @@ end @test_throws DomainError mullow(f, g, -1) end -@testset "ComplexPoly.reverse" begin +@testset "ComplexPolyRingElem.reverse" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 3 @@ -232,7 +232,7 @@ end #@test reverse(f) == 3x^2 + 2x + 1 end -@testset "ComplexPoly.shift" begin +@testset "ComplexPolyRingElem.shift" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -246,7 +246,7 @@ end @test_throws DomainError shift_right(f, -1) end -@testset "ComplexPoly.powering" begin +@testset "ComplexPolyRingElem.powering" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -256,7 +256,7 @@ end @test_throws DomainError f^-1 end -@testset "ComplexPoly.exact_division" begin +@testset "ComplexPolyRingElem.exact_division" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -265,7 +265,7 @@ end @test divexact(f*g, f) == g end -@testset "ComplexPoly.scalar_division" begin +@testset "ComplexPolyRingElem.scalar_division" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -281,7 +281,7 @@ end @test divexact(2*f, 2.0) == f end -@testset "ComplexPoly.evaluation" begin +@testset "ComplexPolyRingElem.evaluation" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -307,7 +307,7 @@ end @test evaluate2(f, CC(10)) == (121, 22) end -@testset "ComplexPoly.roots" begin +@testset "ComplexPolyRingElem.roots" begin R, x = polynomial_ring(CC, "x") f = (x - 1)*(x - 2)*(x - CC("5 +/- 0.001")) @@ -319,7 +319,7 @@ end @test contains(r[3], 5) end -@testset "ComplexPoly.composition" begin +@testset "ComplexPolyRingElem.composition" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -328,7 +328,7 @@ end @test compose(f, g; inner = :second) == x^6+6*x^4+4*x^3+9*x^2+12*x+4 end -@testset "ComplexPoly.derivative_integral" begin +@testset "ComplexPolyRingElem.derivative_integral" begin R, x = polynomial_ring(CC, "x") f = x^2 + 2x + 1 @@ -338,7 +338,7 @@ end @test contains(derivative(integral(f)), f) end -@testset "ComplexPoly.evaluation_interpolation" begin +@testset "ComplexPolyRingElem.evaluation_interpolation" begin R, x = polynomial_ring(CC, "x") n = 5 @@ -382,7 +382,7 @@ end end end -@testset "ComplexPoly.root_bound" begin +@testset "ComplexPolyRingElem.root_bound" begin Rx, x = polynomial_ring(CC, "x") for i in 1:2 @@ -399,5 +399,5 @@ end R, t = polynomial_ring(CC, "t") D, Dt = polynomial_ring(R, "Dt") A_scalarform = t^3 * (32 * t^2 - 1) * (32 * t^2 + 1) * Dt^4 + 2 * t^2 * (7168 * t^4 - 3) * Dt^3 + t * (55296 * t^4 - 7) * Dt^2 + (61440 * t^4 - 1) * Dt + 12288 * t^3 - @test A_scalarform isa PolyRingElem{ComplexPoly} + @test A_scalarform isa PolyRingElem{ComplexPolyRingElem} end diff --git a/test/arb/RealMat-test.jl b/test/arb/RealMat-test.jl index 68e41d59c..104c16135 100644 --- a/test/arb/RealMat-test.jl +++ b/test/arb/RealMat-test.jl @@ -1,23 +1,23 @@ RR = RealField() -@testset "RealMat.constructors" begin +@testset "RealMatrix.constructors" begin @test_throws ErrorException matrix_space(RR, -1, 5) @test_throws ErrorException matrix_space(RR, 0, -2) @test_throws ErrorException matrix_space(RR, -3, -4) - @test_throws ErrorException RealMatSpace(RR, 2, -1) - @test_throws ErrorException RealMatSpace(RR, -1, 2) - @test_throws ErrorException RealMatSpace(RR, -1, -1) + @test_throws ErrorException RealMatrixSpace(RR, 2, -1) + @test_throws ErrorException RealMatrixSpace(RR, -1, 2) + @test_throws ErrorException RealMatrixSpace(RR, -1, -1) S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) - @test elem_type(S) == RealMat - @test elem_type(RealMatSpace) == RealMat - @test parent_type(RealMat) == RealMatSpace + @test elem_type(S) == RealMatrix + @test elem_type(RealMatrixSpace) == RealMatrix + @test parent_type(RealMatrix) == RealMatrixSpace @test nrows(S) == 3 @test ncols(S) == 3 - @test isa(S, RealMatSpace) + @test isa(S, RealMatrixSpace) f = S(ZZRingElem(3)) @@ -69,13 +69,13 @@ RR = RealField() for T in [ZZRingElem, QQFieldElem, Int, BigInt, Float64, BigFloat, RR, string, Rational{Int}, Rational{BigInt}] M = matrix(RR, map(T, arr)) - @test isa(M, RealMat) + @test isa(M, RealMatrix) @test base_ring(M) == RR @test nrows(M) == 2 @test ncols(M) == 2 M2 = matrix(RR, 2, 3, map(T, arr2)) - @test isa(M2, RealMat) + @test isa(M2, RealMatrix) @test base_ring(M2) == RR @test nrows(M2) == 2 @test ncols(M2) == 3 @@ -85,12 +85,12 @@ RR = RealField() M3 = zero_matrix(RR, 2, 3) - @test isa(M3, RealMat) + @test isa(M3, RealMatrix) @test base_ring(M3) == RR M4 = identity_matrix(RR, 3) - @test isa(M4, RealMat) + @test isa(M4, RealMatrix) @test base_ring(M4) == RR a = zero_matrix(RR, 2, 2) @@ -100,16 +100,16 @@ RR = RealField() @test !(a in [b]) end -@testset "RealMat.similar" begin +@testset "RealMatrix.similar" begin S = matrix_space(RR, 3, 3) s = S(ZZRingElem(3)) t = similar(s) - @test t isa RealMat + @test t isa RealMatrix @test size(t) == size(s) t = similar(s, 2, 3) - @test t isa RealMat + @test t isa RealMatrix @test size(t) == (2, 3) for (R, M) in ring_to_mat @@ -127,7 +127,7 @@ end end end -@testset "RealMat.printing" begin +@testset "RealMatrix.printing" begin S = matrix_space(RR, 3, 3) f = S(ZZRingElem(3)) @@ -135,7 +135,7 @@ end @test !occursin(string(typeof(f)), string(f)) end -@testset "RealMat.manipulation" begin +@testset "RealMatrix.manipulation" begin S = matrix_space(RR, 3, 3) A = S([ZZRingElem(2) 3 5; 1 4 7; 9 6 3]) B = S([ZZRingElem(1) 4 7; 9 6 7; 4 3 3]) @@ -157,7 +157,7 @@ end @test deepcopy(A) == A end -@testset "RealMat.unary_ops" begin +@testset "RealMatrix.unary_ops" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -167,7 +167,7 @@ end @test contains(-A, B) end -@testset "RealMat.transpose" begin +@testset "RealMatrix.transpose" begin S = matrix_space(RR, 3, 3) T = matrix_space(ZZ, 3, 3) @@ -182,7 +182,7 @@ end @test overlaps(transpose(C), C) end -@testset "RealMat.binary_ops" begin +@testset "RealMatrix.binary_ops" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -196,7 +196,7 @@ end @test contains(A*B, R([49 41 50; 65 49 56; 75 81 114])) end -@testset "RealMat.adhoc_binary" begin +@testset "RealMatrix.adhoc_binary" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) T = matrix_space(QQ, 3, 3) @@ -234,7 +234,7 @@ end @test contains(A*q, C*q) end -@testset "RealMat.shifting" begin +@testset "RealMatrix.shifting" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -247,7 +247,7 @@ end @test contains(C, 16*B) end -@testset "RealMat.comparison" begin +@testset "RealMatrix.comparison" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -269,7 +269,7 @@ end @test contains(C, A) end -@testset "RealMat.adhoc_comparison" begin +@testset "RealMatrix.adhoc_comparison" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) T = matrix_space(QQ, 3, 3) @@ -290,7 +290,7 @@ end @test B == A end -@testset "RealMat.inversion" begin +@testset "RealMatrix.inversion" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -311,7 +311,7 @@ end @test_throws ErrorException inv(A) end -@testset "RealMat.divexact" begin +@testset "RealMatrix.divexact" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -322,7 +322,7 @@ end @test contains(divexact(one(S), A), B) end -@testset "RealMat.adhoc_divexact" begin +@testset "RealMatrix.adhoc_divexact" begin S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @@ -334,7 +334,7 @@ end @test contains(divexact(A, RR("3.0 +/- 0.5")), B) end -@testset "RealMat.charpoly" begin +@testset "RealMatrix.charpoly" begin S = matrix_space(RR, 3, 3) R, x = polynomial_ring(RR, "x") ZZy, y = polynomial_ring(ZZ, "y") @@ -350,7 +350,7 @@ end @test contains(g, f) end -@testset "RealMat.det" begin +@testset "RealMatrix.det" begin S = matrix_space(RR, 3, 3) A = S(["2.0 +/- 0.1" "3.0 +/- 0.1" "5.0 +/- 0.1"; @@ -362,7 +362,7 @@ end @test contains(d, 24) end -@testset "RealMat.exp" begin +@testset "RealMatrix.exp" begin S = matrix_space(RR, 3, 3) A = S(["2.0 +/- 0.1" "0.0 +/- 0.1" "0.0 +/- 0.1"; @@ -376,7 +376,7 @@ end @test overlaps(B, C) end -@testset "RealMat.lu_nonsquare" begin +@testset "RealMatrix.lu_nonsquare" begin S = matrix_space(RR, 2, 3) A = S(["1.0 +/- 0.01" "1.0 +/- 0.01" "1.0 +/- 0.01"; @@ -388,7 +388,7 @@ end @test r == 2 end -@testset "RealMat.linear_solving" begin +@testset "RealMatrix.linear_solving" begin S = matrix_space(RR, 3, 3) T = matrix_space(ZZ, 3, 3) @@ -414,7 +414,7 @@ end @test contains(transpose(y), ZZ[1 1 1]) end -@testset "RealMat.Solve.solve" begin +@testset "RealMatrix.Solve.solve" begin S = matrix_space(RR, 3, 3) A = S(["1.0 +/- 0.01" "2.0 +/- 0.01" "3.0 +/- 0.01"; @@ -481,7 +481,7 @@ end @test contains(transpose(y), ZZ[2 2 2]) end -@testset "RealMat.bound_inf_norm" begin +@testset "RealMatrix.bound_inf_norm" begin S = matrix_space(RR, 3, 3) A = S([2 3 5; 1 4 7; 9 6 3]) @@ -495,7 +495,7 @@ end end end -@testset "RealMat.norm" begin +@testset "RealMatrix.norm" begin A = matrix(RR, [2 3 5; 1 4 7; 9 6 3]) @test contains(norm(A), sqrt(RR(230))) diff --git a/test/arb/RealPoly-test.jl b/test/arb/RealPoly-test.jl index 8fa2abffa..a0f0421ab 100644 --- a/test/arb/RealPoly-test.jl +++ b/test/arb/RealPoly-test.jl @@ -4,7 +4,7 @@ coeff_types = [Int8, Int, UInt, BigInt, Rational{Int8}, Rational{Int}, Rational{BigInt}, ZZRingElem, QQFieldElem] -@testset "RealPoly.constructors" begin +@testset "RealPolyRingElem.constructors" begin S1 = PolyRing(RR) S2 = PolyRing(RR) @@ -13,10 +13,10 @@ coeff_types = [Int8, Int, UInt, BigInt, R, x = polynomial_ring(RR, "x") - @test elem_type(R) == RealPoly - @test elem_type(RealPolyRing) == RealPoly - @test parent_type(RealPoly) == RealPolyRing - @test dense_poly_type(RealFieldElem) == RealPoly + @test elem_type(R) == RealPolyRingElem + @test elem_type(RealPolyRing) == RealPolyRingElem + @test parent_type(RealPolyRingElem) == RealPolyRing + @test dense_poly_type(RealFieldElem) == RealPolyRingElem @test typeof(R) <: RealPolyRing @@ -46,14 +46,14 @@ coeff_types = [Int8, Int, UInt, BigInt, end end -@testset "RealPoly.printing" begin +@testset "RealPolyRingElem.printing" begin R, x = polynomial_ring(RR, "x") f = x^3 + 2x^2 + x + 1 @test sprint(show, "text/plain", f) == "x^3 + 2.0000000000000000000*x^2 + x + 1" end -@testset "RealPoly.manipulation" begin +@testset "RealPolyRingElem.manipulation" begin R, x = polynomial_ring(RR, "x") @test iszero(zero(R)) @@ -83,7 +83,7 @@ end @test characteristic(R) == 0 end -@testset "RealPoly.polynomial" begin +@testset "RealPolyRingElem.polynomial" begin R = RealField() f = polynomial(R, []) @@ -92,33 +92,33 @@ end k = polynomial(R, [R(1), R(2), R(3)]) p = polynomial(R, [1, 2, 3], "y") - @test isa(f, RealPoly) - @test isa(g, RealPoly) - @test isa(h, RealPoly) - @test isa(k, RealPoly) - @test isa(p, RealPoly) + @test isa(f, RealPolyRingElem) + @test isa(g, RealPolyRingElem) + @test isa(h, RealPolyRingElem) + @test isa(k, RealPolyRingElem) + @test isa(p, RealPolyRingElem) q = polynomial(R, [1, 2, 3], cached=false) @test parent(g) != parent(q) end -@testset "RealPoly.similar" begin +@testset "RealPolyRingElem.similar" begin R = RealField() f = polynomial(R, [1, 2, 3]) g = similar(f) h = similar(f, "y") - @test isa(g, RealPoly) - @test isa(h, RealPoly) + @test isa(g, RealPolyRingElem) + @test isa(h, RealPolyRingElem) q = similar(g, cached=false) @test parent(g) != parent(q) end -@testset "RealPoly.binary_ops" begin +@testset "RealPolyRingElem.binary_ops" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -131,7 +131,7 @@ end @test f - g == -x^3+x^2-x-1 end -@testset "RealPoly.adhoc_binary" begin +@testset "RealPolyRingElem.adhoc_binary" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -158,7 +158,7 @@ end end end -@testset "RealPoly.comparison" begin +@testset "RealPolyRingElem.comparison" begin R, x = polynomial_ring(RR, "x") Zx, zx = polynomial_ring(ZZ, "x") Qx, qx = polynomial_ring(QQ, "x") @@ -204,7 +204,7 @@ end @test !uniq end -@testset "RealPoly.adhoc_comparison" begin +@testset "RealPolyRingElem.adhoc_comparison" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -226,7 +226,7 @@ end @test QQ(7) != f end -@testset "RealPoly.unary_ops" begin +@testset "RealPolyRingElem.unary_ops" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -234,7 +234,7 @@ end @test -f == -x^2 - 2x - 1 end -@testset "RealPoly.truncation" begin +@testset "RealPolyRingElem.truncation" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -249,7 +249,7 @@ end @test_throws DomainError mullow(f, g, -1) end -@testset "RealPoly.reverse" begin +@testset "RealPolyRingElem.reverse" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 3 @@ -257,7 +257,7 @@ end #@test reverse(f) == 3x^2 + 2x + 1 end -@testset "RealPoly.shift" begin +@testset "RealPolyRingElem.shift" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -271,7 +271,7 @@ end @test_throws DomainError shift_right(f, -1) end -@testset "RealPoly.powering" begin +@testset "RealPolyRingElem.powering" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -281,7 +281,7 @@ end @test_throws DomainError f^-1 end -@testset "RealPoly.exact_division" begin +@testset "RealPolyRingElem.exact_division" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -306,7 +306,7 @@ end @test divexact(2*f, 2.0) == f end -@testset "RealPoly.evaluation" begin +@testset "RealPolyRingElem.evaluation" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -332,7 +332,7 @@ end @test evaluate2(f, RR(10)) == (121, 22) end -@testset "RealPoly.composition" begin +@testset "RealPolyRingElem.composition" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -341,7 +341,7 @@ end @test compose(f, g; inner = :second) == x^6+6*x^4+4*x^3+9*x^2+12*x+4 end -@testset "RealPoly.derivative_integral" begin +@testset "RealPolyRingElem.derivative_integral" begin R, x = polynomial_ring(RR, "x") f = x^2 + 2x + 1 @@ -351,7 +351,7 @@ end @test contains(derivative(integral(f)), f) end -@testset "RealPoly.evaluation_interpolation" begin +@testset "RealPolyRingElem.evaluation_interpolation" begin R, x = polynomial_ring(RR, "x") n = 5 @@ -395,7 +395,7 @@ end end end -@testset "RealPoly.root_bound" begin +@testset "RealPolyRingElem.root_bound" begin Rx, x = polynomial_ring(RR, "x") for i in 1:2 diff --git a/test/arb/acb_mat-test.jl b/test/arb/acb_mat-test.jl index f9a3f6e0d..7cc29da34 100644 --- a/test/arb/acb_mat-test.jl +++ b/test/arb/acb_mat-test.jl @@ -5,20 +5,20 @@ RR = ArbField(64) @test_throws ErrorException matrix_space(CC, -1, 5) @test_throws ErrorException matrix_space(CC, 0, -2) @test_throws ErrorException matrix_space(CC, -3, -4) - @test_throws ErrorException AcbMatSpace(CC, 2, -1) - @test_throws ErrorException AcbMatSpace(CC, -1, 2) - @test_throws ErrorException AcbMatSpace(CC, -1, -1) + @test_throws ErrorException AcbMatrixSpace(CC, 2, -1) + @test_throws ErrorException AcbMatrixSpace(CC, -1, 2) + @test_throws ErrorException AcbMatrixSpace(CC, -1, -1) S = matrix_space(CC, 3, 3) R = matrix_space(ZZ, 3, 3) @test elem_type(S) == AcbMatrix - @test elem_type(AcbMatSpace) == AcbMatrix - @test parent_type(AcbMatrix) == AcbMatSpace + @test elem_type(AcbMatrixSpace) == AcbMatrix + @test parent_type(AcbMatrix) == AcbMatrixSpace @test nrows(S) == 3 @test ncols(S) == 3 - @test isa(S, AcbMatSpace) + @test isa(S, AcbMatrixSpace) f = S(ZZRingElem(3)) diff --git a/test/arb/arb_mat-test.jl b/test/arb/arb_mat-test.jl index ba098ae0b..a75506d5d 100644 --- a/test/arb/arb_mat-test.jl +++ b/test/arb/arb_mat-test.jl @@ -4,20 +4,20 @@ RR = ArbField(64) @test_throws ErrorException matrix_space(RR, -1, 5) @test_throws ErrorException matrix_space(RR, 0, -2) @test_throws ErrorException matrix_space(RR, -3, -4) - @test_throws ErrorException ArbMatSpace(RR, 2, -1) - @test_throws ErrorException ArbMatSpace(RR, -1, 2) - @test_throws ErrorException ArbMatSpace(RR, -1, -1) + @test_throws ErrorException ArbMatrixSpace(RR, 2, -1) + @test_throws ErrorException ArbMatrixSpace(RR, -1, 2) + @test_throws ErrorException ArbMatrixSpace(RR, -1, -1) S = matrix_space(RR, 3, 3) R = matrix_space(ZZ, 3, 3) @test elem_type(S) == ArbMatrix - @test elem_type(ArbMatSpace) == ArbMatrix - @test parent_type(ArbMatrix) == ArbMatSpace + @test elem_type(ArbMatrixSpace) == ArbMatrix + @test parent_type(ArbMatrix) == ArbMatrixSpace @test nrows(S) == 3 @test ncols(S) == 3 - @test isa(S, ArbMatSpace) + @test isa(S, ArbMatrixSpace) f = S(ZZRingElem(3))