bool FDefaultValueHelper::IsStringValidInteger(const TCHAR* Start, const TCHAR* End, int32& OutBase)
{
	bool bAllowHex = false;
	bool bADigitFound = false;

	if( !Trim(Start, End) )
	{
		return false;
	}

	if( ( TS(TEXT("-")) == *Start ) || ( TS(TEXT("+")) == *Start ) )
	{
		Start++;
	}

	if( !Trim(Start, End) )
	{
		return false;
	}

	if( TS(TEXT("0")) == *Start )
	{
		Start++;
		bADigitFound = true;
		if( ( TS(TEXT("x")) == *Start ) || ( TS(TEXT("X")) == *Start ) )
		{
			Start++;
			bAllowHex = true;
			bADigitFound = false;
			OutBase = 16;
		}
		else
		{
			OutBase = 8;
		}
	}
	else
	{
		OutBase = 10;
	}

	if( bAllowHex )
	{
		for(; ( Start < End ) && FChar::IsHexDigit( *Start ); ++Start)
		{
			bADigitFound = true;
		}
	}
	else
	{
		for(; ( Start < End ) && FChar::IsDigit( *Start ); ++Start)
		{
			bADigitFound = true;
		}
	}

	return ( !Trim(Start, End) ) && bADigitFound;
}
Example #2
0
void *
lz_timer_proc (void *ctx)
{
    lz_timer_registry_t *reg = NULL;

    if (ctx == NULL)
    {
        lz_log ("timer", LZ_LOG_ERROR, "invalid argument");
        return NULL;
    }

    reg = ctx;

    while (!reg->fin) {
        unsigned long long now;
        struct timeval now_tv;
        lz_timer_t *event = NULL;

        gettimeofday (&now_tv, NULL);
        now = TS (now_tv);
        while (1) {
            unsigned long long at;
            char need_cbk = 0;

            pthread_mutex_lock (&reg->lock);
            {
                event = reg->active.next;
                at = TS (event->at);
                if (event != &reg->active && now >= at) {
                    need_cbk = 1;
                    lz_timer_call_stale (reg, event);
                }
            }
            pthread_mutex_unlock (&reg->lock);
            if (need_cbk)
                event->cbk (event->data);

            else
                break;
        }
        usleep (1000000);
    }

    pthread_mutex_lock (&reg->lock);
    {
        while (reg->active.next != &reg->active) {
            lz_timer_call_cancel (ctx, reg->active.next);
        }

        while (reg->stale.next != &reg->stale) {
            lz_timer_call_cancel (ctx, reg->stale.next);
        }
    }
    pthread_mutex_unlock (&reg->lock);
    pthread_mutex_destroy (&reg->lock);

    return NULL;
}
Example #3
0
gf_timer_t *
gf_timer_call_after (glusterfs_ctx_t *ctx,
                     struct timespec delta,
                     gf_timer_cbk_t callbk,
                     void *data)
{
        gf_timer_registry_t *reg = NULL;
        gf_timer_t *event = NULL;
        gf_timer_t *trav = NULL;
        uint64_t at = 0;

        if (ctx == NULL)
        {
                gf_msg_callingfn ("timer", GF_LOG_ERROR, EINVAL,
                                  LG_MSG_INVALID_ARG, "invalid argument");
                return NULL;
        }

        reg = gf_timer_registry_init (ctx);

        if (!reg) {
                gf_msg_callingfn ("timer", GF_LOG_ERROR, 0,
                                  LG_MSG_TIMER_REGISTER_ERROR, "!reg");
                return NULL;
        }

        event = GF_CALLOC (1, sizeof (*event), gf_common_mt_gf_timer_t);
        if (!event) {
                return NULL;
        }
        timespec_now (&event->at);
        timespec_adjust_delta (&event->at, delta);
        at = TS (event->at);
        event->callbk = callbk;
        event->data = data;
        event->xl = THIS;
        LOCK (&reg->lock);
        {
                trav = reg->active.prev;
                while (trav != &reg->active) {
                        if (TS (trav->at) < at)
                                break;
                        trav = trav->prev;
                }
                event->prev = trav;
                event->next = event->prev->next;
                event->prev->next = event;
                event->next->prev = event;
        }
        UNLOCK (&reg->lock);
        return event;
}
Example #4
0
gf_timer_t *
gf_timer_call_after (glusterfs_ctx_t *ctx,
                     struct timeval delta,
                     gf_timer_cbk_t callbk,
                     void *data)
{
        gf_timer_registry_t *reg = NULL;
        gf_timer_t *event = NULL;
        gf_timer_t *trav = NULL;
        unsigned long long at = 0L;

        if (ctx == NULL)
        {
                gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
                return NULL;
        }

        reg = gf_timer_registry_init (ctx);

        if (!reg) {
                gf_log_callingfn ("timer", GF_LOG_ERROR, "!reg");
                return NULL;
        }

        event = GF_CALLOC (1, sizeof (*event), gf_common_mt_gf_timer_t);
        if (!event) {
                return NULL;
        }
        gettimeofday (&event->at, NULL);
        event->at.tv_usec = ((event->at.tv_usec + delta.tv_usec) % 1000000);
        event->at.tv_sec += ((event->at.tv_usec + delta.tv_usec) / 1000000);
        event->at.tv_sec += delta.tv_sec;
        at = TS (event->at);
        event->callbk = callbk;
        event->data = data;
        event->xl = THIS;
        pthread_mutex_lock (&reg->lock);
        {
                trav = reg->active.prev;
                while (trav != &reg->active) {
                        if (TS (trav->at) < at)
                                break;
                        trav = trav->prev;
                }
                event->prev = trav;
                event->next = event->prev->next;
                event->prev->next = event;
                event->next->prev = event;
        }
        pthread_mutex_unlock (&reg->lock);
        return event;
}
bool FDefaultValueHelper::GetParameters(const FString& Source, const FString& TypeName, FString& OutForm)
{
	int32 Pos = 0;

	if( !Trim(Pos, Source) )
	{
		return false;
	}

	// find the beginning of actual val after "TypeName ( "
	if( Source.Find(TypeName, ESearchCase::CaseSensitive) != Pos )
	{
		return false;
	}
	Pos += TypeName.Len();
	if( !Trim(Pos, Source) )
	{
		return false;
	}
	if( TS(TEXT("(")) != Source[Pos++] )
	{
		return false;
	}
	if( !Trim(Pos, Source) )
	{
		return false;
	}
	const int32 StartPos = Pos;

	int32 EndPos = -1, PendingParentheses = 1;
	// find the end of the actual string before " ) "
	for(Pos = Source.Len() - 1; Pos > StartPos; --Pos )
	{
		if( TS(TEXT(")")) == Source[Pos]) 
		{
			PendingParentheses--;
		}
		else if(!IsWhitespace(Source[Pos]))
		{
			EndPos = Pos+1;
			break;
		}
	}

	if(EndPos < 0 || 0 != PendingParentheses)
	{
		return false;
	}

	OutForm = Source.Mid(StartPos, EndPos - StartPos);
	return true;
}
Example #6
0
// 插入一个事件到定时器链表中
gf_timer_t *
gf_timer_call_after (glusterfs_ctx_t *ctx,
                     struct timespec delta,
                     gf_timer_cbk_t callbk,
                     void *data)
{
        gf_timer_registry_t *reg = NULL;
        gf_timer_t *event = NULL;
        gf_timer_t *trav = NULL;
        uint64_t at = 0;

        if (ctx == NULL)
        {
                gf_log_callingfn ("timer", GF_LOG_ERROR, "invalid argument");
                return NULL;
        }

        reg = gf_timer_registry_init (ctx);

        if (!reg) {
                gf_log_callingfn ("timer", GF_LOG_ERROR, "!reg");
                return NULL;
        }

        event = GF_CALLOC (1, sizeof (*event), gf_common_mt_gf_timer_t);
        if (!event) {
                return NULL;
        }
        timespec_now (&event->at);
        timespec_adjust_delta (&event->at, delta);
        at = TS (event->at);
        event->callbk = callbk;
        event->data = data;
        event->xl = THIS;
        pthread_mutex_lock (&reg->lock);
        {
                //列表最后一个
                trav = reg->active.prev;
                //找最后一个时间比我早的(链表是按时间排序的)
                while (trav != &reg->active) {
                        if (TS (trav->at) < at)
                                break;
                        trav = trav->prev;
                }
                event->prev = trav;
                event->next = event->prev->next;
                event->prev->next = event;
                event->next->prev = event;
        }
        pthread_mutex_unlock (&reg->lock);
        return event;
}
Example #7
0
gf_timer_t *
gf_timer_call_after (glusterfs_ctx_t *ctx,
		     struct timeval delta,
		     gf_timer_cbk_t cbk,
		     void *data)
{
  if (!ctx) {
    gf_log ("timer", GF_LOG_ERROR, "!ctx");
    return NULL;
  }

  gf_timer_registry_t *reg = gf_timer_registry_init (ctx);
  gf_timer_t *event, *trav;
  unsigned long long at;

  if (!reg) {
    gf_log ("timer", GF_LOG_ERROR, "!reg");
    return NULL;
  }

  event = calloc (1, sizeof (*event));
  if (!event) {
    gf_log ("timer", GF_LOG_CRITICAL, "Not enough memory");
    return NULL;
  }
  gettimeofday (&event->at, NULL);
  event->at.tv_usec = ((event->at.tv_usec + delta.tv_usec) % 1000000);
  event->at.tv_sec += ((event->at.tv_usec + delta.tv_usec) / 1000000);
  event->at.tv_sec += delta.tv_sec;
  at = TS (event->at);
  event->cbk = cbk;
  event->data = data;
  pthread_mutex_lock (&reg->lock);
  {
    trav = reg->active.prev;
    while (trav != &reg->active) {
      if (TS (trav->at) < at)
	break;
      trav = trav->prev;
    }
    event->prev = trav;
    event->next = event->prev->next;
    event->prev->next = event;
    event->next->prev = event;
  }
  pthread_mutex_unlock (&reg->lock);
  return event;
}
Example #8
0
File: vm.c Project: talkspoon/cobj
COObject *
COObject_get(COObject *name)
{
    COObject *co;

    co = CODict_GetItem(TS(frame)->f_globals, name);
    if (co) {
        return co;
    }
    // at last
    co = CODict_GetItem(TS(frame)->f_builtins, name);
    if (co) {
        return co;
    }
    return NULL;
}
Example #9
0
test_report benchmark_test_with_external_configuration(std::string test_casename, const std::string function_name, int flag){
	std::cout << "test case: " << test_casename << " starts with external configuration" << std::endl;

	general_configuration ext_conf_file("configuration_"+function_name+".txt");

	Overall_Optimisation_Configuration_Settings myConf2(test_casename,
			ext_conf_file,
			"reference_point_"+function_name+".txt",
			"penalty_point_"+function_name+".txt",
			"lower_bound_"+function_name+".txt",
			"upper_bound_"+function_name+".txt",
			"starting_point_"+function_name+".txt",
			"current_step_"+function_name+".txt");

	const unsigned int n_of_variables=myConf2.getExternalConfigurationFile().getVar();
	const unsigned int n_of_objectives=myConf2.getExternalConfigurationFile().getObj();

	objective_function_formulae obj_function(n_of_objectives);

	ObjectiveFunctionBasic<double> TS_ObjFunc(myConf2, obj_function);

	Container2 MTM(n_of_variables, n_of_objectives, "MTM","./memories");
	Container2 IM(n_of_variables, n_of_objectives, "IM","./memories");
	Container2 HISTORY(n_of_variables, n_of_objectives, "HISTORY","./memories");

	STM_Container2 STM(myConf2.getExternalConfigurationFile().getStmSize(), n_of_variables, "STM", "./memories");
	LTM_Container2Basic2<double> LTM( n_of_variables ,  myConf2.getExternalConfigurationFile().getRegions(), myConf2.get_lower_bound(), myConf2.get_upper_bound(),"LTM", "./memories");
	std::cout << "Memories done!" << std::endl;

	TabuSearch TS(myConf2, flag, TS_ObjFunc, MTM, IM, HISTORY, STM, LTM);

	double hyper_volume_indicator=TS.search2();

	return test_report(myConf2.getCaseName(), TS.getDatumPnt(), hyper_volume_indicator) ;
}
Example #10
0
static int etnaviv_ioctl_gem_wait(struct drm_device *dev, void *data,
	struct drm_file *file)
{
	struct etnaviv_drm_private *priv = dev->dev_private;
	struct drm_etnaviv_gem_wait *args = data;
	struct timespec *timeout = &TS(args->timeout);
	struct drm_gem_object *obj;
	struct etnaviv_gpu *gpu;
	int ret;

