Home > matlab > isint.m

isint

PURPOSE ^

This function tests if the input argument is an integer.

SYNOPSIS ^

function [b,c,d] = isint(a)

DESCRIPTION ^

  This function tests if the input argument is an integer.

  INPUT 
    a    [double]   m*n matrix.

  OUTPUT 
    b    [integer]  m*n matrix of 0 and 1. b(i,j)=1 if a(i,j) is an integer.    
    c    [integer]  p*1 vector of indices pointing to the integer elements of a.
    d    [integer]  q*1 vector of indices pointing to the non integer elements of a.
    
  SPECIAL REQUIREMENTS
    None.
    
  NOTES 
    p+q is equal to the product of m by n.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [b,c,d] = isint(a)
0002 %  This function tests if the input argument is an integer.
0003 %
0004 %  INPUT
0005 %    a    [double]   m*n matrix.
0006 %
0007 %  OUTPUT
0008 %    b    [integer]  m*n matrix of 0 and 1. b(i,j)=1 if a(i,j) is an integer.
0009 %    c    [integer]  p*1 vector of indices pointing to the integer elements of a.
0010 %    d    [integer]  q*1 vector of indices pointing to the non integer elements of a.
0011 %
0012 %  SPECIAL REQUIREMENTS
0013 %    None.
0014 %
0015 %  NOTES
0016 %    p+q is equal to the product of m by n.
0017 
0018 % Copyright (C) 2009 Dynare Team
0019 %
0020 % This file is part of Dynare.
0021 %
0022 % Dynare is free software: you can redistribute it and/or modify
0023 % it under the terms of the GNU General Public License as published by
0024 % the Free Software Foundation, either version 3 of the License, or
0025 % (at your option) any later version.
0026 %
0027 % Dynare is distributed in the hope that it will be useful,
0028 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0029 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0030 % GNU General Public License for more details.
0031 %
0032 % You should have received a copy of the GNU General Public License
0033 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0034 
0035 [m,n] = size(a);
0036 b = abs(fix(a)-a)<1e-15;
0037 
0038 if nargout>1
0039     c = find(b==1);
0040     d = find(b==0);
0041 end

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005