diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-05-08 19:45:10 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-05-08 19:45:10 -0400 |
commit | 33d4601da5e2e715260619a38f5899645d157952 (patch) | |
tree | f5828cf0906e907c88dd9c3ed7643e9983f62a56 /training/liblbfgs/ll_test.cc | |
parent | c168daa1e801a8a0be4d0c16311ae30b06a43b82 (diff) |
switch to liblbfgs for pro
Diffstat (limited to 'training/liblbfgs/ll_test.cc')
-rw-r--r-- | training/liblbfgs/ll_test.cc | 9 |
1 files changed, 4 insertions, 5 deletions
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<lbfgsfloatval_t>& 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<typename F> void Opt(F& f) { - LBFGS<F> lbfgs(4, f, 1.0); - lbfgs.Optimize(); + LBFGS<F> lbfgs(4, f); + lbfgs.MinimizeFunction(); } int main(int argc, char** argv) { |