这篇教程C++ solution函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中solution函数的典型用法代码示例。如果您正苦于以下问题:C++ solution函数的具体用法?C++ solution怎么用?C++ solution使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了solution函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main(int argc, char *argv[]){ QString ampFile("../example_data/amplitude_199x199_double.raw"); QString phaFile("../example_data/phase_199x199_double.raw"); QString solFile("../example_data/solution_199x199_double.raw"); QSize rawSize(199,199); int sz = rawSize.width() * rawSize.height(); QFile amplitude(ampFile); if (!amplitude.open(QIODevice::ReadOnly)) { qDebug() << "amplitude file not found" << ampFile; return -1; } double* amp = new double[sz]; amplitude.read((char*)amp, sz * sizeof(amp[0])); amplitude.close(); QFile phase(phaFile); if (!phase.open(QIODevice::ReadOnly)) { qDebug() << "phase file not found" << phaFile; return -1; } double* pha = new double[sz]; phase.read((char*)pha, sz * sizeof(pha[0])); phase.close(); GSATracking up; up.SetBranchCutMode(GSATracking::AMPLITUDETRACING); // aplitude tracking mode up.SetCutsDilate(7); // dilatation kernel radius up.SetInterpolate(true); // interpolation enabled up.SetWeightedInterpolation(true); // amplitude based weighted interpolation double* sol = up.UnWrapp(pha, amp, rawSize); QFile solution(solFile); solution.open(QIODevice::WriteOnly); solution.write((char*)sol, sz * sizeof(sol[0])); solution.close(); delete amp; delete pha; qDebug() << "positive residues:" << up.PositiveResidueCount(); qDebug() << "negative residues:" << up.NegativeResidueCount(); qDebug() << "solution file created:" << solFile; qDebug() << endl << "press any key"; std::cin.get(); return 0;}
开发者ID:Lukas-kV,项目名称:HoloPhaser,代码行数:58,
示例2: quadrature_formulaReport ElasticProblem2DOnCellV2<dim>::calculate_cells_stress (){ cells_stress .clear (); dealii::QGauss<dim> quadrature_formula(2); dealii::FEValues<dim> fe_values (finite_element, quadrature_formula, dealii::update_gradients | dealii::update_quadrature_points | dealii::update_JxW_values); const uint8_t dofs_per_cell = finite_element.dofs_per_cell; const uint8_t num_quad_points = quadrature_formula.size(); typename dealii::DoFHandler<dim>::active_cell_iterator cell = this->domain.dof_handler.begin_active(); typename dealii::DoFHandler<dim>::active_cell_iterator endc = this->domain.dof_handler.end(); std::vector<unsigned int> local_dof_indices (dofs_per_cell); size_t cell_num = 0; for (; cell != endc; ++cell) { fe_values .reinit (cell); dbl area = 0.0; for(st i = 0; i < num_quad_points; ++i) area += fe_values.JxW(o); dbl mat_id = cell->material_id(); std::array<dbl,2> deform; for (auto i : {x, y}) { deform[i][j] = 0.0; for(auto i : {1, 2, 3, 4}) { dbl summ = 0.0; for (size_t q_point = 0; q_point < num_quad_points; ++q_point) summ += fe_values.shape_grad (n, q_point)[i] * fe_values.JxW(q_point); deform[i] += solution(cell->vertex_dof_index(n, 0)) * summ; }; deform[i] /= area; }; }; REPORT_USE( Report report; report.result = true; _return (report););
开发者ID:evil-is-good,项目名称:primat-projects,代码行数:58,
示例3: fill_costs//Solves the puzzlevoid puzzle::solve(){ std::cout << "Finding edge costs..." << std::endl; fill_costs(); std::vector<match_score>::iterator i= matches.begin(); PuzzleDisjointSet p((int)pieces.size()); //You can save the individual pieces with their id numbers in the file name//If the following loop is uncommented.// for(int i=0; i<pieces.size(); i++){// std::stringstream filename;// filename << "/tmp/final/p" << i << ".png";// cv::imwrite(filename.str(), pieces[i].full_color);// } int output_id=0; while(!p.in_one_set() && i!=matches.end() ){ int p1 = i->edge1/4; int e1 = i->edge1%4; int p2 = i->edge2/4; int e2 = i->edge2%4; //Uncomment the following lines to spit out pictures of the matched edges...// cv::Mat m = cv::Mat::zeros(500,500,CV_8UC1);// std::stringstream out_file_name;// out_file_name << "/tmp/final/match" << output_id++ << "_" << p1<< "_" << e1 << "_" <<p2 << "_" <<e2 << ".png";// std::vector<std::vector<cv::Point> > contours;// contours.push_back(pieces[p1].edges[e1].get_translated_contour(200, 0));// contours.push_back(pieces[p2].edges[e2].get_translated_contour_reverse(200, 0));// cv::drawContours(m, contours, -1, cv::Scalar(255));// std::cout << out_file_name.str() << std::endl;// cv::imwrite(out_file_name.str(), m);// std::cout << "Attempting to merge: " << p1 << " with: " << p2 << " using edges:" << e1 << ", " << e2 << " c:" << i->score << " count: " << output_id++ <<std::endl; p.join_sets(p1, p2, e1, e2); i++; } if(p.in_one_set()){ std::cout << "Possible solution found" << std::endl; solved = true; solution = p.get(p.find(1)).locations; solution_rotations = p.get(p.find(1)).rotations; for(int i =0; i<solution.size[0]; i++){ for(int j=0; j<solution.size[1]; j++){ int piece_number = solution(i,j); pieces[piece_number].rotate(4-solution_rotations(i,j)); } } } }
开发者ID:grevutiu-gabriel,项目名称:PuzzleSolver,代码行数:58,
示例4: mainvoid main(){ long int a; int X,Y,D; scanf("%d %d %d",&X,&Y,&D); a=solution(X,Y,D); printf("Ans: %li/n /r",a);}
开发者ID:ChaitraVenk,项目名称:Hello,代码行数:9,
示例5: mainint main(void){ int16_t *array = malloc(5 * sizeof(int16_t)); for(size_t i = 0; i < 5; i++) array[i] = i; array = solution(array, 5, 5); for(size_t i = 0; i < 5; i++) printf("%d ", array[i]);}
开发者ID:MrPlatwnas,项目名称:Codility,代码行数:9,
示例6: mainint main(int argc, const char * argv[]){ int A[] = {9,3,9,3,9,7,9}; int N = 7; printf("%d/n", solution(A,N)); return 0;}
开发者ID:AlexTerekhoff,项目名称:Codility-lessons,代码行数:9,
示例7: mainint main() { int M, n; scanf("%d", &M); while (M--) { scanf("%d", &n); printf("%d/n", solution(n)); } //system("pause"); return 0;}
开发者ID:scofield7419,项目名称:algorithms,代码行数:10,
示例8: TESTTEST(matrix3, GetTranslationMatrix){ Vector2 v1(3, -7); Matrix3 m = m.GetTranslationMatrix(v1); Matrix3 solution( 1, 0, 3, 0, 1, -7, 0, 0, 1); EXPECT_TRUE(m == solution);}
开发者ID:TheCapleGuy,项目名称:MathLib,代码行数:10,
示例9: _auxsvoidAuxiliarySystem::computeNodalVars(ExecFlagType type){ std::vector<AuxWarehouse> & auxs = _auxs(type); // Do we have some kernels to evaluate? bool have_block_kernels = false; for (std::set<SubdomainID>::const_iterator subdomain_it = _mesh.meshSubdomains().begin(); subdomain_it != _mesh.meshSubdomains().end(); ++subdomain_it) { have_block_kernels |= (auxs[0].activeBlockNodalKernels(*subdomain_it).size() > 0); } Moose::perf_log.push("update_aux_vars_nodal()","Solve"); PARALLEL_TRY { if (have_block_kernels) { ConstNodeRange & range = *_mesh.getLocalNodeRange(); ComputeNodalAuxVarsThread navt(_mproblem, *this, auxs); Threads::parallel_reduce(range, navt); solution().close(); _sys.update(); } } PARALLEL_CATCH; Moose::perf_log.pop("update_aux_vars_nodal()","Solve"); //Boundary AuxKernels Moose::perf_log.push("update_aux_vars_nodal_bcs()","Solve"); PARALLEL_TRY { // after converting this into NodeRange, we can run it in parallel ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange(); ComputeNodalAuxBcsThread nabt(_mproblem, *this, auxs); Threads::parallel_reduce(bnd_nodes, nabt); solution().close(); _sys.update(); } PARALLEL_CATCH; Moose::perf_log.pop("update_aux_vars_nodal_bcs()","Solve");}
开发者ID:MatthewWilliamNoble,项目名称:moose,代码行数:43,
示例10: addConfigintaddConfig(Config config, struct puzzle *back){ unsigned hashvalue; struct puzzle *newpiece; struct puzzlelist *newlistentry; hashvalue = hash(config); newpiece = hashtable[hashvalue % HASHSIZE]; while (newpiece != NULL) { if (newpiece->hashvalue == hashvalue) { int i, j; for (i = 0; i < WIDTH; i++) { for (j = 0; j < HEIGHT; j++) { if (convert[(int)config[j][i]] != convert[(int)newpiece->pieces[j][i]]) goto nomatch; } } return 0; } nomatch: newpiece = newpiece->next; } newpiece = (struct puzzle *) malloc(sizeof(struct puzzle)); newpiece->next = hashtable[hashvalue % HASHSIZE]; newpiece->hashvalue = hashvalue; memcpy(newpiece->pieces, config, HEIGHT * WIDTH); newpiece->backptr = back; newpiece->solnptr = NULL; hashtable[hashvalue % HASHSIZE] = newpiece; newlistentry = (struct puzzlelist *) malloc(sizeof(struct puzzlelist)); newlistentry->puzzle = newpiece; newlistentry->next = NULL; if (lastentry) { lastentry->next = newlistentry; } else { puzzles = newlistentry; } lastentry = newlistentry; if (back == NULL) { startPuzzle = newpiece; } if (solution(config)) { solidifyChain(newpiece); return 1; } return 0;}
开发者ID:GustavoMOG,项目名称:efltk,代码行数:55,
示例11: mainint main() { printf("Answer: %lu/n", solution()); timestamp_t t0 = get_timestamp(); for (int i = 0; i < 3; ++i) { solution(); } timestamp_t t1 = get_timestamp(); double t_elapsed = (t1 - t0) / 1000000.0L / 3; if (t_elapsed < 3) { int run_time = 10; unsigned long long n_iters = run_time / t_elapsed; timestamp_t t0 = get_timestamp(); for (int i = 0; i < n_iters; ++i) { solution(); } timestamp_t t1 = get_timestamp(); t_elapsed = (t1 - t0) / 1000000.0L / n_iters; } double exp_t = log10(t_elapsed); if (exp_t > 0) { printf("Average Duration: %.3g s/n", t_elapsed); } else if (exp_t > -3) { printf("Average Duration: %.3Lg ms/n", t_elapsed * 1000.0L); } else if (exp_t > -6) { printf("Average Duration: %.3Lg C++ solv_free函数代码示例 C++ solo_reg_write函数代码示例
|