Examples of IntVector


Examples of org.tmatesoft.hg.internal.IntVector

      if (changelog2manifest == null) {
        // direct, 1-1 mapping of changeset indexes to manifest
        return;
      }
      // I assume there'd be not too many revisions we don't know manifest of
      IntVector undefinedChangelogRevision = new IntVector();
      for (int i = 0; i < changelog2manifest.length; i++) {
        if (changelog2manifest[i] == BAD_REVISION) {
          undefinedChangelogRevision.add(i);
        }
      }
      if (undefinedChangelogRevision.size() > 0) {
        final IntMap<Nodeid> missingCsetToManifest = new IntMap<Nodeid>(undefinedChangelogRevision.size());
        int[] undefinedClogRevs = undefinedChangelogRevision.toArray();
        // undefinedChangelogRevision is sorted by the nature it's created
        HgManifest.this.getRepo().getChangelog().rangeInternal(new HgChangelog.Inspector() {
         
          public void next(int revisionIndex, Nodeid nodeid, RawChangeset cset) {
            missingCsetToManifest.put(revisionIndex, cset.manifest());
          }
        }, undefinedClogRevs);
        assert missingCsetToManifest.size() == undefinedChangelogRevision.size();
        for (int u : undefinedClogRevs) {
          Nodeid manifest = missingCsetToManifest.get(u);
          if (manifest == null || manifest.isNull()) {
            HgManifest.this.getRepo().getSessionContext().getLog().dump(getClass(), Severity.Warn, "Changeset %d has no associated manifest entry", u);
            // keep BAD_REVISION in the changelog2manifest map.
View Full Code Here

Examples of org.tmatesoft.hg.internal.IntVector

    errorCollector.assertEquals(Unrelated, p3.compareWith(p2));
  }
 
  @Test
  public void testIntVector() {
    IntVector v = new IntVector();
    v.add(10, 9, 8);
    v.add(7);
    errorCollector.assertEquals(4, v.size());
    v.clear();
    errorCollector.assertEquals(0, v.size());
   
    // vector that doesn't grow
    v = new IntVector(3, 0);
    v.add(1,2,3);
    try {
      v.add(4);
      errorCollector.fail("This vector instance is not supposed to grow on demand");
    } catch (UnsupportedOperationException ex) {
    }
    v = new IntVector(5, 2);
    v.add(10,9,8);
    v.add(7,6);
    v.add(5,4,3,2,1);
    errorCollector.assertEquals(10, v.size());
    // so far so good - grow() works
    // now, check reverse()
    v.reverse();
    for (int i = 0; i < v.size(); i++) {
      errorCollector.assertEquals(i+1, v.get(i));
    }
  }
View Full Code Here

Examples of org.tmatesoft.hg.internal.IntVector

    EqualBlocksCollector bc = new EqualBlocksCollector();
    bc.match(-1, 5, 3);
    bc.match(-1, 10, 2);
    bc.match(-1, 15, 3);
    bc.match(-1, 20, 3);
    IntVector r = new IntVector();
    bc.intersectWithTarget(7, 10, r);
    for (int i = 0; i < r.size(); i+=2) {
      System.out.printf("[%d..%d) ", r.get(i), r.get(i) + r.get(i+1));
    }
    System.out.println();
    MergeStrategy1 ms = new MergeStrategy1(bc.matches);
    IntSliceSeq mr = ms.doCombine(0, 16, 508, 514);
    for (IntTuple t : mr) {
View Full Code Here

Examples of org.tmatesoft.hg.internal.IntVector

  private void prepare(T s2) {
    chunk2UseIndex = new HashMap<Object, IntVector>();
    for (int i = 0, len = s2.chunkCount(); i < len; i++) {
      Object bc = s2.chunk(i);
      IntVector loc = chunk2UseIndex.get(bc);
      if (loc == null) {
        chunk2UseIndex.put(bc, loc = new IntVector());
      }
      loc.add(i);
      // bc.registerUseIn(i) - BEWARE, use of bc here is incorrect
      // in this case need to find the only ByteChain to keep indexes
      // i.e. when there are few equal ByteChain instances, notion of "usedIn" shall be either shared (reference same vector)
      // or kept within only one of them
    }
View Full Code Here

Examples of org.tmatesoft.hg.internal.IntVector

    matchStartS1 = matchStartS2 = 0;
    int maxLength = 0;
    IntMap<Integer> chunkIndex2MatchCount = new IntMap<Integer>(8);
    for (int i = startS1; i < endS1; i++) {
      Object bc = seq1.chunk(i);
      IntVector occurencesInS2 = chunk2UseIndex.get(bc);
      if (occurencesInS2 == null) {
        chunkIndex2MatchCount.clear();
        continue;
      }
      IntMap<Integer> newChunkIndex2MatchCount = new IntMap<Integer>(8);
      for (int j : occurencesInS2.toArray()) {
        // s1[i] == s2[j]
        if (j < startS2) {
          continue;
        }
        if (j >= endS2) {
View Full Code Here

Examples of org.tmatesoft.hg.internal.IntVector

      cachedChangesets.put(cs.getRevisionIndex(), cs);
    }
   
    private HgChangeset[] get(int... changelogRevisionIndex) throws HgRuntimeException {
      HgChangeset[] rv = new HgChangeset[changelogRevisionIndex.length];
      IntVector misses = new IntVector(changelogRevisionIndex.length, -1);
      for (int i = 0; i < changelogRevisionIndex.length; i++) {
        if (changelogRevisionIndex[i] == -1) {
          rv[i] = null;
          continue;
        }
        HgChangeset cached = cachedChangesets.get(changelogRevisionIndex[i]);
        if (cached != null) {
          rv[i] = cached;
        } else {
          misses.add(changelogRevisionIndex[i]);
        }
      }
      if (misses.size() > 0) {
        final int[] changesets2read = misses.toArray();
        initTransform();
        repo.getChangelog().range(this, changesets2read);
        for (int changeset2read : changesets2read) {
          HgChangeset cs = cachedChangesets.get(changeset2read);
          if (cs == null) {
View Full Code Here

Examples of weka.core.matrix.IntVector

   */
  private double [] pace(double[][] matrix_X, double [] vector_Y) {
   
    PaceMatrix X = new PaceMatrix( matrix_X );
    PaceMatrix Y = new PaceMatrix( vector_Y, vector_Y.length );
    IntVector pvt = IntVector.seq(0, X.getColumnDimension()-1);
    int n = X.getRowDimension();
    int kr = X.getColumnDimension();

    X.lsqrSelection( Y, pvt, 1 );
    X.positiveDiagonal( Y, pvt );
   
    PaceMatrix sol = (PaceMatrix) Y.clone();
    X.rsolve( sol, pvt, pvt.size() );
    DoubleVector r = Y.getColumn( pvt.size(), n-1, 0);
    double sde = Math.sqrt(r.sum2() / r.size());
   
    DoubleVector aHat = Y.getColumn( 0, pvt.size()-1, 0).times( 1./sde );

    DoubleVector aTilde = null;
    switch( paceEstimator) {
    case ebEstimator:
    case nestedEstimator:
    case subsetEstimator:
      NormalMixture d = new NormalMixture();
      d.fit( aHat, MixtureDistribution.NNMMethod );
      if( paceEstimator == ebEstimator )
  aTilde = d.empiricalBayesEstimate( aHat );
      else if( paceEstimator == ebEstimator )
  aTilde = d.subsetEstimate( aHat );
      else aTilde = d.nestedEstimate( aHat );
      break;
    case pace2Estimator:
    case pace4Estimator:
    case pace6Estimator:
      DoubleVector AHat = aHat.square();
      ChisqMixture dc = new ChisqMixture();
      dc.fit( AHat, MixtureDistribution.NNMMethod );
      DoubleVector ATilde;
      if( paceEstimator == pace6Estimator )
  ATilde = dc.pace6( AHat );
      else if( paceEstimator == pace2Estimator )
  ATilde = dc.pace2( AHat );
      else ATilde = dc.pace4( AHat );
      aTilde = ATilde.sqrt().times( aHat.sign() );
      break;
    case olsEstimator:
      aTilde = aHat.copy();
      break;
    case aicEstimator:
    case bicEstimator:
    case ricEstimator:
    case olscEstimator:
      if(paceEstimator == aicEstimator) olscThreshold = 2;
      else if(paceEstimator == bicEstimator) olscThreshold = Math.log( n );
      else if(paceEstimator == ricEstimator) olscThreshold = 2*Math.log( kr );
      aTilde = aHat.copy();
      for( int i = 0; i < aTilde.size(); i++ )
  if( Math.abs(aTilde.get(i)) < Math.sqrt(olscThreshold) )
    aTilde.set(i, 0);
    }
    PaceMatrix YTilde = new PaceMatrix((new PaceMatrix(aTilde)).times( sde ));
    X.rsolve( YTilde, pvt, pvt.size() );
    DoubleVector betaTilde = YTilde.getColumn(0).unpivoting( pvt, kr );
   
    return betaTilde.getArrayCopy();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.