int funct(int n){
	if(n==0){
		return 0;		
	}
	return n+funct(n-1);

}
예제 #2
0
int32_t DLLst_Iterate_Reverse_4Args(DLinkedList * list, int32_t (*funct)(void *, void*, void*, void*, void*), void *arg1, void *arg2, void *arg3, void* arg4)
{
DLLstElement * listItem, *prev;

#ifdef ENABLE_NETVM_LOGGING
	logdata(LOG_JIT_LISTS_DEBUG_LVL, __FUNCTION__);
#endif

	if (list == NULL)
	{
#ifdef ENABLE_NETVM_LOGGING
		logdata(LOG_JIT_LISTS_DEBUG_LVL, __FUNCTION__ "Null List... returning");
#endif
		return nvmJitSUCCESS;
	}

	if (funct == NULL)
	{
		errorprintf(__FILE__, __FUNCTION__, __LINE__, " Error: null function ptr argument\n");
		return nvmJitFAILURE;
	}

	listItem = list->Tail;

	while (listItem != NULL){
		prev = listItem->Prev;
		if (funct(listItem->Item, arg1, arg2, arg3, arg4) < 0){
			errorprintf(__FILE__, __FUNCTION__, __LINE__, " Error: applying function on items\n");
			return nvmJitFAILURE;
		}
		listItem = prev;
	}

	return nvmJitSUCCESS;
}
예제 #3
0
int32_t DLLst_Iterate_Forward_1Arg(DLinkedList * list, int32_t (*funct)(void *, void*), void *arg)
{
DLLstElement * listItem, *next;

#ifdef ENABLE_NETVM_LOGGING
	logdata(LOG_JIT_LISTS_DEBUG_LVL, __FUNCTION__);
#endif

	if (list == NULL)
	{
#ifdef ENABLE_NETVM_LOGGING
		logdata(LOG_JIT_LISTS_DEBUG_LVL, __FUNCTION__ "Null List... returning");
#endif
		return nvmJitSUCCESS;
	}

	if (funct == NULL){
		errorprintf(__FILE__, __FUNCTION__, __LINE__, " Error: null function ptr argument\n");
		return nvmJitFAILURE;
	}


	listItem = list->Head;

	while (listItem != NULL){
		next = listItem->Next;
		if (funct(listItem->Item, arg) < 0){
			errorprintf(__FILE__, __FUNCTION__, __LINE__, " Error: applying function on items\n");
			return nvmJitFAILURE;
		}
		listItem = next;
	}

	return nvmJitSUCCESS;
}
예제 #4
0
Cn Analitza::func(const Container& n)
{
	Cn ret(.0);
	Ci funct(n.m_params[0]);
	
	if(funct.type()!=Object::variable || !funct.isFunction() || !m_vars->contains(funct.name())) {
		m_err << i18n("The function <em>%1</em> doesn't exist").arg(funct.name());
		return ret;
	}
	
	if(!isFunction(funct)) {
		m_err << i18n("<em>%1</em> is not a function").arg(funct.name());
		return ret;
	}
	
	Container *function = (Container*) m_vars->value(funct.name());
	
	QStringList var = function->bvarList();
	
	for(int i=0; i<var.count(); i++) {
		m_vars->stack(var[i], n.m_params[i+1]);
	}
	
	ret=calc(function->m_params[var.count()]);
	
	for(int i=0; i<var.count(); i++) {
		m_vars->destroy(var[i]);
	}
	
	return ret;
}
예제 #5
0
void		for_each(t_list *list, void (*funct)(void *))
{
  while (list)
    {
      funct(list->data);
      list = list->next;
    }
}
예제 #6
0
파일: direct.cpp 프로젝트: markm541374/GPc
void suddividi(intervallo *curr, int n, int *nf, int *nint, double *xdir, double *fdir,	double funct(int, double*)){
	int i, j;
	int numtrue, ind1, ind2;

	numtrue = 0;
	for(i=0;i<n;i++){
		//printf("id: %d maxdim %f dimen[%d] %f\n",curr->id,curr->maxdim,i,curr->dimen[i]);
		if(curr->maxdim == curr->dimen[i]){
			for(j=0;j<n;j++) mod_suddividi.ysud[j] = curr->cent[j]; 
			mod_suddividi.ysud[i] = curr->cent[i] + 1.0*curr->dimen[i]/3.0;
			unscalevars(n,mod_suddividi.ysud,mod_suddividi.xsud);
			mod_suddividi.vetf1[i] = funct(n,mod_suddividi.xsud);

			mod_suddividi.ysud[i] = curr->cent[i] - 1.0*curr->dimen[i]/3.0;
			unscalevars(n,mod_suddividi.ysud,mod_suddividi.xsud);
			mod_suddividi.vetf2[i] = funct(n,mod_suddividi.xsud);
			mod_suddividi.mask[i] = 1;
			numtrue = numtrue + 1;

			*nf = *nf+2;
		}
		else{
			mod_suddividi.vetf1[i] = 1.e+30;
			mod_suddividi.vetf2[i] = 1.e+30;
			mod_suddividi.mask[i]  = 0;
		}
	}

	//printf("numtrue = %d\n",numtrue);

	for(i=1;i<=numtrue;i++){ 
		ind1 = minloc(n,mod_suddividi.vetf1,mod_suddividi.mask);
		ind2 = minloc(n,mod_suddividi.vetf2,mod_suddividi.mask);
		if( mod_suddividi.vetf1[ind1] < mod_suddividi.vetf2[ind2] ){
			mod_suddividi.mask[ind1] = 0;
			triplica(curr,n,ind1,mod_suddividi.vetf1[ind1],
								 mod_suddividi.vetf2[ind1],nint,xdir,fdir);
		}
		else{
			mod_suddividi.mask[ind2] = 0;
			triplica(curr,n,ind2,mod_suddividi.vetf1[ind2],
								 mod_suddividi.vetf2[ind2],nint,xdir,fdir);
		}
		*nint = *nint + 2;
	}
}
예제 #7
0
int main()
{
    Enum e = enumerator1;
    Struct s;
    int x = funct(e+1);// { dg-error "invalid" }
    int y = s.getI(e+1);// { dg-error "match" }
    return x+y;
}
예제 #8
0
파일: enum4.C 프로젝트: 5432935/crossbridge
int main()
{
  Enum e = enumerator1;
  Struct s;
  int x = funct(e+1);// { dg-error "" } .*
  int y = s.getI(e+1);// { dg-error "" } .*
  return x+y;
}
예제 #9
0
파일: pop_lib.c 프로젝트: 2ion/mutt-1.5.22
/*
 * This function calls  funct(*line, *data)  for each received line,
 * funct(NULL, *data)  if  rewind(*data)  needs, exits when fail or done.
 * Returned codes:
 *  0 - successful,
 * -1 - connection lost,
 * -2 - invalid command or execution error,
 * -3 - error in funct(*line, *data)
 */
