예제 #1
0
TEST(Recording_test, data_access)
{
    std::vector<Section> sec_list(16, Section(32768));
    Channel ch(sec_list);

    Recording rec1(ch);
    int chsize = rec1[0].size();
    int secsize = rec1[0][rec1[0].size()-1].size();
    EXPECT_EQ( rec1[0][chsize-1][secsize-1], 0 );
    EXPECT_THROW( rec1.at(1), std::out_of_range );
    EXPECT_THROW( rec1[0].at(chsize), std::out_of_range );
    EXPECT_THROW( rec1[0][chsize-1].at(secsize), std::out_of_range );

    std::vector<Channel> ch_list(4, Channel(16, 32768));
    Recording rec2(ch_list);
    int recsize = rec2.size();
    chsize = rec2[recsize-1].size();
    secsize = rec2[recsize-1][rec2[recsize-1].size()-1].size();
    EXPECT_EQ( rec2[recsize-1][chsize-1][secsize-1], 0 );
    EXPECT_THROW( rec2.at(recsize), std::out_of_range );
    EXPECT_THROW( rec2[recsize-1].at(chsize), std::out_of_range );
    EXPECT_THROW( rec2[recsize-1][chsize-1].at(secsize), std::out_of_range );

    Recording rec3(4, 16, 32768);
    recsize = rec3.size();
    chsize = rec3[recsize-1].size();
    secsize = rec3[recsize-1][rec3[recsize-1].size()-1].size();
    EXPECT_EQ( rec3[recsize-1][chsize-1][secsize-1], 0 );
    EXPECT_THROW( rec3.at(recsize), std::out_of_range );
    EXPECT_THROW( rec3[recsize-1].at(chsize), std::out_of_range );
    EXPECT_THROW( rec3[recsize-1][chsize-1].at(secsize), std::out_of_range );
}
예제 #2
0
void rec1 (int x) {
  if (x) {
    t = 3;
    rec1(0);
  } else
    t = 5;
}
int main(int argc, char** argv) {

    int numIterations;
    if (argc < 2 || sscanf (argv[1], "%i", &numIterations)!=1) {
        numIterations=TARGET_ITERATIONS;
    }

	for (int i = 0; i < numIterations; i++) {
		rec1();
	}
	return 0;
}
예제 #4
0
int main () {
  int a = 1;
  
  rec1(0);
  assert(t == 5);

  rec2(&a, 0);
  printf("a = %d\n", a);
  assert(a == 9);

  a = fact(6);
  assert(a == 720);

  return 0;
}
예제 #5
0
unsigned int zEndpointInfo::GetRecord(zRecord* zidRecord) // Get a ZID record from an open endpoint info file
{
	unsigned long pos;
	zRecord rec;
	int numRead;

	fseek(_EndpointInfoFileStream, rec._GetRecordLength(), SEEK_SET);

	do 
	{
		pos = ftell(_EndpointInfoFileStream);
		numRead = fread(rec._GetRecordData(), rec._GetRecordLength(), 1, _EndpointInfoFileStream);
		if (numRead == 0) 
		{
			break;
		}

		if (rec.IsOwnZIDRecord() || !rec._IsValid()) 
		{
			continue;
		}

	} while (numRead == 1 &&
		memcmp(zidRecord->GetIdentfr(), rec.GetIdentfr(), ZRECORD_IDENTIFIER_LENGTH) != 0);

	if (numRead == 0) 
	{
		zRecord rec1(zidRecord->GetIdentfr());
		rec1._SetValid();
		if (fwrite(rec1._GetRecordData(), rec1._GetRecordLength(), 1, _EndpointInfoFileStream) < 1)
			++errors;
		memcpy(zidRecord->_GetRecordData(), rec1._GetRecordData(), rec1._GetRecordLength());
	}
	else 
	{
		memcpy(zidRecord->_GetRecordData(), rec._GetRecordData(), rec._GetRecordLength());
	}

	zidRecord->_SetPosition(pos);
	return 1;
}
// draw background of widget window
void CodeMiniMap::drawBackground(QPainter *painter, const QRectF &rect)
{
    Q_UNUSED(rect);

	if (codepixmap != 0)
	{
		QPixmap pm = codepixmap->scaled(int(sceneRect().width()),int(sceneRect().height()*zoomlevel),Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
		painter->drawPixmap(sceneRect(),pm,QRectF(pm.rect()));
		
	}
	
	// draw upper rect
	QPointF intrect_top = m_intrect->mapToScene(m_intrect->boundingRect().topRight());
	intrect_top.setY( intrect_top.y() + 2 );
	QRectF rec1(this->mapToScene(this->rect().topLeft()),intrect_top);
	painter->fillRect(rec1,QBrush(QColor::fromRgbF(0, 0, 0, 0.5)));

	// draw lower rect
	QPointF intrect_bottom = m_intrect->mapToScene(m_intrect->boundingRect().bottomLeft());
	intrect_bottom.setY( intrect_bottom.y() - 2 );
	QRectF rec2(intrect_bottom,	this->mapToScene(this->rect().bottomRight()));
	painter->fillRect(rec2,QBrush(QColor::fromRgbF(0, 0, 0, 0.5)));
}
void LKTracker::normCrossCorrelation(const Mat& img1, const Mat& img2, vector<Point2f>& points1, vector<Point2f>& points2)
{
	Mat rec0(10, 10, CV_8U);
	Mat rec1(10, 10, CV_8U);
	Mat res(1, 1, CV_32F);

	//double maxDis = 3.0f * sqrt(window_size.width*window_size.width + window_size.height*window_size.height); // 过滤距离过远的光流
	similarity.clear();
	for (int i = 0; i < points1.size(); i++) {
		if (status[i] == 1 /*&& norm(points1[i] - points2[i]) < maxDis*/) {
			getRectSubPix(img1, Size(10, 10), points1[i], rec0);
			getRectSubPix(img2, Size(10, 10), points2[i], rec1);
			matchTemplate(rec0, rec1, res, CV_TM_CCOEFF_NORMED);
			similarity.push_back( ((float *)(res.data))[0] );
		}
		else {
			similarity.push_back(0.0);
		}
	}
	rec0.release();
	rec1.release();
	res.release();
}
예제 #8
0
TEST(Recording_test, constructors)
{
    Recording rec0;
    EXPECT_EQ( rec0.size(), 0 );

    std::vector<Section> sec_list(16, Section(32768));
    Channel ch(sec_list);

    Recording rec1(ch);
    EXPECT_EQ( rec1.size(), 1 );
    EXPECT_EQ( rec1[0].size(), 16 );
    EXPECT_EQ( rec1[0][0].size(), 32768 );

    std::vector<Channel> ch_list(4, Channel(16, 32768));
    Recording rec2(ch_list);
    EXPECT_EQ( rec2.size(), 4 );
    EXPECT_EQ( rec2[rec2.size()-1].size(), 16 );
    EXPECT_EQ( rec2[rec2.size()-1][rec2[rec2.size()-1].size()-1].size(), 32768 );

    Recording rec3(4, 16, 32768);
    EXPECT_EQ( rec3.size(), 4 );
    EXPECT_EQ( rec3[rec3.size()-1].size(), 16 );
    EXPECT_EQ( rec3[rec3.size()-1][rec3[rec3.size()-1].size()-1].size(), 32768 );
}
예제 #9
0
파일: call.c 프로젝트: Kwonsoo/p16_unroll
void rec(){
  rec1();
}
예제 #10
0
int main() {
    dump_compact(rec1(8));
}
int rec2(int j) {
  if(j <= 0)
    return 0;
  return rec1(rec2(j-1)) - 1;
}
int rec1(int i) {
  if(i <= 0)
    return 0;
  return rec1(rec1(rec1(i-2) - 1)) + 1;
}
int rec2(int j) {
  if(j <= 0)
    return 0;
  return rec2(rec1(j+1)) - 1;
}