BCLS: Bound Constrained Least Squares

Version 0.1

/matlab/test.m

00001 function test
00002 % ----------------------------------------------------------------------
00003 % aprod.m: Test driver for Matlab interface to BCLS.
00004 % ----------------------------------------------------------------------
00005 % Calls matrix-vector routine aprod.m
00006 %
00007 % Copyright 2006, Michael P. Friedlander, Univ of British Columbia
00008 %
00009 % $Revision: 273 $ $Date: 2006-09-04 15:59:04 -0700 (Mon, 04 Sep 2006) $
00010 
00011 rand('state',0);            % Make experiments reproducible.
00012 options.print_level = 2;    % Increase print level.
00013 
00014 % ----------------------------------------------------------------------
00015 % Explicit sparse matrix.
00016 % ----------------------------------------------------------------------
00017 
00018 fprintf('\nBCLS Test 1: Explicit random matrix\n');
00019 fprintf(  '-----------------------------------\n');
00020 
00021 m    =  1000;
00022 n    =   500;
00023 A    =  sprand(m, n, 0.01);
00024 b    =  randn(m, 1);
00025 bl   =  zeros(n, 1);
00026 bu   =  inf*ones(n,1);
00027 c    =  randn(n, 1);
00028 x0   =  zeros(n, 1);
00029 y0   =  zeros(m, 1);
00030 z0   =  zeros(n, 1);
00031 damp =  0;
00032 
00033 options.major_itns  = 40;
00034 options.usolve      = @(mode, ix, z)usolve(mode, ix, z, A);
00035 
00036 [Xsol, g, info] = bcls(A, b, bl, bu, x0, c, damp, options);
00037 
00038 % ----------------------------------------------------------------------
00039 % Implicit matrix.
00040 % ----------------------------------------------------------------------
00041 
00042 fprintf('\nBCLS Test 2: Implicit matrix\n');
00043 fprintf(  '----------------------------\n');
00044 
00045 options.usolve = ;      % No preconditioning for this problem.
00046 
00047 n    = 100;               % No. of columns (and rows) of A.
00048 b    = aprod( 1, 1:n, ones(n,1) );
00049 bl   = zeros(n,1);        % Solution must be nonnegative.
00050 bu   = ;                % No upper bounds on variables. 
00051 c    = ;                % No linear term.
00052 x    = rand(n,1);         % Use random starting vector.
00053 
00054 [xsol, g, info] = bcls(@aprod, b, bl, bu, x, c, 0, options);

Generated on Sun Mar 4 22:50:03 2007 by Doxygen 1.5.1