23 #if defined (HAVE_CONFIG_H) 65 double tol =
tmp *
s(0) * std::numeric_limits<double>::epsilon ();
76 retval =
V.extract (0, rank, A_nc-1, A_nc-1);
99 double rtol = sqrt (std::numeric_limits<double>::epsilon ());
147 catch (octave::execution_exception&
e)
149 error (
e,
"qp: failed to compute eigenvalues of H");
154 double minReal = eigenvalH.
min ();
158 if (minReal == eigenvalH(
i))
213 p = eigenvecH.column (indminR);
217 if (
p.transpose () * g > std::numeric_limits<double>::epsilon ())
224 lambda_tmp.
fill (0.0);
295 catch (octave::execution_exception&
e)
297 error (
e,
"qp: failed to compute eigenvalues of rH");
302 double mRrH = eigenvalrH.
min ();
306 if (mRrH == eigenvalH(
i))
318 if (
p.transpose () * g > std::numeric_limits<double>::epsilon ())
327 double max_p = abs_p.
max ();
332 if (n_act - n_eq == 0)
342 Yt = Yt.
extract_n (n_eq, 0, n_act-n_eq, n);
343 lambda_tmp = Yt * (g + H *
p);
347 double min_lambda = lambda_tmp.
min ();
358 if (lambda_tmp(
i) == min_lambda)
373 Aact(n_eq+
i,j) = Aact(n_eq+
i+1,j);
374 bact(n_eq+
i) = bact(n_eq+
i+1);
387 if (n_act - n_eq == n_in)
419 double tmp = tmp_row *
p;
420 double res = tmp_row *
x;
424 double alpha_tmp = (bin(
i) - res) /
tmp;
426 if (alpha_tmp < alpha)
442 Aact = Aact.
stack (Ain.
row (is_block));
443 bact.
resize (n_act, bin(is_block));
444 Wact.
resize (n_act-n_eq, is_block);
473 lambda(
i) = lambda_tmp(
i);
479 if (Wact(j) ==
i - n_eq)
481 lambda(
i) = lambda_tmp(n_eq+j);
490 DEFUN (__qp__, args, ,
496 if (args.length () != 8)
500 const Matrix H (args(1).matrix_value ());
502 const Matrix Aeq (args(3).matrix_value ());
504 const Matrix Ain (args(5).matrix_value ());
506 const int maxit (args(7).int_value ());
516 int info =
qp (H, q, Aeq, beq, Ain, bin, maxit,
x, lambda, iter);
518 return ovl (
x, lambda, info, iter);
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)
Matrix pseudo_inverse(double tol=0.0) const
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT F77_DBLE * V
ColumnVector extract_diag(octave_idx_type k=0) const
is already an absolute the name is checked against the file system instead of Octave s loadpath In this if otherwise an empty string is returned If the first argument is a cell array of search each directory of the loadpath for element of the cell array and return the first that matches If the second optional argument return a cell array containing the list of all files that have the same name in the path If no files are found
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
RowVector row(octave_idx_type i) const
OCTINTERP_API void print_usage(void)
DM_T singular_values(void) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
ComplexMatrix right_eigenvectors(void) const
Matrix stack(const Matrix &a) const
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
T right_singular_matrix(void) const
octave_value resize(const dim_vector &dv, bool fill=false) const
static Matrix null(const Matrix &A, octave_idx_type &rank)
Matrix transpose(void) const
F77_RET_T const F77_INT F77_CMPLX * A
octave_idx_type numel(const octave_value_list &idx)
Array< T > column(octave_idx_type k) const
Extract column: A(:,k+1).
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
ComplexColumnVector eigenvalues(void) const
Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
octave_idx_type numel(void) const
Number of elements in the array.
ColumnVector real(const ComplexColumnVector &a)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
T chol_matrix(void) const
void resize(octave_idx_type n, const double &rfv=0)