Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b005d923d273
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: db5bbeee568c
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Mar 14, 2021

  1. Copy the full SHA
    db5bbee View commit details
Showing with 6 additions and 4 deletions.
  1. +6 −4 scopehal/Filter.cpp
10 changes: 6 additions & 4 deletions scopehal/Filter.cpp
Original file line number Diff line number Diff line change
@@ -960,16 +960,18 @@ vector<size_t> Filter::MakeHistogram(AnalogWaveform* cap, float low, float high,
for(size_t i=0; i<bins; i++)
ret.push_back(0);

//Early out if we have zero span
if(bins == 0)
return ret;

float delta = high-low;

for(float v : cap->m_samples)
{
float fbin = (v-low) / delta;
size_t bin = floor(fbin * bins);
if(fbin < 0)
bin = 0;
if(bin >= bins)
bin = bin-1;
bin = max(bin, (size_t)0);
bin = min(bin, bins-1);
ret[bin] ++;
}