Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename number_of_* functions consistently #1553

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -719,7 +735,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 @@ -1053,16 +1068,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 @@
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))

Check warning on line 141 in src/Groups.jl

View check run for this annotation

Codecov / codecov/patch

src/Groups.jl#L141

Added line #L141 was not covered by tests

###############################################################################
#
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 @@
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)

Check warning on line 87 in src/MPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/MPoly.jl#L87

Added line #L87 was not covered by tests

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

@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

Check warning on line 96 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L96

Added line #L96 was not covered by tests

@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

Check warning on line 103 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L103

Added line #L103 was not covered by tests

function Base.hash(a::MatElem, h::UInt)
b = 0x3e4ea81eb31d94f4%UInt
Expand All @@ -114,18 +114,18 @@
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 Expand Up @@ -373,7 +373,7 @@
for `i=1,...,length(rows)` and `j=1,...,length(cols)`.
Instead of a vector, `rows` and `cols` can also be:
* an integer `i`, which is interpreted as `i:i`, or
* `:`, which is interpreted as `1:nrows(M)` or `1:ncols(M)` respectively.
* `:`, which is interpreted as `1:number_of_rows(M)` or `1:number_of_columns(M)` respectively.
lgoettgens marked this conversation as resolved.
Show resolved Hide resolved
"""
function getindex(M::MatElem, rows::AbstractVector{Int}, cols::AbstractVector{Int})
_checkbounds(M, rows, cols)
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 @@
end
end

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

Check warning on line 190 in src/NemoStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/NemoStuff.jl#L190

Added line #L190 was not covered by tests

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 @@
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))

Check warning on line 71 in src/generic/AbsMSeries.jl

View check run for this annotation

Codecov / codecov/patch

src/generic/AbsMSeries.jl#L71

Added line #L71 was not covered by tests

@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 @@
return v
end

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

Check warning on line 48 in src/generic/Fraction.jl

View check run for this annotation

Codecov / codecov/patch

src/generic/Fraction.jl#L48

Added line #L48 was not covered by tests

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

Expand Down
Loading
Loading