Galois field (GF) with R -


is there package galois fields (gf) in r? define following matrix operations gf.

  • 1+1=0
  • 1+0=1
  • 0+1=1
  • 0+0=0

obviously r doesn't understand 1+1 without specifying it:

> k <- matrix(c(0,1,1,0,1,0,0,0,0,1), ncol=10);k      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]    0    1    1    0    1    0    0    0    0     1 > p <- matrix(c(0,0,0,1,1,1,0,1,0,1), ncol=10);p      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]    0    0    0    1    1    1    0    1    0     1 > c <- k+p;c      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]    0    1    1    1    2    1    0    1    0     2 

i don't know galois fields, this question appears addition , subtraction equivalent xor. might easier use fact computations.

as.integer(xor(k,p)) 

or, if want fancy, can overload operator , define own class:

`+.gf`<-function (x, y) as.integer((x | y) & !(x & y)) class(k)<-'gf' class(p)<-'gf' k+p [1] 0 1 1 1 0 1 0 1 0 0 

Comments