Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/15 15:58:16 (9 years ago)
Author:
gkronber
Message:

#2415: added StorableClass attribute to transformation functions (+code improvements)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LinearTransformation.cs

    r12012 r12612  
    3131
    3232namespace HeuristicLab.Problems.DataAnalysis {
     33  [StorableClass]
    3334  [Item("Linear Transformation", "f(x) = k * x + d | Represents a linear transformation with multiplication and addition.")]
    3435  public class LinearTransformation : Transformation<double> {
     
    8081
    8182    public override IEnumerable<double> Apply(IEnumerable<double> data) {
    82       return data.Select(e => e * Multiplier + Addend);
     83      var m = Multiplier;
     84      var a = Addend;
     85      return data.Select(e => e * m + a);
    8386    }
    8487
    8588    public override bool Check(IEnumerable<double> data, out string errorMsg) {
    8689      errorMsg = null;
    87       if (Multiplier == 0.0) {
     90      if (Multiplier.IsAlmost(0.0)) {
    8891        errorMsg = String.Format("Multiplicand is 0, all {0} entries will be set to {1}. Inverse apply will not be possible (division by 0).", data.Count(), Addend);
    8992        return false;
Note: See TracChangeset for help on using the changeset viewer.