VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry& entry) : wxDialog(parent, wxID_ANY, "Mount configuration", wxDefaultPosition) , m_entry(entry) { m_tctrl_dev_path = new wxTextCtrl(this, wxID_ANY); m_btn_select_dev_path = new wxButton(this, wxID_ANY, "..."); m_tctrl_path = new wxTextCtrl(this, wxID_ANY); m_btn_select_path = new wxButton(this, wxID_ANY, "..."); m_tctrl_mount = new wxTextCtrl(this, wxID_ANY); m_ch_type = new wxChoice(this, wxID_ANY); wxBoxSizer& s_type(*new wxBoxSizer(wxHORIZONTAL)); s_type.Add(m_ch_type, 1, wxEXPAND); wxBoxSizer& s_dev_path(*new wxBoxSizer(wxHORIZONTAL)); s_dev_path.Add(m_tctrl_dev_path, 1, wxEXPAND); s_dev_path.Add(m_btn_select_dev_path, 0, wxLEFT, 5); wxBoxSizer& s_path(*new wxBoxSizer(wxHORIZONTAL)); s_path.Add(m_tctrl_path, 1, wxEXPAND); s_path.Add(m_btn_select_path, 0, wxLEFT, 5); wxBoxSizer& s_mount(*new wxBoxSizer(wxHORIZONTAL)); s_mount.Add(m_tctrl_mount, 1, wxEXPAND); wxBoxSizer& s_btns(*new wxBoxSizer(wxHORIZONTAL)); s_btns.Add(new wxButton(this, wxID_OK)); s_btns.AddSpacer(30); s_btns.Add(new wxButton(this, wxID_CANCEL)); wxBoxSizer& s_main(*new wxBoxSizer(wxVERTICAL)); s_main.Add(&s_type, 1, wxEXPAND | wxALL, 10); s_main.Add(&s_dev_path, 1, wxEXPAND | wxALL, 10); s_main.Add(&s_path, 1, wxEXPAND | wxALL, 10); s_main.Add(&s_mount, 1, wxEXPAND | wxALL, 10); s_main.AddSpacer(10); s_main.Add(&s_btns, 0, wxALL | wxCENTER, 10); SetSizerAndFit(&s_main); SetSize(350, -1); for(const auto i : vfsDeviceTypeNames) { m_ch_type->Append(i); } Connect(m_ch_type->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectType)); Connect(m_btn_select_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectPath)); Connect(m_btn_select_dev_path->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnSelectDevPath)); Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VFSEntrySettingsDialog::OnOk)); m_tctrl_dev_path->SetValue(m_entry.device_path); m_tctrl_path->SetValue(m_entry.path); m_tctrl_mount->SetValue(m_entry.mount); m_ch_type->SetSelection(m_entry.device); wxCommandEvent ce; OnSelectType(ce); }
bool_t dat_from_rt(restable_t *rt, dat_t *dat) { uint32_t i; int32_t j; char *path; if (dat_set_numfiles(dat, rt->number) == FALSE) return FALSE; path = NULL; for(i = 0; i < rt->number; i++) { /* Добавление пути */ s_path(&path, rt->entries[i].name, DAT_PATH_DELIM); s_cut_suffix(&path, path, DAT_PATH_SDELIM); if (strlen(path) == 0) s_strcpy(&path, "."); j = dat_add_path(dat, path); s_free(&path); if (j == -1) return FALSE; dat->paths[j].numfiles++; /* Добавление файла */ s_nameext(&(dat->files[i].name), rt->entries[i].name, DAT_PATH_DELIM); dat->files[i].path = j; dat->files[i].compression = rt->entries[i].compression; dat->files[i].offset = rt->entries[i].offset; dat->files[i].size = rt->entries[i].size; if (dat->files[i].compression == 0x40) dat->files[i].compressed = rt->entries[i].compressed; else dat->files[i].compressed = 0; } return TRUE; }
void PathMSDBase::calculate(){ if(neigh_size>0 && getExchangeStep()) error("Neighbor lists for this collective variable are not compatible with replica exchange, sorry for that!"); //log.printf("NOW CALCULATE! \n"); // resize the list to full if(imgVec.empty()){ // this is the signal that means: recalculate all imgVec.resize(nframes); for(unsigned i=0;i<nframes;i++){ imgVec[i].property=indexvec[i]; imgVec[i].index=i; } } // THIS IS THE HEAVY PART (RMSD STUFF) unsigned stride=comm.Get_size(); unsigned rank=comm.Get_rank(); unsigned nat=pdbv[0].size(); plumed_assert(nat>0); plumed_assert(nframes>0); plumed_assert(imgVec.size()>0); std::vector<double> tmp_distances(imgVec.size(),0.0); std::vector<Vector> tmp_derivs; // this array is a merge of all tmp_derivs, so as to allow a single comm.Sum below std::vector<Vector> tmp_derivs2(imgVec.size()*nat); // if imgVec.size() is less than nframes, it means that only some msd will be calculated for(unsigned i=rank;i<imgVec.size();i+=stride){ // store temporary local results tmp_distances[i]=msdv[imgVec[i].index].calculate(getPositions(),tmp_derivs,true); plumed_assert(tmp_derivs.size()==nat); for(unsigned j=0;j<nat;j++) tmp_derivs2[i*nat+j]=tmp_derivs[j]; } // reduce over all processors comm.Sum(tmp_distances); comm.Sum(tmp_derivs2); // assign imgVec[i].distance and imgVec[i].distder for(unsigned i=0;i<imgVec.size();i++){ imgVec[i].distance=tmp_distances[i]; imgVec[i].distder.assign(&tmp_derivs2[i*nat],nat+&tmp_derivs2[i*nat]); } // END OF THE HEAVY PART vector<Value*> val_s_path; if(labels.size()>0){ for(unsigned i=0;i<labels.size();i++){ val_s_path.push_back(getPntrToComponent(labels[i].c_str()));} }else{ val_s_path.push_back(getPntrToComponent("sss")); } Value* val_z_path=getPntrToComponent("zzz"); vector<double> s_path(val_s_path.size());for(unsigned i=0;i<s_path.size();i++)s_path[i]=0.; double partition=0.; double tmp; // clean vector for(unsigned i=0;i< derivs_z.size();i++){derivs_z[i].zero();} typedef vector< class ImagePath >::iterator imgiter; for(imgiter it=imgVec.begin();it!=imgVec.end();++it){ (*it).similarity=exp(-lambda*((*it).distance)); //log<<"DISTANCE "<<(*it).distance<<"\n"; for(unsigned i=0;i<s_path.size();i++){ s_path[i]+=((*it).property[i])*(*it).similarity; } partition+=(*it).similarity; } for(unsigned i=0;i<s_path.size();i++){ s_path[i]/=partition; val_s_path[i]->set(s_path[i]) ;} val_z_path->set(-(1./lambda)*std::log(partition)); for(unsigned j=0;j<s_path.size();j++){ // clean up for(unsigned i=0;i< derivs_s.size();i++){derivs_s[i].zero();} // do the derivative for(imgiter it=imgVec.begin();it!=imgVec.end();++it){ double expval=(*it).similarity; tmp=lambda*expval*(s_path[j]-(*it).property[j])/partition; for(unsigned i=0;i< derivs_s.size();i++){ derivs_s[i]+=tmp*(*it).distder[i] ;} if(j==0){for(unsigned i=0;i< derivs_z.size();i++){ derivs_z[i]+=(*it).distder[i]*expval/partition;}} } for(unsigned i=0;i< derivs_s.size();i++){ setAtomsDerivatives (val_s_path[j],i,derivs_s[i]); if(j==0){setAtomsDerivatives (val_z_path,i,derivs_z[i]);} } } for(unsigned i=0;i<val_s_path.size();++i) setBoxDerivativesNoPbc(val_s_path[i]); setBoxDerivativesNoPbc(val_z_path); // // here set next round neighbors // if (neigh_size>0){ //if( int(getStep())%int(neigh_stride/getTimeStep())==0 ){ // enforce consistency: the stride is in time steps if( int(getStep())%int(neigh_stride)==0 ){ // next round do it all:empty the vector imgVec.clear(); } // time to analyze the results: if(imgVec.size()==nframes){ //sort by msd sort(imgVec.begin(), imgVec.end(), imgOrderByDist()); //resize imgVec.resize(neigh_size); } } //log.printf("CALCULATION DONE! \n"); }
int main(const carg, const char *varg[]) { char *s; int i; s = NULL; i = 0; fprintf(stdout, "s_strcpy(NULL, \"\") == FALSE: "); if (s_strcpy(NULL, "") == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncpy(NULL, \"\", 10) == FALSE: "); if (s_strncpy(NULL, "", 10) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcat(NULL, \"\") == FALSE: "); if (s_strcat(NULL, "") == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncat(NULL, \"\", 10) == FALSE: "); if (s_strncat(NULL, "", 10) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcpy(&s, NULL) == FALSE: "); if (s_strcpy(&s, NULL) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncpy(&s, NULL, 10) == FALSE: "); if (s_strncpy(&s, NULL, 10) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcat(&s, NULL) == FALSE: "); if (s_strcat(&s, NULL) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncat(&s, NULL, 10) == FALSE: "); if (s_strncat(&s, NULL, 10) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcpy(&s, \"ab\"), strcmp(s, \"ab\") == 0: "); s_strcpy(&s, "ab"); if (strcmp(s, "ab") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncpy(&s, \"ab\", 1), strcmp(s, \"a\") == 0: "); s_strncpy(&s, "ab", 1); if (strcmp(s, "a") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcat(&s, \"ab\"), strcmp(s, \"aab\") == 0: "); s_strcat(&s, "ab"); if (strcmp(s, "aab") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncat(&s, \"ab\", 1), strcmp(s, \"aaba\") == 0: "); s_strncat(&s, "ab", 1); if (strcmp(s, "aaba") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcpy(&s, \"abcdefghij klmnop\"), s_strcpy(&s, s), strcmp(s, \"abcdefghij klmnop\") == 0: "); s_strcpy(&s, "abcdefghij klmnop"); s_strcpy(&s, s); if (strcmp(s, "abcdefghij klmnop") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncpy(&s, s, 10), strcmp(s, \"abcdefghij\") == 0: "); s_strncpy(&s, s, 10); if (strcmp(s, "abcdefghij") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strcat(&s, s), strcmp(s, \"abcdefghijabcdefghij\") == 0: "); s_strcat(&s, s); if (strcmp(s, "abcdefghijabcdefghij") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_strncat(&s, s, 10), strcmp(s, \"abcdefghijabcdefghijabcdefghij\") == 0: "); s_strncat(&s, s, 10); if (strcmp(s, "abcdefghijabcdefghijabcdefghij") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_path(NULL, \"\", SYS_PATH_DELIM) == FALSE: "); if (s_path(NULL, "", SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_pathname(NULL, \"\", SYS_PATH_DELIM) == FALSE: "); if (s_pathname(NULL, "", SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_name(NULL, \"\", SYS_PATH_DELIM) == FALSE: "); if (s_name(NULL, "", SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_nameext(NULL, \"\", SYS_PATH_DELIM) == FALSE: "); if (s_nameext(NULL, "", SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_ext(NULL, \"\", SYS_PATH_DELIM) == FALSE: "); if (s_ext(NULL, "", SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_path(&s, NULL, SYS_PATH_DELIM) == FALSE: "); if (s_path(&s, NULL, SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_pathname(&s, NULL, SYS_PATH_DELIM) == FALSE: "); if (s_pathname(&s, NULL, SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_name(&s, NULL, SYS_PATH_DELIM) == FALSE: "); if (s_name(&s, NULL, SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_nameext(&s, NULL, SYS_PATH_DELIM) == FALSE: "); if (s_nameext(&s, NULL, SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_ext(&s, NULL, SYS_PATH_DELIM) == FALSE: "); if (s_ext(&s, NULL, SYS_PATH_DELIM) == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_strcpy(&s, "/path/name.ext"); s_path(&s, s, SYS_PATH_DELIM); fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_path(&s, s, SYS_PATH_DELIM), strcmp(s, \"/path/\") == 0: "); if (strcmp(s, "/path/") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_strcpy(&s, "/path/name.ext"); s_pathname(&s, s, SYS_PATH_DELIM); fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_pathname(&s, s, SYS_PATH_DELIM), strcmp(s, \"/path/name\") == 0: "); if (strcmp(s, "/path/name") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_strcpy(&s, "/path/name.ext"); s_name(&s, s, SYS_PATH_DELIM); fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_name(&s, s, SYS_PATH_DELIM), strcmp(s, \"name\") == 0: "); if (strcmp(s, "name") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_strcpy(&s, "/path/name.ext"); s_nameext(&s, s, SYS_PATH_DELIM); fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_nameext(&s, s, SYS_PATH_DELIM), strcmp(s, \"name.ext\") == 0: "); if (strcmp(s, "name.ext") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_strcpy(&s, "/path/name.ext"); s_ext(&s, s, SYS_PATH_DELIM); fprintf(stdout, "s_strcpy(&s, \"/path/name.ext\"), s_ext(&s, s, SYS_PATH_DELIM), strcmp(s, \".ext\") == 0: "); if (strcmp(s, ".ext") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } i += check_pathnameext("", "", "", "", "", ""); i += check_pathnameext("/", "/", "/", "", "", ""); i += check_pathnameext("path/", "path/", "path/", "", "", ""); i += check_pathnameext("name", "", "name", "name", "name", ""); i += check_pathnameext(".ext", "", "", "", ".ext", ".ext"); i += check_pathnameext("path/name", "path/", "path/name", "name", "name", ""); i += check_pathnameext("path/.ext", "path/", "path/", "", ".ext", ".ext"); i += check_pathnameext("name.ext", "", "name", "name", "name.ext", ".ext"); i += check_pathnameext("path/name.ext", "path/", "path/name", "name", "name.ext", ".ext"); i += check_pathnameext("path.e/", "path.e/", "path.e/", "", "", ""); i += check_pathnameext("path.e/name", "path.e/", "path.e/name", "name", "name", ""); i += check_pathnameext("path.e/.ext", "path.e/", "path.e/", "", ".ext", ".ext"); i += check_pathnameext("path.e/name.ext", "path.e/", "path.e/name", "name", "name.ext", ".ext"); fprintf(stdout, "s_sprintf(NULL, \"%%d abc %%s\", -2147483648, \"def\") == FALSE: "); if (s_sprintf(NULL, "%d abc %s", -2147483648, "def") == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "s_sprintf(&s, NULL, -2147483648, \"def\") == FALSE: "); if (s_sprintf(&s, NULL, -2147483648, "def") == FALSE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_sprintf(&s, "%d abc %s", -2147483648, "def"); fprintf(stdout, "s_sprintf(&s, \"%%d abc %%s\", -2147483648, \"def\"), strcmp(s, \"-2147483648 abc def\") == 0: "); if (strcmp(s, "-2147483648 abc def") == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } fprintf(stdout, "is_equal_files(\"%s\", \"%s\") == TRUE: ", varg[0], varg[0]); if (is_equal_files(varg[0], varg[0]) == TRUE) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed.\n"); i++; } s_free(&s); fprintf(stderr, "Found %d errors.\n", i); return i; }
int check_pathnameext(const char *pathnameext, const char *must_path, const char *must_pathname, const char *must_name, const char *must_nameext, const char *must_ext) { char *path; char *pathname; char *name; char *nameext; char *ext; int i; path = NULL; pathname = NULL; name = NULL; nameext = NULL; ext = NULL; i = 0; fprintf(stdout, "s_path(&path, \"%s\", SYS_PATH_DELIM), strcmp(path, \"%s\") == 0: ", pathnameext, must_path); s_path(&path, pathnameext, SYS_PATH_DELIM); if (strcmp(path, must_path) == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed\n"); i++; } fprintf(stdout, "s_pathname(&pathname, \"%s\", SYS_PATH_DELIM), strcmp(pathname, \"%s\") == 0: ", pathnameext, must_pathname); s_pathname(&pathname, pathnameext, SYS_PATH_DELIM); if (strcmp(pathname, must_pathname) == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed\n"); i++; } fprintf(stdout, "s_name(&name, \"%s\", SYS_PATH_DELIM), strcmp(name, \"%s\") == 0: ", pathnameext, must_name); s_name(&name, pathnameext, SYS_PATH_DELIM); if (strcmp(name, must_name) == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed\n"); i++; } fprintf(stdout, "s_nameext(&name, \"%s\", SYS_PATH_DELIM), strcmp(nameext, \"%s\") == 0: ", pathnameext, must_nameext); s_nameext(&nameext, pathnameext, SYS_PATH_DELIM); if (strcmp(nameext, must_nameext) == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed\n"); i++; } fprintf(stdout, "s_ext(&ext, \"%s\", SYS_PATH_DELIM), strcmp(ext, \"%s\") == 0: ", pathnameext, must_ext); s_ext(&ext, pathnameext, SYS_PATH_DELIM); if (strcmp(ext, must_ext) == 0) fprintf(stdout, "OK\n"); else { fprintf(stdout, "failed\n"); i++; } s_free(&path); s_free(&pathname); s_free(&name); s_free(&nameext); s_free(&ext); return i; }