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


C++ C1函数代码示例

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


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

示例1: SSL_library_init

splatclient::splatclient(string windowstyle,nCursesWindow *window, string ip, unsigned int port)
{
    //SSL stuff
    SSL_library_init();
    ERR_load_crypto_strings();
    ERR_load_SSL_strings();
    OpenSSL_add_all_algorithms();

//	init receive buffer
    recv_buff.iMessageid=recv_buff.tSize=0;
    memset(&(recv_buff.cMesg), '\0',CHUNK);


    sessionID=0;
    win=window;
    sockfd=-1;
    log= new cLogfile("splatclient.log",false);
    msgID=0;
    server_ip=ip;
    server_port=port;

//	vParseWindowstyle(windowstyle, window);
    if (!win)
    {
        sLogelement C1(-1, "Keine Windowfunktion übergeben", false);
        (*log)<<C1;
        exit(1);
    }
    sLogelement C1(0, "Splatclient erschaffen", true);
    (*log)<<C1;
    *win<<C1;
    if (!bConnect(port, ip))
    {
        win->windowstack.back()->nCgetwin().~nCursesWindow();
        exit(1);
    }
    else
    {
        sLogelement C1(-1, "Verbindung hergestellt", true);
        *win<<C1;
    }
    keypad(stdscr,true);
    nodelay(win->windowstack.back()->win, true);
    if (!iGetsocket())
    {
        sLogelement t1(-1,"No socket found!",false);//FATAL
        *win<<t1;
        win->windowstack.back()->nCgetwin().~nCursesWindow();
        (*log) << t1;
        exit(1);
    }
    //cFlow_client
    bkgactive=true; //still need to be active for ping/pong messages
    //MENU
    menu=NULL;
    vCreateMenu();
    bDirty=true;
}
开发者ID:airmack,项目名称:-SPLAT-hack,代码行数:58,代码来源:splatclient.cpp

示例2: foo

void foo(int coin) {
  C1 c1 = coin ? C1(1) : C1(2);
  if (coin) {
    clang_analyzer_eval(c1.getX() == 1); // expected-warning{{TRUE}}
  } else {
    clang_analyzer_eval(c1.getX() == 2); // expected-warning{{TRUE}}
  }
  C2 c2 = coin ? C2(3, 4) : C2(5, 6);
  if (coin) {
    clang_analyzer_eval(c2.getX() == 3); // expected-warning{{TRUE}}
    clang_analyzer_eval(c2.getY() == 4); // expected-warning{{TRUE}}
  } else {
    clang_analyzer_eval(c2.getX() == 5); // expected-warning{{TRUE}}
    clang_analyzer_eval(c2.getY() == 6); // expected-warning{{TRUE}}
  }
}
开发者ID:Teemperor,项目名称:clang,代码行数:16,代码来源:copy-elision.cpp

示例3: main

int main()
{
    C0().f0();
    
    C1().f0();
    C1().f1();
    
    C2().f0();
    C2().f1();
    C2().f2();
    
    C3().f0();
    C3().f1();
    C3().f2();
    C3().f3();
}
开发者ID:CCJY,项目名称:coliru,代码行数:16,代码来源:main.cpp

示例4: test_vector_add

int test_vector_add()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/74120057
	// Vector addition: C = A + B, implements element by element vector addition
	const int numElements{ 50000 };
	std::vector<float> A(numElements), B(numElements), C1(numElements), C2(numElements);

	// Initialize vector
	for (int i = 0; i < numElements; ++i) {
		A[i] = rand() / (float)RAND_MAX;
		B[i] = rand() / (float)RAND_MAX;
	}

	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds
	int ret = vector_add_cpu(A.data(), B.data(), C1.data(), numElements, &elapsed_time1);
	if (ret != 0) PRINT_ERROR_INFO(vectorAdd_cpu);

	ret = vector_add_gpu(A.data(), B.data(), C2.data(), numElements, &elapsed_time2);
	if (ret != 0) PRINT_ERROR_INFO(vectorAdd_gpu);

	for (int i = 0; i < numElements; ++i) {
		if (fabs(C1[i] - C2[i]) > EPS_) {
			fprintf(stderr, "Result verification failed at element %d!\n", i);
			return -1;
		}
	}

	fprintf(stderr, "cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	return 0;
}
开发者ID:fengbingchun,项目名称:CUDA_Test,代码行数:31,代码来源:funset.cpp

示例5: test_long_vector_add

