//意味のある単語まで飛ぶ bool TextAnalyseW::next( void ) { for(;;) { if( pos >= last ) return false; //コメントを飛ばす if( commentNoSkip == false && pos[0] == L'/' && pos[1] == L'/' ) { pos += 2; for(; pos < last && pos[0] != '\n'; pos ++ ){} if( pos >= last ) return false; pos ++; } else if( commentNoSkip == false && pos[0] == L'/' && pos[1] == L'*' ) { pos += 2; for(; pos < last && ( pos[0] != L'*' || pos[1] != L'/' ) ; pos ++ ){} if( pos >= last ) return false; pos += 2; } else //空白を飛ばす if( checkC( *pos ) == false ) { for(; pos < last && checkC( *pos ) == false; pos ++ ){} if( pos >= last ) return false; } else break ; } return true; }
/* traverse all nodes * find inconsitency markers for each child depending on its parents * inconsistency is found whenever: * edge pa --> ch * gammax[pa,t_i] == 1 # if the parent is active, then state switch from active to passive should not occur at the child * gammax[ch, t_i] == 1 & gammax[ch, t_(i+1)] == 0 not possible * gammax[pa,t_i] == 0 # if the parent is passive, then state switch from passive to active should not occur at the child * gammax[ch, t_i] == 0 & gammax[ch, t_(i+1)] == 1 not possible * edge pa --| ch * gammax[pa,t_i] == 1 # if parent is active, then state switch from passive to active should not occur * gammax[ch, t_i] == 0 & gammax[ch, t_(i+1)] == 1 not possible * gammax[pa,t_i] == 0 * gammax[ch, t_i] == 1 & gammax[ch, t_(i+1)] == 0 not possible * */ int is_consistent(int *phi, int *GS, int *G, int N, int T, int R) { int inc=0, cnt=0, pcnt=0; // initialise an array of parents, can be at most N elements int *parents = malloc(N*sizeof(int)); // allocate consistency vector int *consvec = malloc((T*R-1)*sizeof(int)); // for all nodes for(int i=0; i!=N; ++i) { // reset parents vector to 0 memset(parents, 0, N*sizeof(int)); // reset the consistency vector to all consistent for(int ci=0; ci!=(T*R-1); ++ci) { consvec[ci] = 1; } // check all parents pcnt = get_parents(phi, N, parents, i); if(pcnt>0) { // for each parent for(int j=0; j!=N; ++j) { if(parents[j]!=0) { checkC(phi, GS, i, j, N, T, R, consvec); // reset -14 value to 1 for(int ci=0; ci!=(T*R-1); ci++) { if(consvec[ci]==-14) { consvec[ci] = 1; } } } } // parents end // increment the inconsistency count for(int ci=0; ci!=(T*R-1); ++ci) { if(consvec[ci]==0) { inc++; } } } } free(consvec); free(parents); return inc; }
//次の文字列を取得 bool TextAnalyseW::getstr( wchar_t *buf, bool nomove ) { int i, j; wchar_t *temp; next(); temp = pos; if( pos >= last ) return false; //最初の文字が " かどうかで処理を分岐 if( pos[0] == L'\"' ) { // " があるところまでコピー pos++; for( j = 0, i = 0; pos + i < last && pos[i] != L'\"'; i++ ) { //改行、タブは無視する if( pos[i] == L'\r' || pos[i] == L'\n' || pos[i] == L'\t' ) continue; buf[j] = pos[i]; j++; } buf[j] = L'\0'; pos += i; if( *pos == L'\"' ) pos++; } else { //意味が無い文字があるところまでコピー for( i = 0; pos + i < last && checkC( pos[i] ) == true; i++ ) { buf[i] = pos[i]; } buf[i] = L'\0'; pos += i; } if( nomove ) pos = temp; return true; }
void CPUSkeletonize::perform(int type, int structElemV, Image3d *image) { Image3d imageIn(image->getRows(), image->getCols(), image->get3dMatImage().clone()); switch (type) { case 0: { checkA(image, imageIn, structElemV); break; } case 1: { checkB(image, imageIn, structElemV); break; } case 2: { checkC(image, imageIn, structElemV); break; } case 3: { checkD(image, imageIn, structElemV); break; } } imageIn.clear(); }
//次の文字列を取得 bool TextAnalyse::getstr( char *buf, bool nomove ) { int i, j; char *temp; next(); temp = pos; if( pos >= last ) return false; //最初の文字が " かどうかで処理を分岐 if( pos[0] == '\"' ) { // " があるところまでコピー pos++; for( j = 0, i = 0; pos + i < last && pos[i] != '\"'; ) { if( checksize( pos + i ) == 2 ) { buf[j ] = pos[i ]; buf[j+1] = pos[i+1]; i += 2; j += 2; } else { //¥の後に”がある場合は”を文字列の一部としてみなす if( pos + i + 1 < last && pos[i] == '\\' && pos[i+1] == '\"' ) { buf[j] = '\"'; j++; i += 2; } else //改行、タブは無視する if( pos[i] != '\r' && pos[i] != '\n' && pos[i] != '\t' ) { buf[j] = pos[i]; j++; i++; } else { i++; } } } buf[j] = '\0'; pos += i; if( *pos == '\"' ) pos++; } else { //意味が無い文字があるところまでコピー for( i = 0; pos + i < last && checkC( pos[i] ) == true; ) { if( checksize( pos + i ) == 2 ) { buf[i ] = pos[i ]; buf[i+1] = pos[i+1]; i += 2; } else { buf[i] = pos[i]; i ++; } } buf[i] = '\0'; pos += i; } if( nomove ) pos = temp; return true; }
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { JNIEnv *env; jclass cls; cached_jvm = jvm; /* cache the JavaVM pointer */ if ((*jvm)->GetEnv(jvm, (void*) &env, JNI_VERSION_1_6)) { return JNI_ERR; /* JNI version not supported */ } #define check(v,c) if ((v=(c))==NULL) return JNI_ERR #define checkC(v,n) check(cls, (*env)->FindClass(env, n));\ check(v, (*env)->NewGlobalRef(env, cls)); #define checkF(v,c,n,s) check(v, (*env)->GetFieldID(env,c,n,s)); #define checkSF(v,c,n,s) check(v, (*env)->GetStaticFieldID(env,c,n,s)); #define checkM(v,c,n,s) check(v, (*env)->GetMethodID(env,c,n,s)); #define checkSM(v,c,n,s) check(v, (*env)->GetStaticMethodID(env,c,n,s)); // setup "jclass" checkC(NS(Class_MqS), "javamsgque/MqS"); checkC(NS(Class_MqBufferS), "javamsgque/MqBufferS"); checkC(NS(Class_MqSException), "javamsgque/MqSException"); checkC(NS(Class_IService), "javamsgque/IService"); checkC(NS(Class_IServerSetup), "javamsgque/IServerSetup"); checkC(NS(Class_IServerCleanup), "javamsgque/IServerCleanup"); checkC(NS(Class_ICallback), "javamsgque/ICallback"); checkC(NS(Class_IFactory), "javamsgque/IFactory"); checkC(NS(Class_IBgError), "javamsgque/IBgError"); checkC(NS(Class_IEvent), "javamsgque/IEvent"); checkC(NS(Class_RuntimeException), "java/lang/RuntimeException"); checkC(NS(Class_NullPointerException), "java/lang/NullPointerException"); checkC(NS(Class_Throwable), "java/lang/Throwable"); checkC(NS(Class_Class), "java/lang/Class"); checkC(NS(Class_Object), "java/lang/Object"); checkC(NS(Class_System), "java/lang/System"); checkC(NS(Class_StringWriter), "java/io/StringWriter"); checkC(NS(Class_PrintWriter), "java/io/PrintWriter"); // setup "jfieldID" checkF(NS(FID_MqS_hdl), NS(Class_MqS), "hdl", "J"); checkF(NS(FID_MqBufferS_hdl), NS(Class_MqBufferS), "hdl", "J"); checkF(NS(FID_MqSException_num), NS(Class_MqSException), "p_num", "I"); checkF(NS(FID_MqSException_code), NS(Class_MqSException), "p_code", "I"); checkF(NS(FID_MqSException_txt), NS(Class_MqSException), "p_txt", "Ljava/lang/String;"); // setup "jmethodID" checkM(NS(MID_Throwable_getMessage), NS(Class_Throwable), "getMessage", "()Ljava/lang/String;"); checkM(NS(MID_Throwable_printStackTrace), NS(Class_Throwable), "printStackTrace", "(Ljava/io/PrintWriter;)V"); checkM(NS(MID_Class_getName), NS(Class_Class), "getName", "()Ljava/lang/String;"); checkM(NS(MID_IService_Service), NS(Class_IService), "Service", "(Ljavamsgque/MqS;)V"); checkM(NS(MID_IServerSetup_ServerSetup), NS(Class_IServerSetup), "ServerSetup", "()V"); checkM(NS(MID_IServerCleanup_ServerCleanup), NS(Class_IServerCleanup), "ServerCleanup", "()V"); checkM(NS(MID_StringWriter_INIT), NS(Class_StringWriter), "<init>", "()V"); checkM(NS(MID_StringWriter_toString), NS(Class_StringWriter), "toString", "()Ljava/lang/String;"); checkM(NS(MID_PrintWriter_INIT), NS(Class_PrintWriter), "<init>", "(Ljava/io/Writer;)V"); checkSM(NS(MID_System_exit), NS(Class_System), "exit", "(I)V"); checkM(NS(MID_ICallback_Callback), NS(Class_ICallback), "Callback", "(Ljavamsgque/MqS;)V"); checkM(NS(MID_IFactory_Factory), NS(Class_IFactory), "Factory", "()Ljavamsgque/MqS;"); checkM(NS(MID_MqSException_INIT), NS(Class_MqSException), "<init>", "(IILjava/lang/String;)V"); checkM(NS(MID_MqBufferS_INIT), NS(Class_MqBufferS), "<init>", "(J)V"); checkM(NS(MID_MqS_ErrorSet), NS(Class_MqS), "ErrorSet", "(Ljava/lang/Throwable;)V"); checkM(NS(MID_IBgError_BgError), NS(Class_IBgError), "BgError", "()V"); checkM(NS(MID_IEvent_Event), NS(Class_IEvent), "Event", "()V"); #undef check #undef checkC #undef checkF #undef checkSF #undef checkM return JNI_VERSION_1_6; }