summaryrefslogtreecommitdiff
path: root/test_gen.r
blob: 1b5fc56aacac59f018f452720f582f6c1836792e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
}