int main(int argc, char **argv) { YAZ_CHECK_INIT(argc, argv); YAZ_CHECK_LOG(); #if YAZ_HAVE_ICU check_icu_casemap(); check_icu_sortmap(); check_icu_normalizer(); check_icu_tokenizer(); check_icu_chain(); check_chain_empty_token(); check_chain_empty_chain(); check_icu_iter1(); check_icu_iter2(); check_icu_iter3(); check_icu_iter4(); check_bug_1140(); check_norm(); u_cleanup(); #else /* YAZ_HAVE_ICU */ yaz_log(YLOG_LOG, "ICU unit tests omitted"); YAZ_CHECK(0 == 0); #endif /* YAZ_HAVE_ICU */ YAZ_CHECK_TERM; }
static int cdf_dnorm (lua_State *L) { /* stack should contain x, and opt. mean and sd */ lua_Number x = luaL_checknumber(L, 1); lua_Number mean = luaL_optnumber(L, 2, 0); lua_Number sd = luaL_optnumber(L, 3, 1); lua_Number d; check_norm(L, 1, x, sd); d = (x-mean)/sd; d = exp(-d*d/2)/(sqrt(2*M_PI)*sd); lua_pushnumber(L, d); return 1; }
static int stat_pnorm (lua_State *L) { /* stack should contain x, and opt. mean and sd */ lua_Number x = luaL_checknumber(L, 1); lua_Number mean = luaL_optnumber(L, 2, 0); lua_Number sd = luaL_optnumber(L, 3, 1); lua_Number p, q, bound; int which = 1; int status; check_norm(L, 1, x, sd); cdfnor(&which, &p, &q, &x, &mean, &sd, &status, &bound); check_status(L, status, bound); lua_pushnumber(L, p); return 1; }
static int cdf_qnorm (lua_State *L) { /* stack should contain p, and opt. mean and sd */ lua_Number p = luaL_checknumber(L, 1); lua_Number mean = luaL_optnumber(L, 2, 0); lua_Number sd = luaL_optnumber(L, 3, 1); lua_Number x; check_norm(L, 2, p, sd); if (p==0 || p==1) x = (p==0) ? -HUGE_VAL : HUGE_VAL; else { lua_Number q = 1-p; lua_Number bound; int which = 2; int status; cdfnor(&which, &p, &q, &x, &mean, &sd, &status, &bound); check_status(status, bound); } lua_pushnumber(L, x); return 1; }