Assignment {boolfun} | R Documentation |
Implements an element of {0,1}^n that can be used as input to a BooleanFunction
or Polynomial
instance.
x <- Assignment( initializer )
initializer |
a vector containing 2^n integers in {0,1} or a string holding 2^n characters in {'0','1'}. |
The returned value f
is an S3 object which is defined using the R.oo package. Methods of the returned value, say weight()
, can be accessed in two ways using x$weight()
or weight(x)
.
int() | returns the integer encoded by the element of {0,1}^n. | |
Note: "100" encodes the integer 1 instead of 4. |
||
val() | returns a vector of n integer holding the value of each variable. | |
len() | returns the number of variables (n). | |
string() | returns a string representation of the corresponding monomial. For example, | |
string(Assignment(c(1,0,1,0))) returns "x1*x3" and |
||
string(Assignment(c(0,0,0)) returns "1" . |
||
weight() | returns the Hamming weight, i.e. the number of variables that are set to 1. | |
equals() | - | |
print() | - |
F.Lafitte
BooleanFunction
, Polynomial
, R.oo:Object
x <- Assignment( c(0,1,0,1) ) y <- Assignment( "010110" ) print(x) # returns "Assignment with 4 variables." string(x) # returns "x2*x4" int(x) # returns 10 (i.e. 0001 encodes 8 instead of 1)