int test_long_vector_add()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/75570546
	const int length{ 100000000 };
	std::unique_ptr<float[]> A(new float[length]);
	std::unique_ptr<float[]> B(new float[length]);
	std::unique_ptr<float[]> C1(new float[length]);
	std::unique_ptr<float[]> C2(new float[length]);

	generator_random_number(A.get(), length, -1000.f, 1000.f);
	generator_random_number(B.get(), length, -1000.f, 1000.f);

	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds
	int ret = long_vector_add_cpu(A.get(), B.get(), C1.get(), length, &elapsed_time1);
	if (ret != 0) PRINT_ERROR_INFO(long_vector_add_cpu);

	ret = long_vector_add_gpu(A.get(), B.get(), C2.get(), length, &elapsed_time2);
	if (ret != 0) PRINT_ERROR_INFO(matrix_mul_gpu);

	int count_error{ 0 };
	for (int i = 0; i < length; ++i) {
		if (count_error > 100) return -1;
		if (fabs(C1[i] - C2[i]) > EPS_) {
			fprintf(stderr, "Result verification failed at element %d, C1: %f, C2: %f\n",
				i, C1[i], C2[i]);
			++count_error;
		}
	}

	fprintf(stderr, "cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	return 0;
}
开发者ID:fengbingchun,项目名称:CUDA_Test,代码行数:33,代码来源:funset.cpp

示例6: ofSetFrameRate

//--------------------------------------------------------------
void ofApp::setup(){  
  ofSetFrameRate(60.0f);

  for(int i=0;i<12;i++)
  {
    randColorDrop();
  }
  Attractor.reset(new ColorDropAttractor());
  Merger.reset(new ColorDropMerger());
  Dragger.reset(new ColorDropDragger());
  
  ofPtr<ColorHole> H;
  ofFloatColor C0(ofFloatColor::yellow);
  C0.setBrightness(0.7f);
  H.reset(new ColorHole(
    ofVec2f(200,200),
    C0,2600));
  Holes.push_back(H);
  ofFloatColor C1(ofFloatColor::cyan);
  C1.setBrightness(0.7f);
  H.reset(new ColorHole(
    ofVec2f(750,240),
    ofFloatColor(0.8f,0.0f,0.8f,1),3000));
  Holes.push_back(H);
  ofFloatColor C2(ofFloatColor::violet);
  C2.setBrightness(0.7f);
  H.reset(new ColorHole(
    ofVec2f(450,500),
    ofFloatColor(0.0f,0.9f,0.9f,1),3800));
  Holes.push_back(H);
}
开发者ID:ChongChongS,项目名称:ColorMixer,代码行数:32,代码来源:ofApp.cpp

示例7: test_matrix_mul

int test_matrix_mul()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/76618165
	// Matrix multiplication: C = A * B
	// 矩阵A、B的宽、高应是32的整数倍
	const int rowsA{ 352 }, colsA{ 672 }, rowsB = colsA, colsB{ 384 };
	std::unique_ptr<float[]> A(new float[colsA*rowsA]);
	std::unique_ptr<float[]> B(new float[colsB*rowsB]);
	std::unique_ptr<float[]> C1(new float[rowsA*colsB]);
	std::unique_ptr<float[]> C2(new float[rowsA*colsB]);

	generator_random_number(A.get(), colsA*rowsA, -1.f, 1.f);
	generator_random_number(B.get(), colsB*rowsB, -1.f, 1.f);

	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds
	int ret = matrix_mul_cpu(A.get(), B.get(), C1.get(), colsA, rowsA, colsB, rowsB, &elapsed_time1);
	if (ret != 0) PRINT_ERROR_INFO(matrix_mul_cpu);

	ret = matrix_mul_gpu(A.get(), B.get(), C2.get(), colsA, rowsA, colsB, rowsB, &elapsed_time2);
	if (ret != 0) PRINT_ERROR_INFO(matrix_mul_gpu);

	int count{ 0 };
	for (int i = 0; i < rowsA*colsB; ++i) {
		if (count > 100) return -1;
		if (fabs(C1[i] - C2[i]) > EPS_) {
			fprintf(stderr, "Result verification failed at element %d, C1: %f, C2: %f\n",
				i, C1[i], C2[i]);
			++count;
		}
	}

	fprintf(stderr, "test matrix mul: cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	return 0;
}
开发者ID:fengbingchun,项目名称:CUDA_Test,代码行数:35,代码来源:funset.cpp

示例8: A

