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 slnormalize
Home > sltoolbox > core > slnormalize.m

slnormalize

PURPOSE ^

SLNORMALIZE Normalize the sub-arrays

SYNOPSIS ^

function An = slnormalize(A, p, d)

DESCRIPTION ^

SLNORMALIZE Normalize the sub-arrays

 $ Syntax $
   - An = slnormalize(A)
   - An = slnormalize(A, p)
   - An = slnormalize(A, [], d)
   - An = slnormalize(A, p, d)

 $ Arguments $
   - A:        the input array
   - p:        the order of the norm (default = 2)
   - d:        the dimension of subarrays (default = 1, column vectors)
   - An:       the normalized array

 $ Description $
   - An = slnormalize(A) normalizes the column vectors of A by 2nd-order.

   - An = slnormalize(A, p) normalizes the column vectors of a by
     pth-order.

   - An = slnormalize(A, [], d) normalizes the subarrays of A along 
     dimensions specified by d by 2nd-order.

   - An = slnormalize(A, p, d) normalizes the subarrays of A along
     dimensions specified by d by pth-order.

 $ Remarks $
   # Normalize an array by pth order means dividing the elements of 
     the array by its p-th norm.
   # p can be inf or -inf. If p = inf, then the Lp norm is simply the
     maximum magnitude value; while if p = -inf, then the Lp norm is the 
     minimum magnitude value.

 $ History $
   - Created by Dahua Lin on Nov 19th, 2005
   - Modified by Dahua Lin on Sep 10th, 2006
       - replace slmul by slmulvec to increase efficiency

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slenforce SLENFORCE Enforce some property on the array A
  • slmulvec SLMULVEC multiplies a vector to columns or rows of a matrix
  • slnorm SLNORM Compute the Lp-norms
This function is called by:
  • sllocaltanspace SLLOCALTANSPACE Solves the local tangent spaces
  • slregcov SLREGCOV Regularizes covariance matrices
  • slwhiten_from_samples SLWHITEN_FROM_SAMPLES Compute the whitening matrix from sample matrix
  • slpca SLPCA Learns a PCA model from training samples

SOURCE CODE ^

0001 function An = slnormalize(A, p, d)
0002 %SLNORMALIZE Normalize the sub-arrays
0003 %
0004 % $ Syntax $
0005 %   - An = slnormalize(A)
0006 %   - An = slnormalize(A, p)
0007 %   - An = slnormalize(A, [], d)
0008 %   - An = slnormalize(A, p, d)
0009 %
0010 % $ Arguments $
0011 %   - A:        the input array
0012 %   - p:        the order of the norm (default = 2)
0013 %   - d:        the dimension of subarrays (default = 1, column vectors)
0014 %   - An:       the normalized array
0015 %
0016 % $ Description $
0017 %   - An = slnormalize(A) normalizes the column vectors of A by 2nd-order.
0018 %
0019 %   - An = slnormalize(A, p) normalizes the column vectors of a by
0020 %     pth-order.
0021 %
0022 %   - An = slnormalize(A, [], d) normalizes the subarrays of A along
0023 %     dimensions specified by d by 2nd-order.
0024 %
0025 %   - An = slnormalize(A, p, d) normalizes the subarrays of A along
0026 %     dimensions specified by d by pth-order.
0027 %
0028 % $ Remarks $
0029 %   # Normalize an array by pth order means dividing the elements of
0030 %     the array by its p-th norm.
0031 %   # p can be inf or -inf. If p = inf, then the Lp norm is simply the
0032 %     maximum magnitude value; while if p = -inf, then the Lp norm is the
0033 %     minimum magnitude value.
0034 %
0035 % $ History $
0036 %   - Created by Dahua Lin on Nov 19th, 2005
0037 %   - Modified by Dahua Lin on Sep 10th, 2006
0038 %       - replace slmul by slmulvec to increase efficiency
0039 %
0040 
0041 %% parse and verify input arguments
0042 if nargin < 2 || isempty(p)
0043     p = 2;
0044 end
0045 if nargin < 3 || isempty(d)
0046     d = 1;
0047 end
0048 if ~isscalar(p)
0049     error('sltoolbox:notscalar', 'p should be a scalar');
0050 end
0051 if p == 0
0052     error('sltoolbox:zeroerr', 'p should not be zero');
0053 end
0054 
0055 %% compute
0056 nrms = slnorm(A, p, d);
0057 nrms = slenforce(nrms, 'positive');
0058 An = slmulvec(A, 1 ./ nrms);
0059 
0060 
0061

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

Contact us at files@mathworks.com