Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17307


Ignore:
Timestamp:
10/03/19 14:56:46 (5 years ago)
Author:
gkronber
Message:

#2994 added unit test for comparison of autodiff results with numeric differences and fixed a few bugs in AutoDiff code

Location:
branches/2994-AutoDiffForIntervals
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/Dual.cs

    r17303 r17307  
    2525    public Dual<V> Sub(Dual<V> a) { v.Sub(a.v); dv.Sub(a.dv); return this; }
    2626    public Dual<V> AssignNeg(Dual<V> a) { v.AssignNeg(a.v); dv.AssignNeg(a.dv); return this; }
    27     public Dual<V> AssignInv(Dual<V> a) { v.AssignInv(a.v); dv.AssignNeg(a.dv).Mul(v).Mul(v); return this; } // (1/f(x))' = - f(x)' / f(x)^2
     27    public Dual<V> AssignInv(Dual<V> a) { v.AssignInv(a.v); dv.AssignNeg(a.dv).Mul(v.IntPower(2).Inv()); return this; } // (1/f(x))' = - f(x)' / f(x)^2
    2828
    2929    // (a(x) * b(x))' = b(x)*a(x)' + b(x)'*a(x);
     
    3636      return this;
    3737    }
    38     public Dual<V> Div(Dual<V> a) { Mul(a.Inv()); return this; }
     38    public Dual<V> Div(Dual<V> a) { Mul(a.Inv()); return this; } // f(x) / g(x) = f(x) * 1/g(x)
    3939
    4040    public Dual<V> AssignExp(Dual<V> a) { v.AssignExp(a.v); dv.Assign(a.dv).Mul(v); return this; } // exp(f(x)) = exp(f(x))*f(x)'
     
    4242
    4343    public Dual<V> AssignIntPower(Dual<V> a, int p) { v.AssignIntPower(a.v, p); dv.Assign(a.dv).Scale(p).Mul(a.v.Clone().IntPower(p - 1)); return this; }
    44     public Dual<V> AssignIntRoot(Dual<V> a, int r) { v.AssignIntRoot(a.v, r); dv.Assign(a.dv).Scale(1.0 / r).Mul(a.v.IntRoot(r - 1)); return this; }
     44    public Dual<V> AssignIntRoot(Dual<V> a, int r) { v.AssignIntRoot(a.v, r); dv.Assign(a.dv).Scale(1.0 / r).Div(a.v.IntRoot(r).IntPower(r-1)); return this; }
    4545
    4646    public Dual<V> AssignSin(Dual<V> a) { v.AssignSin(a.v); dv.Assign(a.dv).Mul(a.v.Clone().Cos()); return this; }
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/MultivariateDual.cs

    r17303 r17307  
    7676      return this;
    7777    }
    78     public MultivariateDual<V> Div(MultivariateDual<V> a) { v.Div(a.v); dv.Mul(a.dv.Inv()); return this; }
     78    public MultivariateDual<V> Div(MultivariateDual<V> a) { Mul(a.Inv()); return this; }  // f(x) / g(x)
    7979    public MultivariateDual<V> AssignNeg(MultivariateDual<V> a) { v.AssignNeg(a.v); dv.AssignNeg(a.dv); return this; }
    80     public MultivariateDual<V> AssignInv(MultivariateDual<V> a) { v.AssignInv(a.v); dv.AssignNeg(a.dv).Scale(v).Scale(v); return this; }   // (1/f(x))' = - f(x)' / f(x)^2
     80    public MultivariateDual<V> AssignInv(MultivariateDual<V> a) { v.AssignInv(a.v); dv.AssignNeg(a.dv).Scale(a.v.IntPower(2).Inv()); return this; }   // (1/f(x))' = - f(x)' / f(x)^2
    8181
    8282    public MultivariateDual<V> AssignSin(MultivariateDual<V> a) { v.AssignSin(a.v); dv.Assign(a.dv).Scale(a.v.Clone().Cos()); return this; }
     
    8585
    8686    public MultivariateDual<V> AssignIntPower(MultivariateDual<V> a, int p) { v.AssignIntPower(a.v, p); dv.Assign(a.dv).Scale(p).Scale(a.v.Clone().IntPower(p - 1)); return this; }
    87     public MultivariateDual<V> AssignIntRoot(MultivariateDual<V> a, int r) { v.AssignIntRoot(a.v, r); dv.Assign(a.dv).Scale(1.0 / r).Scale(a.v.IntRoot(r - 1)); return this; }
     87    public MultivariateDual<V> AssignIntRoot(MultivariateDual<V> a, int r) { v.AssignIntRoot(a.v, r); dv.Assign(a.dv).Scale(1.0 / r).Scale(a.v.IntRoot(r).IntPower(r - 1).Inv()); return this; }
    8888
    8989    public MultivariateDual<V> AssignExp(MultivariateDual<V> a) { v.AssignExp(a.v); dv.Assign(a.dv).Scale(v); return this; } // exp(f(x)) = exp(f(x))*f(x)'     
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r17289 r17307  
    599599    <Compile Include="HeuristicLab.Persistence.Attic\UseCases.cs" />
    600600    <Compile Include="HeuristicLab.PluginInfraStructure-3.3\TypeExtensionsTest.cs" />
     601    <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\AutoDiffInterpreterTest.cs" />
    601602    <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\ClassificationVariableImpactCalculationTest.cs" />
    602603    <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\DatasetTest.cs" />
Note: See TracChangeset for help on using the changeset viewer.