Skip to content

Commit

Permalink
Merge branch 'master' into lg/mul
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Oct 17, 2023
2 parents 15d561b + 4a830bc commit a27097b
Show file tree
Hide file tree
Showing 14 changed files with 921 additions and 186 deletions.
1 change: 1 addition & 0 deletions docs/Build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pages = [
"misc/conjugacy.md",
],
"Extra features" => ["features/macros.md",
"features/mset.md",
],
"Examples" => "examples.md",
"References" => "references.md",
Expand Down
99 changes: 99 additions & 0 deletions docs/src/features/mset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Multi-sets and sub-set iterators

```@meta
CurrentModule = Hecke
DocTestSetup = quote
using Hecke
end
```

## Multi-sets

### Type and constructors

Objects of type `MSet` consists of a dictionary whose keys are the elements in
the set, and the values are their respective multiplicity.

```@docs
MSet
```

We can create multi-sets from any finite iterator, dictionary or pair of lists
with the appropriate conditions.

```@docs
multiset
```

### Functions

One can iterate over an `MSet` as on a regular `Set`. Here is moreover a list
of functions defined for collections of objects which are currently available
for `MSet`:

* `==`
* `all`
* `any`
* `copy`
* `delete!`
* `eltype`
* `filter`
* `filter!`
* `in`
* `intersect`
* `intersect!`
* `isempty`
* `issubset`
* `length`
* `pop!`
* `push!`
* `setdiff`
* `setdiff!`
* `similar`
* `unique`
* `union`
* `union!`
* ...

Note that `pop!` and `delete!` for `MSet` are available but have a different behaviour.
For an element `x` in an multi-set `M <: MSet`, then `pop!(M, x)` will remove
*one* instance of `x` in `M` - in particular `multiplicity(M, x)` will drop by
$1$. Much stronger, `delete!(M, x)` will remove *all* instances of `x` in `M` and
so `multiplicity(M, x)` will be $0$.

While `unique` will return the keys of the underlying dictionary, one can access
the values (i.e. the multiplicities of the elements in the multi-set) via the
following functions:

```@docs
multiplicities(::MSet)
multiplicity(::MSet{T}, ::T) where {T}
```

Finally, the sum and difference for `MSet` are also available. Difference is
given by the complements of sets and the sum is given by disjoint union of sets.

```@docs
Base.:(+)(::MSet, ::MSet)
Base.:(-)(::MSet, ::MSet...)
```

## Sub-set iterators

### Sub-multi-sets

```@docs
subsets(::MSet{Int})
```

### Sub-sets

```@docs
subsets(::Set{Int})
```

### Sub-sets of a given size

```@docs
subsets(::Set, ::Int)
```
2 changes: 1 addition & 1 deletion docs/src/function_fields/degree_localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Given $k(x)$ a (univariate) rational function field, there are two rings of inte
both of which are Euclidean:

* $k[x]$
* $k_\infty(x) = \{a/b | a, b \in k[x] \;\;\mbox{where}\;\; \deg(a) \leq \deg(b)\}
* $k_\infty(x) = \{a/b | a, b \in k[x] \;\;\mbox{where}\;\; \deg(a) \leq \deg(b)\}$

The second of these rings is the localization of $k[1/x]$ at $(1/x)$ inside the rational
function field $k(x)$, i.e. the localization of the function field at the point at
Expand Down
11 changes: 8 additions & 3 deletions examples/NFDB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -994,10 +994,12 @@ end
#
################################################################################

function Base.merge!(R::NFDB{1}, D1::NFDB{1})
function Base.merge!(R::NFDB{1}, D1::NFDB{1}; skip_update = false)
sizehint!(R.fields, length(R) + length(D1))
append!(R.fields, D1.fields)
update_properties!(R)
if !skip_update
update_properties!(R)
end
return R
end

Expand All @@ -1014,10 +1016,13 @@ function Base.merge(D::Vector{NFDB{1}})
end

R = NFDB{1}()
sizehint!(R.fields, sum(length(d) for d in D))
for i in 1:length(D)
merge!(R, D[i])
merge!(R, D[i], skip_update = true)
end

update_properties!(R)

return R
end

Expand Down
1 change: 1 addition & 0 deletions src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@

@deprecate mul(A::SRow{T}, B::SMat{T}) where T A*B

@deprecate field_of_fractions(O::GenOrd) function_field(O::GenOrd)

# Things that moved to Nemo

Expand Down
2 changes: 1 addition & 1 deletion src/FunField/DegreeLocalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end
in(a::Generic.RationalFunctionFieldElem{T}, R::KInftyRing{T}) where T <: FieldElement
Return `true` if the given element of the rational function field is an
element of `k_\infty(x)`, i.e. if `degree(numerator) <= degree(denominator)`.
element of $k_\infty(x)$, i.e. if `degree(numerator) <= degree(denominator)`.
"""
function in(a::Generic.RationalFunctionFieldElem{T}, R::KInftyRing{T}) where T <: FieldElement
if parent(a) != function_field(R)
Expand Down
5 changes: 0 additions & 5 deletions src/FunField/Divisor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,10 @@ function ideals(D)
end

@doc raw"""
field_of_fractions(O::GenOrd) -> FunctionField
function_field(O::GenOrd) -> FunctionField
Return the function field of O.
"""
function field_of_fractions(O::GenOrd)
return O.F
end

function function_field(O::GenOrd)
return O.F
end
Expand Down
Loading

0 comments on commit a27097b

Please sign in to comment.