function out = op(arg1,operator,arg2)
% computes the binnary operation on the arguments, extending 1-dim
% dimmensions apropriately. E.g. it is ok to multiply 1xNxP and
% MxNx1 matrices, subtarct a vector from a matrix, etc.
%
% Written by Nathan Srebro, MIT LCS, October 1998.
shape1=[size(arg1),ones(1,length(size(arg2))-length(size(arg1)))] ;
shape2=[size(arg2),ones(1,length(size(arg1))-length(size(arg2)))] ;
out = feval(operator, ...
repmat(arg1,(shape1==1) .* shape2 + (shape1 ~= 1) ), ...
repmat(arg2,(shape2==1) .* shape1 + (shape2 ~= 1) )) ;