Codota Logo
HeapSelect.sort
Code IndexAdd Codota to your IDE (free)

How to use
sort
method
in
smile.sort.HeapSelect

Best Java code snippets using smile.sort.HeapSelect.sort (Showing top 7 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: com.github.haifengl/smile-math

/**
 * Sort the smallest values.
 */
public void sort() {
  if (!sorted) {
    sort(heap, Math.min(k,n));
    sorted = true;
  }
}
origin: com.github.haifengl/smile-math

/**
 * Returns the i-<i>th</i> smallest value seen so far. i = 0 returns the smallest
 * value seen, i = 1 the second largest, ..., i = k-1 the last position
 * tracked. Also, i must be less than the number of previous assimilated.
 */
public T get(int i) {
  if (i > Math.min(k, n) - 1) {
    throw new IllegalArgumentException("HeapSelect i is greater than the number of data received so far.");
  }
  if (i == k-1) {
    return heap[0];
  }
  
  if (!sorted) {
    sort(heap, Math.min(k,n));
    sorted = true;
  }
  return heap[k-1-i];
}
origin: com.github.haifengl/smile-core

@Override
public Neighbor<double[], E>[] knn(double[] q, int k) {
  if (k <= 0) {
    throw new IllegalArgumentException("Invalid k: " + k);
  }
  if (k > keys.length) {
    throw new IllegalArgumentException("Neighbor array length is larger than the dataset size");
  }
  Neighbor<double[], E> neighbor = new Neighbor<>(null, null, 0, Double.MAX_VALUE);
  @SuppressWarnings("unchecked")
  Neighbor<double[], E>[] neighbors = (Neighbor<double[], E>[]) java.lang.reflect.Array.newInstance(neighbor.getClass(), k);
  HeapSelect<Neighbor<double[], E>> heap = new HeapSelect<>(neighbors);
  for (int i = 0; i < k; i++) {
    heap.add(neighbor);
    neighbor = new Neighbor<>(null, null, 0, Double.MAX_VALUE);
  }
  search(q, root, heap);
  heap.sort();
  for (int i = 0; i < neighbors.length; i++) {
    neighbors[i].distance = Math.sqrt(neighbors[i].distance);
  }
  return neighbors;
}
origin: com.github.haifengl/smile-core

heap.sort();
origin: com.github.haifengl/smile-core

heap.sort();
return neighbors;
origin: com.github.haifengl/smile-core

heap.sort();
if (hit < k) {
  Neighbor<AbstractSentence, E>[] n2 = (Neighbor<AbstractSentence, E>[])Array.newInstance(Neighbor.class, hit);
origin: com.github.haifengl/smile-core

heap.sort();
smile.sortHeapSelectsort

Javadoc

Sort the smallest values.

Popular methods of HeapSelect

  • heapify
    Place the array in max-heap order. Note that the array is not fully sorted.
  • <init>
    Constructor.
  • add
    Assimilate a new value from the stream.
  • peek
    Returns the k-th smallest value seen so far.

Popular in Java

  • Making http requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now