	if (args->flags & ~(ETNA_WAIT_NONBLOCK))
		return -EINVAL;

	if (args->pipe >= ETNA_MAX_PIPES)
		return -EINVAL;

	gpu = priv->gpu[args->pipe];
	if (!gpu)
		return -ENXIO;

	obj = drm_gem_object_lookup(dev, file, args->handle);
	if (!obj)
		return -ENOENT;

	if (args->flags & ETNA_WAIT_NONBLOCK)
		timeout = NULL;

	ret = etnaviv_gem_wait_bo(gpu, obj, timeout);

	drm_gem_object_unreference_unlocked(obj);

	return ret;
}
Example #11
0
/* Function: mdlInitializeSampleTimes =========================================
 * Abstract:
 *    S-function is comprised of only continuous sample time elements
 */
static void mdlInitializeSampleTimes(SimStruct *S)
{
	/* fixed sample time passed from options */
	ssSetSampleTime(S, 0, TS(S));
	ssSetOffsetTime(S, 0, 0.0);
	ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
Example #12
0
lz_timer_t *
lz_timer_call_after (lz_timer_registry_t *timer, struct timeval delta,
                     lz_timer_cbk_t cbk, void *data)
{
    lz_timer_registry_t *reg = NULL;
    lz_timer_t *event = NULL;
    lz_timer_t *trav = NULL;
    unsigned long long at = 0L;

    if (timer == NULL)
    {
        lz_log ("timer", LZ_LOG_ERROR, "invalid argument");
        return NULL;
    }

    reg = timer;


    event = CALLOC (1, sizeof (*event));
    if (!event) {
        lz_log ("timer", LZ_LOG_CRITICAL, "Not enough memory");
        return NULL;
    }
    gettimeofday (&event->at, NULL);
    event->at.tv_usec = ((event->at.tv_usec + delta.tv_usec) % 1000000);
    event->at.tv_sec += ((event->at.tv_usec + delta.tv_usec) / 1000000);
    event->at.tv_sec += delta.tv_sec;
    at = TS (event->at);
    event->cbk = cbk;
    event->data = data;
    pthread_mutex_lock (&reg->lock);
    {
        trav = reg->active.prev;
        while (trav != &reg->active) {
            if (TS (trav->at) < at)
                break;
            trav = trav->prev;
        }
        event->prev = trav;
        event->next = event->prev->next;
        event->prev->next = event;
        event->next->prev = event;
    }
    pthread_mutex_unlock (&reg->lock);
    return event;
}
Example #13
0
void *
gf_timer_proc (void *ctx)
{
  if (!ctx) {
    gf_log ("timer", GF_LOG_ERROR, "(!ctx)");
    return 0;
  }

  gf_timer_registry_t *reg = gf_timer_registry_init (ctx);
  if (!reg) {
    gf_log ("timer", GF_LOG_ERROR, "!reg");
    return NULL;
  }

  while (!reg->fin) {
    unsigned long long now;
    struct timeval now_tv;
    gf_timer_t *event;

    gettimeofday (&now_tv, NULL);
    now = TS (now_tv);
    while (1) {
      unsigned long long at;
      char need_cbk = 0;

      pthread_mutex_lock (&reg->lock);
      {
	event = reg->active.next;
	at = TS (event->at);
	if (event != &reg->active && now >= at) {
	  need_cbk = 1;
	  gf_timer_call_stale (reg, event);
	}
      }
      pthread_mutex_unlock (&reg->lock);
      if (need_cbk)
	event->cbk (event->data);

      else
	break;
    }
    usleep (100000);
  }
  return NULL;
}
Example #14
0
void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CCollisionRecord *collRecMap, int entNum, EG2_Collision eG2TraceType, int useLod, float fRadius)
{
	int				i, lod;
	skin_t			*skin;
	shader_t		*cust_shader;

	// walk each possible model for this entity and try tracing against it
	for (i=0; i<ghoul2.size(); i++)
	{
		// don't bother with models that we don't care about.
		if (!ghoul2[i].mValid)
		{
			continue;
		}
		assert(G2_MODEL_OK(&ghoul2[i]));
		// do we really want to collide with this object?
		if (ghoul2[i].mFlags & GHOUL2_NOCOLLIDE) 
		{
			continue;
		}
		
		if (ghoul2[i].mCustomShader)
		{
			cust_shader = R_GetShaderByHandle(ghoul2[i].mCustomShader );
		}
		else
		{
			cust_shader = NULL;
		}

		// figure out the custom skin thing
		if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) 
		{
			skin = R_GetSkinByHandle( ghoul2[i].mSkin );
		}
		else
		{
			skin = NULL;
		}

		lod = G2_DecideTraceLod(ghoul2[i],useLod);

		//reset the quick surface override lookup
		G2_FindOverrideSurface(-1, ghoul2[i].mSlist); 

		CTraceSurface TS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist,  ghoul2[i].currentModel, lod, rayStart, rayEnd, collRecMap, entNum, i, skin, cust_shader, ghoul2[i].mTransformedVertsArray, eG2TraceType, fRadius);
		// start the surface recursion loop
		G2_TraceSurfaces(TS);

		// if we've hit one surface on one model, don't bother doing the rest
		if (TS.hitOne)
		{
			break;
		}
	}
}
Example #15
0
/* Function: mdlInitializeSampleTimes =========================================
 * Abstract:
 *    Specify the sample time 
 */
