1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

add doc to reduce function

This commit is contained in:
kalmar 2017-05-11 18:03:46 +02:00
parent f9ccff01a8
commit 9b48932ab4

View File

@ -83,7 +83,7 @@ function free_reduce!(W::GWord)
return reduced return reduced
end end
function reduce!{T}(W::GWord{T}) function reduce!(W::GWord)
if length(W) < 2 if length(W) < 2
deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols)) deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols))
else else
@ -98,8 +98,16 @@ function reduce!{T}(W::GWord{T})
return W return W
end end
reduce(W::GWord) = reduce!(deepcopy(W)) doc"""
reduce(W::GWord)
> performs reduction/simplification of a group element (word in generators).
> The default reduction is the free group reduction, i.e. consists of
> multiplying adjacent symbols with the same `str` identifier and deleting the
> identity elements from `W.symbols`.
> More specific procedures should be dispatched on `GWord`s type parameter.
"""
reduce(W::GWord) = reduce!(deepcopy(W))
function (==){T}(W::GWord{T}, Z::GWord{T}) function (==){T}(W::GWord{T}, Z::GWord{T})
W.modified && reduce!(W) # reduce clears the flag and recalculate the hash W.modified && reduce!(W) # reduce clears the flag and recalculate the hash