obtainTensorDec

PURPOSE ^

extract the right tensor from decomposition

SYNOPSIS ^

function [tensor tensorDim] = obtainTensorDec(dec, measureName, par,vecType, partIndex)

DESCRIPTION ^

 extract the right tensor from decomposition

 THIS FUNCTION IS NO USER FUNCTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tensor tensorDim] = obtainTensorDec(dec, measureName, par, ...
0002     vecType, partIndex)
0003 % extract the right tensor from decomposition
0004 %
0005 % THIS FUNCTION IS NO USER FUNCTION.
0006 
0007 % The elk-library: convex geometry applied to crystallization modeling.
0008 %   Copyright (C) 2012 Alexander Reinhold
0009 %
0010 % This program is free software: you can redistribute it and/or modify it
0011 %   under the terms of the GNU General Public License as published by the
0012 %   Free Software Foundation, either version 3 of the License, or (at your
0013 %   option) any later version.
0014 %
0015 % This program is distributed in the hope that it will be useful, but
0016 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0017 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018 %   General Public License for more details.
0019 %
0020 % You should have received a copy of the GNU General Public License along
0021 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0022 
0023 % shortcuts
0024 thisMeasureStruct = dec.measureData.(measureName);
0025 thisParitition = dec.simplexPartition{partIndex};
0026 tensorDim = thisMeasureStruct.dim;
0027 
0028 %% get parIndex
0029 if thisMeasureStruct.isPar
0030     [~, parIndex] = eliminateRows(par, thisMeasureStruct.par, 0);
0031     
0032     if length(parIndex) < size(par, 1)
0033         error('elk:decomposition:wrongInput', ...
0034             'the provided parameter(s) were not found in the decomposition struct');
0035     end
0036 else
0037     parIndex = 1;
0038 end
0039 
0040 switch lower(vecType)
0041     case 'hc'
0042         % handle parameter
0043         if thisMeasureStruct.isPar
0044             tensor = thisMeasureStruct.tensorHc{parIndex}{partIndex};
0045         else
0046             tensor = thisMeasureStruct.tensorHc{partIndex};
0047         end
0048     case 'se'
0049         % handle parameter
0050         if thisMeasureStruct.isPar
0051             tensor = thisMeasureStruct.tensorSe{parIndex};
0052         else
0053             tensor = thisMeasureStruct.tensorSe;
0054         end
0055         
0056         % handle dimension
0057         switch thisMeasureStruct.dim
0058             case 1
0059                 tensor = tensor(thisParitition.seIndexVector);
0060             case 2
0061                 tensor = tensor(thisParitition.seIndexVector, ...
0062                     thisParitition.seIndexVector);
0063             case 3
0064                 tensor = tensor(thisParitition.seIndexVector, ...
0065                     thisParitition.seIndexVector, ...
0066                     thisParitition.seIndexVector);
0067         end
0068         
0069         % take care of nan
0070         tensor(isnan(tensor)) = 0;
0071         
0072     case 'fullse'
0073         error('elk:decomposition:wrongType', ...
0074             'the named vector type is unknow. This should not happen.');
0075     otherwise
0076         error('elk:decomposition:wrongType', ...
0077             'the named vector type is unknow. This should not happen.');
0078 end

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