Changeset 584
- Timestamp:
- 08/27/09 15:39:33 (15 years ago)
- Location:
- library
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r573 r584 139 139 return dsize; 140 140 } 141 142 //! access function 143 const ivec& _ids() const { return ids;} 141 144 142 145 //! Recount size of the corresponding data vector -
library/bdm/itpp_ext.cpp
r581 r584 398 398 vec randun(int n){vec res(n); for(int i=0;i<n;i++){res(i)=randun();}; return res;}; 399 399 mat randun(int n, int m){mat res(n,m); for(int i=0;i<n*m;i++){res(i)=randun();}; return res;}; 400 401 } 400 ivec 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 113 113 mat randun(int n, int m); 114 114 115 //! function returns unique entries in input vector \c in 116 ivec unique(const ivec &in); 115 117 } 116 118 -
library/tests/rv_test.cpp
r531 r584 133 133 CHECK_EQUAL ( exp_bi[i], bi ( i ) ); 134 134 } 135 136 // check uniqueness 137 RV join=a; 138 join.add(b); 139 RV tmp=a; tmp.t(1); 140 join.add(tmp); 141 tmp=b; tmp.t(-1); 142 join.add(tmp); 143 144 CHECK_EQUAL(unique(join._ids()), vec_2(a.id(0), b.id(0))); 135 145 }