Accessor methods for free algebra objects

words(x)
coeffs(x,drop=TRUE)
coeffs(x) <- value

Arguments

x

Object of class freealg

value

Numeric vector of length 1

drop

Boolean, with default TRUE meaning to drop the disord attribute, as per disordR::drop() and FALSE meaning to consistently return a disord object irregardless

Details

Access or set the different parts of a freealg object. The constant term is technically a coefficient but is documented under constant.Rd.

“Pure” extraction and replacement (as in a[i] and a[i] <- value is implemented exprimentally. The code for extraction is cute but not particularly efficient.

Author

Robin K. S. Hankin

Note

There is an extended discussion of disordR discipline in the context of algebras in the mvp package at accessor.Rd.

See also

Examples

a <- rfalg()
a
#> free algebra element algebraically equal to
#> + 9a + aba + 3acac + 13b + 2c
coeffs(a)
#> A disord object with hash a721c8fd8dd0657fb6cb74ff05462059b0a31ebb and elements
#> [1]  9  1  3 13  2
#> (in some order)
words(a)  # NB: hash is identical to that of coeffs(a)
#> A disord object with hash a721c8fd8dd0657fb6cb74ff05462059b0a31ebb and elements
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 1 2 1
#> 
#> [[3]]
#> [1] 1 3 1 3
#> 
#> [[4]]
#> [1] 2
#> 
#> [[5]]
#> [1] 3
#> 
#> (in some order)

coeffs(a) <- 7   # replacement methods work 
a
#> free algebra element algebraically equal to
#> + 7a + 7aba + 7acac + 7b + 7c
coeffs(a)  #
#> [1] 7 7 7 7 7