예제 #1
0
void DataLog::Log(unsigned int dimension, const float* vals, unsigned int samples )
{
    if(!block0) {
        // Create first block
        block0 = new DataLogBlock(dimension, block_samples_alloc, 0);
        blockn = block0;
    }

    if(record_stats) {
        while(stats.size() < dimension) {
            stats.push_back( DimensionStats() );
        }
        for(unsigned int d=0; d<dimension; ++d) {
            DimensionStats& ds = stats[d];
            for(unsigned int s=0; s<samples; ++s) {
                const float v = vals[s*dimension+d];
                ds.isMonotonic = ds.isMonotonic && (v >= ds.max);
                ds.sum += v;
                ds.sum_sq += v*v;
                ds.min = std::min(ds.min, v);
                ds.max = std::max(ds.max, v);
            }
        }
    }

    blockn->AddSamples(samples,dimension,vals);

    // Update pointer to most recent block.
    while(blockn->NextBlock()) {
        blockn = blockn->NextBlock();
    }
}
예제 #2
0
void DataLog::Log(size_t dimension, const float* vals, unsigned int samples )
{
    if(!block0) {
        // Create first block
        block0 = std::unique_ptr<DataLogBlock>(new DataLogBlock(dimension, block_samples_alloc, 0));
        blockn = block0.get();
    }

    if(record_stats) {
        while(stats.size() < dimension) {
            stats.push_back( DimensionStats() );
        }
        for(unsigned int d=0; d<dimension; ++d) {
            DimensionStats& ds = stats[d];
            for(unsigned int s=0; s<samples; ++s) {
                ds.Add(vals[s*dimension+d]);
            }
        }
    }

    blockn->AddSamples(samples,dimension,vals);

    // Update pointer to most recent block.
    while(blockn->NextBlock()) {
        blockn = blockn->NextBlock();
    }
}