当前位置: 首页>>代码示例>>C++>>正文


C++ rs_error函数代码示例

本文整理汇总了C++中rs_error函数的典型用法代码示例。如果您正苦于以下问题:C++ rs_error函数的具体用法?C++ rs_error怎么用?C++ rs_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rs_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _score2xscore

static mx_xscore_size_t _score2xscore(mx_real_t score, mx_stype_t type)
	{
	mx_xscore_size_t xs;

	/* first check parameters ... */
	if (!score)
		return(-1);
	if (!_stype_isvalid(type))
		rs_error("can't convert score of invalid type %d!",
			type);

	switch (type) {
		case mx_stype_Probability:
			xs = score * 10000.0;
			break;
		case mx_stype_LogProbability:
			xs = ((score < 650) ? (score) * 100.0 : 65535);
			break;
		default:
			rs_error("can't convert %s-type scores to external format!",
				mx_stype_text[type]);
		}

	return(xs);
	}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:25,代码来源:ev_score.c

示例2: lsFloat_setIndex

float lsFloat_setIndex(lsFloat_t *il, int index, float i, float i0)
{
  float ret;
  int j;

  if (!il)
    rs_error("lsFloat_setIndex: got NULL-pointer list");
  if (index < 0)
    rs_error("lsFloat_setIndex: illegal index %d",index);

  if (index >= il->max_list) {
    int d = (index - il->max_list) / LIST_BUF + 1;
    il->list = rs_realloc(il->list,
			  (il->max_list+= d*LIST_BUF) * sizeof(float), 
			  "list items");
  }
  for (j=il->n_list; j <= index; j++) 
    il->list[j] = i0;

  ret = il->list[index];

  il->list[index] = i;
  if (il->n_list <= index)
    il->n_list = index+1;

  return (ret);
}
开发者ID:ChrisWhiten,项目名称:VideoParser,代码行数:27,代码来源:float_list.c

示例3: rs_malloc

lsBuffer_t *lsBuffer_init(lsBuffer_t *b, 
			  lsBuffer_Copy_t *_copy, lsBuffer_Free_t *_free)
{
  int err;

  if (!b)
    b = rs_malloc(sizeof(lsBuffer_t),"lsBuffer");

  lsPt_nil(&b->new);
  lsPt_nil(&b->orig);
  lsPt_nil(&b->copy);
  lsInt_nil(&b->status);
  b->update = 1;

  if ((err = pthread_mutex_init(&b->mutexNew, NULL)) != 0) {
    rs_error("lsBuffer_init: error initializing mutex: %d.", err);
  }
  if ((err = pthread_mutex_init(&b->mutexOrig, NULL)) != 0) {
    rs_error("lsBuffer_init: error initializing mutex: %d.", err);
  }
  if ((err = pthread_mutex_init(&b->mutexCopy, NULL)) != 0) {
    rs_error("lsBuffer_init: error initializing mutex: %d.", err);
  }
  if (!_copy || !_free)
    rs_error("lsBuffer_init: no copy or free function specified.");

  b->_copy = _copy;
  b->_free = _free;
  
  return (b);
}
开发者ID:ChrisWhiten,项目名称:VideoParser,代码行数:31,代码来源:buffer.c

示例4: _xscore2score

static mx_real_t _xscore2score(mx_xscore_size_t xs, mx_stype_t type)
	{
	mx_real_t score;

	/* first check parameters ... */
	if (!xs)
		return(-1);
	if (!_stype_isvalid(type))
		rs_error("can't convert score of invalid type %d!",
			type);

	switch (type) {
		case mx_stype_Probability:
			score = (mx_real_t)(xs) / 10000.0;
			break;
		case mx_stype_LogProbability:
			score = (mx_real_t)(xs) / 100.0;
			break;
		default:
			rs_error("can't convert %s-type scores from external format!",
				mx_stype_text[type]);
		}

	return(score);
	}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:25,代码来源:ev_score.c

示例5: rs_bwrite

int rs_bwrite(rs_IO *io, void *_ptr, int size, int n_elems)
	{
	char* ptr = (char*)_ptr;

	if (!ptr || !io)
		return(-1);

	switch(io->type) {
		case rs_iotype_mem:
			rs_error("binary write to memory not supported!");

			/* ACHTUNG: keine Grenzueberpruefung! */
			break;

		case rs_iotype_file:
			n_elems = _fwrite_padded(ptr, size, n_elems,
						io->base_size, io->fp);
			break;

		default:
			rs_error("IO type %d not supported by 'rs_bread()'!",
				io->type);
		}

	return(n_elems);
	}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:26,代码来源:ev_io.c

示例6: rs_malloc

