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


C++ COUNT函数代码示例

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


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

示例1: wcscpy_s

 //-------------------------------------------------------------------------
 void Settings::SetPath( const WCHAR* path )
 {
     wcscpy_s( _path, COUNT(_path), path );
 }
开发者ID:jamesbascle,项目名称:YoloMouse,代码行数:5,代码来源:Settings.cpp

示例2: new_net


//.........这里部分代码省略.........
		"San Joaquín",
		"Polanco",
		"Auditorio",
		"Constituyentes",				/* 95 */
		"San Pedro de los Pinos",
		"San Antonio",
		"Mixcoac",
		"Barranca del Muerto",
		"Garibaldi", 					/* 100 */
		"San Juan de Letrán",
		"Doctores",
		"Obrera",
		"La Viga",
		"Coyuya",						/* 105 */
		"Iztacalco",
		"Apatlaco",
		"Aculco",
		"Escuadrón 201",
		"Atlalilco",					/* 110 */
		"Iztapalapa",
		"Cerro de la Estrella",
		"UAM-I",
		"Constitución de 1917",
		"Patriotismo",					/* 115 */
		"Chilpancingo",
		"Lázaro Cárdenas",
		"Mixiuhca",
		"Velódromo",
		"Ciudad Deportiva",				/* 120 */
		"Puebla",
		"Agricola Oriental",
		"Canal de San Juan",
		"Tepalcates",
		"Guelatao",						/* 125 */
		"Peñon Viejo",
		"Acatitla",
		"Santa Marta",
		"Los Reyes",
		"La Paz",						/* 130 */
		"Ciudad Azteca",
		"Plaza Aragón",
		"Olimpica",
		"Ecatepec",
		"Múzquiz",						/* 135 */
		"Río de los Remedios",
		"Impulsora",
		"Nezahualcóyotl",
		"Villa de Aragón",
		"Bosque de Aragón",				/* 140 */
		"Deportivo Oceanía",
		"Romero Rubio",
		"R. Flores Magón",
		"Tepito",
		"Lagunilla",					/* 145 */
		"Buenavista"
	};

	int l_1[] = {
		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
		17, 18, 19
	};
	int l_2[] = {
		20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 10, 33, 34,
		35, 36, 37, 38, 39, 40, 41, 42
	};
	int l_3[] = {
		43, 44, 45, 46, 47, 48, 29, 49, 7, 50, 51, 52, 53, 54, 55, 56, 57, 58,
		59, 60, 61
	};
	int l_4[] = { 62, 63, 64, 65, 66, 67, 12, 68, 69, 70 };
	int l_5[] = { 19, 71, 72, 73, 74, 75, 65, 76, 77, 46, 78, 79, 80 };
	int l_6[] = { 81, 82, 83, 84, 85, 86, 79, 87, 44, 88, 62 };
	int l_7[] = { 81, 89, 90, 91, 22, 92, 93, 94, 95, 1, 96, 97, 98, 99};
	int l_8[] = {
		100, 30, 101, 8, 102, 103, 34, 104, 70, 105, 106, 107, 108, 109,
		110, 111, 112, 113, 114
	};
	int l_9[] = { 1, 115, 116, 52, 117, 34, 69, 118, 119, 120, 121, 19 };
	int l_a[] = { 19, 122, 123, 124, 125, 126, 127, 128,129, 130 };
	int l_b[] = {
		131, 132, 133, 134 ,135, 136, 137, 138, 139, 140, 141,
		73, 142, 143, 13, 67, 144, 145, 100, 48, 146
	};

	n = new_net(COUNT(stations), 11);
	net_create_stations(n, stations);
	net_create_line(n, "1", l_1, COUNT(l_1), 18660);
	net_create_line(n, "2", l_2, COUNT(l_2), 23431);
	net_create_line(n, "3", l_3, COUNT(l_3), 23609);
	net_create_line(n, "4", l_4, COUNT(l_4), 10747);
	net_create_line(n, "5", l_5, COUNT(l_5), 15675);
	net_create_line(n, "6", l_6, COUNT(l_6), 13947);
	net_create_line(n, "7", l_7, COUNT(l_7), 18784);
	net_create_line(n, "8", l_8, COUNT(l_8), 20078);
	net_create_line(n, "9", l_9, COUNT(l_9), 15375);
	net_create_line(n, "A", l_a, COUNT(l_a), 17192);
	net_create_line(n, "B", l_b, COUNT(l_b), 23722);

	return n;
}
开发者ID:seorc,项目名称:metro-mx,代码行数:101,代码来源:metro.c

示例3: main

