Example #1
0
void CXUIDatePicker::Init()
{
	DWORD wStyle = WS_CHILD | WS_TABSTOP;

	if(m_showNone)	wStyle |= DTS_SHOWNONE;
	if(m_useSpin)	wStyle |= DTS_UPDOWN;
	switch(m_format)
	{
	case XUI_DATE_FORMAT_LONG:
		wStyle |= DTS_LONGDATEFORMAT;
		break;
	case XUI_DATE_FORMAT_TIME:
		wStyle |= DTS_TIMEFORMAT;
		break;
	default:
		wStyle |= DTS_SHORTDATEFORMAT;
		break;
	}

	if(get_disabled())	wStyle |= WS_DISABLED;
	if(!get_hidden())	wStyle |= WS_VISIBLE;

	m_hWnd = CreateWindowEx(0, DATETIMEPICK_CLASS, L"", wStyle, m_left, m_top, m_width, m_height, m_parent->get_parentWnd(), (HMENU) m_id, m_engine->get_hInstance(), NULL);

	RECT rcDlg = {0, 0, 100, 14};
	if(m_width) rcDlg.right = m_width;
	if(m_height) rcDlg.bottom = m_height;
	MapDialogRect(m_parent->get_parentWnd(), &rcDlg);
	m_minWidth	= rcDlg.right;
	m_minHeight = rcDlg.bottom;

	CXUIElement::Init();
}
int VWindowGUI::drag_stop()
{
	if(get_hidden()) return 0;

	if(mwindow->session->vcanvas_highlighted &&
		mwindow->session->current_operation == DRAG_ASSET)
	{
		mwindow->session->vcanvas_highlighted = 0;
		canvas->draw_refresh();

		Indexable *indexable = mwindow->session->drag_assets->size() ?
			mwindow->session->drag_assets->get(0) :
			0;
		EDL *edl = mwindow->session->drag_clips->size() ?
			mwindow->session->drag_clips->get(0) :
			0;
		
		if(indexable)
			vwindow->change_source(indexable);
		else
		if(edl)
			vwindow->change_source(edl);
		return 1;
	}

	return 0;
}
void VWindowGUI::drag_motion()
{
// Window hidden
	if(get_hidden()) return;
	if(mwindow->session->current_operation != DRAG_ASSET) return;

	int old_status = mwindow->session->vcanvas_highlighted;

	int cursor_x = get_relative_cursor_x();
	int cursor_y = get_relative_cursor_y();
	
	mwindow->session->vcanvas_highlighted = (get_cursor_over_window() &&
		cursor_x >= canvas->x &&
		cursor_x < canvas->x + canvas->w &&
		cursor_y >= canvas->y &&
		cursor_y < canvas->y + canvas->h);


printf("VWindowGUI::drag_motion 1 %d %d %d %d %d\n", 
__LINE__, 
mwindow->session->vcanvas_highlighted,
get_cursor_over_window(),
cursor_x,
cursor_y);


	if(old_status != mwindow->session->vcanvas_highlighted)
		canvas->draw_refresh();
}
Example #4
0
void CXUIFreeDraw::Init()
{
	DWORD wStyle = WS_CHILD;

	if(get_disabled())	wStyle |= WS_DISABLED;
	if(!get_hidden())	wStyle |= WS_VISIBLE;

	m_hWnd = CreateWindowEx(0, XUI_FREEDRAW_CLASS, TEXT(""), wStyle, m_left, m_top, m_width, m_height, m_parent->get_parentWnd(), (HMENU) m_id, m_engine->get_hInstance(), (LPVOID) this);

	RECT rcDlg = {0, 0, !m_minWidth ?  14: m_minWidth, !m_minHeight ? 14 : m_minHeight};
	if(m_width)		rcDlg.right		= m_width;
	if(m_height)	rcDlg.bottom	= m_height;
	MapDialogRect(m_parent->get_parentWnd(), &rcDlg);
	m_minWidth  = rcDlg.right;
	m_minHeight = rcDlg.bottom;
}
Example #5
0
int		*cypher(char *msg, int *key, int flag, char *base, size_t *msg_len)
{
  int		*res;
  int		*msg_mtx;

  res = NULL;
  if (!flag)
    msg_mtx = get_msg(msg, msg_len);
  else
    msg_mtx = get_hidden(msg, msg_len, base);
  if (msg_mtx)
    {
      res = mult_mtx(msg_mtx, key, *msg_len);
      free(msg_mtx);
    }
  else
    perror("./102chiffrement");
  return (res);
}
Example #6
0
File: button.cpp Project: Lucki/Lix
// Liefert nur true, wenn der Button gerade fertig angeklickt wurde
void Button::calc_self()
{
    if (get_hidden()) {
        clicked_last_calc = false;
    }
    else {
        check_whether_to_appear_down();
        // Shall the buttons now fire callbacks or believe to be clicked?
        // KEY_ENTER als Hotkey laesst auch KEY_ENTER_PAD zu!
        bool mouse_here = is_mouse_here();
        bool b =
            (!warm && !hot && mouse_here && hardware.get_mlr())
         || ( warm && !hot && mouse_here && hardware.get_ml ())
         || (          hot && mouse_here && hardware.get_mlh());
        // See hardware.h/cpp for why Enter is separated
        if (hotkey == KEY_ENTER) b = b || hardware.key_enter_once();
        else                     b = b || hardware.key_once(hotkey);
        clicked_last_calc = b;
    }
}
		TITANIUM_PROPERTY_GETTER(File, hidden)
		{
			return get_context().CreateBoolean(get_hidden());
		}
