21 using namespace Eigen;
26 CCGMShiftedFamilySolver::CCGMShiftedFamilySolver()
58 REQUIRE(A,
"Operator is NULL!\n");
64 "weights are not equal! [%d vs %d]\n", shifts.
vlen, weights.
vlen);
67 MatrixXcd x_sh=MatrixXcd::Zero(b.
vlen, shifts.
vlen);
68 MatrixXcd p_sh=MatrixXcd::Zero(b.
vlen, shifts.
vlen);
116 SG_DEBUG(
"CG iteration %d, residual norm %f\n",
147 x_sh.col(i)-=beta_sh[i]*p_sh.col(i);
158 alpha=r_norm2_i/r_norm2;
170 p_sh.col(i)*=alpha_sh[i];
171 p_sh.col(i)+=zeta_sh_new[i]*r;
177 zeta_sh_old[i]=zeta_sh_cur[i];
178 zeta_sh_cur[i]=zeta_sh_new[i];
188 SG_INFO(
"Iteration took %d times, residual norm=%.20lf, time elapsed=%f\n",
193 result.set_const(0.0);
196 for (
index_t i=0; i<x_sh.cols(); ++i)
197 x+=x_sh.col(i)*weights[i];
Class Time that implements a stopwatch based on either cpu time or wall clock time.
std::complex< float64_t > complex128_t
void compute_zeta_sh_new(const SGVector< complex128_t > &zeta_sh_old, const SGVector< complex128_t > &zeta_sh_cur, const SGVector< complex128_t > &shifts, const float64_t &beta_old, const float64_t &beta_cur, const float64_t &alpha, SGVector< complex128_t > &zeta_sh_new)
SGVector< float64_t > get_real()
void begin(const VectorXt &residual)
const index_t get_dimension() const
SGVector< float64_t > m_residuals
const bool end(const VectorXt &residual)
void compute_beta_sh(const SGVector< complex128_t > &zeta_sh_new, const SGVector< complex128_t > &zeta_sh_cur, const float64_t &beta_cur, SGVector< complex128_t > &beta_sh)
float64_t m_absolute_tolerence
float64_t cur_time_diff(bool verbose=false)
template class that is used as an iterator for an iterative linear solver. In the iteration of solvin...
float64_t start(bool verbose=false)
virtual ~CCGMShiftedFamilySolver()
const IterInfo get_iter_info() const
virtual SGVector< T > apply(SGVector< T > b) const =0
all of classes and functions are contained in the shogun namespace
index_t m_max_iteration_limit
const bool succeeded(const VectorXt &residual)
CCGMShiftedFamilySolver()
virtual SGVector< float64_t > solve(CLinearOperator< float64_t > *A, SGVector< float64_t > b)
virtual SGVector< complex128_t > solve_shifted_weighted(CLinearOperator< float64_t > *A, SGVector< float64_t > b, SGVector< complex128_t > shifts, SGVector< complex128_t > weights)
void compute_alpha_sh(const SGVector< complex128_t > &zeta_sh_cur, const SGVector< complex128_t > &zeta_sh_old, const SGVector< complex128_t > &beta_sh_old, const float64_t &beta_old, const float64_t &alpha, SGVector< complex128_t > &alpha_sh)
void set_const(T const_elem)
float64_t m_relative_tolerence
abstract template base for CG based solvers to the solution of shifted linear systems of the form fo...