int main(int argc, char **argv)
{
    long count;
    static unsigned char buf[BUFSIZE];
    static unsigned char key[] = {
        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
        0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
    };
    RC5_32_KEY sch;
    double a, b, c, d;
#ifndef SIGALRM
    long ca, cb, cc;
#endif

#ifndef TIMES
    printf("To get the most accurate results, try to run this\n");
    printf("program when this computer is idle.\n");
#endif

#ifndef SIGALRM
    printf("First we calculate the approximate speed ...\n");
    RC5_32_set_key(&sch, 16, key, 12);
    count = 10;
    do {
        long i;
        RC5_32_INT data[2];

        count *= 2;
        Time_F(START);
        for (i = count; i; i--)
            RC5_32_encrypt(data, &sch);
        d = Time_F(STOP);
    } while (d < 3.0);
    ca = count / 512;
    cb = count;
    cc = count * 8 / BUFSIZE + 1;
    printf("Doing RC5_32_set_key %ld times\n", ca);
# define COND(d) (count != (d))
# define COUNT(d) (d)
#else
# define COND(c) (run)
# define COUNT(d) (count)
    signal(SIGALRM, sig_done);
    printf("Doing RC5_32_set_key for 10 seconds\n");
    alarm(10);
#endif

    Time_F(START);
    for (count = 0, run = 1; COND(ca); count += 4) {
        RC5_32_set_key(&sch, 16, key, 12);
        RC5_32_set_key(&sch, 16, key, 12);
        RC5_32_set_key(&sch, 16, key, 12);
        RC5_32_set_key(&sch, 16, key, 12);
    }
    d = Time_F(STOP);
    printf("%ld RC5_32_set_key's in %.2f seconds\n", count, d);
    a = ((double)COUNT(ca)) / d;

#ifdef SIGALRM
    printf("Doing RC5_32_encrypt's for 10 seconds\n");
    alarm(10);
#else
    printf("Doing RC5_32_encrypt %ld times\n", cb);
#endif
    Time_F(START);
    for (count = 0, run = 1; COND(cb); count += 4) {
        RC5_32_INT data[2];

        RC5_32_encrypt(data, &sch);
        RC5_32_encrypt(data, &sch);
        RC5_32_encrypt(data, &sch);
        RC5_32_encrypt(data, &sch);
    }
    d = Time_F(STOP);
    printf("%ld RC5_32_encrypt's in %.2f second\n", count, d);
    b = ((double)COUNT(cb) * 8) / d;

#ifdef SIGALRM
    printf("Doing RC5_32_cbc_encrypt on %ld byte blocks for 10 seconds\n",
           BUFSIZE);
    alarm(10);
#else
    printf("Doing RC5_32_cbc_encrypt %ld times on %ld byte blocks\n", cc,
           BUFSIZE);
#endif
    Time_F(START);
    for (count = 0, run = 1; COND(cc); count++)
        RC5_32_cbc_encrypt(buf, buf, BUFSIZE, &sch, &(key[0]), RC5_ENCRYPT);
    d = Time_F(STOP);
    printf("%ld RC5_32_cbc_encrypt's of %ld byte blocks in %.2f second\n",
           count, BUFSIZE, d);
    c = ((double)COUNT(cc) * BUFSIZE) / d;

    printf("RC5_32/12/16 set_key       per sec = %12.2f (%9.3fuS)\n", a,
           1.0e6 / a);
    printf("RC5_32/12/16 raw ecb bytes per sec = %12.2f (%9.3fuS)\n", b,
           8.0e6 / b);
    printf("RC5_32/12/16 cbc     bytes per sec = %12.2f (%9.3fuS)\n", c,
           8.0e6 / c);
    exit(0);
//.........这里部分代码省略.........
开发者ID:Henauxg,项目名称:minix,代码行数:101,代码来源:rc5speed.c

示例4: cec_add_elem

int cec_add_elem(u64 pfn)
{
	struct ce_array *ca = &ce_arr;
	unsigned int to;
	int count, ret = 0;

	/*
	 * We can be called very early on the identify_cpu() path where we are
	 * not initialized yet. We ignore the error for simplicity.
	 */
	if (!ce_arr.array || ce_arr.disabled)
		return -ENODEV;

	ca->ces_entered++;

	mutex_lock(&ce_mutex);

	if (ca->n == MAX_ELEMS)
		WARN_ON(!del_lru_elem_unlocked(ca));

	ret = find_elem(ca, pfn, &to);
	if (ret < 0) {
		/*
		 * Shift range [to-end] to make room for one more element.
		 */
		memmove((void *)&ca->array[to + 1],
			(void *)&ca->array[to],
			(ca->n - to) * sizeof(u64));

		ca->array[to] = (pfn << PAGE_SHIFT) |
				(DECAY_MASK << COUNT_BITS) | 1;

		ca->n++;

		ret = 0;

		goto decay;
	}

	count = COUNT(ca->array[to]);

	if (count < count_threshold) {
		ca->array[to] |= (DECAY_MASK << COUNT_BITS);
		ca->array[to]++;

		ret = 0;
	} else {
		u64 pfn = ca->array[to] >> PAGE_SHIFT;

		if (!pfn_valid(pfn)) {
			pr_warn("CEC: Invalid pfn: 0x%llx\n", pfn);
		} else {
			/* We have reached max count for this page, soft-offline it. */
			pr_err("Soft-offlining pfn: 0x%llx\n", pfn);
			memory_failure_queue(pfn, 0, MF_SOFT_OFFLINE);
			ca->pfns_poisoned++;
		}

		del_elem(ca, to);

		/*
		 * Return a >0 value to denote that we've reached the offlining
		 * threshold.
		 */
		ret = 1;

		goto unlock;
	}

decay:
	ca->decay_count++;

	if (ca->decay_count >= CLEAN_ELEMS)
		do_spring_cleaning(ca);

unlock:
	mutex_unlock(&ce_mutex);

	return ret;
}
开发者ID:asmalldev,项目名称:linux,代码行数:80,代码来源:cec.c

示例5: pdf_write_outline_dict

static void
pdf_write_outline_dict(PDF *p, int entry)
{
    pdf_outline *outline = &p->outlines[entry];
    pdc_id act_idlist[PDF_MAX_EVENTS];

    /* write action objects */
    if (outline->action)
        pdf_parse_and_write_actionlist(p, event_bookmark, act_idlist,
                                       (const char *) outline->action);

    pdc_begin_obj(p->out, OBJ_ID(entry));   /* outline object */
    pdc_begin_dict(p->out);

    pdc_objref(p->out, "/Parent", OBJ_ID(PARENT(entry)));

    /* outline destination */
    if (outline->dest)
    {
        pdc_puts(p->out, "/Dest");
        pdf_write_destination(p, outline->dest);
    }

    /* write Action entries */
    else if (outline->action)
        pdf_write_action_entries(p, event_bookmark, act_idlist);

    pdc_puts(p->out, "/Title"); /* outline text */
    pdf_put_hypertext(p, outline->text);
    pdc_puts(p->out, "\n");

    if (PREV(entry))
        pdc_objref(p->out, "/Prev", OBJ_ID(PREV(entry)));
    if (NEXT(entry))
        pdc_objref(p->out, "/Next", OBJ_ID(NEXT(entry)));

    if (FIRST(entry)) {
        pdc_objref(p->out, "/First", OBJ_ID(FIRST(entry)));
        pdc_objref(p->out, "/Last", OBJ_ID(LAST(entry)));
    }
    if (COUNT(entry)) {
        if (OPEN(entry))
            pdc_printf(p->out, "/Count %d\n", COUNT(entry));    /* open */
        else
            pdc_printf(p->out, "/Count %d\n", -COUNT(entry));/* closed */
    }

    /* Color */
    if (outline->textcolor[0] != 0.0 ||
        outline->textcolor[1] != 0.0 ||
        outline->textcolor[2] != 0.0)
        pdc_printf(p->out, "/C[%f %f %f]\n", outline->textcolor[0],
                                              outline->textcolor[1],
                                              outline->textcolor[2]);

    /* FontStyle */
    if (outline->fontstyle != fnt_Normal)
    {
        int fontstyle = 0;
        if (outline->fontstyle == fnt_Bold)
            fontstyle = 2;
        if (outline->fontstyle == fnt_Italic)
            fontstyle = 1;
        if (outline->fontstyle == fnt_BoldItalic)
            fontstyle = 3;
        pdc_printf(p->out, "/F %d\n", fontstyle);
    }

    pdc_end_dict(p->out);
    pdc_end_obj(p->out);                        /* outline object */
}
开发者ID:Vulcanior,项目名称:IUP,代码行数:71,代码来源:p_hyper.c

示例6: PR_IMPLEMENT

PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
{
    PLArena *a;   
    char *rp;     /* returned pointer */

    PR_ASSERT((nb & pool->mask) == 0);
    
    nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */

    /* attempt to allocate from arenas at pool->current */
    {
        a = pool->current;
        do {
            if ( a->avail +nb <= a->limit )  {
                pool->current = a;
                rp = (char *)a->avail;
                a->avail += nb;
                return rp;
            }
        } while( NULL != (a = a->next) );
    }

    /* attempt to allocate from arena_freelist */
    {
        PLArena *p; /* previous pointer, for unlinking from freelist */

        /* lock the arena_freelist. Make access to the freelist MT-Safe */
        if ( PR_FAILURE == LockArena())
            return(0);

        for ( a = arena_freelist, p = NULL; a != NULL ; p = a, a = a->next ) {
            if ( a->base +nb <= a->limit )  {
                if ( p == NULL )
                    arena_freelist = a->next;
                else
                    p->next = a->next;
                UnlockArena();
                a->avail = a->base;
                rp = (char *)a->avail;
                a->avail += nb;
                /* the newly allocated arena is linked after pool->current 
                *  and becomes pool->current */
                a->next = pool->current->next;
                pool->current->next = a;
                pool->current = a;
                if ( NULL == pool->first.next )
                    pool->first.next = a;
                return(rp);
            }
        }
        UnlockArena();
    }

    /* attempt to allocate from the heap */ 
    {  
        PRUint32 sz = PR_MAX(pool->arenasize, nb);
        sz += sizeof *a + pool->mask;  /* header and alignment slop */
        a = (PLArena*)PR_MALLOC(sz);
        if ( NULL != a )  {
            a->limit = (PRUword)a + sz;
            a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
            rp = (char *)a->avail;
            a->avail += nb;
            /* the newly allocated arena is linked after pool->current 
            *  and becomes pool->current */
            a->next = pool->current->next;
            pool->current->next = a;
            pool->current = a;
            if ( NULL == pool->first.next )
                pool->first.next = a;
            PL_COUNT_ARENA(pool,++);
            COUNT(pool, nmallocs);
            return(rp);
        }
    }
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:75,代码来源:plarena.c

示例7: quick_sort

static void	quick_sort(List *l,
		/*List_Iterator *first,
		List_Iterator *last,*/
		list_cmp_fct cmpf)
{
/*	
	A LITTLE MORE OPTIMIZED BUT BUGGED VERSION

	List_Iterator *pivot = last;
	List_Iterator *it = first;
	List_Iterator *next = NULL;
	void *data = NULL;
	last = NULL;

	if (!it || !pivot || it == pivot || !pivot->prev || !it->next)
	{
		return;
	}

	while (it != pivot)
	{
		next = it->next;
		if (cmpf(it->data, pivot->data) <= 0)
		{
			if (it == first)
				first = it->next;
			data = List_remove_it(l, it);
			assert(data);
			assert(List_insert_after_it(l, pivot, data));
			if (last == NULL)
				last = pivot->next;
		}
		it = next;
	}
	quick_sort(l, first, pivot->prev, cmpf);
	quick_sort(l, pivot->next, last, cmpf);*/

	void *pivot;
	int cmp = 0;
	List *less = NEW(List);
	List *greater = NEW(List);
	List *equal = NEW(List);
	List_Iterator *it;

	if (!less || !greater || !equal)
	{
		perror("malloc");
		return ;
	}
	if (COUNT(l) <= 1)
		return ;

	it = List_get_it(l, (COUNT(l)/2 - 1));
	pivot = it->data;
	List_remove_it(l, it);
	while (COUNT(l))
	{
		it = List_pop_first_it(l);
		cmp = cmpf(it->data, pivot);
		if (cmp > 0)
			List_append_it(less, it);
		else if (cmp < 0)
			List_append_it(greater, it);
		else
			List_append_it(equal, it);

	}
	// SUBLISTS
	if (COUNT(less)) {
		quick_sort(less, cmpf);
		List_concat(l, less);
	}
	else
		free(less);

	// 
	List_append(l, pivot);
	
	if (COUNT(equal)) {
		List_concat(l, equal);
	}
	else
		free(equal);


	if (COUNT(greater)) {
		quick_sort(greater, cmpf);
		List_concat(l, greater);
	}
	else
		free(greater);

}
开发者ID:patrickzip,项目名称:emap,代码行数:93,代码来源:quick_sort.c

示例8: DlgLuaScriptDialog


//.........这里部分代码省略.........
				char Str_Tmp [1024]; // shadow added because the global one is unreliable
				SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_GETTEXT,(WPARAM)512,(LPARAM)Str_Tmp);
				// tell the OS to open the file with its associated editor,
				// without blocking on it or leaving a command window open.
				if((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
					if((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
						ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL);
			}	break;

			case IDC_BUTTON_LUABROWSE:
			{
				OPENFILENAME  ofn;
				char  szFileName[MAX_PATH];

				strcpy(szFileName, S9xGetFilenameRel("lua"));

				ZeroMemory( (LPVOID)&ofn, sizeof(OPENFILENAME) );
				ofn.lStructSize = sizeof(OPENFILENAME);
				ofn.hwndOwner = hDlg;
				ofn.lpstrFilter = "Lua Script (*.lua)" "\0*.lua\0" FILE_INFO_ANY_FILE_TYPE "\0*.*\0\0";
				ofn.lpstrFile = szFileName;
				ofn.lpstrDefExt = "lua";
				ofn.nMaxFile = MAX_PATH;
				ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself)
				if(GetOpenFileName( &ofn ))
				{
					SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), szFileName);
				}
				//SetCurrentDirectory(movieDirectory);
				return true;
			}	break;

			case IDC_EDIT_LUAPATH:
			{
				char filename[MAX_PATH];
				GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
				FILE* file = fopen(filename, "rb");
				EnableWindow(GetDlgItem(hDlg, IDOK), file != NULL);
				if(file)
					fclose(file);
			}	break;

			case IDC_LUACONSOLE_CHOOSEFONT:
			{
				CHOOSEFONT cf;

				ZeroMemory(&cf, sizeof(cf));
				cf.lStructSize = sizeof(CHOOSEFONT);
				cf.hwndOwner = hDlg;
				cf.lpLogFont = &LuaConsoleLogFont;
				cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
				if (ChooseFont(&cf)) {
					if (hFont) {
						DeleteObject(hFont);
						hFont = NULL;
					}
					hFont = CreateFontIndirect(&LuaConsoleLogFont);
					if (hFont)
						SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0);
				}
			}	break;

			case IDC_LUACONSOLE_CLEAR:
			{
				SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), "");
			}	break;
		}
		break;

	case WM_CLOSE: {
		S9xLuaStop();
		DragAcceptFiles(hDlg, FALSE);
		if (hFont) {
			DeleteObject(hFont);
			hFont = NULL;
		}
		LuaConsoleHWnd = NULL;
	}	break;

	case WM_DROPFILES: {
		HDROP hDrop;
		//UINT fileNo;
		UINT fileCount;
		char filename[PATH_MAX];

		hDrop = (HDROP)wParam;
		fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
		if (fileCount > 0) {
			DragQueryFile(hDrop, 0, filename, COUNT(filename));
			SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filename);
		}
		DragFinish(hDrop);
		return true;
	}	break;

	}

	return false;

}
开发者ID:Kriole,项目名称:snes9x-rr,代码行数:101,代码来源:luaconsole.cpp

