function [df]=pddiff2(f,dim)
% ddiff First order accurrate finite difference second derivative.
% usage::  [df]=ddiff2[f,dim]
%
% first order accurrate diff(f,2,dim).  size(df)==size(f) 

% revision history:
% 09/12/97 Mark D. Shattuck <mds>   ddiff2.m


perm = [dim:max(ndims(f),dim) 1:dim-1];
f = permute(f,perm);
        
siz = size(f);

df=ipermute(reshape(f([2:siz(1) 1],:)-2*f(:,:)+f([siz(1) 1:siz(1)-1],:),siz),perm); 
