void FuseProb::normalize(Mat& M) //Used only to display the images properly { cout<<"In normalize"<<endl; double v; Point A; Mat M_temp(m_rows, m_cols, CV_64F); M.copyTo(M_temp); for(int i=0; i<m_rows; ++i) for(int j=0; j<m_cols; ++j) { if(!isNavigable(M_temp, i, j)) M_temp.at<double>(i, j)*=(-1); } minMaxLoc(M_temp, NULL, &v, NULL, &A); cout<<"V is "<<v<<endl; for(int i=0; i<m_rows; ++i) for(int j=0; j<m_cols; ++j) { if(isNavigable(M, i, j)) M.at<double>(i, j)/=v; } cout<<"Done in normalize"<<endl; }
MergedSolver::MergedSolver(const_SystemMatrix_ptr M, const Options* options) { const index_t rank = M->mpi_info->rank; const index_t size = M->mpi_info->size; const dim_t global_n = M->getGlobalNumRows(); const dim_t n_block = M->mainBlock->row_block_size; const std::vector<index_t> dist(M->pattern->input_distribution->first_component); SparseMatrix_ptr M_temp(M->mergeSystemMatrix()); mpi_info = M->mpi_info; reordering = options->reordering; refinements = options->coarse_matrix_refinements; //verbose = options->verbose; verbose = false; sweeps = options->pre_sweeps+options->post_sweeps; // First, gather x and b into rank 0 b = new double[global_n*n_block]; x = new double[global_n*n_block]; counts = new int[size]; offset = new int[size]; #pragma omp parallel for for (dim_t i=0; i<size; i++) { const dim_t p = dist[i]; counts[i] = (dist[i+1] - p)*n_block; offset[i] = p*n_block; } if (rank == 0) { #ifdef ESYS_HAVE_MKL A = M_temp->unroll(MATRIX_FORMAT_BLK1 + MATRIX_FORMAT_OFFSET1); A->solver_package = PASO_MKL; #elif defined ESYS_HAVE_UMFPACK A = M_temp->unroll(MATRIX_FORMAT_BLK1 + MATRIX_FORMAT_CSC); A->solver_package = PASO_UMFPACK; #else A->solver_p = Preconditioner_LocalSmoother_alloc(A, (options->smoother == PASO_JACOBI), verbose); A->solver_package = PASO_SMOOTHER; #endif } }