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


C++ Array1::resize方法代码示例

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


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

示例1: exportStates

    void exportStates(Array1<double>& x, Array1<double>& y) const
    {
        x.resize(positions.size());
        y.resize(positions.size());

        for (size_t i = 0; i < positions.size(); ++i)
        {
            x[i] = positions[i].x;
            y[i] = positions[i].y;
        }
    }
开发者ID:sumitneup,项目名称:fluid-engine-dev,代码行数:11,代码来源:physics_animation_tests.cpp

示例2: saveParticleDataXy

JET_END_TEST_F

JET_BEGIN_TEST_F(FlipSolver2, Rotation) {
    // Build solver
    auto solver = FlipSolver2::builder()
        .withResolution({10, 10})
        .withDomainSizeX(1.0)
        .makeShared();

    solver->setGravity({0, 0});
    solver->setPressureSolver(nullptr);

    // Build emitter
    auto box = Sphere2::builder()
        .withCenter({0.5, 0.5})
        .withRadius(0.4)
        .makeShared();

    auto emitter = VolumeParticleEmitter2::builder()
        .withSurface(box)
        .withSpacing(1.0 / 20.0)
        .withIsOneShot(true)
        .makeShared();

    solver->setParticleEmitter(emitter);

    Array1<double> r;

    for (Frame frame; frame.index < 360; ++frame) {
        auto x = solver->particleSystemData()->positions();
        auto v = solver->particleSystemData()->velocities();
        r.resize(x.size());
        for (size_t i = 0; i < x.size(); ++i) {
            r[i] = (x[i] - Vector2D(0.5, 0.5)).length();
        }

        solver->update(frame);

        if (frame.index == 0) {
            x = solver->particleSystemData()->positions();
            v = solver->particleSystemData()->velocities();
            for (size_t i = 0; i < x.size(); ++i) {
                Vector2D rp = x[i] - Vector2D(0.5, 0.5);
                v[i].x = rp.y;
                v[i].y = -rp.x;
            }
        } else {
            for (size_t i = 0; i < x.size(); ++i) {
                Vector2D rp = x[i] - Vector2D(0.5, 0.5);
                if (rp.lengthSquared() > 0.0) {
                    double scale = r[i] / rp.length();
                    x[i] = scale * rp + Vector2D(0.5, 0.5);
                }
            }
        }

        saveParticleDataXy(solver->particleSystemData(), frame.index);
    }
}
开发者ID:sumitneup,项目名称:fluid-engine-dev,代码行数:59,代码来源:flip_solver2_tests.cpp

示例3: fill_pleaf

// pleaf is a vector of joint probabilities on the leaves
void fill_pleaf(Tree &T, StateList &sl, Parameters &Par, Array1 &pleaf) {
  long i, j, l, u, v;
  double p;

  // Initializations
  pleaf.resize(T.nstleaves);
  for (i=0; i < T.nstleaves; i++) {
    pleaf[i] = 0;
  }

  // Loop over all states
  for (i=0; i < T.nstleaves; i++) {
    for(j=0; j < T.nsthidden; j++) {

      // Compute leaf probabilities
      p = Par.r[rootstate(sl.h[j])];
      for(l=0; l < T.nedges; l++) {
        edgestate(T, l, sl.h[j], sl.l[i], u, v);
        p = p*Par.tm[l][u][v];
      }
      pleaf[i] = pleaf[i] + p;
    }
  }
}
开发者ID:Algebraicphylogenetics,项目名称:Empar,代码行数:25,代码来源:fisher.cpp


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