Accord.Tests.Interop.Math.LibBFGSComparisonTest.compute C# (CSharp) 메소드

compute() 개인적인 정적인 메소드

private static compute ( List problems, LBFGSComparer cmp ) : void
problems List
cmp LBFGSComparer
리턴 void
        private static void compute(List<Specification> problems, LBFGSComparer cmp)
        {
            foreach (var problem in problems)
            {
                string actualStr = String.Empty;
                string expectedStr = String.Empty;

                OptimizationProgressEventArgs[] actual = null;

                try { actual = cmp.Actual(problem); }
                catch (Exception ex)
                {
                    actualStr = ex.Data["Code"] as string;
                    if (actualStr == null)
                        throw;
                }

                var expected = cmp.Expected(problem);
                expectedStr = cmp.NativeCode;

                if (actualStr == String.Empty)
                    actualStr = cmp.ActualMessage;

                Assert.AreEqual(expectedStr, actualStr);

                if (expectedStr != "LBFGS_SUCCESS")
                    continue;

                Assert.AreEqual(expected.Length, actual.Length);
                for (int i = 0; i < expected.Length; i++)
                {
                    var a = actual[i];
                    var e = expected[i];

                    Assert.AreEqual(e.fx, a.Value);

                    for (int j = 0; j < e.g.Length; j++)
                        Assert.AreEqual(e.g[j], a.Gradient[j]);
                    Assert.AreEqual(e.gnorm, a.GradientNorm);
                    Assert.AreEqual(e.step, a.Step);
                }
            }
        }