Show
Ignore:
Timestamp:
08/27/09 15:39:33 (15 years ago)
Author:
smidl
Message:

new function unique(ivec) and its test in RV_test

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/itpp_ext.cpp

    r581 r584  
    398398vec randun(int n){vec res(n); for(int i=0;i<n;i++){res(i)=randun();}; return res;}; 
    399399mat randun(int n, int m){mat res(n,m); for(int i=0;i<n*m;i++){res(i)=randun();}; return res;}; 
    400  
    401 } 
     400ivec unique (const ivec &in) 
     401{ 
     402        ivec uniq (0); 
     403        int j = 0; 
     404        bool found = false; 
     405        for (int i = 0;i < in.length(); i++) { 
     406                found = false; 
     407                j = 0; 
     408                while ( (!found) && (j < uniq.length())) { 
     409                        if (in (i) == uniq (j)) found = true; 
     410                        j++; 
     411                } 
     412                if (!found) uniq = concat (uniq, in (i)); 
     413        } 
     414        return uniq; 
     415} 
     416 
     417}