naive_bayes_classifier_t *nB_fscan(naive_bayes_classifier_t *nB, char *filename, fx_select_t *sel) { 
	int class_ind, start, end, i;
    FILE *fp = NULL, *feature_fp = NULL;
    mx_real_t *features=NULL;
    char *line=NULL, *token;
    char *fname =NULL;
    char *class_name = (char *) rs_malloc(STRING_LENGTH*sizeof(char),"String");
    int full_feature_dim=sel?sel->n_features:nB->feature_dim;

    if (!nB)
		rs_error("classifier could not be initialised!");
     
	fp = fopen(filename,"r");
    if (fp == NULL) {
		rs_error("Cannot open file %s!",filename);
    }
    else {
		features = (mx_real_t *) rs_calloc(full_feature_dim, sizeof(mx_real_t), "feature vector");
	 
	 	while ((line= (char *) rs_line_read(fp,';'))) {
	    	fname = (char *) strtok(line,"\t ");
	     	feature_fp = fopen(fname, "r");
	     	if (feature_fp == NULL) {
		 		rs_warning("can't open '%s '!", fname);
		 		while (getchar() != '\n');
		 			continue;
	     	}
	     	line+= strlen(fname)+1;

		    if (feature_fp) {
				for (token = (char *) strtok(line," "); token != NULL; token = (char *) strtok(NULL, " ")) {
		     		if (sscanf(token,"%[^[]s",class_name) !=1 ) 
						rs_error("wrong length information for file %s!",fname);
		     		token += strlen(class_name);
		     		if (sscanf(token,"[%d..%d]",&start,&end) !=2)
			 			rs_error("wrong length information for file %s!",fname);
		     		for (i=start;i<=end;i++) {
			 			if (fread(features,sizeof(mx_real_t),full_feature_dim,feature_fp)!=full_feature_dim)
			     			rs_perror("fread stopped after %d elements in file %s -- %d", i, fname, errno);
			 			else {
							if (sel) 
							    if ( fx_select_apply(&features,sel,features)!= sel->n_features)
									rs_error("Feature selection did not succeed!");
							class_ind = cl_name2number(&(nB->mapping),class_name,nB->n_classes);
							nB=nB_update_classifier(nB,class_ind,features);
			 			}
		     		}
				}
				fclose(feature_fp);
	     	}
		}
		nB_finish_classifier(nB);
	}
    fclose(fp);
    rs_free(class_name);
    rs_free(features);
    
    return nB;
}
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:59,代码来源:ev_naive_bayes.c

示例7: lsFloat_get

float lsFloat_get(lsFloat_t * il,int i)
{
  if (!il)
    rs_error("lsFloat_get: got NULL-pointer list");
  if (i < 0 || i >= il->n_list)
    rs_error("lsFloat_get: index [%d] out of range [%d..%d]",i,0,il->n_list);
  
  return (il->list[i]);
}
开发者ID:ChrisWhiten,项目名称:VideoParser,代码行数:9,代码来源:float_list.c

示例8: if

rs_IO *rs_fopen(char *name, char *mode)
	{
	FILE *fp;
	rs_IO *io;
	int mode_read, mode_mapped;
	void *buf;
	int buf_size;

	/* Lese-/Schreibmodus bestimmen ... */
	if (strchr(mode, 'w') || strchr(mode, 'a'))
		mode_read = 0;
	else if (strchr(mode, 'r'))
		mode_read = 1;
	else	rs_error("illegal mode '%s' for 'rs_fopen()'!", mode);

	/* ... ggf. ge-"mapped" (nur lesend) ... */
	if (strchr(mode, 'm')) {
		if (mode_read)
			mode_mapped = 1;
		else	{
			mode_mapped = 0;
			rs_warning("mapped file IO not supported for writing!");
			}
		}
	else	mode_mapped = 0;

	/* ... Spezialnamen '-' umsetzen ... */
	if (strcmp(name, "-") == 0) {
		if (mode_mapped)
			rs_error("mapped file IO not supported for stdin/out!");

		fp = (mode_read) ? stdin : stdout;
		}
	else	fp = fopen(name, (mode_read) ? "r" : "w");
	if (!fp)
		return(NULL);
	
	if (!mode_mapped) {
		io = rs_malloc(sizeof(rs_IO), "IO data");
		io->type = rs_iotype_file;
		io->base_size = RS_BINIO_BASE_SIZE_DEFAULT;
		io->fp = fp;
		}
	else	{
		fseek(fp, 0, SEEK_END);
		buf_size = ftell(fp);
		rewind(fp);

		buf = rs_malloc(buf_size, "mapped file buffer");
		fread(buf, buf_size, 1, fp);

		io = rs_mopen(buf, buf_size, "r");
		}

	return(io);
	}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:56,代码来源:ev_io.c

