当前位置: 首页>>代码示例>>C++>>正文


C++ solution函数代码示例

本文整理汇总了C++中solution函数的典型用法代码示例。如果您正苦于以下问题:C++ solution函数的具体用法?C++ solution怎么用?C++ solution使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了solution函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int 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,代码来源:main.cpp

示例2: quadrature_formula

Report 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,代码来源:stress.cpp

示例3: fill_costs

//Solves the puzzle
void 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,代码来源:puzzle.cpp

示例4: main

void 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,代码来源:codility2.c

示例5: main

int 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,代码来源:CyclicRotation.c

示例6: main

int 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,代码来源:main.c

示例7: main

int 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,代码来源:003-整数划分1.cpp

示例8: TEST

TEST(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,代码来源:UnitTest.cpp

示例9: _auxs

void
AuxiliarySystem::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,代码来源:AuxiliarySystem.C

示例10: addConfig

int
addConfig(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,代码来源:glpuzzle.cpp

示例11: main

int 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 µs\n", t_elapsed * 1000000.0L);
    } else {
        printf("Average Duration: %.3Lg ns\n", t_elapsed * 1000000000.0L);
    }

    return 0;
}
开发者ID:thomasbkahn,项目名称:project-euler,代码行数:42,代码来源:002.cpp

示例12: run

void run(const casema::ModelData<mpfr::mpreal>& model, ProgramOptions<mpfr::mpreal>& opts)
{
    // Log10(errorPrefactor)
    const mpfr::mpreal errorPrefactor = log10(sqrt(mpfr::mpreal(2))) + model.colLength * model.velocity / (2 * model.colDispersion * log(mpfr::mpreal(10)));
    const mpfr::mpreal T = opts.tMax / mpfr::mpreal(2) * mpfr::mpreal("1.01");
    const mpfr::mpreal errorExponentFactor = model.colLength * sqrt(casema::Constants<mpfr::mpreal>::pi() / (2 * T * model.colDispersion)) / log(mpfr::mpreal(10));

    std::vector<mpfr::mpcomplex> output(opts.summands);
    std::vector<mpfr::mpreal> error(opts.summands, errorPrefactor);
    Inlet_t inlet(model);

    if (model.kineticBinding)
    {
        typedef casema::laplaceSolution::SingleComponentLinearDynamic<mpfr::mpreal, mpfr::mpreal, Inlet_t> Solution_t;
	    Solution_t solution(model, inlet);
        if (opts.withoutInlet)
            fourierCoeff<Solution_t, mpfr::mpreal, mpfr::mpcomplex>(opts.precision, opts.summands, opts.tMax, opts.sigma, solution, errorExponentFactor, output, error);
        else
            fourierCoeff<Solution_t, mpfr::mpreal, mpfr::mpcomplex>(opts.precision, opts.summands, opts.tMax, opts.sigma, solution, inlet, errorExponentFactor, output, error);
    }
    else
    {
        typedef casema::laplaceSolution::SingleComponentLinearRapidEquilibrium<mpfr::mpreal, mpfr::mpreal, Inlet_t> Solution_t;
	    Solution_t solution(model, inlet);
        if (opts.withoutInlet)
            fourierCoeff<Solution_t, mpfr::mpreal, mpfr::mpcomplex>(opts.precision, opts.summands, opts.tMax, opts.sigma, solution, errorExponentFactor, output, error);
        else
            fourierCoeff<Solution_t, mpfr::mpreal, mpfr::mpcomplex>(opts.precision, opts.summands, opts.tMax, opts.sigma, solution, inlet, errorExponentFactor, output, error);
    }

    if (opts.outFile.empty())
    {
        writeMeta(std::cout, model.kineticBinding, opts);
        writeResult(std::cout, output, error, opts.outPrecision, opts.skipSummands);
    }
    else
    {
        std::ofstream fs(opts.outFile, std::ofstream::out | std::ofstream::trunc);
        writeMeta(fs, model.kineticBinding, opts);
        writeResult(fs, output, error, opts.outPrecision, opts.skipSummands);
    }
}
开发者ID:modsim,项目名称:CADET-semi-analytic,代码行数:42,代码来源:fourierError.cpp

示例13: main

int main()
{
  int n,k;
  while(1)
  {
    scanf("%d %d",&n,&k);
    if(!n && !k) break;
    printf("%d\n",solution(n,k));
  }
  return 0;
}
开发者ID:archiver,项目名称:spoj,代码行数:11,代码来源:zsum.c

示例14: main

int main() {
    int N, T;
    int value[50];
    scanf("%d%d", &N, &T);
    while (N || T) {
        for (int i = 0; i < N; ++i) scanf("%d", value + i);
        printf("%d\n", solution(N, T, value));
        scanf("%d%d", &N, &T);
    }
    return 0;
}
开发者ID:scofield7419,项目名称:algorithms,代码行数:11,代码来源:001-硬币找零之最少硬币数目.cpp

示例15: warn_if

      MeshFunctionSharedPtr<Scalar> Limiter<Scalar>::get_solution()
      {
        // A check.
        warn_if(this->component_count > 1, "One solution asked from a Limiter, but multiple solutions exist for limiting.");

        MeshFunctionSharedPtr<Scalar> solution(new Solution<Scalar>());
        Hermes::vector<MeshFunctionSharedPtr<Scalar> > solutions;
        solutions.push_back(solution);
        this->get_solutions(solutions);
        return solutions.back();
      }
开发者ID:julywater,项目名称:hermes,代码行数:11,代码来源:postprocessing.cpp


注:本文中的solution函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。