function x = gradient_descent1(A, y, x, reg, C, dpot, step, tol, niter)
% in
%	A	system matrix (fatrix)
%	y	data
%	x	initial image
%	C	regularizer matrix
%	dpot	function handle for derivative of potential function
%	step	step size
%	tol	stopping tolerance
%	niter	max number of iterations

for iter=1:niter
	ticker(mfilename, iter, niter)
	grad = A' * (A * x - y) + reg * (C' * dpot(C * x));
	x = x - step * grad;
	if (norm(step*grad(:)) < norm(x(:)) * tol)
		printm('stopped at %d iterations', iter)
		break
	end
end

warn('did not converge in %d iterations', niter)
