I would like to perform matrix multiplication modulo 2. Hence, instead of the usual:
A.B
I did:
Inner[#1*#2 &, A, B, Modulus[#1+#2,2]&]
However, it does not work, since #1+#2
(in the modulus) only adds the first two inputs, whereas, I want it to add all its inputs (like Plus
does). I want to define a function that just adds up all its inputs, modulo 2 and it can take in variable number of inputs.
In otherwords, I want to define a addmod
which takes in variable number of inputs and adds them (modulo 2):
addmod[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0] = 1
,addmod[0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0] = 1
and so on. Note, the input is not a list here. Hence I cannot say something like:
addmod[list]=Fold[Modulus[Plus[#1+#2,2],2]&,0,list]
I would be happy to get some help on this. Sorry, if i am missing out something basic.
Thanks very much.
Modulus[]
function in Mathematica... $\endgroup$Mod[... , 2]
. $\endgroup$