Make last-split a bit faster
authorMartin C. Frith
Mon Mar 16 11:25:17 2020 +0900 (2 months ago)
changeset 10580b3571f8e14b
parent 1057 ff73ca674104
child 1059 a380494ff77b
Make last-split a bit faster
src/split/cbrc_split_aligner.cc
src/split/cbrc_split_aligner.hh
     1.1 --- a/src/split/cbrc_split_aligner.cc	Fri Mar 13 08:57:07 2020 +0900
     1.2 +++ b/src/split/cbrc_split_aligner.cc	Mon Mar 16 11:25:17 2020 +0900
     1.3 @@ -1072,8 +1072,13 @@
     1.4  }
     1.5  
     1.6  void SplitAligner::initMatricesForOneQuery() {
     1.7 -  resizeDoubleMatrix(Smat);
     1.8 -  resizeDoubleMatrix(Sexp);
     1.9 +  size_t doubleMatrixSize = cellsPerDpMatrix() * 2;
    1.10 +  // The final cell per row is never used, because there's one less
    1.11 +  // Aij than Dij per candidate alignment.
    1.12 +  if (Smat.size() < doubleMatrixSize) {
    1.13 +    Smat.resize(doubleMatrixSize);
    1.14 +    Sexp.resize(doubleMatrixSize);
    1.15 +  }
    1.16  
    1.17    for (unsigned i = 0; i < numAlns; i++) calcBaseScores(i);
    1.18  
    1.19 @@ -1089,7 +1094,7 @@
    1.20      for (unsigned i = 0; i < numAlns; ++i) initSpliceSignals(i);
    1.21    }
    1.22  
    1.23 -  transform(Smat.begin(), Smat.end(), Sexp.begin(), scaledExp);
    1.24 +  std::transform(&Smat[0], &Smat[0] + doubleMatrixSize, &Sexp[0], scaledExp);
    1.25    // if x/scale < about -745, then exp(x/scale) will be exactly 0.0
    1.26  }
    1.27  
     2.1 --- a/src/split/cbrc_split_aligner.hh	Fri Mar 13 08:57:07 2020 +0900
     2.2 +++ b/src/split/cbrc_split_aligner.hh	Mon Mar 16 11:25:17 2020 +0900
     2.3 @@ -296,16 +296,8 @@
     2.4        // This reserves size for a ragged matrix, which is actually
     2.5        // stored in a flat vector.  There are numAlns rows, and row i
     2.6        // has dpEnd(i) - dpBeg(i) + 1 cells.
     2.7 -      m.resize(cellsPerDpMatrix());
     2.8 -    }
     2.9 -
    2.10 -    template<typename T>
    2.11 -    void resizeDoubleMatrix(T& m) const {
    2.12 -      // This reserves size for Smat and Sexp, which contain 2
    2.13 -      // interpolated matrices (Aij and Dij).  The final cell per row
    2.14 -      // is never used, because there's one less Aij than Dij per
    2.15 -      // candidate alignment.
    2.16 -      m.resize(cellsPerDpMatrix() * 2);
    2.17 +      size_t s = cellsPerDpMatrix();
    2.18 +      if (m.size() < s) m.resize(s);
    2.19      }
    2.20  
    2.21      double probFromSpliceF(unsigned i, unsigned j, unsigned oldNumInplay,