//{ Panel int panel_hitscan(panel_t *panel,int hx,int hy) { int idofs=PAN_ENT*panel->index+PAN_ENT; int wy=D(PANEL_WY+idofs); if(kbpanel&&panel->items[0].str_id==kbpanel) { if(kbpanel==KB_INSTALL) { if(kbitem[kbpanel]>2)kbitem[kbpanel]=2; return panel->index-8==kbitem[kbpanel]; } if(kbitem[kbpanel]>panel->items[0].action_id)kbitem[kbpanel]=panel->items[0].action_id; while(panel->items[kbitem[kbpanel]].type!=TYPE_CHECKBOX&& panel->items[kbitem[kbpanel]].type!=TYPE_BUTTON)kbitem[kbpanel]++; return kbitem[kbpanel]; } if(!wy)return -1; hx-=Xp(panel)+D(PNLITEM_OFSX); hy-=Yp(panel)+D(PNLITEM_OFSY); if(!expertmode&&panel->items[0].type==TYPE_GROUP_BREAK)return -2; if(hx<0||hy<0||hx>XP(panel)-D(PNLITEM_OFSX)*2)return -3; if(hy/wy>=panel->items[0].action_id)return -4; return hy/wy+1; }
void panel_draw_inv(panel_t *panel) { int x=Xp(panel),y=Yp(panel); int idofs=PAN_ENT*panel->index+PAN_ENT; int wy=D(PANEL_WY+idofs); int ofsy=D(PNLITEM_OFSY); RECT rect; if(!panel)return; rect.left=x; rect.top=y; rect.right=x+XP(panel); rect.bottom=y+(wy+1)*panel->items[0].action_id+ofsy*2; InvalidateRect(hMain,&rect,0); }
int main(int argc, char** argv) { int l=5; TinyVector<double,3> pos(0.1,0.3,-0.45), deltax(0.0001,0.0,0.0), deltay(0.0,0.0001,0.0), deltaz(0.0,0.0,0.0001), tpos, g; if(argc>1) l = atoi(argv[1]); if(argc>4) { pos[0] = atof(argv[2]); pos[1] = atof(argv[3]); pos[2] = atof(argv[4]); } SphericalTensor<double,TinyVector<double,3> > Y1(l,true), Y2(l,true), Yp(l,true), Ym(l,true); Y1.evaluate(pos); std::cout.setf(std::ios::scientific, std::ios::floatfield); for(int lm=0; lm<Y1.size(); lm++) { std::cout << lm << std::endl; std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm] << std::setprecision(12) << Y1.gradYlm[lm] << std::endl; //std::cout << std::setw(20) << std::setprecision(12) << Y2.Ylm[lm] // << std::setprecision(12) << Y2.gradYlm[lm] << std::endl; } // for(int lm=0; lm<Y1.size(); lm++) { // tpos = pos+deltax; Yp.evaluate(tpos); // tpos = pos-deltax; Ym.evaluate(tpos); // g[0] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002; // tpos = pos+deltay; Yp.evaluate(tpos); // tpos = pos-deltay; Ym.evaluate(tpos); // g[1] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002; // tpos = pos+deltaz; Yp.evaluate(tpos); // tpos = pos-deltaz; Ym.evaluate(tpos); // g[2] = (Yp.Ylm[lm]-Ym.Ylm[lm])/0.0002; // std::cout << lm << std::endl; // std::cout << std::setw(20) << std::setprecision(12) << Y1.Ylm[lm] // << std::setprecision(12) << Y1.gradYlm[lm] - g << std::endl; // } }
int main() { ofstream output; ifstream input_train ; ifstream input_test ; //ofstream save ; output.open("ex.txt"); input_train.open("trainSet"); //save.open("Net.ini"); YVector normal(2); YVector normal_out(1); normal = 1; normal_out = 1; // e deve avere la dimensione di una riga di Y YVector Yp(1),e(1),X(2),Y(1); double vecw; int i; RFNet prima; // rfwr('Init',ID,2,1,0,0,0,1e-7,50,[1;1],[1],'rfwr_test'); prima.Init(2,1,0,0,0,0.0000001,50,normal,normal_out,"rfwr_test"); //rfwr('Change',ID,'init_D',[25 0.01; 0.01 25]); double el[] = {25, 0.01, 0.01,25}; prima.SetInitD (2,2,el); //rfwr('Change',ID,'init_alpha',ones(2)*250); YMatrix a(2,2); a = 250 * ones(2); prima.SetInitAlpha (a); //rfwr('Change',ID,'w_gen',0.2); prima.SetWGen (0.2); //rfwr('Change',ID,'meta',1); // prima.SetMeta (1); //rfwr('Change',ID,'meta_rate',250); // prima.SetMetaRate (250); for (i = 1; i <=N*20; i++) { input_train >> X(1); input_train >> X(2); input_train >> Y(1); vecw = prima.Train (X,Y,Yp,e); // Per stampare il risulato del train // cout << vecw << endl; // output << vecw << endl; // cout << Yp << endl; // output << Yp << endl; // cout << i << endl; } input_train.close(); input_test.open("testSet"); for (i = 1; i <=1681; i++) { input_test >> X(1); input_test >> X(2); input_test >> Y(1); //[yp,w]=rfwr('Predict',ID,Xt(i,:)',0.001); prima.Simulate (X,0.001,Yp); // Per stampare il risultato del predict // cout << Yp << endl; // output << Yp << endl; outIni(Yp,output); } // prima.print(output); //**** // prima.SaveNet (save); output.close(); input_test.close(); // save.close(); return 0; }
int main() { ofstream output; //**** ifstream input ; //---- //ofstream save ; output.open("o1.txt"); //*** input.open("input.dat");//---- //save.open("Net.ini"); //double v[] = {0.7485, 0.6973, 0.6203}; // Se uso TUTTA X. (N 369) //double v[] = { 0.7055, 0.6973, 0.6003}; // se uso i primi 100 elementi (N 100) double v[] = {0.7,0.7,0.6}; // Per avere valori standard. YVector normal(3,v); YVector normal_out(1); normal_out = 1; YVector Yp(3),e(3),X(3),Y(1); double vecw; int i; RFNet prima; //prima.SetWPrune (0.2); prima.Init(3,1,0,0,0,0.0001,50,normal,normal_out,"test"); input >> X(1); input >> X(2); input >> X(3); input >> Y(1); for (i = 1; i <=N; i++) { //for (i = 1; i <=N; i++) {// Se voglio trainare più volte sullo stesso dato! vecw = prima.Train (X,Y,Yp,e); // Per stampare il risulato del train // cout << vecw << endl; // output << vecw << endl; // cout << Yp << endl; // output << Yp << endl; // cout << i << endl; input >> X(1); input >> X(2); input >> X(3); input >> Y(1); prima.Simulate (X,0.001,Yp); // Per stampare il risultato del predict // cout << Yp << endl; output << Yp << endl; } prima.print(output); //**** // prima.SaveNet (save); /* RFNet seconda; int a =seconda.LoadNet ("Net.ini","C:\\Yarp\\src\\experiments\\babybot\\RFWR\\"); if (a == YARP_FAIL ) { cout << "Problemi con il file "<< endl; return 1; } seconda.print(); */ output.close(); //**** input.close();//---- // save.close(); return 0; }
void panel_draw(HDC hdc,panel_t *panel) { WCHAR buf[BUFLEN]; POINT p; HRGN rgn=0; int cur_i; int i; int idofs=PAN_ENT*panel->index+PAN_ENT; int x=Xp(panel),y=Yp(panel); int ofsx=D(PNLITEM_OFSX),ofsy=D(PNLITEM_OFSY); int wy=D(PANEL_WY+idofs); if(XP(panel)<0)return; //if(panel_lasti/256!=panel->index)return; GetCursorPos(&p); ScreenToClient(hMain,&p); cur_i=panel_hitscan(panel,p.x,p.y); if(!D(PANEL_WY+idofs))return; for(i=0;i<panel->items[0].action_id+1;i++) { if(i==1&&panel->index==0) { wsprintf(buf,L"%s",STR(STR_SYSINF_MOTHERBOARD)); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+SYSINFO_COL1,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s",STR(STR_SYSINF_ENVIRONMENT)); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+SYSINFO_COL2,y+ofsy,buf,wcslen(buf)); } if(i==2&&panel->index==0) { wsprintf(buf,L"%s (%d-bit)",get_winverstr(manager_g),manager_g->matcher->state->architecture?64:32); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL0,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s",state_getproduct(manager_g->matcher->state)); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL1,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s",STR(STR_SYSINF_WINDIR)); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL2,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s",manager_g->matcher->state->text+manager_g->matcher->state->windir); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL3,y+ofsy,buf,wcslen(buf)); } if(i==3&&panel->index==0) { if(XP(panel)<10+SYSINFO_COL1) wsprintf(buf,L"%s",state_getproduct(manager_g->matcher->state)); else wsprintf(buf,L"%s",manager_g->matcher->state->platform.szCSDVersion); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL0,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s: %s",STR(STR_SYSINF_TYPE),STR(isLaptop?STR_SYSINF_LAPTOP:STR_SYSINF_DESKTOP)); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL1,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s",STR(STR_SYSINF_TEMP)); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL2,y+ofsy,buf,wcslen(buf)); wsprintf(buf,L"%s",manager_g->matcher->state->text+manager_g->matcher->state->temp); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx+10+SYSINFO_COL3,y+ofsy,buf,wcslen(buf)); } if(panel->items[i].type==TYPE_GROUP_BREAK&&!expertmode)break; switch(panel->items[i].type) { case TYPE_CHECKBOX: drawcheckbox(hdc,x+ofsx,y+ofsy,D(CHKBOX_SIZE)-2,D(CHKBOX_SIZE)-2,panel->items[i].checked,i==cur_i); SetTextColor(hdc,D(i==cur_i?CHKBOX_TEXT_COLOR_H:CHKBOX_TEXT_COLOR)); TextOut(hdc,x+D(CHKBOX_TEXT_OFSX)+ofsx,y+ofsy,STR(panel->items[i].str_id),wcslen(STR(panel->items[i].str_id))); if(i==cur_i&&kbpanel)drawrectsel(hdc,x+ofsx,y+ofsy,x+XP(panel)-ofsx,y+ofsy+wy,0xff00,1); y+=D(PNLITEM_WY); break; case TYPE_BUTTON: if(panel->index>=8&&panel->index<=10&&D(PANEL_OUTLINE_WIDTH+idofs)<0) box_draw(hdc,x+ofsx,y+ofsy,x+XP(panel)-ofsx,y+ofsy+wy,i==cur_i?BOX_PANEL_H+panel->index*2+2:BOX_PANEL+panel->index*2+2); else box_draw(hdc,x+ofsx,y+ofsy,x+XP(panel)-ofsx,y+ofsy+wy-1,i==cur_i?BOX_BUTTON_H:BOX_BUTTON); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); if(i==1&&panel->index==8) { int j,cnt=0; itembar_t *itembar; itembar=&manager_g->items_list[RES_SLOTS]; for(j=RES_SLOTS;j<manager_g->items_handle.items;j++,itembar++) if(itembar->checked)cnt++; wsprintf(buf,L"%s (%d)",STR(panel->items[i].str_id),cnt); TextOut(hdc,x+ofsx+wy/2,y+ofsy+(wy-D(FONT_SIZE)-2)/2,buf,wcslen(buf)); } else TextOut(hdc,x+ofsx+wy/2,y+ofsy+(wy-D(FONT_SIZE)-2)/2,STR(panel->items[i].str_id),wcslen(STR(panel->items[i].str_id))); y+=D(PNLITEM_WY); break; case TYPE_TEXT: if(i==1&&panel->index==7) { version_t v; v.d=atoi(SVN_REV_D); v.m=atoi(SVN_REV_M); v.y=SVN_REV_Y; wsprintf(buf,L"%s (",TEXT(SVN_REV2)); str_date(&v,buf+wcslen(buf)); wcscat(buf,L")"); SetTextColor(hdc,D(CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx,y+ofsy,buf,wcslen(buf)); } SetTextColor(hdc,D(i==cur_i&&i>11?CHKBOX_TEXT_COLOR_H:CHKBOX_TEXT_COLOR)); TextOut(hdc,x+ofsx,y+ofsy,STR(panel->items[i].str_id),wcslen(STR(panel->items[i].str_id))); y+=D(PNLITEM_WY); break; case TYPE_GROUP_BREAK: case TYPE_GROUP: if(panel->index>=8&&panel->index<=10)break; if(i)y+=D(PNLITEM_WY); box_draw(hdc,x,y,x+XP(panel),y+(wy)*panel->items[i].action_id+ofsy*2, BOX_PANEL+panel->index*2+2); rgn=CreateRectRgn(x,y,x+XP(panel),y+(wy)*panel->items[i].action_id+ofsy*2); SelectClipRgn(hdc,rgn); break; default: break; } } if(rgn) { SelectClipRgn(hdc,0); DeleteObject(rgn); } }