コード例 #1
0
ファイル: average.cpp プロジェクト: hasagar/gromacs
void
AnalysisDataAverageModule::dataStarted(AbstractAnalysisData *data)
{
    int nrows = data->columnCount();
    setRowCount(nrows);
    allocateValues();
    nsamples_.resize(nrows);
}
コード例 #2
0
void
AnalysisDataAverageModule::dataFinished()
{
    allocateValues();
    for (int i = 0; i < columnCount(); ++i)
    {
        impl_->averagers_[i].finish();
        int j = 0;
        for (; j < impl_->averagers_[i].columnCount(); ++j)
        {
            value(j, i).setValue(impl_->averagers_[i].average(j),
                                 std::sqrt(impl_->averagers_[i].variance(j)));
        }
        for (; j < rowCount(); ++j)
        {
            value(j, i).setValue(0.0, 0.0, false);
        }
    }
    valuesReady();
}
コード例 #3
0
ファイル: lifetime.cpp プロジェクト: FoldingAtHome/gromacs
void
AnalysisDataLifetimeModule::dataFinished()
{
    // Need to process the elements present in the last frame explicitly.
    for (size_t i = 0; i < impl_->currentLifetimes_.size(); ++i)
    {
        for (size_t j = 0; j < impl_->currentLifetimes_[i].size(); ++j)
        {
            impl_->addLifetime(i, impl_->currentLifetimes_[i][j]);
        }
    }
    impl_->currentLifetimes_.clear();

    if (impl_->bCumulative_)
    {
        // Sum up subintervals of longer intervals into the histograms
        // if explicitly requested.
        std::vector<Impl::LifetimeHistogram>::iterator histogram;
        for (histogram  = impl_->lifetimeHistograms_.begin();
             histogram != impl_->lifetimeHistograms_.end();
             ++histogram)
        {
            Impl::LifetimeHistogram::iterator shorter, longer;
            for (shorter = histogram->begin(); shorter != histogram->end(); ++shorter)
            {
                int subIntervalCount = 2;
                for (longer = shorter + 1; longer != histogram->end();
                     ++longer, ++subIntervalCount)
                {
                    // Interval of length shorter contains (longer - shorter + 1)
                    // continuous intervals of length longer.
                    *shorter += subIntervalCount * (*longer);
                }
            }
        }
    }

    // X spacing is determined by averaging from the first and last frame
    // instead of first two frames to avoid rounding issues.
    const real spacing =
        (impl_->frameCount_ > 1)
        ? (impl_->lastx_ - impl_->firstx_) / (impl_->frameCount_ - 1)
        : 0.0;
    setXAxis(0.0, spacing);

    // Determine output dimensionality to cover all the histograms.
    setColumnCount(impl_->lifetimeHistograms_.size());
    std::vector<Impl::LifetimeHistogram>::const_iterator histogram;
    size_t maxLifetime = 1;
    for (histogram  = impl_->lifetimeHistograms_.begin();
         histogram != impl_->lifetimeHistograms_.end();
         ++histogram)
    {
        maxLifetime = std::max(maxLifetime, histogram->size());
    }
    setRowCount(maxLifetime);

    // Fill up the output data from the histograms.
    allocateValues();
    int column = 0;
    for (histogram  = impl_->lifetimeHistograms_.begin();
         histogram != impl_->lifetimeHistograms_.end();
         ++histogram, ++column)
    {
        int row = 0;
        Impl::LifetimeHistogram::const_iterator i;
        for (i = histogram->begin(); i != histogram->end(); ++i, ++row)
        {
            // Normalize by the number of frames, taking into account the
            // length of the interval (interval of length N cannot start in
            // N-1 last frames).  row is always smaller than frameCount_
            // because of the histograms have at most frameCount_ entries.
            const real normalized = *i / static_cast<real>(impl_->frameCount_ - row);
            value(row, column).setValue(normalized);
        }
        // Pad the rest of the histogram with zeros to match the longest
        // histogram.
        for (; row < rowCount(); ++row)
        {
            value(row, column).setValue(0.0);
        }
    }
    impl_->lifetimeHistograms_.clear();
    valuesReady();
}