示例#1
0
// ----------------------------------------------------------------------
// Set the first visible army in the list -- index is an offset into
// the m_armies array.
// ----------------------------------------------------------------------
void t_army_list_window::set_first_visible( int index )
{
	if (index < 0)
		index = 0;

	if (index > get_max_index())
		index = get_max_index();
	
	m_first_army = index;
	update();
}
示例#2
0
void test_predict(){
    crbm m;
    dataset_blas train_set;
    int i, j, k;
    int minibatch = 20;
    int batch_size, niter;
    double *x, *y = py;

    load_model(&m, "../data/20newsgroup/cross_valid/crbm.model");
    load_corpus("../data/20newsgroup/train.data.format", &train_set);
    load_corpus_label("../data/20newsgroup/train.label.format", &train_set);

    niter = ceil(train_set.N * 1.0 / minibatch);
    for(k = 0; k < niter; k++){
        if(k == niter - 1){
            batch_size = train_set.N - minibatch * (niter-1);
        }else{
            batch_size = minibatch;
        }
        x = train_set.input + m.nvisible * minibatch * k;
        get_y_given_x(&m, x, y, batch_size);
        for(j = 0; j < batch_size; j++){
            printf("%d : %d\n", train_set.output[k*minibatch+j] + 1, 
                    get_max_index(&y[j*m.ncat], m.ncat));
        }
    }

    free_crbm(&m);
    free_dataset_blas(&train_set);
}
示例#3
0
文件: start.c 项目: wsj-zz/FamesOS
void notifier(int index, int prev_index, INT16U option)
{
    int i;
    long i32;

    if(get_max_index() < 0)
        return;

    i = index+1;

    i32 = (long)i * 100; /* 这里必须用long型数据, 不然当i>327的时候就会变成负数 */
    i = (int)(i32/(get_max_index()+1));

    gui_progress_set_value(progress1, i);

    gui_edit_set_text(edit, "又修改了一次");
    
}
示例#4
0
SEXP c_getMaxIndex(SEXP s_x, SEXP s_ties_method, SEXP s_na_rm) {
    if (length(s_x) == 0)
        return NEW_INTEGER(0);
    int ties_method = asInteger(s_ties_method);
    Rboolean na_rm = asInteger(s_na_rm);
    UNPACK_REAL_VECTOR(s_x, x, len_x);
    GetRNGstate();
    int index = get_max_index(x, len_x, 1, ties_method, na_rm);
    PutRNGstate();
    if (index == -1)
        return NEW_INTEGER(0);
    else
        return ScalarInteger(index);
}
示例#5
0
// ----------------------------------------------------------------------
// display a list of armies
// ----------------------------------------------------------------------
void t_army_list_window::set_scrollbar()
{
	// Handle the limit callback if necessary
	int limit_flags;

	if (m_first_army == 0)
		limit_flags = k_army_list_window_at_top;
	else
		limit_flags = 0;
	
	if (m_first_army == get_max_index())
		limit_flags |= k_army_list_window_at_bottom;

	m_limit_handler( limit_flags );
	

	// Update the scroll bar limits and position
	if (m_scrollbar)
	{
		m_scrollbar->set_limits( 0, get_max_index() );
		m_scrollbar->set_position( m_first_army );
		m_scrollbar->set_visible( is_visible() && get_max_index() > 0 );
	}
}
示例#6
0
文件: start.c 项目: wsj-zz/FamesOS
BOOL set_item(int index, int field_id, char *buf, int buf_len, KEYCODE key, INT16U option)
{
    struct student * t;
    int i;

    FamesAssert(buf);

    if(index > get_max_index())
        return fail;

    t = all_students;
    for(i=0; i<index; i++){
        if(t == NULL)
            return fail;
        t = t->next;
    }
    
    if(t == NULL)
            return fail;

    switch(field_id){
        case __id_name:
            strcpy(t->name, buf);
            break;
        case __id_sex:
            t->sex = buf[0];
            break;
        case __id_old:
            t->old = atoi(buf);
            break;
        case __id_sss:
            sprintf(t->comment, "%s", buf);
            break;
        default:
            break;
    }

    return ok;
}
示例#7
0
文件: start.c 项目: wsj-zz/FamesOS
BOOL get_item(int index, int field_id, char *buf, int buf_len, INT16U option)
{
    struct student * t;
    int i;

    FamesAssert(buf);

    if(index > get_max_index())
        return fail;

    t = all_students;
    for(i=0; i<index; i++){
        if(t == NULL)
            return fail;
        t = t->next;
    }
    if(t == NULL)
            return fail;

    switch(field_id){
        case __id_name:
            strcpy(buf, t->name);
            break;
        case __id_sex:
            sprintf(buf, "%c", t->sex);
            break;
        case __id_old:
            sprintf(buf, "%d", t->old);
            break;
        case __id_sss:
            sprintf(buf, "随机数: %d", rand());
            break;
        default:
            break;
    }

    return ok;
}
示例#8
0
// ----------------------------------------------------------------------
// display a list of armies
// ----------------------------------------------------------------------
void t_army_list_window::on_visibility_change()
{
	if ( m_scrollbar != 0 )
		m_scrollbar->set_visible( is_visible() && get_max_index() > 0 );
}