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


C++ valarray::max方法代码示例

本文整理汇总了C++中valarray::max方法的典型用法代码示例。如果您正苦于以下问题:C++ valarray::max方法的具体用法?C++ valarray::max怎么用?C++ valarray::max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在valarray的用法示例。


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

示例1: setup_initial_genotypes

/* set up sites based on initial genotypes */
void Population::setup_initial_genotypes(valarray<int> &hets, valarray<int> &homs) {
  if (hets.size() != homs.size()) throw SimError("len(hets) != len(homs)");
  if (hets.max() > popsize) throw SimError("too many heterozygotes");
  if (homs.max() > popsize) throw SimError("too many homozygotes");
  if ((hets+homs).max() > popsize) throw SimError("negative homozygote-ancestral");

  /* used to randomize individuals */
  valarray<int> ranout(popsize);

  mutation_loc loc;
  int ind;
  for (int k=0; k < (int)hets.size(); k++) {
    ranint(popsize,ranout);

    if (sites_model == infinite_sites)
      loc = create_site(GenomeInfiniteSites::sample_effect_size());
    else
      loc = (mutation_loc)k;

    /* haploid can't have homozygote_derived */
    if (Site::ploidy_level == haploid && homs[k] > 0)
      throw SimError("haploid can't have homozygote derived site");

    /* mutate heterozygote sites once */
    for (ind=0; ind < hets[k]; ind++) 
      genomes[ranout[ind]]->mutate_site(loc, up);
    /* mutate homozygote sites twice */
    for (; ind < hets[k]+homs[k]; ind++) {
      genomes[ranout[ind]]->mutate_site(loc, up);
      genomes[ranout[ind]]->mutate_site(loc, up);
    }
  }

  /* compute fitnesses */
  for (ind = 0; ind < popsize; ind++) {
    genomes[ind]->update_phenotype();
    genomes[ind]->update_fitness();
  }
  return;
}
开发者ID:kbullaughey,项目名称:polyevol,代码行数:41,代码来源:population.cpp

示例2: updateEigenSystem

    bool updateEigenSystem(unsigned max_tries, unsigned max_iters) {

        if (max_iters==0) max_iters = 30 * p.n;

        static double lastGoodMinimumEigenValue = 1.0;

        /* Try to get a valid calculation */
        for (unsigned tries = 0; tries < max_tries; ++tries) {

            unsigned iters = eig( p.n, C, d, B, max_iters);
            if (iters < max_iters)
            { // all is well

                /* find largest/smallest eigenvalues */
                double minEV = d.min();
                double maxEV = d.max();

                /* (MK Original comment was) :Limit Condition of C to dMaxSignifKond+1
                 * replaced dMaxSignifKond with 1./numeric_limits<double>::epsilon()
                 * */
                if (maxEV * numeric_limits<double>::epsilon() > minEV) {
                    double tmp = maxEV * numeric_limits<double>::epsilon() - minEV;
                    minEV += tmp;
                    for (unsigned i=0;i<p.n;++i) {
                        C[i][i] += tmp;
                        d[i] += tmp;
                    }
                } /* if */
                lastGoodMinimumEigenValue = minEV;

                d = sqrt(d);

                //flgEigensysIsUptodate = 1;
                //genOfEigensysUpdate = gen;
                //clockeigensum += clock() - clockeigenbegin;
                return true;
            } /* if cIterEig < ... */

            // numerical problems, ignore them and try again

            /* Addition des letzten minEW auf die Diagonale von C */
            /* Add the last known good eigen value to the diagonal of C */
            double summand = lastGoodMinimumEigenValue * exp((double) tries);
            for (unsigned i = 0; i < p.n; ++i)
                C[i][i] += summand;

        } /* for iEigenCalcVers */

        return false;

    }
开发者ID:jmp75,项目名称:paradiseo,代码行数:51,代码来源:CMAState.cpp

示例3: max

static double 
Linfty(valarray<double> const &vec) {
    return std::max(vec.max(), -vec.min());
}
开发者ID:AidanDelaney,项目名称:adaptagrams,代码行数:4,代码来源:test_cg.cpp


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