| 156 | } |
| 157 | |
| 158 | void RV::dataind (const RV &rv2, ivec &selfi, ivec &rv2i) const { |
| 159 | //clean results |
| 160 | selfi.set_size(0); |
| 161 | rv2i.set_size(0); |
| 162 | |
| 163 | // just in case any rv is empty |
| 164 | if ((len==0)||(rv2.length()==0)){return;} |
| 165 | |
| 166 | //find comon rv |
| 167 | ivec cids=itpp::find(this->findself(rv2)>=0); |
| 168 | |
| 169 | // index of |
| 170 | if ( cids.length()>0 ) { |
| 171 | str str1 = tostr(); |
| 172 | str str2 = rv2.tostr(); |
| 173 | |
| 174 | ivec part1; |
| 175 | ivec part2; |
| 176 | int i,j; |
| 177 | // find common rv in strs |
| 178 | for ( j=0; j < cids.length();j++ ) { |
| 179 | i = cids(j); |
| 180 | part1 = itpp::find ( ( str1.ids == ids ( i ) ) & ( str1.times == times ( i ) ) ); |
| 181 | part2 = itpp::find ( ( str2.ids == ids ( i ) ) & ( str2.times == times ( i ) ) ); |
| 182 | selfi = concat ( selfi, part1 ); |
| 183 | rv2i = concat ( rv2i, part2 ); |
| 184 | } |
| 185 | } |
| 186 | it_assert_debug(selfi.length() == rv2i.length(),"this should not happen!"); |