Ejemplo n.º 1
0
void cChannel::SetId(int Nid, int Tid, int Sid, int Rid)
{
  if (nid != Nid || tid != Tid || sid != Sid || rid != Rid) {
     if (Number()) {
        dsyslog("changing id of channel %d from %d-%d-%d-%d to %d-%d-%d-%d", Number(), nid, tid, sid, rid, Nid, Tid, Sid, Rid);
        modification |= CHANNELMOD_ID;
        Channels.SetModified();
        Channels.UnhashChannel(this);
        }
     nid = Nid;
     tid = Tid;
     sid = Sid;
     rid = Rid;
     if (Number())
        Channels.HashChannel(this);
     schedule = NULL;
     }
}
Ejemplo n.º 2
0
Number notEqual(Number a,Number b){
	Number result;
	result = equal(a,b);
	if (result==Number(1,1))
		result.setValue(0,1);
	else
		result.setValue(1,1);
	return result;
}
Ejemplo n.º 3
0
void cChannel::SetCaDescriptors(int Level)
{
  if (Level > 0) {
     modification |= CHANNELMOD_CA;
     Channels.SetModified();
     if (Level > 1)
        dsyslog("changing ca descriptors of channel %d", Number());
     }
}
Ejemplo n.º 4
0
extern "C" void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
{
    for (int i = 0; i < Number(spiMap); i++) {
        if (spiMap[i] && &spiMap[i]->_spi == hspi) {
            spiMap[i]->txrxComplete();
            break;
        }
    }
}
Ejemplo n.º 5
0
void Parser::single_group() {
    match(GROUP);
    string num = tokens[look].value;
    match(NUM);
    match(AS);
    string id = tokens[look].value;;
    match(ID);
    groups.push_back(Number(num));
    col_names.push_back(id);
}
Ejemplo n.º 6
0
Archivo: event.c Proyecto: barak/lush
void ev_parsedesc(at *desc)
{
   if (CONSP(desc)) {
      ev_parsedesc(Car(desc));
      ev_parsedesc(Cdr(desc));
   } else if (GPTRP(desc))
      evdesc = (const char *)String(desc);
   else if (NUMBERP(desc))
      evmods = (unsigned char)Number(desc);
}
Ejemplo n.º 7
0
void FailureWeaponJammed(MECH * mech, int weapnum, int weaptype,
						 int section, int critical, int roll, int *modifier,
						 int *type)
{
	SetPartTempNuke(mech, section, critical, failures[Conv(mech, section,
														   critical) +
													  roll].type);
	*type = WEAPON_JAMMED;
	SetRecyclePart(mech, section, critical, Number(20, 40));
}
Ejemplo n.º 8
0
void Subtraction::push_operation_result(Interpreter &interpreter, const PElement &_x, const PElement &_y)
{
	try {
		const Number &x = dynamic_cast<const Number &>(_x);
		const Number &y = dynamic_cast<const Number &>(_y);
		interpreter.pushPolizElement(Number(x.getValue() - y.getValue()));
	} catch(bad_cast&) {
		throw std::logic_error("Operation `" + toString() + "' requires 2 numbers as arguments");
	}
}
Ejemplo n.º 9
0
void Next(Point p)
{
	Point p1, p2; //p2存储下一步要走的位置 p1存储当前位置
	p2=p;
	while(step < N * N)
	{
		InitStack(s[step]);
		board[p.x][p.y] = step;
		Push(s1, p); //将当前位置压入s1
		Exit(p);
		Pop(s[step], p2); 
		if ((s[step].base == s[step].top && Number(p2) == 0) && step != N * N - 1) //s[step]为空栈 下一步不能走了 步数没有到64
		{ 
			Pop(s1, p1); //把当前位置从临时栈s1里pop出来
			board[p1.x][p1.y] = 0; 
			--step; 
			while (s[step].base == s[step].top) 
			{
				Pop(s1, p1); 
				board[p1.x][p1.y] = 0;
				step--; //一直回溯到下步能走为止
			}
			Pop(s[step], p2); //换一种下一步的走法
			step++;
			p=p2;
			
		}
		else if (Number(p2) == 0 && s[step].base != s[step].top)
		{
			Pop(s[step], p2); 
			step++;
			p=p2;
			
		}
		else
		{
			step++;
			p=p2;
			
		}
	}
	board[p.x][p.y] = step;
}
Ejemplo n.º 10
0
void Next(Point p) //找出各个位置并将其步数记录
{
	Point p1,p2; //p2存储下一步要走的位置 p1存储当前位置
	InitStack(s[step]);
	board[p.x][p.y]=step;
	Push(s1,p); //将当前所在位置压入临时栈s1
	if (step<N*N)
	{
		Exit(p);
		Pop(s[step],p2); //p2是从s[step]里pop出来的
		if ((s[step].base==s[step].top&&Number(p2)==0)&&step!=N*N-1) //s[step]为空栈 下一步不能走了 步数没有到64
		{ //这个时候我们需要回溯操作
			Pop(s1,p1); //把当前位置从临时栈s1里pop出来
			board[p1.x][p1.y]=0; //清零操作
			--step; //步数减1
			while (s[step].base==s[step].top) //清除s[step]栈为空栈
			{
				Pop(s1,p1); //从s1中弹栈放到p1中
				board[p1.x][p1.y]=0;
				step--; //一直回溯到能走为止
			}
			Pop(s[step], p2); //换一种下一步的走法
			step++;
			Next(p2);
		}
		else if (Number(p2)==0&&s[step].base!=s[step].top)//下一步没有走的位置 栈不为空
		{
			Pop(s[step],p2); //换一种下一步的走法
			step++;
			Next(p2);
		}
		else if (Number(p2)!=0&&s[step].base==s[step].top)//下一步有走的位置 但是栈s[step]为空
		{ //直接走下一步
			step++;
			Next(p2);
		}
		else
		{
			step++;
			Next(p2);
		}
	}
}
Ejemplo n.º 11
0
thing_th *dirty_sub(thing_th *args) {
    long num=0;
    char *outty;
    thing_th *output;
    if(!args)
        return Number("0");
    if(Cdr(args)) {
        num=text_to_long(Car(args));
        args=Cdr(args);
    }
    while(args) {
        num-=text_to_long(Car(args));
        args=Cdr(args);
    }
    asprintf(&outty, "%ld", num);
    output=Number(outty);
    erase_string(outty);
    return output;
}
Ejemplo n.º 12
0
void Modulo::push_operation_result(Interpreter& interpreter,
		const PElement& left, const PElement& right) {
	try {
		const Number &x = dynamic_cast<const Number &>(left);
		const Number &y = dynamic_cast<const Number &>(right);
		interpreter.pushPolizElement(Number(x.getValue() % y.getValue()));
	} catch(bad_cast&) {
		throw std::logic_error("Operation `" + toString() + "' requires 2 numbers as arguments");
	}
}
Ejemplo n.º 13
0
Data::Data(const Data& right)
{
	tree = right.tree;
	std::strcpy(this->name,right.name);
	this->storedData = Number(right.storedData);
	this->doesDataInited = true;
	doesTreeInited = false;
	this->type = right.type;
	this->priority = right.priority;
}
Ejemplo n.º 14
0
/* interface calling into the fortran routine */
static int lbfgs(index_t *x0, at *f, at *g, double gtol, htable_t *p, at *vargs)
{
   /* argument checking and setup */

   extern void lbfgs_(int *n, int *m, double *x, double *fval, double *gval, \
                      int *diagco, double *diag, int iprint[2], double *gtol, \
                      double *xtol, double *w, int *iflag);

   ifn (IND_STTYPE(x0) == ST_DOUBLE)
      error(NIL, "not an array of doubles", x0->backptr);
   ifn (Class(f)->listeval)
      error(NIL, "not a function", f);
   ifn (Class(f)->listeval)
      error(NIL, "not a function", g);
   ifn (gtol > 0)
      error(NIL, "threshold value not positive", NEW_NUMBER(gtol));
   
   at *gx = copy_array(x0)->backptr;
   at *(*listeval_f)(at *, at *) = Class(f)->listeval;
   at *(*listeval_g)(at *, at *) = Class(g)->listeval;
   at *callf = new_cons(f, new_cons(x0->backptr, vargs));
   at *callg = new_cons(g, new_cons(gx, new_cons(x0->backptr, vargs)));

   htable_t *params = lbfgs_params();
   if (p) htable_update(params, p);
   int iprint[2];
   iprint[0] = (int)Number(htable_get(params, NEW_SYMBOL("iprint-1")));
   iprint[1] = (int)Number(htable_get(params, NEW_SYMBOL("iprint-2")));
   lb3_.gtol = Number(htable_get(params, NEW_SYMBOL("ls-gtol")));
   lb3_.stpmin = Number(htable_get(params, NEW_SYMBOL("ls-stpmin")));
   lb3_.stpmax = Number(htable_get(params, NEW_SYMBOL("ls-stpmax")));
   int m = (int)Number(htable_get(params, NEW_SYMBOL("lbfgs-m")));
   int n = index_nelems(x0);
   double *x = IND_ST(x0)->data;
   double  fval;
   double *gval = IND_ST(Mptr(gx))->data;
   int diagco = false;
   double *diag = mm_blob(n*sizeof(double));
   double *w = mm_blob((n*(m+m+1)+m+m)*sizeof(double));
   double xtol = eps(1); /* machine precision */
   int iflag = 0;

   ifn (n>0)
      error(NIL, "empty array", x0->backptr);
   ifn (m>0)
      error(NIL, "m-parameter must be positive", NEW_NUMBER(m));

   /* reverse communication loop */
   do {
      fval = Number(listeval_f(Car(callf), callf));
      listeval_g(Car(callg), callg);
      lbfgs_(&n, &m, x, &fval, gval, &diagco, diag, iprint, &gtol, &xtol, w, &iflag);
      assert(iflag<2);
   } while (iflag > 0);
   
   return iflag;
}
Ejemplo n.º 15
0
		Serializer& DefaultSerializer::operator <<(const dtn::data::Block& obj)
		{
			_stream.put((char&)obj.getType());
			_stream << obj.getProcessingFlags();

			const Block::eid_list &eids = obj.getEIDList();

#ifdef __DEVELOPMENT_ASSERTIONS__
			// test: BLOCK_CONTAINS_EIDS => (eids.size() > 0)
			assert(!obj.get(Block::BLOCK_CONTAINS_EIDS) || (eids.size() > 0));
#endif

			if (obj.get(Block::BLOCK_CONTAINS_EIDS))
			{
				_stream << Number(eids.size());
				for (Block::eid_list::const_iterator it = eids.begin(); it != eids.end(); ++it)
				{
					dtn::data::Dictionary::Reference offsets;

					if (_compressable)
					{
						offsets = (*it).getCompressed();
					}
					else
					{
						offsets = _dictionary.getRef(*it);
					}

					_stream << offsets.first;
					_stream << offsets.second;
				}
			}

			// write size of the payload in the block
			_stream << Number(obj.getLength());

			// write the payload of the block
			Length slength = 0;
			obj.serialize(_stream, slength);

			return (*this);
		}