int pop_fetch_data (POP_DATA *pop_data, char *query, progress_t *progressbar,
		    int (*funct) (char *, void *), void *data)
{
  char buf[LONG_STRING];
  char *inbuf;
  char *p;
  int ret, chunk = 0;
  long pos = 0;
  size_t lenbuf = 0;

  strfcpy (buf, query, sizeof (buf));
  ret = pop_query (pop_data, buf, sizeof (buf));
  if (ret < 0)
    return ret;

  inbuf = safe_malloc (sizeof (buf));

  FOREVER
  {
    chunk = mutt_socket_readln_d (buf, sizeof (buf), pop_data->conn, M_SOCK_LOG_HDR);
    if (chunk < 0)
    {
      pop_data->status = POP_DISCONNECTED;
      ret = -1;
      break;
    }

    p = buf;
    if (!lenbuf && buf[0] == '.')
    {
      if (buf[1] != '.')
	break;
      p++;
    }

    strfcpy (inbuf + lenbuf, p, sizeof (buf));
    pos += chunk;

    /* cast is safe since we break out of the loop when chunk<=0 */
    if ((size_t)chunk >= sizeof (buf))
    {
      lenbuf += strlen (p);
    }
    else
    {
      if (progressbar)
	mutt_progress_update (progressbar, pos, -1);
      if (ret == 0 && funct (inbuf, data) < 0)
	ret = -3;
      lenbuf = 0;
    }

    safe_realloc (&inbuf, lenbuf + sizeof (buf));
  }

  FREE (&inbuf);
  return ret;
}
예제 #10
0
/**
 * Compute only curve from selection data (averages,histograms buffer and selection buffer)
 * @param clipSrc	source of the plugin
 * @param time	current time
 * @param renderScale	current renderScale
 */
