int scheduler_start(lua_State *L) { luaL_checktype(L,1,LUA_TTABLE); hive_createenv(L); struct global_queue * gmq = lua_newuserdata(L, sizeof(*gmq)); globalmq_init(gmq); lua_pushvalue(L,-1); hive_setenv(L, "message_queue"); lua_State *sL; sL = scheduler_newtask(L); luaL_requiref(sL, "cell.system", cell_system_lib, 0); lua_pop(sL,1); struct cell * sys = cell_new(sL, "system.lua"); if (sys == NULL) { return 0; } scheduler_starttask(sL); lua_getfield(L,1, "thread"); int thread = luaL_optinteger(L, -1, DEFAULT_THREAD); lua_pop(L,1); struct timer * t = lua_newuserdata(L, sizeof(*t)); timer_init(t,sys,gmq); _start(gmq,thread,t); cell_close(sys); return 0; }
static UnitCell *new_shifted_cell(UnitCell *input, int k, double shift) { UnitCell *cell; double asx, asy, asz; double bsx, bsy, bsz; double csx, csy, csz; cell = cell_new(); cell_get_reciprocal(input, &asx, &asy, &asz, &bsx, &bsy, &bsz, &csx, &csy, &csz); switch ( k ) { case REF_ASX : asx += shift; break; case REF_ASY : asy += shift; break; case REF_ASZ : asz += shift; break; case REF_BSX : bsx += shift; break; case REF_BSY : bsy += shift; break; case REF_BSZ : bsz += shift; break; case REF_CSX : csx += shift; break; case REF_CSY : csy += shift; break; case REF_CSZ : csz += shift; break; } cell_set_reciprocal(cell, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); return cell; }
void convert_lines(DataRow * row, std::vector<std::string> lines) { std::vector<std::string>::iterator it = lines.begin(); for (; it != lines.end(); it++) { DataCell * cell = cell_new(NULL, NULL); cell_set(cell, "", "", it->c_str(), 0); row_append(row, cell); } }
UnitCell *cell_new_from_parameters(double a, double b, double c, double alpha, double beta, double gamma) { UnitCell *cell; cell = cell_new(); if ( cell == NULL ) return NULL; cell_set_parameters(cell, a, b, c, alpha, beta, gamma); return cell; }
inline static grn_cell * cons(grn_query *q, grn_cell *car, grn_cell *cdr) { grn_cell *c; if ((c = cell_new(q))) { c->header.type = GRN_CELL_LIST; c->u.l.car = car; c->u.l.cdr = cdr; return c; } else { return NIL; } }
inline static grn_cell * op_new(grn_query *q, int8_t op, int16_t weight, int8_t mode, int32_t option) { grn_cell *c; if ((c = cell_new(q))) { c->header.type = GRN_CELL_OP; c->u.op.op = op; c->u.op.weight = weight; c->u.op.mode = mode; c->u.op.option = option; return c; } else { return NIL; } }
UnitCell *cell_new_from_direct_axes(struct rvec a, struct rvec b, struct rvec c) { UnitCell *cell; cell = cell_new(); if ( cell == NULL ) return NULL; cell->ax = a.u; cell->ay = a.v; cell->az = a.w; cell->bx = b.u; cell->by = b.v; cell->bz = b.w; cell->cx = c.u; cell->cy = c.v; cell->cz = c.w; cell->rep = CELL_REP_CART; return cell; }
inline static grn_cell * token_new(grn_query *q, const char *start, const char *end) { grn_cell *c; if (start >= end) { return NIL; } if ((c = cell_new(q))) { unsigned int len = end - start; c->header.type = GRN_CELL_STR; c->u.b.value = (char *)start; c->u.b.size = len; q->cur_expr++; return c; } else { return NIL; } }
UnitCell *cell_new_from_reciprocal_axes(struct rvec as, struct rvec bs, struct rvec cs) { UnitCell *cell; cell = cell_new(); if ( cell == NULL ) return NULL; cell->axs = as.u; cell->ays = as.v; cell->azs = as.w; cell->bxs = bs.u; cell->bys = bs.v; cell->bzs = bs.w; cell->cxs = cs.u; cell->cys = cs.v; cell->czs = cs.w; cell->rep = CELL_REP_RECIP; return cell; }
void convert_row(DataPage * page, std::vector<Cell> cells) { if (cells.size() <= 0) { return; } DataRow * row = row_new(cells[0].key.row.c_str()); std::vector<Hypertable::ThriftGen::Cell>::iterator it = cells.begin(); int index = 1; for (; it != cells.end(); it++) { DataCell * cell = cell_new(NULL, NULL); cell_set(cell, it->key.column_family.c_str(), it->key.column_qualifier.c_str(), it->value.c_str(), it->key.revision); row_append(row, cell); index++; } //add row page_append(page, row); }
NTSTATUS cell_connect_dn(struct likewise_cell **c, const char *dn) { NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; struct likewise_cell *new_cell = NULL; char *dns_domain = NULL; if (*c || !dn) { nt_status = NT_STATUS_INVALID_PARAMETER; BAIL_ON_NTSTATUS_ERROR(nt_status); } if ((new_cell = cell_new()) == NULL) { nt_status = NT_STATUS_NO_MEMORY; BAIL_ON_NTSTATUS_ERROR(nt_status); } /* Set the DNS domain, dn, etc ... and add it to the list */ dns_domain = cell_dn_to_dns(dn); cell_set_dns_domain(new_cell, dns_domain); SAFE_FREE(dns_domain); cell_set_dn(new_cell, dn); nt_status = cell_connect(new_cell); BAIL_ON_NTSTATUS_ERROR(nt_status); *c = new_cell; done: if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(1,("LWI: Failled to connect to cell \"%s\" (%s)\n", dn ? dn : "NULL", nt_errstr(nt_status))); talloc_destroy(new_cell); } return nt_status; }
int main(int argc, char *argv[]) { int fail = 0; struct quaternion orientation; UnitCell *cell; double asx, asy, asz; double bsx, bsy, bsz; double csx, csy, csz; double asmag, bsmag, csmag; double als, bes, gas; double ax, ay, az; double bx, by, bz; double cx, cy, cz; gsl_rng *rng; rng = gsl_rng_alloc(gsl_rng_mt19937); cell = cell_new_from_parameters(27.155e-9, 28.155e-9, 10.987e-9, deg2rad(90.0), deg2rad(90.0), deg2rad(120.0)); if ( cell == NULL ) return 1; orientation = random_quaternion(rng); cell = cell_rotate(cell, orientation); cell_get_reciprocal(cell, &asx, &asy, &asz, &bsx, &bsy, &bsz, &csx, &csy, &csz); asmag = sqrt(pow(asx, 2.0) + pow(asy, 2.0) + pow(asz, 2.0)); bsmag = sqrt(pow(bsx, 2.0) + pow(bsy, 2.0) + pow(bsz, 2.0)); csmag = sqrt(pow(csx, 2.0) + pow(csy, 2.0) + pow(csz, 2.0)); als = angle_between(bsx, bsy, bsz, csx, csy, csz); bes = angle_between(asx, asy, asz, csx, csy, csz); gas = angle_between(asx, asy, asz, bsx, bsy, bsz); STATUS("Separation between (100) planes = %5.2f nm\n", 1e9/asmag); STATUS("Separation between (010) planes = %5.2f nm\n", 1e9/bsmag); STATUS("Separation between (001) planes = %5.2f nm\n", 1e9/csmag); STATUS("Angle between (100) and (010) planes = %5.2f deg\n", rad2deg(gas)); STATUS("Angle between (100) and (001) planes = %5.2f deg\n", rad2deg(bes)); STATUS("Angle between (010) and (001) planes = %5.2f deg\n", rad2deg(als)); cell_free(cell); cell = cell_new(); if ( cell == NULL ) return 1; cell_set_reciprocal(cell, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); cell_print(cell); cell_get_cartesian(cell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz); STATUS("Cell choice 1:\n"); cell_set_cartesian(cell, ax, ay, az, bx, by, bz, cx, cy, cz); cell_print(cell); STATUS("Cell choice 2:\n"); cell_set_cartesian(cell, bx, by, bz, -ax-bx, -ay-by, -az-bz, cx, cy, cz); cell_print(cell); STATUS("Cell choice 3:\n"); cell_set_cartesian(cell, -ax-bx, -ay-by, -az-bz, ax, ay, az, cx, cy, cz); cell_print(cell); gsl_rng_free(rng); return fail; }
int main() { cell_new(); }