本文整理汇总了C++中MCWalkerConfiguration::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ MCWalkerConfiguration::resize方法的具体用法?C++ MCWalkerConfiguration::resize怎么用?C++ MCWalkerConfiguration::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCWalkerConfiguration
的用法示例。
在下文中一共展示了MCWalkerConfiguration::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XMLReport
/** Write the set of walker configurations to the HDF5 file.
*@param W set of walker configurations
*@param ic the number of frames
*
* \if ic==-1
* use only the last frame for a restart
* \else if ic>=0
* use ic frames from the file for opitimizations
*/
bool
HDFWalkerInput0::put(MCWalkerConfiguration& W, int ic){
if(Counter<0) return false;
int selected = ic;
if(ic<0) {
XMLReport("Will use the last set from " << NumSets << " of configurations.")
selected = NumSets-1;
}
typedef MCWalkerConfiguration::PosType PosType;
typedef MCWalkerConfiguration::PropertyContainer_t ProtertyContainer_t;
typedef Matrix<PosType> PosContainer_t;
int nwt = 0;
int npt = 0;
//2D array of PosTypes (x,y,z) indexed by (walker,particle)
PosContainer_t Pos_temp;
//open the group
char GrpName[128];
sprintf(GrpName,"config%04d",selected);
hid_t group_id = H5Gopen(h_config,GrpName);
HDFAttribIO<PosContainer_t> Pos_in(Pos_temp);
//read the dataset
Pos_in.read(group_id,"coord");
//close the group
H5Gclose(group_id);
/*check to see if the number of walkers and particles is consistent with W */
int nptcl = Pos_temp.cols();
nwt = Pos_temp.rows();
int curWalker = W.getActiveWalkers();
if(curWalker) {
LOGMSG("Adding " << nwt << " walkers to " << curWalker)
W.createWalkers(nwt);
} else {
W.resize(nwt,nptcl);
}
//assign configurations to W
int iw=0;
MCWalkerConfiguration::iterator it = W.begin()+curWalker;
MCWalkerConfiguration::iterator it_end = W.end();
while(it != it_end) {
std::copy(Pos_temp[iw],Pos_temp[iw+1], (*it)->R.begin());
++it;++iw;
}
return true;
}
示例2: sprintf
bool
HDFWalkerInput0::append(MCWalkerConfiguration& W, int blocks){
if(Counter<0) return false;
//if(nwalkers<0) return put(W,-1);
typedef MCWalkerConfiguration::PosType PosType;
typedef Matrix<PosType> PosContainer_t;
PosContainer_t Pos_temp;
int nw_in=0;
int firstConf=std::max(0,NumSets-blocks);
if(blocks<0) firstConf=0;
for(int iconf=firstConf; iconf<NumSets; iconf++) {
//open the group
char GrpName[128];
sprintf(GrpName,"config%04d",iconf);
hid_t group_id = H5Gopen(h_config,GrpName);
HDFAttribIO<PosContainer_t> Pos_in(Pos_temp);
//read the dataset
Pos_in.read(group_id,"coord");
//close the group
H5Gclose(group_id);
/*check to see if the number of walkers and particles is consistent with W */
int nptcl = Pos_temp.cols();
int nwt = Pos_temp.rows();
int curWalker=0;
if(nptcl != W.getParticleNum()) {
W.resize(nwt,nptcl);
} else {
curWalker=W.getActiveWalkers();
W.createWalkers(nwt);
}
MCWalkerConfiguration::iterator it = W.begin()+curWalker;
for(int iw=0; iw<nwt; iw++) {
//std::copy(Post_temp[iw],Post_temp[iw+1], (*it)->R.begin());
for(int iat=0; iat < nptcl; iat++){
(*it)->R(iat) = Pos_temp(iw,iat);
}
++it;
}
nw_in += nwt;
}
LOGMSG("Total " << nw_in << " walkers are loaded using " << NumSets-firstConf << " blocks.")
return true;
}
示例3: sprintf
bool
HDFWalkerInputCollect::read(MCWalkerConfiguration& W, int firstConf, int lastConf) {
int myID = OHMMS::Controller->mycontext();
hid_t mastercf = H5Gopen(fileID,"config_collection");
char confName[128];
char coordName[128];
#if H5_VERS_RELEASE < 4
hssize_t offset[3];
#else
hsize_t offset[3];
#endif
hsize_t dimIn[3],dimTot[3];
offset[0]=0;
offset[1]=0;
offset[2]=0;
typedef MCWalkerConfiguration::PosType PosType;
vector<PosType> pos;
int nwRead=0;
for(int iconf=firstConf; iconf<lastConf; iconf++) {
sprintf(coordName,"config%04d/coord",iconf);
hid_t dataset = H5Dopen(mastercf,coordName);
hid_t dataspace = H5Dget_space(dataset);
int rank = H5Sget_simple_extent_ndims(dataspace);
int status_n = H5Sget_simple_extent_dims(dataspace, dimTot, NULL);
if(CollectMode) {
distribute(dimTot[0]);
} else {
OffSet[myID]=0;
OffSet[myID+1]=dimTot[0];
}
//get the input dimension
dimIn[0]=OffSet[myID+1]-OffSet[myID];
dimIn[1]=dimTot[1];
dimIn[2]=dimTot[2];
offset[0]=OffSet[myID];
vector<PosType> posIn(dimIn[0]*dimIn[1]);
hid_t memspace = H5Screate_simple(3, dimIn, NULL);
herr_t status = H5Sselect_hyperslab(dataspace,H5S_SELECT_SET, offset,NULL,dimIn,NULL);
status = H5Dread(dataset, H5T_NATIVE_DOUBLE, memspace, dataspace, H5P_DEFAULT, &(posIn[0][0]));
H5Sclose(memspace);
H5Dclose(dataset);
H5Sclose(dataspace);
pos.insert(pos.end(), posIn.begin(), posIn.end());
nwRead += dimIn[0];
}
H5Gclose(mastercf);
int curWalker = W.getActiveWalkers();
int nptcl=W.getTotalNum();
if(curWalker) {
W.createWalkers(nwRead);
} else {
W.resize(nwRead,nptcl);
}
MCWalkerConfiguration::iterator it = W.begin()+curWalker;
int ii=0;
for(int iw=0; iw<nwRead; iw++) {
//std::copy(Post_temp[iw],Post_temp[iw+1], (*it)->R.begin());
for(int iat=0; iat < nptcl; iat++,ii++) {
(*it)->R(iat) = pos[ii];
}
++it;
}
return true;
}