double f22(double k,void * params) /* No integral before the deltaM*/ { double alpha = *(double *) params; double f1 = pow(k,2.0) / (2 * pow(M_PI,2.0)); double f2 = Pk( k) * pow(Windowfunc( k,Radius(alpha)),2.0) ; double f = f1 * f2; return sqrt(f); }
void P_graded(vector<double> &P, const vector<double> &par, const NumericMatrix &Theta, const NumericVector &ot, const int &N, const int &nfact, const int &nint, const int &itemexp, const int &israting) { const int parsize = par.size(); vector<double> a(nfact); for(int i = 0; i < nfact; ++i) a[i] = par[i]; vector<double> d(nint, 0.0); if(israting){ const double t = par[parsize-1]; for(int i = nfact; i < parsize - 1; ++i) d[i - nfact] = par[i] + t; } else { for(int i = nfact; i < parsize; ++i) d[i - nfact] = par[i]; } int notordered = 0; for(int i = 1; i < nint; ++i) notordered += d[i-1] <= d[i]; if(notordered){ for(int i = 0; i < P.size(); ++i) P[i] = 0.0; } else { const double nullzero = 0.0, nullone = 1.0; NumericMatrix Pk(N, nint + 2); for(int i = 0; i < N; ++i) Pk(i,0) = 1.0; for(int i = 0; i < nint; ++i){ vector<double> tmp1(N), tmp2(N); itemTrace(tmp1, tmp2, a, &d[i], Theta, &nullzero, &nullone, ot); for(int j = 0; j < N; ++j) Pk(j,i+1) = tmp2[j]; } if(itemexp){ int which = N * (nint + 1) - 1; for(int i = (Pk.ncol()-2); i >= 0; --i){ for(int j = (N-1); j >= 0; --j){ P[which] = Pk(j,i) - Pk(j,i+1); if(P[which] < 1e-20) P[which] = 1e-20; else if((1.0 - P[which]) < 1e-20) P[which] = 1.0 - 1e-20; --which; } } } else { int which = 0; for(int i = 0; i < Pk.ncol(); ++i){ for(int j = 0; j < Pk.nrow(); ++j){ P[which] = Pk(j,i); ++which; } } } } }
void getScale(short *mirror, short *result, int height, int width, int delay, float ix, float iy) { int i, j; // int n, m; float a, b; //float pn, pm; __m128 pm, pn_1, pn0, pn1, pn2; __m128 sum_1, sum0, sum1, sum2; int size = height*iy; int depth = width+2*delay; float sum; #pragma omp parallel private(i, j, sum, a, pn_1, pn0, pn1, pn2, pm, sum_1, sum0, sum1, sum2) { #pragma omp for for (i = 0; i < size; i++) { for (j = 0; j < width*ix; j++) { // sum = 0.0f; a = ((float) i)/ix - ((int) i/ix); b = ((float) j)/iy - ((int) j/iy); //Get all pn pn_1 = _mm_set1_ps(Pk(-1 - a)); pn0 = _mm_set1_ps(Pk(- a)); pn1 = _mm_set1_ps(Pk(1 - a)); pn2 = _mm_set1_ps(Pk(2 - a)); //get all pm pm = _mm_set_ps(Pk(b-2),Pk(b-1),Pk(b),Pk(b+1)); //tmp mul pn*pm pn_1 = _mm_mul_ps(pm,pn_1); pn0 = _mm_mul_ps(pm,pn0); pn1 = _mm_mul_ps(pm,pn1); pn2 = _mm_mul_ps(pm,pn2); //get all mirror pos sum_1 = _mm_cvtepi32_ps(_mm_setr_epi32( mirror INDEX ((int) (i/ix+delay-1), (int) (j/iy+delay-1), depth), mirror INDEX ((int) (i/ix+delay-1), (int) (j/iy+delay), depth), mirror INDEX ((int) (i/ix+delay-1), (int) (j/iy+delay+1), depth), mirror INDEX ((int) (i/ix+delay-1), (int) (j/iy+delay+2), depth))); sum0 = _mm_cvtepi32_ps(_mm_setr_epi32( mirror INDEX ((int) (i/ix+delay), (int) (j/iy+delay-1), depth), mirror INDEX ((int) (i/ix+delay), (int) (j/iy+delay), depth), mirror INDEX ((int) (i/ix+delay), (int) (j/iy+delay+1), depth), mirror INDEX ((int) (i/ix+delay), (int) (j/iy+delay+2), depth))); sum1 = _mm_cvtepi32_ps(_mm_setr_epi32( mirror INDEX ((int) (i/ix+delay+1), (int) (j/iy+delay-1), depth), mirror INDEX ((int) (i/ix+delay+1), (int) (j/iy+delay), depth), mirror INDEX ((int) (i/ix+delay+1), (int) (j/iy+delay+1), depth), mirror INDEX ((int) (i/ix+delay+1), (int) (j/iy+delay+2), depth))); sum2 = _mm_cvtepi32_ps(_mm_setr_epi32( mirror INDEX ((int) (i/ix+delay+2), (int) (j/iy+delay-1), depth), mirror INDEX ((int) (i/ix+delay+2), (int) (j/iy+delay), depth), mirror INDEX ((int) (i/ix+delay+2), (int) (j/iy+delay+1), depth), mirror INDEX ((int) (i/ix+delay+2), (int) (j/iy+delay+2), depth))); //get sum for all mirror pos sum_1 = _mm_mul_ps(sum_1, pn_1); sum0 = _mm_mul_ps(sum0, pn0); sum1 = _mm_mul_ps(sum1, pn1); sum2 = _mm_mul_ps(sum2, pn2); //sum all record sse for mirror pos *pn*pm sum_1 = _mm_add_ps(sum_1, sum0); sum1 = _mm_add_ps(sum1, sum2); sum_1 = _mm_add_ps(sum_1, sum1); sum_1 = _mm_hadd_ps(sum_1, sum_1); sum_1 = _mm_hadd_ps(sum_1, sum_1); _mm_store_ss(&sum, sum_1); result INDEX(i, j, (int) (width*ix)) = (int) sum; } } } }
__m128 Pm(float b){ return _mm_set_ps(Pk(b-2),Pk(b-1),Pk(b),Pk(b+1)); }