Example #1
0
void
outflush(void)
{
    if(outmsg == outdata)
        return;
    noflush = 0;
    outT0(Hack);
    waitack = 1;
    do
        if(rcv() == 0) {
            rescue();
            exits("eof");
        }
    while(waitack);
    outmsg = outdata;
    noflush = 1;
}
Example #2
0
File: mesg.c Project: rennis250/sam
void
outflush(void)
{
	if(outmsg == outdata)
		return;
	outbuffered = 0;
	/* flow control */
	outT0(Hack);
	waitack = 1;
	do
		if(rcv() == 0){
			rescue();
			exits("eof");
		}
	while(waitack);
	outmsg = outdata;
	outbuffered = 1;
}
Example #3
0
File: ed.c Project: Earnestly/plan9
void
notifyf(void *a, char *s)
{
	if(strcmp(s, "interrupt") == 0){
		if(rescuing || waiting)
			noted(NCONT);
		putchr(L'\n');
		lastc = '\n';
		error1(Q);
		notejmp(a, savej, 0);
	}
	if(strcmp(s, "hangup") == 0){
		if(rescuing)
			noted(NDFLT);
		rescue();
	}
	fprint(2, "ed: note: %s\n", s);
	abort();
}
Example #4
0
File: mesg.c Project: rennis250/sam
void
outsend(void)
{
	int outcount;

	if(outp >= outdata+nelem(outdata))
		panic("outsend");
	outcount = outp-outmsg;
	outcount -= 3;
	outmsg[1] = outcount;
	outmsg[2] = outcount>>8;
	outmsg = outp;
	if(!outbuffered){
		outcount = outmsg-outdata;
		if (write(1, (char*) outdata, outcount) != outcount)
			rescue();
		outmsg = outdata;
		return;
	}
}
Example #5
0
void
outsend(void)
{
    int outcount;

    outcount = outp-outmsg;
    outcount -= 3;
    outmsg[1] = outcount;
    outmsg[2] = outcount>>8;
    outmsg = outp;
    if(!noflush) {
        outcount = outmsg-outdata;
        if (write(1, (char*) outdata, outcount) != outcount)
            rescue();
        outmsg = outdata;
        return;
    }
    if(outmsg < outdata+DATASIZE)
        return;
    outflush();
}
Example #6
0
File: ed.c Project: 00001/plan9port
int
append(int (*f)(void), int *a)
{
	int *a1, *a2, *rdot, nline, d;

	nline = 0;
	dot = a;
	while((*f)() == 0) {
		if((dol-zero) >= nlall) {
			nlall += 512;
			a1 = realloc(zero, (nlall+50)*sizeof(int*));
			if(a1 == 0) {
				error("MEM?");
				rescue();
			}
			/* relocate pointers; avoid wraparound if sizeof(int) < sizeof(int*) */
			d = addr1 - zero;
			addr1 = a1 + d;
			d = addr2 - zero;
			addr2 = a1 + d;
			d = dol - zero;
			dol = a1 + d;
			d = dot - zero;
			dot = a1 + d;
			zero = a1;
		}
		d = putline();
		nline++;
		a1 = ++dol;
		a2 = a1+1;
		rdot = ++dot;
		while(a1 > rdot)
			*--a2 = *--a1;
		*rdot = d;
	}
	return nline;
}
Example #7
0
File: sam.c Project: deadpixi/sam
static void
hup(int sig)
{
    rescue();
    exit(EXIT_FAILURE);
}
Example #8
0
File: unix.c Project: 8l/sam
void
hup(int sig)
{
	rescue();
	exit(1);
}
Example #9
0
void Codebook::trainFromExamples(int codebook_size,vector< vector<double> >& accum)
{
    cv::Mat centriods;
    cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS,1000,.99);
    //      Mat data(accum.size(),accum[0].size(),CV_32F);
    //      for (int r=0; r< accum.size(); r++)
    //          for (int c=0; c<accum[0].size(); c++)
    //              data.at<float>(r,c) = accum[r][c];
    int examples_size = std::min( std::max(codebook_size*500, 100000), (int) accum.size());
    cv::Mat data(examples_size,accum[0].size(),CV_32F);

    cout << "selecting random set" << endl;
    cout << "really. accum is " << accum.size() << endl;
    for (int count=0; count< examples_size; count++)
    {
        int r=rand()%accum.size();
        int orig=r;
        while (accum[r].size()==0)
        {
            r = (1+r)%accum.size();
            if (r==orig)
            {
                cout << "ERROR: not enough descriptors" << endl;
                assert(false);
                exit(-1);
                //break;
            }
        }
        //if (r==orig) break;

        for (int c=0; c<data.cols; c++)
        {
            assert(accum[r][c] >= 0);
            data.at<float>(count,c) = accum[r][c];
        }
        accum[r].resize(0);
    }


    cout << "computing kmeans" << endl;

    vector<int> temp;
    cv::kmeans(data,codebook_size,temp,crit,7,cv::KMEANS_PP_CENTERS,centriods);

    //my_kmeans(data,codebook_size,centriods);
    if(centriods.rows != codebook_size)
    {
        cout << "Centriods is probably blank (not cb size), rescuing" << endl;
        //assert(temp.type() == cv::CV_64UI1);
        rescue(temp,data,codebook_size);
        return;
    }

    cout << "compiling codebook" << endl;

    for (int r=0; r<centriods.rows; r++)
    {
        vector<double> toAdd;
        for (int c=0; c<centriods.cols; c++)
        {
            if (centriods.at<float>(r,c) < -1)
            {
                cout << "Negative in centriods, rescuing" << endl;
                rescue(temp,data,codebook_size);
                return;
            }
            toAdd.push_back(centriods.at<float>(r,c));
        }
        codebook.push_back(toAdd);
    }

}