static void mdlInitializeSampleTimes(SimStruct *S)
{
    const double Ts = mxGetScalar(TS(S)); 
    ssSetSampleTime(S, 0, Ts);
    ssSetOffsetTime(S, 0, 0.0);

    /* todo: Is this required?
    ssSetModelReferenceSampleTimeDefaultInheritance(S);      
    */
}
void TS(graph *g,int i,int visited[])
{
	visited[i]=1;
	for(int j=0;j<g->v;j++)
	{
		if(!visited[j] && g->adj[i][j]==1)
		   TS(g,j,visited);
	}
	push(i);
}
Example #17
0
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLOBAL ISM32
validate_TSS
       	    	    	                    
IFN3(
	IU16, selector,	/* (I) selector to be checked */
	IU32 *, descr_addr,	/* (O) address of related descriptor */
	BOOL, is_switch	/* (I) if true we are in task switch */
    )


   {
   BOOL is_ok = TRUE;
   IU8 AR;
   ISM32 super;

   /* must be in GDT */
   if ( selector_outside_GDT(selector, descr_addr) )
      {
      is_ok = FALSE;
      }
   else
      {
      /* is it really an available TSS segment (is_switch false) or
	 is it really a busy TSS segment (is_switch true) */
      AR = spr_read_byte((*descr_addr)+5);
      super = descriptor_super_type((IU16)AR);
      if ( ( !is_switch &&
	     (super == AVAILABLE_TSS || super == XTND_AVAILABLE_TSS) )
	   ||
           ( is_switch &&
	     (super == BUSY_TSS || super == XTND_BUSY_TSS) ) )
	 ;   /* ok */
      else
	 is_ok = FALSE;
      }
   
   /* handle invalid TSS */
   if ( !is_ok )
      {
      if ( is_switch )
	 TS(selector, FAULT_VALTSS_SELECTOR);
      else
	 GP(selector, FAULT_VALTSS_SELECTOR);
      }

   /* must be present */
   if ( GET_AR_P(AR) == NOT_PRESENT )
      NP(selector, FAULT_VALTSS_NP);

   return super;
   }
