FV3_(efilter)::FV3_(efilter)() { lpfCof = 0.0f; hpfCof = 0.0f; updateP(&lpfL, lpfCof); updateP(&lpfR, lpfCof); updateZ(&hpfL, hpfCof); updateZ(&hpfR, hpfCof); }
int QZDir::getType(QString sub) { if (updateZ()==QZF_NONE) return QZF_NONE; if (sub=="." || sub=="..") return QZF_DIR; if (m_type&QZF_ZIP) { QCString str; toMB(str, sub, "euc-kr"); ZEntry *entry = m_dir.z->findByName(str); if (!entry) return QZF_NONE; if (entry->isDir()) return QZF_DIR; else return QZF_FILE; } else { QFileInfo finfo(m_dir.q->absPath()+"/"+sub); if (finfo.isFile()) { QString ext = finfo.extension(false); //printf("EXT:%s\n", (const char*)ext); if (ext.lower()=="zip") return QZF_DIR; return QZF_FILE; } if (finfo.isDir()) return QZF_DIR; return QZF_NONE; } }
QString QZDir::absPath() { if (updateZ()==QZF_NONE) return m_path; if (m_type&QZF_ZIP) { char buffer[1024]; if (m_dir.z->getFullName(buffer, 1024)<0) return m_path; if (buffer[0]=='/' && buffer[1]==0) buffer[0] = 0; QString zname, sname; zname = QString::fromUtf8(m_dir.z->zipFileName()); toWC(sname, buffer, "euc-kr"); //printf("getpath:%s %s\n", (const char*)zname, (const char*)sname); // converting to absolute path QDir zdir(zname); zname = zdir.absPath(); zname += sname; m_path = zname; return zname; } else { return m_dir.q->absPath(); } }
QStringList QZDir::getList(QString mask, int filter, int sort_policy) { if (updateZ()==QZF_NONE) return QStringList(); if (m_type&QZF_ZIP) { ZEntry *ptr = m_dir.z->getFirst(); QStringList to_return; QString str; int en_type; to_return.append("."); to_return.append(".."); while (ptr) { if (filter&(ptr->isDir()?QZFL_DIR:QZFL_FILE)) { toWC(str, QCString(ptr->name()), "euc-kr"); to_return.append(str); } ptr = ptr->m_next; } return to_return; } else { int qspec = 0; if (filter&QZFL_DIR) qspec |= QDir::Dirs; if (filter&QZFL_FILE) qspec |= QDir::Files; return m_dir.q->entryList(mask, qspec); } }
bool QZDir::cdUp() { if (updateZ()==QZF_NONE) return false; if (m_type&QZF_ZIP) { ZDirEntry *entry = m_dir.z->getParent(); if (entry) { m_dir.z = entry; return true; } else { m_dir.z->release(); m_type = QZF_DIR; QString zname; zname = QString::fromUtf8(m_dir.z->zipFileName()); int idx = zname.findRev('/'); if (idx<0) m_dir.q = new QDir("."); else { if (idx==0) m_dir.q = new QDir("/"); else m_dir.q = new QDir(zname.left(idx)); } return true; } } else { return m_dir.q->cdUp(); } }
void StateEstimatorKinematic::filterOneTimeStep_ss() { predictX(); computeAnkleRelated(); // Compute ankle position and velocity updateZ(6); computeInnovation(_y); updateX(6); // The following steps are additional step for next step measurement computeAnkleRelated(); // Compute ankle position and velocity }
//BEGIN class PicItem PicItem::PicItem( ICNDocument *icnDocument, bool newItem, const char *id, MicroSettings *_microSettings ) : CNItem( icnDocument, newItem, id ? id : "picitem" ) { m_name = "PIC"; m_type = typeString(); p_icnDocument = icnDocument; icnDocument->registerItem(this); microSettings = _microSettings; const int numPins = microSettings->microInfo()->package()->pinCount( PicPin::type_bidir | PicPin::type_input | PicPin::type_open ); const int numSide = (numPins/2) + (numPins%2); m_bExpanded = true; m_innerHeight = (numSide+2)*PinWidth + (numSide-1)*PinSeparation; updateVisibility(); addButton( "settings", QRect( SidePadding-8, m_innerHeight+TopPadding+(BottomPadding-24)/2-1, InnerWidth+16, 24 ), i18n("Advanced...") ); addButton( "expandBtn", QRect( (TopPadding-22)/2, (TopPadding-22)/2, 22, 22 ), KIconLoader::global()->loadIcon( "down", KIconLoader::Small ), true ); button("expandBtn")->setState(true); move( 12, 12 ); QStringList pinIDs = microSettings->microInfo()->package()->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open ); QStringList::iterator it = pinIDs.begin(); for ( int i=0; i < numSide; ++i, ++it ) { QPoint position( int(this->x()) + SidePadding - PinLength+1, int(y()) + TopPadding + (i+1)*PinWidth + i*PinSeparation ); const QString id = *it; PinSettings *settings = microSettings->pinWithID(id); m_pinItemList.append( new PinItem( dynamic_cast<FlowCodeDocument*>(icnDocument), position, true, settings ) ); } for ( int i=0; i < numPins/2; ++i, ++it ) { QPoint position( int(this->x()) + SidePadding + InnerWidth-1, int(y()) + TopPadding + m_innerHeight - ( (i+2)*PinWidth + i*PinSeparation ) ); const QString id = *it; PinSettings *settings = microSettings->pinWithID(id); m_pinItemList.append( new PinItem( dynamic_cast<FlowCodeDocument*>(icnDocument), position, false, settings ) ); } setSelected(false); setPen( QPen( Qt::black ) ); updateZ(-1); update(); show(); }
bool QZDir::cd(QString str) { if (updateZ()==QZF_NONE) return false; if (str.left(2)=="..") { if (!this->cdUp()) return false; if (str.length()>3 && str.at(2)=='/') return this->cd(str.mid(3)); return true; } if (m_type&QZF_ZIP) { QCString spath; toMB(spath, str, "euc-kr"); ZEntry *entry = m_dir.z->findByName(spath); if (entry==NULL || !entry->isDir()){ return false; } m_dir.z = (ZDirEntry*)entry; return true; } else { QString c_path; c_path = m_dir.q->path(); c_path += "/" + str; ZEntry *entry; QCString zname, sname; int my_type = getNames(c_path, zname, sname, &entry); if (!(my_type&QZF_DIR)) return false; if (my_type==QZF_DIR) return m_dir.q->cd(str); m_type = my_type; entry->grab(); m_dir.z = (ZDirEntry*)entry; return true; } }
void FV3_(efilter)::setHPF(fv3_float_t val) { hpfCof = val; updateZ(&hpfL, hpfCof); updateZ(&hpfR, hpfCof); }
main(int argc, char *argv[]) {int *permC, *permV, *permV2; int loopz, loopa, loopc, cluster,loopvertexk,loopvertexj,j,i,k,Current,start,outloopc, newcluster; int V,vertexk,vertexj,cl,errors,numlinks; float meanfield0,meanfield1,logfn1,logfn0,loglik1,loglik0; float tmp; static float zma[MAXV][MAXC],zm[MAXV][MAXC], zmat[MAXV][MAXC]; static float zmatmp[MAXV][MAXC],zmtmp[MAXV][MAXC], matmp[MAXC]; static float ma[MAXC], atmp[MAXC], manew[MAXC], floatval[MAXV*MAXC]; int c,cc; static bool A[MAXV][MAXV], AA[MAXV][MAXV]; float T1, T0, logprior0, logprior1, logpost0, logpost1; char LinksInputFile[40], tmps[4]; int C=atoi(argv[4]); int Zloops=atoi(argv[5]); int Aloops=atoi(argv[6]); float beta=atof(argv[7]); float Abeta=atof(argv[8]); float Bbeta=atof(argv[9]); // float Threshold=atof(argv[10]); float Threshold=THRESHOLD; int Vtoupdate=atoi(argv[10]); bool DISP_ERRORS=atoi(argv[11]); int BurninSteps=atoi(argv[12]); float BurninBeta=atof(argv[13]); // char OutputFile=argv[2]; /* get the adjacency matrixc */ FILE *fpLinkFile, *fpOutputFile, *fpInitialFile; int counter, vertex; int ii[MAXLINKS],jj[MAXLINKS]; float fl; srand(time(0)); bool dontstart=0; bool randominit=1; bool singleinit=0; fpLinkFile = fopen(argv[1], "r"); if(fpLinkFile==NULL){ printf("Error: can't open LinkFile %s\n",argv[1]); dontstart=1;} if (strcmp(argv[3],"random")==0) {singleinit=0; randominit=1;printf("\nRandom initialisation.\n");} if (strcmp(argv[3],"single")==0) {singleinit=1; randominit=1;printf("\nReplicated single cluster initialisation.\n");} if (randominit==0) {fpInitialFile = fopen(argv[3], "r"); if(fpInitialFile==NULL){ printf("Error: can't open InitialFile %s\n",argv[3]); dontstart=1; }} if (dontstart==1){return 1;} else /* start the analysis : */ { counter=0; while(!feof(fpLinkFile)){ fscanf(fpLinkFile, "%d %d", &ii[counter], &jj[counter]); counter++; } fclose(fpLinkFile); numlinks=counter; printf("LinkFile read successfully.\n"); /* find the number of vertices : */ int nums[2]; nums[0]=max_value(ii,numlinks); nums[1]=max_value(jj,numlinks); V = max_value(nums,2); printf("Number of vertices =%d\n",V); if (Vtoupdate==0){Vtoupdate=V;} printf("Will update at each iteration %d randomly selected vertices\n",Vtoupdate); if (randominit==0){ cluster=0; while(!feof(fpInitialFile)){ for (vertex=0;vertex<V;vertex++){ fscanf(fpInitialFile, "%f ",&zm[vertex][cluster]); } ++cluster; } fclose(fpInitialFile); printf("InitFile read successfully.\n"); if (C==0){C=cluster;}} /* setup mean alpha */ for (i=0;i<C;i++){ma[i]=1.0;} /* initialise Z */ for (i=0;i<C;i++) { for (j=0;j<V;j++) {if (randominit==1){zm[j][i]=1.0*(rand()>0.5*RAND_MAX);} /* initial to 0.05 not important */ zma[j][i]=ma[i]*zm[j][i]; } } /* setup adj matrix based on links */ for (i=0;i<V;i++) { for (j=0;j<i;j++) { A[j][i]=0; A[i][j]=0; } A[i][i]=1; } for (counter=0;counter<numlinks;counter++) {A[ii[counter]-1][jj[counter]-1]=1;A[jj[counter]-1][ii[counter]-1]=1;} if (singleinit==1) {printf("\nFinding first a single cluster based on random initialisation....\n"); updateZ(argv[2],zm,zma,ma,A,BurninSteps,1,V,V,BurninBeta,Threshold,DISP_ERRORS); for (i=1;i<C;i++) { for (j=0;j<V;j++) {zm[j][i]=zm[k][0];zma[j][i]=ma[i]*zm[j][i]; } } } printf("\n\nFinding the clique matrix marginals p(z[vertex][cluster]=1|adjacency matrix):\n"); if (BurninSteps>0){updateZ(argv[2],zm,zma,ma,A,BurninSteps,C,V,Vtoupdate,BurninBeta,Threshold,DISP_ERRORS);} for (loopa=0;loopa<=Aloops;loopa++) {if (loopa==0) {updateZ(argv[2],zm,zma,ma,A,Zloops,C,V,Vtoupdate,beta,Threshold,DISP_ERRORS);} else {updateZ(argv[2],zm,zma,ma,A,Zloops,C,V,Vtoupdate,beta,Threshold,DISP_ERRORS);} if (loopa<Aloops){ /* update alpha */ printf("\n[%d]Updating number of clusters",loopa); for (i=0;i<V;i++){ for (cluster=0;cluster<C;cluster++){zmat[i][cluster]=zma[i][cluster];}} for (c=0;c<C;c++){manew[c]=0.0;} for (cluster=0;cluster<C;cluster++) { for (i=0;i<V;i++){zmat[i][cluster]=zm[i][cluster];} loglik1=loglik(zmat,A,V,C,beta,Threshold); for (i=0;i<V;i++){zmat[i][cluster]=0.0;} loglik0=loglik(zmat,A,V,C,beta,Threshold); for (i=0;i<V;i++){zmat[i][cluster]=zma[i][cluster];} for (c=0;c<C;c++){atmp[c]=ma[c];} atmp[cluster]=1.0; T1=0.0; for (c=0;c<C;c++){T1+=atmp[c];} T0=1.0*C-T1; logprior1=betalog(Abeta+T1,Bbeta+T0); atmp[cluster]=0.0; T1=0.0; for (c=0;c<C;c++){T1+=atmp[c];} T0=1.0*C-T1; logprior0=betalog(Abeta+T1,Bbeta+T0); logpost1=logprior1+loglik1; logpost0=logprior0+loglik0; ma[cluster]=1.0/(1.0+exp(logpost0-logpost1)); } cluster=0; newcluster=0; for (cluster=0;cluster<C;cluster++){ matmp[cluster]=ma[cluster]; for (i=0;i<V;i++){ zmatmp[i][cluster]=zma[i][cluster]; zmtmp[i][cluster]=zm[i][cluster]; } } for (cluster=0;cluster<C;cluster++){ if (ma[cluster]>SMALLVALUE){ for (i=0;i<V;i++){ zma[i][newcluster]=zmatmp[i][cluster]; zm[i][newcluster]=zmtmp[i][cluster]; } ma[newcluster]=matmp[cluster]; newcluster++; } } C=newcluster; } } } }
bool QZDir::exist() { return updateZ()!=QZF_NONE; }
bool QZDir::isFile() { return (updateZ()&QZF_FILE)!=0; }
bool QZDir::isDir() { return (updateZ()&QZF_DIR)!=0; }
/* * iterateZ() * * Performs a single cycle of fit improvement with x, y width * determined by the z parameter. */ void iterateZ() { updateZ(); calcErr(); }