void OverlayData::computeCurveFromSelectionData( OFX::Clip* clipSrc, const OfxTime time, const OfxPointD& renderScale)
{
	_isComputing = true;

	resetCurvesFromSelectionData();
	
	if( ! clipSrc->isConnected() )
	{	
		_isComputing = false;
		return;
	}
	boost::scoped_ptr<OFX::Image> src( clipSrc->fetchImage(_currentTime, clipSrc->getCanonicalRod(_currentTime)) );	//scoped pointer of current source clip

	// Compatibility tests
	if( !src.get() ) // source isn't accessible
	{
		_isComputing = false;
		std::cout << "src is not accessible" << std::endl;
		return;
	}

	if( src->getRowBytes() == 0 )//if source is wrong
	{
		BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
	}
	OfxRectI srcPixelRod = clipSrc->getPixelRod( _currentTime, renderScale ); //get current RoD
	if( (clipSrc->getPixelDepth() != OFX::eBitDepthFloat) ||
		(!clipSrc->getPixelComponents()) )
	{
		BOOST_THROW_EXCEPTION( exception::Unsupported()	<< exception::user() + "Can't compute histogram data with the actual input clip format." );
        return;
	}

	if( srcPixelRod != src->getBounds() )
	{
		// the host does bad things !
		// remove overlay... but do not crash.
		TUTTLE_COUT_WARNING( "Image RoD and image bounds are not the same (rod=" << srcPixelRod << " , bounds:" << src->getBounds() << ")." );
		return;
	}
	
	// Compute if source is OK
	SView srcView = tuttle::plugin::getView<SView>( src.get(), srcPixelRod );	// get current view from source clip
	
	OfxPointI imgSize;
	imgSize.x = srcView.width();
	imgSize.y = srcView.height();
	
	if( isImageSizeModified( imgSize ) )
	{
		clearAll( imgSize );
	}
	//Compute histogram buffer
	Pixel_compute_histograms funct( _imgBool,_curveFromSelection, true);			//functor declaration
	terry::algorithm::transform_pixels( srcView, funct );		//(USED functor reference)
	
	this->correctHistogramBufferData(_curveFromSelection);				//correct Histogram data to make up for discretization (average)
}
예제 #11
0
int main(){
    char a[500][100];
    char sPRT[3400], scPRT[3400];
    int sect;
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    gets(sDNA);
    gets(peptide);
    char *scDNA = new char[strlen(sDNA)];
    char *sRNA = new char[strlen(sDNA)];
    char *scRNA = new char[strlen(sDNA)];
    complement(sDNA, scDNA);
    DNAintoRNA(sDNA, sRNA);
    DNAintoRNA(scDNA, scRNA);  
    
    count = 0;
    for(pos = 0; pos < 3; pos++){
        translateRNAintoPRT(sPRT, sRNA, pos);
        KMPMatcher(sPRT, peptide);
    }
    sect = count;
    for(pos = 0; pos < 3; pos++){        
        translateRNAintoPRT(scPRT, scRNA, pos);
        KMPMatcher(scPRT, peptide);  
    }
        
    for(int i = 0; i < count; i++){
        for(int j = i + 1; j < count; j++){
            if((i < sect) && (j < sect)){
                funct(i, j, sRNA, sRNA);     
            }
            if((i < sect) && (j >= sect)){
                funct(i, j, sRNA, scRNA);     
            }
            if((i >= sect) && (j >= sect)){
                funct(i, j, scRNA, scRNA);     
            }          
        }        
    }
    
    printSubStr(sDNA, scDNA, sect);
     
return 0;    
}
예제 #12
0
//Differentiation of non-vectors
double deriv(double (*funct)(double), double h, int order = 4) {

	if (order == 2) {
		return (funct(h + EPSILON) - funct(h - EPSILON)) / (2 * EPSILON);
	}
	else if (order == 4) {
		return (funct(h - 2 * EPSILON) - 8 * funct(h - EPSILON) + 8 * funct(h + EPSILON) - funct(h + 2 * EPSILON)) / (12 * EPSILON);
	}
	else {
		return(funct(h + EPSILON)-funct(h)) / EPSILON;
	}
}
int main()
{
	printf("Hello, World!\n");
	char* c1 = "Hello";
	char* c2 = "World!";

	int sz_c1 = strlen(c1);
	int sz_c2 = strlen(c2);
	int sz = sz_c1 + sz_c2 + 2;

	char* c3 = (char*) malloc(sizeof(char) * sz);
	for (int i = 0; i < sz_c1; ++i) c3[i] = c1[i];
	c3[sz_c1] = ' ';
	for (int i = 0; i < sz_c2; ++i) c3[i + sz_c1 + 1] = c2[i];
	printf("%s\n", c3);

	funct(c1, 5);
	funct(c3, "hello");
}
예제 #14
0
void		*find(t_list *list, int (*funct)(void *, void *), void *cmp)
{
  while (list)
    {
      if (!(funct(list->data, cmp)))
	return (list->data);
      list = list->next;
    }
  return (NULL);
}
예제 #15
0
/**
 * CTRMessageSend
 *
 * Sends a message to a receiver object.
 */