void skeletonize(const cv::Mat &input, cv::Mat &output, bool save_images)
{
    TS(total);

    TS(imwrite_0);
    if (save_images) cv::imwrite("0-input.png", input);
    TE(imwrite_0);

    // Convert to grayscale my
    cv::Mat gray_image_my;
    ConvertColor_BGR2GRAY_BT709_fpt(input, gray_image_my);
    if (save_images) cv::imwrite("1-convertcolor_my.png", gray_image_my);
    // Convert to grayscale my
    cv::Mat gray_image;
    ConvertColor_BGR2GRAY_BT709(input, gray_image);
    if (save_images) cv::imwrite("1-convertcolor.png", gray_image);

    // Downscale input image
    cv::Mat small_image;
    cv::Size small_size(input.cols / 1.5, input.rows / 1.5);
    ImageResize(gray_image, small_image, small_size);
    if (save_images) cv::imwrite("2-resize.png", small_image);

    // Binarization and inversion
    cv::threshold(small_image, small_image, 128, 255, cv::THRESH_BINARY_INV);
    if (save_images) cv::imwrite("3-threshold.png", small_image);

    // Thinning
    cv::Mat thinned_image;
    GuoHallThinning(small_image, thinned_image);
    if (save_images) cv::imwrite("4-thinning.png", thinned_image);

    // Back inversion
    output = 255 - thinned_image;
    if (save_images) cv::imwrite("5-output.png", output);

    TE(total);
}
Example #19
0
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLOBAL VOID 
validate_SS_on_stack_change
       		    	    	    		                         
