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