Fix dynamic programming algorithm #1991
                
     Merged
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This PR fixes the dynamic programming algorithm. In particular, we ensure the end point of the aligned curve corresponds to the end point of the curve. I'm afraid we are not there yet, but hopefully this is a first step towards correctness.
Moreover, I've tried to improve naming in order to make the code more readable, but I'm afraid it is still too hard to follow.
Known issues (also occur in previous implementation)
The dynamic programming outputs a squared dist. After alignment, we can also compute a distance using the total space metric (this is the distance quotient metric outputs).
For more complex cases (thinking about birds), I've realized these distances are similar, but slightly off. Moreover, when we swap
pointandbase_point, the dynamic programming squared dist is the same, but the distance we compute with the total space is not necessarily symmetric (though close).For simpler cases as the curves generated by
random_point, the results are better (correspondence between DP and total space; almost symmetric distance).