Skip to content

Commit ed17e26

Browse files
committed
docs(core): add document for list interfaces
1 parent e388304 commit ed17e26

File tree

1 file changed

+110
-5
lines changed

1 file changed

+110
-5
lines changed

Diff for: src/matrices/index.jl

+110-5
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,39 @@ MATRIX_GROUPS[GROUP_BUILTIN] = Set([
144144
])
145145
MATRIX_GROUPS[GROUP_USER] = Set([])
146146

147-
# group functions
147+
"""
148+
list_groups()
149+
150+
List all matrix groups.
151+
152+
# Examples
153+
```jldoctest
154+
julia> list_groups()
155+
2-element Vector{Group}:
156+
Group(:builtin)
157+
Group(:user)
158+
```
159+
"""
148160
list_groups() = collect(keys(MATRIX_GROUPS))
149161

150-
# add to groups
162+
"""
163+
add_to_groups(type, groups)
164+
165+
Add a matrix type to groups.
166+
167+
groups can be vector/varargs of `Group` or symbol.
168+
169+
# Examples
170+
```jldoctest
171+
julia> add_to_groups(Tridiagonal, [Group(:user), Group(:test)])
172+
173+
julia> add_to_groups(Tridiagonal, Group(:user), Group(:test))
174+
175+
julia> add_to_groups(Tridiagonal, [:user, :test])
176+
177+
julia> add_to_groups(Tridiagonal, :user, :test)
178+
```
179+
"""
151180
function add_to_groups(type::Type{<:AbstractMatrix}, groups::Vector{Group})
152181
for group = groups
153182
# check group is builtin
@@ -169,7 +198,20 @@ add_to_groups(type::Type{<:AbstractMatrix}, groups::Group...) = add_to_groups(ty
169198
add_to_groups(type::Type{<:AbstractMatrix}, groups::Symbol...) = add_to_groups(type, collect(groups))
170199
add_to_groups(type::Type{<:AbstractMatrix}, groups::Vector{Symbol}) = add_to_groups(type, [Group(group) for group = groups])
171200

172-
# remove from group
201+
"""
202+
remove_from_group(type, group)
203+
204+
Remove a matrix type from a group.
205+
206+
See also [`remove_from_all_groups`](@ref).
207+
208+
# Examples
209+
```jldoctest
210+
julia> remove_from_group(Tridiagonal, Group(:user))
211+
212+
julia> remove_from_group(Tridiagonal, :user)
213+
```
214+
"""
173215
function remove_from_group(type::Type{<:AbstractMatrix}, group::Group)
174216
# check group is not builtin
175217
if group == GROUP_BUILTIN
@@ -198,7 +240,18 @@ end
198240
# remove from group alternative interfaces
199241
remove_from_group(type::Type{<:AbstractMatrix}, group::Symbol) = remove_from_group(type, Group(group))
200242

201-
# remove from all groups
243+
"""
244+
remove_from_all_groups(type)
245+
246+
Remove a matrix type from all groups.
247+
248+
See also [`remove_from_group`](@ref).
249+
250+
# Examples
251+
```jldoctest
252+
julia> remove_from_all_groups(Tridiagonal)
253+
```
254+
"""
202255
function remove_from_all_groups(type::Type{<:AbstractMatrix})
203256
for group = keys(MATRIX_GROUPS)
204257
if group != GROUP_BUILTIN && type MATRIX_GROUPS[group]
@@ -207,7 +260,59 @@ function remove_from_all_groups(type::Type{<:AbstractMatrix})
207260
end
208261
end
209262

210-
# list matrices
263+
"""
264+
list_matrices(groups, props)
265+
266+
List all matrices that are in groups and have properties.
267+
268+
groups can be vector/varargs of `Group` or symbol.
269+
270+
props can be vector/varargs of `Property`, symbol, data type or property type.
271+
272+
# Examples
273+
```jldoctest
274+
julia> list_matrices()
275+
42-element Vector{Type{<:AbstractMatrix}}:
276+
Fiedler
277+
Prolate
278+
RandSVD
279+
DingDong
280+
Hankel
281+
Companion
282+
KMS
283+
Moler
284+
285+
Involutory
286+
Sampling
287+
Lotkin
288+
Grcar
289+
Triw
290+
Hilbert
291+
Pascal
292+
293+
julia> list_matrices([Group(:builtin), Group(:user)], [Property(:symmetric), Property(:inverse)])
294+
295+
julia> list_matrices(Property(:symmetric), Property(:inverse))
296+
297+
julia> list_matrices([Property(:symmetric), Property(:inverse)])
298+
299+
julia> list_matrices(:symmetric, :inverse)
300+
301+
julia> list_matrices([:symmetric, :inverse])
302+
303+
julia> list_matrices(PropertyTypes.Symmetric, PropertyTypes.Inverse)
304+
305+
julia> list_matrices([PropertyTypes.Symmetric, PropertyTypes.Inverse])
306+
307+
julia> list_matrices(PropertyTypes.Symmetric(), PropertyTypes.Inverse())
308+
309+
julia> list_matrices([PropertyTypes.Symmetric(), PropertyTypes.Inverse()])
310+
311+
julia> list_matrices(Group(:builtin), Group(:user))
312+
313+
julia> list_matrices([Group(:builtin), Group(:user)])
314+
```
315+
"""
211316
function list_matrices(groups::Vector{Group}, props::Vector{Property})
212317
# check properties
213318
check_properties_exists(props...)

0 commit comments

Comments
 (0)