/* The estimate formula has the unfortunate property of being negative for small n. This will be the most negative. Add this as an extra boost to prevent negative flops estimates. */ static real worstFlops(real cQ, real d, real f) { real a = mw_pow(2.0, 3.0 - 3.0 * d / cQ); real b = (cQ - d) * mw_log(8.0); real c = cQ * mw_log(mw_pow(8.0, 1.0 - d / cQ)); return -a * sqr(f) * (cQ + b - c) / (M_E * mw_log(8.0)); }
/* Retrieve the current HEAD revision at SVN URL <path> */ static svn_revnum_t mw_get_head_rev(const char *path, struct callback_args *args, const char *project, FILE *logfp) { apr_pool_t *subpool; svn_revnum_t rev; svn_opt_revision_t pegrev, headrev; svn_error_t *err = NULL; subpool = svn_pool_create(args->pool); pegrev.kind = svn_opt_revision_unspecified; headrev.kind = svn_opt_revision_head; err = svn_client_info2(path, &pegrev, &headrev, &mw_revision_info_cb, &rev, svn_depth_empty, NULL, args->ctx, args->pool); if (err != NULL) { mw_log(logfp, "Error fetching info for project `%s' " "at path `%s': %s\n", project, path, err->message); fprintf(stderr, "Error fetching info for project `%s' " "at path `%s': %s\n", project, path, err->message); exit(1); } svn_pool_destroy(subpool); return (rev); }
real propability_match(int n, int k, real pobs){ real result; result = choose(n, k); result *= mw_pow(pobs, (real)k); result *= mw_pow((1-pobs), (real)(n-k)); result = mw_log(result); return result; }
static inline mwvector nfwHaloAccel(const Halo* halo, mwvector pos, real r) { const real a = halo->scaleLength; const real ar = a + r; // const real c = a * sqr(halo->vhalo) * (r - ar * mw_log((r + a) / a)) / (0.2162165954 * cube(r) * ar); /* this is done to agree with NEMO. IDK WHY. IDK where 0.2162165954 comes from */ const real c = a * sqr(a) * 237.209949228 * (r - ar * mw_log((r + a) / a)) / ( cube(r) * ar); return mw_mulvs(pos, c); }
/* This is called by the project processor, and runs a checkout for each * project. */ static void mw_conf_list_get(struct mw_conf_head *r, const char *project, struct callback_args *args) { struct conf_list_entry *node; FILE *logfp; char *approot, *cpos, *project_dir, buf[MAXPATHLEN], canonical[MAXPATHLEN]; char slink[MAXPATHLEN]; char true_url[MAXPATHLEN]; int found = 0; svn_revnum_t revnum, result_revnum; svn_opt_revision_t revision, pegrev; apr_pool_t *subpool; svn_error_t *err = NULL; pegrev.kind = svn_opt_revision_unspecified; /* Open our per-project checkout log. This needs to go in /tmp * initially, because we don't have a project checked out */ if ((logfp = fdopen(args->logfd, "a")) == NULL) { exit(1); syslog(LOG_ERR, "mwbuild: %s failed for %s", "get", project); } /* Find the PROJECT_SVN path for this project */ TAILQ_FOREACH(node, r, conf_node_list) { if (node->conf->key != NULL && strcmp(node->conf->key, "PROJECT_SVN") == 0) { found = 1; break; } } /* We MUST have a PROJECT_SVN value for each project */ if (!found) { fprintf(stderr, "could not find valid PROJECT_SVN value for project `%s'\n", project); mw_log(logfp, "could not find valid PROJECT_SVN value for project `%s'", project); syslog(LOG_ERR, "mwbuild: %s failed for %s", "get", project); exit(1); } revision.kind = svn_opt_revision_number; /* Couldn't find a revision, fetch revision of HEAD */ if ((revnum = mw_svn_rev(node->conf->value)) == -1) { /* Shorten SVN string to just the URL part */ if ((cpos = strchr(node->conf->value, ':')) != NULL) { *cpos = '\0'; } /* Build up the URL */ xsnprintf(true_url, sizeof(true_url), "%s/%s", SVN_ROOT, node->conf->value); revision.value.number = mw_get_head_rev(true_url, args, project, logfp); } else { /* Shorten SVN string to just the URL part */ if ((cpos = strchr(node->conf->value, ':')) != NULL) { *cpos = '\0'; } /* Build up the URL */ xsnprintf(true_url, sizeof(true_url), "%s/%s", SVN_ROOT, node->conf->value); revision.value.number = revnum; } /* Build up the (temporary) local path for checkout */ project_dir = mw_get_config_var(r, PROJECT_DIR); approot = mw_get_config_var(r, MWBUILD_APPROOT); xsnprintf(buf, sizeof(buf), "%s/%s_%ld", approot, project_dir, revision.value.number); /* On some systems (notably linux), realpath(3) needs the full path to exist first */ if (mw_mkpath(buf) == -1) { fprintf(stderr, "mw_mkpath() failure\n"); } if (realpath(buf, canonical) == NULL) { fprintf(stderr, "Could not canonicalise path: %s: %s\n", buf, strerror(errno)); mw_log(logfp, "Could not canonicalise path: %s: %s\n", buf, strerror(errno)); syslog(LOG_ERR, "mwbuild: %s failed for %s", "get", mw_get_config_var(r, PROJECT_SVN)); exit(1); } subpool = svn_pool_create(args->pool); printf("Checking out %s:%ld to %s\n", true_url, revision.value.number, canonical); mw_log(logfp, "Checking out %s:%ld to %s", true_url, revision.value.number, canonical); /* Run the actual checkout */ err = svn_client_checkout2(&result_revnum, true_url, canonical, &pegrev, &revision, TRUE, args->opt_state->ignore_externals, args->ctx, subpool); svn_pool_destroy(subpool); if (err != NULL) { fprintf(stderr, "Error checking out project `%s' at URL `%s': %s\n", project, true_url, err->message); mw_log(logfp, "Error checking out project `%s' at URL `%s': %s", project, true_url, err->message); syslog(LOG_ERR, "mwbuild: %s failed for %s", "get", mw_get_config_var(r, PROJECT_SVN)); exit(1); } /* Update symlink */ xsnprintf(slink, sizeof(slink), "%s/%s", approot, project_dir); (void) unlink(slink); if (symlink(canonical, slink) == -1) { fprintf(stderr, "Error symlinking %s to %s: %s\n", slink, canonical, strerror(errno)); mw_log(logfp, "Error symlinking %s to %s: %s", slink, canonical, strerror(errno)); syslog(LOG_ERR, "mwbuild: %s failed for %s", "get", mw_get_config_var(r, PROJECT_SVN)); exit(1); } syslog(LOG_DEBUG, "mwbuild: %s succeeded for %s", "get", mw_get_config_var(r, PROJECT_SVN)); }
static inline real log8(real x) { return mw_log(x) / mw_log(8.0); }