RobinHankin/freegroup

subs() functionality

Closed this issue · 2 comments

In the freealg package, subs() has a nice feature:

> (x <- rfalg())
free algebra element algebraically equal to
+ 4*abcc + 13*b + 2*bbba + 3*cbbc + 1*ccba + 5*cccc
> x %>% subs(a="1+x")
free algebra element algebraically equal to
+ 13*b + 2*bbb + 2*bbbx + 4*bcc + 3*cbbc + 1*ccb + 1*ccbx + 5*cccc + 4*xbcc
> 

But this does not work in the freegroup package:

> (x <- as.free(c("a","aab","c")))
[1] a     a^2.b c    
> x %>% subs(a="1+x")
Error in is_ok_free(words, coeffs) : 
  length(words) == length(coeffs) is not TRUE
> 

and it would be nice if it did.

Actually subs(a="1+x") would not be sensible (the free group is not an algebra) but something like
subs(a="abA") might be useful and/or interesting.

Also observe that the internal representation for a freegroup object is a list of integer matrices, symbols like a and b are created by the print method.