Package de.lmu.ifi.dbs.elki.utilities.pairs

Examples of de.lmu.ifi.dbs.elki.utilities.pairs.IntIntPair


   */
  public static FlexiHistogram<IntIntPair, IntIntPair> IntSumIntSumHistogram(int bins) {
    return new FlexiHistogram<IntIntPair, IntIntPair>(bins, new Adapter<IntIntPair, IntIntPair>() {
      @Override
      public IntIntPair make() {
        return new IntIntPair(0, 0);
      }

      @Override
      public IntIntPair cloneForCache(IntIntPair data) {
        return new IntIntPair(data.first, data.second);
      }

      @Override
      public IntIntPair downsample(IntIntPair first, IntIntPair second) {
        return new IntIntPair(first.first + second.first, first.second + second.second);
      }

      @Override
      public IntIntPair aggregate(IntIntPair existing, IntIntPair data) {
        existing.first = existing.first + data.first;
View Full Code Here


   */
  public static AggregatingHistogram<IntIntPair, IntIntPair> IntSumIntSumHistogram(int bins, double min, double max) {
    return new AggregatingHistogram<IntIntPair, IntIntPair>(bins, min, max, new Adapter<IntIntPair, IntIntPair>() {
      @Override
      public IntIntPair make() {
        return new IntIntPair(0, 0);
      }

      @Override
      public IntIntPair aggregate(IntIntPair existing, IntIntPair data) {
        existing.first = existing.first + data.first;
View Full Code Here

      // (depends on chosen method in switch)
      // store position in pivotRow, pivotCol

      // TODO: Note that we're using "row, col", whereas "col, row" would be
      // more common?
      IntIntPair pivotPos = new IntIntPair(0, 0);
      IntIntPair currPos = new IntIntPair(k, k);

      switch(method){
      case TRIVAL_PIVOT_SEARCH:
        pivotPos = nonZeroPivotSearch(k);
        break;
View Full Code Here

          pivotRow = i;
          pivotCol = j;
        }// end if
      }// end for j
    }// end for k
    return new IntIntPair(pivotRow, pivotCol);
  }
View Full Code Here

        // current entry in absValue
        absValue = Math.abs(coeff[row[i]][col[j]]);

        // check if absValue is non-zero
        if(absValue > 0) { // found a pivot element
          return new IntIntPair(i, j);
        }// end if
      }// end for j
    }// end for k
    return new IntIntPair(k, k);
  }
View Full Code Here

    // Seed triangulation
    if(!hullonly) {
      tris.add(besttri);
    }
    // Seed convex hull
    hull.add(new IntIntPair(besttri.a, 0));
    hull.add(new IntIntPair(besttri.b, 0));
    hull.add(new IntIntPair(besttri.c, 0));

    if(logger.isDebuggingFinest()) {
      debugHull();
    }

    // Resort from triangle center
    Vector center = besttri.m;
    for(int i = start; i < len; i++) {
      sort[i].first = quadraticEuclidean(center, points.get(sort[i].second));
    }
    Arrays.sort(sort, start, len);

    // Grow hull and triangles
    for(int i = start; i < len; i++) {
      final int pointId = sort[i].second;
      final Vector newpoint = points.get(pointId);

      LinkedList<Triangle> newtris = hullonly ? null : new LinkedList<Triangle>();
      // We identify edges by their starting point. -1 is invalid.
      int hstart = -1, hend = -1;
      // Find first and last consecutive visible edge, backwards:
      {
        Iterator<IntIntPair> iter = hull.descendingIterator();
        IntIntPair next = hull.getFirst();
        Vector nextV = points.get(next.first);
        for(int pos = hull.size() - 1; iter.hasNext(); pos--) {
          IntIntPair prev = iter.next();
          Vector prevV = points.get(prev.first);
          // Not yet visible:
          if(hend < 0) {
            if(leftOf(prevV, nextV, newpoint)) {
              hstart = pos;
              hend = pos;
              if(!hullonly) {
                // Clockwise, A is new point!
                Triangle tri = new Triangle(pointId, next.first, prev.first);
                assert (tri.isClockwise(points));
                assert (prev.second >= 0);
                tri.updateCircumcircle(points);
                tri.bc = prev.second;
                newtris.addFirst(tri);
              }
            }
          }
          else {
            if(leftOf(prevV, nextV, newpoint)) {
              hstart = pos;
              // Add triad:
              if(!hullonly) {
                // Clockwise, A is new point!
                Triangle tri = new Triangle(pointId, next.first, prev.first);
                assert (tri.isClockwise(points));
                assert (prev.second >= 0);
                tri.updateCircumcircle(points);
                tri.bc = prev.second;
                newtris.addFirst(tri);
              }
            }
            else {
              break;
            }
          }
          next = prev;
          nextV = prevV;
        }
      }
      // If the last edge was visible, we also need to scan forwards:
      if(hend == hull.size() - 1) {
        Iterator<IntIntPair> iter = hull.iterator();
        IntIntPair prev = iter.next();
        Vector prevV = points.get(prev.first);
        while(iter.hasNext()) {
          IntIntPair next = iter.next();
          Vector nextV = points.get(next.first);
          if(leftOf(prevV, nextV, newpoint)) {
            hend++;
            // Add triad:
            if(!hullonly) {
              // Clockwise, A is new point!
              Triangle tri = new Triangle(pointId, next.first, prev.first);
              assert (tri.isClockwise(points));
              assert (prev.second >= 0);
              tri.updateCircumcircle(points);
              tri.bc = prev.second;
              newtris.addLast(tri);
            }
          }
          else {
            break;
          }
          prev = next;
          prevV = nextV;
        }
      }
      assert (hstart >= 0 && hend >= hstart);
      // Note that hend can be larger than hull.size() now, interpret as
      // "hend % hull.size()"
      // Update hull, remove points
      final int firsttri, lasttri;
      if(hullonly) {
        firsttri = -1;
        lasttri = -1;
      }
      else {
        final int tristart = tris.size();
        firsttri = tristart;
        lasttri = tristart + newtris.size() - 1;
      }
      final int hullsize = hull.size();
      if(logger.isDebuggingFinest()) {
        logger.debugFinest("Size: " + hullsize + " start: " + hstart + " end: " + hend);
      }
      if(hend < hullsize) {
        ListIterator<IntIntPair> iter = hull.listIterator();
        int p = 0;
        // Skip
        for(; p <= hstart; p++) {
          iter.next();
        }
        // Remove
        for(; p <= hend; p++) {
          iter.next();
          iter.remove();
        }
        // Insert, and update edge->triangle mapping
        iter.add(new IntIntPair(pointId, lasttri));
        iter.previous();
        if(!hullonly) {
          if(iter.hasPrevious()) {
            iter.previous().second = firsttri;
          }
          else {
            hull.getLast().second = firsttri;
          }
        }
      }
      else {
        // System.err.println("Case #2 "+pointId+" "+hstart+" "+hend+" "+hullsize);
        ListIterator<IntIntPair> iter = hull.listIterator();
        // Remove end
        int p = hullsize;
        for(; p <= hend; p++) {
          iter.next();
          iter.remove();
        }
        // Insert
        iter.add(new IntIntPair(pointId, lasttri));
        // Wrap around
        p -= hullsize;
        IntIntPair pre = null;
        for(; p <= hstart; p++) {
          pre = iter.next();
        }
        assert (pre != null);
        pre.second = firsttri;
View Full Code Here

      Rk = new ArrayList<Vector<IntIntPair>>();
      // Set of all dim*phi ranges
      ArrayList<IntIntPair> q = new ArrayList<IntIntPair>();
      for(int i = 1; i <= dimensionality; i++) {
        for(int j = 1; j <= phi; j++) {
          IntIntPair s = new IntIntPair(i, j);
          q.add(s);
          // Add to first Rk
          Vector<IntIntPair> v = new Vector<IntIntPair>();
          v.add(s);
          Rk.add(v);
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.utilities.pairs.IntIntPair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.