Quellcode durchsuchen

Fix an initialization bug in ProgramEvaluator.

The buffers used to store the per thread value of the gradient
were not set to zero at the beginning of each call to evaluate.

Change-Id: I9c8afea54a4e2e0b805164025da3023166a309af
Sameer Agarwal vor 13 Jahren
Ursprung
Commit
31432aeec4
1 geänderte Dateien mit 4 neuen und 0 gelöschten Zeilen
  1. 4 0
      internal/ceres/program_evaluator.h

+ 4 - 0
internal/ceres/program_evaluator.h

@@ -138,6 +138,10 @@ class ProgramEvaluator : public Evaluator {
     // Each thread gets it's own cost and evaluate scratch space.
     // Each thread gets it's own cost and evaluate scratch space.
     for (int i = 0; i < options_.num_threads; ++i) {
     for (int i = 0; i < options_.num_threads; ++i) {
       evaluate_scratch_[i].cost = 0.0;
       evaluate_scratch_[i].cost = 0.0;
+      if (gradient != NULL) {
+        VectorRef(evaluate_scratch_[i].gradient.get(),
+                  program_->NumEffectiveParameters()).setZero();
+      }
     }
     }
 
 
     // This bool is used to disable the loop if an error is encountered
     // This bool is used to disable the loop if an error is encountered