Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/10/12 13:28:55 (12 years ago)
Author:
gkronber
Message:

#1902 implemented all mean and covariance functions with parameters as ParameterizedNamedItems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs

    r8562 r8612  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2427
    2528namespace HeuristicLab.Algorithms.DataAnalysis {
    26   public static class Util {
     29  internal static class Util {
    2730    public static double ScalarProd(IEnumerable<double> v, IEnumerable<double> u) {
    2831      return v.Zip(u, (vi, ui) => vi * ui).Sum();
     
    9497      return Enumerable.Range(0, rows).Select(r => x[r, c]);
    9598    }
     99
     100
     101    public static void AttachValueChangeHandler<T, U>(IValueParameter<T> parameter, Action action)
     102      where T : ValueTypeValue<U>
     103      where U : struct {
     104      parameter.ValueChanged += (sender, args) => {
     105        if (parameter.Value != null) {
     106          parameter.Value.ValueChanged += (s, a) => action();
     107          action();
     108        }
     109      };
     110      if (parameter.Value != null) {
     111        parameter.Value.ValueChanged += (s, a) => action();
     112      }
     113    }
     114
     115    public static void AttachArrayChangeHandler<T, U>(IValueParameter<T> parameter, Action action)
     116      where T : ValueTypeArray<U>
     117      where U : struct {
     118      parameter.ValueChanged += (sender, args) => {
     119        if (parameter.Value != null) {
     120          parameter.Value.ItemChanged += (s, a) => action();
     121          parameter.Value.Reset += (s, a) => action();
     122          action();
     123        }
     124      };
     125      if (parameter.Value != null) {
     126        parameter.Value.ItemChanged += (s, a) => action();
     127        parameter.Value.Reset += (s, a) => action();
     128      }
     129    }
    96130  }
    97131}
Note: See TracChangeset for help on using the changeset viewer.