ctr_object* ctr_send_message(ctr_object* receiverObject, char* message, long vlen, ctr_argument* argumentList) {
	char toParent = 0;
	ctr_object* me;
	ctr_object* methodObject;
	ctr_object* searchObject;
	ctr_argument* argCounter;
	ctr_argument* mesgArgument;
	ctr_object* result;
	ctr_object* (*funct)(ctr_object* receiverObject, ctr_argument* argumentList);
	int argCount;
	if (CtrStdError != NULL) return NULL; /* Error mode, ignore subsequent messages until resolved. */
	methodObject = NULL;
	searchObject = receiverObject;
	if (vlen > 1 && message[0] == '`') {
		me = ctr_internal_object_find_property(ctr_contexts[ctr_context_id], ctr_build_string_from_cstring("me\0"), 0);
		if (searchObject == me) {
			toParent = 1;
			message = message + 1;
			vlen--;
		}
	}
	while(!methodObject) {
		methodObject = ctr_internal_object_find_property(searchObject, ctr_build_string(message, vlen), 1);
		if (methodObject && toParent) { toParent = 0; methodObject = NULL; }
		if (methodObject) break;
		if (!searchObject->link) break;
		searchObject = searchObject->link;
	}
	if (!methodObject) {
		argCounter = argumentList;
		argCount = 0;
		while(argCounter->next && argCount < 4) {
			argCounter = argCounter->next;
			argCount ++;
		}
		mesgArgument = CTR_CREATE_ARGUMENT();
		mesgArgument->object = ctr_build_string(message, vlen);
		mesgArgument->next = argumentList;
		if (argCount == 0 || argCount > 2) {
			return ctr_send_message(receiverObject, "respondTo:", 10,  mesgArgument);
		} else if (argCount == 1) {
			return ctr_send_message(receiverObject, "respondTo:with:", 15,  mesgArgument);
		} else if (argCount == 2) {
			return ctr_send_message(receiverObject, "respondTo:with:and:", 19,  mesgArgument);
		}
	}
	if (methodObject->info.type == CTR_OBJECT_TYPE_OTNATFUNC) {
		funct = methodObject->value.fvalue;
		result = funct(receiverObject, argumentList);
	}
	if (methodObject->info.type == CTR_OBJECT_TYPE_OTBLOCK) {
		result = ctr_block_run(methodObject, argumentList, receiverObject);
	}	
	return result;
}
예제 #16
0
/*
 * Copy RGB channels of the clip source into a buffer
 */
