0001 function [SX] = integral_dke_jd(dx,X,d)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 if nargin < 3,
0020 error('Wrong number of input arguments for integral_dke_jd');
0021 end
0022
0023 nd = ndims(X);
0024 ndx = length(dx);
0025
0026 if size(X,d) ~= ndx
0027 error('Dimension mismatch');
0028 end
0029
0030 if ndx == 0
0031 SX = [];
0032 return
0033 end
0034 if ndx == 1
0035
0036 SX = squeeze(X*dx);
0037 if size(SX,1) == 1
0038 SX = SX.';
0039 end
0040 return;
0041 end
0042 Xs = shiftdim(X,d-1);
0043 clear X
0044 dx = dx(:);
0045
0046 sizeXs = size(Xs);
0047 Xdxs = zeros(sizeXs);
0048 nds = ndims(Xs);
0049 if nds > 1
0050 Xdxs = repmat(dx,[1,sizeXs(2:nds)]);
0051 else
0052 Xdxs = dx;
0053 end
0054
0055 SXs = sum(Xdxs.*Xs);
0056 clear Xdxs Xs
0057
0058 if nd > 2
0059
0060
0061 SX = shiftdim(shiftdim(SXs,1),nd-d);
0062 else
0063 SX = SXs.';
0064 end
0065