bool fft(int n, double *wave, double *mag, double *phase) { int i, n2 = n/2; double n_2 = ((double)n)/2.0; double *x; fftw_plan p; x = fftw_malloc(n*sizeof(double)); if (!x) return false; p = fftw_plan_r2r_1d(n, x, x, FFTW_R2HC, FFTW_ESTIMATE); if (!p) { fftw_free(x); return false; } memcpy(x, wave, n*sizeof(double)); fftw_execute(p); mag[0] = myabs(x[0], 0.0)/n; phase[0] = myarg(x[0], 0.0); for (i = 1; i < n2; i++) { mag[i] = myabs(x[i], x[n-i])/n_2; phase[i] = myarg(x[i], x[n-i]); } if (n > 1) if (n%2 == 0) { mag[n2] = myabs(x[n2], 0.0)/n; phase[n2] = myarg(x[n2], 0.0); } else { mag[n2] = myabs(x[n2], x[n-n2])/n_2; phase[n2] = myarg(x[n2], x[n-n2]); } fftw_destroy_plan(p); fftw_free(x); return true; }
void Client::commandApop(const std::string &arg) { std::string myarg(arg.c_str()); unsigned int sep = myarg.find(" "); if (sep != std::string::npos && sep > 1) { std::string uname(myarg.substr(0, sep)); std::string upass(myarg.substr(sep + 1, 32)); if ((this->user_ = this->server_.getUserList().findUser(uname, upass)) != NULL) { std::string vals(this->MailsInfo(uname)); std::istringstream ss(vals); std::string s; std::string txt(uname); txt += "'s mailbox has "; ss >> s; txt.append(s); txt += " messages ("; ss >> s; txt += s; txt += " octets)"; std::cout << "yoo mama |" << txt << std::endl; this->response_.setCode("+Ok"); this->response_.setText(txt); this->request_.resetRequest(); }
int main() { { myarg a; boost::shared_ptr< X > x = boost::make_shared< X >(a); BOOST_TEST( x->constructed_by_ == X::ref_constructor); } { const myarg ca; boost::shared_ptr< X > x = boost::make_shared< X >(ca); BOOST_TEST( x->constructed_by_ == X::const_ref_constructor); } { boost::shared_ptr< X > x = boost::make_shared< X >(myarg()); BOOST_TEST( x->constructed_by_ == X::move_constructor); } { int value = 1; boost::shared_ptr< Y > y = boost::make_shared< Y >(value); BOOST_TEST( y->ref == 1 && value == y->ref ); ++y->ref; BOOST_TEST( value == y->ref ); } return boost::report_errors(); }