int CloudPointData::generateAllPointsVBOData(SView srcView)
{
	//compute buffer size
	int size = (int)(srcView.height()*srcView.width());	//return size : full image here

	//copy full image into buffer
	Pixel_copy funct( _imgCopy );						//functor declaration	
	//treatment
	terry::algorithm::transform_pixels( srcView, funct );		//transform pixel did with functor reference
	return size;
}
예제 #17
0
파일: mathlib.c 프로젝트: AAAJet/ooc
static double doMath (const void * tree)
{	double result = exec(right(tree));

	errno = 0;
	result = funct(tree)(result);
	if (errno)
		error("error in %s: %s",
			((struct Math *) left(tree)) -> _.name,
			strerror(errno));
	return result;
}
예제 #18
0
파일: RhoFile.cpp 프로젝트: KlearXos/rhodes
/*static*/ unsigned int CRhoFile::deleteFolder(const char* szFolderPath) 
{
#if defined(WINDOWS_PLATFORM) && !defined(OS_WP8)

	StringW  swPath;
    convertToStringW(szFolderPath, swPath);
	wchar_t* name = new wchar_t[ swPath.length() + 2];
    swprintf(name, L"%s%c", swPath.c_str(), '\0');
    translate_wchar(name, L'/', L'\\');

    SHFILEOPSTRUCTW fop = {0};

	fop.hwnd = NULL;
	fop.wFunc = FO_DELETE;		
        fop.pFrom = name;
	fop.pTo = NULL;
	fop.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR 
#if defined(OS_WINDOWS_DESKTOP) || defined(OS_PLATFORM_MOTCE)
                 | FOF_NOERRORUI
#endif        
        ;
        int result = SHFileOperationW(&fop);

    delete name;

    return result == 0 ? 0 : (unsigned int)-1;
#elif defined(OS_WP8)
	StringW  swPath;
    convertToStringW(szFolderPath, swPath);
	recursiveDeleteDirectory(swPath);
	return 0;
#elif defined (OS_ANDROID)
    
    RemoveFileFunctor funct(szFolderPath);
    return funct("");

#else
    rho_file_impl_delete_folder(szFolderPath);
    return 0;
#endif
}
예제 #19
0
/*
 * Copy discretization RGB channels of the clip source into a buffer
 */