void graphics::NgoiLang(QPainter& painter,int x,int y,int c,int r)
{
    QPoint A(x-r/2,y+c);
    QPoint B(x+r/2,y+c);
    QPoint C(x+r/2,y+c/3);
    QPoint D(x,y);
    QPoint E(x-r/2,y+c/3);
    QPolygon poly1;
    poly1 << D << E << A << B << C;
    painter.drawPolygon(poly1);
// ve cai cua
    QPoint A1(x,y+c);
    QPoint B1(x,y+2*c/3);
    QPoint C1(x-r/4,y+2*c/3);
    QPoint D1(x-r/4,y+c);
    QPolygon poly2;
    poly2 << A1 << B1 << C1 << D1;
    painter.drawPolyline(poly2);
 // ve cua so
   QPoint A11(x-r/4,y+c/6);
    QPoint B11(x-r/4,y);
   QPoint C11(x-r/8,y);
    QPoint D11(x-r/8,y+c/12);
   QPolygon poly21;
    poly21 << A11 << B11 << C11 << D11;
    painter.drawPolygon(poly21);
    painter.drawRect(x+r/4,y+c/2.5,c/10,r/10);

}
开发者ID:xdien,项目名称:my_qtprojects,代码行数:29,代码来源:graphics.cpp

示例9: currentIndexChanged

void ViewmdaModel::setC1(int i) {
	if (m_d1<0) return;
	if (C1()==i) return;
	if ((i<0)||(i>=N1())) return;
	m_current_index[m_d1]=i;
	emit currentIndexChanged();	
} 
开发者ID:magland,项目名称:sequencetree5,代码行数:7,代码来源:viewmdamodel.cpp

示例10: sc_main

int sc_main (int argc , char *argv[]) 
{
#ifdef KASCPAR
 	veri_signal<bool> s1;
 	veri_signal<bool> s2;
 	veri_signal<bool> s3;
#else
	sc_core::sc_signal<bool> s1("s1"), s2("s2");//, s3("s3");
#endif

 	Component C1("C1");
 	Component C2("C2");
// 	Component C3("C3");
       
// 	//	superclass* C;
// 	//	C = dynamic_cast<superclass*>(&C3);
// 	//	superclass* S = C;
// 	//	Component* res = dynamic_cast<Component*>(S);

 	C1.out(s1);
 	C2.out(s2);
// 	//	(*res).out(s3);
// 	C3.out(s3);

 	C1.in(s2);
 	C2.in(s1);
// 	C3.in(s2);

// 	C1.isHead = true;

	//Run the Simulation for "200 nanosecnds"
	sc_start(200, SC_NS);

	return 0;
}
开发者ID:rgly,项目名称:pinavm,代码行数:35,代码来源:main.cpp

示例11: main

int main(int argc, char** argv){
	irqSet(IRQ_VBLANK, &vblank);

	#ifdef TEXTMODE
		videoSetMode(MODE_0_2D);
		videoSetModeSub(MODE_0_2D);

		vramSetBankA(VRAM_A_MAIN_BG);
		vramSetBankC(VRAM_C_SUB_BG);
	#endif//TEXTMODE

	Display::init();

	keysSetRepeat(30, 12);

	srand(time(NULL));

	Player P1(FGrave);
	Player P2(FMidori);

	ControlLocal	C1(P1);
	ControlAI		C2(P2);

	//DisplayPlayerOverview a(0, 0, 0, 32, 1, P1);
	//DisplayContainer b(0, 0, 1, 32, 21, P1.hand());

	//DisplayCard c(1, 0, 0, 32, 24, P1.hand().at(0), false);

	Game(&C1, &C2);

	while(1){
		update();
	}
	return 0;
}
开发者ID:nevilc,项目名称:YomiDS,代码行数:35,代码来源:main.cpp

示例12: SingleBenchmark