示例9: rs_infilebuf_fill

/*
 * If the stream has no more data available, read some from F into
 * BUF, and let the stream use that.  On return, SEEN_EOF is true if
 * the end of file has passed into the stream.
 */
rs_result rs_infilebuf_fill(rs_job_t *job, rs_buffers_t *buf,
                            void *opaque)
{
    int                     len;
    rs_filebuf_t            *fb = (rs_filebuf_t *) opaque;
    FILE                    *f = fb->f;
        
    /* This is only allowed if either the buf has no input buffer
     * yet, or that buffer could possibly be BUF. */
    if (buf->next_in != NULL) {
        assert(buf->avail_in <= fb->buf_len);
        assert(buf->next_in >= fb->buf);
        assert(buf->next_in <= fb->buf + fb->buf_len);
    } else {
        assert(buf->avail_in == 0);
    }

    if (buf->eof_in || (buf->eof_in = feof(f))) {
        rs_trace("seen end of file on input");
        buf->eof_in = 1;
        return RS_DONE;
    }

    if (buf->avail_in)
        /* Still some data remaining.  Perhaps we should read
           anyhow? */
        return RS_DONE;
        
    len = fread(fb->buf, 1, fb->buf_len, f);
    if (len <= 0) {
        /* This will happen if file size is a multiple of input block len
         */
        if (feof(f)) {
            rs_trace("seen end of file on input");
            buf->eof_in = 1;
            return RS_DONE;
        }
        if (ferror(f)) {
            rs_error("error filling buf from file: %s",
                     strerror(errno));
            return RS_IO_ERROR;
        } else {
            rs_error("no error bit, but got %d return when trying to read",
                     len);
            return RS_IO_ERROR;
        }
    }
    buf->avail_in = len;
    buf->next_in = fb->buf;

    return RS_DONE;
}
开发者ID:paulharris,项目名称:librsync,代码行数:57,代码来源:buf.c

示例10: lsFloat_delSwap

float lsFloat_delSwap(lsFloat_t *il, int i)
{
  float x;

  if (LS_isNIL(il))
    rs_error("ls_delIndex: got empty list");
  if (!LS_EXISTS(il,i))
    rs_error("ls_delIndex: illegal index %d",i);

  x = LS_GET(il,i);
  LS_GET(il,i) = LS_LAST(il);
  LS_N(il)--;
  return (x);
}
开发者ID:ChrisWhiten,项目名称:VideoParser,代码行数:14,代码来源:float_list.c

示例11: mx_scoreset_fread

int mx_scoreset_fread(mx_scoreset_t *scoreset, FILE *fp)
	{
	int i, j, tot_scores = 0;
	mx_scorelist_t *scorelist;
	mx_xscore_size_t n;
	mx_xscore_t xscore;

	if (!scoreset || !fp)
		return(-1);

	mx_scoreset_reset(scoreset);

	if (scoreset->n_lists > 1) {
		if (fread(&n, sizeof(n), 1, fp) != 1)
			return(0);
		if (n != scoreset->n_lists)
			rs_error("number of codebooks %d does not match"
				"external score data %d!",
				n, scoreset->n_lists);
		}

	for (i = 0; i < scoreset->n_lists; i++) {
		scorelist = scoreset->list[i];

		if (fread(&n, sizeof(n), 1, fp) != 1) {
			if (scoreset->n_lists > 1)
				rs_error("can't read # of scores!");
			else	return(0);
			}
		if (n <= 0)
			rs_error("illegal # of scores %d read!", n);

		for (j = 0; j < n; j++) {
			if (fread(&xscore, sizeof(xscore), 1, fp) != 1)
				rs_error("can't read external score!");
			if (xscore.id < 0)
				rs_error("illegal id %d external score data!",
					xscore.id);

			mx_scorelist_addscore(scorelist,
				xscore.id,
				_xscore2score(xscore.score, scorelist->type));
			}

		tot_scores += scorelist->n_scores;
		}

	return(tot_scores);
	}
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:49,代码来源:ev_score.c

示例12: fopen