IFN4(
	IU32, priv,	/* (I) privilege level to check against */
	IU16, selector,	/* (I) selector to be checked */
	IU32 *, descr,	/* (O) address of related descriptor */
	CPU_DESCR *, entry	/* (O) the decoded descriptor */
    )


   {
   if ( selector_outside_GDT_LDT(selector, descr) )
      TS(selector, FAULT_VALSS_CHG_SELECTOR);
   
   read_descriptor_linear(*descr, entry);

   /* do access check */
   if ( GET_SELECTOR_RPL(selector) != priv ||
	GET_AR_DPL(entry->AR) != priv )
      TS(selector, FAULT_VALSS_CHG_ACCESS);
   
   /* do type check */
   switch ( descriptor_super_type(entry->AR) )
      {
   case EXPANDUP_WRITEABLE_DATA:
   case EXPANDDOWN_WRITEABLE_DATA:
      break;   /* ok */
   
   default:
      TS(selector, FAULT_VALSS_CHG_BAD_SEG_TYPE);   /* wrong type */
      }

   /* finally check it is present */
   if ( GET_AR_P(entry->AR) == NOT_PRESENT )
      SF(selector, FAULT_VALSS_CHG_NOTPRESENT);
   }
int main(int argc, char* argv[]){
	if(argc!=5){
		usage();	
	}
	omp_set_dynamic(0);

	/* Parse Arguments */
	omp_thread_count = atoi(argv[1]);
	if(omp_thread_count > 50 || omp_thread_count <=1)
		usage();
	num_barriers = atoi(argv[2]);
	if(num_barriers > 1000 || num_barriers <1)
		usage();
	use_busy_wait = atoi(argv[3]);
	if(use_busy_wait!=0 && use_busy_wait!=1)
		usage();
	busy_wait_count = atoi(argv[4]);
	
	/* Run the experiment */
	struct timeval start,end;
	omp_set_num_threads(omp_thread_count);
	gettimeofday(&start, NULL);
	#pragma omp parallel
	{
		int i;
		for(i=0;i<num_barriers;i++){		
		#pragma omp critical
		test++;
		barrier();
		}
		#pragma omp master
		fprintf(stderr,"%3d\t",test);
	}
	gettimeofday(&end, NULL);
	fprintf(stderr,"%10.4f\tusec\n",(TS(end)-TS(start))/(double)num_barriers);
}
bool FDefaultValueHelper::IsStringValidFloat(const TCHAR* Start, const TCHAR* End)
{
	if( !Trim(Start, End) )
	{
		return false;
	}

	if( ( TS(TEXT("-")) == *Start ) || ( TS(TEXT("+")) == *Start ) )
	{
		Start++;
	}
	if( !Trim(Start, End) )
	{
		return false;
	}

	for(; ( Start < End ) && FChar::IsDigit( *Start ); ++Start ) { }
	if( TS(TEXT(".")) == *Start )
	{
		Start++;
	}

	for(; ( Start < End ) && FChar::IsDigit( *Start ); ++Start ) { }

	if( ( TS(TEXT("e")) == *Start ) || ( TS(TEXT("E")) == *Start ) )
	{
		Start++;
		if( ( TS(TEXT("-")) == *Start ) || ( TS(TEXT("+")) == *Start ) )
		{
			Start++;
		}
	}
	for(; ( Start < End ) && FChar::IsDigit( *Start ); ++Start) { }
	if( ( TS(TEXT("f")) == *Start ) || ( TS(TEXT("F")) == *Start ) )
	{
		Start++;
	}

	return !Trim(Start, End);
}
Example #22
0
void
COErr_Fetch(COObject **type, COObject **value, COObject **traceback)
{
    *type = TS(curexc_type);
    *value = TS(curexc_value);
    *traceback = TS(curexc_traceback);

    TS(curexc_type) = NULL;
    TS(curexc_value) = NULL;
    TS(curexc_traceback) = NULL;
}
void topologicalsort(graph *g)
{
   //initialization of stack
   top=NULL;
   int visited[g->v];
	for(int i=0;i<g->v;i++)
	  visited[i]=0;
	for(int i=0;i<g->v;i++)
	{
		if(!visited[i])
		  TS(g,i,visited);
	}	
	while(top!=NULL)
	{   
	    int z=pop();
		printf("%d->",z);
	}
}
Example #24
0
static int etnaviv_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
		struct drm_file *file)
{
	struct drm_etnaviv_gem_cpu_prep *args = data;
	struct drm_gem_object *obj;
	int ret;

