Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/08 00:02:43 (16 years ago)
Author:
gkronber
Message:

worked on #139:

  • fixed display of trees in the gui
  • split list representation of tree into two lists code and data
  • implemented static evaluation for all predefined functions (except ProgrammableFunction)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ExperimentalFunctionsBaking/Division.cs

    r203 r220  
    3030
    3131namespace HeuristicLab.Functions {
    32   public class Division : FunctionBase {
     32  public sealed class Division : FunctionBase {
    3333    private const double EPSILON = 10.0E-20; // if any divisor is < EPSILON return 0
    3434
     
    5252    }
    5353
    54     public static double Divide(double[] args) {
    55       // (/ 3) => 1/3
    56       // (/ 2 3) => 2/3
    57       // (/ 3 4 5) => 3/20
    58       if(args.Length == 1) {
    59         double divisor = args[0];
    60         if(Math.Abs(divisor) < EPSILON) return 0;
    61         else return 1.0 / divisor;
    62       } else {
    63         double result = args[0];
    64         for(int i = 1; i < args.Length; i++) {
    65           double divisor = args[i];
    66           if(Math.Abs(divisor) < EPSILON) return 0.0;
    67           result /= divisor;
    68         }
    69         return result;
    70       }
    71     }
    72 
    73     public override double Apply(Dataset dataset, int sampleIndex, double[] args) {
    74       return Division.Divide(args);
    75     }
    76 
    7754    public override void Accept(IFunctionVisitor visitor) {
    7855      visitor.Visit(this);
Note: See TracChangeset for help on using the changeset viewer.