trimConstraintMatrix

PURPOSE ^

normalize and trim rows and (optionally) remove zero-rows

SYNOPSIS ^

function A = trimConstraintMatrix(A, zerotol, removeZeroRows)

DESCRIPTION ^

 normalize and trim rows and (optionally) remove zero-rows

 While trimming almost equal entries in the same columns, the rows are
   eliminated, using the unique function.

 It also eliminates almost-zero rows.

 THIS IS NO USER FUNCTION

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function A = trimConstraintMatrix(A, zerotol, removeZeroRows)
0002 % normalize and trim rows and (optionally) remove zero-rows
0003 %
0004 % While trimming almost equal entries in the same columns, the rows are
0005 %   eliminated, using the unique function.
0006 %
0007 % It also eliminates almost-zero rows.
0008 %
0009 % THIS IS NO USER FUNCTION
0010 
0011 % The elk-library: convex geometry applied to crystallization modeling.
0012 %   Copyright (C) 2013 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 %% identify rows that are non-zero rows
0028 if removeZeroRows
0029     A(all(abs(A) < sqrt(zerotol), 2), :) = [];
0030 end
0031 %! DEV: changed the above from zerotol to sqrt(zerotol) as it occured that
0032 %       zero rows might really be THAT tight.
0033 %/
0034 
0035 %% normalize constraints
0036 A = bsxfun(@rdivide, A, sqrt(sum(A.^2, 2)) );
0037 
0038 %% trim columns for almost equal values
0039 A = trimColumns(A, zerotol);

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