	if (args->op & ~(ETNA_PREP_READ | ETNA_PREP_WRITE | ETNA_PREP_NOSYNC))
		return -EINVAL;

	obj = drm_gem_object_lookup(dev, file, args->handle);
	if (!obj)
		return -ENOENT;

	ret = etnaviv_gem_cpu_prep(obj, args->op, &TS(args->timeout));

	drm_gem_object_unreference_unlocked(obj);

	return ret;
}
Example #25
0
int OCCFace::loft(std::vector<OCCBase *> profiles, bool ruled, double tolerance)
{
    try {
        Standard_Boolean isSolid = Standard_False;
        Standard_Boolean isRuled = Standard_True;
        
        if (!ruled) isRuled = Standard_False;
        
        BRepOffsetAPI_ThruSections TS(isSolid, isRuled, tolerance);
        
        for (unsigned i=0; i<profiles.size(); i++) {
            if (profiles[i]->getShape().ShapeType() == TopAbs_WIRE) {
                TS.AddWire(TopoDS::Wire(profiles[i]->getShape()));
            } else {
                TS.AddVertex(TopoDS::Vertex(profiles[i]->getShape()));
            }
        }
        //TS.CheckCompatibility(Standard_False);  
        TS.Build();
        if (!TS.IsDone()) {
            StdFail_NotDone::Raise("Failed in loft operation");;
        }
        this->setShape(TS.Shape());
        
        // possible fix shape
        if (!this->fixShape())
            StdFail_NotDone::Raise("Shapes not valid");
        
    } catch(Standard_Failure &err) {
        Handle_Standard_Failure e = Standard_Failure::Caught();
        const Standard_CString msg = e->GetMessageString();
        if (msg != NULL && strlen(msg) > 1) {
            setErrorMessage(msg);
        } else {
            setErrorMessage("Failed to loft");
        }
        return 0;
    }
    return 1;
}
Example #26
0
static int etnaviv_ioctl_wait_fence(struct drm_device *dev, void *data,
		struct drm_file *file)
{
	struct drm_etnaviv_wait_fence *args = data;
	struct etnaviv_drm_private *priv = dev->dev_private;
	struct timespec *timeout = &TS(args->timeout);
	struct etnaviv_gpu *gpu;

