Description Usage Arguments Value Transformation characteristics Examples
Decompose a truth table algorithm into two sub-truth table algorithm with an arbitrage bit (positioned last) to switch between the two nicely packaged into a new composite algorithm.
1 |
algo |
The truth table algorithm to be splitted (algo_tt) |
... |
For future usage |
A composite algorithm that has an identical truth table to original truth table algorithm but where the truth table has been split in two and an arbitrage bit is used (algo_composite)
dimensional_equivalence
logical_equivalence
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Pick a random input dimension
dim_i <- sample(x = 2:6, size = 1, replace = TRUE);
# Pick a random output dimension
dim_o <- sample(x = 2:6, size = 1, replace = TRUE);
# Create a truth table algorithm of desired dimensions
truthtable_algo <- algo_tt$new(dim_i = dim_i, dim_o = dim_o);
# Randomize the truth table outputs, we end up with a random deterministic algorithm
truthtable_algo$do_randomize_outputs();
# Split the random truth table algorithm and retrieve the resulting composite algorithm
splitted_algo <- split(truthtable_algo);
for(test_counter in 1:3){
# Pick a random input value
n <- bnum$new(dim = dim_i)$randomize();
print(paste0("Input: ", n$format(), ", output of truth table algo: ", truthtable_algo$exec(n)$format(), ", output of splitted algo: ", splitted_algo$exec(n)$format()));
}
# Plot the original algo
truthtable_algo$plot();
# Plot the splitted algo
splitted_algo$plot();
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.