diff options
author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/benchmarks/localization/src/c/get3DGaussianProb.c | |
parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/benchmarks/localization/src/c/get3DGaussianProb.c')
-rw-r--r-- | SD-VBS/benchmarks/localization/src/c/get3DGaussianProb.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/localization/src/c/get3DGaussianProb.c b/SD-VBS/benchmarks/localization/src/c/get3DGaussianProb.c new file mode 100644 index 0000000..58c4475 --- /dev/null +++ b/SD-VBS/benchmarks/localization/src/c/get3DGaussianProb.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include "localization.h" | ||
8 | |||
9 | F2D* get3DGaussianProb( F2D* data, F2D* mean, F2D* A) | ||
10 | { | ||
11 | F2D *p, *diff, *temp1, *temp2, *mt; | ||
12 | float temp; | ||
13 | int n_data, n_channel; | ||
14 | int i, j, k; | ||
15 | F2D* t; | ||
16 | float pi = 3.1412; | ||
17 | |||
18 | n_data = data->height; | ||
19 | n_channel = data->width; | ||
20 | |||
21 | t = fSetArray(n_data, 1, 1); | ||
22 | |||
23 | mt = fMtimes(t, mean); | ||
24 | diff = fMinus( data, mt); | ||
25 | p = fSetArray(diff->height, 1, 0); | ||
26 | |||
27 | temp = sqrt(1.0/(pow(2*pi, n_channel))); | ||
28 | temp2 = randWrapper(diff->height,1); | ||
29 | |||
30 | j = (temp2->height*temp2->width); | ||
31 | for(i=0; i<j; i++) | ||
32 | { | ||
33 | float temp2i; | ||
34 | temp2i = asubsref(temp2,i); | ||
35 | |||
36 | temp2i = exp(-0.5*temp2i); | ||
37 | asubsref(p,i) = temp2i*temp; | ||
38 | } | ||
39 | |||
40 | fFreeHandle(t); | ||
41 | fFreeHandle(temp2); | ||
42 | fFreeHandle(mt); | ||
43 | fFreeHandle(diff); | ||
44 | |||
45 | return p; | ||
46 | } | ||
47 | |||
48 | |||
49 | |||