From 355d4954f40cc62d4323603d264c47124691ba0f Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Wed, 20 Mar 2019 12:13:09 +0100 Subject: [PATCH 01/11] Develop (#12) * print the system platform * print out the platform * changed darwin to Darwin * remove extra_link_args for mac * Test the robustness of result (#11) * Fixed the bug with omp * fixed rescaling * typo * removed a print * Removed a print from setup.py --- setup.py | 1 - src/krbalancing.cpp | 22 ++++++++++++++++------ src/krbalancing.hpp | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 0e58e4c..35219cf 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,6 @@ def get_include(): # TODO def __extra_compile_args(): extra_compile_args = [] - print("Platform is "+ platform.system()) if platform.system() == 'Darwin': extra_compile_args = ["-std=c++11"] diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 9230c95..04cbf02 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -10,6 +10,7 @@ kr_balancing::kr_balancing(const SparseMatrixCol & input){ I.setIdentity(); I = I*0.00001; A = A + I; + rescaled = false; } @@ -130,12 +131,15 @@ void kr_balancing::inner_loop(){ void kr_balancing::compute_normalised_matrix(bool & rescale){ assert(A.rows() == A.cols()); - A = SparseMatrixCol(A.triangularView()); - if(rescale ==true){ + if(rescale ==true && rescaled == false){ rescale_norm_vector(); + rescaled = true; + }else{ + A = SparseMatrixCol(A.triangularView()); } #pragma omp parallel for num_threads(num_threads) schedule(dynamic) for (int k=0; k()); + + #pragma omp parallel for num_threads(num_threads) for (int k=0; k rk; SparseMatrixCol output; + bool rescaled; }; #endif From dee414b78e2f8b42246487fd55e32c5f924449ec Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Wed, 20 Mar 2019 12:16:24 +0100 Subject: [PATCH 02/11] version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 35219cf..63bb297 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from sysconfig import get_config_var, get_paths import logging -__version__ = '0.0.1dev' +__version__ = '0.0.4' def get_include(): # TODO From 5720d3b75f6cc3938a0fa3b27c80e63256a00b26 Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Tue, 7 May 2019 10:10:10 +0200 Subject: [PATCH 03/11] Replaced the copy of sparse matrix with a reference to its dimension and its non zero values --- src/krbalancing.cpp | 57 ++++++++++++++++++++++++++++++++++----------- src/krbalancing.hpp | 6 ++++- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 04cbf02..99393d3 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -1,19 +1,47 @@ #include "krbalancing.hpp" -kr_balancing::kr_balancing(const SparseMatrixCol & input){ - A = input; - e.resize(A.rows(),1); - e.setOnes(); - /*Replace zeros with 0.00001 on the main diagonal*/ - SparseMatrixCol I; - I.resize(A.rows(),A.cols()); - I.setIdentity(); - I = I*0.00001; - A = A + I; - rescaled = false; +// kr_balancing::kr_balancing(const SparseMatrixCol & input){ +// A = input; +// e.resize(A.rows(),1); +// e.setOnes(); +// /*Replace zeros with 0.00001 on the main diagonal*/ +// SparseMatrixCol I; +// I.resize(A.rows(),A.cols()); +// I.setIdentity(); +// I = I*0.00001; +// A = A + I; +// rescaled = false; +// } + +//TODO go vector by vector?? +kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, + const int & input_nnz, + const Eigen::Ref input_nnzRows, + const Eigen::Ref input_nnzCols, + const Eigen::Ref input_values){ + + A.resize(input_rows,input_cols); + A.reserve(input_nnz); + typedef Eigen::Triplet T; + std::vector triplets; + triplets.reserve(input_nnz); + for(size_t i = 0; i < input_nnzRows.size(); i++){ + triplets.push_back(T(input_nnzRows(i), input_nnzCols(i), + input_values(i))); + } + A.setFromTriplets(triplets.begin(), triplets.end()); + //std::cout << A << std::endl; + e.resize(A.rows(),1); + e.setOnes(); + /*Replace zeros with 0.00001 on the main diagonal*/ + SparseMatrixCol I; + I.resize(A.rows(),A.cols()); + I.setIdentity(); + I = I*0.00001; + A = A + I; + rescaled = false; } - void kr_balancing::computeKR(){ x = e.sparseView(); assert(x.isVector()); @@ -191,7 +219,10 @@ const SparseMatrixCol* kr_balancing::get_normalisation_vector(bool & rescale){ PYBIND11_MODULE(krbalancing, m) { py::class_(m, "kr_balancing") - .def(py::init< const SparseMatrixCol & >()) + .def(py::init< const int &, const int &, const int &, + const Eigen::Ref, + const Eigen::Ref, + const Eigen::Ref >()) .def("computeKR", &kr_balancing::computeKR) .def("get_normalisation_vector",&kr_balancing::get_normalisation_vector, py::return_value_policy::reference_internal) .def("get_normalised_matrix",&kr_balancing::get_normalised_matrix, py::return_value_policy::reference_internal); diff --git a/src/krbalancing.hpp b/src/krbalancing.hpp index 7a5f0e1..091c320 100644 --- a/src/krbalancing.hpp +++ b/src/krbalancing.hpp @@ -27,7 +27,11 @@ size_t num_threads = 10; //TODO add it as an argument to be set by user class kr_balancing{ public: - kr_balancing(const SparseMatrixCol & input); + kr_balancing(const int & input_rows , const int & input_cols, + const int & input_nnz, + const Eigen::Ref input_outer, + const Eigen::Ref input_inner, + const Eigen::Ref input_values); void computeKR(); void outer_loop(); void inner_loop(); From 85e2d9944e030cd34a779e6de7653569ef472b42 Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Tue, 7 May 2019 11:26:40 +0200 Subject: [PATCH 04/11] added test prints --- src/krbalancing.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 99393d3..e8c0149 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -22,15 +22,18 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, A.resize(input_rows,input_cols); A.reserve(input_nnz); + //Eigen::Map > sm1(input_rows, input_cols, + // input_nnz, *outerIndexPtr,*innerIndexPtr,*values) typedef Eigen::Triplet T; std::vector triplets; - triplets.reserve(input_nnz); + triplets.reserve(input_nnz); //multi-thread! + std::cout<< "ref!"< Date: Mon, 13 May 2019 08:55:26 +0200 Subject: [PATCH 05/11] Adding parsing with indpt, indices and data from csr_matrix (#13) --- src/krbalancing.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 99393d3..937526f 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -16,19 +16,37 @@ //TODO go vector by vector?? kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, const int & input_nnz, - const Eigen::Ref input_nnzRows, - const Eigen::Ref input_nnzCols, + const Eigen::Ref input_indptr, + const Eigen::Ref input_indices, const Eigen::Ref input_values){ A.resize(input_rows,input_cols); A.reserve(input_nnz); - typedef Eigen::Triplet T; + typedef Eigen::Triplet T; std::vector triplets; triplets.reserve(input_nnz); - for(size_t i = 0; i < input_nnzRows.size(); i++){ - triplets.push_back(T(input_nnzRows(i), input_nnzCols(i), - input_values(i))); + + // size_t x = input_indptr(0); + size_t i = 0; + size_t j_start = 0; + size_t j_end = 0; + + while (i < input_indptr.size() - 1) { + j_start = input_indptr(i); + j_end = input_indptr(i+1); + + while (j_start < j_end) { + triplets.push_back(T(i, input_indices(j_start), + float(input_values(j_start)))); + j_start++; + + } + i++; } + // for(size_t i = 0; i < input_nnzRows.size(); i++){ + // triplets.push_back(T(input_nnzRows(i), input_nnzCols(i), + // input_values(i))); + // } A.setFromTriplets(triplets.begin(), triplets.end()); //std::cout << A << std::endl; e.resize(A.rows(),1); From 679aa16dd47af663d4ef5324a1fe0da087c936a9 Mon Sep 17 00:00:00 2001 From: Joachim Wolff Date: Wed, 15 May 2019 09:04:30 +0200 Subject: [PATCH 06/11] Ref to matrix (#14) * Adding parsing with indpt, indices and data from csr_matrix * Write directly to matrix. added openmp for that, but looks like there is no benefit from openmp * Removing openmp and direct writing to matrix, performance was too bad. Adding clean to triplets to free memory as early as possible --- src/krbalancing.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 937526f..33528de 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -20,6 +20,7 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, const Eigen::Ref input_indices, const Eigen::Ref input_values){ + // SparseMatrix mat(rows,cols); A.resize(input_rows,input_cols); A.reserve(input_nnz); typedef Eigen::Triplet T; @@ -30,12 +31,16 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, size_t i = 0; size_t j_start = 0; size_t j_end = 0; - + std::cout << "start to parse values" << std::endl; while (i < input_indptr.size() - 1) { j_start = input_indptr(i); j_end = input_indptr(i+1); + // #pragma omp parallel + // for (j_start = input_indptr(i); j_start < j_end; j_start++) { while (j_start < j_end) { + // #pragma omp critical + // A.insert(i, input_indices(j_start)) = float(input_values(j_start)); triplets.push_back(T(i, input_indices(j_start), float(input_values(j_start)))); j_start++; @@ -43,11 +48,14 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, } i++; } + std::cout << "end parsing values" << std::endl; + // for(size_t i = 0; i < input_nnzRows.size(); i++){ // triplets.push_back(T(input_nnzRows(i), input_nnzCols(i), // input_values(i))); // } A.setFromTriplets(triplets.begin(), triplets.end()); + triplets.clear(); //std::cout << A << std::endl; e.resize(A.rows(),1); e.setOnes(); From 9e70763b270822d7cf320c5b81d8115b1362cdef Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Wed, 15 May 2019 10:57:19 +0200 Subject: [PATCH 07/11] omp --- src/krbalancing.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index e8c0149..64144c7 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -13,26 +13,33 @@ // rescaled = false; // } -//TODO go vector by vector?? kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, const int & input_nnz, const Eigen::Ref input_nnzRows, const Eigen::Ref input_nnzCols, const Eigen::Ref input_values){ - - A.resize(input_rows,input_cols); - A.reserve(input_nnz); + std::cout << input_nnz << " "<< input_cols < > sm1(input_rows, input_cols, // input_nnz, *outerIndexPtr,*innerIndexPtr,*values) typedef Eigen::Triplet T; std::vector triplets; - triplets.reserve(input_nnz); //multi-thread! - std::cout<< "ref!"< Date: Fri, 17 May 2019 12:27:46 +0200 Subject: [PATCH 08/11] added noconvert() --- src/krbalancing.cpp | 306 +++++++++++++++++++++++--------------------- src/krbalancing.hpp | 1 + 2 files changed, 158 insertions(+), 149 deletions(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 04a9bd0..e5a31be 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -20,7 +20,7 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, const Eigen::Ref input_values){ - // SparseMatrix mat(rows,cols); + // SparseMatrix mat(rows,cols); A.resize(input_rows,input_cols); A.reserve(input_nnz); typedef Eigen::Triplet T; @@ -37,10 +37,10 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, j_end = input_indptr(i+1); // #pragma omp parallel - // for (j_start = input_indptr(i); j_start < j_end; j_start++) { + //for (j_start = input_indptr(i); j_start < j_end; j_start++) { while (j_start < j_end) { // #pragma omp critical - // A.insert(i, input_indices(j_start)) = float(input_values(j_start)); + //A.insert(i, input_indices(j_start)) = float(input_values(j_start)); triplets.push_back(T(i, input_indices(j_start), float(input_values(j_start)))); j_start++; @@ -50,13 +50,10 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, } std::cout << "end parsing values" << std::endl; - // for(size_t i = 0; i < input_nnzRows.size(); i++){ - // triplets.push_back(T(input_nnzRows(i), input_nnzCols(i), - // input_values(i))); - // } + A.setFromTriplets(triplets.begin(), triplets.end()); + //A.makeCompressed(); triplets.clear(); - //std::cout << A << std::endl; e.resize(A.rows(),1); @@ -64,6 +61,7 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, /*Replace zeros with 0.00001 on the main diagonal*/ SparseMatrixCol I; I.resize(A.rows(),A.cols()); + I.reserve(A.rows()); I.setIdentity(); I = I*0.00001; A = A + I; @@ -71,175 +69,183 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, } void kr_balancing::computeKR(){ - x = e.sparseView(); - assert(x.isVector()); - v = x.cwiseProduct(A*x); - rk = Eigen::VectorXd::Constant(v.rows(),1) - v; //Vecotr of 1 - v - assert(rk.isVector()); - rho_km1 = rk.conjugate().transpose()*rk; - assert(rho_km1.coeff(0,0)>=0); - rho_km2 = rho_km1; - outer_loop(); + x = e.sparseView(); + assert(x.isVector()); + v = x.cwiseProduct(A*x); + rk = Eigen::VectorXd::Constant(v.rows(),1) - v; //Vecotr of 1 - v + assert(rk.isVector()); + rho_km1 = rk.transpose()*rk; + assert(rho_km1.coeff(0,0)>=0); + rho_km2 = rho_km1; + outer_loop(); } void kr_balancing::outer_loop(){ - size_t outer_loop_count = 0; - double stop_tol = tol*0.5; - double eta = etamax; - double rt = std::pow(tol,2); - double rout = rho_km1.coeff(0,0); - double rold = rout; - if(fl == 1) std::cout<< 'intermediate convergence statistics is off'< rt){//outer itteration - outer_loop_count ++; - i=i+1; k=0; y=e.sparseView(); - innertol = std::max(std::pow(eta,2)*rout,rt); - inner_loop(); - //assert(rho_km1.coeff(0,0) > 0); - assert(rho_km1.coeff(0,0) != std::numeric_limits::infinity()); - x=x.cwiseProduct(y); - assert(x.isVector()); - v=x.cwiseProduct((A*x)); - rk = Eigen::VectorXd::Constant(v.rows(),1) - v; - rho_km1 = rk.conjugate().transpose()*rk; - //assert(rho_km1.coeff(0,0) > 0); - assert(rho_km1.coeff(0,0) != std::numeric_limits::infinity()); - rout = rho_km1.coeff(0,0); - MVP = MVP + k + 1; - //Update inner iteration stopping criterion. - double rat = rout/rold; rold = rout; double res_norm = std::sqrt(rout); - double eta_o = eta; eta = g*rat; - if(g*std::pow(eta_o,2) > 0.1){ - eta = std::max(eta,g*std::pow(eta_o,2)); - } - eta = std::max(std::min(eta,etamax),stop_tol/res_norm); - if(fl == 1){ - res.push_back(res_norm); - } - if(outer_loop_count %50 ==0) std::cout << "outer loop number "<< outer_loop_count <= 100) { - // std::cout << "nochange >=100" < rt){//outer itteration + outer_loop_count ++; + i=i+1; k=0; y=e.sparseView(); + innertol = std::max(eta*eta*rout,rt); + inner_loop(); + //assert(rho_km1.coeff(0,0) > 0); + assert(rho_km1.coeff(0,0) != std::numeric_limits::infinity()); + x=x.cwiseProduct(y); + assert(x.isVector()); + v=x.cwiseProduct((A*x)); + rk = Eigen::VectorXd::Constant(v.rows(),1) - v; + rho_km1 = rk.transpose()*rk; + //assert(rho_km1.coeff(0,0) > 0); + assert(rho_km1.coeff(0,0) != std::numeric_limits::infinity()); + rout = rho_km1.coeff(0,0); + MVP = MVP + k + 1; + //Update inner iteration stopping criterion. + double rat = rout/rold; rold = rout; double res_norm = std::sqrt(rout); + double eta_o = eta; eta = g*rat; + if(g*eta_o*eta_o > 0.1){ + eta = std::max(eta,g*eta_o*eta_o); + } + eta = std::max(std::min(eta,etamax),stop_tol/res_norm); + if(fl == 1){ + res.push_back(res_norm); + } + if(outer_loop_count %50 ==0) std::cout << "outer loop number "<< outer_loop_count <= 100) { + // std::cout << "nochange >=100" < innertol){ // Inner itteration (conjugate gradient method) - inner_loop_count ++; - k++; - if(k == 1){ - Z = rk.cwiseQuotient(v); - p=Z; - rho_km1 = rk.conjugate().transpose()*Z; - }else{ - Eigen::VectorXd beta=rho_km1.cwiseQuotient(rho_km2); - p = Z + (beta(0)*p); - } - //Update search direction efficiently. - SparseMatrixCol w=x.cwiseProduct(A*(x.cwiseProduct(p))) + v.cwiseProduct(p); - SparseMatrixCol alpha_mat = rho_km1.cwiseQuotient(p.conjugate().transpose()*w); - double alpha = alpha_mat.coeff(0,0); - Eigen::VectorXd ap = alpha * p; - //Test distance to boundary of cone. - Eigen::VectorXd ynew = y + ap; - if(ynew.minCoeff() <= delta){ - if(delta == 0) break; - Eigen::Matrix ind_helper = (ap.array()<0); - Eigen::VectorXi ind = Eigen::VectorXi::LinSpaced(ind_helper.size(),0,ind_helper.size()-1); - ind.conservativeResize(std::stable_partition( - ind.data(), ind.data()+ind.size(), [&ind_helper](int i){return ind_helper(i);})-ind.data()); - Eigen::VectorXd y_copy; - y_copy.resize(ind.size()); - for(size_t i = 0; i < ind.size(); i++){ - y_copy(i) = (delta - y(ind(i)))/ap(ind(i)); - } - double gamma = y_copy.minCoeff(); - y = y + gamma*ap; - break; - } - if(ynew.maxCoeff() >= Delta){ - Eigen::Matrix ind_helper = (ynew.array() > Delta); - Eigen::VectorXi ind = Eigen::VectorXi::LinSpaced(ind_helper.size(),0,ind_helper.size()-1); - ind.conservativeResize(std::stable_partition( - ind.data(), ind.data()+ind.size(), [&ind_helper](int i){return ind_helper(i);})-ind.data()); - Eigen::VectorXd y_copy; - y_copy.resize(ind.size()); - for(size_t i = 0; i < ind.size(); i++){ - y_copy(i) = (Delta - y(ind(i)))/ap(ind(i)); - } - double gamma = y_copy.minCoeff(); - y = y + (gamma*ap); - break; - } - y = ynew; - rk = rk - (alpha*w); rho_km2 = rho_km1; - Z = rk.cwiseQuotient(v); rho_km1 = rk.conjugate().transpose()*Z; + size_t inner_loop_count = 0; + while (rho_km1.coeff(0,0) > innertol){ // Inner itteration (conjugate gradient method) + inner_loop_count ++; + k++; + if(k == 1){ + Z = rk.cwiseQuotient(v); + p=Z; + rho_km1 = rk.conjugate().transpose()*Z; + }else{ + Eigen::VectorXd beta=rho_km1.cwiseQuotient(rho_km2); + p = Z + (beta(0)*p); + } + //Update search direction efficiently. + SparseMatrixCol w=x.cwiseProduct(A*(x.cwiseProduct(p))) + v.cwiseProduct(p); + SparseMatrixCol alpha_mat = rho_km1.cwiseQuotient(p.conjugate().transpose()*w); + double alpha = alpha_mat.coeff(0,0); + Eigen::VectorXd ap = alpha * p; + //Test distance to boundary of cone. + Eigen::VectorXd ynew = y + ap; + if(ynew.minCoeff() <= delta){ + if(delta == 0) break; + Eigen::Matrix ind_helper = (ap.array()<0); + Eigen::VectorXi ind = Eigen::VectorXi::LinSpaced(ind_helper.size(),0,ind_helper.size()-1); + ind.conservativeResize(std::stable_partition( + ind.data(), ind.data()+ind.size(), [&ind_helper](int i){return ind_helper(i);})-ind.data()); + Eigen::VectorXd y_copy; + y_copy.resize(ind.size()); + for(size_t i = 0; i < ind.size(); i++){ + y_copy(i) = (delta - y(ind(i)))/ap(ind(i)); + } + double gamma = y_copy.minCoeff(); + y = y + gamma*ap; + break; + } + if(ynew.maxCoeff() >= Delta){ + Eigen::Matrix ind_helper = (ynew.array() > Delta); + Eigen::VectorXi ind = Eigen::VectorXi::LinSpaced(ind_helper.size(),0,ind_helper.size()-1); + ind.conservativeResize(std::stable_partition( + ind.data(), ind.data()+ind.size(), [&ind_helper](int i){return ind_helper(i);})-ind.data()); + Eigen::VectorXd y_copy; + y_copy.resize(ind.size()); + for(size_t i = 0; i < ind.size(); i++){ + y_copy(i) = (Delta - y(ind(i)))/ap(ind(i)); + } + double gamma = y_copy.minCoeff(); + y = y + (gamma*ap); + break; + } + y = ynew; + rk = rk - (alpha*w); rho_km2 = rho_km1; + Z = rk.cwiseQuotient(v); rho_km1 = rk.conjugate().transpose()*Z; }//End of the inner 'while' } void kr_balancing::compute_normalised_matrix(bool & rescale){ - assert(A.rows() == A.cols()); - if(rescale ==true && rescaled == false){ - rescale_norm_vector(); - rescaled = true; - }else{ - A = SparseMatrixCol(A.triangularView()); - } - #pragma omp parallel for num_threads(num_threads) schedule(dynamic) - for (int k=0; k()); + } + #pragma omp parallel for num_threads(num_threads) schedule(dynamic) + for (int k=0; k()); + float original_sum = 0.0; + float norm_vector_sum = 0.0; + assert(A.rows() == A.cols()); + A = SparseMatrixCol(A.triangularView()); - #pragma omp parallel for num_threads(num_threads) - for (int k=0; k, const Eigen::Ref >()) .def("computeKR", &kr_balancing::computeKR) - .def("get_normalisation_vector",&kr_balancing::get_normalisation_vector, py::return_value_policy::reference_internal) - .def("get_normalised_matrix",&kr_balancing::get_normalised_matrix, py::return_value_policy::reference_internal); + .def("get_normalisation_vector",&kr_balancing::get_normalisation_vector, + py::return_value_policy::reference_internal, py::arg().noconvert()) + .def("get_normalised_matrix",&kr_balancing::get_normalised_matrix, + py::return_value_policy::reference_internal, py::arg().noconvert()); } diff --git a/src/krbalancing.hpp b/src/krbalancing.hpp index 091c320..9038bca 100644 --- a/src/krbalancing.hpp +++ b/src/krbalancing.hpp @@ -32,6 +32,7 @@ class kr_balancing{ const Eigen::Ref input_outer, const Eigen::Ref input_inner, const Eigen::Ref input_values); + ~kr_balancing(){} void computeKR(); void outer_loop(); void inner_loop(); From 77185efd5780570325fb4e00f458e792bbb2c550 Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Fri, 17 May 2019 14:11:00 +0200 Subject: [PATCH 09/11] removed a commented line --- src/krbalancing.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index e5a31be..124ac4d 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -20,7 +20,6 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, const Eigen::Ref input_values){ - // SparseMatrix mat(rows,cols); A.resize(input_rows,input_cols); A.reserve(input_nnz); typedef Eigen::Triplet T; From c913b6b5a32bd77a852c60db747b2300e26e7222 Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Tue, 11 Jun 2019 12:56:29 +0200 Subject: [PATCH 10/11] removing commented lines --- src/krbalancing.cpp | 2 +- src/krbalancing.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 124ac4d..09fb99e 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -50,7 +50,7 @@ kr_balancing::kr_balancing(const int & input_rows , const int & input_cols, std::cout << "end parsing values" << std::endl; - A.setFromTriplets(triplets.begin(), triplets.end()); + A.setFromTriplets(triplets.begin(), triplets.end()); //bottleneck //A.makeCompressed(); triplets.clear(); diff --git a/src/krbalancing.hpp b/src/krbalancing.hpp index 9038bca..65fba53 100644 --- a/src/krbalancing.hpp +++ b/src/krbalancing.hpp @@ -22,7 +22,7 @@ #include #include namespace py = pybind11; -using SparseMatrixCol = Eigen::SparseMatrix; +using SparseMatrixCol = Eigen::SparseMatrix; size_t num_threads = 10; //TODO add it as an argument to be set by user class kr_balancing{ From b51b3957db3796dba6cbf2f3519e68b7400c208a Mon Sep 17 00:00:00 2001 From: Leily Rabbani Date: Tue, 11 Jun 2019 13:02:34 +0200 Subject: [PATCH 11/11] version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 63bb297..639d70a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from sysconfig import get_config_var, get_paths import logging -__version__ = '0.0.4' +__version__ = '0.0.5dev' def get_include(): # TODO