From 031a9965d80f467d59a531bc4ff838341eda011a Mon Sep 17 00:00:00 2001 From: Paloma de la Puente <paloma.delapuente@upm.es> Date: Wed, 21 Oct 2009 18:50:05 +0000 Subject: [PATCH] alphas instead of indices --- sm/csm/structprior/Constraint.cpp | 20 +++++++++++++++++--- sm/csm/structprior/Constraint.h | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sm/csm/structprior/Constraint.cpp b/sm/csm/structprior/Constraint.cpp index 1e914a7..bae68a8 100644 --- a/sm/csm/structprior/Constraint.cpp +++ b/sm/csm/structprior/Constraint.cpp @@ -20,13 +20,26 @@ Values Constraint::ApplyConstraint(double alphas[], double params[]) { Values v; double err = 0; - double grd = 0; + double grd[3] = {0,0,0}; switch(type) { 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; } @@ -40,7 +53,8 @@ Values Constraint::ApplyConstraint(double alphas[], double params[]) } v.error = err; - v.grad = grd; + for (int i=0;i< 3;i++) + v.grad[i] = grd[i]; return v; } diff --git a/sm/csm/structprior/Constraint.h b/sm/csm/structprior/Constraint.h index a98a54a..3260aca 100644 --- a/sm/csm/structprior/Constraint.h +++ b/sm/csm/structprior/Constraint.h @@ -11,7 +11,7 @@ struct Values{ double error; - double grad; + double grad[]; }; -- GitLab