function [X, y, Z, C, A, b, X_0, y_0] = testgrssdp(n, m, toler, precond);
% generate C, A, b randomly (along with initial solutions X_0 and y_0) and solve the following problem
% min <C,X> subject to A(X) = b, X >= 0
% n: size of matrix X
% m: number of constraints
% toler: relative tolerance
% A: cell of m symmetric matrices
% C: symmetric objective matrix
% b: vector m by 1 right-hand side
% X_0, y_0: initial solutions

rand('state',sum(100*clock));
%construct random matrices A
A = cell(m,1);
for i=1:m
	B = -2*rand(n) + 1; %random matrix with elements in (-1,1)
	A{i} = (1/2)*(B + B');
end
%construct random righ-hand side and intial solution X_0>=0
%B = -2*rand(n) + 1;
[q,r] = qr(randn(n));
X_0 = q*diag(1+10*rand(n,1))*q';
X_0 = (X_0+X_0')/2;
%X_0 = B*B';
b = zeros(m,1);
for i=1:m
	b(i) = trace(A{i}*X_0);
end
%construct random objective and initial solution y_0
y_0 = -2*rand(m,1) + 1;
[q,r] = qr(randn(n));
Z_0 = q*diag(1+10*rand(n,1))*q';
Z_0 = (Z_0+Z_0')/2;
%B = -2*rand(n) + 1;
%Z_0 = B*B';
C = Z_0;
for i=1:m
	C = C + y_0(i)*A{i};
end
%solve the problem using rsdp with all default parameters
[X, y, Z, muu, itersinfo, meritfn] = grssdp(C, A, b, toler, precond);
