function y=partial1D(x,dir,g)
% PARTIAL1D partial derivative +dx/2
[nx nz]=size(x);
[nop onz]=size(g);
if nz > nx, nx=nz; end
if onz > nop, nop=onz; end


if dir==1, ig=nop/2;end 
if dir==-1, ig=nop/2+1;end 

sum=x*g(ig);

% causal terms

temp=x;
for j=ig+1:nop,
	temp=cshift1d(x,-1);
	sum=sum+g(j)*temp;
end

% anti-causal

temp=x;
for j=ig-1:-1:1,
	temp=cshift1d(x,1);
	sum=sum+g(j)*temp;
end

y=-sum;