// Run a single benchmark for multiplying m x k x n with num_steps of recursion.
// To just call GEMM, set num_steps to zero.
// The median of five trials is printed to std::cout.
// If run_check is true, then it also
void SingleBenchmark(int m, int k, int n, int num_steps, int algorithm) {
  // Run a set number of trials and pick the median time.
  int num_trials = 1;
  std::vector<double> times(num_trials);
  for (int trial = 0; trial < num_trials; ++trial) {
    Matrix<double> A = RandomMatrix<double>(m, k);
    Matrix<double> B = RandomMatrix<double>(k, n);
    Matrix<double> C1(m, n);
    if (algorithm == SMIRNOV54) {
      times[trial] = square54_1::FastMatmul(A, B, C1, 3);
    } else if (algorithm == MKL) {
      times[trial] = strassen::FastMatmul(A, B, C1, 0);
    } else if (algorithm == STRASSEN) {
      times[trial] = strassen::FastMatmul(A, B, C1, num_steps);
    } else if (algorithm == SCHONHAGE333_21_117_APPROX) {
      times[trial] = schonhage333_21_117_approx::FastMatmul(A, B, C1, num_steps);
    }
  }

  // Spit out the median time
  std::sort(times.begin(), times.end());
  size_t ind = num_trials / 2;
  std::cout << " " << m << " " << k << " " << n << " "
            << num_steps << " " << times[ind] << " "
            << "; ";
}
开发者ID:arbenson,项目名称:fast-matmul,代码行数:30,代码来源:square54_benchmark.cpp

示例13: test_streams

int test_streams()
{
	// Blog: http://blog.csdn.net/fengbingchun/article/details/76532198
	const int length{ 1024 * 1024 * 20};
	std::unique_ptr<int[]> A(new int[length]);
	std::unique_ptr<int[]> B(new int[length]);
	std::unique_ptr<int[]> C1(new int[length]);
	std::unique_ptr<int[]> C2(new int[length]);

	generator_random_number<int>(A.get(), length, -100, 100);
	generator_random_number<int>(B.get(), length, -100, 100);
	std::for_each(C1.get(), C1.get() + length, [](int& n) {n = 0; });
	std::for_each(C2.get(), C2.get() + length, [](int& n) {n = 0; });

	float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds

	int ret = streams_cpu(A.get(), B.get(), C1.get(), length, &elapsed_time1);
	if (ret != 0) PRINT_ERROR_INFO(streams_cpu);

	ret = streams_gpu(A.get(), B.get(), C2.get(), length, &elapsed_time2);
	if (ret != 0) PRINT_ERROR_INFO(streams_gpu);

	for (int i = 0; i < length; ++i) {
		if (C1[i] != C2[i]) {
			fprintf(stderr, "their values are different at: %d, val1: %d, val2: %d\n",
				i, C1[i], C2[i]);
			return -1;
		}
	}

	fprintf(stderr, "test streams' usage: cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);

	return 0;
}
开发者ID:fengbingchun,项目名称:CUDA_Test,代码行数:34,代码来源:funset.cpp

示例14: intersectsRect

bool intersectsRect(Vector2 A, Vector2 B, double x, double y, double width, double height) {
    Vector2 C0(x, y);
    Vector2 D0(x + width, y);

    Vector2 C1(x + width, y);
    Vector2 D1(x + width, y + height);

    Vector2 C2(x + width, y + height);
    Vector2 D2(x, y + height);

    Vector2 C3(x, y + height);
    Vector2 D3(x, y);

    bool I0, I1, I2, I3;

    Vector2 buf;

    I0 = intersects(A, B, C0, D0, buf);
    I1 = intersects(A, B, C1, D1, buf);
    I2 = intersects(A, B, C2, D2, buf);
    I3 = intersects(A, B, C3, D3, buf);
    if(I0 || I1 || I2 || I3) {
        return false;
    }
    return true;
}
开发者ID:MichaelStevens,项目名称:VirtualBot,代码行数:26,代码来源:math.cpp

示例15: inter_sphere

void	inter_sphere(t_caster *caster, t_object *sphere)
{
  double	delt;
  double	a;
  double	b;
  double	c;

  init_temp_pos(caster, sphere);
  a = A1(caster->temp_vec.x, caster->temp_vec.y, caster->temp_vec.z);
  b = B1(caster->temp_vec.x, caster->temp_pos.x, caster->temp_vec.y,
	 caster->temp_pos.y, caster->temp_vec.z, caster->temp_pos.z);
  c = C1(sphere->data.radius, caster->temp_pos.x, caster->temp_pos.y
	 , caster->temp_pos.z);
  delt = (pow(b, 2.0) - 4.0 * (a * c));
  if (delt >= 0.0)
    {
      sphere->dist = get_nearest((- b - sqrt(delt)) / (2.0 * a),
				 (- b + sqrt(delt)) / (2.0 * a));
      if (sphere->dist > 0.0 && sphere->dist < caster->intersection.dist)
	{
	  caster->intersection.brightness = sphere->brightness;
	  init_intersection(caster, sphere);
	  rotate_caster(caster, sphere);
	}
    }
}
开发者ID:Sorikairo,项目名称:Raytracer,代码行数:26,代码来源:inter_object.c


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