appendProjectionData

PURPOSE ^

append a projection for mapping

SYNOPSIS ^

function projectionData = appendProjectionData(projectionData,constraintMatrix, projectionMatrix, zerotol)

DESCRIPTION ^

 append a projection for mapping

 Syntax: projectionData = appendProjectionData([], dim)
  or     projectionData = appendProjectionData(projectionData, ...
                            constraintMatrix)

 THIS IS NO USER FUNCTION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function projectionData = appendProjectionData(projectionData, ...
0002     constraintMatrix, projectionMatrix, zerotol)
0003 % append a projection for mapping
0004 %
0005 % Syntax: projectionData = appendProjectionData([], dim)
0006 %  or     projectionData = appendProjectionData(projectionData, ...
0007 %                            constraintMatrix)
0008 %
0009 % THIS IS NO USER FUNCTION
0010 
0011 % The elk-library: convex geometry applied to crystallization modeling.
0012 %   Copyright (C) 2012 Alexander Reinhold
0013 %
0014 % This program is free software: you can redistribute it and/or modify it
0015 %   under the terms of the GNU General Public License as published by the
0016 %   Free Software Foundation, either version 3 of the License, or (at your
0017 %   option) any later version.
0018 %
0019 % This program is distributed in the hope that it will be useful, but
0020 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0021 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0022 %   General Public License for more details.
0023 %
0024 % You should have received a copy of the GNU General Public License along
0025 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0026 
0027 %% initialize
0028 if isempty(projectionData)
0029     % constraintMatrix is dim in this case
0030     projectionData.A = zeros(0, constraintMatrix);
0031     projectionData.responsibleMatrix = zeros(0, 3);
0032     projectionData.projectionList = {};
0033     return
0034 end
0035 
0036 %% add projection
0037 projectionData.projectionList{end+1} = projectionMatrix;
0038 nProjection = length(projectionData.projectionList);
0039 
0040 %% skip, if constraintMatrix is empty
0041 if isempty(constraintMatrix)
0042     return
0043 end
0044 
0045 %% filter zero-rows from constraintMatrix
0046 constraintMatrix = eliminateRows(constraintMatrix, ...
0047     constraintMatrix(1,:)*0, zerotol);
0048 
0049 %% normalize constraints
0050 constraintMatrix = bsxfun(@rdivide, constraintMatrix, ...
0051     sqrt(sum(constraintMatrix.^2, 2)));
0052 
0053 %% add existing constraints (as is)
0054 [constraintMatrix, thisIndexVector] = eliminateRows(...
0055     constraintMatrix, projectionData.A, zerotol);
0056 projectionData.responsibleMatrix = [projectionData.responsibleMatrix; ...
0057     [thisIndexVector(:), thisIndexVector(:)*0+nProjection, ...
0058     thisIndexVector(:)*0+1]];
0059 
0060 %% add existing negative constraints
0061 [constraintMatrix, thisIndexVector] = eliminateRows(...
0062     constraintMatrix, -1*projectionData.A, zerotol);
0063 projectionData.responsibleMatrix = [projectionData.responsibleMatrix; ...
0064     [thisIndexVector(:), thisIndexVector(:)*0+nProjection, ...
0065     thisIndexVector(:)*0-1]];
0066 
0067 %% add remaining constraints
0068 % add remaining constraints as is which means using -1
0069 thisIndexVector = (1:size(constraintMatrix, 1)) + size(projectionData.A, 1);
0070 projectionData.A = [projectionData.A; constraintMatrix];
0071 projectionData.responsibleMatrix = [projectionData.responsibleMatrix; ...
0072     [thisIndexVector(:), thisIndexVector(:)*0+nProjection, ...
0073     thisIndexVector(:)*0+1]];

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