#define EIGEN_USE_MKL_ALL #define EIGEN_VECTORIZE_SSE4_2 #include #include #include #include #include #include #include #include #include #include "frpca/frpca.h" #include "frpca/matrix_vector_functions_intel_mkl.h" #include "frpca/matrix_vector_functions_intel_mkl_ext.h" using namespace std; using namespace Eigen; using namespace boost; const float EPS = 0.00000000001f; typedef Eigen::SparseMatrix SMatrixXf; DEFINE_string(filename, "data/PPI.ungraph", "Filename for edgelist file."); DEFINE_string(emb1, "sparse.emb", "Filename for svd results."); DEFINE_string(emb2, "spectral.emb", "Filename for svd results."); DEFINE_int32(num_node, 3890, "Number of node in the graph."); DEFINE_int32(num_rank, 128, "Embedding dimension."); DEFINE_int32(num_step, 10, "Number of order for recursion."); DEFINE_int32(num_iter, 5, "Number of iter in randomized svd."); DEFINE_int32(num_thread, 10, "Number of threads."); DEFINE_double(theta, 0.5, "Parameter of ProNE"); DEFINE_double(mu, 0.1, "Parameter of ProNE"); SMatrixXf readGraph(string filename, int num_node){ SMatrixXf A(num_node, num_node); typedef Eigen::Triplet T; vector tripletList; ifstream fin(filename.c_str()); while (1) { string x, y; if (!(fin >> x >> y)) break; int a = atoi(x.c_str()), b = atoi(y.c_str()); if (a==b) continue; tripletList.push_back(T(a, b, 1)); tripletList.push_back(T(b, a, 1)); } A.setFromTriplets(tripletList.begin(), tripletList.end()); return A; } SMatrixXf l1Normalize(SMatrixXf & mat){ SMatrixXf mat2(mat.rows(), mat.cols()); for (int k=0; k svdOfC(data, Eigen::ComputeThinU); MatrixXf emb = svdOfC.matrixU() * svdOfC.singularValues().cwiseSqrt().asDiagonal(); emb = l2Normalize(emb); return emb; } MatrixXf runFrPCA(SMatrixXf & input, int rank, int iter) { int m = input.rows(), nnz = input.nonZeros(); mat_coo *A = coo_matrix_new(m, m, nnz); A->nnz = nnz; int i=0; for (int k=0; krows[i] = k+1; A->cols[i] = it.col()+1; A->values[i] = it.value(); i += 1; } cout << "read matrix done..." <