MaskRay added a comment.

In `buildGraph`, the nested loop

  for (int P = 0; P < PatN; ++P) {
      // Scores[P + 1][P][Miss] = Scores[P + 1][P][Match] = {AwfulScore, Miss};
      for (int W = P; W < WordN; ++W) {

is interpreted as: we are calculating the cell `Scores[P+1][W+1][*]`, using the 
characters `Pattern[P]` and `Word[W]`. This is a position central viewpoint.
If you see `P and W` as numbers of characters, instead of the string indices, 
will it make more sense due to alleviated +1 -1 mental burden?

It can also be rephrased as:

  for (int P = 1; P <= PatN; ++P) {
      for (int W = P + 1; W <= WordN; ++W) {     // Since you like this form 
(though I don't)

This is a cell central viewpoint.
(we are calculating the cell `Scores[P][W][*]`, using the characters 
`Pattern[P-1]` and `Word[W-1]`)

The former interpretation is preferred because half closed intervals are 
generally preferred.

In the table dumping stage,

  for (int I = W; i > 0; i--)

is better than

  for (int I = W - 1; I >= 0; --I)

because we are tracing through the optimal path of the dynamic programming 
*cells*. We are also tracing the `W P` positions, but the former interpretation 
gets rid of some +1 -1.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44720



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to