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

pincr

(tmp_for_tar/misc/pincr.m)


Function Synopsis

y=pincr(x,maxx);

Help text

       y      =  pincr( x,    maxx );
      (RxC)            (RxC)  

 Increment  x,  which represents a number written in base  maxx.

 Last modified: January 2000



Listing of function file tmp_for_tar/misc/pincr.m

##       y      =  pincr( x,    maxx );
##      (RxC)            (RxC)  
## 
## Increment  x,  which represents a number written in base  maxx.
##
## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: January 2000

function y=pincr(x,maxx);

[r,c]=size(x);
x=x(:);
N=size(x,1);
## if prod (size (maxx)) == 1, maxx *= ones(N,1); end

## if any( x>= maxx), 
if any( diff([x;maxx]) <= 0 ), 
  printf("pincr : Bad input\n");
  keyboard
end

if ++x(N) >= maxx,
  if N>1, 
    tmp = pincr(x(1:N-1),maxx-1) ; 
  else 
    tmp=0; 
  end
  if tmp==0,
    y = 0 ;
  else
    y = [tmp;tmp(N-1)+1];
    y = reshape(y,r,c);
  end
else
  y = reshape(x,r,c); ;
end

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