// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "mode.h" // Implementation #include template IGL_INLINE void igl::mode( const Eigen::Matrix & X, const int d, Eigen::Matrix & M) { assert(d==1 || d==2); using namespace std; int m = X.rows(); int n = X.cols(); M.resize((d==1)?n:m,1); for(int i = 0;i<((d==2)?m:n);i++) { vector counts(((d==2)?n:m),0); for(int j = 0;j<((d==2)?n:m);j++) { T v = (d==2)?X(i,j):X(j,i); for(int k = 0;k<((d==2)?n:m);k++) { T u = (d==2)?X(i,k):X(k,i); if(v == u) { counts[k]++; } } } assert(counts.size() > 0); int max_count = -1; int max_count_j = -1; int j =0; for(vector::iterator it = counts.begin();it(Eigen::Matrix const&, int, Eigen::Matrix&); // generated by autoexplicit.sh template void igl::mode(Eigen::Matrix const&, int, Eigen::Matrix&); #endif