Package cern.colt.function

Examples of cern.colt.function.IntComparator


*/
public ObjectMatrix1D sort(final ObjectMatrix1D vector) {
  int[] indexes = new int[vector.size()]; // row indexes to reorder instead of matrix itself
  for (int i=indexes.length; --i >= 0; ) indexes[i] = i;

  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      Comparable av = (Comparable) (vector.getQuick(a));
      Comparable bv = (Comparable) (vector.getQuick(b));
      int r = av.compareTo(bv);
      return r<0 ? -1 : (r>0 ? 1 : 0);
View Full Code Here


*/
public ObjectMatrix1D sort(final ObjectMatrix1D vector, final java.util.Comparator c) {
  int[] indexes = new int[vector.size()]; // row indexes to reorder instead of matrix itself
  for (int i=indexes.length; --i >= 0; ) indexes[i] = i;

  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      return c.compare(vector.getQuick(a), vector.getQuick(b));
    }
  };

View Full Code Here

  int[] rowIndexes = new int[matrix.rows()]; // row indexes to reorder instead of matrix itself
  for (int i=rowIndexes.length; --i >= 0; ) rowIndexes[i] = i;

  final ObjectMatrix1D col = matrix.viewColumn(column);
  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      Comparable av = (Comparable) (col.getQuick(a));
      Comparable bv = (Comparable) (col.getQuick(b));
      int r = av.compareTo(bv);
      return r<0 ? -1 : (r>0 ? 1 : 0);
View Full Code Here

  for (int i=rowIndexes.length; --i >= 0; ) rowIndexes[i] = i;

  final ObjectMatrix1D[] views = new ObjectMatrix1D[matrix.rows()]; // precompute views for speed
  for (int i=views.length; --i >= 0; ) views[i] = matrix.viewRow(i);

  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      //return c.compare(matrix.viewRow(a), matrix.viewRow(b));
      return c.compare(views[a], views[b]);
    }
  };
View Full Code Here

  int[] sliceIndexes = new int[matrix.slices()]; // indexes to reorder instead of matrix itself
  for (int i=sliceIndexes.length; --i >= 0; ) sliceIndexes[i] = i;

  final ObjectMatrix1D sliceView = matrix.viewRow(row).viewColumn(column);
  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      Comparable av = (Comparable) (sliceView.getQuick(a));
      Comparable bv = (Comparable) (sliceView.getQuick(b));
      int r = av.compareTo(bv);
      return r<0 ? -1 : (r>0 ? 1 : 0);
View Full Code Here

  for (int i=sliceIndexes.length; --i >= 0; ) sliceIndexes[i] = i;

  final ObjectMatrix2D[] views = new ObjectMatrix2D[matrix.slices()]; // precompute views for speed
  for (int i=views.length; --i >= 0; ) views[i] = matrix.viewSlice(i);

  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      //return c.compare(matrix.viewSlice(a), matrix.viewSlice(b));
      return c.compare(views[a], views[b]);
    }
  };
View Full Code Here

    }
  };
 
  // compare splitter[a] with columnView[rowIndexes[b]]
  final ObjectMatrix1D columnView = matrix.viewColumn(column)
  IntComparator comp = new IntComparator() {
    public int compare(int a, int b) {
      Comparable av = (Comparable) (splitters[a]);
      Comparable bv = (Comparable) (columnView.getQuick(g[b]));
      int r = av.compareTo(bv);
      return r<0 ? -1 : (r==0 ? 0 : 1);
    }
  };

  // compare columnView[rowIndexes[a]] with columnView[rowIndexes[b]]
  IntComparator comp2 = new IntComparator() {
    public int compare(int a, int b) {
      Comparable av = (Comparable) (columnView.getQuick(g[a]));
      Comparable bv = (Comparable) (columnView.getQuick(g[b]));
      int r = av.compareTo(bv);
      return r<0 ? -1 : (r==0 ? 0 : 1);
    }
  };

  // compare splitter[a] with splitter[b]
  IntComparator comp3 = new IntComparator() {
    public int compare(int a, int b) {
      Comparable av = (Comparable) (splitters[a]);
      Comparable bv = (Comparable) (splitters[b]);
      int r = av.compareTo(bv);
      return r<0 ? -1 : (r==0 ? 0 : 1);
View Full Code Here

      t2 = y[a]; y[a] = y[b]; y[b] = t2;
      t3 = z[a]; z[a] = z[b];  z[b] = t3;
    }
  };

  IntComparator comp = new IntComparator() {
    public int compare(int a, int b) {
      return x[a]==x[b] ? 0 : (x[a]<x[b] ? -1 : 1);
    }
  };
View Full Code Here

      t2 = y[a]; y[a] = y[b]; y[b] = t2;
      t3 = z[a]; z[a] = z[b];  z[b] = t3;
    }
  };
 
  IntComparator comp = new IntComparator() {
    public int compare(int a, int b) {
      if (y[a]==y[b]) return z[a]==z[b] ? 0 : (z[a]<z[b] ? -1 : 1);
      return y[a]<y[b] ? -1 : 1;
    }
  };
View Full Code Here

*/
public DoubleMatrix1D sort(final DoubleMatrix1D vector) {
  int[] indexes = new int[vector.size()]; // row indexes to reorder instead of matrix itself
  for (int i=indexes.length; --i >= 0; ) indexes[i] = i;

  IntComparator comp = new IntComparator() { 
    public int compare(int a, int b) {
      double av = vector.getQuick(a);
      double bv = vector.getQuick(b);
      if (av!=av || bv!=bv) return compareNaN(av,bv); // swap NaNs to the end
      return av<bv ? -1 : (av==bv ? 0 : 1);
View Full Code Here

TOP

Related Classes of cern.colt.function.IntComparator

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.