Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slsum
Home > sltoolbox > core > slsum.m

slsum

PURPOSE ^

SLSUM Compute the sum of values in subarrays

SYNOPSIS ^

function S = slsum(A, d)

DESCRIPTION ^

SLSUM Compute the sum of values in subarrays

 $ Syntax $
   - S = slsum(A) 
   - S = slsum(A, d)
   - S = slsum(A, [d1 d2 ... dk])

 $ Arguments $
   - A:        the input array
   - d:        the dimensions along which the sum is performed
   - S:        the resultant sum matrix

 $ Description $
   - S = slsum(A) sums up the values in column vectors of A. It is 
     equivalent to S = sum(A)

   - S = slsum(A, d) sums up the values along dimension d. It is 
     equivalent to S = sum(A, d)

   - S = slsum(A, [d1 d2 ... dk]) sums up the values along dimension
     d1, d2, ... dk.

 $ History $
   - Created by Dahua Lin on Nov 18th, 2005

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • slnorm SLNORM Compute the Lp-norms

SOURCE CODE ^

0001 function S = slsum(A, d)
0002 %SLSUM Compute the sum of values in subarrays
0003 %
0004 % $ Syntax $
0005 %   - S = slsum(A)
0006 %   - S = slsum(A, d)
0007 %   - S = slsum(A, [d1 d2 ... dk])
0008 %
0009 % $ Arguments $
0010 %   - A:        the input array
0011 %   - d:        the dimensions along which the sum is performed
0012 %   - S:        the resultant sum matrix
0013 %
0014 % $ Description $
0015 %   - S = slsum(A) sums up the values in column vectors of A. It is
0016 %     equivalent to S = sum(A)
0017 %
0018 %   - S = slsum(A, d) sums up the values along dimension d. It is
0019 %     equivalent to S = sum(A, d)
0020 %
0021 %   - S = slsum(A, [d1 d2 ... dk]) sums up the values along dimension
0022 %     d1, d2, ... dk.
0023 %
0024 % $ History $
0025 %   - Created by Dahua Lin on Nov 18th, 2005
0026 %
0027 
0028 %% parse and verify input arguments
0029 if nargin < 2 || isempty(d)
0030     d = 1;
0031 end
0032 
0033 %% compute
0034 if isscalar(d)
0035     S = sum(A, d);
0036 else
0037     k = length(d);
0038     S = A;
0039     for i = 1 : k
0040         S = sum(S, d(i));
0041     end
0042 end
0043 
0044

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com