Skip to content
Snippets Groups Projects
Commit 031a9965 authored by Paloma de la Puente's avatar Paloma de la Puente
Browse files

alphas instead of indices

parent 1acdb927
No related branches found
No related tags found
No related merge requests found
...@@ -20,13 +20,26 @@ Values Constraint::ApplyConstraint(double alphas[], double params[]) ...@@ -20,13 +20,26 @@ Values Constraint::ApplyConstraint(double alphas[], double params[])
{ {
Values v; Values v;
double err = 0; double err = 0;
double grd = 0; double grd[3] = {0,0,0};
switch(type) switch(type)
{ {
case EQUAL_TO_EITHER: case EQUAL_TO_EITHER:
{ {
double e1 = 0.5*(alphas[1]-alphas[0]);
double e2 = 0.5*(alphas[2]-alphas[1]);
if (e1 < e2)
{
err = e1;
}
else
{
err = e2;
}
break; break;
} }
...@@ -40,7 +53,8 @@ Values Constraint::ApplyConstraint(double alphas[], double params[]) ...@@ -40,7 +53,8 @@ Values Constraint::ApplyConstraint(double alphas[], double params[])
} }
v.error = err; v.error = err;
v.grad = grd; for (int i=0;i< 3;i++)
v.grad[i] = grd[i];
return v; return v;
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
struct Values{ struct Values{
double error; double error;
double grad; double grad[];
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment