function [xxx]=residual(hhh)

%% check that hhh is a column
[ii,jj]=size(hhh);
if jj>ii
hhh=hhh.';
end
 
%% check that spike is positive
yy=real(max(hhh));
if yy<0
hhh=-hhh;
end
%
[y,i]=max(abs(hhh));
desired_response=zeros(length(hhh),1);
desired_response(i)=1;
xxx=(desired_response-hhh)'*(desired_response-hhh);

