//returns a new lint with lint n trimmed of leading 0s lint *shrinkI(lint *n) { int i; for(i=n->length-1;(i>=0)&&(n->digits[i]==0);--i); if(i<0) return createI(1); lint *newn=createI(i+1); newn->sign=n->sign; for(;i>=0;--i) newn->digits[i]=n->digits[i]; return newn; }
//returns a new lint cloned from lint a lint *cloneI(lint *a) { lint *n=createI(a->length); int i; for(i=0;i<a->length;++i) n->digits[i]=a->digits[i]; n->sign=a->sign; return n; }
Shape::Shape() { transformIndex = 0; mainBlock = sf::Vector2i(5,1); int randomBelowSeven = rand() % 7; switch (randomBelowSeven) { case 0: createI(); break; case 1: createJ(); break; case 2: createS(); break; case 3: createO(); break; case 4: createZ(); break; case 5: createL(); break; case 6: createT(); break; } applyTransform(transformIndex); }
lint *inttolint(int m) { int i,j; for(i=0,j=m;j>0;++i) j/=10; lint *n=createI(i); for(i=0;i<n->length;++i,m/=10) n->digits[i]=m%10; return n; }
lint *stringtolint(char *str) { int i; lint *strint=createI(2*len(str)); for(i=0;i<strint->length/2;++i) { strint->digits[2*i]=(str[i]-'A')%10; strint->digits[2*i+1]=(str[i]-'A')/10; } return strint; }
//returns new lint with product of lint n and m, assumed +ve lint *intoI(lint *n,char m) { lint *prod=createI(n->length+1); int i,c; for(i=c=0;i<n->length;++i) { prod->digits[i]+=(c+n->digits[i]*m)%10; c=(c+n->digits[i]*m)/10; } prod->digits[n->length]=c; return prod; }
HRESULT TimgFilterTomsMoComp::process(TfilterQueue::iterator it, TffPict &pict, const TfilterSettingsVideo *cfg0) { if (is(pict, cfg0)) { const TdeinterlaceSettings *cfg = (const TdeinterlaceSettings*)cfg0; if (((pict.fieldtype & FIELD_TYPE::PROGRESSIVE_FRAME) || pict.film) && !cfg->deinterlaceAlways) { return parent->processSample(++it, pict); } init(pict, cfg->full, cfg->half); const unsigned char *src[4]; bool cspChanged = getCur(FF_CSP_420P | FF_CSP_YUY2, pict, cfg->full, src); unsigned char *dst[4]; cspChanged |= getNext(csp1, pict, cfg->full, dst); if (cspChanged || se != cfg->tomsmocompSE || vf != cfg->tomsmocompVF || oldstride10 != stride1[0]) { oldstride10 = stride1[0]; se = cfg->tomsmocompSE; vf = cfg->tomsmocompVF; done(); } if (!t) { //pstride[0]=(dxY/16+2)*16;pstride[1]=pstride[2]=pstride[0]/2; for (unsigned int i = 0; i < pict.cspInfo.numPlanes; i++) { pstride[i] = stride1[i]; psrc[i] = (unsigned char*)aligned_calloc(pstride[i], dy1[i]); } twidth = dx1[0]; theight = dy1[0]; t = createI(); inited = t->create((Tconfig::cpu_flags & FF_CPU_SSE) != 0, (Tconfig::cpu_flags & FF_CPU_MMXEXT) != 0, (Tconfig::cpu_flags & FF_CPU_3DNOW) != 0, csp1 & FF_CSP_YUY2 ? true : false, -1, se, vf != 0, twidth, theight, stride1, stride2); frameNum = 0; } if (inited) { t->GetFrame(frameNum, 1, src, dst, (const unsigned char**)psrc); pict.fieldtype = (pict.fieldtype & ~(FIELD_TYPE::MASK_INT_PROG)) | FIELD_TYPE::PROGRESSIVE_FRAME; pict.csp &= ~FF_CSP_FLAGS_INTERLACED; for (unsigned int i = 0; i < pict.cspInfo.numPlanes; i++) { TffPict::copy(psrc[i], pstride[i], src[i], stride1[i], dx2[i], dy2[i]); } frameNum++; } } if (pict.rectClip != pict.rectFull) { parent->dirtyBorder = 1; } return parent->processSample(++it, pict); }
//returns new lint with product of lint a and b, assumed trimmed and +ve with a>b lint *_multiplicationI(lint *a,lint *b) { lint *prod=createI(a->length),*tmp1,*tmp2,*tmp3,*tmp4; int i; for(i=b->length-1;i>=0;--i) { tmp1=shiftI(prod,1); tmp2=intoI(a,b->digits[i]); tmp3=_additionI(tmp1,tmp2); tmp4=shrinkI(tmp3); deleteI(prod); deleteI(tmp3); deleteI(tmp2); deleteI(tmp1); prod=tmp4; } return prod; }
//returns new lint with difference of lint a and b, assumed trimmed and +ve with a>b lint *_subtractionI(lint *a,lint *b) { int i,bor,d; lint *diff=createI(a->length); for(i=bor=0;i<b->length;++i) { d=a->digits[i]-b->digits[i]-bor; diff->digits[i]=(10+d)%10; bor=d<0?1:0; } for(i=b->length;(i<a->length)&&(bor);++i) { d=a->digits[i]-bor; diff->digits[i]=(10+d)%10; bor=d<0?1:0; } for(;i<a->length;++i) diff->digits[i]=a->digits[i]; return diff; }
//returns new lint with sum of lint a and b, assumed trimmed and +ve with a>b lint *_additionI(lint *a,lint *b) { int i,car,s; lint *sum=createI(a->length+1); for(i=car=0;i<b->length;++i) { s=car+a->digits[i]+b->digits[i]; sum->digits[i]=s%10; car=s>9?1:0; } for(i=b->length;i<a->length;++i) { s=car+a->digits[i]; sum->digits[i]=s%10; car=s>9?1:0; } sum->digits[a->length]=car; return sum; }
//returns new lint with lint a to the power b, assumed trimmed lint *powerI(lint *a,lint *b) { if(b->sign==MINUS) return createI(1); if(a->sign==PLUS) return _powerI(a,b); lint *one=convertI("1"),*two=convertI("2"),**div=_divisionI(b,two); switch(_compareI(*(div+1),one)) { case LESS: destroyI(div,2); deleteI(one); deleteI(two); return _powerI(a,b); case EQUAL: destroyI(div,2); deleteI(one); deleteI(two); return negateI(_powerI(a,b)); } }
//returns a new lint with lint n leftshifted by l places lint *shiftI(lint *n,int l) { lint *newn=createI(n->length+l); int i=0,j=l; while(i<n->length) newn->digits[j++]=n->digits[i++]; return newn; }
//returns a new lint as + with absolute value of null terminated string s lint *convertI(char *s) { lint *n=createI(len(s)); int i,j; for(i=n->length-1,j=0;j<n->length;--i,++j) n->digits[i]=s[j]-'0'; return n; }
//returns new lint of n random digits lint *randoneI(int n) { lint *random=createI(n); int i; for(i=0;i<n;++i) random->digits[i]=rand()%10; return random; }
void nasolver<nr_type_t>::saveResults (const std::string &volts, const std::string &s, int saveOPs, qucs::vector * f) { int N = countNodes (); int M = countVoltageSources (); // add node voltage variables if (!volts.empty()) { for (int r = 0; r < N; r++) { std::string n = createV (r, volts, saveOPs); if(!n.empty()) { saveVariable (n, x->get (r), f); } } } // add branch current variables if (!amps.empty()) { for (int r = 0; r < M; r++) { std::string n = createI (r, amps, saveOPs); if (!n.empty()) { saveVariable (n, x->get (r + N), f); } } } // add voltage probe data if (!volts.empty()) { circuit * root = subnet->getRoot (); for (circuit * c = root; c != NULL; c = (circuit *) c->getNext ()) { if (!c->isProbe ()) continue; if (!c->getSubcircuit().empty() && !(saveOPs & SAVE_ALL)) continue; if (volts != "vn") c->saveOperatingPoints (); std::string n = createOP (c->getName (), volts); saveVariable (n, nr_complex_t (c->getOperatingPoint ("Vr"), c->getOperatingPoint ("Vi")), f); } } // save operating points of non-linear circuits if requested if (saveOPs & SAVE_OPS) { circuit * root = subnet->getRoot (); for (circuit * c = root; c != NULL; c = (circuit *) c->getNext ()) { if (!c->isNonLinear ()) continue; if (!c->getSubcircuit ().empty() && !(saveOPs & SAVE_ALL)) continue; c->calcOperatingPoints (); for (auto ops: c->getOperatingPoints ()) { operatingpoint &p = ops.second; std::string n = createOP (c->getName (), p.getName ()); saveVariable (n, p.getValue (), f); } } } }