Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3022-FastFunctionExtraction/FFX/ProductBaseFunction.cs @ 18057

Last change on this file since 18057 was 17779, checked in by gkronber, 4 years ago

#3022: made a few changes while reviewing the code.

File size: 1.1 KB
RevLine 
[17737]1using HeuristicLab.Problems.DataAnalysis;
2using System;
3using System.Linq;
4
5namespace HeuristicLab.Algorithms.DataAnalysis.FastFunctionExtraction {
6    internal struct ProductBaseFunction : IBasisFunction {
7        public IBasisFunction B1 { get; set; }
8        public IBasisFunction B2 { get; set; }
9
[17779]10        public int Complexity => 1 + B1.Complexity + B2.Complexity;
[17737]11
[17779]12        public bool IsDenominator { get; set; }
[17737]13
[17779]14        public ProductBaseFunction(IBasisFunction b1, IBasisFunction b2, bool isDenominator) {
[17737]15            B1 = b1 ?? throw new ArgumentNullException(nameof(b1));
16            B2 = b2 ?? throw new ArgumentNullException(nameof(b2));
[17779]17            IsDenominator = isDenominator;
[17737]18        }
19
[17779]20        public double[] Evaluate(IRegressionProblemData data) {
21            return B1.Evaluate(data).Zip(B2.Evaluate(data), (a, b) => a * b).ToArray();
[17737]22        }
23
24        public override string ToString() {
25            return $"{B1} * {B2}";
26        }
27
28        public IBasisFunction DeepCopy() {
[17779]29            return new ProductBaseFunction(B1, B2, IsDenominator);
[17737]30        }
31    }
32}
Note: See TracBrowser for help on using the repository browser.