Objects of class free
free.Rd
Generate, and test for, objects of class free
Details
The basic structure of an element of the free group is a two-row matrix. The top row is the symbols (1=a, 2=b, 3=c, etc) and the bottom row is the corresponding power. Thus \(a^2ba^{-1}c^9\) would be
> rbind(c(1,2,1,3),c(2,1,-1,9))
[,1] [,2] [,3] [,4]
[1,] 1 2 1 3
[2,] 2 1 -1 9
>
Function free()
needs either a two-row matrix or a list of
two-row matrices. It is the only place in the package that sets the
class of an object to free
. Function as.free()
is a bit
more user-friendly and tries a bit harder to do the Right Thing.
The package uses setOldClass("free")
for the dot
methods.
Examples
free(rbind(1:5,5:1))
#> [1] a^5.b^4.c^3.d^2.e
x <- rfree(10,3)
x
#> [1] b^3.c^3.a^2 a^-2.c^3.a^-1 b^3.a^4 b^3.c^2.b^-2 a^-3.b^2
#> [6] c^-3.b^2 a^2 b.c^-2 b^2.a a^-2.c^-1
x+x
#> [1] b^3.c^3.a^2.b^3.c^3.a^2 a^-2.c^3.a^-3.c^3.a^-1 b^3.a^4.b^3.a^4
#> [4] b^3.c^2.b.c^2.b^-2 a^-3.b^2.a^-3.b^2 c^-3.b^2.c^-3.b^2
#> [7] a^4 b.c^-2.b.c^-2 b^2.a.b^2.a
#> [10] a^-2.c^-1.a^-2.c^-1
x-x
#> [1] 0 0 0 0 0 0 0 0 0 0
x[1:5]*(1:5)
#> [1] b^3.c^3.a^2
#> [2] a^-2.c^3.a^-3.c^3.a^-1
#> [3] b^3.a^4.b^3.a^4.b^3.a^4
#> [4] b^3.c^2.b.c^2.b.c^2.b.c^2.b^-2
#> [5] a^-3.b^2.a^-3.b^2.a^-3.b^2.a^-3.b^2.a^-3.b^2
as.free(c(4,3,2,2,2))
#> [1] d.c.b^3
as.free("aaaabccccaaaaa")
#> [1] a^4.b.c^4.a^5
as.free(c("a","A","abAAA"))
#> [1] a a^-1 a.b.a^-3