void test_specific(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&)
{
   if(std::numeric_limits<Number>::is_modulo)
   {
      if(!std::numeric_limits<Number>::is_signed)
      {
         BOOST_TEST(1 + (std::numeric_limits<Number>::max)() == 0);
         BOOST_TEST(--Number(0) == (std::numeric_limits<Number>::max)());
      }
   }
}
Ejemplo n.º 17
0
static thing_th *read_literals(FILE *src, text_buffer *tb, int inputChar) {
    while(!literal_terminator_char(inputChar)) {
        tb_append(tb, inputChar);
        inputChar=get_character(src);
    }
    if(!is_whitespace(inputChar))
        ungetc(inputChar, src);
    if(is_decimal_text(tb->txt))
        return read_subcons(Number(tb->txt), src, tb);
    return read_subcons(Atom(tb->txt), src, tb);
}
Ejemplo n.º 18
0
void cChannel::SetCaIds(const int *CaIds)
{
  if (caids[0] && caids[0] <= CA_USER_MAX)
     return; // special values will not be overwritten
  if (IntArraysDiffer(caids, CaIds)) {
     char OldCaIdsBuf[MAXCAIDS * 5 + 10]; // 5: 4 digits plus delimiting ',', 10: paranoia
     char NewCaIdsBuf[MAXCAIDS * 5 + 10];
     IntArrayToString(OldCaIdsBuf, caids, 16);
     IntArrayToString(NewCaIdsBuf, CaIds, 16);
     if (Number())
        dsyslog("changing caids of channel %d from %s to %s", Number(), OldCaIdsBuf, NewCaIdsBuf);
     for (int i = 0; i <= MAXCAIDS; i++) { // <= to copy the terminating 0
         caids[i] = CaIds[i];
         if (!CaIds[i])
            break;
         }
     modification |= CHANNELMOD_CA;
     Channels.SetModified();
     }
}
Ejemplo n.º 19
0
	/**
	 * \note A state variable will be reset when no feedback instruction is used on it in a single run.
	 *       It will be reinitialized by the next time INIT_FEEDBACK is executed.
	 * 
	 * \param Int The index of the state variable.
	 * \param Address The function to give the initial value, if not yet set.
	 * 
	 * \return Data The value of the state variable.
	 */
	void INIT_FEEDBACK(Machine & machine){
		Index state_index = machine.nextInt();
		Address initialization_function = machine.stack.popAddress();
		machine.state[state_index].is_executed = true;
		machine.state[state_index].thread = machine.currentThreadId();
		if (machine.state[state_index].data.isSet()){
			machine.stack.push(machine.state[state_index].data);
		} else {
			machine.stack.push(Number(state_index));
			machine.call(initialization_function, INIT_FEEDBACK_set_state);
		}
	}
