Changeset 155 for trunk/sources/HeuristicLab.Functions/Substraction.cs
- Timestamp:
- 04/22/08 18:05:14 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/Substraction.cs
r2 r155 33 33 public override string Description { 34 34 get { 35 return @"Substracts the results of sub- operators 2..n from the result of the first sub-operator.35 return @"Substracts the results of sub-tree 2..n from the result of the first sub-tree. 36 36 (- 3) => -3 37 37 (- 2 3) => -1 … … 46 46 } 47 47 48 public Substraction(Substraction source, IDictionary<Guid, object> clonedObjects)49 : base(source, clonedObjects) {50 }51 48 52 53 public override double Evaluate(Dataset dataset, int sampleIndex) { 54 55 if(SubFunctions.Count == 1) { 56 return -SubFunctions[0].Evaluate(dataset, sampleIndex); 49 public override double Apply(Dataset dataset, int sampleIndex, double[] args) { 50 if(args.Length == 1) { 51 return -args[0]; 57 52 } else { 58 double result = SubFunctions[0].Evaluate(dataset, sampleIndex);59 for(int i = 1; i < SubFunctions.Count; i++) {60 result -= SubFunctions[i].Evaluate(dataset, sampleIndex);53 double result = args[0]; 54 for(int i = 1; i < args.Length; i++) { 55 result -= args[i]; 61 56 } 62 57 return result; 63 58 } 64 }65 66 public override object Clone(IDictionary<Guid, object> clonedObjects) {67 Substraction clone = new Substraction(this, clonedObjects);68 clonedObjects.Add(clone.Guid, clone);69 return clone;70 59 } 71 60
Note: See TracChangeset
for help on using the changeset viewer.