本文整理汇总了C++中CopyVector函数的典型用法代码示例。如果您正苦于以下问题:C++ CopyVector函数的具体用法?C++ CopyVector怎么用?C++ CopyVector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CopyVector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_genrand
void DESolver::Setup( double *min, double *max, int deStrategy, double diffScale,
double crossoverProb, double ftol, unsigned long rngSeed )
{
int i;
strategy = deStrategy;
scale = diffScale;
probability = crossoverProb;
tolerance = ftol;
// PE: seed the (Mersenne Twister) RNG
if (rngSeed > 0)
init_genrand(rngSeed);
else
init_genrand((unsigned long)time((time_t *)NULL));
CopyVector(minBounds, min);
CopyVector(maxBounds, max);
for (i = 0; i < nPop; i++) {
for (int j = 0; j < nDim; j++)
Element(population,i,j) = RandomUniform(min[j], max[j]);
popEnergy[i] = 1.0E20;
}
for (i = 0; i < nDim; i++)
bestSolution[i] = 0.0;
}
示例2: operator
//assumes normalized normals
bool operator () (const dContactGeom& a,const dContactGeom& b)
{
Vector3 ax,bx;
CopyVector(ax,a.pos);
CopyVector(bx,b.pos);
return ax.distanceSquared(bx) < Sqr(ptol);
}
示例3: CopyString
void HouseTypeExt::ExtData::InheritSettings(HouseTypeClass *pThis) {
if(auto ParentCountry = HouseTypeClass::Find(pThis->ParentCountry)) {
if(const auto ParentData = HouseTypeExt::ExtMap.Find(ParentCountry)) {
CopyString(&HouseTypeExt::ExtData::FlagFile, ParentData, this);
CopyString(&HouseTypeExt::ExtData::ObserverFlag, ParentData, this);
CopyString(&HouseTypeExt::ExtData::ObserverBackground, ParentData, this);
CopyString(&HouseTypeExt::ExtData::LSFile, ParentData, this);
CopyString(&HouseTypeExt::ExtData::LSPALFile, ParentData, this);
CopyString(&HouseTypeExt::ExtData::TauntFile, ParentData, this);
CopyString(&HouseTypeExt::ExtData::LSName, ParentData, this);
CopyString(&HouseTypeExt::ExtData::LSSpecialName, ParentData, this);
CopyString(&HouseTypeExt::ExtData::LSBrief, ParentData, this);
CopyString(&HouseTypeExt::ExtData::StatusText, ParentData, this);
this->LoadTextColor = ParentData->LoadTextColor;
this->RandomSelectionWeight = ParentData->RandomSelectionWeight;
this->CountryListIndex = ParentData->CountryListIndex + 1;
this->ObserverBackgroundSHP = ParentData->ObserverBackgroundSHP;
this->ObserverFlagSHP = ParentData->ObserverFlagSHP;
this->ObserverFlagYuriPAL = ParentData->ObserverFlagYuriPAL;
this->ParaDropPlane.Set(ParentData->ParaDropPlane);
this->Parachute_Anim.Set(ParentData->Parachute_Anim);
CopyVector(&HouseTypeExt::ExtData::Powerplants, ParentData, this);
CopyVector(&HouseTypeExt::ExtData::ParaDrop, ParentData, this);
CopyVector(&HouseTypeExt::ExtData::ParaDropNum, ParentData, this);
CopyStdVector(&HouseTypeExt::ExtData::VeteranBuildings, ParentData, this);
}
}
this->SettingsInherited = true;
}
示例4: SetCovs
/* SetCovs: set covariance values in hmm */
void SetCovs(void)
{
int i,s,m;
StateElem *se;
StreamElem *ste;
MixtureElem *me;
MixPDF *mp;
CalcCovs();
if (trace&T_TOP) {
printf("Updating HMM ");
if (meanUpdate) printf("Means and ");
printf("Covariances\n");
}
for (i=2,se=hmmLink->svec+2; i < hmmLink->numStates; i++,se++)
for (s=1,ste=se->info->pdf+1; s <= hset.swidth[0]; s++,ste++)
for (m=1,me = ste->spdf.cpdf+1; m<=ste->nMix; m++, me++) {
mp = me->mpdf;
if (meanUpdate && !IsSeenV(mp->mean)){ /* meanSum now holds mean */
CopyVector(accs[s].meanSum,mp->mean);
TouchV(mp->mean);
}
if (!IsSeenV(mp->cov.var)){
if (mp->ckind==FULLC)
CopyMatrix(accs[s].fixed.inv,mp->cov.inv);
else if (fullcNeeded[s]) /* dont need full cov, but its all we have */
TriDiag2Vector(accs[s].fixed.inv,mp->cov.var);
else
CopyVector(accs[s].fixed.var,mp->cov.var);
TouchV(mp->cov.var);
}
}
ClearSeenFlags(&hset,CLR_ALL);
}
示例5: SetQuaterniond
DexAnalogMixin::DexAnalogMixin( void ) {
Quaternion align, flip;
// Define the rotation of the ATI sensors with respect to the local
// manipulandum reference frame. These are probably constants,
// but perhaps they should be read from the model-specific parameter file as well.
ATIRotationAngle[LEFT_ATI] = LEFT_ATI_ROTATION;
ATIRotationAngle[RIGHT_ATI] = RIGHT_ATI_ROTATION;
// Compute the transformations to put ATI forces in a common reference frame.
// The local manipulandum reference frame should align with
// the world reference frame when the manipulandum is held upright in the seated posture.
SetQuaterniond( ftAlignmentQuaternion[0], ATIRotationAngle[0], kVector );
SetQuaterniond( align, ATIRotationAngle[1], kVector );
SetQuaterniond( flip, 180.0, iVector );
MultiplyQuaternions( ftAlignmentQuaternion[1], flip, align );
// Set a default filter constant.
SetFilterConstant( 100.0 );
// Initialize some instance variables used to hold the current state
// when filtering certain vector values.
CopyVector( filteredManipulandumPosition, zeroVector );
CopyVector( filteredManipulandumRotations, zeroVector );
CopyVector( filteredLoadForce, zeroVector );
CopyVector( filteredAcceleration, zeroVector );
for (int ati = 0; ati < N_FORCE_TRANSDUCERS; ati++ ) CopyVector( filteredCoP[ati], zeroVector );
filteredGripForce = 0.0;
}
示例6: GetContacts
///Will produce bogus o1 and o2 vectors
void GetContacts(dBodyID a,vector<ODEContactList>& contacts)
{
if(a == 0) return;
contacts.resize(0);
for(list<ODEContactResult>::iterator i=gContacts.begin();i!=gContacts.end();i++) {
if(a == dGeomGetBody(i->o1) || a == dGeomGetBody(i->o2)) {
dBodyID b = dGeomGetBody(i->o2);
bool reverse = false;
if(b == a) { b = dGeomGetBody(i->o1); reverse = true; }
contacts.resize(contacts.size()+1);
contacts.back().points.resize(i->contacts.size());
contacts.back().forces.resize(i->feedback.size());
for(size_t j=0;j<i->feedback.size();j++) {
CopyVector(contacts.back().forces[j],i->feedback[j].f1);
CopyVector(contacts.back().points[j].x,i->contacts[j].pos);
CopyVector(contacts.back().points[j].n,i->contacts[j].normal);
//contacts.back().points[j].kFriction = i->contacts[j].surface.mu;
contacts.back().points[j].kFriction = 0;
if(reverse) {
contacts.back().forces[j].inplaceNegative();
contacts.back().points[j].n.inplaceNegative();
}
}
}
}
}
示例7: EnergyFunction
bool DESolver::Solve(int maxGenerations)
{
int generation;
int candidate;
bool bAtSolution;
bestEnergy = 1.0E20;
bAtSolution = false;
for (generation=0;(generation < maxGenerations) && !bAtSolution;generation++)
for (candidate=0; candidate < nPop; candidate++)
{
(this->*calcTrialSolution)(candidate);
trialEnergy = EnergyFunction(trialSolution,bAtSolution);
if (trialEnergy < popEnergy[candidate])
{
// New low for this candidate
popEnergy[candidate] = trialEnergy;
CopyVector(RowVector(population,candidate),trialSolution);
// Check if all-time low
if (trialEnergy < bestEnergy)
{
bestEnergy = trialEnergy;
CopyVector(bestSolution,trialSolution);
}
}
}
generations = generation;
return(bAtSolution);
}
示例8: CopyVector
Frustrum::Frustrum( double near_v[3], double far_v[3] ) {
CopyVector( near_vertex, near_v );
CopyVector( far_vertex, far_v );
multi_color = true;
OpenGLObject(); // Do what every OpenGlObject does at creation.
}
示例9: CHContactsPlane
/** Two ways of merging frictionless contacts without resorting to 6D
* wrench space
* 1) interior points in 2D convex hull, with the projection defined
* by the contact normal
* 2) interior points in convex cone at a single contact point (TODO)
*
* If contacts have friction, the convex hull method only works when the
* points are on the same plane.
*/
void CHContactsPlane(vector<dContactGeom>& contacts)
{
if(contacts.empty()) return;
if(contacts.size() <= 2) return;
Vector3 c(Zero),n(Zero);
for(size_t i=0;i<contacts.size();i++) {
Vector3 cx,nx;
CopyVector(cx,contacts[i].pos);
CopyVector(nx,contacts[i].normal);
c += cx;
n += nx;
}
c /= contacts.size();
n.inplaceNormalize();
//get the deepest contact
size_t deepest = 0;
for(size_t i=1;i<contacts.size();i++)
if(contacts[i].depth > contacts[deepest].depth) deepest=i;
//make a plane
Vector3 x,y;
n.getOrthogonalBasis(x,y);
//Real nofs = n.dot(c);
Real xofs = x.dot(c);
Real yofs = y.dot(c);
vector<Vector2> pt2d(contacts.size());
for(size_t i=0;i<contacts.size();i++) {
Vector3 cx;
CopyVector(cx,contacts[i].pos);
pt2d[i].x = x.dot(cx)-xofs;
pt2d[i].y = y.dot(cx)-yofs;
}
//get the convex hull
vector<Vector2> ch(contacts.size());
vector<int> mapping(contacts.size());
int num=Geometry::ConvexHull2D_Chain_Unsorted(&pt2d[0],contacts.size(),&ch[0],&mapping[0]);
vector<dContactGeom> temp(num);
bool addDeepest = true;
for(int i=0;i<num;i++) {
Assert(mapping[i] < (int)contacts.size());
temp[i] = contacts[mapping[i]];
if(mapping[i] == (int)deepest)
addDeepest = false;
}
if(addDeepest)
temp.push_back(contacts[deepest]);
swap(temp,contacts);
}
示例10: PutVFloor
/* PutVFloor: output variance floor vectors */
void PutVFloor(void)
{
int i,s;
char outfn[MAXSTRLEN],vName[32],num[10];
FILE *f;
Vector v;
MakeFN("vFloors",outDir,NULL,outfn);
if ((f = fopen(outfn,"w")) == NULL)
HError(2011,"PutVFloor: cannot create %s",outfn);
for (s=1; s <= hset.swidth[0]; s++) {
v = CreateVector(&gstack,hset.swidth[s]);
sprintf(num,"%d",s);
strcpy(vName,"varFloor"); strcat(vName,num);
fprintf(f,"~v %s\n",vName);
if (fullcNeeded[s])
TriDiag2Vector(accs[s].squareSum.inv,v);
else
CopyVector(accs[s].fixed.var,v);
for (i=1; i<=hset.swidth[s]; i++)
v[i] *= vFloorScale;
fprintf(f,"<Variance> %d\n",hset.swidth[s]);
WriteVector(f,v,FALSE);
FreeVector(&gstack,v);
}
fclose(f);
if (trace&T_TOP)
printf("Var floor macros output to file %s\n",outfn);
}
示例11: UpdateControlsForSelection
void ExternalToolsDialog::Apply()
{
// If a tool doesn't have a name, give it one since this prevents
// us from putting it in the menu.
int selectedItem = m_listBox->GetSelection();
for (unsigned int i = 0; i < m_workingTools.size(); ++i)
{
ExternalTool* tool = m_workingTools[i];
if (tool->GetTitle().IsEmpty())
{
tool->SetTitle("Unnamed Tool");
m_listBox->Delete(i);
m_listBox->Insert(tool->GetTitle(), i);
}
}
m_listBox->SetSelection(selectedItem);
UpdateControlsForSelection(selectedItem);
// Apply the changes.
CopyVector(*m_appliedTools, m_workingTools);
}
示例12: estimate_lambda_storey04
/* Estimating best value of lambda via minimising the mean squared error
* under bootstraps (see Storey 04, and note that the bootstrapping has
* an analytical solution since W(lambda) is binomial).
* Lambda restricted to [0,max pval)
*/
double estimate_lambda_storey04 ( const double * pval, const unsigned int m ){
assert(NULL!=pval);
/* Sort pvals */
double * pval_sort = CopyVector(pval,malloc(m*sizeof(double)),m);
qsort(pval_sort,m,sizeof(double),CmpDouble);
/* Find pi_star, min_lambda pi_0(lambda) */
double pi_star = 1.;
for ( unsigned int i=0 ; i<m ; i++){
double pi_0 = (double)(m-i-1)/(double)(m*(1.-pval_sort[i]));
if ( pi_0 < pi_star){ pi_star = pi_0; }
}
double lambda_min = 0.;
double mse_min = (1. - pi_star)*(1. - pi_star);
for ( unsigned int i=0 ; i<m-1 ; i++){
const double lambda = pval_sort[i];
const double p = (m-i-1)/(double)m;
const double pi_0 = p/(1.-lambda);
const double mse = p*(1-p)/((1.-lambda)*(1.-lambda))
+ pi_0*pi_0
- 2*pi_star*pi_0
+ pi_star*pi_star;
if (mse<mse_min){
mse_min = mse;
lambda_min = pval_sort[i];
}
}
free(pval_sort);
return lambda_min;
}
示例13: MakeWtAccLists
/* MakeWtAccLists: Copy info from WtAcc to WALink and add WALink to wtStore,
Zero WtAcc afterwards */
void MakeWtAccLists()
{
int ix,n,s,i,nMix;
HMMScanState hss;
HLink hmm;
WALink *w;
StateElem *se;
StreamElem *ste;
WtAcc *wa;
NewHMMScan(&hset,&hss);
ix=1;
do {
hmm = hss.hmm;
for (i=2,se = hmm->svec+2; i<hmm->numStates;i++,se++)
for (s=1,ste = se->info->pdf+1; s<=nStreams; s++,ste++){
w = &(wtStore[ix][i][s]); n = 0;
while (*w != NULL){
++n; w = &((*w)->next);
}
nMix = (hset.hsKind==TIEDHS) ? hset.tmRecs[s].nMix : ste->nMix;
(*w) = CreateChWtAcc(&wtAccStack, nMix);
wa = (WtAcc *)ste->hook;
CopyVector(wa->c,(*w)->c);
(*w)->occ = wa->occ;
wa->occ = 0;
ZeroVector(wa->c);
}
ix++;
} while (GoNextHMM(&hss));
EndHMMScan(&hss);
}
示例14: SetRotamersSimilarToPDB
/****************************************************************************
Assign rotamer to be close to that in PDB, and calcualte cartesian coordinates
*****************************************************************************/
void SetRotamersSimilarToPDB(int nc, struct s_polymer *p, struct atom_s *a, int napdb)
{
int ic,i,ir=0,irotmin,iaa,is,ipdb,found;
struct vector pdb[ROT_ATMAX],cpol[ROT_ATMAX];
double rmsd2min=99999.,x;
fprintf(stderr,"Set rotamers close to those of PDB\n");
for(ic=0;ic<nc;ic++)
for(i=0;i<(p+ic)->nback;i++)
if (!strcmp( (((p+ic)->back)+i)->type , "CA" ) && (((p+ic)->back)+i)->nside>0) // loop on all CA atoms
{
iaa = (((p+ic)->back)+i)->iaa;
// find positions in the pdb
for(is=1;is< (((p+ic)->back)+i)->nside; is++) // loop on sides of polymer, except CB
{
found=0;
for(ipdb=0;ipdb<napdb;ipdb++)
{
if ( (a+ipdb)->chain == ic && (a+ipdb)->iaa == iaa &&
!strcmp((a+ipdb)->atom,((((((p+ic)->back)+i)->side)+is)->type) ) )
{ CopyVector(&((a+ipdb)->pos),pdb+is-1); found=1; } // this contains the corresponding positions in the pdb
}
if (found==0) Error("Cannot find atom in SetRotamersSimilarToPDB");
}
// find the best rotamer
rmsd2min=99999.;
irotmin=0;
for(ir=0;ir< (((p+ic)->back)+i)->nrot;ir++)
{
(((p+ic)->back)+i)->irot = ir;
AddSidechain(p,i,i,ic);
for(is=1;is<(((p+ic)->back)+i)->nside; is++) CopyVector( &((((((p+ic)->back)+i)->side)+is)->pos),cpol+is-1 );
x = DumbRMSD2( pdb, cpol, (((p+ic)->back)+i)->nside-1 );
if (x<rmsd2min) { rmsd2min=x; irotmin=ir; };
}
// set rotamer and cartesian coordinates
(((p+ic)->back)+i)->irot = irotmin;
fprintf(stderr,"%d %d irotmin=%d/%d\n",ic,i,irotmin,(((p+ic)->back)+i)->nrot);
AddSidechain(p,i,i,ic);
}
}
示例15: SubtractVector
void SubtractVector(float* vector1, float* vector2, float* result) {
float temp[3];
CopyVector(vector2, temp);
for(int i=0; i<3; i++) {
temp[i] *= -1.0;
}
AddVector(vector1, temp, result);
}