Ejemplo n.º 20
0
void cChannel::SetName(const char *Name, const char *ShortName, const char *Provider)
{
  if (!isempty(Name)) {
     bool nn = strcmp(name, Name) != 0;
     bool ns = strcmp(shortName, ShortName) != 0;
     bool np = strcmp(provider, Provider) != 0;
     if (nn || ns || np) {
        if (Number()) {
           dsyslog("changing name of channel %d from '%s,%s;%s' to '%s,%s;%s'", Number(), name, shortName, provider, Name, ShortName, Provider);
           modification |= CHANNELMOD_NAME;
           Channels.SetModified();
           }
        if (nn)
           name = strcpyrealloc(name, Name);
        if (ns)
           shortName = strcpyrealloc(shortName, ShortName);
        if (np)
           provider = strcpyrealloc(provider, Provider);
        }
     }
}
Ejemplo n.º 21
0
/*------------------------------------------------------------------------*
 * 4近傍のラベリング。できあがりはlong型
 *------------------------------------------------------------------------*/
long image__N4_labelling_long(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("N4_labelling_long",
				   original,
				   Number(N4_long_table),N4_long_table);

  if (caller) return caller(label,original);

  return 0;
}
Ejemplo n.º 22
0
/*
 * Determine the trace type for FILE * 'fp'.
 *
 * NB - This function should NOT be used when biolims support is required
 * (as biolims doesn't use files !)
 *
 * Returns:
 *     TT_SCF, TT_CTF, TT_ZTR, TT_ABI, TT_ALF, or TT_PLN for success.
 *     TT_UNK for unknown type.
 *     TT_ERR for error.
 */
