void ApplyFit (std::vector< RVec > &b, double x, double y, double z, double A, double B, double C) {
RVec temp;
- //#pragma omp parallel
- //{
- //#pragma omp for schedule(dynamic)
+ #pragma omp parallel
+ {
+ #pragma omp for schedule(dynamic)
for (int i = 0; i < b.size(); i++) {
temp = b[i];
b[i][0] = (temp[2] + z) * (sin(A) * sin(C) + cos(A) * cos(C) * sin(B)) - (temp[1] + y) * (cos(A) * sin(C) - cos(C) * sin(A) * sin(B)) + cos(B) * cos(C) * (temp[0] + x);
b[i][1] = (temp[1] + y) * (cos(A) * cos(C) + sin(A) * sin(B) * sin(C)) - (temp[2] + z) * (cos(C) * sin(A) - cos(A) * sin(B) * sin(C)) + cos(B) * sin(C) * (temp[0] + x);
b[i][2] = cos(A) * cos(B) * (temp[2] + z) - sin(B) * (temp[0] + x) + cos(B) * sin(A) * (temp[1] + y);
}
- //}
+ }
}
void CalcMid (std::vector< RVec > a, std::vector< RVec > b, RVec &midA, RVec &midB, std::vector< std::pair< int, int > > pairs) {
f1 += F(a[pairs[i].first][0], a[pairs[i].first][1], a[pairs[i].first][2], b[pairs[i].second][0] + x, b[pairs[i].second][1] + y, b[pairs[i].second][2] + z, A, B, C);
}
if (FtCnst == 0) {
- FtCnst = 0.00001;
+ FtCnst = 0.0001;
}
if (f1 == 0) {
return;
} else {
- int count = 0;
+ //int count = 0;
while (f1 - f2 < 0 || f1 - f2 > FtCnst) {
f1 = 0; fx = 0; fy = 0; fz = 0; fa = 0; fb = 0; fc = 0;
for (int i = 0; i < pairs.size(); i++) {
for (int i = 0; i < pairs.size(); i++) {
f2 += F(a[pairs[i].first][0], a[pairs[i].first][1], a[pairs[i].first][2], b[pairs[i].second][0] + (x - l * fx), b[pairs[i].second][1] + (y - l * fy), b[pairs[i].second][2] + (z - l * fz), A - l * fa, B - l * fb, C - l * fc);
}
- count++;
+ //count++;
if (f2 < f1) {
x -= l * fx; y -= l * fy; z -= l * fz; A -= l * fa; B -= l * fb; C -= l * fc;
fx = 0; fy = 0; fz = 0; fa = 0; fb = 0; fc = 0;
break;
} else {
- l *= 0.85; // may be put somewhere l > 0
+ l *= 0.99; // may be put somewhere l > 0
}
}
- count++;
}
+ //std::cout << " " << count << "\n";
ApplyFit(b, x, y, z, A, B, C);
}
}
std::vector< std::vector < RVec > > clone;
clone.resize(0);
clone.resize(prs.size(), trj[i]);
+ std::chrono::time_point<std::chrono::system_clock> now1, now2;
for (int j = 0; j < prs.size(); j++) {
+ now1 = std::chrono::system_clock::now();
MyFitNew(trj[0], clone[j], prs[j], FC);
+ now2 = std::chrono::system_clock::now();
+ std::cout << " " << std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count() << "\n";
for (int k = 0; k < prs[j].size(); k++) {
trj[i][prs[j][k].first] = clone[j][prs[j][k].first];
}
std::vector< std::vector< std::pair< int, int > > > pairs;
int frames = 0;
int method = 1;
- double FitConst = 0.0001;
+ double FitConst = 0;
std::string OutPutTrjName;
t_trxstatus *op;
};