Exemple #1
0
//=============================================================================
bool bicg
(
 const CPPL::dgematrix& A,
 //const CPPL::dgsmatrix& A,
 CPPL::dcovector& x,
 const double& eps
)
{
  double alpha, beta(0.0);
  CPPL::dcovector p_0(x.l), p_1, P_0(x.l), P_1, q, Q;
  CPPL::dcovector r_1(x), r_2, R_1(r_1), R_2;
  double rho_0(r_1%R_1), rho_1;
  x.zero();
  p_0.zero();
  P_0.zero();
  
  int itc(0);
  const int itmax(2*x.l);
  while(fabs(damax(r_1))>eps && ++itc<itmax){
    std::cout << itc << " " << fabs(damax(r_1)) << std::endl;
    
    rho_1 =r_1%R_1;
    beta =rho_1/rho_0;
    p_1 =r_1 +beta*p_0;
    P_1 =R_1 +beta*P_0;
    q =A*p_1;
    Q =t(t(P_1)*A);
    alpha =rho_1/(P_1%q);
    x +=alpha*p_1;
    r_2 =r_1 -alpha*q;
    R_2 =R_1 -alpha*Q;

    rho_0 =rho_1;
    swap(p_0, p_1);
    swap(P_0, P_1);
    swap(r_1, r_2);
    swap(R_1, R_2);
  }
  std::cerr << "itc=" << itc << "  fabs(damax(r_1))=" << fabs(damax(r_1)) << std::endl;
  
  if(itc<itmax){ return 0; }
  else{ return 1; }
}
Exemple #2
0
void AR_Test_Combine_Abutting(const TAlignRange& r, const TAlignRange& r_a, const TAlignRange& r_res)
{
    BOOST_REQUIRE(r.IsAbutting(r_a)); // precondition
    BOOST_REQUIRE(r_a.IsAbutting(r));

    TAlignRange r_1(r);
    r_1.CombineWithAbutting(r_a);
    TAlignRange r_2 = r.CombinationWithAbutting(r_a);

    // check that the operation is symmetrical
    TAlignRange r_3(r_a);
    r_3.CombineWithAbutting(r);
    TAlignRange r_4 = r_a.CombinationWithAbutting(r);

    BOOST_CHECK_EQUAL(r_res, r_1);
    BOOST_CHECK_EQUAL(r_res, r_2);
    BOOST_CHECK_EQUAL(r_res, r_3);
    BOOST_CHECK_EQUAL(r_res, r_4);
}