[Index for tmp_for_tar/misc]
[Return to Master Index]
test_lexicosort
(tmp_for_tar/misc/test_lexicosort.m)
Help text
Test whether lexicosort works
Last modified: April 2001
Cross-Reference Information
This calls
- sayif tmp_for_tar/misc/sayif.m
Listing of file tmp_for_tar/misc/test_lexicosort.m
##
## Test whether lexicosort works
##
## Author: Etienne Grossmann <etienne@isr.ist.utl.pt>
## Last modified: April 2001
R = 100 ; # Number of rows
if exist ("verbose")!=1, verbose = 1; end
if exist ("check")!=1, check = 1; end
ok = 1;
for realmat = 0:1,
if realmat, tag = "real-valued";
else tag = "integer" ;
end
sayif (verbose, "test_lexicosort : %s matrices\n",tag);
for C = [1,2,3,5,10,20,50,100,200],
x = (rand(R,C)-0.5)*10 ;
if realmat==1, x = floor (x); end
y = lexicosort (x) ;
## keyboard
bugs = zeros (1,R) ;
for i = 1:R-1,
if lex_cmp( y(i,:),y(i+1,:) ) > 0, bugs(i) = 1 ; end
end
if any(bugs),
ok = 0 ;
printf ("Whoa ! (lexicosort) Some rows are badly sorted\n");
printf ("%d ",find(bugs));printf("\n");
if check, keyboard; end
else
sayif (verbose, "Ok : for width=%-3d, %s matrix\n",C,tag);
end
end
end
Produced by oct2html on Sat Apr 28 21:14:54 2001
Cross-Directory links are: ON