Skip to content

Commit

Permalink
Rename number_of_* functions consistently (Nemocas#1553)
Browse files Browse the repository at this point in the history
* ncols

* ndigits

* ngens

* nrows

* nvars

* Update src/Matrix.jl [skip ci]

Co-authored-by: Tommy Hofmann <[email protected]>

---------

Co-authored-by: Tommy Hofmann <[email protected]>
  • Loading branch information
2 people authored and ooinaruhugh committed Feb 15, 2024
1 parent a285296 commit 4e07e61
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 79 deletions.
2 changes: 1 addition & 1 deletion docs/src/free_associative_algebra.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ multivariate polynomial interface are provided.

```julia
symbols(S::FreeAssAlgebra)
nvars(f::FreeAssAlgebra)
number_of_variables(f::FreeAssAlgebra)
gens(S::FreeAssAlgebra)
gen(S::FreeAssAlgebra, i::Int)
is_gen(x::FreeAssAlgElem)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/laurent_mpolynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ finish(M::LaurentMPolyBuildCtx)

```julia
symbols(S::LaurentMPolyRing)
nvars(f::LaurentMPolyRing)
number_of_variables(f::LaurentMPolyRing)
gens(S::LaurentMPolyRing)
gen(S::LaurentMPolyRing, i::Int)
is_gen(x::LaurentMPolyRingElem)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/laurent_polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ julia> symbols(R)
1-element Vector{Symbol}:
:x
julia> nvars(R)
julia> number_of_variables(R)
1
julia> f = x^-2 + 2x
Expand Down
12 changes: 6 additions & 6 deletions docs/src/matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ dense_matrix_type(::Ring)
```

```@docs
nrows(::MatSpace)
ncols(::MatSpace)
number_of_rows(::MatSpace)
number_of_columns(::MatSpace)
```

```@docs
nrows(::MatrixElem{T}) where T <: RingElement
ncols(::MatrixElem{T}) where T <: RingElement
number_of_rows(::MatrixElem{T}) where T <: RingElement
number_of_columns(::MatrixElem{T}) where T <: RingElement
```

```@docs
Expand Down Expand Up @@ -501,10 +501,10 @@ julia> B = S([R(2) R(3) R(1); t t + 1 t + 2; R(-1) t^2 t^3])
julia> T = dense_matrix_type(R)
AbstractAlgebra.Generic.MatSpaceElem{AbstractAlgebra.Generic.Poly{Rational{BigInt}}}
julia> r = nrows(B)
julia> r = number_of_rows(B)
3
julia> c = ncols(B)
julia> c = number_of_columns(B)
3
julia> length(B)
Expand Down
12 changes: 6 additions & 6 deletions docs/src/matrix_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,27 @@ E.g. in Nemo, which depends on AbstractAlgebra, we define
`dense_matrix_type(::Type{ZZRingElem}) = ZZMatrix`.

```julia
nrows(M::MyMatSpace{T}) where T <: RingElem
nrows(M::MyMatAlgebra{T}) where T <: RingElem
number_of_rows(M::MyMatSpace{T}) where T <: RingElem
number_of_rows(M::MyMatAlgebra{T}) where T <: RingElem
```

Return the number of rows of matrices in the matrix space.

```julia
ncols(M:MyMatSpace{T}) where T <: RingElem
ncols(M:MyMatAlgebra{T}) where T <: RingElem
number_of_columns(M:MyMatSpace{T}) where T <: RingElem
number_of_columns(M:MyMatAlgebra{T}) where T <: RingElem
```

Return the number of columns of matrices in the matrix space.

```julia
nrows(f::MyMat{T}) where T <: RingElem
number_of_rows(f::MyMat{T}) where T <: RingElem
```

Return the number of rows of the given matrix.

```julia
ncols(f::MyMat{T}) where T <: RingElem
number_of_columns(f::MyMat{T}) where T <: RingElem
```

Return the number of columns of the given matrix.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ iszero(m::FPModuleElem{T}) where T <: RingElement
Return `true` if the given module element is zero.

```julia
ngens(M::FPModule{T}) where T <: RingElement
number_of_generators(M::FPModule{T}) where T <: RingElement
```

Return the number of generators of the module $M$ in its current representation.
Expand Down Expand Up @@ -77,7 +77,7 @@ relation is given as an AbstractAlgebra row matrix.
julia> M = FreeModule(QQ, 2)
Vector space of dimension 2 over rationals
julia> n = ngens(M)
julia> n = number_of_generators(M)
2
julia> G = gens(M)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/module_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ iszero(m::MyModuleElem{T}) where T <: RingElement
Return `true` if the given module element is zero.

```julia
ngens(M::MyModule{T}) where T <: RingElement
number_of_generators(M::MyModule{T}) where T <: RingElement
```

Return the number of generators of the module $M$ in its current representation.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/mpoly_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ring. Note that these are `Symbol`s not `String`s, though their string values wi
usually be used when printing polynomials.

```julia
nvars(f::MyMPolyRing{T}) where T <: RingElem
number_of_variables(f::MyMPolyRing{T}) where T <: RingElem
```

Return the number of variables of the polynomial ring.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/mpolynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ All basic functions from the Multivariate Polynomial interface are provided.

```julia
symbols(S::MPolyRing)
nvars(f::MPolyRing)
number_of_variables(f::MPolyRing)
gens(S::MPolyRing)
gen(S::MPolyRing, i::Int)
```
Expand Down Expand Up @@ -458,7 +458,7 @@ julia> n = length(f)
julia> is_gen(y)
true
julia> nvars(S) == 2
julia> number_of_variables(S) == 2
true
julia> d = total_degree(f)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/mseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ for absolute series over any commutative ring.
The following are provided for weighted and unweighted series:

```@docs
nvars(::Generic.AbsMSeriesRing)
number_of_variables(::Generic.AbsMSeriesRing)
```

```@docs
Expand Down
21 changes: 16 additions & 5 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ export is_real
export is_subset
export is_valid
export is_zero
export number_of_digits

@alias is_empty isempty
@alias is_even iseven
Expand All @@ -326,6 +327,7 @@ export is_zero
@alias is_subset issubset
@alias is_valid isvalid
@alias is_zero iszero
@alias number_of_digits ndigits

function order end

Expand All @@ -338,6 +340,20 @@ const is_symmetric = issymmetric
const is_lower_triangular = istril
const is_upper_triangular = istriu

# alternative names for some of our own functions
function number_of_columns end
function number_of_generators end
function number_of_rows end
function number_of_variables end
export number_of_columns
export number_of_generators
export number_of_rows
export number_of_variables
@alias ncols number_of_columns
@alias ngens number_of_generators
@alias nrows number_of_rows
@alias nvars number_of_variables

###############################################################################
# Macros for fancy printing. to use, enable attribute storage for your struct,
# i.e.m change
Expand Down Expand Up @@ -720,7 +736,6 @@ import .Generic: monomial!
import .Generic: monomials
import .Generic: MPolyBuildCtx
import .Generic: mullow_karatsuba
import .Generic: ngens
import .Generic: norm
import .Generic: normal_form
import .Generic: normalise
Expand Down Expand Up @@ -1058,16 +1073,12 @@ export multiply_column
export multiply_column!
export multiply_row
export multiply_row!
export ncols
export newton_to_monomial!
export ngens
export norm
export normal_form
export normalise
export nrows
export nullspace
export num_coeff
export nvars
export O
export one
export order
Expand Down
10 changes: 5 additions & 5 deletions src/Generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import Base: length
import Base: log1p
import Base: Matrix
import Base: mod
import Base: ndigits
import Base: oct
import Base: one
import Base: parent
Expand Down Expand Up @@ -205,13 +204,14 @@ import ..AbstractAlgebra: mul_classical
import ..AbstractAlgebra: mul_karatsuba
import ..AbstractAlgebra: mul!
import ..AbstractAlgebra: mullow
import ..AbstractAlgebra: ncols
import ..AbstractAlgebra: number_of_columns
import ..AbstractAlgebra: number_of_digits
import ..AbstractAlgebra: number_of_generators
import ..AbstractAlgebra: NCRing
import ..AbstractAlgebra: NCRingElem
import ..AbstractAlgebra: ngens
import ..AbstractAlgebra: nrows
import ..AbstractAlgebra: number_of_rows
import ..AbstractAlgebra: numerator
import ..AbstractAlgebra: nvars
import ..AbstractAlgebra: number_of_variables
import ..AbstractAlgebra: O
import ..AbstractAlgebra: order
import ..AbstractAlgebra: parent_type
Expand Down
2 changes: 1 addition & 1 deletion src/Groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ The default implementation returns `true`.
has_gens(G::Group) = true

gens(G::Group) = throw(NotImplementedError(:gens, G))
ngens(G::Group) = throw(NotImplementedError(:ngens, G))
number_of_generators(G::Group) = throw(NotImplementedError(:number_of_generators, G))

###############################################################################
#
Expand Down
4 changes: 2 additions & 2 deletions src/MPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ function is_exact_type(a::Type{T}) where {S <: RingElement, T <: MPolyRingElem{S
end

@doc raw"""
ngens(R::MPolyRing)
number_of_generators(R::MPolyRing)
Return the number of variables in `R`.
"""
ngens(R::MPolyRing) = nvars(R)
number_of_generators(R::MPolyRing) = number_of_variables(R)

@doc raw"""
vars(p::MPolyRingElem{T}) where {T <: RingElement}
Expand Down
16 changes: 8 additions & 8 deletions src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ check_square(S::MatAlgebra) = S
###############################################################################

@doc raw"""
nrows(a::MatSpace)
number_of_rows(a::MatSpace)
Return the number of rows of the given matrix space.
"""
nrows(a::MatSpace) = a.nrows
number_of_rows(a::MatSpace) = a.nrows

@doc raw"""
ncols(a::MatSpace)
number_of_columns(a::MatSpace)
Return the number of columns of the given matrix space.
"""
ncols(a::MatSpace) = a.ncols
number_of_columns(a::MatSpace) = a.ncols

function Base.hash(a::MatElem, h::UInt)
b = 0x3e4ea81eb31d94f4%UInt
Expand All @@ -114,18 +114,18 @@ function Base.hash(a::MatElem, h::UInt)
end

@doc raw"""
nrows(a::MatrixElem{T}) where T <: NCRingElement
number_of_rows(a::MatrixElem{T}) where T <: NCRingElement
Return the number of rows of the given matrix.
"""
nrows(a::MatrixElem{T}) where T <: NCRingElement
number_of_rows(a::MatrixElem{T}) where T <: NCRingElement

@doc raw"""
ncols(a::MatrixElem{T}) where T <: NCRingElement
number_of_columns(a::MatrixElem{T}) where T <: NCRingElement
Return the number of columns of the given matrix.
"""
ncols(a::MatrixElem{T}) where T <: NCRingElement
number_of_columns(a::MatrixElem{T}) where {T<:NCRingElement}

@doc raw"""
length(a::MatrixElem{T}) where T <: NCRingElement
Expand Down
4 changes: 2 additions & 2 deletions src/MatrixAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function Base.hash(a::MatAlgElem, h::UInt)
return b
end

nrows(a::MatAlgebra) = a.n
ncols(a::MatAlgebra) = nrows(a)
number_of_rows(a::MatAlgebra) = a.n
number_of_columns(a::MatAlgebra) = number_of_rows(a)

@doc raw"""
degree(a::MatAlgebra)
Expand Down
2 changes: 1 addition & 1 deletion src/NemoStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function Base.getindex(L::SimpleNumField{T}, i::Int) where {T}
end
end

ngens(L::SimpleNumField{T}) where {T} = 1
number_of_generators(L::SimpleNumField{T}) where {T} = 1

is_unit(a::NumFieldElem) = !iszero(a)

Expand Down
4 changes: 2 additions & 2 deletions src/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ this is returned as an array of `Symbol` not `String`.
symbols(a::PolyRing) = [a.S]

@doc raw"""
nvars(a::PolyRing)
number_of_variables(a::PolyRing)
Return the number of variables of the polynomial ring, which is 1.
"""
nvars(a::PolyRing) = 1
number_of_variables(a::PolyRing) = 1

function check_parent(a::PolynomialElem, b::PolynomialElem, throw::Bool = true)
c = parent(a) != parent(b)
Expand Down
6 changes: 3 additions & 3 deletions src/generic/AbsMSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ Return the number of nonzero terms in the series $a$.
length(a::AbsMSeries) = length(poly(a))

@doc raw"""
nvars(R::AbsMSeriesRing)
number_of_variables(R::AbsMSeriesRing)
Return the number of variables in the series ring.
"""
nvars(R::AbsMSeriesRing) = nvars(poly_ring(R))
number_of_variables(R::AbsMSeriesRing) = number_of_variables(poly_ring(R))

ngens(R::AbsMSeriesRing) = ngens(poly_ring(R))
number_of_generators(R::AbsMSeriesRing) = number_of_generators(poly_ring(R))

@doc raw"""
precision(a::AbsMSeries)
Expand Down
2 changes: 1 addition & 1 deletion src/generic/DirectSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ base_ring(N::DirectSumModule{T}) where T <: RingElement = base_ring(N.m[1])

base_ring(v::DirectSumModuleElem{T}) where T <: RingElement = base_ring(v.parent)

ngens(N::DirectSumModule{T}) where T <: RingElement = sum(ngens(M) for M in N.m)
number_of_generators(N::DirectSumModule{T}) where T <: RingElement = sum(ngens(M) for M in N.m)

gens(N::DirectSumModule{T}) where T <: RingElement = [gen(N, i) for i = 1:ngens(N)]

Expand Down
2 changes: 1 addition & 1 deletion src/generic/Fraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function deepcopy_internal(a::FracFieldElem{T}, dict::IdDict) where {T <: RingEl
return v
end

ngens(F::FracField) = ngens(base_ring(F))
number_of_generators(F::FracField) = number_of_generators(base_ring(F))

gen(F::FracField) = F(gen(base_ring(F)))

Expand Down
Loading

0 comments on commit 4e07e61

Please sign in to comment.