Mercurial > hg > octave-nkf
changeset 5295:015b15716cbe
[project @ 2005-04-21 16:38:38 by jwe]
author | jwe |
---|---|
date | Thu, 21 Apr 2005 16:38:38 +0000 |
parents | f04d9f855794 |
children | 4e753a157ed2 |
files | src/ChangeLog src/DLD-FUNCTIONS/__qp__.cc |
diffstat | 2 files changed, 35 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -3,6 +3,8 @@ * version.h (OCTAVE_VERSION): Now 2.9.2. (OCTAVE_API_VERSION): Now api-v15. + * DLD-FUNCTIONS/__qp__.cc (qp): Use octave_idx_type where needed. + * DLD-FUNCTIONS/__qp__.cc: New file. * Makefile.in (DLD_XSRC): Add it to the list.
--- a/src/DLD-FUNCTIONS/__qp__.cc +++ b/src/DLD-FUNCTIONS/__qp__.cc @@ -45,7 +45,7 @@ } static Matrix -null (const Matrix& A, int& rank) +null (const Matrix& A, octave_idx_type& rank) { Matrix retval; @@ -61,16 +61,16 @@ Matrix V = A_svd.right_singular_matrix (); - int A_nr = A.rows (); - int A_nc = A.cols (); + octave_idx_type A_nr = A.rows (); + octave_idx_type A_nc = A.cols (); - int tmp = A_nr > A_nc ? A_nr : A_nc; + octave_idx_type tmp = A_nr > A_nc ? A_nr : A_nc; double tol = tmp * s(0) * DBL_EPSILON; - int n = s.length (); + octave_idx_type n = s.length (); - for (int i = 0; i < n; i++) + for (octave_idx_type i = 0; i < n; i++) { if (s(i) > tol) rank++; @@ -90,13 +90,13 @@ { // R should be the result of calling chol on a symmetric positive // definite matrix. - int n = R.rows (); + octave_idx_type n = R.rows (); Matrix L = R.transpose (); ColumnVector d = L.diag (); ColumnVector tmp (n); - for (int k = 0; k < n; k++) + for (octave_idx_type k = 0; k < n; k++) { - for (int j = 0; j < n; j++) + for (octave_idx_type j = 0; j < n; j++) L(j,k) = L(j,k) / d(k); tmp(k) = 1.0/(d(k)*d(k)); } @@ -119,17 +119,17 @@ double rtol = sqrt (DBL_EPSILON); // Problem dimension. - int n = x.length (); + octave_idx_type n = x.length (); // Dimension of constraints. - int n_eq = beq.length (); - int n_in = bin.length (); + octave_idx_type n_eq = beq.length (); + octave_idx_type n_in = bin.length (); // Filling the current active set. - int n_act = n_eq; + octave_idx_type n_act = n_eq; - int n_tot = n_eq + n_in; + octave_idx_type n_tot = n_eq + n_in; // Equality constraints come first. We won't check the sign of the // Lagrange multiplier for those. @@ -142,7 +142,7 @@ { ColumnVector res = Ain*x - bin; - for (int i = 0; i < n_in; i++) + for (octave_idx_type i = 0; i < n_in; i++) { res(i) /= (1.0 + ABS (bin(i))); @@ -162,8 +162,8 @@ ColumnVector eigenvalH = real (eigH.eigenvalues ()); Matrix eigenvecH = real (eigH.eigenvectors ()); double minReal = eigenvalH.min (); - int indminR = 0; - for (int i = 0; i < n; i++) + octave_idx_type indminR = 0; + for (octave_idx_type i = 0; i < n; i++) { if (minReal == eigenvalH(i)) { @@ -239,11 +239,11 @@ // Computing the null space. - int rank; + octave_idx_type rank; Matrix Z = null (Aact, rank); - int dimZ = n - rank; + octave_idx_type dimZ = n - rank; // XXX FIXME XXX -- still remain to handle the case of // non-full rank active set matrix. @@ -255,7 +255,7 @@ Matrix Zt = Z.transpose (); Matrix rH = Zt * H * Z; - int pR = 0; + octave_idx_type pR = 0; if (dimZ > 0) { @@ -301,7 +301,7 @@ Matrix eigenvecrH = real (eigrH.eigenvectors ()); double mRrH = eigenvalrH.min (); indminR = 0; - for (int i = 0; i < n; i++) + for (octave_idx_type i = 0; i < n; i++) { if (mRrH == eigenvalH(i)) { @@ -322,7 +322,7 @@ // Checking the step-size. ColumnVector abs_p (n); - for (int i = 0; i < n; i++) + for (octave_idx_type i = 0; i < n; i++) abs_p(i) = ABS (p(i)); double max_p = abs_p.max (); @@ -345,7 +345,7 @@ { lambda_tmp.resize (n_in, 0.0); - for (int i = n_act-n_eq; i < n_in; i++) + for (octave_idx_type i = n_act-n_eq; i < n_in; i++) lambda_tmp(i) = 0; } @@ -359,8 +359,8 @@ } else { - int which_eig = 0; - for (int i = 0; i < n_act; i++) + octave_idx_type which_eig = 0; + for (octave_idx_type i = 0; i < n_act; i++) { if (lambda_tmp(i) == min_lambda) { @@ -372,10 +372,10 @@ // At least one multiplier is negative, we // remove it from the set. - for (int i = which_eig; i < n_act - n_eq; i++) + for (octave_idx_type i = which_eig; i < n_act - n_eq; i++) { Wact(i) = Wact(i+1); - for (int j = 0; j < n; j++) + for (octave_idx_type j = 0; j < n; j++) Aact(n_eq+i,j) = Aact(n_eq+i+1,j); bact(n_eq+i) = bact(n_eq+i+1); } @@ -402,13 +402,13 @@ // Some constraints were not active. Checking if // there is a blocking constraint. alpha = 1.0; - int is_block = -1; + octave_idx_type is_block = -1; - for (int i = 0; i < n_in; i++) + for (octave_idx_type i = 0; i < n_in; i++) { bool found = false; - for (int j = 0; j < n_act-n_eq; j++) + for (octave_idx_type j = 0; j < n_act-n_eq; j++) { if (Wact(j) == i) { @@ -476,12 +476,12 @@ lambda.resize (n_tot); lambda.fill (0.0); - for (int i = 0; i < n_eq; i++) + for (octave_idx_type i = 0; i < n_eq; i++) lambda(i) = lambda_tmp(i); - for (int i = n_eq; i < n_tot; i++) + for (octave_idx_type i = n_eq; i < n_tot; i++) { - for (int j = 0; j < n_act-n_eq; j++) + for (octave_idx_type j = 0; j < n_act-n_eq; j++) { if (Wact(j) == i) {