本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
}
}