congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
QuickSort_F64
Code IndexAdd Tabnine to your IDE (free)

How to use
QuickSort_F64
in
org.ddogleg.sorting

Best Java code snippets using org.ddogleg.sorting.QuickSort_F64 (Showing top 5 results out of 315)

origin: lessthanoptimal/ddogleg

@Override
public void computeStatistics() {
  int size = allPoints.size();
  if (errors.length < size) {
    errors = new double[size * 3 / 2];
    origErrors = new double[errors.length];
  }
  Iterator<PointIndex<Point>> iter = allPoints.iterator();
  int index = 0;
  while( iter.hasNext() ) {
    Point pt = iter.next().data;
    errors[index++] = modelError.computeDistance(pt);
  }
  System.arraycopy(errors, 0, origErrors, 0, size);
  int where = (int) (size * pruneThreshold);
  sorter.sort(errors, size);
  medianError = errors[size / 2];
  pruneVal = errors[where];
}
origin: lessthanoptimal/ddogleg

  @Test
  public void testSortingRandom_indexes() {
    int offset = 10;
    for( int a = 0; a < 20; a++ ) {
      double[] normal = BenchMarkSort.createRandom_F64(rand,20);
      double[] original = normal.clone();
      double[] withIndexes = new double[offset+normal.length];;
      int[] indexes = new int[ withIndexes.length ];

      System.arraycopy(normal,0,withIndexes,offset,normal.length);

      QuickSort_F64 sorter = new QuickSort_F64();

      sorter.sort(normal,normal.length);
      sorter.sort(withIndexes,offset,normal.length,indexes);

      for( int i = 0; i < normal.length; i++ ) {
        // make sure the original hasn't been modified
        assertEquals(original[i],withIndexes[i+offset], UtilEjml.TEST_F64);
        // see if it produced the same results as the normal one
        assertEquals(normal[i],withIndexes[indexes[i]],UtilEjml.TEST_F64);
      }
    }
  }
}
origin: lessthanoptimal/ddogleg

@Test
public void testSortingRandom() {
  double[] ret = BenchMarkSort.createRandom_F64(rand,200);
  double preTotal = UtilDouble.sum(ret);
  QuickSort_F64 sorter = new QuickSort_F64();
  sorter.sort(ret,ret.length);
  double postTotal = UtilDouble.sum(ret);
  // make sure it didn't modify the list, in an unexpected way
  assertEquals(preTotal,postTotal,UtilEjml.TEST_F64);
  double prev = ret[0];
  for( int i = 1; i < ret.length; i++ ) {
    if( ret[i] < prev )
      fail("Not ascending");
    prev = ret[i];
  }
}
origin: org.ddogleg/ddogleg

@Override
public void computeStatistics() {
  int size = allPoints.size();
  if (errors.length < size) {
    errors = new double[size * 3 / 2];
    origErrors = new double[errors.length];
  }
  Iterator<PointIndex<Point>> iter = allPoints.iterator();
  int index = 0;
  while( iter.hasNext() ) {
    Point pt = iter.next().data;
    errors[index++] = modelError.computeDistance(pt);
  }
  System.arraycopy(errors, 0, origErrors, 0, size);
  int where = (int) (size * pruneThreshold);
  sorter.sort(errors, size);
  medianError = errors[size / 2];
  pruneVal = errors[where];
}
origin: org.boofcv/feature

@Override
public double compute(double c_x, double c_y) {
  double period = scale*this.period;
  // top left corner of the region being sampled
  double tl_x = c_x - sampleRadius *period;
  double tl_y = c_y - sampleRadius *period;
  computeGradient(tl_x,tl_y,period);
  // apply weight to each gradient dependent on its position
  if( weights != null ) {
    for( int i = 0; i < total; i++ ) {
      double w = weights.data[i];
      derivX[i] *= w;
      derivY[i] *= w;
    } 
  }
  
  for( int i = 0; i < total; i++ ) {
    angles[i] = Math.atan2(derivY[i],derivX[i]);
  }
  // order points from lowest to highest
  sorter.sort(angles, angles.length, order);
  return estimateAngle();
}
org.ddogleg.sortingQuickSort_F64

Javadoc

An implementation of the quick sort algorithm from Numerical Recipes Third Edition that is specified for arrays of doubles. A small amount of memory is declared for this sorting algorithm. This implementation seems to often perform slower than Shell sort. A comment in Numerical recipes about unnecessary array checks makes me think this is slow because java always does a bounds check on arrays. This has slightly better performance than Arrays.sort(double[]). Not noticeable in most applications.

Most used methods

  • sort
  • <init>

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • JOptionPane (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now