code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static void load(Class<?> restrictionClass) {
if(MASTER_CACHE == null) {
initialize();
}
if(MASTER_CACHE.isEmpty()) {
return;
}
Iterator<Class<?>> iter = MASTER_CACHE.iterator();
while(iter.hasNext()) {
Class<?> clazz = iter.next();
// Skip other classes.
if(... | java |
private static int comparePackageClass(Class<?> o1, Class<?> o2) {
return o1.getPackage() == o2.getPackage() ? //
o1.getCanonicalName().compareTo(o2.getCanonicalName()) //
: o1.getPackage() == null ? -1 : o2.getPackage() == null ? +1 //
: o1.getPackage().getName().compareTo(o2.getPackage... | java |
private static int classPriority(Class<?> o1) {
Priority p = o1.getAnnotation(Priority.class);
if(p == null) {
Class<?> pa = o1.getDeclaringClass();
p = (pa != null) ? pa.getAnnotation(Priority.class) : null;
}
return p != null ? p.value() : Priority.DEFAULT;
} | java |
public int nextIndex(int weight) {
if(used == parent.length) {
int nsize = used + (used >> 1);
this.weight = Arrays.copyOf(this.weight, nsize);
this.parent = Arrays.copyOf(this.parent, nsize);
}
this.weight[used] = weight;
this.parent[used] = used;
return used++;
} | java |
public int find(int cur) {
assert (cur >= 0 && cur < parent.length);
int p = parent[cur], tmp;
while(cur != p) {
tmp = p;
p = parent[cur] = parent[p]; // Perform simple path compression.
cur = tmp;
}
return cur;
} | java |
public int union(int first, int second) {
int firstComponent = find(first), secondComponent = find(second);
if(firstComponent == secondComponent) {
return firstComponent;
}
final int w1 = weight[firstComponent], w2 = weight[secondComponent];
if(w1 > w2) {
parent[secondComponent] = firstC... | java |
public IntList getRoots() {
IntList roots = new IntArrayList();
for(int i = 0; i < used; i++) {
// roots or one element in component
if(parent[i] == i) {
roots.add(i);
}
}
return roots;
} | java |
public int growSuperNode() {
if(getNumEntries() < getCapacity()) {
throw new IllegalStateException("This node is not yet overflowing (only " + getNumEntries() + " of " + getCapacity() + " entries)");
}
Entry[] old_nodes = super.entries.clone();
assert old_nodes[old_nodes.length - 1] != null;
s... | java |
public <T extends AbstractXTree<N>> void readSuperNode(ObjectInput in, T tree) throws IOException, ClassNotFoundException {
readExternal(in);
if(capacity_to_be_filled <= 0 || !isSuperNode()) {
throw new IllegalStateException("This node does not appear to be a supernode");
}
if(isLeaf) {
thro... | java |
public static int compare(DBIDRef id1, DBIDRef id2) {
return DBIDFactory.FACTORY.compare(id1, id2);
} | java |
public static boolean equal(DBIDRef id1, DBIDRef id2) {
return DBIDFactory.FACTORY.equal(id1, id2);
} | java |
public static DBID deref(DBIDRef ref) {
return ref instanceof DBID ? (DBID) ref : importInteger(ref.internalGetIndex());
} | java |
public static ModifiableDBIDs union(DBIDs ids1, DBIDs ids2) {
ModifiableDBIDs result = DBIDUtil.newHashSet(Math.max(ids1.size(), ids2.size()));
result.addDBIDs(ids1);
result.addDBIDs(ids2);
return result;
} | java |
public static ModifiableDBIDs difference(DBIDs ids1, DBIDs ids2) {
ModifiableDBIDs result = DBIDUtil.newHashSet(ids1);
result.removeDBIDs(ids2);
return result;
} | java |
public static ArrayDBIDs ensureArray(DBIDs ids) {
return ids instanceof ArrayDBIDs ? (ArrayDBIDs) ids : newArray(ids);
} | java |
public static SetDBIDs ensureSet(DBIDs ids) {
return ids instanceof SetDBIDs ? (SetDBIDs) ids : newHashSet(ids);
} | java |
public static ModifiableDBIDs ensureModifiable(DBIDs ids) {
return ids instanceof ModifiableDBIDs ? (ModifiableDBIDs) ids : //
ids instanceof HashSetDBIDs ? newHashSet(ids) : newArray(ids);
} | java |
public static DBIDPair newPair(DBIDRef id1, DBIDRef id2) {
return DBIDFactory.FACTORY.newPair(id1, id2);
} | java |
public static DoubleDBIDPair newPair(double val, DBIDRef id) {
return DBIDFactory.FACTORY.newPair(val, id);
} | java |
public static void sort(int[] data, Comparator<? super DBIDRef> comp) {
sort(data, 0, data.length, comp);
} | java |
private static int compare(IntegerDBIDVar i1, int p1, IntegerDBIDVar i2, int p2, Comparator<? super DBIDRef> comp) {
i1.internalSetIndex(p1);
i2.internalSetIndex(p2);
return comp.compare(i1, i2);
} | java |
@Override
protected int computeHeight() {
N node = getRoot();
int tHeight = 1;
// compute height
while(!node.isLeaf() && node.getNumEntries() != 0) {
SpatialEntry entry = node.getEntry(0);
node = getNode(entry);
tHeight++;
}
return tHeight;
} | java |
public long commit() throws IOException {
final PageFile<N> file = super.getFile();
if(!(file instanceof PersistentPageFile)) {
throw new IllegalStateException("Trying to commit a non-persistent XTree");
}
long npid = file.getNextPageID();
XTreeHeader ph = (XTreeHeader) ((PersistentPageFile<?>... | java |
public void setExpanded(SpatialEntry entry1, SpatialEntry entry2) {
IntSet exp1 = expanded.get(getPageID(entry1));
if(exp1 == null) {
exp1 = new IntOpenHashSet();
expanded.put(getPageID(entry1), exp1);
}
exp1.add(getPageID(entry2));
} | java |
public IntSet getExpanded(SpatialEntry entry) {
IntSet exp = expanded.get(getPageID(entry));
return (exp != null) ? exp : IntSets.EMPTY_SET;
} | java |
public void increment(double coord, double val) {
int bin = getBinNr(coord);
if (bin < 0) {
if (size - bin > data.length) {
// Reallocate. TODO: use an arraylist-like grow strategy!
double[] tmpdata = new double[growSize(data.length, size - bin)];
System.arraycopy(data, 0, tmpdata,... | java |
public double get(double coord) {
int bin = getBinNr(coord);
return (bin < 0 || bin >= size) ? 0 : data[bin];
} | java |
public Assignment update(Border border) {
Arrays.sort(cs);
int j = 1;
boolean found = (cs[0].core == border.core);
for(int i = 1; i < cs.length; i++) {
if(cs[i].core != cs[i - 1].core) {
cs[j++] = cs[i];
}
found |= (cs[i].core == border.core);
}
if(found) {
if(j =... | java |
public Core getCore() {
Core a = cs[0].core;
for(int i = 1; i < cs.length; i++) {
Core v = cs[i].core;
a = a.num > v.num ? a : v; // max, of negative values
}
return a;
} | java |
protected int currentCluster(List<? extends ModifiableDBIDs> clusters, DBIDRef id) {
for(int i = 0; i < k; i++) {
if(clusters.get(i).contains(id)) {
return i;
}
}
return -1;
} | java |
protected void computeINFLO(Relation<O> relation, ModifiableDBIDs pruned, KNNQuery<O> knnq, WritableDataStore<ModifiableDBIDs> rNNminuskNNs, WritableDoubleDataStore inflos, DoubleMinMax inflominmax) {
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Computing INFLOs", relation.size(), LOG) : null;
Ha... | java |
public OutlierResult run(Database database, Relation<O> relation) {
// Get the query functions:
DistanceQuery<O> dq = database.getDistanceQuery(relation, getDistanceFunction());
KNNQuery<O> knnq = database.getKNNQuery(dq, k);
// Get the objects to process, and a data storage for counting and output:
... | java |
public static Icon getStockIcon(String name) {
SoftReference<Icon> ref = iconcache.get(name);
if(ref != null) {
Icon icon = ref.get();
if(icon != null) {
return icon;
}
}
java.net.URL imgURL = StockIcon.class.getResource(name + ".png");
if(imgURL != null) {
Icon icon ... | java |
@Override
public void initializeFromFile(TreeIndexHeader header, PageFile<FlatRStarTreeNode> file) {
super.initializeFromFile(header, file);
// reconstruct root
int nextPageID = file.getNextPageID();
dirCapacity = nextPageID;
root = createNewDirectoryNode();
for(int i = 1; i < nextPageID; i++... | java |
protected Node bulkConstruct(DBIDRef cur, int maxScale, double parentDist, ModifiableDoubleDBIDList elems) {
assert (!elems.contains(cur));
final double max = maxDistance(elems);
final int scale = Math.min(distToScale(max) - 1, maxScale);
final int nextScale = scale - 1;
// Leaf node, because points... | java |
@Override
public double getWeight(double distance, double max, double stddev) {
if(max <= 0) {
return 1.0;
}
double relativedistance = distance / max;
return 1.0 - 0.9 * relativedistance * relativedistance;
} | java |
public double maxDist(SpatialComparable mbr1, SpatialComparable mbr2) {
final int dim1 = mbr1.getDimensionality(), dim2 = mbr2.getDimensionality();
final int mindim = dim1 < dim2 ? dim1 : dim2;
double agg = 0.;
for(int d = 0; d < mindim; d++) {
double d1 = mbr1.getMax(d) - mbr2.getMin(d);
d... | java |
public synchronized void updateFromTrackParameters(TrackParameters track) {
parameters.clear();
for(TrackedParameter p : track.getAllParameters()) {
Parameter<?> option = p.getParameter();
String value = null;
if(option.isDefined()) {
if(option.tookDefaultValue()) {
value = D... | java |
public synchronized void addParameter(Parameter<?> option, String value, int bits, int depth) {
parameters.add(new Node(option, value, bits, depth));
} | java |
public static List<Clustering<? extends Model>> getClusteringResults(Result r) {
if(r instanceof Clustering<?>) {
List<Clustering<?>> crs = new ArrayList<>(1);
crs.add((Clustering<?>) r);
return crs;
}
if(r instanceof HierarchicalResult) {
return ResultUtil.filterResults(((Hierarchic... | java |
private static double[] randomLatitudeLongitude(Random r) {
// Make marginally more realistic looking data by non-uniformly sampling
// latitude, since Earth is a sphere, and there is not much at the poles
double lat = Math.pow(1. - r.nextDouble() * 2., 2) / 2. * 180;
double lng = (.5 - r.nextDouble()) ... | java |
@Override
public double distance(NumberVector v1, NumberVector v2) {
return 1 - Math.abs(PearsonCorrelation.coefficient(v1, v2));
} | java |
private long inverse(double current) {
// Represent to base b.
short[] digits = new short[maxi];
for(int j = 0; j < maxi; j++) {
current *= base;
digits[j] = (short) current;
current -= digits[j];
if(current <= 1e-10) {
break;
}
}
long inv = 0;
for(int j = m... | java |
private double radicalInverse(long i) {
double digit = 1.0 / (double) base;
double radical = digit;
double inverse = 0.0;
while(i > 0) {
inverse += digit * (double) (i % base);
digit *= radical;
i /= base;
}
return inverse;
} | java |
private double nextRadicalInverse() {
counter++;
// Do at most MAXFAST appromate steps
if(counter >= MAXFAST) {
counter = 0;
inverse += MAXFAST;
current = radicalInverse(inverse);
return current;
}
// Fast approximation:
double nextInverse = current + invbase;
if(next... | java |
public String dimensonsToString(String sep) {
StringBuilder result = new StringBuilder(100).append('[');
for(int dim = BitsUtil.nextSetBit(dimensions, 0); dim >= 0; dim = BitsUtil.nextSetBit(dimensions, dim + 1)) {
result.append(dim + 1).append(sep);
}
if(result.length() > sep.length()) { // Un-ap... | java |
public boolean isSubspace(Subspace subspace) {
return this.dimensionality <= subspace.dimensionality && //
BitsUtil.intersectionSize(dimensions, subspace.dimensions) == dimensionality;
} | java |
protected <E extends SpatialComparable, A> double computeOverlap(A entries, ArrayAdapter<E, A> getter, long[] assign) {
ModifiableHyperBoundingBox mbr1 = null, mbr2 = null;
for(int i = 0; i < getter.size(entries); i++) {
E e = getter.get(entries, i);
if(BitsUtil.get(assign, i)) {
if(mbr1 == ... | java |
private void binarySplitSort(List<? extends SpatialComparable> objs, final int start, final int end, int depth, final int numdim, int[] dims, Sorter comp) {
final int mid = start + ((end - start) >>> 1);
// Make invariant
comp.setDimension(dims != null ? dims[depth] : depth);
QuickSelect.quickSelect(obj... | java |
public static Element svgElement(Document document, String name) {
return document.createElementNS(SVGConstants.SVG_NAMESPACE_URI, name);
} | java |
public static void setStyle(Element el, String d) {
el.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, d);
} | java |
public static void addCSSClass(Element e, String cssclass) {
String oldval = e.getAttribute(SVGConstants.SVG_CLASS_ATTRIBUTE);
if(oldval == null || oldval.length() == 0) {
setAtt(e, SVGConstants.SVG_CLASS_ATTRIBUTE, cssclass);
return;
}
String[] classes = oldval.split(" ");
for(String c ... | java |
public static void removeCSSClass(Element e, String cssclass) {
String oldval = e.getAttribute(SVGConstants.SVG_CLASS_ATTRIBUTE);
if(oldval == null) {
return;
}
String[] classes = oldval.split(" ");
if(classes.length == 1) {
if(cssclass.equals(classes[0])) {
e.removeAttribute(SVG... | java |
public static Element makeStyleElement(Document document) {
Element style = SVGUtil.svgElement(document, SVGConstants.SVG_STYLE_TAG);
style.setAttribute(SVGConstants.SVG_TYPE_ATTRIBUTE, SVGConstants.CSS_MIME_TYPE);
return style;
} | java |
public static Element svgRect(Document document, double x, double y, double w, double h) {
Element rect = SVGUtil.svgElement(document, SVGConstants.SVG_RECT_TAG);
SVGUtil.setAtt(rect, SVGConstants.SVG_X_ATTRIBUTE, x);
SVGUtil.setAtt(rect, SVGConstants.SVG_Y_ATTRIBUTE, y);
SVGUtil.setAtt(rect, SVGConstan... | java |
public static Element svgCircle(Document document, double cx, double cy, double r) {
Element circ = SVGUtil.svgElement(document, SVGConstants.SVG_CIRCLE_TAG);
SVGUtil.setAtt(circ, SVGConstants.SVG_CX_ATTRIBUTE, cx);
SVGUtil.setAtt(circ, SVGConstants.SVG_CY_ATTRIBUTE, cy);
SVGUtil.setAtt(circ, SVGConstan... | java |
public static Element svgLine(Document document, double x1, double y1, double x2, double y2) {
Element line = SVGUtil.svgElement(document, SVGConstants.SVG_LINE_TAG);
SVGUtil.setAtt(line, SVGConstants.SVG_X1_ATTRIBUTE, x1);
SVGUtil.setAtt(line, SVGConstants.SVG_Y1_ATTRIBUTE, y1);
SVGUtil.setAtt(line, SV... | java |
public static Color stringToColor(String str) {
int icol = SVG_COLOR_NAMES.getInt(str.toLowerCase());
if(icol != NO_VALUE) {
return new Color(icol, false);
}
return colorLookupStylesheet.stringToColor(str);
} | java |
public static String colorToString(int col) {
final char[] buf = new char[] { '#', 'X', 'X', 'X', 'X', 'X', 'X' };
for(int i = 6; i > 0; i--) {
final int v = (col & 0xF);
buf[i] = (char) ((v < 10) ? ('0' + v) : ('a' + v - 10));
col >>>= 4;
}
return new String(buf);
} | java |
public static SVGPoint elementCoordinatesFromEvent(Document doc, Element tag, Event evt) {
try {
DOMMouseEvent gnme = (DOMMouseEvent) evt;
SVGMatrix mat = ((SVGLocatable) tag).getScreenCTM();
SVGMatrix imat = mat.inverse();
SVGPoint cPt = ((SVGDocument) doc).getRootElement().createSVGPoint()... | java |
public static void removeLastChild(Element tag) {
final Node last = tag.getLastChild();
if(last != null) {
tag.removeChild(last);
}
} | java |
public static void removeFromParent(Element elem) {
if(elem != null && elem.getParentNode() != null) {
elem.getParentNode().removeChild(elem);
}
} | java |
public static Element svgCircleSegment(SVGPlot svgp, double centerx, double centery, double angleStart, double angleDelta, double innerRadius, double outerRadius) {
final DoubleWrapper tmp = new DoubleWrapper(); // To return cosine
double sin1st = FastMath.sinAndCos(angleStart, tmp);
double cos1st = tmp.val... | java |
protected WritableDoubleDataStore computeCoreDists(DBIDs ids, KNNQuery<O> knnQ, int minPts) {
final Logging LOG = getLogger();
final WritableDoubleDataStore coredists = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_DB);
FiniteProgress cprog = LOG.isVerbose() ? new Fi... | java |
protected void convertToPointerRepresentation(ArrayDBIDs ids, DoubleLongHeap heap, WritableDBIDDataStore pi, WritableDoubleDataStore lambda) {
final Logging LOG = getLogger();
// Initialize parent array:
for(DBIDArrayIter iter = ids.iter(); iter.valid(); iter.advance()) {
pi.put(iter, iter); // Initia... | java |
private void updateHeap(final double distance, final int iid) {
final double prevdist = kdist;
final int previd = heap.peekValue();
heap.replaceTopElement(distance, iid);
kdist = heap.peekKey();
// If the kdist improved, zap ties.
if(kdist < prevdist) {
numties = 0;
}
else {
... | java |
private void addToTies(int id) {
if(ties.length == numties) {
ties = Arrays.copyOf(ties, (ties.length << 1) + 1); // grow.
}
ties[numties] = id;
++numties;
} | java |
public static int numberOfFreeParameters(Relation<? extends NumberVector> relation, Clustering<? extends MeanModel> clustering) {
// number of clusters
int m = clustering.getAllClusters().size(); // num_ctrs
// dimensionality of data points
int dim = RelationUtil.dimensionality(relation); // num_dims
... | java |
protected void dumpClusteringOutput(PrintStream writer, ResultHierarchy hierarchy, Clustering<?> c) {
DBIDRange ids = null;
for(It<Relation<?>> iter = hierarchy.iterParents(c).filter(Relation.class); iter.valid(); iter.advance()) {
DBIDs pids = iter.get().getDBIDs();
if(pids instanceof DBIDRange) {
... | java |
public <F extends NumberVector> F getMeanVector(Relation<? extends F> relation) {
return RelationUtil.getNumberVectorFactory(relation).newNumberVector(mean);
} | java |
public void reset() {
Arrays.fill(mean, 0.);
Arrays.fill(nmea, 0.);
if(elements != null) {
for(int i = 0; i < elements.length; i++) {
Arrays.fill(elements[i], 0.);
}
}
else {
elements = new double[mean.length][mean.length];
}
wsum = 0.;
} | java |
public static CovarianceMatrix make(Relation<? extends NumberVector> relation) {
int dim = RelationUtil.dimensionality(relation);
CovarianceMatrix c = new CovarianceMatrix(dim);
double[] mean = c.mean;
int count = 0;
// Compute mean first:
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid... | java |
@Override
public StringBuilder appendToBuffer(StringBuilder buf) {
String processedString = Integer.toString(getProcessed());
int percentage = (int) (getProcessed() * 100.0 / total);
buf.append(getTask());
buf.append(": ");
for(int i = 0; i < totalLength - processedString.length(); i++) {
bu... | java |
public void ensureCompleted(Logging logger) {
if(!isComplete()) {
logger.warning("Progress had not completed automatically as expected: " + getProcessed() + "/" + total, new Throwable());
setProcessed(getTotal());
logger.progress(this);
}
} | java |
private void clusterData(DBIDs ids, RangeQuery<O> rnnQuery, WritableDoubleDataStore radii, WritableDataStore<ModifiableDBIDs> labels) {
FiniteProgress clustProg = LOG.isVerbose() ? new FiniteProgress("Density-Based Clustering", ids.size(), LOG) : null;
// Iterate over all objects
for(DBIDIter iter = ids.ite... | java |
private int updateSizes(DBIDs ids, WritableDataStore<ModifiableDBIDs> labels, WritableIntegerDataStore newSizes) {
// to count the unclustered all over
int countUnmerged = 0;
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
// checking the point's new cluster size after the clustering s... | java |
public PointerHierarchyRepresentationResult run(Database database, Relation<O> relation) {
DBIDs ids = relation.getDBIDs();
WritableDBIDDataStore pi = DataStoreUtil.makeDBIDStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_STATIC);
WritableDoubleDataStore lambda = DataStoreUtil.makeDoubleStorag... | java |
protected void process(DBIDRef id, ArrayDBIDs ids, DBIDArrayIter it, int n, WritableDBIDDataStore pi, WritableDoubleDataStore lambda, WritableDoubleDataStore m) {
slinkstep3(id, it, n, pi, lambda, m);
slinkstep4(id, it, n, pi, lambda);
} | java |
public void add(DBIDRef id, double reach, DBIDRef pre) {
ids.add(id);
reachability.putDouble(id, reach);
if(pre == null || pre instanceof DBIDVar && !((DBIDVar) pre).isSet()) {
return;
}
predecessor.putDBID(id, pre);
} | java |
@Override
public ArrayModifiableDBIDs order(DBIDs ids) {
ArrayModifiableDBIDs res = DBIDUtil.newArray(ids.size());
for(DBIDIter it = this.ids.iter(); it.valid(); it.advance()) {
if(ids.contains(it)) {
res.add(it);
}
}
return res;
} | java |
public void getPredecessor(DBIDRef id, DBIDVar out) {
if(predecessor == null) {
out.unset();
return;
}
predecessor.assignVar(id, out);
} | java |
public OutlierResult run(Database database, Relation<O> relation) {
StepProgress stepprog = LOG.isVerbose() ? new StepProgress("COF", 3) : null;
DistanceQuery<O> dq = database.getDistanceQuery(relation, getDistanceFunction());
LOG.beginStep(stepprog, 1, "Materializing COF neighborhoods.");
KNNQuery<O> k... | java |
private void computeCOFScores(KNNQuery<O> knnq, DBIDs ids, DoubleDataStore acds, WritableDoubleDataStore cofs, DoubleMinMax cofminmax) {
FiniteProgress progressCOFs = LOG.isVerbose() ? new FiniteProgress("COF for objects", ids.size(), LOG) : null;
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
... | java |
public void invokeLater(Runnable r) {
queue.add(r);
synchronized(this) {
if(synchronizer == null) {
runQueue();
}
else {
synchronizer.activate();
}
}
} | java |
public void runQueue() {
synchronized(sync) {
while(!queue.isEmpty()) {
Runnable r = queue.poll();
if(r != null) {
try {
r.run();
}
catch(Exception e) {
// Alternatively, we could allow the specification of exception
// handlers... | java |
public synchronized void synchronizeWith(UpdateSynchronizer newsync) {
// LoggingUtil.warning("Synchronizing: " + sync + " " + newsync, new
// Throwable());
if(synchronizer == newsync) {
LoggingUtil.warning("Double-synced to the same plot!", new Throwable());
return;
}
if(synchronizer !=... | java |
public synchronized void unsynchronizeWith(UpdateSynchronizer oldsync) {
if(synchronizer == null) {
LoggingUtil.warning("Warning: was not synchronized.");
return;
}
if(synchronizer != oldsync) {
LoggingUtil.warning("Warning: was synchronized differently!");
return;
}
// Loggi... | java |
protected static double estimateInitialBeta(double[] dist_i, double perplexity) {
double sum = 0.;
for(double d : dist_i) {
double d2 = d * d;
sum += d2 < Double.POSITIVE_INFINITY ? d2 : 0.;
}
return sum > 0 && sum < Double.POSITIVE_INFINITY ? .5 / sum * perplexity * (dist_i.length - 1.) : 1... | java |
public static List<Relation<?>> getRelations(Result r) {
if(r instanceof Relation<?>) {
List<Relation<?>> anns = new ArrayList<>(1);
anns.add((Relation<?>) r);
return anns;
}
if(r instanceof HierarchicalResult) {
return filterResults(((HierarchicalResult) r).getHierarchy(), r, Relati... | java |
public static List<OrderingResult> getOrderingResults(Result r) {
if(r instanceof OrderingResult) {
List<OrderingResult> ors = new ArrayList<>(1);
ors.add((OrderingResult) r);
return ors;
}
if(r instanceof HierarchicalResult) {
return filterResults(((HierarchicalResult) r).getHierarc... | java |
public static List<CollectionResult<?>> getCollectionResults(Result r) {
if(r instanceof CollectionResult<?>) {
List<CollectionResult<?>> crs = new ArrayList<>(1);
crs.add((CollectionResult<?>) r);
return crs;
}
if(r instanceof HierarchicalResult) {
return filterResults(((Hierarchica... | java |
public static List<IterableResult<?>> getIterableResults(Result r) {
if(r instanceof IterableResult<?>) {
List<IterableResult<?>> irs = new ArrayList<>(1);
irs.add((IterableResult<?>) r);
return irs;
}
if(r instanceof HierarchicalResult) {
return filterResults(((HierarchicalResult) r... | java |
public static <C extends Result> ArrayList<C> filterResults(ResultHierarchy hier, Result r, Class<? super C> restrictionClass) {
ArrayList<C> res = new ArrayList<>();
final It<C> it = hier.iterDescendantsSelf(r).filter(restrictionClass);
it.forEach(res::add);
return res;
} | java |
public static void addChildResult(HierarchicalResult parent, Result child) {
parent.getHierarchy().add(parent, child);
} | java |
public static Database findDatabase(ResultHierarchy hier, Result baseResult) {
final List<Database> dbs = filterResults(hier, baseResult, Database.class);
return (!dbs.isEmpty()) ? dbs.get(0) : null;
} | java |
public static void removeRecursive(ResultHierarchy hierarchy, Result child) {
for(It<Result> iter = hierarchy.iterParents(child); iter.valid(); iter.advance()) {
hierarchy.remove(iter.get(), child);
}
for(It<Result> iter = hierarchy.iterChildren(child); iter.valid(); iter.advance()) {
removeRecu... | java |
protected void findEigenVectors(double[][] imat, double[][] evs, double[] lambda) {
final int size = imat.length;
Random rnd = random.getSingleThreadedRandom();
double[] tmp = new double[size];
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Learning projections", tdim, LOG) : null;
for(... | java |
protected void randomInitialization(double[] out, Random rnd) {
double l2 = 0.;
while(!(l2 > 0)) {
for(int d = 0; d < out.length; d++) {
final double val = rnd.nextDouble();
out[d] = val;
l2 += val * val;
}
}
// Standardize:
final double s = 1. / FastMath.sqrt(l2)... | java |
protected double updateEigenvector(double[] in, double[] out, double l) {
double s = 1. / (l > 0. ? l : l < 0. ? -l : 1.);
s = (in[0] > 0.) ? s : -s; // Reduce flipping vectors
double diff = 0.;
for(int d = 0; d < in.length; d++) {
in[d] *= s; // Scale to unit length
// Compute change from p... | java |
protected void updateMatrix(double[][] mat, final double[] evec, double eval) {
final int size = mat.length;
for(int i = 0; i < size; i++) {
final double[] mati = mat[i];
final double eveci = evec[i];
for(int j = 0; j < size; j++) {
mati[j] -= eval * eveci * evec[j];
}
}
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.