/*
 * Simple implementation of the Sherpa beta1D model as a user model
 *
 * Unlike the "ascfit" usermodel version we just need to provide a
 * routine that will evaluate the model. The user_model.c file
 * contains routines that handle the S-Lang interface.
 *
 * Both *.c files need editing if you want to add your own model(s).
 */

#include <math.h>

/* prototype */
void evaluate_beta1d(double r0,
		     double beta,
		     double xpos,
		     double ampl,
		     double *x,
		     double *y,
		     int nelem);

/*
 * This routine evaluates the model and fills in the output array
 */
void evaluate_beta1d(double r0,
		     double beta,
		     double xpos,
		     double ampl,
		     double *x,
		     double *y,
		     int nelem)
{
  double powterm, r02;
  int i;

  /*
   * Evaluate:
   *   f(x) = A (1+[(x-xpos)/r_o]^2)^(-3*beta+1/2)
   */
  powterm = 0.5 - 3.0 * beta;
  r02 = r0 * r0;
  for(i = 0; i < nelem; i++)
  {
    y[i] =
      ampl * pow (1.0 + (x[i] - xpos)*(x[i] - xpos)/r02, powterm);
  }
}

/* End */
