function adjsubsref(i)
global tape
global globp


if ~isempty(tape(i).arg2vc)
[m,n]=size(tape(i).val);
[m2,n2]=size(tape(tape(i).arg1vc).val);
if isempty(tape(i).arg3vc)


len=length(tape(i).arg2vc);
if (m2==1) m2=n2; end
if (max(tape(i).arg2vc) <= m2) | isequal(tape(i).arg2vc,':')
% next line changed (Thomas Slawig 05/31/2006), originally was:
% if isequal(tape(i).arg2vc,':')
if (~isnumeric(tape(i).arg2vc)) & isequal(tape(i).arg2vc,':')
tape(tape(i).arg1vc).W=tape(tape(i).arg1vc).W+reshape(tape(i).W,size(tape(tape(i).arg1vc).W));
else
for j=1:len
tape(tape(i).arg1vc).W(tape(i).arg2vc(j),:)=tape(tape(i).arg1vc).W(tape(i).arg2vc(j),:)+tape(i).W(j,:);
end
end


else
I=tape(i).arg2vc;
for j=1:length(I)
jindex=ceil(I(j)/n2);
iindex=I(j)-m2*(jindex-1);
tape(tape(i).arg1vc).W(iindex,jindex,:)=tape(tape(i).arg1vc).W(iindex,jindex,:)+tape(i).W(j,:);
end

end
else
if (ndims(tape(i).W)==3)
for j=1:globp
tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc,j)=tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc,j)+tape(i).W(:,:,j);
end
else
if (ndims(tape(tape(i).arg1vc).W)==3)

for j=1:globp
if (m==1) & (n~=1)
tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc,j)=tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc,j)+tape(i).W(:,j)';
else
tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc,j)=tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc,j)+tape(i).W(:,j);
end
end
else
if ~isequal(tape(i).arg2vc,':') & ~isequal(tape(i).arg3vc,':')
if length(tape(i).arg2vc) > 1  | length(tape(i).arg3vc) > 1
if ((m==1) & (n~=1)) & (size(tape(tape(i).arg1vc).val,1)~=1)
tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc)=tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc)+tape(i).W';
else
tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc)=tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc)+tape(i).W;
end
else
if size(tape(tape(i).arg1vc).val,1)==1
tape(tape(i).arg1vc).W(tape(i).arg3vc,:)=tape(tape(i).arg1vc).W(tape(i).arg3vc,:)+tape(i).W;
else
tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc)=tape(tape(i).arg1vc).W(tape(i).arg2vc,tape(i).arg3vc)+tape(i).W;
end

end

elseif ~isequal(tape(i).arg2vc,':')
[p,q]=size(tape(tape(i).arg1vc).val);
if p==1
tape(tape(i).arg1vc).W=tape(tape(i).arg1vc).W+tape(i).W;
else
tape(tape(i).arg1vc).W(tape(i).arg2vc,:)=tape(tape(i).arg1vc).W(tape(i).arg2vc,:)+reshape(tape(i).W,size(tape(tape(i).arg1vc).W(tape(i).arg2vc,:)));
end
else
if m2==1 & n2~=1
tape(tape(i).arg1vc).W(tape(i).arg3vc,:)=tape(tape(i).arg1vc).W(tape(i).arg3vc,:)+tape(i).W;
else
tape(tape(i).arg1vc).W(:,tape(i).arg3vc,:)=tape(tape(i).arg1vc).W(:,tape(i).arg3vc,:)+tape(i).W;
end
%tape(tape(i).arg1vc).W(tape(i).arg3vc,:)=tape(tape(i).arg1vc).W(tape(i).arg3vc,:)+tape(i).W;
end

end

end

end
end
