diff options
author | TinWoodman92 <chrhodgden@gmail.com> | 2023-02-25 18:58:22 -0600 |
---|---|---|
committer | TinWoodman92 <chrhodgden@gmail.com> | 2023-02-25 18:58:22 -0600 |
commit | 6042506b3b6a77c35471ce007d77ffbd6ae7420c (patch) | |
tree | 8c96f61f303666c2449851e6039af7e9ffc85250 /test_gen.r |
Diffstat (limited to 'test_gen.r')
-rw-r--r-- | test_gen.r | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test_gen.r b/test_gen.r new file mode 100644 index 0000000..1b5fc56 --- /dev/null +++ b/test_gen.r @@ -0,0 +1,29 @@ +test_input <- function(input_node_count) { + return(floor(runif(input_node_count, max = 2))) +} + +test_output <- function(test_input) { + inc <- length(test_input) + onc <- packBits(as.integer(c(rep(1, inc), rep(0, 32 - inc))), "integer") + 1 + tar_int <- packBits(as.integer(c(test_input, rep(0, 32 - inc))), "integer") + tar_out <- rep(0, onc) + tar_out[tar_int + 1] <- 1 + return(tar_out) +} + +read_input <- function(test_input) { + inc <- length(test_input) + tar_int <- packBits(as.integer(c(test_input, rep(0, 32 - inc))), "integer") + return(tar_int) +} + +read_output <- function(output_signal) { + tar_int <- which(output_signal == 1) - 1 + return(tar_int) +} + +clean_output <- function(output_signal) { + mo <- max(output_signal) + tar_int <- which(output_signal == mo) - 1 + return(tar_int) +}
\ No newline at end of file |