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/quatRot.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/quatRot.c')
-rw-r--r-- | SD-VBS/benchmarks/localization/src/c/quatRot.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/localization/src/c/quatRot.c b/SD-VBS/benchmarks/localization/src/c/quatRot.c new file mode 100644 index 0000000..4962b55 --- /dev/null +++ b/SD-VBS/benchmarks/localization/src/c/quatRot.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <stdlib.h> | ||
7 | #include "localization.h" | ||
8 | |||
9 | F2D* quatRot(F2D* vec, F2D* rQuat) | ||
10 | { | ||
11 | F2D *ret; | ||
12 | int nr, i, j, k, rows, cols; | ||
13 | F2D *tv, *vQuat, *temp, *temp1; | ||
14 | F2D *retVec; | ||
15 | |||
16 | nr = vec->height; | ||
17 | tv = fSetArray(nr, 1, 0); | ||
18 | vQuat = fHorzcat(tv, vec); | ||
19 | temp = quatMul(rQuat, vQuat); | ||
20 | temp1 = quatConj(rQuat); | ||
21 | retVec = quatMul(temp, temp1); | ||
22 | |||
23 | rows = retVec->height; | ||
24 | cols = retVec->width; | ||
25 | |||
26 | ret = fSetArray(rows, 3, 0); | ||
27 | |||
28 | for(i=0; i<rows; i++) | ||
29 | { | ||
30 | k = 0; | ||
31 | for(j=1; j<4; j++) | ||
32 | { | ||
33 | subsref(ret,i,k) = subsref(retVec,i,j); | ||
34 | k++; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | fFreeHandle(tv); | ||
39 | fFreeHandle(vQuat); | ||
40 | fFreeHandle(temp); | ||
41 | fFreeHandle(temp1); | ||
42 | fFreeHandle(retVec); | ||
43 | |||
44 | return ret; | ||
45 | } | ||
46 | |||
47 | |||