static void LoadCode(LoadState* S, Proto* f) { int n=LoadInt(S); Align4(S); if (!luaZ_direct_mode(S->Z)) { f->code=luaM_newvector(S->L,n,Instruction); LoadVector(S,f->code,n,sizeof(Instruction)); } else { f->code=(Instruction*)luaZ_get_crt_address(S->Z); LoadVector(S,NULL,n,sizeof(Instruction)); } f->sizecode=n; }
static void LoadCode(LoadState* S, Proto* f) { int n=LoadInt(S); f->code=luaM_newvector(S->L,n,Instruction); f->sizecode=n; LoadVector(S,f->code,n,sizeof(Instruction)); }
static void checkliteral (LoadState *S, const char *s, const char *msg) { char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */ size_t len = strlen(s); LoadVector(S, buff, len); if (memcmp(s, buff, len) != 0) error(S, msg); }
static void LoadDebug(LoadState* S, Proto* f) { int i,n; n=LoadInt(S); f->lineinfo=luaM_newvector(S->L,n,uint32_t); f->sizelineinfo=n; LoadVector(S,f->lineinfo,n,sizeof(uint32_t)); if (S->flip) for (i=0; i<n; i++) f->lineinfo[i] = Swap32(f->lineinfo[i]); n=LoadInt(S); f->locvars=luaM_newvector(S->L,n,LocVar); f->sizelocvars=n; for (i=0; i<n; i++) f->locvars[i].varname=NULL; for (i=0; i<n; i++) { f->locvars[i].varname=LoadString(S); f->locvars[i].startpc=LoadInt(S); f->locvars[i].endpc=LoadInt(S); } n=LoadInt(S); f->upvalues=luaM_newvector(S->L,n,TString*); f->sizeupvalues=n; for (i=0; i<n; i++) f->upvalues[i]=NULL; for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); }
static void LoadCode (LoadState* S, Proto* f) { int size=LoadInt(S); f->code=luaM_newvector(S->L,size,Instruction); f->sizecode=size; LoadVector(S,f->code,size,sizeof(*f->code)); }
bool BrfData::LoadFast(const wchar_t*filename, bool faster){ FILE *f = wfopen(filename,"rb"); if (!f) return false; version = 0; globVersion = version; while (1) { char str[255]; if (!LoadString(f, str)) return false; if (!strcmp(str,"end")) break; else if (!strcmp(str,"rfver ")) LoadVersion(f,-1); else if (!strcmp(str,"shader")) {if (!SkipVector(f,shader)) return false;} else if (!strcmp(str,"texture")) {if (!LoadVector(f,texture)) return false; } else if (!strcmp(str,"material")) {if (!SkipVector(f,material)) return false; } else if (!strcmp(str,"mesh")) { if (faster) break; if (!SkipVector(f,mesh)) return false;} else if (!strcmp(str,"skeleton")) {if (!SkipVector(f,skeleton)) return false;} else if (!strcmp(str,"skeleton_anim")) { if (faster) break; if (!SkipVector(f,animation)) return false;} else if (!strcmp(str,"body")) { if (faster) break; if (!SkipVector(f,body)) return false;} else { //printf("ERROR! Unknown token \"%s\"\n",str); fflush(stdout); fclose(f); return false; } } fclose(f); return true; }
int main(int argc, char *argv[]) { Vector Y; Matrix X; Matrix Cov; LoadVector("input.linear.mvt.y", Y); LoadMatrix("input.linear.mvt.x", X); LoadMatrix("input.linear.mvt.cov", Cov); { Matrix x; Vector y; x = X; y = Y; LinearRegressionVT linear; if (!linear.FitNullModel(Cov, Y)) { fprintf(stderr, "Fitting failed! - step 1!\n"); return -1; } if (!linear.TestCovariate(Cov, Y, X)) { fprintf(stderr, "Fitting failed - step 2!\n"); return -1; } dumpToFile(linear.GetU(), stdout); dumpToFile(linear.GetV(), stdout); dumpToFile(linear.GetT(), stdout); dumpToFile(linear.GetCov(), stdout); fprintf(stdout, "%g\t0\n", linear.GetPvalue(), 0); } return 0; };
static void LoadLines (LoadState* S, Proto* f) { int size=LoadInt(S); f->lineinfo=luaM_newvector(S->L,size,int); f->sizelineinfo=size; LoadVector(S,f->lineinfo,size,sizeof(*f->lineinfo)); }
static void LoadLines(LoadState* S, Proto* f) { int n=LoadInt(S); f->lineinfo=luaM_newvector(S->L,n,int); f->sizelineinfo=n; LoadVector(S,f->lineinfo,n,sizeof(int)); }
int main(int argc, char* argv[]) { LogisticRegression lr; LogisticRegressionScoreTest lrst; LogisticRegressionPermutationTest lrpt; Vector y; Matrix x; Matrix cov; LoadVector("input.y", y); LoadMatrix("input.x", x); LoadMatrix("input.cov", cov); Matrix xall; xall = x; xall.StackRight(cov); // 1 + x + cov if (lr.FitLogisticModel(xall, y, 100) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } Vector& beta = lr.GetCovEst(); Matrix& v = lr.GetCovB(); Vector& pWald = lr.GetAsyPvalue(); fprintf(stdout, "wald_beta\t"); Print(beta); fputc('\n', stdout); fprintf(stdout, "wald_vcov\t"); Print(v); fputc('\n', stdout); fprintf(stdout, "wald_p\t"); Print(pWald[1]); fputc('\n', stdout); if (lrpt.FitLogisticModelCov(xall, 1, y, 2000, -1) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } fprintf(stdout, "permutation_p\t"); double permu_p = lrpt.getPvalue(); Print(permu_p); fputc('\n', stdout); if (lrst.FitLogisticModel(xall, y, 1, 100) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } fprintf(stdout, "score_p\t"); double score_p = lrst.GetPvalue(); Print(score_p); fputc('\n', stdout); return 0; };
static void LoadLines (lua_State* L, Proto* tf, ZIO* Z, int swap) { int n; tf->nlineinfo=n=LoadInt(L,Z,swap); tf->lineinfo=luaM_newvector(L,n,int); LoadVector(L,tf->lineinfo,n,sizeof(*tf->lineinfo),Z,swap); }
static void LoadDebug(LoadState* S, Proto* f) { int i,n; n=LoadInt(S); f->lineinfo=luaM_newvector(S->L,n,int); f->sizelineinfo=n; LoadVector(S,f->lineinfo,n,sizeof(int)); n=LoadInt(S); f->locvars=luaM_newvector(S->L,n,LocVar); f->sizelocvars=n; for (i=0; i<n; i++) f->locvars[i].varname=NULL; for (i=0; i<n; i++) { f->locvars[i].varname=LoadString(S); #if LUA_REFCOUNT luarc_addrefstring(f->locvars[i].varname); #endif /* LUA_REFCOUNT */ f->locvars[i].startpc=LoadInt(S); f->locvars[i].endpc=LoadInt(S); } n=LoadInt(S); f->upvalues=luaM_newvector(S->L,n,TString*); f->sizeupvalues=n; for (i=0; i<n; i++) f->upvalues[i]=NULL; #if LUA_REFCOUNT for (i=0; i<n; i++) { f->upvalues[i]=LoadString(S); luarc_addrefstring(f->upvalues[i]); } #else for (i=0; i<n; i++) f->upvalues[i]=LoadString(S); #endif /* LUA_REFCOUNT */ }
static void LoadCode (lua_State* L, Proto* tf, ZIO* Z, int swap) { int size=LoadInt(L,Z,swap); tf->code=luaM_newvector(L,size,Instruction); LoadVector(L,tf->code,size,sizeof(*tf->code),Z,swap); if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.99s'",ZNAME(Z)); luaF_protook(L,tf,size); }
static TString *LoadString (LoadState *S) { size_t size = LoadByte(S); if (size == 0xFF) LoadVar(S, size); if (size == 0) return NULL; else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */ char buff[LUAI_MAXSHORTLEN]; LoadVector(S, buff, size); return luaS_newlstr(S->L, buff, size); } else { /* long string */ TString *ts = luaS_createlngstrobj(S->L, size); LoadVector(S, getstr(ts), size); /* load directly in final place */ return ts; } }
bool BrfData::Load(FILE*f,int verbose,int imposeVers){ Clear(); version = 0; globVersion = version; while (1) { char str[255]; if (!LoadString(f, str)) return false; if (verbose>1) printf("Read \"%s\"\n",str); if (!strcmp(str,"end")) break; else if (!strcmp(str,"rfver ")) LoadVersion(f,imposeVers); else if (!strcmp(str,"mesh")) { if (!LoadVector(f,mesh)) return false; // int k; LoadInt(f,k); mesh.resize(1); mesh[0].Load(f); return true; } else if (!strcmp(str,"texture")) {if (!LoadVector(f,texture)) return false;} else if (!strcmp(str,"shader")) {if (!LoadVector(f,shader)) return false;} else if (!strcmp(str,"material")) {if (!LoadVector(f,material)) return false;} else if (!strcmp(str,"skeleton")) {if (!LoadVector(f,skeleton)) return false;} else if (!strcmp(str,"skeleton_anim")) {if (!LoadVector(f,animation)) return false;} else if (!strcmp(str,"body")) {if (!LoadVector(f,body)) return false; } else { //printf("ERROR! Unknown token \"%s\"\n",str); fflush(stdout); fclose(f); return false; } } fclose(f); return true; }
static void LoadDebug(LoadState* S, Proto* f) { int i,n; n=LoadInt(S); Align4(S); if (!luaZ_direct_mode(S->Z)) { f->lineinfo=luaM_newvector(S->L,n,int); LoadVector(S,f->lineinfo,n,sizeof(int)); } else {
int main(int argc, char* argv[]) { LinearRegression lr; LinearRegressionScoreTest lrst; LinearRegressionPermutationTest lrpt; Vector y; Matrix x; LoadVector("input.y", y); LoadMatrix("input.x", x); if (lr.FitLinearModel(x, y) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } Vector& beta = lr.GetCovEst(); Matrix& v = lr.GetCovB(); Vector& pWald = lr.GetAsyPvalue(); fprintf(stdout, "wald_beta\t"); Print(beta); fputc('\n', stdout); fprintf(stdout, "wald_vcov\t"); Print(v); fputc('\n', stdout); fprintf(stdout, "wald_p\t"); Print(pWald[1]); fputc('\n', stdout); if (lrpt.FitLinearModel(x, 1, y, 200, 0.05) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } fprintf(stdout, "permutation_p\t"); double permu_p = lrpt.getPvalue(); Print(permu_p); fputc('\n', stdout); if (lrst.FitLinearModel(x, y, 1) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } fprintf(stdout, "score_p\t"); double score_p = lrst.GetPvalue(); Print(score_p); fputc('\n', stdout); return 0; };
static void LoadCode(LoadState* S, Proto* f) { int n=LoadInt(S); int i=0; f->code=luaM_newvector(S->L,n,Instruction); f->sizecode=n; LoadVector(S,f->code,n,sizeof(Instruction)); if (!S->flip) return; for (i=0; i<n; ++i) f->code[i] = Swap32(f->code[i]); }
static TString *LoadString (LoadState *S) { size_t size = LoadByte(S); if (size == 0xFF) LoadVar(S, size); if (size == 0) return NULL; else { char *s = luaZ_openspace(S->L, S->b, --size); LoadVector(S, s, size); return luaS_newlstr(S->L, s, size); } }
static TString* LoadWString(LoadState* S) { size_t size; LoadVar(S,size); if (size==0) return NULL; else { lua_WChar* s=(lua_WChar*)luaZ_openspace(S->L,S->b,size*2); LoadVector(S,s,size,2); return luaS_newlwstr(S->L,s,size-1); /* remove trailing '\0' */ } }
void SpriteBatch::Impl::Draw(std::shared_ptr<Texture> texture, float4 destination, Rect const* sourceRect, float4 color, u32 flags) { static const size_t vectorSize = sizeof(float4); #define LoadVector(dest, src) memcpy(dest, src, vectorSize) if (!texture) throw Exception("Texture cannot be null"); if (!m_insideBeginEnd) throw Exception("Being must be called before Draw"); if (m_queueCount >= m_queueSize) GrowSpriteQueue(); float4 dest = destination; SpriteInfo* sprite = &m_spriteQueue[m_queueCount]; if (sourceRect) { LoadVector(&sprite->source, &sourceRect); } else { static const float4 wholeTexture(0, 0, 1, 1); LoadVector(&sprite->source, &wholeTexture); } sprite->rotation = 0; LoadVector(&sprite->destination, &dest); LoadVector(&sprite->color, &color); sprite->texture = texture; sprite->flags = flags; m_queueCount++; #undef LoadVector }
static void LoadConstants (lua_State* L, Proto* tf, ZIO* Z, int swap) { int i,n; tf->nkstr=n=LoadInt(L,Z,swap); tf->kstr=luaM_newvector(L,n,TString*); for (i=0; i<n; i++) tf->kstr[i]=LoadString(L,Z,swap); tf->nknum=n=LoadInt(L,Z,swap); tf->knum=luaM_newvector(L,n,Number); LoadVector(L,tf->knum,n,sizeof(*tf->knum),Z,swap); tf->nkproto=n=LoadInt(L,Z,swap); tf->kproto=luaM_newvector(L,n,Proto*); for (i=0; i<n; i++) tf->kproto[i]=LoadFunction(L,Z,swap); }
static void LoadDebug (LoadState *S, Proto *f) { int i, n; n = LoadInt(S); f->lineinfo = luaM_newvector(S->L, n, int); f->sizelineinfo = n; LoadVector(S, f->lineinfo, n); n = LoadInt(S); f->locvars = luaM_newvector(S->L, n, LocVar); f->sizelocvars = n; for (i = 0; i < n; i++) f->locvars[i].varname = NULL; for (i = 0; i < n; i++) { f->locvars[i].varname = LoadString(S); f->locvars[i].startpc = LoadInt(S); f->locvars[i].endpc = LoadInt(S); } n = LoadInt(S); for (i = 0; i < n; i++) f->upvalues[i].name = LoadString(S); }
void TerrainShader::LoadLight(Light& light, float ambientLight) { LoadVector(location_lightPosition, light.GetPosition()); LoadVector(location_lightColor, light.GetColor()); LoadFloat(location_ambientLight, ambientLight); }