int main() { #include "ellint_e2_data.ipp" add_data(data1); add_data(ellint_e2_data); unsigned data_total = data.size(); screen_data([](const std::vector<double>& v){ return boost::math::ellint_2(v[1], v[0]); }, [](const std::vector<double>& v){ return v[2]; }); #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES) screen_data([](const std::vector<double>& v){ return std::tr1::ellint_2(v[1], v[0]); }, [](const std::vector<double>& v){ return v[2]; }); #endif #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES) screen_data([](const std::vector<double>& v){ return gsl_sf_ellint_E(v[0], v[1], GSL_PREC_DOUBLE); }, [](const std::vector<double>& v){ return v[2]; }); #endif unsigned data_used = data.size(); std::string function = "ellint_2[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)"; std::string function_short = "ellint_2"; double time; time = exec_timed_test([](const std::vector<double>& v){ return boost::math::ellint_2(v[1], v[0]); }); std::cout << time << std::endl; #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX)) report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name()); #endif report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name()); // // Boost again, but with promotion to long double turned off: // #if !defined(COMPILER_COMPARISON_TABLES) if(sizeof(long double) != sizeof(double)) { time = exec_timed_test([](const std::vector<double>& v){ return boost::math::ellint_2(v[1], v[0], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); }); std::cout << time << std::endl; #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH) || defined(TEST_LIBSTDCXX)) report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name() + "[br]promote_double<false>"); #endif report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name() + "[br]promote_double<false>"); } #endif #if defined(TEST_LIBSTDCXX) && !defined(COMPILER_COMPARISON_TABLES) time = exec_timed_test([](const std::vector<double>& v){ return std::tr1::ellint_2(v[1], v[0]); }); std::cout << time << std::endl; report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "tr1/cmath"); #endif #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES) time = exec_timed_test([](const std::vector<double>& v){ return gsl_sf_ellint_E(v[0], v[1], GSL_PREC_DOUBLE); }); std::cout << time << std::endl; report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "GSL " GSL_VERSION); #endif return 0; }
static int smtp_mail(FILE *fp, char *to, char *subj) { int rc, fd; char buffie[1024] ; fd = smtp_open(conffile.smtp_mta, conffile.smtp_portnum, conffile.smtp_helo); if (fd < 0) { return child_perror("Smtp_open"); } rc = set_envelope(fd, conffile.smtp_from, to); if (rc < 0) { return child_perror("Smtp_envelope"); } rc = set_data(fd); if (rc < 0) { return child_perror("Smtp_data"); } if (subj) add_header(fd, "Subject", subj); if (conffile.smtp_reply_to) add_header(fd, "Reply-To", conffile.smtp_reply_to); add_header(fd, "X-NNGS-SMTP", "Yes, Baby!" ); add_header(fd, NULL, 0); while(fgets(buffie, sizeof buffie, fp)) { rc = add_data(fd, buffie, 0); if (rc < 0) { return child_perror("Smtp_loop"); } } add_data(fd, NULL, 0); close(fd); return 0; }
int main() { int rc, fd; char buffie[512] ; fd = smtp_open(NULL, WANTED_SMTP_PORT, NULL); if (fd < 0) goto kut; set_envelope(fd, "nngs@localhost", "nngs@localhost"); rc = set_data(fd); if (rc < 0) goto kut; add_header(fd, "Subject", "Kuttje (met twee thee)"); add_header(fd, "Reply-To", "nngs@localhost"); add_header(fd, NULL, 0); add_data(fd, "En een droge sherry, alstublieft!\n", 0); while(fgets(buffie, sizeof buffie, stdin)) { rc = add_data(fd, buffie, 0); /* sleep(1); */ if (rc < 0) break; } add_data(fd, NULL, 0); sleep(10); close(fd); kut: exit(0); }
int main() { # include "ibeta_small_data.ipp" # include "ibeta_data.ipp" # include "ibeta_large_data.ipp" # include "ibeta_int_data.ipp" add_data(ibeta_small_data); add_data(ibeta_data); add_data(ibeta_large_data); add_data(ibeta_int_data); unsigned data_total = data.size(); std::cout << "Screening boost data:\n"; screen_data([](const std::vector<double>& v){ return boost::math::ibetac(v[0], v[1], v[2]); }, [](const std::vector<double>& v){ return v[6]; }); #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES) std::cout << "Screening libstdc++ data:\n"; screen_data([](const std::vector<double>& v){ return ::pbeta(v[2], v[0], v[1], 0, 0); }, [](const std::vector<double>& v){ return v[6]; }); #endif unsigned data_used = data.size(); std::string function = "ibetac[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)"; std::string function_short = "ibetac"; double time; time = exec_timed_test([](const std::vector<double>& v){ return boost::math::ibetac(v[0], v[1], v[2]); }); std::cout << time << std::endl; #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH)) report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name()); #endif report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name()); // // Boost again, but with promotion to long double turned off: // #if !defined(COMPILER_COMPARISON_TABLES) if(sizeof(long double) != sizeof(double)) { time = exec_timed_test([](const std::vector<double>& v){ return boost::math::ibetac(v[0], v[1], v[2], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); }); std::cout << time << std::endl; #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH)) report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name() + "[br]promote_double<false>"); #endif report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name() + "[br]promote_double<false>"); } #endif #if defined(TEST_RMATH) && !defined(COMPILER_COMPARISON_TABLES) time = exec_timed_test([](const std::vector<double>& v){ return ::pbeta(v[2], v[0], v[1], 0, 0); }); std::cout << time << std::endl; report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "Rmath " R_VERSION_STRING); #endif return 0; }
int main(void) { int addseccount = 0; /* 文件系统后边添加的扇区数 */ if(-1 == mkfs()) { printf("ERROR: make file-system error!\n"); return -1; } if(-1 == (addseccount=add_data())) { printf("ERROR: add data to disk error!\n"); return -1; } printf("===OK!\n"); printf("Size of FS is %f MB, total %d sectors.\n", HEADS*SPT*CYLINDERS * 512.0/1024.0/1024.0, HEADS*SPT*CYLINDERS); printf("Size of DISK is %f MB, total %d sectors.\n", (HEADS*SPT*CYLINDERS + addseccount) * 512.0/1024.0/1024.0, (HEADS*SPT*CYLINDERS + addseccount)); printf(" FS -- cylinders: %d, heads: %d, spt: %d.\n", CYLINDERS, HEADS, SPT); printf("DISK -- cylinders: %d, heads: %d, spt: %d.\n", CYLINDERS + addseccount/HEADS/SPT, HEADS, SPT); printf("###Please check 'Bochs' or 'VMware' configuration.\n"); printf("mkfs exit.\n\n"); return 0; }
void add(char *database_name, char *table_name, void *data) { if (true == add_data(database_name, table_name, data)) { printf("add \"%s\" in \"%s\" \n", data, table_name); } else { printf("failed to add \"%s\" in \"%s\" \n", data, table_name); } }
SSLM::StateSpaceLogitModel(const Vector &successes, const Vector &trials, const Matrix &design, const std::vector<bool> &observed) : StateSpaceNormalMixture(ncol(design)), observation_model_(new BinomialLogitModel(ncol(design))) { setup(); bool all_observed = observed.empty(); if (successes.size() != trials.size() || successes.size() != nrow(design) || (!all_observed && successes.size() != observed.size())) { report_error("Data sizes do not match in StateSpaceLogitModel " "constructor"); } for (int i = 0; i < successes.size(); ++i) { NEW(ABRD, dp)(successes[i], trials[i], design.row(i)); if (!(all_observed || observed[i])) { dp->set_missing_status(Data::missing_status::completely_missing); } add_data(dp); } }
hash_manager::content_page::content_page(const char buffer[hash_manager::page_size]) : page(buffer) { std::bitset<n_data> data_bitmap(chars_to_int(&buffer[9])); int j = 0; for (int i=13 ; i<page_size-7 ; i+=8) { if (data_bitmap[j++]) add_data(std::make_pair(chars_to_int(&buffer[i]),chars_to_int(&buffer[i+4]))); } }
/** * Send a message on a queue. * * Send / queue a message. * This service may panic if err parameter is NULL and: * -# queue parameter is invalid, or * -# the queue is already full, or * * Authorized execution levels: task, fiber, ISR. * * @param queue: handler on the queue (value returned by queue_create). * * @param message (in): pointer to the message to send. * * @param err (out): execution status: * -# E_OS_OK : a message was read * -# E_OS_ERR_OVERFLOW: the queue is full (message was not posted) * -# E_OS_ERR: invalid parameter */ void queue_send_message(T_QUEUE queue, T_QUEUE_MESSAGE message, OS_ERR_TYPE* err ) { OS_ERR_TYPE _err; queue_impl_t * q = (queue_impl_t*) queue; /* check input parameters */ if( queue_used(q) && q->sema != NULL ) { uint32_t it_mask = interrupt_lock(); _err = add_data(q, message); interrupt_unlock(it_mask); if(_err == E_OS_OK) { semaphore_give(q->sema, &_err); // signal new message in the queue to the listener. error_management (err, E_OS_OK); } else { error_management (err, _err); } } else { /* param invalid */ error_management (err, E_OS_ERR); } return; }
static int add_dir(const char *name, int parent) { struct jffs2_raw_inode ri; int inode; inode = add_dirent(name, IFTODT(S_IFDIR), parent); if (rbytes() < sizeof(ri)) pad(erasesize); prep_eraseblock(); memset(&ri, 0, sizeof(ri)); ri.magic = JFFS2_MAGIC_BITMASK; ri.nodetype = JFFS2_NODETYPE_INODE; ri.totlen = sizeof(ri); ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4); ri.ino = inode; ri.mode = S_IFDIR | 0755; ri.uid = ri.gid = 0; ri.atime = ri.ctime = ri.mtime = 0; ri.isize = ri.csize = ri.dsize = 0; ri.version = 1; ri.node_crc = crc32(0, &ri, sizeof(ri) - 8); ri.data_crc = 0; add_data((char *) &ri, sizeof(ri)); pad(4); return inode; }
void add_field_data(struct session *s,struct transaction * t,INT2 fn,char * p,int c) { s->debug(2,"Sending parm %d value %s\n",fn,p); add_int2field(t,htons(fn)); add_data(t,p,c); }
int Packet::add_data(uint8_t *buffer, int length) { if(buffer_length < 4) { for(int i = buffer_length; i < buffer_length + length; i++) { this->length += uint32_t(buffer[0]) << ((3 - i) * 8); buffer++; buffer_length++; length--; } if(buffer_length + length >= 4) { this->buffer = new uint8_t[this->length]; } add_data(buffer, length); } else { int maxlength = length; if(buffer_length + length > this->length + 4) { maxlength = length - buffer_length - 4; } memcpy(this->buffer + buffer_length, buffer, maxlength); buffer_length += maxlength; return length - maxlength; } return 0; }
/* read stec grid data body --------------------------------------------------*/ static void read_stecb(FILE *fp, nav_t *nav) { gtime_t time; double tow,pos[2],iono,rate,rms; char buff[256],id[64]; int week,sat,slip; trace(3,"read_stecb:\n"); while (fgets(buff,sizeof(buff),fp)) { /* read position */ if (sscanf(buff,"$SPOS %d %lf %lf %lf",&week,&tow,pos,pos+1)>=4) { /* add stec grid */ if (!add_grid(nav,pos)) break; } /* read ionos */ if (sscanf(buff,"$STEC %d %lf %s %d %lf %lf %lf",&week,&tow,id,&slip, &iono,&rate,&rms)>=6) { if (nav->nn<=0||!(sat=satid2no(id))) continue; time=gpst2time(week,tow); /* add grid data */ if (!add_data(nav->stec+nav->nn-1,time,sat,slip,iono,rate,rms)) { break; } } } }
static void prep_eraseblock(void) { if (ofs > 0) return; add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1); }
void nstx_handlepacket(const char *ptr, size_t len, void (*nstx_usepacket)(const char*, size_t)) { struct nstxhdr *nstxpkt = (struct nstxhdr *) ptr; struct nstx_item *nstxitem; char *netpacket; int netpacketlen; if ((!ptr) || (signed int) len < (signed int) sizeof(struct nstxhdr)) return; if (!nstxpkt->id) return; nstxitem = get_item_by_id(nstxpkt->id); if (!nstxitem) nstxitem = alloc_item(nstxpkt->id); if (add_data(nstxitem, nstxpkt, len)) { netpacket = dealloc_item(nstxitem, &netpacketlen); nstx_usepacket(netpacket, netpacketlen); } check_timeouts(); }
void add_data(AVL **tree, char *k, int n) { if (*tree == NULL) { *tree = GetNode(); strcpy((*tree)->key, k); (*tree)->line_num = n; return; } else if ((*tree)->key[0] < k[0]) { add_data(&(*tree)->right, k, n); } else if ((*tree)->key[0] >= k[0]) { add_data(&(*tree)->left, k, n); } }
double delete_test(OSyncEngine *engine, OSyncMember *member, int num, const char *objtype) { printf("Test \"Delete %i\" starting", num); fflush(stdout); empty_all(engine); printf("."); fflush(stdout); int i = 0; for (i = 0; i < num; i++) add_data(member, objtype); printf("."); fflush(stdout); check_sync(engine, "None", num); printf("."); fflush(stdout); delete_data(member, objtype); printf("."); fflush(stdout); return check_sync(engine, "Delete", num); }
//------------------------------------------------------------ MLB::MLogitBase(ResponseVec responses, const Mat &Xsubject, const std::vector<Mat> &Xchoice) : DataPolicy(), PriorPolicy(), choice_data_wsp_(new Mat), nch_(responses[0]->nlevels()), psub_(Xsubject.ncol()), pch_(0) { uint n = responses.size(); if(nrow(Xsubject) != n || (!Xchoice.empty() && Xchoice.size() != n)){ ostringstream err; err << "Predictor sizes do not match in MLogitBase constructor" << endl << "responses.size() = " << n << endl << "nrow(Xsubject) = " << nrow(Xsubject) << endl; if(!Xchoice.empty()){ err << "Xchoice.size() = " << Xchoice.size() << endl; } report_error(err.str()); } for(uint i=0; i<n; ++i){ NEW(VectorData, subject)(Xsubject.row(i)); std::vector<Ptr<VectorData> > choice; if(!Xchoice.empty()){ const Mat & choice_matrix(Xchoice[i]); if(pch_ == 0){ pch_ = ncol(choice_matrix); }else if(pch_ != ncol(choice_matrix)){ ostringstream err; err << "The number of columns in the choice matrix for observation " << i << " did not match previous observations." << endl << "ncol(Xsubject[i]) = " << ncol(choice_matrix) << endl << "previously: " << pch_ << endl; report_error(err.str()); } if(nrow(choice_matrix) != nch_){ ostringstream err; err << "The number of rows in choice matrix does not match the " << "number of choices available in the response." << endl << "response: " << nch_ << endl << "Xchoice[" << i << "]: " << nrow(choice_matrix) << endl; report_error(err.str()); } for(uint j=0; j<nch_; ++j){ NEW(VectorData, ch)(choice_matrix.row(j)); choice.push_back(ch); } } NEW(ChoiceData, dp)(*responses[i], subject, choice); add_data(dp); } }
void MixtureDataPolicy::add_data_with_known_source( const Ptr<DataType> &data_point, int source) { if (known_data_source_.empty()) { known_data_source_.assign(dat().size(), -1); } add_data(data_point); known_data_source_.push_back(source); }
void modbuf::add_size( int len ) { unsigned char *zeros = new unsigned char[len]; memset( zeros, 0, len ); add_data( zeros, len ); delete[] zeros; }
void PrefsReplaceInt16(const char *name, int16 val) { prefs_node *p = find_node(name, TYPE_INT16); if (p) *(int16 *)(p->data) = val; else add_data(name, TYPE_INT16, &val, sizeof(int16)); }
void PrefsReplaceBool(const char *name, bool b) { prefs_node *p = find_node(name, TYPE_BOOLEAN); if (p) *(bool *)(p->data) = b; else add_data(name, TYPE_BOOLEAN, &b, sizeof(bool)); }
void PrefsReplaceInt32(const char *name, int32 val) { prefs_node *p = find_node(name, TYPE_INT32); if (p) *(int32 *)(p->data) = val; else add_data(name, TYPE_INT32, &val, sizeof(int32)); }
void ReachingDefinitionBase:: add_ref( const std::string& varname, const AstNodePtr& scope, const std::pair<AstNodePtr,AstNodePtr>& def) { std::string scopename = scopemap.get_string(scope); std::string name = varname + scopename; if (DebugReachingDef()) std:: cerr << "adding variable name: " << name << "\n"; add_data(name, def); }
void PrefsReplaceString(const char *name, const char *s, int index) { prefs_node *p = find_node(name, TYPE_STRING, index); if (p) { free(p->data); p->data = strdup(s); } else add_data(name, TYPE_STRING, (void *)s, strlen(s) + 1); }
HomogeneousPoissonProcess::HomogeneousPoissonProcess( const std::vector<DateTime> ×tamps) : ParamPolicy(new UnivParams(1.0)), DataPolicy(new PoissonProcessSuf) { NEW(PointProcess, data)(timestamps); add_data(data); mle(); }
// 追加する void regist_data(){ Bookdata tmp; Bookdata *tail; init_data(&tmp); input_data(&tmp); tail = malloc(sizeof(Bookdata)); *tail = tmp; add_data(tail); }
char *askUserPass(const char *title) { static window win = NULL; dialog_data *d; window prev = current_window; if (! win) { int tw, bw, h, middle; tw = strwidth(SystemFont, G_("Cancel")) * 8; h = getheight(SystemFont); if (tw < 150) tw = 150; win = newwindow(title, rect(0, 0, tw+30, h*9+12), Titlebar | Centered | Modal); setbackground(win, dialog_bg()); add_data(win); d = data(win); d->question = newlabel(G_("User"), rect(10, h, tw+4, h*2+2), AlignLeft); bw = strwidth(SystemFont, G_("Password")); d->text = newfield("", rect(20+bw, h, tw-6-bw, h*3/2)); newlabel(_("Password"), rect(10, h*4, tw+4, h*2+2), AlignLeft); d->pass = newpassword("", rect(20+bw, h*4, tw-6-bw, h*3/2)); middle = (tw+30)/2; bw = strwidth(SystemFont, G_("Cancel")) * 3/2; d->yes = newbutton(G_("OK"), rect(middle-bw-10, h*7, bw, h+10), hit_button); setvalue(d->yes, YES); d->cancel = newbutton(G_("Cancel"), rect(middle+10, h*7, bw, h+10), hit_button); setvalue(d->cancel, CANCEL); setkeydown(win, hit_key); } else { d = data(win); settext(d->text, ""); settext(d->pass, ""); } if (TopmostDialogs & MB_TOPMOST) BringToTop(win, 1); handle_message_dialog(win); current_window = prev; { char *user, *pass; static char buf[1000]; if (d->hit < YES) /* cancelled */ return ""; if (d->text) user = new_string(GA_gettext(d->text)); else return ""; if (d->pass) pass = new_string(GA_gettext(d->pass)); else return ""; snprintf(buf, 1000, "%s:%s", user, pass); return buf; } return ""; /* -Wall */ }
/*************************************************************************** * Function: int get_connection(int port_fd) * * Description: * Accept a new connection from the indicated port and add it to the list * of current connections. Return TRUE if a connection was successfully * accepted, FALSE otherwise. **************************************************************************/ static int get_connection(int port_fd) { conn_data *conn; struct sockaddr_in s_address; int new_fd, s_addr_size; extern int errno; /* * Prepare to accept a new connection by getting the local port's name. */ s_addr_size = sizeof(s_address); if (getsockname(port_fd, (struct sockaddr *)&s_address, &s_addr_size) < 0) { fprintf(stderr, "Error: Couldn't get socket name from fd %d.\n", port_fd); perror(" get_connection(getsockname)"); exit(ERROR); } /* * Accept the new connection off of the port/socket. If errno == EWOULDBLOCK, * there wasn't really a new connection to accept, so return FALSE. If there * _was_ a new connection, set the file descriptor that has been associated * with it non_blocking. */ if ((new_fd = accept(port_fd, (struct sockaddr *)&s_address, &s_addr_size)) < 0) { if (errno == EWOULDBLOCK) return(FALSE); fprintf(stderr, "Error: Couldn't accept new connection from fd %d.\n", port_fd); perror(" get_connection(accept)"); exit(ERROR); } fd_noblock(new_fd); /* * Create and initialize a conn_data object for the new connection, and * add it to the list of connections. */ if ((conn = (conn_data *)malloc(sizeof(conn_data))) == NULL) { fprintf(stderr, "Error: Memory allocation failed.\n"); perror(" get_connection(malloc)"); exit(ERROR); } bzero(conn, sizeof(conn_data)); conn->fd = new_fd; sprint_ipnum(conn->addr, &s_address); time(&(conn->connect_time)); conn->input = create_list(); conn->output = create_list(); add_data(conn_list, conn, PREPEND); fprintf(stderr, "Connect on fd %d from %s assigned fd %d (%s)\n", port_fd, conn->addr, conn->fd, ctime(&(conn->connect_time))); welcome(conn); return(TRUE); }
LogisticRegressionModel::LogisticRegressionModel (const Mat &X, const Vec &y, bool add_int) : ParamPolicy(new GlmCoefs(X.ncol())), log_alpha_(0) { int n = nrow(X); for(int i = 0; i < n; ++i){ NEW(BinaryRegressionData, dp)(y[i]>.5,X.row(i)); add_data(dp); } }