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

Add components method to Abelian group #1632

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions docs/src/manual/abelian/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ parent(x::FinGenAbGroupElem)
### Access

```@docs
getindex(x::FinGenAbGroupElem, v::AbstractVector{Int})
getindex(x::FinGenAbGroupElem, i::Int)
```

Expand Down
30 changes: 30 additions & 0 deletions src/GrpAb/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,36 @@
return x.coeff[1, i]
end

@doc raw"""
getindex(x::FinGenAbGroupElem, v::AbstractVector{Int}) -> Vector{ZZRingElem}

Returns the $i$-th components of the element $x$ where $i \in v$.

!!! note
This function is inefficient since the elements are internally stored using ZZMatrix but this function outputs a vector.
"""
function getindex(x::FinGenAbGroupElem, v::AbstractVector{Int})
return [x.coeff[1, i] for i in v]

Check warning on line 158 in src/GrpAb/Elem.jl

View check run for this annotation

Codecov / codecov/patch

src/GrpAb/Elem.jl#L157-L158

Added lines #L157 - L158 were not covered by tests
end

@doc raw"""
firstindex(x::FinGenAbGroupElem) -> Int64

Returns the first component of the element $x$.
"""
paemurru marked this conversation as resolved.
Show resolved Hide resolved
function Base.firstindex(x::FinGenAbGroupElem)
return Int64(1)

Check warning on line 167 in src/GrpAb/Elem.jl

View check run for this annotation

Codecov / codecov/patch

src/GrpAb/Elem.jl#L166-L167

Added lines #L166 - L167 were not covered by tests
paemurru marked this conversation as resolved.
Show resolved Hide resolved
end

@doc raw"""
lastindex(x::FinGenAbGroupElem) -> Int64

Returns the last component of the element $x$.
"""
paemurru marked this conversation as resolved.
Show resolved Hide resolved
function Base.lastindex(x::FinGenAbGroupElem)
return ngens(parent(x))

Check warning on line 176 in src/GrpAb/Elem.jl

View check run for this annotation

Codecov / codecov/patch

src/GrpAb/Elem.jl#L175-L176

Added lines #L175 - L176 were not covered by tests
end

################################################################################
#
# Comparison
Expand Down
1 change: 1 addition & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export codifferent
export codomain
export coefficient_ideals
export coefficients
export components
paemurru marked this conversation as resolved.
Show resolved Hide resolved
export coinvariant_lattice
export cokernel
export collapse_top_layer
Expand Down
Loading