Ignore:
Timestamp:
09/20/16 17:14:41 (5 years ago)
Author:
bburlacu
Message:

#2672: Add cloning constructors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineNormalizedMeanSquaredErrorCalculator.cs

    r14293 r14294  
    4343    }
    4444
    45     // private constructor used internally by the Clone() method
    46     public OnlineNormalizedMeanSquaredErrorCalculator(OnlineMeanAndVarianceCalculator meanSquaredErrorCalculator, OnlineMeanAndVarianceCalculator originalVarianceCalculator) {
    47       this.meanSquaredErrorCalculator = meanSquaredErrorCalculator;
    48       this.originalVarianceCalculator = originalVarianceCalculator;
     45    protected OnlineNormalizedMeanSquaredErrorCalculator(OnlineNormalizedMeanSquaredErrorCalculator other, Cloner cloner) {
     46      meanSquaredErrorCalculator = (OnlineMeanAndVarianceCalculator)other.meanSquaredErrorCalculator.Clone(cloner);
     47      originalVarianceCalculator = (OnlineMeanAndVarianceCalculator)originalVarianceCalculator.Clone(cloner);
    4948    }
    5049
     
    102101    // IDeepCloneable members
    103102    public object Clone() {
    104       var meanSquaredErrorCalculatorClone = (OnlineMeanAndVarianceCalculator)meanSquaredErrorCalculator.Clone();
    105       var originalVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)originalVarianceCalculator.Clone();
    106       return new OnlineNormalizedMeanSquaredErrorCalculator(meanSquaredErrorCalculatorClone, originalVarianceCalculatorClone);
     103      var cloner = new Cloner();
     104      return new OnlineNormalizedMeanSquaredErrorCalculator(this, cloner);
    107105    }
    108106
     
    110108      var clone = cloner.GetClone(this);
    111109      if (clone == null) {
    112         var meanSquaredErrorCalculatorClone = (OnlineMeanAndVarianceCalculator)meanSquaredErrorCalculator.Clone(cloner);
    113         var originalVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)originalVarianceCalculator.Clone(cloner);
    114         clone = new OnlineNormalizedMeanSquaredErrorCalculator(meanSquaredErrorCalculatorClone, originalVarianceCalculatorClone);
     110        clone = new OnlineNormalizedMeanSquaredErrorCalculator(this, cloner);
    115111        cloner.RegisterClonedObject(this, clone);
    116112      }
Note: See TracChangeset for help on using the changeset viewer.