disp('Problem 5.5(a)');

A = [-2, 1; -1, 2; 1, 2];
b = [2; 7; 3];
c = [-1; -2];

x = [1;1;1;1;1]; s = x;
y = [0; 0; 0];

m = size(A, 1);
A = [A, eye(m)];
c = [c; zeros(m, 1)];

[x, y, s, obj] = pdpc(A, b, c, x, y, s, 0.99);

disp(' ');
disp('Problem 5.5(b)');
m = 500; n = 650;
A = (2*rand(m, n)-1) * 3;
y = (2*rand(m, 1)-1) * 5;
x = [rand(m, 1) * 7; zeros(n-m, 1)];
s = [rand(m, 1) * 6; zeros(n-m, 1)];
b = A * x;
c = A' * y + s;

x0 = rand(n, 1) * 20;
s0 = rand(n, 1) * 20;

t0 = clock;
[x, y, s, obj] = pdpc(A, b, c, x0, y, s0, 0.99);
disp(['Time: ' num2str(etime(clock, t0)) 'sec']);

t0 = clock;
x = linprog(c, -eye(n), zeros(n, 1), A, b);
disp(['Time: ' num2str(etime(clock, t0)) 'sec']);
disp(['opt obj by linprog = ' num2str(c' * x) ]);
% x(find(x < 0))
