Changeset 584 for library/bdm/itpp_ext.cpp
- Timestamp:
- 08/27/09 15:39:33 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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 }