From 33d4601da5e2e715260619a38f5899645d157952 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 8 May 2012 19:45:10 -0400 Subject: switch to liblbfgs for pro --- training/liblbfgs/ll_test.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'training/liblbfgs/ll_test.cc') diff --git a/training/liblbfgs/ll_test.cc b/training/liblbfgs/ll_test.cc index 058db716..43c0f214 100644 --- a/training/liblbfgs/ll_test.cc +++ b/training/liblbfgs/ll_test.cc @@ -4,12 +4,11 @@ using namespace std; // Function must be lbfgsfloatval_t f(x.begin, x.end, g.begin) -lbfgsfloatval_t func(const lbfgsfloatval_t* x, lbfgsfloatval_t* g) { +lbfgsfloatval_t func(const vector& x, lbfgsfloatval_t* g) { int i; lbfgsfloatval_t fx = 0.0; - int n = 4; - for (i = 0;i < n;i += 2) { + for (i = 0;i < x.size();i += 2) { lbfgsfloatval_t t1 = 1.0 - x[i]; lbfgsfloatval_t t2 = 10.0 * (x[i+1] - x[i] * x[i]); g[i+1] = 20.0 * t2; @@ -21,8 +20,8 @@ lbfgsfloatval_t func(const lbfgsfloatval_t* x, lbfgsfloatval_t* g) { template void Opt(F& f) { - LBFGS lbfgs(4, f, 1.0); - lbfgs.Optimize(); + LBFGS lbfgs(4, f); + lbfgs.MinimizeFunction(); } int main(int argc, char** argv) { -- cgit v1.2.3