Real moment(const size_t m) const {
   Real val = 0., coeff = 0.;
   for (size_t i = 0; i < m+1; i++) {
     coeff = compute_coeff(m,i);
     val  += coeff*(std::pow(a_,i)*expa_-std::pow(b_,i)*expb_)/std::pow(scale_,m-i+1);
   } 
   return coeff_*val;
 }
示例#2
0
multi_adag_node::multi_adag_node(coeff_t c, bool is_targ, reg_t reg, sp_t sp, 
				 adag_node *src1, adag_node *src2)
    : adag_node(c, is_targ, reg) {
    src.resize(2); scales.resize(2);
    sp.normalize(src1->c, src2->c);
    src[0] = src1; scales[0] = sp.first;
    src[1] = src2; scales[1] = sp.second;
    depth = 1 + max(src1->depth, src2->depth);
    src[0]->add_parent(this); src[1]->add_parent(this);
    rsh = compute_shr(compute_coeff());
    verify();
}
示例#3
0
 Real moment(const size_t m) const {
   if ( m == 1 ) {
     return mean_;
   }
   if ( m == 2 ) {
     return std::pow(mean_,2) + 2.*std::pow(scale_,2);
   }
   Real coeff = 0., val = 0.;
   for (size_t k = 0; k < m+1; k++) {
     if ( k%2 == 0 ) {
       coeff = compute_coeff(m,k);
       val  += coeff*std::pow(scale_,k)*std::pow(mean_,m-k);
     }
   }
   return val;
 }