void KMEANS<T>::print() { ofstream fout; fout.open("res.txt"); if (!fout) { cout << "file res.txt open failed" << endl; exit(0); } typename vector< vector<T> >::iterator it = dataSet.begin(); typename vector< tNode >::iterator itt = clusterAssignment.begin(); for (int i = 0; i < rowLen; ++i) { typename vector<T>::iterator it2 = it->begin(); while ( it2 != it->end() ) { fout << *it2 << "\t"; ++it2; } fout << (*itt).minIndex << endl; ++itt; ++it; } }
IGL_INLINE void igl::polygon_mesh_to_triangle_mesh( const std::vector<std::vector<Index> > & vF, Eigen::PlainObjectBase<DerivedF>& F) { using namespace std; using namespace Eigen; int m = 0; // estimate of size for(typename vector<vector<Index > >::const_iterator fit = vF.begin(); fit!=vF.end(); fit++) { if(fit->size() >= 3) { m += fit->size() - 2; } } // Resize output F.resize(m,3); { int k = 0; for(typename vector<vector<Index > >::const_iterator fit = vF.begin(); fit!=vF.end(); fit++) { if(fit->size() >= 3) { typename vector<Index >::const_iterator cit = fit->begin(); cit++; typename vector<Index >::const_iterator pit = cit++; for(; cit!=fit->end(); cit++,pit++) { F(k,0) = *(fit->begin()); F(k,1) = *pit; F(k,2) = *cit; k++; } } } assert(k==m); } }
void test_createFilters(const Kernel& f) { using namespace MatchedFilter; if (os_) *os_ << "test_createFilters() " << typeid(f).name() << endl; int sampleRadius = 2; int subsampleFactor = 4; double dx = 1; typedef typename KernelTraits<Kernel>::filter_type filter_type; typedef typename KernelTraits<Kernel>::ordinate_type ordinate_type; vector<filter_type> filters = details::createFilters(f, sampleRadius, subsampleFactor, dx); // verify filter count unit_assert((int)filters.size() == subsampleFactor); for (typename vector<filter_type>::const_iterator it=filters.begin(); it!=filters.end(); ++it) { if (os_) { copy(it->begin(), it->end(), ostream_iterator<ordinate_type>(*os_, " ")); *os_ << endl; } // verify filter size unit_assert((int)it->size() == sampleRadius*2 + 1); // verify filter normalization double sum = 0; for (typename filter_type::const_iterator jt=it->begin(); jt!=it->end(); ++jt) sum += norm(complex<double>(*jt)); unit_assert_equal(sum, 1, 1e-14); } if (os_) *os_ << endl; }
template<class T> void printArray2D(vector< vector<T> > &I) { // This is how we iterate using an iterator for 2d vectors typename vector< vector<T> >::iterator row; // Iterator for row of 2d vector typename vector<T>::iterator col; // Iterator for columns of 2d vector cout << "Matrix size: " << "[" << I.size() << "x" << I[0].size() << "]" << endl; // print the row and columns for(row = I.begin(); row !=I.end(); row++) { for(col = row->begin(); col != row->end(); col++) { cout << *col << ","; // print the value contained in each row of our 2d vector. } cout << endl; } }