source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/ndsum.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 620 bytes
Line 
1function x = ndsum(x,dim)
2% NDSUM    Multi-dimensional summation.
3% NDSUM(X,DIM) sums out the dimensions in DIM, and squeezes the result.
4
5% Written by Tom Minka
6% (c) Microsoft Corporation. All rights reserved.
7
8if 0
9  % permutation takes too long
10  x = permute_to_front(x,dim);
11  sz = size(x);
12  msz = sz(1:length(dim));
13  ksz = sz(length(dim)+1:end);
14  x = reshape(x,[prod(msz) ksz]);
15  x = sum(x);
16  x = mysqueeze(x);
17else
18  sz = size(x);
19  for i=1:length(dim)
20    x = sum(x, dim(i));
21  end
22  addflops(prod(sz)-numel(x));
23  %x = mysqueeze(x);
24  sz(dim) = [];
25  x = reshape(x,[sz 1 1]);
26end
Note: See TracBrowser for help on using the repository browser.