idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
157,000
public void reInsert ( N node , IndexTreePath < E > path , int [ ] offs ) { final int depth = path . getPathCount ( ) ; long [ ] remove = BitsUtil . zero ( node . getCapacity ( ) ) ; List < E > reInsertEntries = new ArrayList <> ( offs . length ) ; for ( int i = 0 ; i < offs . length ; i ++ ) { reInsertEntries . add ( ...
Reinserts the specified node at the specified level .
400
11
157,001
private void condenseTree ( IndexTreePath < E > subtree , Stack < N > stack ) { N node = getNode ( subtree . getEntry ( ) ) ; // node is not root if ( ! isRoot ( node ) ) { N parent = getNode ( subtree . getParentPath ( ) . getEntry ( ) ) ; int index = subtree . getIndex ( ) ; if ( hasUnderflow ( node ) ) { if ( parent...
Condenses the tree after deletion of some nodes .
389
10
157,002
private void getLeafNodes ( N node , List < E > result , int currentLevel ) { // Level 1 are the leaf nodes, Level 2 is the one atop! if ( currentLevel == 2 ) { for ( int i = 0 ; i < node . getNumEntries ( ) ; i ++ ) { result . add ( node . getEntry ( i ) ) ; } } else { for ( int i = 0 ; i < node . getNumEntries ( ) ; ...
Determines the entries pointing to the leaf nodes of the specified subtree .
137
16
157,003
public static double angleDense ( NumberVector v1 , NumberVector v2 ) { final int dim1 = v1 . getDimensionality ( ) , dim2 = v2 . getDimensionality ( ) ; final int mindim = ( dim1 <= dim2 ) ? dim1 : dim2 ; // Essentially, we want to compute this: // v1.transposeTimes(v2) / (v1.euclideanLength() * v2.euclideanLength());...
Compute the absolute cosine of the angle between two dense vectors .
352
14
157,004
public static double angleSparse ( SparseNumberVector v1 , SparseNumberVector v2 ) { // TODO: exploit precomputed length, when available? double l1 = 0. , l2 = 0. , cross = 0. ; int i1 = v1 . iter ( ) , i2 = v2 . iter ( ) ; while ( v1 . iterValid ( i1 ) && v2 . iterValid ( i2 ) ) { final int d1 = v1 . iterDim ( i1 ) , ...
Compute the angle for sparse vectors .
482
8
157,005
public static double angleSparseDense ( SparseNumberVector v1 , NumberVector v2 ) { // TODO: exploit precomputed length, when available. final int dim2 = v2 . getDimensionality ( ) ; double l1 = 0. , l2 = 0. , cross = 0. ; int i1 = v1 . iter ( ) , d2 = 0 ; while ( v1 . iterValid ( i1 ) ) { final int d1 = v1 . iterDim (...
Compute the angle for a sparse and a dense vector .
397
12
157,006
public static double cosAngle ( NumberVector v1 , NumberVector v2 ) { // Java Hotspot appears to optimize these better than if-then-else: return v1 instanceof SparseNumberVector ? // v2 instanceof SparseNumberVector ? // angleSparse ( ( SparseNumberVector ) v1 , ( SparseNumberVector ) v2 ) : // angleSparseDense ( ( Spa...
Compute the absolute cosine of the angle between two vectors .
141
13
157,007
public static double minCosAngle ( SpatialComparable v1 , SpatialComparable v2 ) { if ( v1 instanceof NumberVector && v2 instanceof NumberVector ) { return cosAngle ( ( NumberVector ) v1 , ( NumberVector ) v2 ) ; } final int dim1 = v1 . getDimensionality ( ) , dim2 = v2 . getDimensionality ( ) ; final int mindim = ( di...
Compute the minimum angle between two rectangles .
705
10
157,008
public static double angle ( NumberVector v1 , NumberVector v2 , NumberVector o ) { final int dim1 = v1 . getDimensionality ( ) , dim2 = v2 . getDimensionality ( ) , dimo = o . getDimensionality ( ) ; final int mindim = ( dim1 <= dim2 ) ? dim1 : dim2 ; // Essentially, we want to compute this: // v1' = v1 - o, v2' = v2 ...
Compute the angle between two vectors with respect to a reference point .
452
14
157,009
public static double dotDense ( NumberVector v1 , NumberVector v2 ) { final int dim1 = v1 . getDimensionality ( ) , dim2 = v2 . getDimensionality ( ) ; final int mindim = ( dim1 <= dim2 ) ? dim1 : dim2 ; double dot = 0 ; for ( int k = 0 ; k < mindim ; k ++ ) { dot += v1 . doubleValue ( k ) * v2 . doubleValue ( k ) ; } ...
Compute the dot product of two dense vectors .
111
10
157,010
public static double dotSparse ( SparseNumberVector v1 , SparseNumberVector v2 ) { double dot = 0. ; int i1 = v1 . iter ( ) , i2 = v2 . iter ( ) ; while ( v1 . iterValid ( i1 ) && v2 . iterValid ( i2 ) ) { final int d1 = v1 . iterDim ( i1 ) , d2 = v2 . iterDim ( i2 ) ; if ( d1 < d2 ) { i1 = v1 . iterAdvance ( i1 ) ; } ...
Compute the dot product for two sparse vectors .
215
10
157,011
public static double dotSparseDense ( SparseNumberVector v1 , NumberVector v2 ) { final int dim2 = v2 . getDimensionality ( ) ; double dot = 0. ; for ( int i1 = v1 . iter ( ) ; v1 . iterValid ( i1 ) ; ) { final int d1 = v1 . iterDim ( i1 ) ; if ( d1 >= dim2 ) { break ; } dot += v1 . iterDoubleValue ( i1 ) * v2 . double...
Compute the dot product for a sparse and a dense vector .
137
13
157,012
public static double dot ( NumberVector v1 , NumberVector v2 ) { // Java Hotspot appears to optimize these better than if-then-else: return v1 instanceof SparseNumberVector ? // v2 instanceof SparseNumberVector ? // dotSparse ( ( SparseNumberVector ) v1 , ( SparseNumberVector ) v2 ) : // dotSparseDense ( ( SparseNumber...
Compute the dot product of the angle between two vectors .
139
12
157,013
public static double minDot ( SpatialComparable v1 , SpatialComparable v2 ) { if ( v1 instanceof NumberVector && v2 instanceof NumberVector ) { return dot ( ( NumberVector ) v1 , ( NumberVector ) v2 ) ; } final int dim1 = v1 . getDimensionality ( ) , dim2 = v2 . getDimensionality ( ) ; final int mindim = ( dim1 <= dim2...
Compute the minimum angle between two rectangles assuming unit length vectors
331
13
157,014
public static < V extends NumberVector > V project ( V v , long [ ] selectedAttributes , NumberVector . Factory < V > factory ) { int card = BitsUtil . cardinality ( selectedAttributes ) ; if ( factory instanceof SparseNumberVector . Factory ) { final SparseNumberVector . Factory < ? > sfactory = ( SparseNumberVector ....
Project a number vector to the specified attributes .
333
9
157,015
public void mergeWith ( Core o ) { o . num = this . num = ( num < o . num ? num : o . num ) ; }
Merge two cores .
32
5
157,016
public Clustering < Model > run ( Relation < ? > relation ) { HashMap < String , DBIDs > labelMap = multiple ? multipleAssignment ( relation ) : singleAssignment ( relation ) ; ModifiableDBIDs noiseids = DBIDUtil . newArray ( ) ; Clustering < Model > result = new Clustering <> ( "By Label Clustering" , "bylabel-cluster...
Run the actual clustering algorithm .
313
7
157,017
private HashMap < String , DBIDs > singleAssignment ( Relation < ? > data ) { HashMap < String , DBIDs > labelMap = new HashMap <> ( ) ; for ( DBIDIter iditer = data . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { final Object val = data . get ( iditer ) ; String label = ( val != null ) ? val . toString...
Assigns the objects of the database to single clusters according to their labels .
118
16
157,018
private HashMap < String , DBIDs > multipleAssignment ( Relation < ? > data ) { HashMap < String , DBIDs > labelMap = new HashMap <> ( ) ; for ( DBIDIter iditer = data . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { String [ ] labels = data . get ( iditer ) . toString ( ) . split ( " " ) ; for ( String ...
Assigns the objects of the database to multiple clusters according to their labels .
121
16
157,019
private void assign ( HashMap < String , DBIDs > labelMap , String label , DBIDRef id ) { if ( labelMap . containsKey ( label ) ) { DBIDs exist = labelMap . get ( label ) ; if ( exist instanceof DBID ) { ModifiableDBIDs n = DBIDUtil . newHashSet ( ) ; n . add ( ( DBID ) exist ) ; n . add ( id ) ; labelMap . put ( label...
Assigns the specified id to the labelMap according to its label
169
14
157,020
public void put ( double val ) { min = val < min ? val : min ; max = val > max ? val : max ; }
Process a single double value .
29
6
157,021
public static void addShadowFilter ( SVGPlot svgp ) { Element shadow = svgp . getIdElement ( SHADOW_ID ) ; if ( shadow == null ) { shadow = svgp . svgElement ( SVGConstants . SVG_FILTER_TAG ) ; shadow . setAttribute ( SVGConstants . SVG_ID_ATTRIBUTE , SHADOW_ID ) ; shadow . setAttribute ( SVGConstants . SVG_WIDTH_ATTRI...
Static method to prepare a SVG document for drop shadow effects .
544
12
157,022
public static void addLightGradient ( SVGPlot svgp ) { Element gradient = svgp . getIdElement ( LIGHT_GRADIENT_ID ) ; if ( gradient == null ) { gradient = svgp . svgElement ( SVGConstants . SVG_LINEAR_GRADIENT_TAG ) ; gradient . setAttribute ( SVGConstants . SVG_ID_ATTRIBUTE , LIGHT_GRADIENT_ID ) ; gradient . setAttrib...
Static method to prepare a SVG document for light gradient effects .
678
12
157,023
public static Element makeCheckmark ( SVGPlot svgp ) { Element checkmark = svgp . svgElement ( SVGConstants . SVG_PATH_TAG ) ; checkmark . setAttribute ( SVGConstants . SVG_D_ATTRIBUTE , SVG_CHECKMARK_PATH ) ; checkmark . setAttribute ( SVGConstants . SVG_FILL_ATTRIBUTE , SVGConstants . CSS_BLACK_VALUE ) ; checkmark . ...
Creates a 15x15 big checkmark
133
9
157,024
public double continueToMargin ( double [ ] origin , double [ ] delta ) { assert ( delta . length == 2 && origin . length == 2 ) ; double factor = Double . POSITIVE_INFINITY ; if ( delta [ 0 ] > 0 ) { factor = Math . min ( factor , ( maxx - origin [ 0 ] ) / delta [ 0 ] ) ; } else if ( delta [ 0 ] < 0 ) { factor = Math ...
Continue a line along a given direction to the margin .
194
11
157,025
@ Override public void clear ( ) { try { file . setLength ( header . size ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Clears this PageFile .
41
6
157,026
private double deviation ( double [ ] delta , double [ ] [ ] beta ) { final double a = squareSum ( delta ) ; final double b = squareSum ( transposeTimes ( beta , delta ) ) ; return ( a > b ) ? FastMath . sqrt ( a - b ) : 0. ; }
Deviation from a manifold described by beta .
66
9
157,027
private Separation findSeparation ( Relation < NumberVector > relation , DBIDs currentids , int dimension , Random r ) { Separation separation = new Separation ( ) ; // determine the number of samples needed, to secure that with a specific // probability // in at least on sample every sampled point is from the same clu...
This method samples a number of linear manifolds an tries to determine which the one with the best cluster is .
605
22
157,028
public double getDistance ( final DBIDRef o1 , final DBIDRef o2 ) { return FastMath . sqrt ( getSquaredDistance ( o1 , o2 ) ) ; }
Returns the kernel distance between the two specified objects .
41
10
157,029
public double getSquaredDistance ( final DBIDRef id1 , final DBIDRef id2 ) { final int o1 = idmap . getOffset ( id1 ) , o2 = idmap . getOffset ( id2 ) ; return kernel [ o1 ] [ o1 ] + kernel [ o2 ] [ o2 ] - 2 * kernel [ o1 ] [ o2 ] ; }
Returns the squared kernel distance between the two specified objects .
84
11
157,030
public double getSimilarity ( DBIDRef id1 , DBIDRef id2 ) { return kernel [ idmap . getOffset ( id1 ) ] [ idmap . getOffset ( id2 ) ] ; }
Get the kernel similarity for the given objects .
45
9
157,031
protected double [ ] [ ] initialMeans ( Database database , Relation < V > relation ) { Duration inittime = getLogger ( ) . newDuration ( initializer . getClass ( ) + ".time" ) . begin ( ) ; double [ ] [ ] means = initializer . chooseInitialMeans ( database , relation , k , getDistanceFunction ( ) ) ; getLogger ( ) . s...
Choose the initial means .
101
5
157,032
public static void plusEquals ( double [ ] sum , NumberVector vec ) { for ( int d = 0 ; d < sum . length ; d ++ ) { sum [ d ] += vec . doubleValue ( d ) ; } }
Similar to VMath . plusEquals but accepts a number vector .
49
14
157,033
public static void minusEquals ( double [ ] sum , NumberVector vec ) { for ( int d = 0 ; d < sum . length ; d ++ ) { sum [ d ] -= vec . doubleValue ( d ) ; } }
Similar to VMath . minusEquals but accepts a number vector .
49
14
157,034
public static void plusMinusEquals ( double [ ] add , double [ ] sub , NumberVector vec ) { for ( int d = 0 ; d < add . length ; d ++ ) { final double v = vec . doubleValue ( d ) ; add [ d ] += v ; sub [ d ] -= v ; } }
Add to one remove from another .
69
7
157,035
protected static void incrementalUpdateMean ( double [ ] mean , NumberVector vec , int newsize , double op ) { if ( newsize == 0 ) { return ; // Keep old mean } // Note: numerically stabilized version: VMath . plusTimesEquals ( mean , VMath . minusEquals ( vec . toArray ( ) , mean ) , op / newsize ) ; }
Compute an incremental update for the mean .
82
9
157,036
public static int fastModPrime ( long data ) { // Mix high and low 32 bit: int high = ( int ) ( data >>> 32 ) ; // Use fast multiplication with 5 for high: int alpha = ( ( int ) data ) + ( high << 2 + high ) ; // Note that in Java, PRIME will be negative. if ( alpha < 0 && alpha > - 5 ) { alpha = alpha + 5 ; } return a...
Fast modulo operation for the largest unsigned integer prime .
93
11
157,037
private void doRangeQuery ( DBID o_p , AbstractMTreeNode < O , ? , ? > node , O q , double r_q , ModifiableDoubleDBIDList result ) { double d1 = 0. ; if ( o_p != null ) { d1 = distanceQuery . distance ( o_p , q ) ; index . statistics . countDistanceCalculation ( ) ; } if ( ! node . isLeaf ( ) ) { for ( int i = 0 ; i < ...
Performs a range query on the specified subtree . It recursively traverses all paths from the specified node which cannot be excluded from leading to qualifying objects .
458
33
157,038
public static double pdf ( double x , double mu , double beta ) { final double z = ( x - mu ) / beta ; if ( x == Double . NEGATIVE_INFINITY ) { return 0. ; } return FastMath . exp ( - z - FastMath . exp ( - z ) ) / beta ; }
PDF of Gumbel distribution
69
6
157,039
public static double logpdf ( double x , double mu , double beta ) { if ( x == Double . NEGATIVE_INFINITY ) { return Double . NEGATIVE_INFINITY ; } final double z = ( x - mu ) / beta ; return - z - FastMath . exp ( - z ) - FastMath . log ( beta ) ; }
log PDF of Gumbel distribution
77
7
157,040
public static double cdf ( double val , double mu , double beta ) { return FastMath . exp ( - FastMath . exp ( - ( val - mu ) / beta ) ) ; }
CDF of Gumbel distribution
40
7
157,041
public static double quantile ( double val , double mu , double beta ) { return mu - beta * FastMath . log ( - FastMath . log ( val ) ) ; }
Quantile function of Gumbel distribution
37
8
157,042
public void setPartitions ( Relation < V > relation ) throws IllegalArgumentException { if ( ( FastMath . log ( partitions ) / FastMath . log ( 2 ) ) != ( int ) ( FastMath . log ( partitions ) / FastMath . log ( 2 ) ) ) { throw new IllegalArgumentException ( "Number of partitions must be a power of 2!" ) ; } final int ...
Initialize the data set grid by computing quantiles .
302
11
157,043
public long getScannedPages ( ) { int vacapacity = pageSize / VectorApproximation . byteOnDisk ( splitPositions . length , partitions ) ; long vasize = ( long ) Math . ceil ( ( vectorApprox . size ( ) ) / ( 1.0 * vacapacity ) ) ; return vasize * scans ; }
Get the number of scanned bytes .
75
7
157,044
private void hqr2BackTransformation ( int nn , int low , int high ) { for ( int j = nn - 1 ; j >= low ; j -- ) { final int last = j < high ? j : high ; for ( int i = low ; i <= high ; i ++ ) { final double [ ] Vi = V [ i ] ; double sum = 0. ; for ( int k = low ; k <= last ; k ++ ) { sum += Vi [ k ] * H [ k ] [ j ] ; } ...
Back transformation to get eigenvectors of original matrix .
124
12
157,045
protected static double gammaQuantileNewtonRefinement ( final double logpt , final double k , final double theta , final int maxit , double x ) { final double EPS_N = 1e-15 ; // Precision threshold // 0 is not possible, try MIN_NORMAL instead if ( x <= 0 ) { x = Double . MIN_NORMAL ; } // Current estimation double logp...
Refinement of ChiSquared probit using Newton iterations .
361
12
157,046
@ Override public Element useMarker ( SVGPlot plot , Element parent , double x , double y , int stylenr , double size ) { Element marker = plot . svgCircle ( x , y , size * .5 ) ; final String col ; if ( stylenr == - 1 ) { col = dotcolor ; } else if ( stylenr == - 2 ) { col = greycolor ; } else { col = colors . getColo...
Use a given marker on the document .
143
8
157,047
public Clustering < DendrogramModel > run ( PointerHierarchyRepresentationResult pointerresult ) { Clustering < DendrogramModel > result = new Instance ( pointerresult ) . run ( ) ; result . addChildResult ( pointerresult ) ; return result ; }
Process an existing result .
61
5
157,048
public static double erf ( double x ) { final double w = x < 0 ? - x : x ; double y ; if ( w < 2.2 ) { double t = w * w ; int k = ( int ) t ; t -= k ; k *= 13 ; y = ( ( ( ( ( ( ( ( ( ( ( ( ERF_COEFF1 [ k ] * t + ERF_COEFF1 [ k + 1 ] ) * t + // ERF_COEFF1 [ k + 2 ] ) * t + ERF_COEFF1 [ k + 3 ] ) * t + ERF_COEFF1 [ k + 4...
Error function for Gaussian distributions = Normal distributions .
568
10
157,049
public static double standardNormalQuantile ( double d ) { return ( d == 0 ) ? Double . NEGATIVE_INFINITY : // ( d == 1 ) ? Double . POSITIVE_INFINITY : // ( Double . isNaN ( d ) || d < 0 || d > 1 ) ? Double . NaN // : MathUtil . SQRT2 * - erfcinv ( 2 * d ) ; }
Approximate the inverse error function for normal distributions .
91
11
157,050
@ Override public < N extends SpatialComparable > List < List < N > > partition ( List < N > spatialObjects , int minEntries , int maxEntries ) { List < List < N >> partitions = new ArrayList <> ( ) ; List < N > objects = new ArrayList <> ( spatialObjects ) ; while ( ! objects . isEmpty ( ) ) { StringBuilder msg = new ...
Partitions the specified feature vectors where the split axes are the dimensions with maximum extension .
379
17
157,051
private int chooseMaximalExtendedSplitAxis ( List < ? extends SpatialComparable > objects ) { // maximum and minimum value for the extension int dimension = objects . get ( 0 ) . getDimensionality ( ) ; double [ ] maxExtension = new double [ dimension ] ; double [ ] minExtension = new double [ dimension ] ; Arrays . fi...
Computes and returns the best split axis . The best split axis is the split axes with the maximal extension .
281
22
157,052
public void setTotal ( int total ) throws IllegalArgumentException { if ( getProcessed ( ) > total ) { throw new IllegalArgumentException ( getProcessed ( ) + " exceeds total: " + total ) ; } this . total = total ; }
Modify the total value .
55
6
157,053
@ SuppressWarnings ( "unchecked" ) protected < T > T get ( DBIDRef id , int index ) { Object [ ] d = data . get ( DBIDUtil . deref ( id ) ) ; if ( d == null ) { return null ; } return ( T ) d [ index ] ; }
Actual getter .
70
5
157,054
@ SuppressWarnings ( "unchecked" ) protected < T > T set ( DBIDRef id , int index , T value ) { Object [ ] d = data . get ( DBIDUtil . deref ( id ) ) ; if ( d == null ) { d = new Object [ rlen ] ; data . put ( DBIDUtil . deref ( id ) , d ) ; } T ret = ( T ) d [ index ] ; d [ index ] = value ; return ret ; }
Actual setter .
109
5
157,055
public UniformDistribution estimate ( DoubleMinMax mm ) { return new UniformDistribution ( Math . max ( mm . getMin ( ) , - Double . MAX_VALUE ) , Math . min ( mm . getMax ( ) , Double . MAX_VALUE ) ) ; }
Estimate parameters from minimum and maximum observed .
57
9
157,056
public static boolean canVisualize ( Relation < ? > rel , AbstractMTree < ? , ? , ? , ? > tree ) { if ( ! TypeUtil . NUMBER_VECTOR_FIELD . isAssignableFromType ( rel . getDataTypeInformation ( ) ) ) { return false ; } return getLPNormP ( tree ) > 0 ; }
Test for a visualizable index in the context s database .
80
12
157,057
void initializeRandomAttributes ( SimpleTypeInformation < V > in ) { int d = ( ( VectorFieldTypeInformation < V > ) in ) . getDimensionality ( ) ; selectedAttributes = BitsUtil . random ( k , d , rnd . getSingleThreadedRandom ( ) ) ; }
Initialize random attributes .
63
5
157,058
protected void singleEnsemble ( final double [ ] ensemble , final NumberVector vec ) { double [ ] buf = new double [ 1 ] ; for ( int i = 0 ; i < ensemble . length ; i ++ ) { buf [ 0 ] = vec . doubleValue ( i ) ; ensemble [ i ] = voting . combine ( buf , 1 ) ; if ( Double . isNaN ( ensemble [ i ] ) ) { LOG . warning ( "...
Build a single - element ensemble .
132
7
157,059
public static String getFullDescription ( Parameter < ? > param ) { StringBuilder description = new StringBuilder ( 1000 ) // . append ( param . getShortDescription ( ) ) . append ( FormatUtil . NEWLINE ) ; param . describeValues ( description ) ; if ( ! FormatUtil . endsWith ( description , FormatUtil . NEWLINE ) ) { ...
Format a parameter description .
308
5
157,060
private static void println ( StringBuilder buf , int width , String data ) { for ( String line : FormatUtil . splitAtLastBlank ( data , width ) ) { buf . append ( line ) ; if ( ! line . endsWith ( FormatUtil . NEWLINE ) ) { buf . append ( FormatUtil . NEWLINE ) ; } } }
Simple writing helper with no indentation .
76
8
157,061
public static int centroids ( Relation < ? extends NumberVector > rel , List < ? extends Cluster < ? > > clusters , NumberVector [ ] centroids , NoiseHandling noiseOption ) { assert ( centroids . length == clusters . size ( ) ) ; int ignorednoise = 0 ; Iterator < ? extends Cluster < ? > > ci = clusters . iterator ( ) ;...
Compute centroids .
242
6
157,062
public static double cdf ( double val , double rate ) { final double v = .5 * FastMath . exp ( - rate * Math . abs ( val ) ) ; return ( v == Double . POSITIVE_INFINITY ) ? ( ( val <= 0 ) ? 0 : 1 ) : // ( val < 0 ) ? v : 1 - v ; }
Cumulative density static version
77
6
157,063
protected double maxDistance ( DoubleDBIDList elems ) { double max = 0 ; for ( DoubleDBIDListIter it = elems . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { final double v = it . doubleValue ( ) ; max = max > v ? max : v ; } return max ; }
Find maximum in a list via scanning .
73
8
157,064
protected void excludeNotCovered ( ModifiableDoubleDBIDList candidates , double fmax , ModifiableDoubleDBIDList collect ) { for ( DoubleDBIDListIter it = candidates . iter ( ) ; it . valid ( ) ; ) { if ( it . doubleValue ( ) > fmax ) { collect . add ( it . doubleValue ( ) , it ) ; candidates . removeSwap ( it . getOffs...
Retain all elements within the current cover .
108
9
157,065
protected void collectByCover ( DBIDRef cur , ModifiableDoubleDBIDList candidates , double fmax , ModifiableDoubleDBIDList collect ) { assert ( collect . size ( ) == 0 ) : "Not empty" ; DoubleDBIDListIter it = candidates . iter ( ) . advance ( ) ; // Except first = cur! while ( it . valid ( ) ) { assert ( ! DBIDUtil . ...
Collect all elements with respect to a new routing object .
161
11
157,066
private void process ( double [ ] data , double min , double max , KernelDensityFunction kernel , int window , double epsilon ) { dens = new double [ data . length ] ; var = new double [ data . length ] ; // This is the desired bandwidth of the kernel. double halfwidth = ( ( max - min ) / window ) * .5 ; for ( int curr...
Process a new array
318
4
157,067
public static double [ ] computeSimilarityMatrix ( DependenceMeasure sim , Relation < ? extends NumberVector > rel ) { final int dim = RelationUtil . dimensionality ( rel ) ; // TODO: we could use less memory (no copy), but this would likely be // slower. Maybe as a fallback option? double [ ] [ ] data = new double [ d...
Compute a column - wise dependency matrix for the given relation .
192
13
157,068
protected N buildSpanningTree ( int dim , double [ ] mat , Layout layout ) { assert ( layout . edges == null || layout . edges . size ( ) == 0 ) ; int [ ] iedges = PrimsMinimumSpanningTree . processDense ( mat , new LowerTriangularAdapter ( dim ) ) ; int root = findOptimalRoot ( iedges ) ; // Convert edges: ArrayList <...
Build the minimum spanning tree .
239
6
157,069
protected N buildTree ( int [ ] msg , int cur , int parent , ArrayList < N > nodes ) { // Count the number of children: int c = 0 ; for ( int i = 1 ; i < msg . length ; i += 2 ) { if ( ( msg [ i - 1 ] == cur && msg [ i ] != parent ) || ( msg [ i ] == cur && msg [ i - 1 ] != parent ) ) { c ++ ; } } // Build children: Li...
Recursive tree build method .
260
6
157,070
protected int maxDepth ( Layout . Node node ) { int depth = 0 ; for ( int i = 0 ; i < node . numChildren ( ) ; i ++ ) { depth = Math . max ( depth , maxDepth ( node . getChild ( i ) ) ) ; } return depth + 1 ; }
Compute the depth of the graph .
64
8
157,071
@ Override public void initialize ( ) { TreeIndexHeader header = createHeader ( ) ; if ( this . file . initialize ( header ) ) { initializeFromFile ( header , file ) ; } rootEntry = createRootEntry ( ) ; }
Initialize the tree if the page file already existed .
51
11
157,072
public N getNode ( int nodeID ) { if ( nodeID == getPageID ( rootEntry ) ) { return getRoot ( ) ; } else { return file . readPage ( nodeID ) ; } }
Returns the node with the specified id .
45
8
157,073
public void initializeFromFile ( TreeIndexHeader header , PageFile < N > file ) { this . dirCapacity = header . getDirCapacity ( ) ; this . leafCapacity = header . getLeafCapacity ( ) ; this . dirMinimum = header . getDirMinimum ( ) ; this . leafMinimum = header . getLeafMinimum ( ) ; if ( getLogger ( ) . isDebugging (...
Initializes this index from an existing persistent file .
158
10
157,074
protected final void initialize ( E exampleLeaf ) { initializeCapacities ( exampleLeaf ) ; // create empty root createEmptyRoot ( exampleLeaf ) ; final Logging log = getLogger ( ) ; if ( log . isStatistics ( ) ) { String cls = this . getClass ( ) . getName ( ) ; log . statistics ( new LongStatistic ( cls + ".directory....
Initializes the index .
173
5
157,075
public static MeanVarianceMinMax [ ] newArray ( int dimensionality ) { MeanVarianceMinMax [ ] arr = new MeanVarianceMinMax [ dimensionality ] ; for ( int i = 0 ; i < dimensionality ; i ++ ) { arr [ i ] = new MeanVarianceMinMax ( ) ; } return arr ; }
Create and initialize a new array of MeanVarianceMinMax
72
12
157,076
@ Override public double getWeight ( double distance , double max , double stddev ) { if ( stddev <= 0 ) { return 1 ; } double scaleddistance = distance / stddev ; return stddev * FastMath . exp ( - .5 * scaleddistance ) ; }
Get exponential weight max is ignored .
62
7
157,077
protected static < A > int [ ] sortedIndex ( final NumberArrayAdapter < ? , A > adapter , final A data , int len ) { int [ ] s1 = MathUtil . sequence ( 0 , len ) ; IntegerArrayQuickSort . sort ( s1 , ( x , y ) -> Double . compare ( adapter . getDouble ( data , x ) , adapter . getDouble ( data , y ) ) ) ; return s1 ; }
Build a sorted index of objects .
94
7
157,078
protected static < A > int [ ] discretize ( NumberArrayAdapter < ? , A > adapter , A data , final int len , final int bins ) { double min = adapter . getDouble ( data , 0 ) , max = min ; for ( int i = 1 ; i < len ; i ++ ) { double v = adapter . getDouble ( data , i ) ; if ( v < min ) { min = v ; } else if ( v > max ) {...
Discretize a data set into equi - width bin numbers .
207
14
157,079
protected void finishGridRow ( ) { GridBagConstraints constraints = new GridBagConstraints ( ) ; constraints . gridwidth = GridBagConstraints . REMAINDER ; constraints . weightx = 0 ; final JLabel icon ; if ( param . isOptional ( ) ) { if ( param . isDefined ( ) && param . tookDefaultValue ( ) && ! ( param instanceof F...
Complete the current grid row adding the icon at the end
268
11
157,080
private double normalize ( int d , double val ) { d = ( mean . length == 1 ) ? 0 : d ; return ( val - mean [ d ] ) / stddev [ d ] ; }
Normalize a single dimension .
44
6
157,081
private static EigenPair [ ] processDecomposition ( EigenvalueDecomposition evd ) { double [ ] eigenvalues = evd . getRealEigenvalues ( ) ; double [ ] [ ] eigenvectors = evd . getV ( ) ; EigenPair [ ] eigenPairs = new EigenPair [ eigenvalues . length ] ; for ( int i = 0 ; i < eigenvalues . length ; i ++ ) { double e = ...
Convert an eigenvalue decomposition into EigenPair objects .
182
15
157,082
public void nextIteration ( double [ ] [ ] means ) { this . means = means ; changed = false ; final int k = means . length ; final int dim = means [ 0 ] . length ; centroids = new double [ k ] [ dim ] ; sizes = new int [ k ] ; Arrays . fill ( varsum , 0. ) ; }
Initialize for a new iteration .
78
7
157,083
public double [ ] [ ] getMeans ( ) { double [ ] [ ] newmeans = new double [ centroids . length ] [ ] ; for ( int i = 0 ; i < centroids . length ; i ++ ) { if ( sizes [ i ] == 0 ) { newmeans [ i ] = means [ i ] ; // Keep old mean. continue ; } newmeans [ i ] = centroids [ i ] ; } return newmeans ; }
Get the new means .
103
5
157,084
public static String format ( double [ ] v , int w , int d ) { DecimalFormat format = new DecimalFormat ( ) ; format . setDecimalFormatSymbols ( new DecimalFormatSymbols ( Locale . US ) ) ; format . setMinimumIntegerDigits ( 1 ) ; format . setMaximumFractionDigits ( d ) ; format . setMinimumFractionDigits ( d ) ; forma...
Returns a string representation of this vector .
210
8
157,085
public static StringBuilder formatTo ( StringBuilder buf , double [ ] d , String sep ) { if ( d == null ) { return buf . append ( "null" ) ; } if ( d . length == 0 ) { return buf ; } buf . append ( d [ 0 ] ) ; for ( int i = 1 ; i < d . length ; i ++ ) { buf . append ( sep ) . append ( d [ i ] ) ; } return buf ; }
Formats the double array d with the default number format .
98
12
157,086
public static String format ( float [ ] f ) { return ( f == null ) ? "null" : ( f . length == 0 ) ? "" : // formatTo ( new StringBuilder ( ) , f , ", " ) . toString ( ) ; }
Formats the float array f with as separator and default precision .
54
14
157,087
public static String format ( int [ ] a , String sep ) { return ( a == null ) ? "null" : ( a . length == 0 ) ? "" : // formatTo ( new StringBuilder ( ) , a , sep ) . toString ( ) ; }
Formats the int array a for printing purposes .
56
10
157,088
public static String format ( boolean [ ] b , final String sep ) { return ( b == null ) ? "null" : ( b . length == 0 ) ? "" : // formatTo ( new StringBuilder ( ) , b , ", " ) . toString ( ) ; }
Formats the boolean array b with as separator .
58
11
157,089
public static String format ( double [ ] [ ] d ) { return d == null ? "null" : ( d . length == 0 ) ? "[]" : // formatTo ( new StringBuilder ( ) . append ( "[\n" ) , d , " [" , "]\n" , ", " , NF2 ) . append ( ' ' ) . toString ( ) ; }
Formats the double array d with as separator and 2 fraction digits .
81
15
157,090
public static String format ( double [ ] [ ] m , int w , int d , String pre , String pos , String csep ) { DecimalFormat format = new DecimalFormat ( ) ; format . setDecimalFormatSymbols ( new DecimalFormatSymbols ( Locale . US ) ) ; format . setMinimumIntegerDigits ( 1 ) ; format . setMaximumFractionDigits ( d ) ; for...
Returns a string representation of this matrix .
244
8
157,091
public static String format ( double [ ] [ ] m , NumberFormat nf ) { return formatTo ( new StringBuilder ( ) . append ( "[\n" ) , m , " [" , "]\n" , ", " , nf ) . append ( "]" ) . toString ( ) ; }
returns String - representation of Matrix .
66
8
157,092
public static String format ( Collection < String > d , String sep ) { if ( d == null ) { return "null" ; } if ( d . isEmpty ( ) ) { return "" ; } if ( d . size ( ) == 1 ) { return d . iterator ( ) . next ( ) ; } int len = sep . length ( ) * ( d . size ( ) - 1 ) ; for ( String s : d ) { len += s . length ( ) ; } Iterat...
Formats the String collection with the specified separator .
171
11
157,093
public static String format ( String [ ] d , String sep ) { if ( d == null ) { return "null" ; } if ( d . length == 0 ) { return "" ; } if ( d . length == 1 ) { return d [ 0 ] ; } int len = sep . length ( ) * ( d . length - 1 ) ; for ( String s : d ) { len += s . length ( ) ; } StringBuilder buffer = new StringBuilder ...
Formats the string array d with the specified separator .
152
12
157,094
public static int findSplitpoint ( String s , int width ) { // the newline (or EOS) is the fallback split position. int in = s . indexOf ( NEWLINE ) ; in = in < 0 ? s . length ( ) : in ; // Good enough? if ( in < width ) { return in ; } // otherwise, search for whitespace int iw = s . lastIndexOf ( ' ' , width ) ; // g...
Find the first space before position w or if there is none after w .
191
15
157,095
public static List < String > splitAtLastBlank ( String s , int width ) { List < String > chunks = new ArrayList <> ( ) ; String tmp = s ; while ( tmp . length ( ) > 0 ) { int index = findSplitpoint ( tmp , width ) ; // store first part chunks . add ( tmp . substring ( 0 , index ) ) ; // skip whitespace at beginning of...
Splits the specified string at the last blank before width . If there is no blank before the given width it is split at the next .
191
28
157,096
public static String pad ( String o , int len ) { return o . length ( ) >= len ? o : ( o + whitespace ( len - o . length ( ) ) ) ; }
Pad a string to a given length by adding whitespace to the right .
40
15
157,097
public static String padRightAligned ( String o , int len ) { return o . length ( ) >= len ? o : ( whitespace ( len - o . length ( ) ) + o ) ; }
Pad a string to a given length by adding whitespace to the left .
43
15
157,098
public static String formatTimeDelta ( long time , CharSequence sep ) { final StringBuilder sb = new StringBuilder ( ) ; final Formatter fmt = new Formatter ( sb ) ; for ( int i = TIME_UNIT_SIZES . length - 1 ; i >= 0 ; -- i ) { // We do not include ms if we are in the order of minutes. if ( i == 0 && sb . length ( ) >...
Formats a time delta in human readable format .
246
10
157,099
public static StringBuilder appendZeros ( StringBuilder buf , int zeros ) { for ( int i = zeros ; i > 0 ; i -= ZEROPADDING . length ) { buf . append ( ZEROPADDING , 0 , i < ZEROPADDING . length ? i : ZEROPADDING . length ) ; } return buf ; }
Append zeros to a buffer .
78
8