Example #8
0
	void print_rbm(rbm* r) {

	  std::cout << "Rbm with " << r->nv << " visible and "
				<< r->nh << " hidden units." << std::endl;

	  // visible units
	  std::cout << "visible units:" << std::endl;
	  for (unsigned int i=0; i<r->nv; i++) {

		std::cout << get_visible(r, i);
		if (i != 0 && i % 8 == 0) {
		  std::cout << std::endl;
		}
		else {
		  std::cout << " ";
		}
	  }
	  std::cout << std::endl;

	  // hidden units
	  std::cout << "Hidden units:" << std::endl;
	  for (unsigned int j=0; j<r->nh; j++) {

		std::cout << get_hidden(r, j);
		if (j != 0 && j % 8 == 0) {
		  std::cout << std::endl;
		}
		else {
		  std::cout << " ";
		}
	  }
	  std::cout << std::endl;

	  // weights
	  std::cout << "Weights:" << std::endl;
	  for (unsigned int i=0; i<r->nv; i++) {

		for(unsigned int j=0; j<r->nh; j++) {
			std::cout << get_weight(r, i, j);
			if ((i + j) != 0 && (i + j) % 8 == 0) {
			  std::cout << std::endl;
			}
			else {
			  std::cout << " ";
			}
		 }
	  }
	  std::cout << std::endl;

	  //biases
	  std::cout << "Bias weights visible:" << std::endl;
	  for (unsigned int i=0; i<r->nv; i++) {

		std::cout << get_weight_visible_bias(r, i);
		if (i != 0 && i % 8 == 0) {
		  std::cout << std::endl;
		}
		else {
		  std::cout << " ";
		}
	  }
	  std::cout << std::endl;
	  std::cout << "Bias weights hidden:" << std::endl;
	  for (unsigned int j=0; j<r->nh; j++) {

		std::cout << get_weight_hidden_bias(r, j);
		if (j != 0 && j % 8 == 0) {
		  std::cout << std::endl;
		}
		else {
		  std::cout << " ";
		}
	  }
	  std::cout << std::endl;
	}
