Example #1
0
static double measure(void)
{
    long long i, iterations;
    int result;
    struct timeval start, stop;
    double elapsed;

    add1(0, 0);   /* prepare off-line */

    i = 0;
    iterations = 1000;
    result = gettimeofday(&start, NULL);
    assert(result == 0);

    while (1) {
        for (; i < iterations; i++) {
            add1(((int)i) & 0xaaaaaa, ((int)i) & 0x555555);
        }
        result = gettimeofday(&stop, NULL);
        assert(result == 0);

        elapsed = time_delta(&stop, &start);
        assert(elapsed >= 0.0);
        if (elapsed > 2.5)
            break;
        iterations = iterations * 3 / 2;
    }

    return elapsed / (double)iterations;
}
Example #2
0
int main(void)
{
    int x, y;
    x = add1(40, 2);
    y = add1(100, -5);
    printf("got: %d %d\n", x, y);
    return 0;
}
Example #3
0
int main(int argc, const char *argv[])
{
    int a,b,ad,su,mu,de,mo;
    char i;
    fun add1;//申请一个地址空间
    add1=add;//把函数add的入口地址赋给add1 

    fun subtract1;
    subtract1=subtract;
    
    fun multiply1;
    multiply1=multiply;

    fun dev1;
    dev1=dev;

    fun mod1;
    mod1=mod;
    while(1)
    {
    printf("Input a symbol:\n");
    scanf("%c",&i);
    if(i=='#') break;
        printf("Input num1:\n");
         scanf("%d",&a);
          printf("Input num2:\n");
          scanf("%d",&b);
          ad=add1(a,b);
          getchar();//因为输入完成之后要回车才能输入字符,程序会把回车当字符读入造成程序出乱,所以加上getchar()
    switch(i)
    {
        case '+':
          ad=add1(a,b);
          printf("%d + %d= %d\n",a,b,ad);
          break;
         
        case '-':
         su=subtract1(a,b);
          printf("%d - %d= %d\n",a,b,su);
          break;
        case '*':
          mu=multiply1(a,b);
          printf("%d * %d= %d\n",a,b,mu);
          break;
        case '/':
          de=dev1(a,b);
          printf("%d / %d= %d\n",a,b,de);
          break;
        case '%':
          mo=mod1(a,b);
          printf("%d %% %d= %d\n",a,b,mo);
          //打印%的时候 中间要加一个%分开 否则会出错误
          break;
    }

    }
    return 0;
}
Example #4
0
Word32 quant_2p_2N1(                       /* (o) return (2*N)+1 bits         */
		Word16 pos1,                          /* (i) position of the pulse 1     */
		Word16 pos2,                          /* (i) position of the pulse 2     */
		Word16 N)                             /* (i) number of bits for position */
{
	Word16 mask, tmp;
	Word32 index;
	mask = (1 << N) - 1;              /* mask = ((1<<N)-1); */
	/*-------------------------------------------------------*
	 * Quantization of 2 pulses with 2*N+1 bits:             *
	 // 2×n + 1位2脉冲量化
	 *-------------------------------------------------------*/
	if (((pos2 ^ pos1) & NB_POS) == 0)
	{
		/* sign of 1st pulse == sign of 2th pulse */
		// 标志第一脉冲= =第二签名脉冲
		if(pos1 <= pos2)          /* ((pos1 - pos2) <= 0) */
		{
			/* index = ((pos1 & mask) << N) + (pos2 & mask); */
			index = L_deposit_l(add1((((Word16) (pos1 & mask)) << N), ((Word16) (pos2 & mask))));
		} else
		{
			/* ((pos2 & mask) << N) + (pos1 & mask); */
			index = L_deposit_l(add1((((Word16) (pos2 & mask)) << N), ((Word16) (pos1 & mask))));
		}
		if ((pos1 & NB_POS) != 0)
		{
			tmp = (N << 1);
			index = vo_L_add(index, (1L << tmp));       /* index += 1 << (2*N); */
		}
	} else
	{
		/* sign of 1st pulse != sign of 2th pulse */
		// 第一脉冲信号!=第二脉冲信号
		if (vo_sub((Word16) (pos1 & mask), (Word16) (pos2 & mask)) <= 0)
		{
			/* index = ((pos2 & mask) << N) + (pos1 & mask); */
			index = L_deposit_l(add1((((Word16) (pos2 & mask)) << N), ((Word16) (pos1 & mask))));
			if ((pos2 & NB_POS) != 0)
			{
				tmp = (N << 1);           /* index += 1 << (2*N); */
				index = vo_L_add(index, (1L << tmp));
			}
		} else
		{
			/* index = ((pos1 & mask) << N) + (pos2 & mask);	 */
			index = L_deposit_l(add1((((Word16) (pos1 & mask)) << N), ((Word16) (pos2 & mask))));
			if ((pos1 & NB_POS) != 0)
			{
				tmp = (N << 1);
				index = vo_L_add(index, (1 << tmp));    /* index += 1 << (2*N); */
			}
		}
	}
	return (index);
}
Example #5
0
static void *pgsql_open_conn(const DBConf *db_conf)
{
    PGconn *conn = NULL;
    PgSQLConf *conf = db_conf->pgsql; /* make compiler happy */
    Octstr *tmp, *cs;

    /* sanity check */
    if (conf == NULL)
        return NULL;

    cs = octstr_create("");
    add1(" host=%S", conf->host);
    /* TODO: add hostaddr support via 'host' directive too.
     * This needs an octstr_is_addr(Octstr *os) checking if a given string
     * contains a valid IPv4 address. Obviously parsing on our own via gwlib
     * functions or using regex. If found, insert hostaddr instead of host
     * for the connection string. */
    /* add1(" hostaddr=%S", conf->host); */
    if (conf->port > 0) {   /* add only if user set a value */
        octstr_append_cstr(cs, " port=");    
        octstr_append_decimal(cs, conf->port);
    }
    add1(" user=%S", conf->username);
    add1(" password=%S", conf->password);
    add1(" dbname=%S", conf->database);

#if 0
    /* TODO: This is very bad to show password in the log file */
    info(0, "PGSQL: Using connection string: %s.", octstr_get_cstr(cs));
#endif

    conn = PQconnectdb(octstr_get_cstr(cs));

    octstr_destroy(cs);
    if (conn == NULL)
        goto failed;

    gw_assert(conn != NULL);

    if (PQstatus(conn) == CONNECTION_BAD) {
        error(0, "PGSQL: connection to database '%s' failed!", octstr_get_cstr(conf->database)); 
        panic(0, "PGSQL: %s", PQerrorMessage(conn));
        goto failed;
    }

    info(0, "PGSQL: Connected to server at '%s'.", octstr_get_cstr(conf->host));

    return conn;

failed:
    PQfinish(conn);
    return NULL;
}
Example #6
0
void push_down(int l, int r, int rt)
{
    if (w[rt] == -1)
    {
        multi[rt<<1] = multi[rt<<1] * multi[rt] % M;
        multi[rt<<1|1] = multi[rt<<1|1] * multi[rt] % M;
        add[rt<<1] = (add[rt<<1] * multi[rt] + add[rt]) % M;
        add[rt<<1|1] = (add[rt<<1|1] * multi[rt] + add[rt]) % M;
        if (w[rt<<1] != -1) w[rt<<1] = (w[rt<<1] * multi[rt] + add[rt]) % M;
        if (w[rt<<1|1] != -1) w[rt<<1|1] = (w[rt<<1|1] * multi[rt] + add[rt]) % M;
        mul(rt<<1, multi[rt]);
        mul(rt<<1|1, multi[rt]);
        int mid = (l + r) >> 1;
        add1(l, mid, rt<<1, add[rt]);
        add1(mid+1, r, rt<<1|1, add[rt]);
    }
Example #7
0
calc::calc(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

    setFixedSize(sizeHint());

    clearall();

    connect (Button1,SIGNAL(clicked()),this,SLOT(add1()));
    connect (Button2,SIGNAL(clicked()),this,SLOT(add2()));
    connect (Button3,SIGNAL(clicked()),this,SLOT(add3()));
    connect (Button4,SIGNAL(clicked()),this,SLOT(add4()));
    connect (Button5,SIGNAL(clicked()),this,SLOT(add5()));
    connect (Button6,SIGNAL(clicked()),this,SLOT(add6()));
    connect (Button7,SIGNAL(clicked()),this,SLOT(add7()));
    connect (Button8,SIGNAL(clicked()),this,SLOT(add8()));
    connect (Button9,SIGNAL(clicked()),this,SLOT(add9()));
    connect (Button0,SIGNAL(clicked()),this,SLOT(add0()));
    connect (backButton,SIGNAL(clicked()),this,SLOT(delnum()));
    connect (pointButton,SIGNAL(clicked()),this,SLOT(insertpoint()));
    connect (plusButton,SIGNAL(clicked()),this,SLOT(plus()));
    connect (minusButton,SIGNAL(clicked()),this,SLOT(minus()));
    connect (multiplyButton,SIGNAL(clicked()),this,SLOT(multiply()));
    connect (divideButton,SIGNAL(clicked()),this,SLOT(divide()));
    connect (equalButton,SIGNAL(clicked()),this,SLOT(equal()));
    connect (CButton,SIGNAL(clicked()),this,SLOT(clearall()));
    connect (actionAbout_Qt,SIGNAL(triggered()),this,SLOT(about()));
    connect (actionExit,SIGNAL(triggered()),this,SLOT(close()));
    connect (pmButton,SIGNAL(clicked()),this,SLOT(togglepm()));
}
Example #8
0
int main(void)
{
	printf("add1(%d) = %d\n",7,add1(7));
	printf("sub1(%d) = %d\n",7,sub1(7));
	printf(
return 0;
}
int main(){
	int i,a,b,t;
	char s[5];
	for(i=0;i<30000;i++)h1[i]=i+1;
	while(scanf("%d %s",&a,s)!=EOF){
		while(l2>0&&m[h2[0]]<a){
			t=get2();
			m[t]=0;
			add1(t);
		}
		if(s[0]=='+'){
			t=get1();
			printf("%d\n",t);
			m[t]=a+599;
			add2(t);
		}else{
			scanf("%d",&b);
			if(m[b]==0)printf("-\n");
			else{
				printf("+\n");
				m[b]=a+599;
				adj2(b);
			}
		}
	}
	return 0;
}
Example #10
0
int main() {
    int i, n =0 ;
    add1(50);
    for (i = 1; i <= 50; i++)
        n += i;
    printf("The sum of 1-50 is %d \n", n);
}
Example #11
0
int main()
{
    Num num,square;
    int n,i;
    FILE *fp = fopen("palsquare.in","r");
#ifdef DEBUG
    FILE *debug = fopen("palsquare.tmp","w");
#endif
    fscanf(fp,"%d",&n);
    fclose(fp);
    
    fp = fopen("palsquare.out","w");
    for(i = 0;i < LENGTH;i++)
    {
          num.num[i] = '0';
          square.num[i] = '0';
    }
    for(i = 1;i <= M;i++)
    {
          add1(&num,n);
          square = Square(num,n);
#ifdef DEBUG
    PrintNum(debug,num,square);
#endif
          if(IsPalindrom(square))
                 PrintNum(fp,num,square);
    }
#ifdef DEBUG

#endif
    fclose(fp);
    return 0;
}
// address: 0x104f4
int main(int argc, char *argv[], char *envp[]) {
    int o0; 		// r8

    __isoc99_scanf();
    o0 = add1(34);
    printf("Sum = %ld\n", o0);
    return 0;
}
main()
{
	char num1[1000]={"127834"}, num2[1000]={"57987674"};
	int num=atoi(num1);
	int num3=atoi(num2);
	add1(num,num3);
	//calling the functions
}
int callee()
{ 
  int t1 = 3;
  int result = add1(t1);  
  result = result - t1;
  
  return result;
}
Example #15
0
void  scopePlot::plotData(unsigned int size,
                          double * dData1, QString curve1Name, QString yLLabel,
                          double * dData2, QString curve2Name, QString yRLabel)
{	
  add1(dData1,size,curve1Name,yLLabel);
  add3(dData2,size,curve2Name,yRLabel);
  show();
}
Example #16
0
int main (void) {
	int i;
   int a[10];
	for(i=0;i<10;i++)
	a[i]=i+1;
   printf("%d\n", add1(a,10));
   return 0;
}
Example #17
0
SearchNotesWidget::SearchNotesWidget(NoteManager & m)
  : m_accel_group(Gtk::AccelGroup::create())
  , m_no_matches_box(NULL)
  , m_manager(m)
  , m_clickX(0), m_clickY(0)
  , m_matches_column(NULL)
  , m_note_list_context_menu(NULL)
  , m_notebook_list_context_menu(NULL)
  , m_initial_position_restored(false)
  , m_sort_column_id(2)
  , m_sort_column_order(Gtk::SORT_DESCENDING)
{
  set_hexpand(true);
  set_vexpand(true);
  make_actions();

  // Notebooks Pane
  Gtk::Widget *notebooksPane = Gtk::manage(make_notebooks_pane());
  notebooksPane->show();

  set_position(150);
  add1(*notebooksPane);
  add2(m_matches_window);

  make_recent_tree();
  m_tree = manage(m_tree);
  m_tree->set_enable_search(false);
  m_tree->show();

  update_results();

  m_matches_window.property_hscrollbar_policy() = Gtk::POLICY_AUTOMATIC;
  m_matches_window.property_vscrollbar_policy() = Gtk::POLICY_AUTOMATIC;
  m_matches_window.add(*m_tree);
  m_matches_window.show();

  // Update on changes to notes
  m.signal_note_deleted.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_deleted));
  m.signal_note_added.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_added));
  m.signal_note_renamed.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_renamed));
  m.signal_note_saved.connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_saved));

  // Watch when notes are added to notebooks so the search
  // results will be updated immediately instead of waiting
  // until the note's queue_save () kicks in.
  notebooks::NotebookManager::obj().signal_note_added_to_notebook()
    .connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_added_to_notebook));
  notebooks::NotebookManager::obj().signal_note_removed_from_notebook()
    .connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_removed_from_notebook));
  notebooks::NotebookManager::obj().signal_note_pin_status_changed
    .connect(sigc::mem_fun(*this, &SearchNotesWidget::on_note_pin_status_changed));

  Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
  settings->signal_changed().connect(sigc::mem_fun(*this, &SearchNotesWidget::on_settings_changed));
  parse_sorting_setting(settings->get_string(Preferences::SEARCH_SORTING));
  settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
  settings->signal_changed().connect(sigc::mem_fun(*this, &SearchNotesWidget::on_settings_changed));
}
int main()
{
     /*#TS*/
     makeView("mainView", "wholeGraph","Higraph.PDV", "PlacedNode");
     setTitle("mainView", "Matrices PDV");
     setDefaultNodeValueShow(true, CENTER);
     setDefaultNodeValueColor(MARKER_RED);
     setDefaultNodeShape(RECTANGLE);
	 //ScriptManager::relay("HigraphManager", "setDefaultZoneColor", BLUE);
     ScriptManager::relay("HigraphManager", "setDefaultNodeFillColor", WHITE);
     ScriptManager::relay("HigraphManager", "setDefaultNodeValueShow", true, CENTER);
     ScriptManager::relay("HigraphManager", "setDefaultNodeValueColor", BLACK);
     ScriptManager::relay("HigraphManager", "setDefaultNodeNameShow", true, WEST);
     ScriptManager::relay("HigraphManager", "setDefaultNodeNameColor", MAGENTA);
	 ScriptManager::relay("HigraphManager", "setDefaultNodeShape", RECTANGLE);
	 ScriptManager::relay("HigraphManager","setDefaultNodeSize", 40, 40);
       
     /*#/TS*/
     const int rows = 2;
     const int cols = 3;
	 int val = 10;/*#TS*/ setupval(val);
	 /*#/TS*/
     
     int matrix[rows*cols];
     /*#TS*/makeArray(matrix,(rows*cols),true,"matrix[]");/*#/TS*/
	 int i,j;/*#TS*//*nodes for i & j*/setup_i_j(i,j);/*#/TS*/
	 
	 /*#TS*/int **mat = new int*[rows];
     for(int k=0;k<rows;k++)
        mat[k]=new int[cols];
     makeMatrix(mat,rows,cols,true,"Theoretical representation");/*#/TS*/
	 
     for(i = 0; i < rows; i++)
     {
        for(j = 0; j < cols; j++)
            {	/*#TS*/ScriptManager::relay("HigraphManager","setNodeFillColor", mat[i][j], YELLOW);
					ScriptManager::relay("HigraphManager","setNodeFillColor", matrix[(i*cols)+j], YELLOW);/*#/TS*/
				/*#TS*/	mat[i][j]=val;/*#/TS*/
                matrix[(i*cols)+j]=val++;
				/*#TS*/ScriptManager::relay("HigraphManager","setNodeFillColor", mat[i][j], WHITE);
					ScriptManager::relay("HigraphManager","setNodeFillColor", matrix[(i*cols)+j], WHITE);/*#/TS*/
			}
     }
	 
	 //Call module to add 1 to each element of matrix
	
	 add1(matrix, rows, cols);
	 
	 
	 
	 //See that the values of the original matrix have changed
     
     /*#TS*/
	 //ScriptManager::relay("HigraphManager","setNodeNameLabel",matrix,"matrix[]");
     /*#/TS*/
     return 0;
}
Example #19
0
int main(int argc, char* argv[]) {
    std::cout << "Hello World!!\n";

    int x = 20;
    int y = 40;

    std::cout << x << " + " << y << " = " << add1(x, y) << "\n";
    return 0; 
}
// address: 0x804849d
int main(int argc, char *argv[], char *envp[]) {
    __size32 eax; 		// r24
    __size32 local0; 		// m[esp - 12]

    __isoc99_scanf();
    eax = add1(local0);
    printf("Sum = %ld\n", eax);
    return 0;
}
// address: 0x104f4
int main(int argc, char *argv[], char *envp[]) {
    float f0; 		// r32
    __size32 local0; 		// m[o6 - 8]

    __isoc99_scanf();
    f0 = add1(local0);
    printf("Sum = %ld\n", f0);
    return 0;
}
// address: 0x104f4
int main(int argc, char *argv[], char *envp[]) {
    __size32 local0; 		// m[o6 - 8]
    int o0; 		// r8

    __isoc99_scanf();
    o0 = add1(local0);
    printf("Sum = %ld\n", o0);
    return 0;
}
Example #23
0
//ham main
int main() 
{ 
   init1(); 
   add1();
   add2();
   system("clear");
   menu();
   btcls(bt1);
   btcls(bt2);
} 
Example #24
0
int main(int argc, char **argv)
{
int a;
a=3;
while (a < 20)
    {
    printf("a is %d\n",a);
    add1(a);
    }
}
Example #25
0
void
debugee_fileactions_addclose(void* p,int fd){
    actionptr* x;
    int o;
    add1(p);
    x = *(actionptr **)p;
    o = x->count-1;
    x->act[o].act = ACT_CLOSE;
    x->act[o].param1 = fd;
}
Example #26
0
int main()
{
	int a[]={9,9,9},i;
	struct Node *start=NULL;
	for(i=0;i<3;i++)
	{
		add(a[i],&start);
	}
	printList(add1(start));
	return 0;
}
Example #27
0
File: bntseq.c Project: a113n/bwa
int64_t bns_fasta2bntseq(gzFile fp_fa, const char *prefix, int for_only)
{
	extern void seq_reverse(int len, ubyte_t *seq, int is_comp); // in bwaseqio.c
	kseq_t *seq;
	char name[1024];
	bntseq_t *bns;
	uint8_t *pac = 0;
	int32_t m_seqs, m_holes;
	int64_t ret = -1, m_pac, l;
	bntamb1_t *q;
	FILE *fp;

	// initialization
	seq = kseq_init(fp_fa);
	bns = (bntseq_t*)calloc(1, sizeof(bntseq_t));
	bns->seed = 11; // fixed seed for random generator
	srand48(bns->seed);
	m_seqs = m_holes = 8; m_pac = 0x10000;
	bns->anns = (bntann1_t*)calloc(m_seqs, sizeof(bntann1_t));
	bns->ambs = (bntamb1_t*)calloc(m_holes, sizeof(bntamb1_t));
	pac = calloc(m_pac/4, 1);
	q = bns->ambs;
	strcpy(name, prefix); strcat(name, ".pac");
	fp = xopen(name, "wb");
	// read sequences
	while (kseq_read(seq) >= 0) pac = add1(seq, bns, pac, &m_pac, &m_seqs, &m_holes, &q);
	if (!for_only) { // add the reverse complemented sequence
		m_pac = (bns->l_pac * 2 + 3) / 4 * 4;
		pac = realloc(pac, m_pac/4);
		memset(pac + (bns->l_pac+3)/4, 0, (m_pac - (bns->l_pac+3)/4*4) / 4);
		for (l = bns->l_pac - 1; l >= 0; --l, ++bns->l_pac)
			_set_pac(pac, bns->l_pac, 3-_get_pac(pac, l));
	}
	ret = bns->l_pac;
	{ // finalize .pac file
		ubyte_t ct;
		err_fwrite(pac, 1, (bns->l_pac>>2) + ((bns->l_pac&3) == 0? 0 : 1), fp);
		// the following codes make the pac file size always (l_pac/4+1+1)
		if (bns->l_pac % 4 == 0) {
			ct = 0;
			err_fwrite(&ct, 1, 1, fp);
		}
		ct = bns->l_pac % 4;
		err_fwrite(&ct, 1, 1, fp);
		// close .pac file
		err_fflush(fp);
		err_fclose(fp);
	}
	bns_dump(bns, prefix);
	bns_destroy(bns);
	kseq_destroy(seq);
	free(pac);
	return ret;
}
int main()
{
   int n;
   long result;
   scanf("%d", &n);
   result = add1(n);
 
   printf("Sum = %ld\n", result);
 
   return 0;
}
Example #29
0
void
debugee_fileactions_adddup2(void* p,int fd0,int fd1){
    actionptr* x;
    int o;
    add1(p);
    x = *(actionptr **)p;
    o = x->count-1;
    x->act[o].act = ACT_DUP2;
    x->act[o].param1 = fd0;
    x->act[o].param2 = fd1;
}
Example #30
0
int main() {
	int x=50 ;

	printf("x = %d\n", x);
	printf("&x = %p\n", &x);

	add1(&x);

	printf("x = %d\n", x);
	printf("&x = %p\n", &x);

	return 0;
}