コード例 #1
0
ファイル: fit.c プロジェクト: reflectometry/garefl
static void
partial_point(fitinfo *fit, int k, Real Q[],
	      Real A[], Real B[], Real C[], Real D[],
	      int weighted, int *df, Real *sumsq)
{
  /* FIXME don't remove this without fixing fit_w?sumsq.  In particular,
     it is now assuming fitQ matches data.Q, which is not true for this
     code.  The underlying problem is that the theory calculation points
     not correspond to the data points, either because there are multiple
     points with the same resolution or because all four cross sections
     are not measured at every Q value or because thick layers requires
     oversampling in Q to avoid aliasing effects.
   */
  assert(1==0);
  if (A[k] == NOVALUE) {
    /* Set next point */
    fit->fitQ = Q+k;
    fit->fitA = A+k;
    fit->fitB = B+k;
    fit->fitC = C+k;
    fit->fitD = D+k;

    /* Compute reflectivity */
    if (fit->datatype == FIT_REAL) calc_real(fit);
    else if (fit->datatype == FIT_IMAGINARY) calc_imaginary(fit);
    else calc_magnitude(fit);

    /* Accumulate sumsq */
    if (weighted) fit_wsumsq(fit,df,sumsq);
    else fit_sumsq(fit,df,sumsq);
  }
}
コード例 #2
0
ファイル: fit.c プロジェクト: reflectometry/garefl
void fit_update(fitinfo *fit, int approx)
{
  int worksize = 0;

  /* Find the Q points at which we need to calculate the theory */
  find_target_Q(fit);

  /* For convolution, we need one Real per Q value. */
  if (worksize < fit->nQ) worksize += fit->nQ;
  extend_work(fit,worksize);

  /* Calculate the theory */
  model_profile(&fit->m, &fit->p);
  if (fit->datatype == FIT_REAL) calc_real(fit);
  else if (fit->datatype == FIT_IMAGINARY) calc_imaginary(fit);
  else if (approx && fit->datatype != FIT_POLARIZED) calc_approx(fit);
  else calc_magnitude(fit);
}
コード例 #3
0
ファイル: fit.c プロジェクト: reflectometry/garefl
void fit_portion_update(fitinfo *fit, Real portion)
{
  int worksize = 0;

  /* Generate the profile from the model */
  model_profile(&fit->m, &fit->p);

  /* For convolution, we need one Real per Q value. */
  if (worksize < fit->totalQ) worksize += fit->totalQ;
  extend_work(fit,worksize);

  if (portion > 0.9) { /* Must save at least 10% */
    /* Cheat: don't copy subQ.  Instead need to be able to find
     * the memory allocated for it, which is allQ+n.
     */
    fit->fitQ = fit->allQ;
    fit->nQ = fit->totalQ;
  } else {
    /* Weight Q selection according to Qc */
    Real rhoV = fit->m.rho[0];
    Real rhoS = fit->m.rho[fit->m.n-1];
    Real pQc, mQc;
    if (rhoS<=rhoV) {
      mQc = -sqrt(16.*M_PI*(rhoV-rhoS));
      pQc = 0.;
    } else {
      mQc = 0.;
      pQc = sqrt(16.*M_PI*(rhoS-rhoV));
    }
    fit->fitQ = fit->allQ + fit->totalQ;
    fit->nQ = generate_subset(fit->totalQ, fit->allQ ,fit->fitQ,
			      mQc, pQc, portion);
  }

  if (fit->datatype == FIT_REAL) calc_real(fit);
  else if (fit->datatype == FIT_IMAGINARY) calc_imaginary(fit);
  else calc_magnitude(fit);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: fujiisoup/MyLibrary
int main(){
	calc_real();
//	calc_complex();
}