idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
34,400
public OutlierResult run ( Relation < V > relation ) { final DBIDs ids = relation . getDBIDs ( ) ; ArrayList < ArrayDBIDs > subspaceIndex = buildOneDimIndexes ( relation ) ; Set < HiCSSubspace > subspaces = calculateSubspaces ( relation , subspaceIndex , rnd . getSingleThreadedRandom ( ) ) ; if ( LOG . isVerbose ( ) ) ...
Perform HiCS on a given database .
34,401
private ArrayList < ArrayDBIDs > buildOneDimIndexes ( Relation < ? extends NumberVector > relation ) { final int dim = RelationUtil . dimensionality ( relation ) ; ArrayList < ArrayDBIDs > subspaceIndex = new ArrayList < > ( dim + 1 ) ; SortDBIDsBySingleDimension comp = new VectorUtil . SortDBIDsBySingleDimension ( rel...
Calculates index structures for every attribute i . e . sorts a ModifiableArray of every DBID in the database for every dimension and stores them in a list
34,402
private double [ ] max ( double [ ] distances1 , double [ ] distances2 ) { if ( distances1 . length != distances2 . length ) { throw new RuntimeException ( "different lengths!" ) ; } double [ ] result = new double [ distances1 . length ] ; for ( int i = 0 ; i < distances1 . length ; i ++ ) { result [ i ] = Math . max (...
Returns an array that holds the maximum values of the both specified arrays in each index .
34,403
public static int compileShader ( Class < ? > context , GL2 gl , int type , String name ) throws ShaderCompilationException { int prog = - 1 ; try ( InputStream in = context . getResourceAsStream ( name ) ) { int [ ] error = new int [ 1 ] ; String shaderdata = FileUtil . slurp ( in ) ; prog = gl . glCreateShader ( type...
Compile a shader from a file .
34,404
protected int effectiveBandSize ( final int dim1 , final int dim2 ) { if ( bandSize == Double . POSITIVE_INFINITY ) { return ( dim1 > dim2 ) ? dim1 : dim2 ; } if ( bandSize >= 1. ) { return ( int ) bandSize ; } return ( int ) Math . ceil ( ( dim1 >= dim2 ? dim1 : dim2 ) * bandSize ) ; }
Compute the effective band size .
34,405
public final int addLeafEntry ( E entry ) { if ( ! ( entry instanceof LeafEntry ) ) { throw new UnsupportedOperationException ( "Entry is not a leaf entry!" ) ; } if ( ! isLeaf ( ) ) { throw new UnsupportedOperationException ( "Node is not a leaf node!" ) ; } return addEntry ( entry ) ; }
Adds a new leaf entry to this node s children and returns the index of the entry in this node s children array . An UnsupportedOperationException will be thrown if the entry is not a leaf entry or this node is not a leaf node .
34,406
public final int addDirectoryEntry ( E entry ) { if ( entry instanceof LeafEntry ) { throw new UnsupportedOperationException ( "Entry is not a directory entry!" ) ; } if ( isLeaf ( ) ) { throw new UnsupportedOperationException ( "Node is not a directory node!" ) ; } return addEntry ( entry ) ; }
Adds a new directory entry to this node s children and returns the index of the entry in this node s children array . An UnsupportedOperationException will be thrown if the entry is not a directory entry or this node is not a directory node .
34,407
public boolean deleteEntry ( int index ) { System . arraycopy ( entries , index + 1 , entries , index , numEntries - index - 1 ) ; entries [ -- numEntries ] = null ; return true ; }
Deletes the entry at the specified index and shifts all entries after the index to left .
34,408
@ SuppressWarnings ( "unchecked" ) public final List < E > getEntries ( ) { List < E > result = new ArrayList < > ( numEntries ) ; for ( Entry entry : entries ) { if ( entry != null ) { result . add ( ( E ) entry ) ; } } return result ; }
Returns a list of the entries .
34,409
public void removeMask ( long [ ] mask ) { int dest = BitsUtil . nextSetBit ( mask , 0 ) ; if ( dest < 0 ) { return ; } int src = BitsUtil . nextSetBit ( mask , dest ) ; while ( src < numEntries ) { if ( ! BitsUtil . get ( mask , src ) ) { entries [ dest ] = entries [ src ] ; dest ++ ; } src ++ ; } int rm = src - dest ...
Remove entries according to the given mask .
34,410
public final void splitTo ( AbstractNode < E > newNode , List < E > sorting , int splitPoint ) { assert ( isLeaf ( ) == newNode . isLeaf ( ) ) ; deleteAllEntries ( ) ; StringBuilder msg = LoggingConfiguration . DEBUG ? new StringBuilder ( 1000 ) : null ; for ( int i = 0 ; i < splitPoint ; i ++ ) { addEntry ( sorting . ...
Redistribute entries according to the given sorting .
34,411
public static void ensureClusteringResult ( final Database db , final Result result ) { Collection < Clustering < ? > > clusterings = ResultUtil . filterResults ( db . getHierarchy ( ) , result , Clustering . class ) ; if ( clusterings . isEmpty ( ) ) { ResultUtil . addChildResult ( db , new ByLabelOrAllInOneClustering...
Ensure that the result contains at least one Clustering .
34,412
public static < A > double [ ] toPrimitiveDoubleArray ( A data , NumberArrayAdapter < ? , A > adapter ) { if ( adapter == DoubleArrayAdapter . STATIC ) { return ( ( double [ ] ) data ) . clone ( ) ; } final int len = adapter . size ( data ) ; double [ ] x = new double [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { x [ ...
Local copy see ArrayLikeUtil . toPrimitiveDoubleArray .
34,413
public void flush ( ) { try { out . flush ( ) ; } catch ( Exception ex ) { reportError ( null , ex , ErrorManager . FLUSH_FAILURE ) ; } try { err . flush ( ) ; } catch ( Exception ex ) { reportError ( null , ex , ErrorManager . FLUSH_FAILURE ) ; } }
Flush output streams
34,414
public void publish ( final LogRecord record ) { final Writer destination ; if ( record . getLevel ( ) . intValue ( ) >= Level . WARNING . intValue ( ) ) { destination = this . err ; } else { destination = this . out ; } final String m ; if ( record instanceof ProgressLogRecord ) { ProgressLogRecord prec = ( ProgressLo...
Publish a log record .
34,415
private boolean checkForNaNs ( NumberVector vec ) { for ( int i = 0 , d = vec . getDimensionality ( ) ; i < d ; i ++ ) { double v = vec . doubleValue ( i ) ; if ( v != v ) { return true ; } } return false ; }
Check for NaN values .
34,416
public static Relation < String > guessLabelRepresentation ( Database database ) throws NoSupportedDataTypeException { try { Relation < ? extends ClassLabel > classrep = database . getRelation ( TypeUtil . CLASSLABEL ) ; if ( classrep != null ) { return new ConvertToStringView ( classrep ) ; } } catch ( NoSupportedData...
Guess a potentially label - like representation preferring class labels .
34,417
public static ArrayModifiableDBIDs getObjectsByLabelMatch ( Database database , Pattern name_pattern ) { Relation < String > relation = guessLabelRepresentation ( database ) ; if ( name_pattern == null ) { return DBIDUtil . newArray ( ) ; } ArrayModifiableDBIDs ret = DBIDUtil . newArray ( ) ; for ( DBIDIter iditer = re...
Find object by matching their labels .
34,418
public void writeExternal ( ObjectOutput out ) throws IOException { super . writeExternal ( out ) ; out . writeObject ( conservativeApproximation ) ; }
Calls the super method and writes the conservative approximation of the knn distances of this entry to the specified stream .
34,419
public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { super . readExternal ( in ) ; conservativeApproximation = ( ApproximationLine ) in . readObject ( ) ; }
Calls the super method and reads the the conservative approximation of the knn distances of this entry from the specified input stream .
34,420
protected void updateDensities ( WritableDoubleDataStore rbod_score , DoubleDBIDList referenceDists ) { DoubleDBIDListIter it = referenceDists . iter ( ) ; for ( int l = 0 ; l < referenceDists . size ( ) ; l ++ ) { double density = computeDensity ( referenceDists , it , l ) ; it . seek ( l ) ; if ( ! ( density > rbod_s...
Update the density estimates for each object .
34,421
static void chooseRemaining ( Relation < ? extends NumberVector > relation , DBIDs ids , DistanceQuery < NumberVector > distQ , int k , List < NumberVector > means , WritableDoubleDataStore weights , double weightsum , Random random ) { while ( true ) { if ( weightsum > Double . MAX_VALUE ) { throw new IllegalStateExce...
Choose remaining means weighted by distance .
34,422
private double factor ( int dimension ) { return maxima [ dimension ] > minima [ dimension ] ? maxima [ dimension ] - minima [ dimension ] : maxima [ dimension ] > 0 ? maxima [ dimension ] : 1 ; }
Returns a factor for normalization in a certain dimension .
34,423
protected double derivative ( int i , NumberVector v ) { final int dim = v . getDimensionality ( ) ; if ( dim == 1 ) { return 0. ; } i = ( i == 0 ) ? 1 : ( i == dim - 1 ) ? dim - 2 : i ; return ( v . doubleValue ( i ) - v . doubleValue ( i - 1 ) + ( v . doubleValue ( i + 1 ) - v . doubleValue ( i - 1 ) ) * .5 ) * .5 ; ...
Given a NumberVector and the position of an element approximates the gradient of given element .
34,424
public Assignments < E > split ( AbstractMTree < ? , N , E , ? > tree , N node ) { final int n = node . getNumEntries ( ) ; int pos1 = random . nextInt ( n ) , pos2 = random . nextInt ( n - 1 ) ; pos2 = pos2 >= pos1 ? pos2 + 1 : pos2 ; double [ ] dis1 = new double [ n ] , dis2 = new double [ n ] ; E e1 = node . getEntr...
Selects two objects of the specified node to be promoted and stored into the parent node . The m - RAD strategy considers all possible pairs of objects and after partitioning the set of entries promotes the pair of objects for which the sum of covering radiuses is minimum .
34,425
public static boolean checkCSSStatements ( Collection < Pair < String , String > > statements ) { for ( Pair < String , String > pair : statements ) { if ( ! checkCSSStatement ( pair . getFirst ( ) , pair . getSecond ( ) ) ) { return false ; } } return true ; }
Validate a set of CSS statements .
34,426
public String getStatement ( String key ) { for ( Pair < String , String > pair : statements ) { if ( pair . getFirst ( ) . equals ( key ) ) { return pair . getSecond ( ) ; } } return null ; }
Get the current value of a particular CSS statement .
34,427
public void setStatement ( String key , String value ) { if ( value != null && ! checkCSSStatement ( key , value ) ) { throw new InvalidCSS ( "Invalid CSS statement." ) ; } for ( Pair < String , String > pair : statements ) { if ( pair . getFirst ( ) . equals ( key ) ) { if ( value != null ) { pair . setSecond ( value ...
Set a CSS statement .
34,428
public void appendCSSDefinition ( StringBuilder buf ) { buf . append ( "\n." ) ; buf . append ( name ) ; buf . append ( '{' ) ; for ( Pair < String , String > pair : statements ) { buf . append ( pair . getFirst ( ) ) ; buf . append ( ':' ) ; buf . append ( pair . getSecond ( ) ) ; buf . append ( ";\n" ) ; } buf . appe...
Append CSS definition to a stream
34,429
public String inlineCSS ( ) { StringBuilder buf = new StringBuilder ( ) ; for ( Pair < String , String > pair : statements ) { buf . append ( pair . getFirst ( ) ) ; buf . append ( ':' ) ; buf . append ( pair . getSecond ( ) ) ; buf . append ( ';' ) ; } return buf . toString ( ) ; }
Render CSS class to inline formatting
34,430
protected Distribution findBestFit ( final List < V > col , Adapter adapter , int d , double [ ] test ) { if ( estimators . size ( ) == 1 ) { return estimators . get ( 0 ) . estimate ( col , adapter ) ; } Distribution best = null ; double bestq = Double . POSITIVE_INFINITY ; trials : for ( DistributionEstimator < ? > e...
Find the best fitting distribution .
34,431
protected boolean constantZero ( List < V > column , Adapter adapter ) { for ( int i = 0 , s = adapter . size ( column ) ; i < s ; i ++ ) { if ( adapter . get ( column , i ) != 0. ) { return false ; } } return true ; }
Test if an attribute is constant zero .
34,432
private StreamTokenizer makeArffTokenizer ( BufferedReader br ) { StreamTokenizer tokenizer = new StreamTokenizer ( br ) ; { tokenizer . resetSyntax ( ) ; tokenizer . whitespaceChars ( 0 , ' ' ) ; tokenizer . ordinaryChars ( '0' , '9' ) ; tokenizer . ordinaryChar ( '-' ) ; tokenizer . ordinaryChar ( '.' ) ; tokenizer ....
Make a StreamTokenizer for the ARFF format .
34,433
private void setupBundleHeaders ( ArrayList < String > names , int [ ] targ , TypeInformation [ ] etyp , int [ ] dimsize , MultipleObjectsBundle bundle , boolean sparse ) { for ( int in = 0 , out = 0 ; in < targ . length ; out ++ ) { int nin = in + 1 ; for ( ; nin < targ . length ; nin ++ ) { if ( targ [ nin ] != targ ...
Setup the headers for the object bundle .
34,434
private void readHeader ( BufferedReader br ) throws IOException { String line ; while ( true ) { line = br . readLine ( ) ; if ( line == null ) { throw new AbortException ( ARFF_HEADER_RELATION + " not found in file." ) ; } if ( ARFF_COMMENT . reset ( line ) . matches ( ) || EMPTY . reset ( line ) . matches ( ) ) { co...
Read the dataset header part of the ARFF file to ensure consistency .
34,435
private void nextToken ( StreamTokenizer tokenizer ) throws IOException { tokenizer . nextToken ( ) ; if ( ( tokenizer . ttype == '\'' ) || ( tokenizer . ttype == '"' ) ) { tokenizer . ttype = StreamTokenizer . TT_WORD ; } else if ( ( tokenizer . ttype == StreamTokenizer . TT_WORD ) && ( tokenizer . sval . equals ( "?"...
Helper function for token handling .
34,436
public static < E extends ClusterOrder > Clustering < Model > makeOPTICSCut ( E co , double epsilon ) { Clustering < Model > clustering = new Clustering < > ( "OPTICS Cut Clustering" , "optics-cut" ) ; ModifiableDBIDs noise = DBIDUtil . newHashSet ( ) ; double lastDist = Double . MAX_VALUE ; double actDist = Double . M...
Compute an OPTICS cut clustering
34,437
public static LabelList make ( Collection < String > labels ) { int size = labels . size ( ) ; if ( size == 0 ) { return EMPTY_LABELS ; } return new LabelList ( labels . toArray ( new String [ size ] ) ) ; }
Constructor replacement .
34,438
public Clustering < SubspaceModel > run ( Database db , Relation < V > relation ) { if ( mu >= relation . size ( ) ) { throw new AbortException ( "Parameter mu is chosen unreasonably large. This won't yield meaningful results." ) ; } DiSHClusterOrder opticsResult = new Instance ( db , relation ) . run ( ) ; if ( LOG . ...
Performs the DiSH algorithm on the given database .
34,439
private Clustering < SubspaceModel > computeClusters ( Relation < V > database , DiSHClusterOrder clusterOrder ) { final int dimensionality = RelationUtil . dimensionality ( database ) ; Object2ObjectOpenCustomHashMap < long [ ] , List < ArrayModifiableDBIDs > > clustersMap = extractClusters ( database , clusterOrder )...
Computes the hierarchical clusters according to the cluster order .
34,440
private void logClusterSizes ( String m , int dimensionality , Object2ObjectOpenCustomHashMap < long [ ] , List < ArrayModifiableDBIDs > > clustersMap ) { if ( LOG . isVerbose ( ) ) { final StringBuilder msg = new StringBuilder ( 1000 ) . append ( m ) . append ( '\n' ) ; for ( ObjectIterator < Object2ObjectMap . Entry ...
Log cluster sizes in verbose mode .
34,441
private List < Cluster < SubspaceModel > > sortClusters ( Relation < V > relation , Object2ObjectMap < long [ ] , List < ArrayModifiableDBIDs > > clustersMap ) { final int db_dim = RelationUtil . dimensionality ( relation ) ; List < Cluster < SubspaceModel > > clusters = new ArrayList < > ( ) ; for ( long [ ] pv : clus...
Returns a sorted list of the clusters w . r . t . the subspace dimensionality in descending order .
34,442
private void checkClusters ( Relation < V > relation , Object2ObjectMap < long [ ] , List < ArrayModifiableDBIDs > > clustersMap ) { final int dimensionality = RelationUtil . dimensionality ( relation ) ; List < Pair < long [ ] , ArrayModifiableDBIDs > > notAssigned = new ArrayList < > ( ) ; Object2ObjectMap < long [ ]...
Removes the clusters with size &lt ; minpts from the cluster map and adds them to their parents .
34,443
private Pair < long [ ] , ArrayModifiableDBIDs > findParent ( Relation < V > relation , Pair < long [ ] , ArrayModifiableDBIDs > child , Object2ObjectMap < long [ ] , List < ArrayModifiableDBIDs > > clustersMap ) { Centroid child_centroid = ProjectedCentroid . make ( child . first , relation , child . second ) ; Pair <...
Returns the parent of the specified cluster
34,444
private int subspaceDimensionality ( NumberVector v1 , NumberVector v2 , long [ ] pv1 , long [ ] pv2 , long [ ] commonPreferenceVector ) { int subspaceDim = v1 . getDimensionality ( ) - BitsUtil . cardinality ( commonPreferenceVector ) ; if ( BitsUtil . equal ( commonPreferenceVector , pv1 ) || BitsUtil . equal ( commo...
Compute the common subspace dimensionality of two vectors .
34,445
protected static double weightedDistance ( NumberVector v1 , NumberVector v2 , long [ ] weightVector ) { double sqrDist = 0 ; for ( int i = BitsUtil . nextSetBit ( weightVector , 0 ) ; i >= 0 ; i = BitsUtil . nextSetBit ( weightVector , i + 1 ) ) { double manhattanI = v1 . doubleValue ( i ) - v2 . doubleValue ( i ) ; s...
Computes the weighted distance between the two specified vectors according to the given preference vector .
34,446
public double [ ] [ ] processIds ( DBIDs ids , Relation < ? extends NumberVector > database ) { return CovarianceMatrix . make ( database , ids ) . destroyToPopulationMatrix ( ) ; }
Compute Covariance Matrix for a collection of database IDs .
34,447
private void updateMeta ( ) { meta = new BundleMeta ( ) ; BundleMeta origmeta = source . getMeta ( ) ; for ( int i = 0 ; i < origmeta . size ( ) ; i ++ ) { SimpleTypeInformation < ? > type = origmeta . get ( i ) ; if ( column < 0 ) { if ( TypeUtil . NUMBER_VECTOR_VARIABLE_LENGTH . isAssignableFromType ( type ) ) { if (...
Update metadata .
34,448
public static double logquantile ( double val , double loc , double scale ) { return loc + scale * ( val - MathUtil . log1mexp ( - val ) ) ; }
log Quantile function .
34,449
public static < C extends Model > void logClusterSizes ( Clustering < C > c ) { if ( ! LOG . isStatistics ( ) ) { return ; } final List < Cluster < C > > clusters = c . getAllClusters ( ) ; final int numc = clusters . size ( ) ; LOG . statistics ( new StringStatistic ( PREFIX + "name" , c . getLongName ( ) ) ) ; LOG . ...
Log the cluster sizes of a clustering .
34,450
public void addDenseUnit ( CLIQUEUnit unit ) { int numdim = unit . dimensionality ( ) ; for ( int i = 0 ; i < numdim ; i ++ ) { BitsUtil . setI ( getDimensions ( ) , unit . getDimension ( i ) ) ; } denseUnits . add ( unit ) ; coverage += unit . numberOfFeatureVectors ( ) ; }
Adds the specified dense unit to this subspace .
34,451
public List < Pair < Subspace , ModifiableDBIDs > > determineClusters ( ) { List < Pair < Subspace , ModifiableDBIDs > > clusters = new ArrayList < > ( ) ; for ( CLIQUEUnit unit : denseUnits ) { if ( ! unit . isAssigned ( ) ) { ModifiableDBIDs cluster = DBIDUtil . newHashSet ( ) ; CLIQUESubspace model = new CLIQUESubsp...
Determines all clusters in this subspace by performing a depth - first search algorithm to find connected dense units .
34,452
public void dfs ( CLIQUEUnit unit , ModifiableDBIDs cluster , CLIQUESubspace model ) { cluster . addDBIDs ( unit . getIds ( ) ) ; unit . markAsAssigned ( ) ; model . addDenseUnit ( unit ) ; final long [ ] dims = getDimensions ( ) ; for ( int dim = BitsUtil . nextSetBit ( dims , 0 ) ; dim >= 0 ; dim = BitsUtil . nextSet...
Depth - first search algorithm to find connected dense units in this subspace that build a cluster . It starts with a unit assigns it to a cluster and finds all units it is connected to .
34,453
protected CLIQUEUnit leftNeighbor ( CLIQUEUnit unit , int dim ) { for ( CLIQUEUnit u : denseUnits ) { if ( u . containsLeftNeighbor ( unit , dim ) ) { return u ; } } return null ; }
Returns the left neighbor of the given unit in the specified dimension .
34,454
protected CLIQUEUnit rightNeighbor ( CLIQUEUnit unit , int dim ) { for ( CLIQUEUnit u : denseUnits ) { if ( u . containsRightNeighbor ( unit , dim ) ) { return u ; } } return null ; }
Returns the right neighbor of the given unit in the specified dimension .
34,455
private IntIterator getCommonSplitDimensions ( N node ) { Collection < SplitHistory > splitHistories = new ArrayList < > ( node . getNumEntries ( ) ) ; for ( int i = 0 ; i < node . getNumEntries ( ) ; i ++ ) { SpatialEntry entry = node . getEntry ( i ) ; if ( ! ( entry instanceof XTreeDirectoryEntry ) ) { throw new Run...
Determine the common split dimensions from a list of entries .
34,456
private HyperBoundingBox mbr ( final int [ ] entries , final int from , final int to ) { SpatialEntry first = this . node . getEntry ( entries [ from ] ) ; ModifiableHyperBoundingBox mbr = new ModifiableHyperBoundingBox ( first ) ; for ( int i = from + 1 ; i < to ; i ++ ) { mbr . extend ( this . node . getEntry ( entri...
Computes and returns the mbr of the specified nodes only the nodes between from and to index are considered .
34,457
private void ensureSize ( int minsize ) { if ( minsize <= store . length ) { return ; } int asize = store . length ; while ( asize < minsize ) { asize = ( asize >>> 1 ) + asize ; } final int [ ] prev = store ; store = new int [ asize ] ; System . arraycopy ( prev , 0 , store , 0 , size ) ; }
Resize as desired .
34,458
private void grow ( ) { final int newsize = store . length + ( store . length >>> 1 ) ; final int [ ] prev = store ; store = new int [ newsize ] ; System . arraycopy ( prev , 0 , store , 0 , size ) ; }
Grow array by 50% .
34,459
public static double sumOfProbabilities ( DBIDIter ignore , DBIDArrayIter di , double [ ] p ) { double s = 0 ; for ( di . seek ( 0 ) ; di . valid ( ) ; di . advance ( ) ) { if ( DBIDUtil . equal ( ignore , di ) ) { continue ; } final double v = p [ di . getOffset ( ) ] ; if ( ! ( v > 0 ) ) { break ; } s += v ; } return...
Compute the sum of probabilities stop at first 0 ignore query object .
34,460
public synchronized static Task queue ( Listener callback ) { final Task task = new Task ( callback ) ; if ( THREAD != null && THREAD . isAlive ( ) ) { THREAD . queue . add ( task ) ; return task ; } THREAD = new ThumbnailThread ( ) ; THREAD . queue . add ( task ) ; THREAD . start ( ) ; return task ; }
Queue a thumbnail task in a global thumbnail thread .
34,461
public static void unqueue ( Task task ) { if ( THREAD != null ) { synchronized ( THREAD ) { THREAD . queue . remove ( task ) ; } } }
Remove a pending task from the queue .
34,462
public void beginStep ( int step , String stepTitle , Logging logger ) { setProcessed ( step - 1 ) ; this . stepTitle = stepTitle ; logger . progress ( this ) ; }
Do a new step and log it
34,463
protected static HyperBoundingBox computeBounds ( NumberVector [ ] samples ) { assert ( samples . length > 0 ) : "Cannot compute bounding box of empty set." ; final int dimensions = samples [ 0 ] . getDimensionality ( ) ; final double [ ] min = new double [ dimensions ] ; final double [ ] max = new double [ dimensions ...
Compute the bounding box for some samples .
34,464
protected void preprocess ( ) { final Logging log = getLogger ( ) ; createStorage ( ) ; ArrayDBIDs ids = DBIDUtil . ensureArray ( relation . getDBIDs ( ) ) ; if ( log . isStatistics ( ) ) { log . statistics ( new LongStatistic ( this . getClass ( ) . getName ( ) + ".k" , k ) ) ; } Duration duration = log . isStatistics...
The actual preprocessing step .
34,465
protected void objectsInserted ( DBIDs ids ) { final Logging log = getLogger ( ) ; StepProgress stepprog = log . isVerbose ( ) ? new StepProgress ( 3 ) : null ; ArrayDBIDs aids = DBIDUtil . ensureArray ( ids ) ; log . beginStep ( stepprog , 1 , "New insertions ocurred, materialize their new kNNs." ) ; List < ? extends ...
Called after new objects have been inserted updates the materialized neighborhood .
34,466
protected void objectsRemoved ( DBIDs ids ) { final Logging log = getLogger ( ) ; StepProgress stepprog = log . isVerbose ( ) ? new StepProgress ( 3 ) : null ; log . beginStep ( stepprog , 1 , "New deletions ocurred, remove their materialized kNNs." ) ; for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . a...
Called after objects have been removed updates the materialized neighborhood .
34,467
protected void fireKNNsInserted ( DBIDs insertions , DBIDs updates ) { KNNChangeEvent e = new KNNChangeEvent ( this , KNNChangeEvent . Type . INSERT , insertions , updates ) ; Object [ ] listeners = listenerList . getListenerList ( ) ; for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( listeners [ i ] == K...
Informs all registered KNNListener that new kNNs have been inserted and as a result some kNNs have been changed .
34,468
protected void fireKNNsRemoved ( DBIDs removals , DBIDs updates ) { KNNChangeEvent e = new KNNChangeEvent ( this , KNNChangeEvent . Type . DELETE , removals , updates ) ; Object [ ] listeners = listenerList . getListenerList ( ) ; for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) { if ( listeners [ i ] == KNNLis...
Informs all registered KNNListener that existing kNNs have been removed and as a result some kNNs have been changed .
34,469
public void buildClassifier ( Database database , Relation < ? extends ClassLabel > labelrep ) { Object2IntOpenHashMap < ClassLabel > count = new Object2IntOpenHashMap < > ( ) ; for ( DBIDIter iter = labelrep . iterDBIDs ( ) ; iter . valid ( ) ; iter . advance ( ) ) { count . addTo ( labelrep . get ( iter ) , 1 ) ; } i...
Learns the prior probability for all classes .
34,470
public Assignments < E > split ( AbstractMTree < ? , N , E , ? > tree , N node ) { final int n = node . getNumEntries ( ) ; double [ ] [ ] distanceMatrix = computeDistanceMatrix ( tree , node ) ; double miSumCR = Double . POSITIVE_INFINITY ; boolean leaf = node . isLeaf ( ) ; Assignments < E > bestAssignment = null ; f...
Selects two objects of the specified node to be promoted and stored into the parent node . The mM - RAD strategy considers all possible pairs of objects and after partitioning the set of entries promotes the pair of objects for which the larger of the two covering radiuses is minimum .
34,471
public static double [ ] [ ] unboxVectors ( List < ? extends NumberVector > means ) { double [ ] [ ] ret = new double [ means . size ( ) ] [ ] ; for ( int i = 0 ; i < ret . length ; i ++ ) { ret [ i ] = means . get ( i ) . toArray ( ) ; } return ret ; }
Unbox database means to primitive means .
34,472
public void put ( double x , double y , double w ) { if ( w == 0. ) { return ; } if ( sumWe <= 0. ) { sumX = x * w ; sumY = y * w ; sumWe = w ; return ; } final double deltaX = x * sumWe - sumX ; final double deltaY = y * sumWe - sumY ; final double oldWe = sumWe ; sumWe += w ; final double f = w / ( sumWe * oldWe ) ; ...
Put a single value into the correlation statistic .
34,473
public double getCorrelation ( ) { if ( ! ( sumXX > 0. && sumYY > 0. ) ) { return ( sumXX == sumYY ) ? 1. : 0. ; } return sumXY / FastMath . sqrt ( sumXX * sumYY ) ; }
Get the Pearson correlation value .
34,474
public static double coefficient ( double [ ] x , double [ ] y ) { final int xdim = x . length ; final int ydim = y . length ; if ( xdim != ydim ) { throw new IllegalArgumentException ( "Invalid arguments: arrays differ in length." ) ; } if ( xdim == 0 ) { throw new IllegalArgumentException ( "Empty vector." ) ; } doub...
Compute the Pearson product - moment correlation coefficient for two FeatureVectors .
34,475
public static double weightedCoefficient ( NumberVector x , NumberVector y , double [ ] weights ) { final int xdim = x . getDimensionality ( ) ; final int ydim = y . getDimensionality ( ) ; if ( xdim != ydim ) { throw new IllegalArgumentException ( "Invalid arguments: number vectors differ in dimensionality." ) ; } if ...
Compute the Pearson product - moment correlation coefficient for two NumberVectors .
34,476
@ SuppressWarnings ( "unchecked" ) public static < T , A > ExtendedArray < T > extend ( A array , ArrayAdapter < T , A > getter , T extra ) { return new ExtendedArray < > ( array , ( ArrayAdapter < T , Object > ) getter , extra ) ; }
Static wrapper that has a nicer generics signature .
34,477
public static SelectionResult ensureSelectionResult ( final Database db ) { List < SelectionResult > selections = ResultUtil . filterResults ( db . getHierarchy ( ) , db , SelectionResult . class ) ; if ( ! selections . isEmpty ( ) ) { return selections . get ( 0 ) ; } SelectionResult sel = new SelectionResult ( ) ; Re...
Ensure that there also is a selection container object .
34,478
@ SuppressWarnings ( "unused" ) public void debugRender ( GL2 gl ) { if ( ! DEBUG || ( startcamera == null ) ) { return ; } gl . glLineWidth ( 3f ) ; gl . glColor4f ( 1.f , 0.f , 0.f , .66f ) ; gl . glBegin ( GL . GL_LINES ) ; gl . glVertex3f ( 0.f , 0.f , 0.f ) ; double rot = startangle - startcamera . getRotationZ ( ...
Render a debugging hint for the arcball tool .
34,479
public static List < SettingsResult > getSettingsResults ( Result r ) { if ( r instanceof SettingsResult ) { List < SettingsResult > ors = new ArrayList < > ( 1 ) ; ors . add ( ( SettingsResult ) r ) ; return ors ; } if ( r instanceof HierarchicalResult ) { return ResultUtil . filterResults ( ( ( HierarchicalResult ) r...
Collect all settings results from a Result
34,480
public static String usage ( Collection < TrackedParameter > options ) { StringBuilder usage = new StringBuilder ( 10000 ) ; if ( ! REFERENCE_VERSION . equals ( VERSION ) ) { usage . append ( "ELKI build: " ) . append ( VERSION ) . append ( NEWLINE ) . append ( NEWLINE ) ; } usage . append ( REFERENCE ) ; OptionUtil . ...
Returns a usage message explaining all known options
34,481
protected static void printErrorMessage ( Exception e ) { if ( e instanceof AbortException ) { LoggingConfiguration . setVerbose ( Level . VERBOSE ) ; LOG . verbose ( e . getMessage ( ) ) ; } else if ( e instanceof UnspecifiedParameterException ) { LOG . error ( e . getMessage ( ) ) ; } else if ( e instanceof Parameter...
Print an error message for the given error .
34,482
private static void printDescription ( Class < ? > descriptionClass ) { if ( descriptionClass == null ) { return ; } try { LoggingConfiguration . setVerbose ( Level . VERBOSE ) ; LOG . verbose ( OptionUtil . describeParameterizable ( new StringBuilder ( ) , descriptionClass , FormatUtil . getConsoleWidth ( ) , "" ) . t...
Print the description for the given parameter
34,483
public static < T > void processDense ( T data , Adapter < T > adapter , Collector collector ) { final int n = adapter . size ( data ) ; double [ ] best = new double [ n ] ; Arrays . fill ( best , Double . POSITIVE_INFINITY ) ; int [ ] src = new int [ n ] ; byte [ ] connected = new byte [ n ] ; int current = 0 ; connec...
Run Prim s algorithm on a dense graph .
34,484
protected boolean isInputValid ( String filename , String line , String id , String msg ) { return ! filename . isEmpty ( ) || ! line . isEmpty ( ) || ! id . isEmpty ( ) || ! msg . isEmpty ( ) ; }
Derived classes can overload this method
34,485
public void parseVCppLine ( String line , String projectPath , String compilationFile ) { this . parseVCppCompilerCLLine ( line , projectPath , compilationFile ) ; }
Can be used to create a list of includes defines and options for a single line If it follows the format of VC ++
34,486
public Set < ValgrindError > processReport ( File report ) throws XMLStreamException { ValgrindReportStreamHandler streamHandler = new ValgrindReportStreamHandler ( ) ; new StaxParser ( streamHandler ) . parse ( report ) ; return streamHandler . valgrindErrors ; }
Parses given valgrind report
34,487
private static boolean isGeneratedNodeExcluded ( AstNode astNode ) { AstNode prev = astNode . getPreviousAstNode ( ) ; return prev != null && prev . getTokenLine ( ) == astNode . getTokenLine ( ) && prev . isCopyBookOrGeneratedNode ( ) ; }
Exclude subsequent generated nodes if they are consecutive and on the same line .
34,488
private boolean isBreakStatementExcluded ( AstNode astNode ) { boolean exclude = false ; if ( excludeCaseBreak && astNode . getToken ( ) . getType ( ) . equals ( CxxKeyword . BREAK ) ) { for ( AstNode statement = astNode . getFirstAncestor ( CxxGrammarImpl . statement ) ; statement != null ; statement = statement . get...
Exclude break statement if it is on the same line as the switch label
34,489
private boolean isEmptyExpressionStatement ( AstNode astNode ) { if ( astNode . is ( CxxGrammarImpl . expressionStatement ) && ";" . equals ( astNode . getToken ( ) . getValue ( ) ) ) { AstNode statement = astNode . getFirstAncestor ( CxxGrammarImpl . selectionStatement ) ; if ( statement != null ) { return astNode . g...
Exclude empty expression statement
34,490
private Map < String , Macro > parsePredefinedUnitMacros ( Map < String , Macro > configuredMacros ) { if ( ! ctorInProgress || ( unitMacros != null ) ) { throw new IllegalStateException ( "Preconditions for initial fill-out of predefinedUnitMacros were violated" ) ; } if ( conf . getCompilationUnitSourceFiles ( ) . is...
Create temporary unitMacros map ; This map will be used as an active macros storage while parsing of forced includes . After parsing was over extract resulting macros and destroy the unitMacros . fixedMacros will be set as active macros again .
34,491
public < G extends Serializable > Metric < G > getMetric ( CxxMetricsFactory . Key metricKey ) { Metric < G > metric = ( Metric < G > ) this . langSpecificMetrics . get ( metricKey ) ; if ( metric == null ) { throw new IllegalStateException ( "Requested metric " + metricKey + " couldn't be found" ) ; } return metric ; ...
Get language specific metric
34,492
public static List < String > getElements ( File file , String charset ) { List < String > list = new ArrayList < > ( ) ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( java . nio . file . Files . newInputStream ( file . toPath ( ) ) , charset ) ) ) { StringBuilder sb = new StringBuilder ( 4096 ...
get all DrMemory elements from file
34,493
public void saveUniqueViolation ( SensorContext sensorContext , CxxReportIssue issue ) { if ( uniqueIssues . add ( issue ) ) { saveViolation ( sensorContext , issue ) ; } }
Saves code violation only if it wasn t already saved
34,494
public static SourceFile scanSingleFile ( InputFile file , SensorContext sensorContext , CxxLanguage language , SquidAstVisitor < Grammar > ... visitors ) { return scanSingleFileConfig ( language , file , new CxxConfiguration ( sensorContext . fileSystem ( ) . encoding ( ) ) , visitors ) ; }
Helper method for testing checks without having to deploy them on a Sonar instance .
34,495
public static SourceFile scanSingleFileConfig ( CxxLanguage language , InputFile file , CxxConfiguration cxxConfig , SquidAstVisitor < Grammar > ... visitors ) { if ( ! file . isFile ( ) ) { throw new IllegalArgumentException ( "File '" + file + "' not found." ) ; } AstScanner < Grammar > scanner = create ( language , ...
Helper method for scanning a single file
34,496
public static String join ( Path path1 , Path path2 ) { if ( path2 . toString ( ) . isEmpty ( ) ) { return "" ; } if ( ! path1 . isAbsolute ( ) ) { path1 = Paths . get ( "." , path1 . toString ( ) ) ; } if ( ! path2 . isAbsolute ( ) ) { path2 = Paths . get ( "." , path2 . toString ( ) ) ; } Path result = path1 . resolv...
Join two paths
34,497
public static void parse ( CxxConfiguration config , File compileCommandsFile ) throws IOException { LOG . debug ( "Parsing 'JSON Compilation Database' format" ) ; ObjectMapper mapper = new ObjectMapper ( ) ; mapper . disable ( DeserializationFeature . FAIL_ON_UNKNOWN_PROPERTIES ) ; mapper . enable ( DeserializationFea...
Set up the given CxxConfiguration from the JSON compilation database
34,498
private static String getOperatorId ( AstNode operatorFunctionId ) { StringBuilder builder = new StringBuilder ( operatorFunctionId . getTokenValue ( ) ) ; AstNode operator = operatorFunctionId . getFirstDescendant ( CxxGrammarImpl . overloadableOperator ) ; if ( operator != null ) { AstNode opNode = operator . getFirs...
XXX may go to a utility class
34,499
private static List < Token > getInlineDocumentation ( Token token , int line ) { List < Token > comments = new ArrayList < > ( ) ; for ( Trivia trivia : token . getTrivia ( ) ) { if ( trivia . isComment ( ) ) { Token triviaToken = trivia . getToken ( ) ; if ( ( triviaToken != null ) && ( triviaToken . getLine ( ) == l...
Check if inline Doxygen documentation is attached to the given token at specified line