Example #9
0
void train_crbm(dataset_blas *train_set, int nvisible, int nhidden, int nlabel,
               int epoch, double lr,
               int minibatch, double momentum, char *model_file){
    crbm m;
    int i, j, k;
    int nepoch;
    double *v1, *y1;
    uint8_t *l;
    int batch_size, niter;
    int wc;
    int err;
    double lik;
    double delta;
    int *idx;
    time_t start_t, end_t;

    init_crbm(&m, nvisible, nhidden, nlabel);

    //wc = (int)cblas_dasum(train_set->N * train_set->n_feature, train_set->input, 1);
    niter = (train_set->N-1)/minibatch + 1;
    delta = lr / (1.0*minibatch);
    /*
     * shuffle training data
    v1 = (double*)malloc(minibatch * m.nvisible * sizeof(double));
    y1 = (double*)malloc(minibatch * m.ncat * sizeof(double));
    l = (uint8_t*)malloc(minibatch * sizeof(uint8_t));
    idx = (int*)malloc(train_set->N * sizeof(int));
    for(i = 0; i < train_set->N; i++)
        idx[i] = i;*/
    bzero(w_u, sizeof(w_u));
    bzero(u_u, sizeof(u_u));
    bzero(bh_u, sizeof(bh_u));
    bzero(bv_u, sizeof(bv_u));
    bzero(by_u, sizeof(by_u));

    //shuffle(idx, train_set->N);
    
    for(nepoch = 0; nepoch < epoch; nepoch++){
        
        lik = 0;
        err = 0;
        start_t = time(NULL);

        for(k = 0; k < niter; k++){
#ifdef DEBUG
            if((k+1) % 200 == 0){
                printf("batch %d\n", k+1);
            }
#endif
            if(k == niter - 1){
                batch_size = train_set->N - minibatch * (niter-1);
            }else{
                batch_size = minibatch;
            }

            v1 = train_set->input + train_set->n_feature * minibatch * k;
            y1 = train_set->label + train_set->nlabel * minibatch * k;
            l = train_set->output + minibatch * k;
            /*
             * shuffle training data
            for(i = 0; i < batch_size; i++){
                cblas_dcopy(m.nvisible, train_set->input + m.nvisible * idx[k*minibatch+i],
                            1, v1 + m.nvisible * i, 1);
                cblas_dcopy(m.ncat, train_set->label + m.ncat * idx[k*minibatch+i],
                            1, y1 + m.ncat * i, 1);
                l[i] = train_set->output[idx[k*minibatch+i]];
            }*/
            get_hidden(&m, v1, y1, ph1, batch_size);            
            sample_hidden(&m, ph1, h1, batch_size);

            get_visible(&m, h1, pv, batch_size);
            sample_visible(&m, pv, v2, batch_size);

            get_class(&m, h1, py, batch_size);
            sample_class(&m, py, y2, batch_size);

            get_hidden(&m, v2, y2, ph2, batch_size);
            sample_hidden(&m, ph2, h2, batch_size);
            
            //lik += get_likelihood(&m, v1, pv, batch_size);
            err += get_error(&m, y2, l, batch_size);
            
            //update w_u
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nhidden, m.nvisible, batch_size,
                        1.0, ph2, m.nhidden, v2, m.nvisible,
                        0, a, m.nvisible);
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nhidden, m.nvisible, batch_size,
                        1.0, ph1, m.nhidden, v1, m.nvisible,
                        -1, a, m.nvisible);
            cblas_daxpy(m.nvisible * m.nhidden, momentum, w_u, 1,
                        a, 1);
            cblas_dcopy(m.nvisible * m.nhidden, a, 1, w_u, 1);

            //update u_u
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nhidden, m.ncat, batch_size,
                        1.0, ph2, m.nhidden, y2, m.ncat,
                        0, a, m.ncat);
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nhidden, m.ncat, batch_size,
                        1.0, ph1, m.nhidden, y1, m.ncat,
                        -1, a, m.ncat);
            cblas_daxpy(m.ncat * m.nhidden, momentum, u_u, 1,
                        a, 1);
            cblas_dcopy(m.ncat * m.nhidden, a, 1, u_u, 1);

            //update bv_u
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nvisible, 1, batch_size,
                        1.0, v2, m.nvisible, I, 1,
                        0, a, 1);
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nvisible, 1, batch_size,
                        1.0, v1, m.nvisible, I, 1,
                        -1, a, 1);
            cblas_daxpy(m.nvisible, momentum, bv_u, 1,
                        a, 1);
            cblas_dcopy(m.nvisible, a, 1, bv_u, 1);

            //update by_u
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.ncat, 1, batch_size,
                        1.0, y2, m.ncat, I, 1,
                        0, a, 1);
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.ncat, 1, batch_size,
                        1.0, y1, m.ncat, I, 1,
                        -1, a, 1);
            cblas_daxpy(m.ncat, momentum, by_u, 1,
                        a, 1);
            cblas_dcopy(m.ncat, a, 1, by_u, 1);

            //update bh_u
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nhidden, 1, batch_size,
                        1.0, ph2, m.nhidden, I, 1,
                        0, a, 1);
            cblas_dgemm(CblasRowMajor, CblasTrans, CblasNoTrans,
                        m.nhidden, 1, batch_size,
                        1.0, ph1, m.nhidden, I, 1,
                        -1, a, 1);
            cblas_daxpy(m.nhidden, momentum, bh_u, 1,
                        a, 1);
            cblas_dcopy(m.nhidden, a, 1, bh_u, 1);

            //change parameter
            cblas_daxpy(m.nvisible * m.nhidden, delta, w_u, 1,
                        m.w, 1);
            cblas_daxpy(m.ncat * m.nhidden, delta, u_u, 1,
                        m.u, 1);
            cblas_daxpy(m.nvisible, delta, bv_u, 1,
                        m.bv, 1);
            cblas_daxpy(m.ncat, delta, by_u, 1,
                        m.by, 1);
            cblas_daxpy(m.nhidden, delta, bh_u, 1,
                        m.bh, 1);
        }
        end_t = time(NULL);

        printf("[epoch %d] error:%.5lf%%\ttime:%.2fmin\n", nepoch + 1, 
               err * 100.0 / train_set->N, (end_t - start_t) / 60.0);
    }
    dump_model(&m, model_file);
    //print_prob(&m, train_set, "../data/rsm/test.prob");

    /*
     * shuffle training data
    free(v1);
    free(y1);
    free(l);*/
    free_crbm(&m);
}