Changeset 584 for library/bdm

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

Location:
library/bdm
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/bdmbase.h

    r573 r584  
    139139                        return dsize; 
    140140                } 
     141                 
     142                //! access function 
     143                const ivec& _ids() const { return ids;} 
    141144 
    142145                //! Recount size of the corresponding data vector 
  • 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} 
  • library/bdm/itpp_ext.h

    r579 r584  
    113113mat randun(int n, int m); 
    114114 
     115//! function returns unique entries in input vector \c in 
     116ivec unique(const ivec &in); 
    115117} 
    116118