36 double* pinp_b =
nullptr
50 return sqrt(this->
gg_);
74 double*
pb_ =
nullptr;
86 innerproduct *= this->
dV_;
static float dot(const int n, const float *const X, const int incX, const float *const Y, const int incY, base_device::AbacusDevice_t device_type=base_device::AbacusDevice_t::CpuDevice)
Definition blas_connector_vector.cpp:142
A class designed to deal with optimization problems with CG method. Three forms of CG methods have be...
Definition opt_CG.h:25
void allocate(int nx)
Allocate the space for pdirect_old and pgradient_old.
Definition opt_CG.cpp:36
double get_residual()
Definition opt_CG.h:48
void init_b(double *pinp_b)
Initialize b before solving Ax = b.
Definition opt_CG.cpp:22
int iter_
Definition opt_CG.h:65
double beta_
Definition opt_CG.h:67
double eta_
Definition opt_CG.h:68
int nx_
Definition opt_CG.h:64
void PR_beta(double *pgradient)
Get the beta in PR form. beta_k = max{0, <g_k, g_k-g_{k-1}>/<g_{k-1}, g_{k-1}>} <> means inner produc...
Definition opt_CG.cpp:202
int get_iter()
Definition opt_CG.h:52
void next_direct(double *pgradient, int label, double *rdirect)
Get the next optimization direction.
Definition opt_CG.cpp:85
double alpha_
Definition opt_CG.h:73
void refresh(int nx_new=0, double *pinp_b=nullptr)
Refresh the class. If nx changes, reallocate space. If b is provided, initialize it.
Definition opt_CG.cpp:59
double * pdirect_old_
Definition opt_CG.h:69
~Opt_CG()
Definition opt_CG.cpp:10
double inner_product(double *pa, double *pb, int length)
Definition opt_CG.h:83
double gg_
Definition opt_CG.h:66
void HZ_beta(double *pgradient)
Get the beta in HZ form. See formula in Hager W W, Zhang H. SIAM Journal on optimization,...
Definition opt_CG.cpp:222
double * pb_
Definition opt_CG.h:74
double dV_
Definition opt_CG.h:63
Opt_CG()
Definition opt_CG.cpp:6
double * pgradient_old_
Definition opt_CG.h:70
void stantard_CGdirect(double *pAd, double *rdirect)
Get the next optimization direction with standard CG workflow.
Definition opt_CG.cpp:163
void set_para(double dV)
Definition opt_CG.cpp:47
double step_length(double *pAd, double *pdirect, int &ifPD)
Get the step length, only work for standard CG.
Definition opt_CG.cpp:131
Definition array_pool.h:6