int C_THISCLASS::render(char visdata[2][2][576], int isBeat, int *framebuffer, int *fbout, int w, int h) { //pow(sin(d),dpos)*1.7 if (need_recompile) { int err=0; int x; EnterCriticalSection(&rcs); if (!var_b || g_reset_vars_on_recompile) { clearVars(); var_x = registerVar("x"); var_y = registerVar("y"); var_w = registerVar("w"); var_h = registerVar("h"); var_b = registerVar("b"); var_alpha = registerVar("alpha"); inited=0; } need_recompile=0; for (x = 0; x < 3; x ++) { freeCode(codehandle[x]); codehandle[x]=compileCode(effect_exp[x].get()); } LeaveCriticalSection(&rcs); } *var_w=w; *var_h=h; *var_b=isBeat?1.0:0.0; if (isBeat&0x80000000) return 0; if (codehandle[0] && (!inited || m_lasth != h || m_lastw != w)) { m_lastw=w; m_lasth=h; *var_x=0; *var_y=0; *var_alpha=0.5; executeCode(codehandle[0],visdata); inited=1; } executeCode(codehandle[1],visdata); if (isBeat) executeCode(codehandle[2],visdata); int doblend=blend; int ialpha=127; if (doblend) { ialpha=(int)(*var_alpha*255.0); if (ialpha <= 0) return 0; if (ialpha >= 255) doblend=0; } int *inptr=framebuffer; int *blendptr=framebuffer; int *outptr=fbout; int xa=(int)*var_x; int ya=(int)*var_y; // var_x, var_y at this point tell us how to shift, and blend also tell us what to do. if (!subpixel) { int endy=h+ya; int endx=w+xa; int x,y; if (endx > w) endx=w; if (endy > h) endy=h; if (ya < 0) inptr += -ya*w; if (ya > h) ya=h; if (xa > w) xa=w; for (y = 0; y < ya; y ++) { x=w; if (!doblend) while (x--) *outptr++ = 0; else while (x--) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); } for (; y < endy; y ++) { int *ip=inptr; if (xa < 0) inptr += -xa; if (!doblend) { for (x = 0; x < xa; x ++) *outptr++=0; for (; x < endx; x ++) *outptr++=*inptr++; for (; x < w; x ++) *outptr++=0; } else { for (x = 0; x < xa; x ++) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); for (; x < endx; x ++) *outptr++ = BLEND_ADJ(*inptr++,*blendptr++,ialpha); for (; x < w; x ++) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); } inptr=ip+w; } for (; y < h; y ++) { x=w; if (!doblend) while (x--) *outptr++ = 0; else while (x--) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); } } else // bilinear filtering version { int xpart,ypart; { double vx=*var_x; double vy=*var_y; xpart=(int) ((vx - (int)vx)*255.0); if (xpart < 0) xpart=-xpart; else { xa++; xpart=255-xpart; } if (xpart < 0) xpart=0; if (xpart > 255) xpart=255; ypart=(int) ((vy - (int)vy)*255.0); if (ypart < 0) ypart=-ypart; else { ya++; ypart=255-ypart; } if (ypart < 0) ypart=0; if (ypart > 255) ypart=255; } int x,y; if (ya < 1-h) ya=1-h; if (xa < 1-w) xa=1-w; if (ya > h-1) ya=h-1; if (xa > w-1) xa=w-1; if (ya < 0) inptr += -ya*w; int endy=h-1+ya; int endx=w-1+xa; if (endx > w-1) endx=w-1; if (endy > h-1) endy=h-1; if (endx < 0) endx=0; if (endy < 0) endy=0; for (y = 0; y < ya; y ++) { x=w; if (!doblend) while (x--) *outptr++ = 0; else while (x--) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); } for (; y < endy; y ++) { int *ip=inptr; if (xa < 0) inptr += -xa; if (!doblend) { for (x = 0; x < xa; x ++) *outptr++=0; for (; x < endx; x ++) *outptr++=BLEND4((unsigned int *)inptr++,w,xpart,ypart); for (; x < w; x ++) *outptr++=0; } else { for (x = 0; x < xa; x ++) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); for (; x < endx; x ++) *outptr++ = BLEND_ADJ(BLEND4((unsigned int *)inptr++,w,xpart,ypart),*blendptr++,ialpha); for (; x < w; x ++) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); } inptr=ip+w; } for (; y < h; y ++) { x=w; if (!doblend) while (x--) *outptr++ = 0; else while (x--) *outptr++ = BLEND_ADJ(0,*blendptr++,ialpha); } } #ifndef NO_MMX __asm emms; #endif return 1; }
static int readlagrangian(int check, int ugForce) { algvertptr lgrgn1,lgrgn2; int i, j, mm; char * ss; char pPtr[4][60]; int factorShift,lorentzShift; arr4byte f_copy; int mLine,totcolor,color,spinorNumb; linelist ln; static char fName[4][5] = {"P1","P2","P3","P4"}; polyvars var_testing={0,NULL}; vardef=&(var_testing); clearlgrgn(); factorShift=tabCharPos(lgrng_tab.format,4); lorentzShift=tabCharPos(lgrng_tab.format,5); tabName=lgrng_tab.headln; for(ln=lgrng_tab.strings, nLine=1; ln; ln=ln->next, nLine++) { ss=ln->line; sscanf(ss,"%[^|]%*c%[^|]%*c%[^|]%*c%[^|]",pPtr[0],pPtr[1],pPtr[2],pPtr[3]); for(i=0;i<4;i++) trim(pPtr[i]); if(pPtr[0][0]=='%') continue; for(i=0;i<4;i++) { if(pPtr[i][0]) { locateinbase(pPtr[i],&j); if(check && j == 0) { errorMessage( fName[i]," unknown particle %s" ,pPtr[i]); return 0; } f_copy[i]=j; } else if(i==3) f_copy[3]=0; else { errorMessage( fName[i],"particle name is expected");return 0;} } if(ugForce) { for(i=0;i<4;i++) { j=f_copy[i]; if(j && ghostp(j) &&(!zeromass(j))) i=10; } if(i>=10) continue; } lgrgn1=(algvertptr)m_alloc( sizeof(*lgrgn1)); lgrgn1->next = lgrgn; lgrgn = lgrgn1; lgrgn->comcoef= ln->line+factorShift; lgrgn->description=ln->line+lorentzShift; for (i=0;i<4;i++) lgrgn->fields[i] = f_copy[i]; if(check) { totcolor=1; for (mm=0;((mm<4)&&(lgrgn->fields[mm] !=0));mm++) { color=prtclbase[lgrgn->fields[mm] -1].cdim; if (color==-3) color=5; totcolor=totcolor*color; } if( (totcolor!=1)&&(totcolor!=15)&&(totcolor!=64)&&(totcolor!=120)&&(totcolor!=512) ) { errorMessage("Lorentz part","wrong color structure"); return 0; } spinorNumb=0; for (mm=0;((mm<4)&&(lgrgn->fields[mm] !=0));mm++) { if( prtclbase1[lgrgn->fields[mm]].spin&1 ) spinorNumb++ ; } if( (spinorNumb!=0)&&(spinorNumb!=2) ) { errorMessage("Lorentz part","wrong spinor structure"); return 0; } } if (! testLgrgn(lgrgn) ) { clearVars(vardef); return 0;} } clearVars(vardef); clearpregarbage(); lgrgn1 = lgrgn; /* Sorting */ do { lgrgn1->factor=1; for(i=0;i<4 && lgrgn1->fields[i];i++) { int hlp=prtclbase[lgrgn1->fields[i]-1].hlp; if(hlp=='C') break; else if(hlp=='c') {lgrgn1->factor=-1; break;} } for (i = 1; i <= 4; i++) lgrgn1->perm[i-1] = i; i = 1; while (i < 4) if (lgrgn1->fields[i-1] >= lgrgn1->fields[i + 1-1]) ++(i); else { mm = lgrgn1->fields[i-1]; lgrgn1->fields[i-1] = lgrgn1->fields[i + 1-1]; lgrgn1->fields[i + 1-1] = mm; mm = lgrgn1->perm[i-1]; lgrgn1->perm[i-1] = lgrgn1->perm[i + 1-1]; lgrgn1->perm[i + 1-1] = mm; if (i == 1) ++(i); else --(i); } lgrgn1 = lgrgn1->next; } while (lgrgn1 != NULL); if (check) { mLine=nLine; lgrgn1 = lgrgn; /* check1 */ do { nLine--; lgrgn2=lgrgn1->next; while (lgrgn2 != NULL ) { if( (lgrgn1->fields[0]==lgrgn2->fields[0]) && (lgrgn1->fields[1]==lgrgn2->fields[1]) && (lgrgn1->fields[2]==lgrgn2->fields[2]) && (lgrgn1->fields[3]==lgrgn2->fields[3]) ) { char sss[20]=""; for(i=0;i<4;i++) if(lgrgn1->fields[i]) { strcat(sss, prtclbase1[lgrgn1->fields[i]].name); strcat(sss," ");} errorMessage("P1,P2,P3,P4","duplicate vertex {%s}",sss); return 0; } lgrgn2=lgrgn2->next; } lgrgn1= lgrgn1->next; } while (lgrgn1 != NULL); nLine=mLine; lgrgn1 = lgrgn; /* check2 */ do { nLine--; for (i=0;i<4;i++) { f_copy[i]=lgrgn1->fields[i]; if (f_copy[i] !=0) { mm=ghostmother(f_copy[i]); f_copy[i]=prtclbase[mm-1].anti + f_copy[i]-mm ; } } i = 1; while (i < 4) if (f_copy[i-1] >= f_copy[i ]) ++(i); else { mm = f_copy[i-1]; f_copy[i-1] = f_copy[i ]; f_copy[i ] = mm; if (i == 1) ++(i); else --(i); } lgrgn2=lgrgn; while ((lgrgn2 != NULL ) && ( (f_copy[0] !=lgrgn2->fields[0]) || (f_copy[1] !=lgrgn2->fields[1]) || (f_copy[2] !=lgrgn2->fields[2]) || (f_copy[3] !=lgrgn2->fields[3]) ) ) { lgrgn2=lgrgn2->next; } if (lgrgn2 == NULL) { char sss[10]; strcpy(sss,""); for (i=0;i<3;i++) { strcat (sss, prtclbase[lgrgn1->fields[i]-1].name); strcat(sss," "); } if (lgrgn1->fields[3] !=0 ) strcat(sss,prtclbase[lgrgn1->fields[3]-1].name); errorMessage("P1,P2,P3,P4","conjugated vertex for %s not found",sss); return 0; } lgrgn1= lgrgn1->next; } while (lgrgn1 != NULL); } return 1; }
void BasicExpression::setExpr(const std::string& str) { clearVars(); Expression::setExpr(str); }
static int testLgrgn(algvertptr lgrgn) { preres m; int n; /* goto_xy(1,20); print("%d ",nLine); */ m = (preres) readExpression(lgrgn->comcoef,rd_pre, act_preF,NULL); if (rderrcode ) { errorMessage("Factor","*"); return 0; } m->free=1; if (m->tp >rationtp) { errorMessage("Factor","scalar expected"); return 0; } if (m->maxp>0) { errorMessage("Factor","moments p%d are not permitable here",m->maxp); return 0; } for (n = 0; n < vardef->nvar; n++) { int err; err=findvar(vardef->vars[n].name,NULL,NULL); if (err) { errorMessage("Factor","unknown variable '%s'", vardef->vars[n].name); return 0; } } clearVars(vardef); m=(preres) readExpression(lgrgn->description,rd_pre,act_pre,NULL); if(rderrcode) { errorMessage("Lorentz part","*"); return 0; } m->free=1; if (m->tp == rationtp) { errorMessage("Lorentz part","division is not permited here"); return 0; } if( (m->tp == spintp) &&( prtclbase1[lgrgn->fields[0]].spin&1 !=1) &&( prtclbase1[lgrgn->fields[1]].spin&1 !=1) &&( prtclbase1[lgrgn->fields[2]].spin&1 !=1) ) { errorMessage("Lorentz part","Dirac gamma matrix not expected"); return 0; } if ((m->maxp == 4)&&(lgrgn->fields[3] == 0)) { errorMessage("Lorentz part","p4 are not permited here"); return 0; } for (n = 0; n < vardef->nvar; n++) { int err; err=findvar (vardef->vars[n].name,NULL,NULL); if (err) { errorMessage("Lorentz part","unknown variable '%s'",vardef->vars[n].name); return 0; } } clearVars(vardef); for (n = 0; n <= 3; n++) { int ind1,ind2,np ; ind1=0; np = lgrgn->fields[n]; if ( np != 0 ) switch (prtclbase[np-1].spin) { case 2: case 3: ind1=1; break; case 4: ind1=3; } ind2=0; if( (1<<n)& m->indlist) ind2 += 1; if( (1<<(n+4))& m->indlist) ind2 += 2; if (ind1 != ind2 ) { errorMessage("Lorentz part","index 'm%d' unbalanced",n+1); return 0; } } return 1; }
BasicExpression::~BasicExpression() { clearVars(); }