Home > SPlaC v1_0 > Mie > GEN > GenCheckSumNumPb.m

GenCheckSumNumPb

PURPOSE ^

Check potential loss of precision during sum of two arrays (same dimensions)

SYNOPSIS ^

function GenCheckSumNumPb(ar1,ar2,sVar,sCaller)

DESCRIPTION ^

 Check potential loss of precision during sum of two arrays (same dimensions)
 See the supplementary information for a discussion of loss of precision.
 This function is called by all other functions checking for numerical
 precision problems and issues the warnings in case of problem.

 Parameters:
 - ar1: scalar, vector, or matrix
 - ar2: scalar, vector, or matrix (same dimension as ar1)
 - sVar: string describing the variable that is being calculated
 - sCaller: string describing the function in which the calculation is
            performed

 Returns nothing
 Issues a warning in case of problem and allow the user to enter debug
 mode to investigate the problems further.

 This file is part of the SPlaC v1.0 package (copyright 2008)
 Check the README file for further information

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 indDb= find(abs(ar1)<1e-12*abs(ar2));
0003 if ~isempty(indDb)
0004     disp ' ';
0005     disp(['Possible numerical pb in ' sCaller ' with variable ' sVar]) 
0006     nbr=size(ar1,1);
0007     disp(['Pb with ' int2str(length(indDb)) ' indices. Details of first index where problem occurs:']);
0008     kk=1;
0009     disp(['Row ' int2str(mod(indDb(kk)-1,nbr)+1) ' Col ' int2str(floor((indDb(kk) -1)/ nbr)+1)]);
0010     disp(['Sum result is ' num2str(ar1(indDb(1)))]);
0011     disp(['Sum element is ' num2str(ar2(indDb(1)))]);
0012     pkey=input ('enter d for details, k for entering debug mode, or enter to continue ?','s');
0013     if (strcmpi(pkey,'d') || strcmpi(pkey,'k'))
0014         for kk=2:length(indDb)
0015             disp(['Row ' int2str(mod(indDb(kk)-1,nbr)+1) ' Col ' int2str(floor((indDb(kk) -1)/ nbr)+1)]);
0016         end
0017         if strcmpi(pkey,'k')
0018             keyboard
0019         end
0020     end
0021     disp ' ';
0022 end

This web page is part of the SPlaC package © 2008. Contact: Eric Le Ru
Generated on Wed 03-Dec-2008 11:10:14 by m2html © 2003 (adapted)