forked from markapost/ubayes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testnode.c
47 lines (36 loc) · 1.32 KB
/
testnode.c
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "node.h"
#include "graph.h"
int main(int argc, char **argv)
{
char bdot[32768]; unsigned int blength = 256;
unsigned int nn[3];
char name1[] = "TEST1", name2[] = "TEST2", name3[] = "TEST3";
fix dist1[] = {DOUBLE_TO_FIX(0.4), DOUBLE_TO_FIX(0.6)};
fix dist2[] = {DOUBLE_TO_FIX(0.6), DOUBLE_TO_FIX(0.4)};
fix dist3[] = {DOUBLE_TO_FIX(0.5), DOUBLE_TO_FIX(0.5)};
printf("Byte Sizes: short=%ld int=%ld long=%ld fix=%ld fixrad=%ld BERR=%d\n",
sizeof(short), sizeof(int), sizeof(long), sizeof(fix), sizeof(fixrad), BERR);
nn[0] = addBNode(name1, dist1, 2);
nn[1] = addBNode(name2, dist2, 2);
nn[2] = addBNode(name3, dist3, 2);
nn[0] = findBNode(name1);
nn[1] = findBNode(name2);
nn[2] = findBNode(name3);
addBParent(nn[2], nn[0]);
addBParent(nn[2], nn[1]);
setBNodeProbElementCoords(nn[2], DOUBLE_TO_FIX(0.9), 0, 0, 0);
setBNodeProbElementCoords(nn[2], DOUBLE_TO_FIX(0.1), 1, 0, 0);
setBNodeProbElementCoords(nn[2], DOUBLE_TO_FIX(0.8), 0, 1, 0);
setBNodeProbElementCoords(nn[2], DOUBLE_TO_FIX(0.2), 1, 1, 0);
setBNodeProbElementCoords(nn[2], DOUBLE_TO_FIX(0.7), 0, 0, 1);
setBNodeProbElementCoords(nn[2], DOUBLE_TO_FIX(0.3), 1, 0, 1);
inferBNode(nn[2]);
printBNetwork();
generateDotGraph(bdot, blength);
DisplayDotGraph(bdot);
freeBNetwork();
return 0;
}