REBIN

vector

 Syntax: REBIN v vout n 

 Suppose that len(v) = N, then vout[j]=sum(v[(j-1)*n+i],i,[1:n]) for
 j=[1:N/n], that is, the length of vout will be N/n, and
 vout[1]=v[1]+v[2]+...+v[n], vout[2]=v[n+1]+v[n+2]+...+v[2*n], ...,
 vout[N/n]=v[(N/n-1)*n+1]+v[(N/n-1)*n+2]+...+v[N/n*n]

 If N/n*n is not equal to N, the last element of vout will be incomplete.
 For example, if N=10 and n=3, then vout will have 3 elements:
 vout[1]=v[1]+v[2]+v[3], vout[2]=v[4]+v[5]+v[6], vout[3]=v[7]+v[8]+v[9]
 and v[10] will not be included in vout.

Additional Information on:

  • 1_example
  • 2_example
  • matrix

     Syntax: REBIN m mout nr nc
    
     Suppose that m has N rows and M columns, then
     mout[i,j]=sum(sum(m[(i-1)*nr+k,(j-1)*nc+l],k,[1:nr]),l,[1:nc]) for
     i=[1:N/nr] and j=[1:M/nc], that is, the matrix mout will have N/nr
     rows and M/nc columns, and 
       mout[1,1] = sum( m[i,j] ) for all  i=1,nr  and  j=1,nc 
       mout[1,2] = sum( m[i,j] ) for all  i=1,nr  and  j=nc+1,2*nc
       mout[2,1] = sum( m[i,j] ) for all  i=nr+1,2*nr  and  j=1,nc
       mout[2,2] = sum( m[i,j] ) for all  i=nr+1,2*nr  and  j=nc+1,2*nc
               ...
    
     If N/nr*nr is not equal to N, the last row of mout will be incomplete.
     If M/nc*nc is not equal to M, the last column of mout will be incomplete.
    

    Additional Information on:

  • 1_example