Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/logsum.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function y=logsum(x,d) |
matthiasm@8 | 2 %LOGSUM logsum(x,d)=log(sum(exp(x),d)) |
matthiasm@8 | 3 % d gives dimension to sum along |
matthiasm@8 | 4 |
matthiasm@8 | 5 % Copyright (C) Mike Brookes 1998 |
matthiasm@8 | 6 % |
matthiasm@8 | 7 % Last modified Mon Oct 12 15:47:25 1998 |
matthiasm@8 | 8 % |
matthiasm@8 | 9 % VOICEBOX is a MATLAB toolbox for speech processing. Home page is at |
matthiasm@8 | 10 % http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html |
matthiasm@8 | 11 % |
matthiasm@8 | 12 |
matthiasm@8 | 13 if nargin==1 |
matthiasm@8 | 14 d=[find(size(x)-1) 1]; |
matthiasm@8 | 15 d=d(1); |
matthiasm@8 | 16 end |
matthiasm@8 | 17 n=size(x,d); |
matthiasm@8 | 18 if n<=1, y=x; return; end |
matthiasm@8 | 19 s=size(x); |
matthiasm@8 | 20 p=[d:ndims(x) 1:d-1]; |
matthiasm@8 | 21 z=reshape(permute(x,p),n,prod(s)/n); |
matthiasm@8 | 22 |
matthiasm@8 | 23 y=max(z); |
matthiasm@8 | 24 y=y+log(sum(exp(z-y(ones(n,1),:)))); |
matthiasm@8 | 25 |
matthiasm@8 | 26 s(d)=1; |
matthiasm@8 | 27 y=ipermute(reshape(y,s(p)),p); |
matthiasm@8 | 28 |