from
slatec
by Ben Barrowes The slatec library converted into matlab functions.
[l,v]=dbdiff(l,v);
function [l,v]=dbdiff(l,v);
%***BEGIN PROLOGUE DBDIFF
%***SUBSIDIARY
%***PURPOSE Subsidiary to DBSKIN
%***LIBRARY SLATEC
%***TYPE doubleprecision (BDIFF-S, DBDIFF-D)
%***AUTHOR Amos, D. E., (SNLA)
%***DESCRIPTION
%
% DBDIFF computes the sum of B(L,K)*V(K)*(-1)**K where B(L,K)
% are the binomial coefficients. Truncated sums are computed by
% setting last part of the V vector to zero. On return, the binomial
% sum is in V(L).
%
%***SEE ALSO DBSKIN
%***ROUTINES CALLED (NONE)
%***REVISION HISTORY (YYMMDD)
% 820601 DATE WRITTEN
% 891214 Prologue converted to Version 4.0 format. (BAB)
% 900328 Added TYPE section. (WRB)
%***end PROLOGUE DBDIFF
%
persistent i j k ;
if isempty(i), i=0; end;
if isempty(j), j=0; end;
if isempty(k), k=0; end;
v_shape=size(v);v=reshape(v,1,[]);
%***FIRST EXECUTABLE STATEMENT DBDIFF
if( l==1 )
v_shape=zeros(v_shape);v_shape(:)=v(1:numel(v_shape));v=v_shape;
return;
end;
for j = 2 : l;
k = fix(l);
for i = j : l;
v(k) = v(k-1) - v(k);
k = fix(k - 1);
end; i = fix(l+1);
end; j = fix(l+1);
v_shape=zeros(v_shape);v_shape(:)=v(1:numel(v_shape));v=v_shape;
end
%DECK DBESI0