approximateDec

PURPOSE ^

shape approximation based on sample points and decomposition data

SYNOPSIS ^

function dataApprox = approximateDec(heMatrix, dec, varargin)

DESCRIPTION ^

 shape approximation based on sample points and decomposition data

 Syntax: dataApprox = approximateDec(hcMatrix, dec, 'option', value, ...)

 This function approximates the points in heMatrix (one sample point each 
   column) by an orthogonal projection to a linear subspace of the given
   Hc-representation (dec). The approximated hE vectors are computed by:
       heApprox = P * hE
   where the projection matrix is computed from
       P = baseMatrix * baseMatrix'.
   The base matrix contains nTargetDim columns that span the desired
   linear subspace in the embedding hE-space. Both results are returned in
   dataApprox as the fields
     .projectionMatrix - this is P
     .mappingReducedToEmbedding - this is baseMatrix
     .mappingEmbeddingToreduced - this is pinv(baseMatrix) or simply
        the baseMatrix' since the base vectors are orthonormal

 The method of the approximation is determined by: 
       approximateDec(.., 'method', method)
   where method='PCA' uses principal component analysis (a quick first 
   result), 'nonlinear' uses a global nonlinear optimization (usually the
   thing you wan't to do) and 'nonlinearLocal' finds only one local
   optimum, starting from the PCA optimum.

 For the nonlinear approach, you can specify options a string cell array
   of measures that shalle be consideres ('measureList', {'volume',
   'meanWidth'}). A corresponding vector assigns the weights
   ('measureWeightVector', [1 0]).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dataApprox = approximateDec(heMatrix, dec, varargin)
0002 % shape approximation based on sample points and decomposition data
0003 %
0004 % Syntax: dataApprox = approximateDec(hcMatrix, dec, 'option', value, ...)
0005 %
0006 % This function approximates the points in heMatrix (one sample point each
0007 %   column) by an orthogonal projection to a linear subspace of the given
0008 %   Hc-representation (dec). The approximated hE vectors are computed by:
0009 %       heApprox = P * hE
0010 %   where the projection matrix is computed from
0011 %       P = baseMatrix * baseMatrix'.
0012 %   The base matrix contains nTargetDim columns that span the desired
0013 %   linear subspace in the embedding hE-space. Both results are returned in
0014 %   dataApprox as the fields
0015 %     .projectionMatrix - this is P
0016 %     .mappingReducedToEmbedding - this is baseMatrix
0017 %     .mappingEmbeddingToreduced - this is pinv(baseMatrix) or simply
0018 %        the baseMatrix' since the base vectors are orthonormal
0019 %
0020 % The method of the approximation is determined by:
0021 %       approximateDec(.., 'method', method)
0022 %   where method='PCA' uses principal component analysis (a quick first
0023 %   result), 'nonlinear' uses a global nonlinear optimization (usually the
0024 %   thing you wan't to do) and 'nonlinearLocal' finds only one local
0025 %   optimum, starting from the PCA optimum.
0026 %
0027 % For the nonlinear approach, you can specify options a string cell array
0028 %   of measures that shalle be consideres ('measureList', {'volume',
0029 %   'meanWidth'}). A corresponding vector assigns the weights
0030 %   ('measureWeightVector', [1 0]).
0031 %
0032 
0033 %! ToDo: rewrite documentation
0034 
0035 
0036 %
0037 % The output structure contains
0038 %   .time - computation time for approximation and conversion
0039 %   .optimalGrassmanVector - defines the optimal projection subspace based
0040 %      on the PCA subspace - different optimal projections might be compared
0041 %      according to this data
0042 %/
0043 %
0044 %
0045 % see also: obtainDec, obtainCrystalDec, addMeasureDec
0046 
0047 % The elk-library: convex geometry applied to crystallization modeling.
0048 %   Copyright (C) 2013 Alexander Reinhold
0049 %
0050 % This program is free software: you can redistribute it and/or modify it
0051 %   under the terms of the GNU General Public License as published by the
0052 %   Free Software Foundation, either version 3 of the License, or (at your
0053 %   option) any later version.
0054 %
0055 % This program is distributed in the hope that it will be useful, but
0056 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0057 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0058 %   General Public License for more details.
0059 %
0060 % You should have received a copy of the GNU General Public License along
0061 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0062 
0063 %% input handling
0064 par = mapOptionStruct(varargin, ...
0065     'method', 'PCA', ...
0066     'targetDim', 1, ...
0067     'nResample', 0, ...
0068     'measureList', 'volume', ...
0069     'measureWeightVector', [], ...
0070     'errorType', 'absoluteSquared', ...
0071     'errorGroupVector', [], ...
0072     'projectionType', 'true', ...
0073     'manualScaling', 0.5, ...
0074     'manualBoundingCone', [], ...
0075     'numTrialPoints', 500, ...
0076     'numStageOnePoints', 10, ...
0077     'zerotol', elkZerotol);
0078 
0079 %% Scaling / Resampling
0080 if par.nResample > 0
0081     disp('Reducing set of sample points..')
0082     resampleData = resampleHeMatrix(heMatrix, par.nResample);
0083     heMatrix = resampleData.heMatrixResampled;
0084     disp('  done.')
0085 end
0086 
0087 par = validateInput(heMatrix, dec, par);
0088 
0089 % add measure values for original hE-vectors
0090 % measure value matrix
0091 par.measureValueMatrix = computeMeasureDec(dec, 'hC', heMatrix, ...
0092         par.measureList, par.zerotol, 0, 1);
0093 
0094 %% handle approximation
0095 tic
0096 switch lower(par.method)
0097     case 'pca'
0098         dataApprox = approxPca(heMatrix, par);
0099     case 'nonlinear'
0100         dataApprox = approxNonlinear(heMatrix, dec, par);
0101     case 'nonlinearlocal'
0102         % call fmincon instead of global search based on fmincon to provide
0103         %   a local minimum (right thig to use this for testing)
0104         dataApprox = approxNonlinear(heMatrix, dec, par);
0105     otherwise
0106         error('elk:approximation', 'This should not happen.');
0107 end
0108 
0109 % dataApprox.mappingEmbeddingToReduced = orth(dataApprox.projectionMatrix)';
0110 % dataApprox.mappingReducedToFull = pinv(dataApprox.mappingFullToReduced);
0111 dataApprox.heMatrix = heMatrix;
0112 if strcmpi(par.projectionType, 'true')
0113     dataApprox.heMatrixApprox = dataApprox.projectionMatrix*heMatrix;
0114 else 
0115     dataApprox.heMatrixApprox = ...
0116         estimateHeMatrix(heMatrix, dataApprox.projectionMatrix, ...
0117                          dataApprox.nonlinearData.sampleProjectionData);
0118 end
0119 dataApprox.parameterStruct = par;
0120 if exist('resampleData', 'var')
0121     dataApprox.resampleData = resampleData;
0122 end
0123 dataApprox.time = toc;

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005