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/svm/src/c/examineExample.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/svm/src/c/examineExample.c')
| -rw-r--r-- | SD-VBS/benchmarks/svm/src/c/examineExample.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/svm/src/c/examineExample.c b/SD-VBS/benchmarks/svm/src/c/examineExample.c new file mode 100644 index 0000000..5335f35 --- /dev/null +++ b/SD-VBS/benchmarks/svm/src/c/examineExample.c | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include "svm.h" | ||
| 6 | |||
| 7 | int examineExample(int i, F2D* a, float* b, float C, F2D* e, F2D* X, F2D* Y, float tolerance, int N, float eps, int dim) | ||
| 8 | { | ||
| 9 | int ret, j, k, m, n; | ||
| 10 | float E, r1, randVal; | ||
| 11 | float maxDiff, temp; | ||
| 12 | |||
| 13 | if( ( asubsref(a,i) > 0) && ( asubsref(a,i) <C) ) | ||
| 14 | E = asubsref(e,i); | ||
| 15 | else | ||
| 16 | E = cal_learned_func(i, a, b, N, Y, X, dim) - asubsref(Y,i); | ||
| 17 | |||
| 18 | r1 = subsref(Y,i,0) * E; | ||
| 19 | if( ((r1 < (-1*tolerance)) && ( asubsref(a,i) < C)) || ((r1 >tolerance) && ( asubsref(a,i) > 0)) ) | ||
| 20 | { | ||
| 21 | maxDiff = 0; | ||
| 22 | j = i; | ||
| 23 | |||
| 24 | for(k=0; k<N; k++) | ||
| 25 | { | ||
| 26 | if( ( asubsref(a,k) > 0) && ( asubsref(a,k) < C) ) | ||
| 27 | { | ||
| 28 | temp = fabsf( E - asubsref(e,k)); | ||
| 29 | if (temp > maxDiff) | ||
| 30 | j = k; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | if ( i!=j) | ||
| 35 | { | ||
| 36 | ret = takeStep(i, j, a, C, e, Y, X, eps, b, N, dim); | ||
| 37 | if(ret == 1) | ||
| 38 | return ret; | ||
| 39 | } | ||
| 40 | |||
| 41 | randVal = 1.0; | ||
| 42 | for( k= (randVal*(N-2)); k<N; k++) | ||
| 43 | { | ||
| 44 | if( ( asubsref(a,k) > 0) && ( asubsref(a,k) <C) ) | ||
| 45 | { | ||
| 46 | ret = takeStep(i, k, a, C, e, Y, X, eps, b, N, dim); | ||
| 47 | if (ret == 1) | ||
| 48 | return ret; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | for(k=0; k<N; k++) | ||
| 53 | { | ||
| 54 | ret = takeStep(i, k, a, C, e, Y, X, eps, b, N, dim); | ||
| 55 | if(ret == 1) | ||
| 56 | return ret; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | |||
| 61 | ret = 0; | ||
| 62 | return ret; | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | |||