示例9: EQUATION

#include "fun_head_fast.h"


MODELBEGIN


EQUATION("Init")
/*
Model initialization
*/

v[0] = V("N");
v[1] = V("C0");
v[2] = V("Q0");
v[3] = COUNT("Firm");

for (i = v[3] + 1; i <= v[0]; ++i)
	ADDOBJ("Firm");				// add missing objects

i = 1;
CYCLE(cur, "Firm")				// set initial conditions (t=0)
{
	WRITELS(cur, "Convenience", v[1], 0);
	WRITELS(cur, "Quality", v[2], 0);
	WRITELS(cur, "Prob", 0, 0);
	WRITELS(cur, "sigma", 0, 0);
	WRITELS(cur, "ms", 1 / v[0], 0);
}

PARAMETER;
开发者ID:marcov64,项目名称:Lsd,代码行数:30,代码来源:fun_richardson.cpp

示例10: char_ioctl_arg


//.........这里部分代码省略.........
		put_value(proc, "left", "%d", level->left);
		put_value(proc, "right", "%d", level->right);
		return IF_ALL;

	case MIXIOGETINPUTLEFT:
	case MIXIOGETINPUTRIGHT:
	case MIXIOGETOUTPUT:
		if ((inout = (struct inout_ctrl *)ptr) == NULL)
			return dir;

		if (dir == IF_OUT)
			put_sound_device(proc, "device", inout->device);
		else {
			put_sound_state(proc, "left", inout->left);
			put_sound_state(proc, "right", inout->right);
		}
		return IF_ALL;

	case MIXIOSETINPUTLEFT:
	case MIXIOSETINPUTRIGHT:
	case MIXIOSETOUTPUT:
		if ((inout = (struct inout_ctrl *)ptr) == NULL)
			return IF_OUT;

		put_sound_device(proc, "device", inout->device);
		put_sound_state(proc, "left", inout->left);
		put_sound_state(proc, "right", inout->right);
		return IF_ALL;

	case TIOCFLUSH:
		if (ptr == NULL)
			return IF_OUT;

		put_flags(proc, NULL, flush_flags, COUNT(flush_flags), "0x%x",
		    *(int *)ptr);
		return IF_ALL;

	case TIOCGETA:
	case TIOCSETA:
	case TIOCSETAW:
	case TIOCSETAF:
		if ((tc = (struct termios *)ptr) == NULL)
			return dir;

		/*
		 * These are fairly common IOCTLs, so printing everything by
		 * default would create a lot of noise.  By default we limit
		 * ourselves to printing the field that contains what I
		 * consider to be the most important flag: ICANON.
		 * TODO: see if we can come up with a decent format for
		 * selectively printing (relatively important) flags.
		 */
		if (verbose > 0) {
			put_flags(proc, "c_iflag", tc_iflags, COUNT(tc_iflags),
			    "0x%x", tc->c_iflag);
			put_flags(proc, "c_oflag", tc_oflags, COUNT(tc_oflags),
			    "0x%x", tc->c_oflag);
			put_flags(proc, "c_cflag", tc_cflags, COUNT(tc_cflags),
			    "0x%x", tc->c_cflag);
		}
		put_flags(proc, "c_lflag", tc_lflags, COUNT(tc_lflags), "0x%x",
			tc->c_lflag);
		if (verbose > 0) {
			put_value(proc, "c_ispeed", "%d", tc->c_ispeed);
			put_value(proc, "c_ospeed", "%d", tc->c_ospeed);
		}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:67,代码来源:char.c

