Commit d7e61080 authored by Davis King's avatar Davis King

Made the solver return the number of iterations performed.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404001
parent 25720eaf
...@@ -107,7 +107,7 @@ namespace dlib ...@@ -107,7 +107,7 @@ namespace dlib
typename EXP2, typename EXP2,
long NR long NR
> >
void operator() ( unsigned long operator() (
const matrix_exp<EXP1>& Q, const matrix_exp<EXP1>& Q,
const matrix_exp<EXP2>& y, const matrix_exp<EXP2>& y,
const scalar_type nu, const scalar_type nu,
...@@ -150,10 +150,13 @@ namespace dlib ...@@ -150,10 +150,13 @@ namespace dlib
} }
} }
unsigned long count = 0;
// now perform the actual optimization of alpha // now perform the actual optimization of alpha
long i=0, j=0; long i=0, j=0;
while (find_working_group(y,alpha,Q,df,tau,eps,i,j)) while (find_working_group(y,alpha,Q,df,tau,eps,i,j))
{ {
++count;
const scalar_type old_alpha_i = alpha(i); const scalar_type old_alpha_i = alpha(i);
const scalar_type old_alpha_j = alpha(j); const scalar_type old_alpha_j = alpha(j);
...@@ -168,6 +171,8 @@ namespace dlib ...@@ -168,6 +171,8 @@ namespace dlib
for(long k = 0; k < df.nr(); ++k) for(long k = 0; k < df.nr(); ++k)
df(k) += Q_i(k)*delta_alpha_i + Q_j(k)*delta_alpha_j; df(k) += Q_i(k)*delta_alpha_i + Q_j(k)*delta_alpha_j;
} }
return count;
} }
const column_matrix& get_gradient ( const column_matrix& get_gradient (
......
...@@ -93,7 +93,7 @@ namespace dlib ...@@ -93,7 +93,7 @@ namespace dlib
typename EXP2, typename EXP2,
long NR long NR
> >
void operator() ( unsigned long operator() (
const matrix_exp<EXP1>& Q, const matrix_exp<EXP1>& Q,
const matrix_exp<EXP2>& y, const matrix_exp<EXP2>& y,
const scalar_type nu, const scalar_type nu,
...@@ -121,6 +121,7 @@ namespace dlib ...@@ -121,6 +121,7 @@ namespace dlib
(a reasonable eps is usually about 1e-3) (a reasonable eps is usually about 1e-3)
- #get_gradient() == Q*(#alpha) - #get_gradient() == Q*(#alpha)
(i.e. stores the gradient of f() at #alpha in get_gradient()) (i.e. stores the gradient of f() at #alpha in get_gradient())
- returns the number of iterations performed.
throws throws
- invalid_nu_error - invalid_nu_error
This exception is thrown if nu >= maximum_nu(y). This exception is thrown if nu >= maximum_nu(y).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment