void printLists (const list<int>& l1, const list<int>& l2) { cout << "list1: "; copy (l1.cbegin(), l1.cend(), ostream_iterator<int>(cout," ")); cout << endl << "list2: "; copy (l2.cbegin(), l2.cend(), ostream_iterator<int>(cout," ")); cout << endl << endl; }
bool ProcessList::any_of_process_is_running(const list<wstring> & processes) { auto running_processes = get_processes(); return any_of(processes.cbegin(), processes.cend(), [&](auto process) { return find(running_processes.cbegin(), running_processes.cend(), process) != running_processes.cend(); }); }
bool Person::isFriend(const Person &p) const { for (auto it = following.cbegin(); it != following.cend(); ++it) { if (*it == p.follower) return true; } return false; }
void PCAKNN::train(const list<Interval> &intervals, const bool console_output) { if (intervals.size() == 0) return; projections.clear(); n = 0; width = intervals.front().start->face.cols; height = intervals.front().start->face.rows; list<Interval>::const_iterator itr; vector<Face>::const_iterator start, end; //add the number of images from all intervals for (itr = intervals.cbegin(); itr != intervals.cend(); itr++) { n += itr->Length(); } Mat pca_matrix(static_cast<int>(n), width*height, data_type); int c = 0; for (itr = intervals.cbegin(); itr != intervals.cend(); itr++) { //for each image in the current interval for (start = itr->start, end = itr->end; start != end; start++, ++c) { if (console_output) printf("Preparing samples %d/%d\n", c + 1, n); //insert current image into pca_matrix Mat image_row = start->face.clone().reshape(1, 1); Mat row_i = pca_matrix.row(c); image_row.convertTo(row_i, data_type);//CV_64FC1 ? Face f; f.name = start->name; projections.push_back(f);//save the names for later } } if (console_output) printf("TRAINING...\n"); //Perfrom principal component analysis on pca_matrix PCA pca(pca_matrix, Mat(), CV_PCA_DATA_AS_ROW, pca_matrix.rows); //extract mean/eigenvalues mean = pca.mean.reshape(1, 1); ev = pca.eigenvalues.clone(); transpose(pca.eigenvectors, w); //project each face into subspace and save them with the name above for recognition for (unsigned int i = 0; i<n; ++i) { if (console_output) printf("Projecting %d/%d\n", i + 1, n);//project so subspace projections[i].face = subspaceProject(w, mean, pca_matrix.row(i)); } }
bool func(vector<int> ivec, list<int> il) { if (ivec.size() != il.size()) return false; auto iter1 = ivec.cbegin(); auto iter2 = il.cbegin(); for (; iter1 != ivec.end(); ++iter1, ++iter2) if (*iter1 != *iter2) return false; return true; }
void RemoveDup(list< int >& lList) { cout << "Before : "; copy(lList.cbegin(), lList.cend(), ostream_iterator< int >(cout, " ")); set< int > sSet; for (list< int >::iterator it = lList.begin(); it != lList.end();) { auto rtn = sSet.insert(*it); if (false == rtn.second) { lList.erase(it++); } else ++it; } cout << endl << "After : "; copy(lList.cbegin(), lList.cend(), ostream_iterator< int >(cout, " ")); }
list<float> NRZ_L_Enc::encode(const list<bool>& in) { list<float> output; for(auto citer = in.cbegin(); citer != in.cend(); ++citer) { if(*citer) { output.push_back(-amplitude); } else { output.push_back(amplitude); } } return output; }
void ode_solver::print_trace(ostream& out, string const & key, int const idx, list<pair<interval, IVector>> const & trajectory) const { out << "{" << endl; out << "\t" << "\"key\": \"" << key << "\"," << endl; out << "\t" << "\"mode\": \"" << m_mode << "\"," << endl; out << "\t" << "\"step\": \"" << m_step << "\"," << endl; out << "\t" << "\"values\": [" << endl; if (!trajectory.empty()) { auto iter = trajectory.cbegin(); print_datapoint(out, iter->first, iter->second[idx]); for (++iter; iter != trajectory.cend(); iter++) { out << ", " << endl; print_datapoint(out, iter->first, iter->second[idx]); } out << endl; } out << "\t" << "]" << endl; out << "}" << endl; }
void DecodeTrace::on_show_hide_decoder(int index) { using pv::data::decode::Decoder; const list< shared_ptr<Decoder> > stack(decoder_stack_->stack()); // Find the decoder in the stack auto iter = stack.cbegin(); for (int i = 0; i < index; i++, iter++) assert(iter != stack.end()); shared_ptr<Decoder> dec = *iter; assert(dec); const bool show = !dec->shown(); dec->show(show); assert(index < (int)decoder_forms_.size()); decoder_forms_[index]->set_decoder_visible(show); if (owner_) owner_->row_item_appearance_changed(false, true); }
// copy of above function for list<>. // todo: make this a templated function bool basicEffect::bindWithShapes(list<basicShape *>& _shapes){ if(_shapes.size()==0) return false; bool success = true; for(auto _shape=_shapes.cbegin(); _shape!=_shapes.cend(); ++_shape){ if( *_shape == NULL ){ success = false; continue; } // prevent adding the same shape several times for(auto it=shapes.begin(); it!=shapes.end(); ++it){ if( *_shape == *it ) continue; // already exists } //shapes.push_back( *_shape ); shapes.insert(shapes.end(), *_shape); } updateBoundingBox(); return success; }
void WriteJson::parse(const list<double> &values, const string &&type) { parseContainers(values.cbegin(), values.cend(), type); }
bool lessForCollection (const list<int>& l1, const list<int>& l2) { return lexicographical_compare (l1.cbegin(), l1.cend(), // first range l2.cbegin(), l2.cend()); // second range }
// For lazy testing ConstCacheIterator getIterator() { return m_list.cbegin(); }
void print_list(const list<int>& x) { for (auto it = x.cbegin(); it != x.cend(); ++it) std::cout << *it << " "; std::cout << std::endl; }