Mercurial > hg > ishara
view sequences/@seq/cumsum.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | b1280319413e |
children |
line wrap: on
line source
% cumsum - cumsum for sequences % % cumsum :: seq [[N,M]], D:natural -> seq [[N,M]]. % % cumulative sum taken along Dth dimension of the array function y=cumsum(x,n,s0) if length(size(x))>2 error('cumsum not supported for >2 dim array sequences'); end switch n case 1, if nargin<3, s0=zeros(1,size(x,2)); end y=scanl(@cs1,s0,x); case 1, if nargin<3, s0=zeros(size(x,2),1); end y=scanl(@cs2,s0,x); case 3, error('cumsum(.,3) not supported for sequences'); end function w=cs1(s,z), w=row(cumsum([s(end,:);z],1),2:size(z,1)+1); end function w=cs2(s,z), w=col(cumsum([s(:,end),z],2),2:size(z,2)+1); end end