示例11: sharelock

static __inline void
sharelock(struct thread *td, struct lock *lkp, int incr) {
	lkp->lk_flags |= LK_SHARE_NONZERO;
	lkp->lk_sharecount += incr;
	COUNT(td, incr);
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:6,代码来源:osi_vnodeops.c

示例12: Config_ResetDefault

void Config_ResetDefault() {
  float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
  float tmp2[] = DEFAULT_MAX_FEEDRATE;
  long tmp3[] = DEFAULT_MAX_ACCELERATION;
  for (uint8_t i = 0; i < NUM_AXIS; i++) {
    axis_steps_per_unit[i] = tmp1[i];
    max_feedrate[i] = tmp2[i];
    max_acceleration_units_per_sq_second[i] = tmp3[i];
    #if ENABLED(SCARA)
      if (i < COUNT(axis_scaling))
        axis_scaling[i] = 1;
    #endif
  }

  // steps per sq second need to be updated to agree with the units per sq second
  reset_acceleration_rates();

  acceleration = DEFAULT_ACCELERATION;
  retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
  travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
  minimumfeedrate = DEFAULT_MINIMUMFEEDRATE;
  minsegmenttime = DEFAULT_MINSEGMENTTIME;
  mintravelfeedrate = DEFAULT_MINTRAVELFEEDRATE;
  max_xy_jerk = DEFAULT_XYJERK;
  max_z_jerk = DEFAULT_ZJERK;
  max_e_jerk = DEFAULT_EJERK;
  home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;

  #if ENABLED(MESH_BED_LEVELING)
    mbl.active = 0;
  #endif

  #if ENABLED(AUTO_BED_LEVELING_FEATURE)
    zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
  #endif

  #if ENABLED(DELTA)
    endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
    delta_radius =  DELTA_RADIUS;
    delta_diagonal_rod =  DELTA_DIAGONAL_ROD;
    delta_segments_per_second =  DELTA_SEGMENTS_PER_SECOND;
    delta_diagonal_rod_trim_tower_1 = DELTA_DIAGONAL_ROD_TRIM_TOWER_1;
    delta_diagonal_rod_trim_tower_2 = DELTA_DIAGONAL_ROD_TRIM_TOWER_2;
    delta_diagonal_rod_trim_tower_3 = DELTA_DIAGONAL_ROD_TRIM_TOWER_3;
    recalc_delta_settings(delta_radius, delta_diagonal_rod);
  #elif ENABLED(Z_DUAL_ENDSTOPS)
    z_endstop_adj = 0;
  #endif

  #if ENABLED(ULTIPANEL)
    plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
    plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
    plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
    absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
    absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
    absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
  #endif

  #if ENABLED(HAS_LCD_CONTRAST)
    lcd_contrast = DEFAULT_LCD_CONTRAST;
  #endif

  #if ENABLED(PIDTEMP)
    #if ENABLED(PID_PARAMS_PER_EXTRUDER)
      for (uint8_t e = 0; e < EXTRUDERS; e++)
    #else
      int e = 0; UNUSED(e); // only need to write once
    #endif
    {
      PID_PARAM(Kp, e) = DEFAULT_Kp;
      PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
      PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
      #if ENABLED(PID_ADD_EXTRUSION_RATE)
        PID_PARAM(Kc, e) = DEFAULT_Kc;
      #endif
    }
    #if ENABLED(PID_ADD_EXTRUSION_RATE)
      lpq_len = 20; // default last-position-queue size
    #endif
    // call updatePID (similar to when we have processed M301)
    updatePID();
  #endif // PIDTEMP

  #if ENABLED(PIDTEMPBED)
    bedKp = DEFAULT_bedKp;
    bedKi = scalePID_i(DEFAULT_bedKi);
    bedKd = scalePID_d(DEFAULT_bedKd);
  #endif

  #if ENABLED(FWRETRACT)
    autoretract_enabled = false;
    retract_length = RETRACT_LENGTH;
    #if EXTRUDERS > 1
      retract_length_swap = RETRACT_LENGTH_SWAP;
    #endif
    retract_feedrate = RETRACT_FEEDRATE;
    retract_zlift = RETRACT_ZLIFT;
    retract_recover_length = RETRACT_RECOVER_LENGTH;
    #if EXTRUDERS > 1
      retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
//.........这里部分代码省略.........
开发者ID:squidwrench,项目名称:Marlin,代码行数:101,代码来源:configuration_store.cpp

示例13: main

int main(void)
{
    clock_t tic,toc;

    double signal[] = { 3,4,5,6,7,8,9,10};
    double filter[] = { 2,1 };
    //double result[COUNT(signal) + COUNT(filter) - 1] = NULL;
    double* result = (double *) calloc(COUNT(signal) + COUNT(filter) - 1, sizeof(double));

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
    tic = clock();
    convolve(signal, COUNT(signal), filter, COUNT(filter), result);
    toc = clock();
    printf("Elapsed: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);
*/
    int j;/*
    printf("Resultado Final:\n");
    for( j=0; j<(COUNT(signal) + COUNT(filter) - 1); j++ ) {
        printf("%f ",result[j]);
    }
    printf("\n");
*/
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    result = (double *) calloc(COUNT(signal) + COUNT(filter) - 1, sizeof(double));

    tic = clock();
    //convolve_index(signal,0, COUNT(signal), filter, COUNT(filter), result);

    convNormalIndex(signal,0, COUNT(signal), filter, COUNT(filter), result);

    toc = clock();
    printf("Elapsed: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);

    //printf("Resultado Final:\n");
    for( j=0; j<(COUNT(signal) + COUNT(filter) - 1); j++ ) {
        printf("%f ",result[j]);
    }
    printf("\n");

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    result = (double *) calloc(COUNT(signal) + COUNT(filter) - 1, sizeof(double));

    int block_size = 4;
    int l_localBuffer = nextpw2(block_size+COUNT(filter)-1);
    double* localBuffer = (double *) calloc(l_localBuffer, sizeof(double));
    printf("size = %d\n",l_localBuffer);

    tic = clock();
    for( j=0; j<(COUNT(signal)/block_size); j++ ) {
        //printf("Bucle externo j: %d\n",j);
        //que empiece enl puntero en el inicio del vector signal o result pero en (j*block_size)
        convOverlapAdd(&signal[j*block_size], block_size, localBuffer, l_localBuffer, filter, COUNT(filter), &result[j*block_size]);
    }

    toc = clock();
    printf("Elapsed: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);
    free(localBuffer);
    printf("Resultado Final:\n");
    for( j=0; j<(COUNT(signal) + COUNT(filter) - 1); j++ ) {
        printf("%f ",result[j]);
    }
    printf("\n");

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    printf("%d\n",(int)resultLength);

    double *A = malloc( resultLength*sizeof(double) );
    //double *B = malloc( resultLength*sizeof(double) );
    //double *C = (double *) calloc(resultLength, sizeof(double));


    /* datos aleatorios */
    /*    printf("[");
    int j;
    for( j=0; j<signalLength; j++ ) {
        A[j] = ((double) rand()/ RAND_MAX);
        printf("%f, ",A[j]);
    }
    printf("]\n");
     */
/*
    tic = clock();
    convolve(soundRandom, signalLength, H_1, filterLength, A);
    toc = clock();
    printf("Elapsed: %f miliseconds\n", (double)(toc - tic)*1000 / CLOCKS_PER_SEC);


    int block_size2 = 512;
    int l_localBuffer2 = nextpw2(block_size2+filterLength-1);
    double *localBuffer2 = (double *) calloc(l_localBuffer2, sizeof(double));
    printf("size = %d\n",l_localBuffer2);

    tic = clock();
    for( j=0; j<(signalLength/block_size2); j++ ) {
        printf("Bucle externo j: %d, indice:%d\n",j,j*block_size2);
        //que empiece enl puntero en el inicio del vector signal o result pero en (j*block_size)
        //convOverlapAdd(&soundRandom[j*block_size], block_size2, localBuffer2, l_localBuffer2, H_1, filterLength, &C[j*block_size]);
//.........这里部分代码省略.........
开发者ID:MihaiLupoiu,项目名称:Convolution,代码行数:101,代码来源:convolucion.c

示例14: vram_init

void vram_init()
{
    menu_add("VRAM", vram_menus, COUNT(vram_menus));
    old_buffer_pos = YUV422_LV_BUFFER_1;
}
开发者ID:frantony,项目名称:magic-lantern,代码行数:5,代码来源:vram.c

示例15: French

void model1::em_loop(int it,Perplexity& perp, sentenceHandler& sHandler1, bool seedModel1, 
		     bool dump_alignment, const char* alignfile, Dictionary& dict, bool useDict, Perplexity& viterbi_perp, bool test)
{
  WordIndex i, j, l, m ;
  double cross_entropy;
  int pair_no=0 ;
  perp.clear();
  viterbi_perp.clear();
  ofstream of2;
  // for each sentence pair in the corpus
  if (dump_alignment||FEWDUMPS)
    of2.open(alignfile);
  cerr <<" number of French (target) words = " << noFrenchWords << endl;
  PROB uniform = 1.0/noFrenchWords ;
  cerr << "initial unifrom prob = " << uniform << endl;
  sentPair sent ;
  sHandler1.rewind();
  while(sHandler1.getNextSentence(sent)){
    Vector<WordIndex>& es = sent.eSent;
    Vector<WordIndex>& fs = sent.fSent;
    const float so  = sent.getCount(); // number of times sentence occurs in corpus
    //std::cerr << "\n\nNEW sentence (#" << (pair_no + 1) << ") with count = " << so << endl;
    l = es.size() - 1;  // source length
    m = fs.size() - 1;  // target length
    cross_entropy = log(1.0);
    Vector<WordIndex> viterbi_alignment(fs.size());
    double viterbi_score = 1 ;

    /*mebool eindict[l + 1];
    bool findict[m + 1];
    bool indict[m + 1][l + 1];
    if(it == 1 && useDict){
      for(unsigned int dummy = 0; dummy <= l; dummy++) eindict[dummy] = false;
      for(unsigned int dummy = 0; dummy <= m; dummy++){
	findict[dummy] = false;
	for(unsigned int dummy2 = 0; dummy2 <= l; dummy2++) 
	  indict[dummy][dummy2] = false;
      }
      for(j = 0; j <= m; j++)
	for(i = 0; i <= l; i++)
	  if(dict.indict(fs[j], es[i])){
	    eindict[i] = findict[j] = indict[j][i] = true;
	  }
    }me*/

    for(j=1; j <= m; j++){
      //cerr << "Current french (TARGET) word = " << fs[j] << endl;
      // entries  that map fs to all possible ei in this sentence.
      Vector<LpPair<COUNT,PROB> *> sPtrCache(es.size(),0); // cache pointers to table 
      LpPair<COUNT,PROB> **sPtrCachePtr;

      PROB denom = 0.0;
      WordIndex best_i = 0 ; // i for which fj is best maped to ei
      PROB word_best_score = 0 ;  // score for the best mapping of fj
      if (it == 1 && !seedModel1){
        //cerr << "Using uniform denominator\n";
	denom = uniform  * es.size() ;
	word_best_score = uniform ;
      }
      else 
	for((i=0),(sPtrCachePtr=&sPtrCache[0]); i <= l; i++,sPtrCachePtr++){
          //cerr << "current english (SOURCE) word = " << es[i] << endl;
	  PROB e(0.0) ;
          srcHits_.insert(es[i]);
	  (*sPtrCachePtr) = tTable.getPtr(es[i], fs[j]) ;
	  if ((*sPtrCachePtr) != 0 && (*((*sPtrCachePtr))).prob > PROB_SMOOTH) 
	    e = (*((*sPtrCachePtr))).prob;
	  else e = PROB_SMOOTH ;
	  denom += e  ;
	  if (e > word_best_score){
	    word_best_score = e ;
	    best_i = i ;
	  }	
        }
      viterbi_alignment[j] = best_i ;
      viterbi_score *= word_best_score ; /// denom ;
      if (denom == 0){
	if (test)
	  cerr << "WARNING: denom is zero (TEST)\n";
	else 
	  cerr << "WARNING: denom is zero (TRAIN)\n";
      }
      cross_entropy += log(denom) ;
      if (!test){
	if(denom > 0){	  
	  COUNT val = COUNT(so) / (COUNT) double(denom) ;
	  /* this if loop implements a constraint on counting:
	     count(es[i], fs[j]) is implemented if and only if
	     es[i] and fs[j] occur together in the dictionary, 
	     OR
	     es[i] does not occur in the dictionary with any fs[x] and
	     fs[j] does not occur in the dictionary with any es[y]
	  */
	  /*meif(it == 1 && useDict){
	    for((i=0),(sPtrCachePtr=&sPtrCache[0]); i <= l; i++,sPtrCachePtr++){
	      if(indict[j][i] || (!findict[j] && !eindict[i])){
		PROB e(0.0) ;
		if (it == 1 && !seedModel1)
		  e =  uniform  ;
		else if ((*sPtrCachePtr) != 0 &&  (*((*sPtrCachePtr))).prob > PROB_SMOOTH) 
//.........这里部分代码省略.........
开发者ID:akivajp,项目名称:inc-giza-pp,代码行数:101,代码来源:model1.cpp


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