void SphereClumpGeom::postLoad(SphereClumpGeom&,void* attr){ if(attr==NULL){ if(centers.size()!=radii.size()) throw std::runtime_error("SphereClumpGeom: centers and radii must have the same length (len(centers)="+to_string(centers.size())+", len(radii)="+to_string(radii.size())+")."); // valid data, and volume has not been computed yet if(!centers.empty() && isnan(volume)) recompute(div); } else { // centers/radii/div changed, try to recompute recompute(div,/*failOk*/true,/*fastOnly*/true); } }
/** * @brief Creates a camera at (0, 0, 0) and looking towards the x axis. */ camera::camera(): position(0, 0, 0), horizontal_angle(0), vertical_angle(0) { recompute(); }
/* Default constructor. Sets a standard normal distribution: * mean = 0.0, and standard deviation = 1.0. */ GaussianDistribution::GaussianDistribution() : mean(0.0), sigma(1.0) { recompute(); } // End of constructor 'GaussianDistribution::GaussianDistribution()'
static void test_inc_x(size_t i, const double *dx, const size_t *jdx, size_t ndx) { size_t j, k; if (jdx) { for (k = 0; k < ndx; k++) { X[i * P + jdx[k]] += dx[k]; } } else if (ndx) { assert(ndx == P); for (j = 0; j < P; j++) { X[i * P + j] += dx[j]; } } recompute(); mlogit_set_x(&MLOGIT, i, 0, P, X + i * P); //print_error("\tx..."); test_x(); //print_error("ok\n\tmean..."); test_mean(); //print_error("ok\n\tcov..."); test_cov(); //print_error("ok\n"); }
// Copy any settings from another model that we can. void GPCMTransitionReward::copySettings( GPCMTransitionReward *other // Other transition reward to copy settings from. ) { this->gaussianProcess->copySettings(other->gaussianProcess); recompute(false); // Must recompute ourselves, since model doesn't recompute us. }
vector<shared_ptr<SphereClumpGeom>> SphereClumpGeom::fromSpherePack(const shared_ptr<SpherePack>& sp, int div){ std::map<int,std::list<int>> cIx; // map clump to all its spheres size_t N=sp->pack.size(); int noClump=-1; for(size_t i=0; i<N; i++){ if(sp->pack[i].clumpId<0) cIx[noClump--].push_back(i); // standalone spheres, get negative "ids" else cIx[sp->pack[i].clumpId].push_back(i); } vector<shared_ptr<SphereClumpGeom>> ret; ret.reserve(cIx.size()); // store iterators in flat array so that the loop can be parallelized vector<std::map<int,std::list<int>>::iterator> cIxIter; cIxIter.reserve(cIx.size()); for(std::map<int,std::list<int>>::iterator I=cIx.begin(); I!=cIx.end(); ++I) cIxIter.push_back(I); #ifdef WOO_OPENMP #pragma omp parallel for schedule(guided) #endif for(size_t i=0; i<cIxIter.size(); i++){ const auto& ci(*cIxIter[i]); auto cg=make_shared<SphereClumpGeom>(); cg->div=div; cg->centers.clear(); cg->centers.reserve(ci.second.size()); cg->radii.clear(); cg->radii.reserve(ci.second.size()); for(const int& i: ci.second){ cg->centers.push_back(sp->pack[i].c); cg->radii.push_back(sp->pack[i].r); } assert(cg->centers.size()==ci.second.size()); assert(cg->radii.size()==ci.second.size()); cg->recompute(div); assert(cg->isOk()); ret.push_back(cg); } return ret; }
void Process::GraphicsViewLayerModelPanelProxy::on_sizeChanged(const QSize& size) { m_height = size.height() - m_view->horizontalScrollBar()->height() - 2; m_width = size.width(); recompute(); }
/* Explicit constructor. * * @param mu Mean * @param sig Standard deviation * * \warning If (sig <= 0.0), it will be set to 1.0. */ GaussianDistribution::GaussianDistribution( double mu, double sig ) : mean(mu), sigma(sig) { recompute(); } // End of constructor 'GaussianDistribution::GaussianDistribution()'
ProcessorEnvelope::ProcessorEnvelope(float attack, float decay, float sustain, float release) { reset(); this->attack = attack; this->decay = decay; this->sustain = sustain; this->release = release; recompute(); }
map::Proxy& map::Proxy::operator+=(afield::mapped_type str) { pm._field[key] += str; if (pm.parent.smart_build) recompute(); return *this; }
PerspectiveCamera::PerspectiveCamera (Point3 _position, Vector3 _forward, Vector3 _up, float _aspect_ratio, float _horizontal_angle) : horizontal_angle(_horizontal_angle), aspect_ratio(_aspect_ratio), position(_position), up(~_up), forward(~_forward) { recompute(); }
map::Proxy& map::Proxy::operator+=(const Proxy &rhs) { pm._field[key] += map_get_ro(rhs.pm._field, rhs.key); if (pm.parent.smart_build) recompute(); return *this; }
void CodeBlockHash::dump(PrintStream& out) const { FixedArray<char, 7> buffer = integerToSixCharacterHashString(m_hash); #if !ASSERT_DISABLED CodeBlockHash recompute(buffer.data()); ASSERT(recompute == *this); #endif // !ASSERT_DISABLED out.print(buffer.data()); }
void Envelope::setADSR(int attms, int decms, int susms, int relms, int samplerate) { m_attack = std::max(attms, 0); m_decay = std::max(decms, 0); m_release = std::max(relms, 0); if (m_sampleRate > 0) m_sampleRate = samplerate; int length = (attms + decms + susms + relms) * (m_sampleRate / 1000.f); recompute(length); }
void ThreeBandEqNode::process() { if(werePropertiesModified(this, Lav_THREE_BAND_EQ_LOWBAND_DBGAIN, Lav_THREE_BAND_EQ_LOWBAND_FREQUENCY, Lav_THREE_BAND_EQ_MIDBAND_DBGAIN, Lav_THREE_BAND_EQ_HIGHBAND_DBGAIN, Lav_THREE_BAND_EQ_HIGHBAND_FREQUENCY )) recompute(); for(int channel=0; channel < midband_peaks.getChannelCount(); channel++) scalarMultiplicationKernel(block_size, lowband_gain, input_buffers[channel], output_buffers[channel]); midband_peaks.process(block_size, &output_buffers[0], &output_buffers[0]); highband_shelves.process(block_size, &output_buffers[0], &output_buffers[0]); }
//Proxy of string& operator=(char c); map::Proxy& map::Proxy::operator=(afield::mapped_type::value_type c) { pm._field[key] = c; if (key == 0) { resplit(); } else if (pm.parent.smart_build) { recompute(); } return *this; }
//Proxy of string& operator=(const string& str); map::Proxy& map::Proxy::operator=(const Proxy &rhs) { pm._field[key] = map_get_ro(rhs.pm._field, rhs.key); if (key == 0) { resplit(); } else if (pm.parent.smart_build) { recompute(); } return *this; }
// The event loop itself. void GfEventLoop::operator()() { SDL_Event event; // Event structure // Check for events. while (!_pPrivate->bQuit) { // Loop until there are no events left in the queue. while (!_pPrivate->bQuit && SDL_PollEvent(&event)) { // Process events we care about, and ignore the others. switch(event.type) { case SDL_KEYDOWN: injectKeyboardEvent(event.key.keysym.sym, event.key.keysym.mod, 0, #if SDL_MAJOR_VERSION < 2 event.key.keysym.unicode); #else 0); #endif break; case SDL_KEYUP: injectKeyboardEvent(event.key.keysym.sym, event.key.keysym.mod, 1, #if SDL_MAJOR_VERSION < 2 event.key.keysym.unicode); #else 0); #endif break; case SDL_QUIT: postQuit(); break; default: break; } } if (!_pPrivate->bQuit) { // Recompute if anything to. recompute(); } } GfLogTrace("Quitting event loop.\n"); }
/* Sets the standard deviation * * @param sig Standard deviation * * \warning If (sig <= 0.0), it will be set to 1.0. */ GaussianDistribution& GaussianDistribution::setSigma(double sig) { if( sig <= 0.0 ) { sig = 1.0; } sigma = sig; recompute(); return (*this); } // End of method 'GaussianDistribution::setSigma()'
void Process::GraphicsViewLayerModelPanelProxy::on_zoomChanged(ZoomRatio newzoom) { // TODO refactor this with what's in base element model // mapZoom maps a value between 0 and 1 to the correct zoom. auto mapZoom = [] (double val, double min, double max) { return (max - min) * val + min; }; const auto& duration = m_layer.processModel().duration(); m_zoomRatio = mapZoom(1.0 - newzoom, 2., std::max(4., 2 * duration.msec() / m_width)); recompute(); }
void SquareNode::process() { recompute(); //we incorporate this here, the effect is the same. float phase_offset =getProperty(Lav_SQUARE_PHASE).getFloatValue(); for(int i= 0; i < block_size; i++) { float currentPhase= phase+phase_offset; //we make this wider to further reduce aliasing output_buffers[0][i] = (squareIntegral(currentPhase+8*phase_increment, on_for)-squareIntegral(currentPhase, on_for))/(8*phase_increment); //That's between 0 and 1, so scale. output_buffers[0][i] *= 2; output_buffers[0][i] -= 1; phase += phase_increment; phase -= floorf(phase); } }
// Train the model. void GPCMTransitionReward::optimize() { // If the model has autoregressive dynamics, copy its parameters here. if (model->getDynamics()->getType() == DynamicsTypeGP) gaussianProcess->getKernel()->copySettings( (dynamic_cast<GPCMDynamicsGP*>(model->getDynamics()))->getGaussianProcess()->getKernel()); // Create input and output matrices. setInputOutput(); // Recompute here. recompute(false); // Run optimization. optimization->optimize(this); }
void zoomout( void ) { unsigned *newstack; if( !stackptr ) return; pageEnd = stack[--stackptr]; pageBegin = stack[--stackptr]; recompute(); redraw(); if( stackptr < stacksize/2 ) { if( (newstack = realloc(stack,(stacksize/2)*sizeof(stack[0]))) ) { stack = newstack; stacksize >>= 1; } }
void ThreeBandEqNode::process() { if(werePropertiesModified(this, Lav_THREE_BAND_EQ_LOWBAND_DBGAIN, Lav_THREE_BAND_EQ_LOWBAND_FREQUENCY, Lav_THREE_BAND_EQ_MIDBAND_DBGAIN, Lav_THREE_BAND_EQ_HIGHBAND_DBGAIN, Lav_THREE_BAND_EQ_HIGHBAND_FREQUENCY )) recompute(); for(int channel=0; channel < channels; channel++) { auto &peak= *midband_peaks[channel]; auto &shelf = *highband_shelves[channel]; for(int i= 0; i < block_size; i++) { output_buffers[channel][i] = lowband_gain*peak.tick(shelf.tick(input_buffers[channel][i])); } } }
void GpxTreeWidget::mergeTracks() { assert(_gpx!=0); QList<QTreeWidgetItem*> tracks = selectedItems(); tracks.removeAll(root); if (tracks.size()==0) return; QList<QString> toMerge; toMerge.push_back(tracks[0]->text(1)); for (int i=1; i<tracks.size(); ++i) { toMerge.push_back(tracks[i]->text(1)); delete tracks[i]; } _gpx->mergeTracksByName(toMerge); recompute(); emit gpxChanged(); }
void GpxTreeWidget::removeTracks() { assert(_gpx!=0); QList<QTreeWidgetItem*> tracks = selectedItems(); tracks.removeAll(root); if (_gpx->segmentCount()==1) return; if (tracks.size()==0) return; QList<QString> toRemove; for (int i=0; i<tracks.size(); ++i) { toRemove.push_back(tracks[i]->text(1)); delete tracks[i]; } _gpx->removeTracksByName(toRemove); recompute(); emit gpxChanged(); }
void CodeBlockHash::dump(PrintStream& out) const { ASSERT(strlen(TABLE) == 62); char buffer[7]; unsigned accumulator = m_hash; for (unsigned i = 6; i--;) { buffer[i] = TABLE[accumulator % 62]; accumulator /= 62; } buffer[6] = 0; #if !ASSERT_DISABLED CodeBlockHash recompute(buffer); ASSERT(recompute == *this); #endif // !ASSERT_DISABLED out.print(buffer); }
void GpxTreeWidget::buildTree() { clear(); removeAction->setEnabled(false); mergeAction->setEnabled(false); splitAction->setEnabled(false); if (_gpx==0) return; root = new QTreeWidgetItem(this); for (int i=0; i<_gpx->segmentCount(); ++i) { new QTreeWidgetItem(root); } expandItem(root); recompute(); removeAction->setEnabled(true); mergeAction->setEnabled(true); splitAction->setEnabled(true); }
// Load model from specified MAT file reader. void GPCMTransitionReward::load( GPCMMatReader *reader ) { // Read difference setting. MatrixXd diffMat = reader->getVariable("diff"); if (diffMat(0,0) == 0.0) bDifference = false; else bDifference = true; // Read velocity setting. MatrixXd velMat = reader->getVariable("usevel"); if (velMat(0,0) == 0.0) bUseVelocity = false; else bUseVelocity = true; // Read gaussian process. gaussianProcess->load(reader); recompute(false); // Must recompute ourselves, since model doesn't recompute us. }
Component::Component( ::Spline::ProcessModel& element, const ::Execution::Context& ctx, const Id<score::Component>& id, QObject* parent) : ::Execution:: ProcessComponent_T<Spline::ProcessModel, ossia::node_process>{ element, ctx, id, "Executor::SplineComponent", parent} { auto node = std::make_shared<spline>(); this->node = node; m_ossia_process = std::make_shared<ossia::node_process>(node); con(element, &Spline::ProcessModel::splineChanged, this, [this] { this->recompute(); }); recompute(); }