63 double tol = tmp * s(0) * std::numeric_limits<double>::epsilon ();
74 retval = V.
extract (0, rank, A_nc-1, A_nc-1);
79 if (
std::abs (retval(i)) < std::numeric_limits<double>::epsilon ())
97 double rtol = sqrt (std::numeric_limits<double>::epsilon ());
125 res(i) /= (1.0 +
std::abs (bin(i)));
131 bact.
resize (n_act, bin(i));
132 Wact.
resize (n_act-n_eq, i);
143 error (
"qp: failed to compute eigenvalues of H");
149 double minReal = eigenvalH.
min ();
153 if (minReal == eigenvalH(i))
208 p = eigenvecH.
column (indminR);
212 if (p.
transpose () * g > std::numeric_limits<double>::epsilon ())
219 lambda_tmp.
fill (0.0);
250 CHOL cholrH (rH, pR);
288 error (
"qp: failed to compute eigenvalues of rH");
294 double mRrH = eigenvalrH.
min ();
298 if (mRrH == eigenvalH(i))
310 if (p.
transpose () * g > std::numeric_limits<double>::epsilon ())
319 double max_p = abs_p.
max ();
324 if (n_act - n_eq == 0)
334 Yt = Yt.
extract_n (n_eq, 0, n_act-n_eq, n);
335 lambda_tmp = Yt * (g + H * p);
339 double min_lambda = lambda_tmp.
min ();
350 if (lambda_tmp(i) == min_lambda)
365 Aact(n_eq+i,j) = Aact(n_eq+i+1,j);
366 bact(n_eq+i) = bact(n_eq+i+1);
379 if (n_act - n_eq == n_in)
411 double tmp = tmp_row * p;
412 double res = tmp_row *
x;
416 double alpha_tmp = (bin(i) - res) / tmp;
418 if (alpha_tmp < alpha)
434 Aact = Aact.
stack (Ain.
row (is_block));
435 bact.
resize (n_act, bin(is_block));
436 Wact.
resize (n_act-n_eq, is_block);
458 lambda_tmp = Y.
transpose () * (g + H * p);
465 lambda(i) = lambda_tmp(i);
471 if (Wact(j) == i - n_eq)
473 lambda(i) = lambda_tmp(n_eq+j);
482 DEFUN (__qp__, args, ,
484 @deftypefn {Built-in Function} {[@var{x}, @var{lambda}, @var{info}, @var{iter}] =} __qp__ (@var{x0}, @var{H}, @var{q}, @var{Aeq}, @var{beq}, @var{Ain}, @var{bin}, @var{maxit})\n\
485 Undocumented internal function.\n\
490 if (args.length () == 8)
493 const Matrix H (args(1) . matrix_value ());
495 const Matrix Aeq (args(3) . matrix_value ());
497 const Matrix Ain (args(5) . matrix_value ());
499 const int maxit (args(7) . int_value ());
511 int info =
qp (H, q, Aeq, beq, Ain, bin, maxit, x, lambda, iter);
521 error (
"qp: internal error");
524 error (
"__qp__: invalid arguments");