int CloudPointData::generateDiscretizedVBOData(SView srcView, const int& discretizationStep )
{
	//compute buffer size
	int size = (int)(srcView.height()*srcView.width());						//return size : full image here

	//Create and use functor to get discretize data  (functor with template)
	Pixel_copy_discretization<SPixel> funct(_imgCopy,discretizationStep);	//functor declaration	
	terry::algorithm::transform_pixels( srcView, funct);							//with functor reference
	funct.convertSetDataToVectorData();										//copy functor data to _imgCopy data
	size = _imgCopy.size();													//change size
	return size;
}
예제 #20
0
void ProcessFile(void (*funct)(UNCH *n, FILE *f), UNCH *e, UNCH *fln){
   UNCH s[100], s2[100]; s2[0] = 0;
	makefilename(s, fln,e);
   if(dtdfilename != 0)makefilename(s2, dtdfilename,e);
	FILE *f = fopen((char *)s, "r");
	if (f != 0) funct(s, f);
   else if(s2[0] != 0){
		f = fopen((char *)s2, "r");
		if (f) funct(s2, f);
	   }
   else {
		/*RES OLD MSG 586
		Neither %0 file "%1" or "%2" was found.  SGML2TDB will stop.
		*/
		ResFile->MsgData(e);
		ResFile->MsgData(s);
		ResFile->MsgData(s2);
		ResFile->PutResError( /*RES REM INS*/ 586);
		exit(100);
	}
};
void RemoteThreadInjector::CallDLLMethod(const std::string& method) const
{
	auto hModule = LoadLibraryW(std::wstring(m_DllPath.begin(), m_DllPath.end()).c_str());
	if (hModule != nullptr)
	{
		auto procAddress = GetProcAddress(hModule, method.c_str());
		typedef void (__stdcall * funct)();
		funct DLLMethod;
		DLLMethod = funct(procAddress);
		DLLMethod();

		FreeLibrary(hModule);
	}
예제 #22
0
bool		f_list_foreach(t_list *v_this, bool (*funct)(void *data))
{
    t_list_cell	*cur;

    cur = v_this->v_begin;
    while (cur != NULL)
    {
        if (funct(cur->v_data) == false)
            return (false);
        cur = cur->v_next;
    }
    return (true);
}
예제 #23
0
파일: stack.c 프로젝트: gsliu/Work
int funct(int p)
{
	int i;
	char array[128] ;
	for(i = 0;i< 128;i++)
		array[i] = 'c';
	if(p == 0)
	{
		sleep(100000);
		return 0;
	}else{
		return funct(p-1);
	}
}
예제 #24
0
//Differentiation of vectors for any size
Matrix deriv(Vector(*funct)(Vector), Vector xy, int order = 2) {
	Matrix result(xy.len(), xy.len());
	Vector hm1 = xy;
	Vector hm2 = xy;
	Vector col;
	if (order == 2) {
		//Second order method
		for (unsigned i = 0; i < xy.len(); i++) {

			hm1.assign(i, xy(i) + EPSILON);
			hm2.assign(i, xy(i) - EPSILON);
			col = (funct(hm1) - funct(hm2)) / (2 * EPSILON);
			for (unsigned j = 0; j < xy.len(); j++)result.assign(j, i, col(j));
			hm1.assign(i, xy(i));
			hm2.assign(i, xy(i));
		}
	}
	else if (order == 4) {
		//Fourth order method
		Vector hm3=xy;
		Vector hm4=xy;
		for (unsigned i = 0; i < xy.len(); i++) {
			hm1.assign(i, xy(i) + 2*EPSILON);
			hm2.assign(i, xy(i) - 2*EPSILON);
			hm3.assign(i, xy(i) + EPSILON);
			hm4.assign(i, xy(i) - EPSILON);
			col = (funct(hm2) - 8*funct(hm4)+8*funct(hm3)-funct(hm1)) / (12 * EPSILON);
			for (unsigned j = 0; j < xy.len(); j++)	result.assign(j, i, col(j));
			hm1.assign(i, xy(i));
			hm2.assign(i, xy(i));
			hm3.assign(i, xy(i));
			hm4.assign(i, xy(i));
		}

	}
	else {
		for (unsigned i = 0; i < xy.len(); i++) {
			//First order method
			hm2.assign(i, xy(i) - EPSILON);
			col = (funct(xy) - funct(hm2)) / (EPSILON);
			for (unsigned j = 0; j < xy.len(); j++)	result.assign(j, i, col(j));
			hm1.assign(i, xy(i));
			
		}
	}
	return result;
	}
예제 #25
0
/*
 * Extend a geodesicForm using the selection
 */
void SelectionAverage::extendGeodesicForm(OFX::Clip* clipColor, const OfxPointD& renderScale, GeodesicForm& geodesicForm)
{
    // connection test
    if(!clipColor->isConnected())
    {
        return;
    }

    boost::scoped_ptr<OFX::Image> src(clipColor->fetchImage(
        _time, clipColor->getCanonicalRod(_time, renderScale))); // scoped pointer of current source clip

    // TUTTLE_LOG_VAR( TUTTLE_INFO, clipColor->getPixelRod(_time,renderScale));
    // TUTTLE_LOG_VAR( TUTTLE_INFO, clipColor->getCanonicalRod(_time, renderScale));

    // Compatibility tests
    if(!src.get()) // source isn't accessible
    {
        std::cout << "src is not accessible (color clip)" << std::endl;
        return;
    }

    if(src->getRowDistanceBytes() == 0) // if source is wrong
    {
        BOOST_THROW_EXCEPTION(exception::WrongRowBytes());
        return;
    }

    const OfxRectI srcPixelRod = clipColor->getPixelRod(_time, renderScale); // get current RoD
    if((clipColor->getPixelDepth() != OFX::eBitDepthFloat) || (!clipColor->getPixelComponents()))
    {
        BOOST_THROW_EXCEPTION(exception::Unsupported()
                              << exception::user() + "Can't compute histogram data with the actual input clip format.");
        return;
    }

    if(srcPixelRod != src->getBounds()) // the host does bad things !
    {
        // remove overlay... but do not crash.
        TUTTLE_LOG_WARNING("Image RoD and image bounds are not the same (rod=" << srcPixelRod
                                                                               << " , bounds:" << src->getBounds() << ").");
        return;
    }

    // Compute if source is OK
    SView colorView = tuttle::plugin::getGilView<SView>(src.get(), srcPixelRod,
                                                        eImageOrientationIndependant); // get current view from color clip
    Pixel_extend_GeodesicForm funct(geodesicForm);        // functor declaration			//initialize functor
    terry::algorithm::transform_pixels(colorView, funct); // with functor reference;
}
예제 #26
0
/*
** Function: newDigit
**
** Description:
** Called whenever new pulse digit or DTMF digit is collected
** Digit is added to digit buffer and findNumber is called to search for a match
** in the 'phonebook'
**
** Input Parameters:
** pState: pointer to channel state data structure
** asciiChar: digit pressed on the phone
**
** Return:
** none
*/
static void newDigit (chanState *pState, uInt8 asciiChar) {
    pt2Func funct;
    funct = NULL;
    if (pState->digitCount < 19)
    {
        pState->digits[pState->digitCount] = asciiChar;
        pState->digitCount++;
        pState->digits[pState->digitCount]= 0;
#if(PRINTF_IS_OK)
        printf("Value= %c  String collected \"%s\" ", asciiChar, pState->digits );
#endif
        funct =	findNumber(pState);
        if (funct) funct(pState);
    }
}
예제 #27
0
int main()
{
#ifdef __NVCUDA__
    acc_init( acc_device_nvcuda );
#endif
#ifdef __NVOPENCL__
    acc_init( acc_device_nvocl );
    //acc_list_devices_spec( acc_device_nvocl );
#endif

    float a[SIZE], b[SIZE], c[SIZE];
    int i;
    for(i=0; i<2*SIZE; i++)
    {
        a[i%SIZE]=i;
        b[i%SIZE]=a[(i*13)%SIZE];
        c[i%SIZE]=0;
    }

#pragma acc kernels copyin(a,b) copyout(c)
#pragma acc loop independent
    for(int i=0; i<SIZE; i++)
    {
        c[i] = funct (a[i], b[i]);
        //c[i] = a[i]>b[i]?a[i]:b[i];
    }

    for (i = 0; i < SIZE; ++i) {
        if(c[i]!= funct(a[i],b[i])) {
            fprintf(stderr,"Error %d %16.10f!=%16.10f \n", i, c[i], funct(a[i],b[i]));
            return -1;
        }
    }
    fprintf(stderr,"'function call in kernels region' test was successful!\n");
    return 0;
}
int main(){
	char function;
	int num1, num2, result;

	printf("Input numbers \n");
	scanf("%d %d", &num1, &num2);
	printf("input mathematical fuction \n");
	scanf("%s", &function);

	result=funct(function, num1, num2);
	printf("Rezultata e %d", result);
	return 0;
	int funct(char function, int num1, int num2){
		int result;
	}
예제 #29
0
double num_integrate(double x0, int n, double h) {


    double xi = 0;
    double num_integ = 0;

    // in this case: midpoint approximation
    // calculating half-step-width
    double h2 = 0.5*h;
    int i; // notice! in standard c the variables in a loop have to be declared outside
    for (i=0; i<n; i++) {
        xi = x0+i*h;
        num_integ += funct(xi+h2)*h;
    }
    return (num_integ);
} // END num_integrate()
예제 #30
0
/**
 * Update selection areas buffer to selection histograms overlay
 * @param args needed to have current time
 */
void OverlayData::computeHistogramBufferData( HistogramBufferData& data, SView& srcView, const OfxTime time, const bool isSelection)
{
	data._step = _vNbStep;					//prepare HistogramBuffer structure
	
	BOOST_ASSERT( _imgBool.shape()[0] == _size.y );
	BOOST_ASSERT( _imgBool.shape()[1] == _size.x );
	BOOST_ASSERT( srcView.width() == _size.x );
	BOOST_ASSERT( srcView.height() == _size.y );
	
	Pixel_compute_histograms funct( _imgBool, data, isSelection );			//functor declaration
	
	terry::algorithm::transform_pixels( srcView, funct );		//(USED functor reference)
	//boost::gil::for_each_pixel(srcView, funct);		(NOT USED)
	
	this->correctHistogramBufferData(data);				//correct Histogram data to make up for discretization (average)
}