	if (args->flags & ~(ETNA_WAIT_NONBLOCK))
		return -EINVAL;

	if (args->pipe >= ETNA_MAX_PIPES)
		return -EINVAL;

	gpu = priv->gpu[args->pipe];
	if (!gpu)
		return -ENXIO;

	if (args->flags & ETNA_WAIT_NONBLOCK)
		timeout = NULL;

	return etnaviv_gpu_wait_fence_interruptible(gpu, args->fence,
						    timeout);
}
Example #27
0
void
COErr_Restore(COObject *type, COObject *value, COObject *traceback)
{
    COObject *oldtype, *oldvalue, *oldtraceback;

    oldtype = TS(curexc_type);
    oldvalue = TS(curexc_value);
    oldtraceback = TS(curexc_traceback);

    TS(curexc_type) = type;
    TS(curexc_value) = value;
    TS(curexc_traceback) = traceback;

    CO_XINCREF(type);
    CO_XINCREF(value);
    CO_XINCREF(traceback);
    CO_XDECREF(oldtype);
    CO_XDECREF(oldvalue);
    CO_XDECREF(oldtraceback);
}
Example #28
0
void Rescale(
    const char *type, size_t kl, size_t ku,
    const TS &cfrom, const TS &cto,
    size_t m, size_t n, T* a, size_t lda
) {
    if(n == 0 || m == 0) {
        return;
    }

    const TS smlnum = Traits<TS>::min();
    const TS bignum = TS(1) / smlnum;

    TS cfromc = cfrom;
    TS ctoc = cto;

    bool done = true;
    do {
        const TS cfrom1 = cfromc * smlnum;
        TS mul;
        if(cfrom1 == cfromc) {
            // CFROMC is an inf.  Multiply by a correctly signed zero for
            // finite CTOC, or a NaN if CTOC is infinite.
            mul = ctoc / cfromc;
            done = true;
            //cto1 = ctoc;
        } else {
            const TS cto1 = ctoc / bignum;
            if(cto1 == ctoc) {
                // CTOC is either 0 or an inf.  In both cases, CTOC itself
                // serves as the correct multiplication factor.
                mul = ctoc;
                done = true;
                cfromc = TS(1);
            } else if(Traits<TS>::abs(cfrom1) > Traits<TS>::abs(ctoc) && ctoc != TS(0)) {
                mul = smlnum;
                done = false;
                cfromc = cfrom1;
            } else if(Traits<TS>::abs(cto1) > Traits<TS>::abs(cfromc)) {
                mul = bignum;
                done = false;
                ctoc = cto1;
            } else {
                mul = ctoc / cfromc;
                done = true;
            }
        }

        switch(type[0]) {
        case 'G': // Full matrix
            for(size_t j = 0; j < n; ++j) {
                for(size_t i = 0; i < m; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
            break;
        case 'L': // Lower triangular matrix
            for(size_t j = 0; j < n; ++j) {
                for(size_t i = j; i < m; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
            break;
        case 'U': // Upper triangular matrix
            for(size_t j = 0; j < n; ++j) {
                size_t ilimit = j+1;
                if(m < ilimit) {
                    ilimit = m;
                }
                for(size_t i = 0; i < ilimit; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
            break;
        case 'H': // Upper Hessenberg matrix
            for(size_t j = 0; j < n; ++j) {
                size_t ilimit = j+2;
                if(m < ilimit) {
                    ilimit = m;
                };
                for(size_t i = 0; i < ilimit; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
            break;
        case 'B': // Lower half of a symmetric band matrix
            for(size_t j = 0; j < n; ++j) {
                size_t ilimit = n-j;
                if(kl+1 < ilimit) {
                    ilimit = kl+1;
                }
                for(size_t i = 0; i < ilimit; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
            break;
        case 'Q': // Upper half of a symmetric band matrix
            for(size_t j = 0; j < n; ++j) {
                size_t istart = (ku > j) ? ku-j : 0;
                for(size_t i = istart; i <= ku; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
        case 'Z': // Band matrix
        {   size_t k3 = 2*kl + ku + 1;
            for(size_t j = 0; j < n; ++j) {
                size_t istart = kl+ku-j;
                if(kl > istart) {
                    istart = kl;
                }
                size_t ilimit = kl + ku + m-j;
                if(k3 < ilimit) {
                    ilimit = k3;
                }
                for(size_t i = istart; i < ilimit; ++i) {
                    a[i+j*lda] *= mul;
                }
            }
        }
        break;
        default:
            break;
        }
    } while(!done);
}
Example #29
0
#define TS(_x,_y) TCPOPT_TSTAMP, 10, D(_x), D(_y)

/* There are virtually no OSes that do not send MSS. Support for RFC 1323
   and 2018 is not given, so we have to test various combinations here. */

static u8 opt_combos[8][24] = {

  { MSS(SPECIAL_MSS), NOP, EOL },                           /* 6  */

  { MSS(SPECIAL_MSS), SOK, NOP, EOL },                      /* 8  */

  { MSS(SPECIAL_MSS), WS(5), NOP, EOL },                    /* 9  */

  { MSS(SPECIAL_MSS), WS(5), SOK, NOP, EOL },               /* 12 */

  { MSS(SPECIAL_MSS), TS(1337, 0), NOP, EOL },              /* 17 */

  { MSS(SPECIAL_MSS), SOK, TS(1337, 0), NOP, EOL },         /* 19 */

  { MSS(SPECIAL_MSS), WS(5), TS(1337, 0), NOP, EOL },       /* 20 */

  { MSS(SPECIAL_MSS), WS(5), SOK,  TS(1337, 0), NOP, EOL }  /* 22 */

};

int main(int argc, char** argv) {

  static struct sockaddr_in6 sin;
  char one = 1;
  s32  sock;
  u32  i;
Example #30
0
test_report benchmark_test_with_internal_configuration(std::string test_casename, const std::string function_name, int flag, int nVar){
	std::ofstream report_file("tests_report_file.txt", std::ios::app);
	time_t start_time; time (&start_time);

	std::cout << "test case: " << test_casename << " starts with internal configuration" << std::endl;


	general_configuration internal_configuration_old("no_filename",
			10, //1 - diversify
			5, //2 - intensify
			15, //3 - reduce
			0.00, //4 - SS
			0.5, //5 - SSRF
			1, //6 - save step
			3, //7 - sampling
			nVar, //8 - nVar
			2, //9 - nObj
			0, //10 loop limit
			3000, //11 evaluations limit
			0, //12 Improvements limit , number of consecutive improvements
			4, //13 - number of regions
			6, //14 - STM size
			"HV", // 15
			"full", //16
			-0.05, //17 - starting point
			200, //18
			300); //19

	general_configuration internal_configuration("configuration.txt");

	ObjFunction2 test_reference_point=ObjFunction2(2, 22.0);
	ObjFunction2 test_penalty_point=ObjFunction2(2,33333.0);

	Point2 test_lower_bound=Point2(nVar,0.0);
	test_lower_bound[0]=5.0;
	test_lower_bound[1]=1.0;
	test_lower_bound[2]=11.0;

	Point2 test_upper_bound=Point2(nVar,1.0);
	test_upper_bound[0]=11.0;
	test_upper_bound[1]=200.0;
	test_upper_bound[2]=29.0;


	Point2 test_starting_point=Point2(nVar,0.5);
	test_starting_point[0]=7.0;
	test_starting_point[1]=100.0;
	test_starting_point[2]=24.5;

	Point2 test_current_step=Point2(nVar,0.05);
	test_current_step[0]=0.1666666;
	test_current_step[1]=0.050251256;
	test_current_step[2]=0.055555556;

	Overall_Optimisation_Configuration_Settings myConf2(test_casename,
			internal_configuration,
			test_reference_point,
			test_penalty_point,
			test_lower_bound,
			test_upper_bound,
			test_starting_point,
			test_current_step);

	const unsigned int n_of_variables=myConf2.getExternalConfigurationFile().getVar();
	const unsigned int n_of_objectives=myConf2.getExternalConfigurationFile().getObj();

	objective_function_formulae obj_function(n_of_objectives);

	ObjectiveFunctionBasic<double> TS_ObjFunc(myConf2, obj_function);

	Container2 MTM(n_of_variables, n_of_objectives, "MTM","./memories");
	Container2 IM(n_of_variables, n_of_objectives, "IM","./memories");
	Container2 HISTORY(n_of_variables, n_of_objectives, "HISTORY","./memories");

	STM_Container2 STM(myConf2.getExternalConfigurationFile().getStmSize(), n_of_variables, "STM", "./memories");
	LTM_Container2Basic2<double> LTM( n_of_variables ,  myConf2.getExternalConfigurationFile().getRegions(), myConf2.get_lower_bound(), myConf2.get_upper_bound(),"LTM", "./memories");
	std::cout << "Memories done!" << std::endl;

	TabuSearch TS(myConf2, flag, TS_ObjFunc, MTM, IM, HISTORY, STM, LTM);

	double hyper_volume_indicator=TS.search2();

	time_t end; time (&end);
	double dif = difftime (end,start_time);
	std::cout << "end in " << dif<< "seconds" << std::endl;
	report_file << test_casename << "\t" << n_of_variables << "\t" << dif << " seconds " << __DATE__ << "\t" << __TIME__  << std::endl;
	report_file.close();

	return test_report(myConf2.getCaseName(), TS.getDatumPnt(), hyper_volume_indicator) ;
}