naive_bayes_classifier_t *nB_fread_classifier(char *model_name) {
    int class_ind, weight_no=0, n_classes, feature_dim, i;
    FILE *model_fp;
    char *line, *token;
    naive_bayes_classifier_t *naiveBayes=NULL;
    
    model_fp = fopen(model_name,"r");
    if (!model_fp)
	rs_error("can't open file %s!",model_name);      

    line = (char *) rs_line_read(model_fp,'#');
    token = (char *) strtok(line,"\t");
    n_classes = atoi(token);
    line += strlen(token)+1;
    feature_dim = atoi((char *) strtok(line,"\t"));
    

    naiveBayes = nB_new_classifier(n_classes,feature_dim);
    
    class_ind=0;
    while ((line= (char *) rs_line_read(model_fp,'#')) && class_ind < n_classes) {
	char *name =(char *) strtok(line,"\t");
	int len=strlen(name)+1;
	naiveBayes->mapping[class_ind] = (char *) rs_malloc(len*sizeof(char),"class name");
	strcpy(naiveBayes->mapping[class_ind],name);
	line+=len;
	naiveBayes->class_probs[class_ind] = (mx_real_t) atof((char *) strtok(line,"\t"));
	
	while (weight_no < feature_dim && fscanf(model_fp, "%g\t%g", &naiveBayes->means[class_ind][weight_no], &naiveBayes->std_dev[class_ind][weight_no]) == 2) 
	    weight_no++;
	if (weight_no<feature_dim-1)
	    rs_error("problem with means or standard devs in file %s!",model_name);
	weight_no=0;
	class_ind++;
    }

    if (class_ind <n_classes-1)
	rs_error("problem with class no %d in file %s!",class_ind,model_name);

    //fprintf(stderr,"Classifying into the following classes:\n");
    //for (i=0;i<n_classes;i++)
	//fprintf(stderr,"%s ",naiveBayes->mapping[i]);
    //fprintf(stderr,"\n");
    
    naiveBayes->finished=1;
    fclose(model_fp);
    return naiveBayes;
}
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:48,代码来源:ev_naive_bayes.c

示例13: rs_validate_rabin

/* Check that the given Rabin signature is valid. */
int rs_validate_rabin (const mpz_t sig,  /* purported signature of app */
		       int f,		 /* f value */
		       const mpz_t hash, /* MD5 hash of app */
                       const RSKey* key) /* key structure */
{
  mpz_t a, b;
  int result;

  if (!mpz_sgn(key->n)) {
    rs_error(key, NULL, "unable to validate: public key missing");
    return RS_ERR_MISSING_PUBLIC_KEY;
  }

  if (f < 0 || f > 3)
    return RS_SIGNATURE_INCORRECT;

  mpz_init(a);
  mpz_init(b);

  mpz_mul(a, sig, sig);
  mpz_mod(a, a, key->n);

  applyf(b, hash, key->n, f);

  result = mpz_cmp(a, b);

  mpz_clear(a);
  mpz_clear(b);
  return (result ? RS_SIGNATURE_INCORRECT : RS_SUCCESS);
}
开发者ID:abbrev,项目名称:rabbitsign,代码行数:31,代码来源:rabin.c

示例14: svm_class_prob

mx_real_t svm_class_prob(svm_classifier_t *svm, mx_real_t *instance, int class_ind) {
    int i, svm_type=svm_get_svm_type(svm->model);
    double *prob_estimates=NULL;
    struct svm_node *x;
	mx_real_t class_prob;

    if (svm_type!=C_SVC && svm_type != NU_SVC)
	rs_error("Cannot give class probability for 1-class or regression SVM!");

    x = (struct svm_node *) rs_malloc((svm->feature_dim+1)*sizeof(struct svm_node),"Feature vector representation for svm");
    for (i=0;i<svm->feature_dim;i++) {
		x[i].index=i+1;
		x[i].value=instance[i];
    }
    x[i].index=-1;

    _scale_instance(&x,svm->feature_dim,svm->max,svm->min);
    
    prob_estimates = (double *) rs_malloc(svm->n_classes*sizeof(double),"SVM probability estimates");
    
    svm_predict_probability(svm->model,x,prob_estimates);
    
	class_prob = prob_estimates[class_ind];
	rs_free (x);
	rs_free (prob_estimates);
	return class_prob;
}
开发者ID:hihiy,项目名称:IntelliVoice,代码行数:27,代码来源:ev_svm_wrapper.c

示例15: event_handler_pdu_receive

bool event_handler_pdu_receive(node_t *node, node_t *incoming_node, mac_pdu_t *pdu)
{
    bool all_ok = TRUE;

    incoming_node->mac_info->error = FALSE; /* emulate a MAC acknowledgment */

    switch (pdu->type) {

        case MAC_TYPE_IP : {
            ip_pdu_t *ip_pdu = pdu->sdu;
            pdu->sdu = NULL;

            if (!ip_node_receive(node, incoming_node, ip_pdu)) {
                all_ok = FALSE;
            }

            break;
        }

        default:
            rs_error("node '%s': unknown MAC type '0x%04X'", node->phy_info->name, pdu->type);
            all_ok = FALSE;
    }

    return all_ok;
}
开发者ID:Dirkomir,项目名称:rpl-simulator,代码行数:26,代码来源:mac.c


注:本文中的rs_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。