void ZoomableGerberView::resizeEvent ( QResizeEvent * event ) { QPointF p((double)event->oldSize().width()/2.0L+(double)horizontalScrollBar()->value(), (double)event->oldSize().height()/2.0L+(double)verticalScrollBar()->value()); double xp = ensure0to1(p.x()/(double)mView->width()); double yp = ensure0to1(p.y()/(double)mView->height()); updateViewSize(); horizontalScrollBar()->setValue(qRound64((double)mView->width()*xp) - (viewport()->width()+1)/2); verticalScrollBar()->setValue(qRound64((double)mView->height()*yp) - (viewport()->height()+1)/2); QScrollArea::resizeEvent(event); }
void TemplatePositionDockWidget::valueChanged() { // Mark original template area as dirty temp->setTemplateAreaDirty(); // Transform relevant parts of pass points into template coords for (int i = 0; i < temp->getNumPassPoints(); ++i) { PassPoint* point = temp->getPassPoint(i); if (temp->isAdjustmentApplied()) { point->dest_coords = temp->mapToTemplate(point->dest_coords); point->calculated_coords = temp->mapToTemplate(point->calculated_coords); } else point->src_coords = temp->mapToTemplate(point->src_coords); } // Change transformation QWidget* widget = (QWidget*)sender(); if (widget == x_edit) temp->setTemplateX(qRound64(1000 * x_edit->text().toDouble())); else if (widget == y_edit) temp->setTemplateY(qRound64(-1000 * y_edit->text().toDouble())); else if (widget == scale_x_edit) temp->setTemplateScaleX(scale_x_edit->text().toDouble()); else if (widget == scale_y_edit) temp->setTemplateScaleY(scale_y_edit->text().toDouble()); else if (widget == rotation_edit) temp->setTemplateRotation(rotation_edit->text().toDouble() * M_PI / 180.0); // Transform relevant parts of pass points back to map coords for (int i = 0; i < temp->getNumPassPoints(); ++i) { PassPoint* point = temp->getPassPoint(i); if (temp->isAdjustmentApplied()) { point->dest_coords = temp->templateToMap(point->dest_coords); point->calculated_coords = temp->templateToMap(point->calculated_coords); } else point->src_coords = temp->templateToMap(point->src_coords); } // Mark new template area as dirty temp->setTemplateAreaDirty(); // Tell others about changes controller->getMap()->setTemplatesDirty(); react_to_changes = false; controller->getMap()->emitTemplateChanged(temp); react_to_changes = true; }
qint64 ClipRenderer::getLengthMs() const { if ( m_selectedClip ) return ( qRound64( (qreal)( m_end - m_begin ) / m_selectedClip->getMedia()->fps() * 1000.0 ) ); return 0; }
qint64 ClipRenderer::getCurrentFrame() const { if ( m_clipLoaded == false || m_isRendering == false || m_selectedClip == NULL ) return 0; return qRound64( (qreal)m_mediaPlayer->getTime() / 1000 * (qreal)m_selectedClip->getMedia()->fps() ); }
void MapView::finishPanning(QPoint offset) { setPanOffset({0,0}); try { auto rotated_offset = MapCoord::fromNative64(qRound64(-pixelToLength(offset.x())), qRound64(-pixelToLength(offset.y())) ); auto rotated_offset_f = MapCoordF{ rotated_offset }; rotated_offset_f.rotate(-rotation); auto move = MapCoord{ rotated_offset_f }; setCenter(center() + move); } catch (std::range_error) { // Do nothing } }
void Clip::computeLength() { float fps = m_media->source()->fps(); if ( fps < 0.1f ) fps = Clip::DefaultFPS; m_nbFrames = m_end - m_begin; m_lengthSeconds = qRound64( (float)m_nbFrames / fps ); }
KREPORT_EXPORT uint qHash(const KReportElement &element, uint seed) { return qHash(element.name(), seed) ^ qHash(element.z(), seed) ^ qHash(element.rect().x(), seed) ^ qHash(element.foregroundColor().name(), seed) ^ qHash(element.backgroundColor().name(), seed) ^ qHash(qRound64(element.backgroundOpacity() * 1000.0), seed); }
/*------------------------------------------------------------------------------ | OMX_MediaProcessor::seek +-----------------------------------------------------------------------------*/ bool OMX_MediaProcessor::seek(qint64 position) { LOG_VERBOSE(LOG_TAG, "Seek %lldms.", position); // Get current position in ms. qint64 current = m_av_clock->OMXMediaTime(false)*1E-3; qint64 currentS = qRound64(current/1000.0d); // position is in ms. Translate to seconds. int seconds = qRound64(position/1000.0d); int increment = seconds - currentS; if (!increment) return true; m_incr = increment; return true; }
void ClipRenderer::previewWidgetCursorChanged( qint64 newFrame ) { if ( m_isRendering == true ) { newFrame += m_begin; qint64 nbSeconds = qRound64( (qreal)newFrame / m_selectedClip->getMedia()->fps() ); m_mediaPlayer->setTime( nbSeconds * 1000 ); } }
QString Tools::doubleToStr(const qreal value, int precision) { uint multiplier = 1; while (precision--) multiplier *= 10; qreal tmpValue = qRound64(qAbs(value) * multiplier); if (qFuzzyCompare(tmpValue, 0.0)) return "0"; qreal newValue = tmpValue/multiplier; int decimalPointPos = numbersBeforePoint(newValue); int zeroAfterPoint = zerosAfterPoint(newValue); qulonglong l = tmpValue; ushort buff[65]; ushort *p = buff + 65; static ushort m_zero = QChar('0').unicode(); int pos = 0; while (l != 0) { pos++; l /= 10; } l = tmpValue; bool isTrailingZero = true; int charCount = 0; while (l != 0) { int c = l % 10; if (c != 0) isTrailingZero = false; if (!isTrailingZero) { *(--p) = m_zero + c; charCount++; } pos--; if (pos == decimalPointPos && decimalPointPos != 0) { if (charCount > 0) *(--p) = QChar('.').unicode(); isTrailingZero = false; } l /= 10; } while (zeroAfterPoint--) *(--p) = m_zero; if (decimalPointPos == 0) { *(--p) = QChar('.').unicode(); static const bool useStartingZero = !Keys::get().flag(Key::RemoveUnneededSymbols); if (useStartingZero) *(--p) = m_zero; } if (value < 0) *(--p) = QChar('-').unicode(); return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff)); }
void ClipRenderer::__timeChanged( qint64 time ) { float fps = (qreal)m_mediaPlayer->getFps(); if ( fps < 0.1f ) fps = m_selectedClip->getMedia()->fps(); qint64 f = qRound64( (qreal)time / 1000.0 * fps ); if ( f >= m_end ) { __endReached(); return ; } f = f - m_begin; emit frameChanged( f, Vlmc::Renderer ); }
void ParamItem::update() { double min = getDoubleField(1); double current = getDoubleField(2); double max = getDoubleField(3); Q_ASSERT(min <= max); Q_ASSERT(min <= current && current <= max); ui->paramName->setText(getStringField(0)); ui->MinLabel->setText(QString::number(min)); ui->CurrentValueEdit->setText(QString::number(current)); ui->MaxLabel->setText(QString::number(max)); int sliderCurrent = qRound64((current - min) / (max - min) * maxValue); Q_ASSERT(0 <= sliderCurrent && sliderCurrent <= maxValue); ui->paramSlider->setValue(sliderCurrent); }
void ParamItem::currentEditEditingFinished() { double min = getDoubleField(1); double current = ui->CurrentValueEdit->text().toDouble(); double max = getDoubleField(3); if(current < min){ current = min; } if(current > max){ current = max; } // Snap it to slider resolution. int sliderCurrent = qRound64((current - min) / (max - min) * maxValue); current = double(sliderCurrent)/maxValue*(max - min) + min; setField(2, current); update(); }
bool QgsField::convertCompatible( QVariant& v ) const { if ( v.isNull() ) { v.convert( mType ); return true; } if ( !v.convert( mType ) ) { return false; } if ( mType == QVariant::Double && mPrecision > 0 ) { v = qRound64( v.toDouble() * qPow( 10, mPrecision ) ) / qPow( 10, mPrecision ); return true; } return true; }
qint64 WorkflowRenderer::length() const { return qRound64( (qreal)getLengthMs() / 1000.0 * (qreal)getFps() ); }
bool PassPointList::estimateSimilarityTransformation(TemplateTransform* transform) { auto num_pass_points = int(size()); if (num_pass_points == 1) { PassPoint* point = &at(0); MapCoordF offset = point->dest_coords - point->src_coords; transform->template_x += qRound64(1000 * offset.x()); transform->template_y += qRound64(1000 * offset.y()); point->calculated_coords = point->dest_coords; point->error = 0; } else if (num_pass_points >= 2) { // Create linear equation system and solve using the pseuo inverse // Derivation: // (Attention: not by a mathematician. Please correct any errors.) // // Start by stating that the original coordinates (x, y) multiplied // with the transformation matrix should give the desired coordinates (X, Y): // // | a b c| |x| |X| // | d e f| * |y| = |Y| // |1| // // The parametrization of the transformation matrix should be simplified because // we want to have isotropic scaling. // With s = scaling, r = rotation and (x, y) = offset, it looks like this: // // | s*cos(r) s*sin(r) x| | a b c| // |-s*sin(r) s*cos(r) y| =: |-b a d| // // With this, reordering the matrices to have the unknowns // in the second matrix results in: // // | x y 1 0| |a| |X| // | y -x 0 1| * |b| = |Y| // |c| // |d| // // For every pass point, two rows like this result. The complete, stacked // equation system is then "solved" as good as possible using the // pseudo inverse. Finally, s, r, x and y are recovered from a, b, c and d. Matrix mat(2*num_pass_points, 4); Matrix values(2*num_pass_points, 1); for (int i = 0; i < num_pass_points; ++i) { PassPoint* point = &at(i); mat.set(2*i, 0, point->src_coords.x()); mat.set(2*i, 1, point->src_coords.y()); mat.set(2*i, 2, 1); mat.set(2*i, 3, 0); mat.set(2*i+1, 0, point->src_coords.y()); mat.set(2*i+1, 1, -point->src_coords.x()); mat.set(2*i+1, 2, 0); mat.set(2*i+1, 3, 1); values.set(2*i, 0, point->dest_coords.x()); values.set(2*i+1, 0, point->dest_coords.y()); } Matrix transposed; mat.transpose(transposed); Matrix mat_temp, mat_temp2, pseudo_inverse; transposed.multiply(mat, mat_temp); if (!mat_temp.invert(mat_temp2)) return false; mat_temp2.multiply(transposed, pseudo_inverse); // Calculate transformation parameters Matrix output; pseudo_inverse.multiply(values, output); double move_x = output.get(2, 0); double move_y = output.get(3, 0); double rotation = qAtan2((-1) * output.get(1, 0), output.get(0, 0)); double scale = output.get(0, 0) / qCos(rotation); // Calculate transformation matrix double cosr = cos(rotation); double sinr = sin(rotation); Matrix trans_change(3, 3); trans_change.set(0, 0, scale * cosr); trans_change.set(0, 1, scale * (-sinr)); trans_change.set(1, 0, scale * sinr); trans_change.set(1, 1, scale * cosr); trans_change.set(0, 2, move_x); trans_change.set(1, 2, move_y); // Transform the original transformation parameters to get the new transformation transform->template_scale_x *= scale; transform->template_scale_y *= scale; transform->template_rotation -= rotation; auto temp_x = qRound(1000.0 * (trans_change.get(0, 0) * (transform->template_x/1000.0) + trans_change.get(0, 1) * (transform->template_y/1000.0) + trans_change.get(0, 2))); transform->template_y = qRound(1000.0 * (trans_change.get(1, 0) * (transform->template_x/1000.0) + trans_change.get(1, 1) * (transform->template_y/1000.0) + trans_change.get(1, 2))); transform->template_x = temp_x; // Transform the pass points and calculate error for (auto& point : *this) { point.calculated_coords = MapCoordF(trans_change.get(0, 0) * point.src_coords.x() + trans_change.get(0, 1) * point.src_coords.y() + trans_change.get(0, 2), trans_change.get(1, 0) * point.src_coords.x() + trans_change.get(1, 1) * point.src_coords.y() + trans_change.get(1, 2)); point.error = point.calculated_coords.distanceTo(point.dest_coords); } } return true; }
qint64 QBenchmarkTickMeasurer::checkpoint() { CycleCounterTicks now = getticks(); return qRound64(elapsed(now, startTicks)); }
static QwtScaleDiv qwtDivideToSeconds( const QDateTime &minDate, const QDateTime &maxDate, double stepSize, int maxMinSteps, QwtDate::IntervalType intervalType ) { // calculate the min step size double minStepSize = 0; if ( maxMinSteps > 1 ) { minStepSize = qwtDivideMajorStep( stepSize, maxMinSteps, intervalType ); } bool daylightSaving = false; if ( minDate.timeSpec() == Qt::LocalTime ) { daylightSaving = intervalType > QwtDate::Hour; if ( intervalType == QwtDate::Hour ) { daylightSaving = stepSize > 1; } } const double s = qwtMsecsForType( intervalType ) / 1000; const int secondsMajor = static_cast<int>( stepSize * s ); const double secondsMinor = minStepSize * s; // UTC excludes daylight savings. So from the difference // of a date and its UTC counterpart we can find out // the daylight saving hours const double utcOffset = QwtDate::utcOffset( minDate ); double dstOff = 0; QList<double> majorTicks; QList<double> mediumTicks; QList<double> minorTicks; for ( QDateTime dt = minDate; dt <= maxDate; dt = dt.addSecs( secondsMajor ) ) { if ( !dt.isValid() ) break; double majorValue = QwtDate::toDouble( dt ); if ( daylightSaving ) { const double offset = utcOffset - QwtDate::utcOffset( dt ); majorValue += offset * 1000.0; if ( offset > dstOff ) { // we add some minor ticks for the DST hour, // otherwise the ticks will be unaligned: 0, 2, 3, 5 ... minorTicks += qwtDstTicks( dt, secondsMajor, qRound( secondsMinor ) ); } dstOff = offset; } if ( majorTicks.isEmpty() || majorTicks.last() != majorValue ) majorTicks += majorValue; if ( secondsMinor > 0.0 ) { const int numMinorSteps = qFloor( secondsMajor / secondsMinor ); for ( int i = 1; i < numMinorSteps; i++ ) { const QDateTime mt = dt.addMSecs( qRound64( i * secondsMinor * 1000 ) ); double minorValue = QwtDate::toDouble( mt ); if ( daylightSaving ) { const double offset = utcOffset - QwtDate::utcOffset( mt ); minorValue += offset * 1000.0; } if ( minorTicks.isEmpty() || minorTicks.last() != minorValue ) { const bool isMedium = ( numMinorSteps % 2 == 0 ) && ( i != 1 ) && ( i == numMinorSteps / 2 ); if ( isMedium ) mediumTicks += minorValue; else minorTicks += minorValue; } } } } QwtScaleDiv scaleDiv; scaleDiv.setInterval( QwtDate::toDouble( minDate ), QwtDate::toDouble( maxDate ) ); scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks ); scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks ); scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks ); return scaleDiv; }
QDateTime Double2DateTimeFilter::dateTimeAt(int row) const { if (!d_inputs.value(0)) return QDateTime(); double input_value = d_inputs.value(0)->valueAt(row); QDateTime result; // This gets a little messy, since QDate can't represent the reference date of JDN. // Thus, we manually interpret invalid dates as JDN reference. switch (m_unit_interval) { case Year: if (m_date_time_0.isValid()) result = m_date_time_0.addYears(int(floor(input_value))); else { result.setDate(QDate(int(floor(input_value))+4713, 1, 1)); result.setTime(QTime(12,0,0,0)); } return result.addMSecs(qRound64((input_value - int(floor(input_value))) * result.date().daysInYear() * 86400000.0)); case Month: if (m_date_time_0.isValid()) result = m_date_time_0.addMonths(int(floor(input_value))); else { result.setDate(QDate(int(floor(input_value))/12+4713, int(floor(input_value))%12+1, 1)); result.setTime(QTime(12,0,0,0)); } return result.addMSecs(qRound64((input_value - int(floor(input_value))) * result.date().daysInMonth() * 86400000.0)); case Day: if (m_date_time_0.isValid()) result = m_date_time_0.addDays(int(floor(input_value))); else { result.setDate(QDate::fromJulianDay(int(floor(input_value)))); result.setTime(QTime(12,0,0,0)); } return result.addMSecs(qRound64((input_value - int(floor(input_value))) * 86400000.0)); case Hour: if (m_date_time_0.isValid()) return m_date_time_0.addMSecs(qRound64(input_value * 3600000.0)); else { result.setDate(QDate::fromJulianDay(int(floor(input_value)) / 24)); result.setTime(QTime(12,0,0,0)); result.addSecs((int(floor(input_value)) % 24) * 3600); return result.addMSecs(qRound64((input_value - int(floor(input_value))) * 3600000.0)); } case Minute: if (m_date_time_0.isValid()) return m_date_time_0.addMSecs(qRound64(input_value * 60000.0)); else { result.setDate(QDate::fromJulianDay(int(floor(input_value)) / (24 * 60))); result.setTime(QTime(12,0,0,0)); result.addSecs((int(floor(input_value)) % (24 * 60)) * 60); return result.addMSecs(qRound64((input_value - int(floor(input_value))) * 60000.0)); } case Second: if (m_date_time_0.isValid()) return m_date_time_0.addMSecs(qRound64(input_value * 1000.0)); else { result.setDate(QDate::fromJulianDay(int(floor(input_value)) / (24 * 60 * 60))); result.setTime(QTime(12,0,0,0)); result.addSecs(int(floor(input_value)) % (24 * 60 * 60)); return result.addMSecs(qRound64((input_value - int(floor(input_value))) * 1000.0)); } case Millisecond: if (m_date_time_0.isValid()) return m_date_time_0.addMSecs(qRound64(input_value)); else { result.setDate(QDate::fromJulianDay(int(floor(input_value)) / (24 * 60 * 60))); result.setTime(QTime(12,0,0,0)); result.addSecs(int(floor(input_value)) % (24 * 60 * 60)); return result.addMSecs(qRound64((input_value - int(floor(input_value))) * 1000.0)); } } }
void US_MPI_Analysis::dmga_master_loop( void ) { static const double DIGIT_FIT = 1.0e+4; static const int min_generation = 10; static const int _KS_BASE_ = 6; static const int _KS_STEP_ = 3; QString dbgtext = parameters[ "debug_text" ]; QString s_ksbase = par_key_value( dbgtext, "ksame_base" ); QString s_ksstep = par_key_value( dbgtext, "ksame_step" ); int ks_base = s_ksbase.isEmpty() ? _KS_BASE_ : s_ksbase.toInt(); int ks_step = s_ksstep.isEmpty() ? _KS_STEP_ : s_ksstep.toInt(); ks_base = qMax( 2, ks_base ); ks_step = qMax( 1, ks_step ); // static const int max_same_count = my_workers * 5; int max_same_count = ( ks_base + ( nfloatc / ks_step ) * ks_step ) * my_workers; int avg_generation = 0; bool early_termination = false; int fitness_same_count = 0; double best_overall_fitness = LARGE; int tag; int workers = my_workers; DbgLv(1) << "dmga_master start loop: gcores_count fitsize" << gcores_count << best_fitness.size() << "best_overall" << best_overall_fitness; DbgLv(0) << "dmga_master start loop: nfloatc max_same_count" << nfloatc << max_same_count << "ks_base ks_step" << ks_base << ks_step; // Reset best fitness for each worker for ( int i = 0; i < gcores_count; i++ ) { best_fitness[ i ].fitness = LARGE; best_fitness[ i ].index = i; } QList < DGene > emigres; // Holds genes passed as emmigrants QVector< int > v_generations( gcores_count, 0 ); int sum = 0; int avg = 0; long rsstotal = 0L; double fit_power = 5; double fit_digit = 1.0e4; double fitness_round = 1.0e5; while ( workers > 0 ) { MPI_GA_MSG msg; MPI_Status status; int worker; MPI_Recv( &msg, // Get a message MPI #1 sizeof( msg ), MPI_BYTE, MPI_ANY_SOURCE, MPI_ANY_TAG, my_communicator, &status ); worker = status.MPI_SOURCE; max_rss(); switch ( status.MPI_TAG ) { case GENERATION: v_generations[ worker ] = msg.generation; sum = 0; for ( int i = 1; i <= my_workers; i++ ) sum += v_generations[ i ]; avg = qRound( (double)sum / (double)my_workers ) + 1; if ( avg > avg_generation ) { avg_generation = avg; int mc_iter = mgroup_count < 2 ? ( mc_iteration + 1 ) : mc_iteration; QString progress = "Avg. Generation: " + QString::number( avg_generation ); if ( data_sets.size() > 1 ) { if ( datasets_to_process == 1 ) progress += "; Dataset: " + QString::number( current_dataset + 1 ) + " of " + QString::number( count_datasets ); else progress += "; Datasets: " + QString::number( datasets_to_process ); } progress += "; MonteCarlo: " + QString::number( mc_iter ); if ( best_overall_fitness != LARGE && best_overall_fitness > 0.0 ) progress += "; RMSD: " + QString::number( sqrt( best_overall_fitness ) ); send_udp( progress ); } // Get the best gene for the current generation from the worker DbgLv(1) << " MAST: work" << worker << "Recv#2 nfloatc" << nfloatc; MPI_Recv( dgmarker.data(), // MPI #2 nfloatc, MPI_DOUBLE, worker, GENE, my_communicator, MPI_STATUS_IGNORE ); DbgLv(1) << " MAST: work" << worker << " dgm size" << dgmarker.size() << "bestdg size" << best_dgenes.size(); dgene_from_marker( dgmarker, dgene ); best_dgenes[ worker ] = dgene; max_rss(); // Compute a current-deme best fitness value that is rounded // to 4 significant digits fit_power = (double)qRound( log10( msg.fitness ) ); fit_digit = pow( 10.0, -fit_power ) * DIGIT_FIT; fitness_round = (double)qRound64( msg.fitness * fit_digit ) / fit_digit; DbgLv(1) << " MAST: work" << worker << "fit msg,round,bestw,besto" << msg.fitness << fitness_round << best_fitness[worker].fitness << best_overall_fitness; // Set deme's best fitness if ( fitness_round < best_fitness[ worker ].fitness ) best_fitness[ worker ].fitness = fitness_round; DbgLv(1) << "master: worker/fitness/best gene" << worker << msg.fitness << dgene_key( best_dgenes[worker] ); if ( ! early_termination ) { // Handle normal pre-early-termination updates if ( avg_generation == 1 && mc_iterations == 1 && best_overall_fitness == LARGE ) { // Report first best-fit RMSD DbgLv(0) << "First Best Fit RMSD" << sqrt( fitness_round ); } DbgLv(1) << " MAST: work" << worker << "fit besto,round" << best_overall_fitness << fitness_round << "fit_power fit_digit msgfit" << fit_power << fit_digit << msg.fitness; if ( fitness_round < best_overall_fitness ) { // Update over-all best fitness value (rounded) best_overall_fitness = fitness_round; fitness_same_count = 0; } else { // Bump the count of consecutive same best overall fitness fitness_same_count++; } if ( fitness_same_count > max_same_count && avg_generation > min_generation ) { // Mark early termination at threshold same-fitness count DbgLv(0) << "Fitness has not improved in the last" << fitness_same_count << "deme results - Early Termination."; early_termination = true; } } //DbgLv(1) << " best_overall_fitness" << best_overall_fitness // << "fitness_same_count" << fitness_same_count // << " early_term?" << early_termination; if((worker%10)==1) DbgLv(1) << worker << ": best_overall_fitness" << best_overall_fitness << "fitness_same_count" << fitness_same_count << " early_term?" << early_termination; // Tell the worker to either stop or continue tag = early_termination ? FINISHED : GENERATION; DbgLv(1) << "dgmast: Send#3 tag" << tag << "( FINISHED,GENERATION" << FINISHED << GENERATION << " )"; MPI_Send( &msg, // MPI #3 0, // Only interested in the tag MPI_BYTE, worker, tag, my_communicator ); break; case FINISHED: DbgLv(1) << "dgmast: Recv FINISH msg.size rsstotal" << msg.size << rsstotal; rsstotal += (long)msg.size; workers--; break; case EMMIGRATE: { // First get a set of genes as a concatenated marker vector. int gene_count = msg.size; int doubles_count = gene_count * nfloatc; QVector< double > emmigrants( doubles_count ) ; DbgLv(1) << "dgmast: Recv#4 EMMIG: gene_count doubles_count" << gene_count << doubles_count; MPI_Recv( emmigrants.data(), // MPI #4 doubles_count, MPI_DOUBLE, worker, EMMIGRATE, my_communicator, MPI_STATUS_IGNORE ); // Add the genes to the emmigres list int emgx = emigres.size(); DbgLv(1) << "dgmast: Recv#4 EMMIG: emgx" << emgx; marker_to_dgenes( emmigrants, emigres, emgx, gene_count ); DbgLv(1) << "dgmast: Recv#4 EMMIG: emigres size" << emigres.size(); //*DEBUG* //if(emigres[0][0].s<0.0) // DbgLv(0) << "MAST: **GENE s" << emigres[0][0].s << " Emigrant"; //*DEBUG* max_rss(); // Don't send any back if the pool is too small if ( emigres.size() < gene_count * 5 ) doubles_count = 0; // Get immigrants from emmigres QVector< double > immigrants; dgmarker.resize( nfloatc ); if ( doubles_count > 0 ) { // Prepare a marker vector from the emmigrant list for ( int ii = 0; ii < gene_count; ii++ ) { dgene = emigres.takeAt( u_random( emigres.size() ) ); marker_from_dgene( dgmarker, dgene ); immigrants += dgmarker; } } else { DbgLv(1) << "dgmast: Send#5 IMMIG: count==0 migr data" << immigrants.data(); immigrants.resize( 1 ); } DbgLv(1) << "dgmast: Send#5 IMMIG: immigrants size" << immigrants.size() << "doubles_count" << doubles_count << "migr data" << immigrants.data(); MPI_Send( immigrants.data(), // MPI #5 doubles_count, MPI_DOUBLE, worker, IMMIGRATE, my_communicator ); DbgLv(1) << "dgmast: Send#5 IMMIG: complete"; //*DEBUG* //if(immigrants[0].s<0.0) // DbgLv(0) << "MAST: **GENE s" << immigrants[0].s << " Immigrant-to-send"; //*DEBUG* break; } } max_rss(); } DbgLv(1) << "Master maxrss" << maxrss << " worker total rss" << rsstotal << "rank" << my_rank; maxrss += rsstotal; if ( early_termination ) { // Report when we have reached early termination of generations int mc_iter = mgroup_count < 2 ? ( mc_iteration + 1 ) : mc_iteration; DbgLv(0) << "Early termination at average generation" << avg << ", MC" << mc_iter; } }
dfs::core::DTimeStamp dfs::core:: secondsToTimeStampDuration(double secs) { return qRound64(secs * 1000); }
qint64 AbstractGraphicsItem::startPos() const { return qRound64( QGraphicsItem::pos().x() ); }