summaryrefslogtreecommitdiff
path: root/viterbi_generator/tests/test_check.m
blob: a08c801f37ded6d397b37e170a1570c2362e87c4 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/octave --silent
addpath("./tests/utils");
addpath("./utils");
addpath("./utils/lower_utils");
addpath("./utils/lower_utils/lower_utils");

arg_list=argv();
Lh=sscanf(arg_list{1}, "%d", "C");
PATHS_NUM=2**(Lh);
load tests/data/rhh.dat;
load tests/data/normal_burst.dat;
load test_result;

[r BURST_SIZE] = size(normal_burst);

[ SYMBOLS , PREVIOUS , NEXT , START , STOPS ] = viterbi_init(Lh);

path_metrics_test_result = path_metrics_test_result.';
[rx_burst METRIC] = viterbi_detector(SYMBOLS,NEXT,PREVIOUS,START,STOPS,normal_burst,Rhh);
[r,burst_size] = size(METRIC);
sum_check=0; %number of errors

%find branch metrics computation errors number (errors bigger than 1000)
for i=1:2:burst_size,
  check_matrix = (abs(METRIC(1:2:r,i)-path_metrics_test_result(:,i)));
  suma=sum( check_matrix > ones(PATHS_NUM,1)*1000);
  sum_check = sum_check + suma;
  
  check_matrix = (abs(METRIC(2:2:r,i+1)-path_metrics_test_result(:,i+1)));
  suma=sum( check_matrix > ones(PATHS_NUM,1)*1000);
  sum_check = sum_check + suma;
end

%compute expected number of errors (errors from the beginning)
q=2;
expected_result=0;
while(q<PATHS_NUM),
  expected_result=expected_result + (PATHS_NUM-q);
  q=q*2;
end

%check result
if(sum_check == expected_result),
  printf("Path metrics test: ok\n");
else
  sum_check
  printf("Path metrics test: failed\n");  
end

%check output of the viterbi_detector function
if(sum(output==rx_burst) == BURST_SIZE),
  printf("Final result test: ok\n");
else
  printf("Final result test: failed\n");  
end

personal git repositories of Harald Welte. Your mileage may vary