function [X,lambda,how]=conls(A,b,C,d,vlb,vub,X,neqcstr,verbosity)
%CONLS Constrained linear least squares.
%   CONLS has been replaced with LSQLIN.  CONLS currently works but
%   will be removed in the future.  Use LSQLIN instead.
%
%   X=CONLS(A,b,C,d) solves the least-squares problem
%
%           min  0.5*(NORM(A*x-b)).^2       subject to    Cx <= d
%            x
%
%       where A is m-by-n.
%
%       X=CONLS(A,b,C,d,VLB,VUB) defines a set of lower and upper
%       bounds on the design variables, X, so that the solution  
%       is always in the range VLB <= X <= VUB.
%
%       X=CONLS(A,b,C,d,VLB,VUB,X0) sets the initial starting point to X0.
%
%       X=CONLS(A,b,C,d,VLB,VUB,X0,N) indicates that the first N constraints 
%       defined by C and d are equality constraints.
%
%       X=CONLS(A,b,C,d,VLB,VUB,X0,N,DISPLAY) controls the level of warning
%       messages displayed.  Warning messages can be turned off with
%       DISPLAY = -1.
%
%       [x,LAMBDA]=CONLS(A,b,C,d) returns the set of Lagrangian multipliers
%       LAMBDA, affiliated with the related quadratic programming problem,
%       at the solution.
%
%       [X,LAMBDA,HOW] = CONLS(A,b,C,d) also returns a string HOW that 
%       indicates error conditions at the final iteration.
%
%       CONLS produces warning messages when the solution is either unbounded
%       or infeasible and DISPLAY > -1.

%   Copyright (c) 1990-98 by The MathWorks, Inc.
%   $Revision: 1.9 $  $Date: 1998/08/31 22:29:19 $
%   Andy Grace 7-9-90. Mary Ann Branch 9-30-96.


% Handle missing arguments
if nargin < 9, verbosity = 0; 
   if nargin < 8, neqcstr = 0; 
      if nargin < 7, X = []; 
         if nargin < 6, vub = []; 
            if nargin < 5, vlb = [];
               if nargin < 4, d = [];
                  if nargin < 3, C = [];
                  end, end, end, end, end, end, end
[ncstr,nvars]=size(C);
if isempty(A) | isempty(b)
   error('The first two arguments to CONLS cannot be empty matrices.')
else
   nvars = max([size(A,2),nvars]); % In case C is empty
end

[rows,cols]=size(A);
if length(b) ~= rows
   error('The number of rows in A must be equal to the length of b.');
end

if length(d) ~= size(C,1)
   error('The number of rows in C must be equal to the length of d.');
end

if isempty(verbosity), verbosity = 0; end
if isempty(neqcstr), neqcstr = 0; end
if isempty(X), X=zeros(nvars,1); end

if isempty(C), C=zeros(0,nvars); end
if isempty(d), d=zeros(0,1); end

% Set b, d and X to be column vectors
b = b(:);
d = d(:);
X = X(:);

% Test if A is all zeros or empty
if  norm(A,'inf')==0 | isempty(A)
   A=0; 
end

caller = 'conls';
[X,lambda,how]=qpsubold(A,b,C,d,vlb,vub,X,neqcstr,verbosity,caller,ncstr,nvars);



