hi everyone!
i have some project about using svm the coding using C++, ii wanna use this parameter in my java processing because i needed to control robot using leap motion and the svm as the decision maker. the array of double send error.
in the processing web they said
Processing functions don’t use this datatype, so while they work in the language, you’ll usually have to convert to a float using the (float) syntax before passing into a function
please help! i really stuck
double param1[6][14] = {{1,1,1,1,0.792019601,1,1,-1,-1,-1,-1,-1,-0.792019601,-1},
{-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1},
{-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1},
{-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558,0.033558}};
double param2[6][18] = {{1,1,1,1,0.318464496,1,1,1,0.769380154,-1,-1,-1,-1,-0.087844649,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-0.25701,-0.21729,-0.09348,-0.08653,0.145652,0.062454,-0.01667,0.079085,0.0012,-0.4499,-0.44327,-0.46571,-0.42028,-0.42201,-0.44852,-0.41926,-0.39713,-0.40579},
{-121085,-116608,-107282,-112798,-0.88837,-0.94401,-107663,-0.90106,-115809,-0.84784,-0.83931,-0.80587,-0.70346,-0.70533,-0.92365,-0.9593,-0.97531,-0.94895},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568,-0.86568}};
double param3[6][19] = {{1,1,1,1,0.456578608,1,1,1,1,-1,-0.187059758,-1,-1,-1,-1,-1,-1,-1,-0.26951885},
{1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1.25614,-1.19248,-0.994,-0.98286,-0.66881,-0.87087,-0.65989,-0.84223,-0.7936,-1.22893,-1.19252,-1.29349,-0.98669,-0.98892,-1.18328,-1.36766,-1.32095,-0.24681,0.483479},
{0.323382,0.354186,0.418358,0.380401,0.487666,0.415735,0.365585,0.359688,0.345772,0.074203,-0.00114,0.093422,0.007426,-0.04313,0.033755,0.055782,0.035636,-0.17976,-0.42344},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{-0.02824,-0.02825,-0.02826,-0.02827,-0.02828,-0.02829,-0.02830,-0.02831,-0.02832,-0.02833,-0.02834,-0.02835,-0.02836,-0.02837,-0.02838,-0.02839,-0.02840,-0.02841,-0.02842}};
double param4[6][20] = {{1,1,1,1,1,1,0.463702921,1,1,1,-1,-1,-0.705748012,-1,-1,-1,-1,-1,-1,-0.75795491},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1},
{1.017038,1.046933,0.902235,0.736103,0.860032,0.736503,0.724111,0.655464,0.67848,0.713734,1.140196,1.150551,1.115492,1.14235,1.18807,1.222666,1.209121,0.924121,0.126399,-0.54345},
{-0.37552,-0.41018,-0.42873,-0.4702,-0.46058,-0.45412,-0.49043,-0.37792,-0.39576,-0.40371,-0.06427,-0.05869,-0.03677,-0.11394,-0.1373,-0.14779,-0.13052,-0.01386,0.167516,0.318457},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{-0.24815,-0.24816,-0.24817,-0.24818,-0.24819,-0.24820,-0.24821,-0.24822,-0.24823,-0.24824,-0.24825,-0.24826,-0.24827,-0.24828,-0.24829,-0.24830,-0.24831,-0.24832,-0.24833,-0.24834}};
double param5[6][16] = {{1,1,1,1,1,1,0.883359223,1,-1,-1,-1,-1,-0.883359223,-1,-1,-1},
{-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1},
{0.121326,0.140013,0.049562,-0.05429,-0.04718,0.02318,-0.09362,-0.06178,0.403332,0.425519,0.363987,0.382795,0.394049,0.43115,0.31879,0.34725},
{1.162903,1.107373,1.07764,1.011192,0.96486,1.026602,0.969164,0.978771,0.900346,0.785385,0.929671,0.679563,0.646683,0.83863,0.872239,0.8415},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{-0.98695,-0.98696,-0.98697,-0.98698,-0.98699,-0.98700,-0.98701,-0.98702,-0.98703,-0.98704,-0.98705,-0.98706,-0.98707,-0.98708,-0.98709,-0.98710}};
double param6[6][16] = {{1,1,1,0.339561015,1,1,1,1,-1,-1,-1,-1,-0.339561015,-1,-1,-1},
{-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,-1},
{-0.20354,-0.19362,-0.2272,-0.15921,-0.20148,-0.15769,-0.12455,-0.13752,0.110591,0.144587,0.050308,0.079125,0.096368,0.153214,-0.01894,0.024663},
{0.168873,0.173118,0.18977,0.240751,0.131133,0.113386,0.105415,0.118537,-0.19213,-0.24665,-0.17823,-0.29683,-0.31242,-0.2214,-0.20546,-0.22004},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0.03956,0.03957,0.03958,0.03959,0.03960,0.03961,0.03962,0.03963,0.03964,0.03965,0.03966,0.03967,0.03968,0.03969,0.03970,0.03971}};
void setX1(double x1[14]){
for(int i=0; i<14; i++){
param1[4][i] = x1[i];
}
}
void setX2(double x1[18]){
for(int i=0; i<18; i++){
param2[4][i] = x1[i];
}
}
void setX3(double x1[19]){
for(int i=0; i<19; i++){
param3[4][i] = x1[i];
}
}
void setX4(double x1[20]){
for(int i=0; i<20; i++){
param4[4][i] = x1[i];
}
}
void setX5(double x1[16]){
for(int i=0; i<16; i++){
param5[4][i] = x1[i];
}
}
void setX6(double x1[16]){
for(int i=0; i<16; i++){
param6[4][i] = x1[i];
}
}
int calculate(){
int resultClass;
int numInClass[] = {0,0,0,0} ;
double sf1, sf2, sf3, sf4, sf5, sf6;
for(int i=0; i<14; i++){
sf1 += (param1[0][i] * param1[1][i] * (param1[2][i] + param1[3][i]) * param1[4][i]) + param1[5][i];
}
for(int i=0; i<18; i++){
sf2 += (param2[0][i] * param2[1][i] * (param2[2][i] + param2[3][i]) * param2[4][i]) + param2[5][i];
}
for(int i=0; i<19; i++){
sf3 += (param3[0][i] * param3[1][i] * (param3[2][i] + param3[3][i]) * param3[4][i]) + param3[5][i];
}
for(int i=0; i<20; i++){
sf4 += (param4[0][i] * param4[1][i] * (param4[2][i] + param4[3][i]) * param4[4][i]) + param4[5][i];
}
for(int i=0; i<16; i++){
sf5 += (param5[0][i] * param5[1][i] * (param5[2][i] + param5[3][i]) * param5[4][i]) + param5[5][i];
}
for(int i=0; i<16; i++){
sf6 += (param6[0][i] * param6[1][i] * (param6[2][i] + param6[3][i]) * param6[4][i]) + param6[5][i];
}
if(sf1 > 0) numInClass[0]++;
else numInClass[1]++;
if(sf2 > 0) numInClass[0]++;
else numInClass[2]++;
if(sf3 > 0) numInClass[0]++;
else numInClass[3]++;
if(sf4 > 0) numInClass[1]++;
else numInClass[2]++;
if(sf5 > 0) numInClass[1]++;
else numInClass[3]++;
if(sf6 > 0) numInClass[2]++;
else numInClass[3]++;
cout<<"Class 1 : "<<numInClass[0]<<"\n";
cout<<"Class 2 : "<<numInClass[1]<<"\n";
cout<<"Class 3 : "<<numInClass[2]<<"\n";
cout<<"Class 4 : "<<numInClass[3]<<"\n";
int max = 0;
for(int i=0; i<4; i++){
if(numInClass[i] > max){
max = numInClass[i];
resultClass = i+1;
}
}
cout<<"\nMax: "<<max;
return resultClass;
}
int main(){
cout<<"\nResult: "<<calculate();
return 0;
}