[Index for tmp_for_tar/misc] [Return to Master Index]

test_cloose

(tmp_for_tar/misc/test_cloose.m)


Help text


 Check that cloose does what it should

 Last modified: April 2001



Listing of file tmp_for_tar/misc/test_cloose.m

##
## Check that cloose does what it should
##


## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: April 2001

if ! exist ("check"),   check = 0; end
if ! exist ("verbose"), verbose = 0; end
cnt = 1;

if verbose,
  if ! check,
    printf ("test_cloose : set 'check=1' to inspect tests that fail\n");
  end
end

sz = floor(30*rand(1,2)+1) ;
a = randn(sz)<0 ;
f = cfind(a) ;
b = cloose(f,sz(1)) ;


				# simple case

if any(a(:)!=b(:)),
  printf("not ok %i\n",cnt) ;
  if check, keyboard; end
else
  printf("ok %i\n",cnt) ;
end
cnt++ ;

a(:,1) = 0 ;			# a has a zero column
f = cfind(a) ;
b = cloose(f,sz(1)) ;

if any(a(:)!=b(:)),
  printf("not ok %i\n",cnt) ;
  if check, keyboard; end
else
  printf("ok %i\n",cnt) ;
end
cnt++ ;

b = cloose(f) ;			# a has a zero column, sz not specified

if any(a(:)!=b(:)),
  printf("not ok %i\n",cnt) ;
  if check, keyboard; end
else
  printf("ok %i\n",cnt) ;
end
cnt++ ;


sz(1) = max(2,sz(1)) ;		# a has a zero row, sz not specified
a = randn(sz)<0 ;
a(sz(1)-1,1) = 0 ;
a(sz(1),:) = 0 ;
f = cfind(a) ;
c = cloose(f) ;

if size(c,1)!=size(a,1)-1,
  printf("not ok %i\n",cnt) ;
  if check, keyboard; end
else
  printf("ok %i\n",cnt) ;
end
cnt++ ;

if any(a(1:max(f(:)),:)(:)!=c(:)),
  printf("not ok %i\n",cnt) ;
  if check, keyboard; end
else
  printf("ok %i\n",cnt) ;
end
cnt++ ;


Produced by oct2html on Sat Apr 28 21:14:54 2001
Cross-Directory links are: ON