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");
DiagMatrix singular_values(void) const
ColumnVector & fill(double val)
static int qp(const Matrix &H, const ColumnVector &q, const Matrix &Aeq, const ColumnVector &beq, const Matrix &Ain, const ColumnVector &bin, int maxit, ColumnVector &x, ColumnVector &lambda, int &iter)
bool is_empty(void) const
Matrix right_singular_matrix(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
Matrix extract(octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2) const
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
F77_RET_T const octave_idx_type Complex * A
Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
#define DEFUN(name, args_name, nargout_name, doc)
ComplexMatrix eigenvectors(void) const
void error(const char *fmt,...)
RowVector row(octave_idx_type i) const
F77_RET_T const octave_idx_type const octave_idx_type const octave_idx_type double const octave_idx_type double const octave_idx_type double const octave_idx_type double * Z
ColumnVector extract_diag(octave_idx_type k=0) const
Matrix chol_matrix(void) const
octave_idx_type rows(void) const
RowVector transpose(void) const
ComplexColumnVector eigenvalues(void) const
static Matrix null(const Matrix &A, octave_idx_type &rank)
ComplexMatrix chol2inv(const ComplexMatrix &r)
Matrix transpose(void) const
Array< T > column(octave_idx_type k) const
Extract column: A(:,k+1).
octave_idx_type length(void) const
Number of elements in the array.
Matrix stack(const Matrix &a) const
F77_RET_T const octave_idx_type const octave_idx_type const octave_idx_type const double const double octave_idx_type double * V
ColumnVector real(const ComplexColumnVector &a)
octave_idx_type cols(void) const
Matrix pseudo_inverse(double tol=0.0) const
F77_RET_T const double * x
void resize(octave_idx_type n, const double &rfv=0)