// Calulate the matching weights between each pair of itemsets in the sequences, stores in a matrix void S2MP::calcWeightMatrix(const OwnedArray<KeyValueMIDIPair> &sp1, const OwnedArray<KeyValueMIDIPair> &sp2) { DBG("sp1 size: " + String(sp1.size())); DBG("sp2 size: " + String(sp2.size())); // clear the weight matrix _w.clearQuick(); // for each ith itemset in seq1, calculate matching weight for each jth item in seq2 for (int i = _sp1frst; i < _sp1len; i++) { // add a new row for itemset i _w.add(Array<double>()); for (int j = _sp2frst; j < _sp2len; j++) { // find interection int intersection = numberOfIntersections (sp1[i]->getItemSet(), sp2[j]->getItemSet()); // append row with jth: matching weight = (num elements in intersection)/(avg num of elements in itemsets) _w.getReference(i - _sp1frst).add (intersection/(_sp1len + _sp2len/2.0)); } DBG("Size of row " + String(i) + " " + String(_w.getReference(i - _sp1frst).size()) + " number of jth items tested " + String(_sp2len)); } }
void Osg3dView::pickAnObjectFromView() { if (numberOfIntersections() == 0) return; osg::NodePath np = getFirstLoadedItemClicked(); // turn pointers into ref_ptrs because we don't know // where this will end up QVector< osg::ref_ptr<osg::Node> > myNodePath; for (unsigned i=0 ; i < np.size() ; i++) { osg::ref_ptr<osg::Node> saveMe(np.at(i)); myNodePath.push_back(saveMe); } emit pickObject(myNodePath); }
void solve(std::vector<std::shared_ptr<line_segment>>& polygon, std::ifstream& in) { std::string temp = ""; std::getline(in, temp); int m = std::atoi(temp.c_str()); for (int i = 0; i < m; ++i) { std::getline(in, temp); std::shared_ptr<point> pointToSolve(new point(temp)); std::shared_ptr<line_segment> ray(new line_segment(pointToSolve, std::shared_ptr<point>(new point(-100000, pointToSolve->y)))); if (numberOfIntersections(polygon, ray) % 2 == 0) { std::cout << "no" << std::endl; } else { std::cout << "yes" << std::endl; } } }