int fdetermine_trace_type(FILE *fp)
{
    unsigned int i;
    size_t len;
    char buf[512];
    int ps;
    int acgt;
    int c;

    /* check magics */
    for (i = 0 ; i < Number(magics) ; i++) {
	if (fseek(fp,magics[i].offset,0) == 0) {
	    len = strlen(magics[i].string);
	    if (fread(buf,1,len,fp)==len) {
		if (strncmp(buf,magics[i].string,len)==0) {
		    return magics[i].type;
		}
	    }
	}
    }
    fseek(fp, 0, 0);

    /* determine if this is a text file */
    len = 0; ps = 0; acgt = 0;
    for (i = 0; i < 512; i++) {
	if ( ( c = fgetc(fp) ) == EOF ) break;
	switch(c) {
	case 'a': case 'c': case 'g': case 't':
	case 'A': case 'C': case 'G': case 'T':
	/*YUK! need the next line?*/
	case 'n': case 'N': case '-':
	    acgt++;
	default:
	    len++;
	    if ( (isprint(c) && isascii(c)) || isspace(c) ) ps++;
	}
    }
    fseek(fp, 0, 0);
    /*YUK! 75% of characters printable means text*/
    if ( 100 * (size_t)ps > 75 * len ) {
	/*YUK! 75% of printables ACGTN means plain*/
	if (100 * acgt > 75 * ps) {
	    return TT_PLN;
	}
    }

    /* YUK! short files are not traces? */
    if (len<512) {
        return TT_UNK;
    }

    return TT_UNK;
}
Ejemplo n.º 23
0
void growSnow(MAP * map, int lowDepth, int highDepth)
{
    int i, j;
    char terrain;
    int layer, layerData;
    int depth = 0;
    int sign = 1;
    int low, high;

    if ((lowDepth == 0) && (highDepth == 0))
	return;

    low = MIN(abs(lowDepth), abs(highDepth));
    high = MAX(abs(lowDepth), abs(highDepth));

    if ((lowDepth < 0) || (highDepth < 0))
	sign = -1;

    for (i = 0; i < map->map_width; i++) {
	for (j = 0; j < map->map_height; j++) {
	    terrain = GetHexTerrain(map, i, j);

	    switch (terrain) {
	    case BRIDGE:
	    case FIRE:
	    case WATER:
	    case ICE:
		continue;
		break;
	    }

	    depth = Number(low, high) * sign;

	    if (depth == 0)
		continue;

	    layerData = GetHexLayerData(map, i, j);

	    if (depth < 0) {
		if (!(HexHasSnow(map, i, j) || HexHasDeepSnow(map, i, j)))
		    continue;
	    } else {
		if (!(HexHasSnow(map, i, j) && HexHasDeepSnow(map, i, j)))
		    SetHexLayers(map, i, j, HEXLAYER_SNOW);
	    }

	    SetHexLayerData(map, i, j, (layerData + depth));
	    validateSnowDepth(map, i, j);
	}
    }

}
Ejemplo n.º 24
0
Value DOMCSSRule::getValueProperty(ExecState *exec, int token) const
{
    switch(token)
    {
        case Type:
            return Number(cssRule.type());
        case CssText:
            return String(cssRule.cssText());
        case ParentStyleSheet:
            return getDOMStyleSheet(exec, cssRule.parentStyleSheet());
        case ParentRule:
            return getDOMCSSRule(exec, cssRule.parentRule());

        // for DOM::CSSRule::STYLE_RULE:
        case Style_SelectorText:
            return String(static_cast< DOM::CSSStyleRule >(cssRule).selectorText());
        case Style_Style:
            return getDOMCSSStyleDeclaration(exec, static_cast< DOM::CSSStyleRule >(cssRule).style());

        // for DOM::CSSRule::MEDIA_RULE:
        case Media_Media:
            return getDOMMediaList(exec, static_cast< DOM::CSSMediaRule >(cssRule).media());
        case Media_CssRules:
            return getDOMCSSRuleList(exec, static_cast< DOM::CSSMediaRule >(cssRule).cssRules());

        // for DOM::CSSRule::FONT_FACE_RULE:
        case FontFace_Style:
            return getDOMCSSStyleDeclaration(exec, static_cast< DOM::CSSFontFaceRule >(cssRule).style());

        // for DOM::CSSRule::PAGE_RULE:
        case Page_SelectorText:
            return String(static_cast< DOM::CSSPageRule >(cssRule).selectorText());
        case Page_Style:
            return getDOMCSSStyleDeclaration(exec, static_cast< DOM::CSSPageRule >(cssRule).style());

        // for DOM::CSSRule::IMPORT_RULE:
        case Import_Href:
            return String(static_cast< DOM::CSSImportRule >(cssRule).href());
        case Import_Media:
            return getDOMMediaList(exec, static_cast< DOM::CSSImportRule >(cssRule).media());
        case Import_StyleSheet:
            return getDOMStyleSheet(exec, static_cast< DOM::CSSImportRule >(cssRule).styleSheet());

        // for DOM::CSSRule::CHARSET_RULE:
        case Charset_Encoding:
            return String(static_cast< DOM::CSSCharsetRule >(cssRule).encoding());

        default:
            kdDebug(6070) << "WARNING: DOMCSSRule::getValueProperty unhandled token " << token << endl;
    }
    return Undefined();
}
TNumberPlateDetector::Number TNumberPlateDetector::Recognizer::recognizeNumber(const cv::Mat& plate) {
    CV_Assert(plate.type() == CV_8UC1);

    cv::Mat img_thresh;
    cv::threshold(plate, img_thresh, RECOGNIZER_THRESHOLD, RECOGNIZER_THRESHOLD_MAX, CV_THRESH_BINARY_INV);

    cv::blur(img_thresh, img_thresh, cv::Size(3, 3));
#if defined(_DEBUG_)
    cv::imshow("Thresh", img_thresh);
#endif

    cv::Mat img_contours = img_thresh.clone();
    std::vector<std::vector< cv::Point >> contours;
    cv::findContours(img_contours, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

#if defined(_DEBUG_)
    std::cout << "Found contours: " << contours.size() << std::endl;
    for (auto it = contours.cbegin(), iend = contours.cend(); it != iend; ++it) {
        cv::Scalar color(255);
        cv::drawContours(img_contours, contours, it - contours.cbegin(), color);
    }
    cv::imshow("Contours", img_contours);
    cv::waitKey();
#endif

    for (auto it = contours.begin(); it != contours.end(); ++it) {
        cv::Rect symbolBounds = cv::boundingRect(*it);
        cv::Mat symbol = img_thresh(
            cv::Range(symbolBounds.y, symbolBounds.y + symbolBounds.height),
            cv::Range(symbolBounds.x, symbolBounds.x + symbolBounds.width)            
            ).clone();
        if (verifySymbolSize(symbol) == false) {
            it = contours.erase(it);
            if (it != contours.end()) {
                break;
            }
        }
    }

#if defined(_DEBUG_)
    img_contours.setTo(cv::Scalar(0));
    std::cout << "Found contours: " << contours.size() << std::endl;
    for (auto it = contours.cbegin(), iend = contours.cend(); it != iend; ++it) {
        cv::Scalar color(255);
        cv::drawContours(img_contours, contours, it - contours.cbegin(), color, CV_FILLED);
    }
    cv::imshow("Accepted contours", img_contours);
    cv::waitKey();
#endif

    return Number();
}
Ejemplo n.º 26
0
std::vector<Number> ball_of_radius (float radius)
{
    std::vector<Number> result;
    for (int i = 1; i < radius; ++i) {
        for (int j = 1; i * i + j * j <= radius * radius; ++j) {
            if (gcd(i, j) == 1) {
                result.push_back(Number(i, j));
            }
        }
    }
    std::sort(result.begin(), result.end());
    return result;
}
Ejemplo n.º 27
0
/*------------------------------------------------------------------------*
 * 8近傍のラベリング。できあがりはushort型
 *------------------------------------------------------------------------*/
long image__N8_labelling_ushort(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("N8_labelling_ushort",
				   original,
				   Number(N8_ushort_table),
				   N8_ushort_table);

  if (caller) return caller(label,original);

  return 0;
}
Ejemplo n.º 28
0
/*------------------------------------------------------------------------*
 * 8近傍のラベリング。できあがりはlong型
 *------------------------------------------------------------------------*/
long image__N8_labelling_foreground_long(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("image__N8_labelling_foreground_long",
				   original,
				   Number(N8FG_long_table),
				   N8FG_long_table);

  if (caller) return caller(label,original);

  return 0;
}
Ejemplo n.º 29
0
static thing_th *inner_funky_length(thing_th *args) {
    unsigned long len=0;
    char *num;
    thing_th *outcome;
    while(args && (Cdr(args) || Car(args))) {
        ++len;
        args=Cdr(args);
    }
    asprintf(&num, "%ld", len);
    outcome=Number(num);
    erase_string(num);
    return outcome;
}
Ejemplo n.º 30
0
/*------------------------------------------------------------------------*
 * 4近傍のラベリング。できあがりはushort型
 *------------------------------------------------------------------------*/
long image__N4_labelling_foreground_ushort(image label, image original)
{
  f_caller caller;

  caller = (f_caller)image__caller("image__N4_labelling_foreground_ushort",
				   original,
				   Number(N4FG_ushort_table),
				   N4FG_ushort_table);

  if (caller) return caller(label,original);

  return 0;
}