1 // MeCab -- Yet Another Part-of-Speech and Morphological Analyzer
4 // Copyright(C) 2001-2006 Taku Kudo <taku@chasen.org>
5 // Copyright(C) 2004-2006 Nippon Telegraph and Telephone Corporation
16 explicit LBFGS(): iflag_(0), iscn(0), nfev(0), iycn(0),
17 point(0), npt(0), iter(0), info(0),
18 ispt(0), isyt(0), iypt(0), maxfev(0),
19 stp(0.0), stp1(0.0), mcsrch_(0) {}
20 virtual ~LBFGS() { clear(); }
24 int optimize(size_t size, double *x, double f, double *g,
25 bool orthant, double C) {
26 static const int msize = 5;
29 w_.resize(size * (2 * msize + 1) + 2 * msize);
31 } else if (diag_.size() != size) {
32 std::cerr << "size of array is different" << std::endl;
36 lbfgs_optimize(static_cast<int>(size),
37 msize, x, f, g, &diag_[0], &w_[0], orthant, C, &iflag_);
40 std::cerr << "routine stops with unexpected error" << std::endl;
46 return 0; // terminate
49 return 1; // evaluate next f and g
54 int iflag_, iscn, nfev, iycn, point, npt;
55 int iter, info, ispt, isyt, iypt, maxfev;
57 std::vector <double> diag_;
58 std::vector <double> w_;
61 void lbfgs_optimize(int size,
67 double *w, bool orthant, double C, int *iflag);