diff options
-rw-r--r-- | model/ranksvmtn.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/model/ranksvmtn.cpp b/model/ranksvmtn.cpp index 6a7057d..539ab5e 100644 --- a/model/ranksvmtn.cpp +++ b/model/ranksvmtn.cpp @@ -6,6 +6,26 @@ using namespace Eigen; const int maxiter = 10; const double prec=1e-3; +int cg_solve(const MatrixXd &A, const VectorXd &b, const VectorXd &x) +{ + double alpha,beta,r_1,r_2; + VectorXd p = x; + VectorXd q; + VectorXd res; + while (1) + { + beta = r_1/r_2; + p = res + beta*p; + q = A*p; + alpha = r_1/p.dot(q); + // Non preconditioned version + alpha = p.dot(p)/(p.dot(q)); + res=res-alpha*q; + break; + } + return 0; +} + // Calculate objfunc gradient & support vectors int objfunc_linear(const VectorXd &w,const double C,const VectorXd &pred,const VectorXd &grad, double &obj,MatrixXd &sv) { @@ -17,12 +37,13 @@ int objfunc_linear(const VectorXd &w,const double C,const VectorXd &pred,const V sv(i,i)=1; else sv(i,i)=0; + return 0; } // line search int line_search(const VectorXd &w,const double C,const VectorXd &step,VectorXd &pred,double &t) { - + return 0; } int RSVMTN::train(DataSet &D, Labels &label){ |