function xnew = deltarestrict(x,m1,m2)
% This function computes the restriction of an mth level SG
% delta-network of resistors with given values to a Y-network on 
% the three boundary vertices.
%
% Support functions: restrict.m
%
% INPUT: 
% x - initial resistances on each resistor, stored in TLR ordering
% (the resistance on the opposite edge to each point is given in
% that point's place)
% m1 - beginning level of restriction (size(x) = [3^m1 3])
% m2 - ending level of restriction (size(xnew) = [3^m2 3])
%
% OUTPUT:
% xnew - resistances on resulting Y-network

% Convert each delta in network to a Y circuit
for j = 1:3^(m1-1) ;
  y(3*j-2:3*j) = ydelta(x(3*j-2:3*j)) ;
end

% Use restrict function to perform Y-network restriction
xnew = restrict(y,m1,m2) ;