function [x, fval, exitflag, output] = runqpbox5
% RUNQPBOX4 demonstrates 'HessMult' option for QUADPROG with equalities.
% 

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.1 $  $Date: 2000/06/16 21:54:26 $

load qpbox5 % Get xstart, u, l, B, A, f
mtxmpy = @qpbox5mult; % function handle to subfunction qpbox4mult

% Choose the HessMult option
% Override the TolPCG option
options = optimset('HessMult',mtxmpy,'display','iter','TolPcg',0.01); 

% Pass B to qpbox4mult via the H argument. Also, B will be used in
% computing a preconditioner for PCG.
% A is passed as an additional argument after 'options'
n = length(f);
[x, fval, exitflag, output] = quadprog([],f,[],[],Aeq,beq,[],[],xstart,options,A,B);

%----------------------------------------------------------------------------
function W = qpbox5mult(dummy,Y,A,B);
% QPBOX4MULT Structured multiply
%
%   W = qpbox4mult(B,Y,A);
%
%   Compute W = (B + A)*Y where 
%
%   INPUT:
%       Y - vector (or matrix) to be multiplied by B+A.
%       B - sparse square matrix (512 by 512)
%       A - sparse matrix with 512 rows and 10 columns.
%
%   OUTPUT:
%       W - The product (B + A)*Y.
%

  W = B*Y;
  U = A*Y; 
  W = W + U;