26 #if defined (HAVE_CONFIG_H)
49 double min_val =
x.min ();
52 if (min_val ==
x.xelem (i))
80 double tol = tmp * s(0) * std::numeric_limits<double>::epsilon ();
91 retval =
V.extract (0, rank, A_nc-1, A_nc-1);
96 if (
std::abs (
retval(i)) < std::numeric_limits<double>::epsilon ())
107 int maxit,
double rtol,
140 res(i) /= (1.0 +
std::abs (bin(i)));
146 bact.
resize (n_act, bin(i));
147 Wact.
resize (n_act-n_eq, i);
160 catch (octave::execution_exception& e)
162 error (e,
"qp: failed to compute eigenvalues of H");
194 double minReal = eigenvalH.
xelem (indminR);
219 p = eigenvecH.
column (indminR);
223 if (p.
transpose () * g > std::numeric_limits<double>::epsilon ())
230 lambda_tmp.
fill (0.0);
301 catch (octave::execution_exception& e)
303 error (e,
"qp: failed to compute eigenvalues of rH");
315 if (p.
transpose () * g > std::numeric_limits<double>::epsilon ())
324 double max_p = abs_p.
max ();
329 if (n_act - n_eq == 0)
340 lambda_tmp = Yt * (g + H * p);
344 double min_lambda = lambda_tmp.
min ();
355 if (lambda_tmp(i) == min_lambda)
370 Aact(n_eq+i,j) = Aact(n_eq+i+1,j);
371 bact(n_eq+i) = bact(n_eq+i+1);
384 if (n_act - n_eq == n_in)
416 double tmp = tmp_row * p;
417 double res = tmp_row *
x;
421 double alpha_tmp = (bin(i) - res) / tmp;
423 if (alpha_tmp < alpha)
439 Aact = Aact.
stack (Ain.
row (is_block));
440 bact.
resize (n_act, bin(is_block));
441 Wact.
resize (n_act-n_eq, is_block);
463 lambda_tmp = Y.
transpose () * (g + H * p);
470 lambda(i) = lambda_tmp(i);
476 if (Wact(j) == i - n_eq)
478 lambda(i) = lambda_tmp(n_eq+j);
487 DEFUN (__qp__, args, ,
493 if (args.length () != 9)
497 const Matrix H (args(1).matrix_value ());
499 const Matrix Aeq (args(3).matrix_value ());
501 const Matrix Ain (args(5).matrix_value ());
503 const int maxit (args(7).int_value ());
504 const double rtol (args(8).double_value());
514 int info =
qp (H, q, Aeq, beq, Ain, bin, maxit, rtol,
x, lambda, iter);
516 return ovl (
x, lambda, info, iter);
static octave_idx_type min_index(const ColumnVector &x)
static int qp(const Matrix &H, const ColumnVector &q, const Matrix &Aeq, const ColumnVector &beq, const Matrix &Ain, const ColumnVector &bin, int maxit, double rtol, ColumnVector &x, ColumnVector &lambda, int &iter)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
void resize(octave_idx_type n, const double &rfv=0)
ColumnVector & fill(double val)
RowVector transpose(void) const
ColumnVector extract_diag(octave_idx_type k=0) const
ComplexMatrix right_eigenvectors(void) const
ComplexColumnVector eigenvalues(void) const
Matrix pseudo_inverse(double tol=0.0) const
RowVector row(octave_idx_type i) const
Matrix stack(const Matrix &a) const
Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
Matrix transpose(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
ColumnVector column(octave_idx_type i) const
T chol_matrix(void) const
DM_T singular_values(void) const
T right_singular_matrix(void) const
ColumnVector real(const ComplexColumnVector &a)
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Z
F77_RET_T const F77_INT F77_CMPLX * A
F77_RET_T const F77_DBLE * x
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.