summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java')
-rw-r--r--src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java b/src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java
index 9829eaf8..1d816e2d 100644
--- a/src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java
+++ b/src/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/FloatDynamicHistogram.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities.datastructures.histogram;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2013
+ Copyright (C) 2014
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -162,10 +162,12 @@ public class FloatDynamicHistogram extends FloatStaticHistogram {
assert (levels > 0) : "No resampling required?!? sizereq=" + sizereq + " destsize=" + destsize + " array=" + data.length;
final int step = 1 << levels;
+ // We want to map [i ... i+step[ -> (i+off)/step
+ // Fix point: i = (i+off)/step; i*(step-1)=off; i=off/(step-1)
final int fixpoint = off / (step - 1);
{
// Start positions for in-place bottom-up downsampling.
- int oup = fixpoint;
+ int oup = (fixpoint >= 0) ? fixpoint : 0;
int inp = (oup << levels) - off;
assert (-step < inp && inp <= oup && oup < inp + step) : (inp + " -> " + oup + " s=" + step + " o=" + off + " l=" + levels);
for (; inp < size; inp += step, oup++) {
@@ -177,9 +179,9 @@ public class FloatDynamicHistogram extends FloatStaticHistogram {
data[oup] = 0;
}
}
- if (off > 0) {
+ if(off >= step) {
// Start positions for in-place downsampling top-down:
- int oup = fixpoint - 1;
+ int oup = (fixpoint - 1 < size) ? fixpoint - 1 : size - 1;
int inp = (oup << levels) - off;
assert (oup > inp) : (inp + " -> " + oup + " s=" + step + " o=" + off + " l=" + levels);
for (; inp > -step; inp -= step, oup--) {