congrats Icon
New! Announcing our next generation AI code completions
Read here
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 requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • getSharedPreferences (Context)
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JFileChooser (javax.swing)
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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