Exemplo n.º 1
0
static PyObject *
forms_show_input(PyObject *f, PyObject *args)
{
	char *str;
	char *a, *b;

	if (!PyArg_Parse(args, "(ss)", &a, &b)) return NULL;

	Py_BEGIN_ALLOW_THREADS
	str = fl_show_input(a, b);
	Py_END_ALLOW_THREADS

	if (str == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
	return PyString_FromString(str);
}
Exemplo n.º 2
0
RNG *CreateRNG() {
  FL_OBJECT *ap = the_gui->AEntry;
  FL_OBJECT *bp = the_gui->BEntry;
  FL_OBJECT *cp = the_gui->DistributionChoice;
  char buf[80];
  char *cdffn;
  double a;
  double b;
  int i;
  RNG *r;

  switch (fl_get_choice(cp)) {
  case Uniform:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new UniformRNG(a,b);
    break;
  case Binomial:
    a = atof(fl_get_input(ap));
    i = atoi(fl_get_input(bp));
    r = new BinomialRNG(a,i);
    break;
  case CDF:
    CDFRNG *cdfr;
    cdffn = (char *)fl_show_input("PDF File Name","wdist.dat");
    if (cdffn == NULL)
      return NULL;
    cdfr = new CDFRNG(cdffn);
    if (cdfr->bad()) {
      fl_show_message("Can't open PDF file",cdffn,"");
      return NULL;
    }
    sprintf(buf,"%f",cdfr->min());
    fl_set_input(ap,buf);
    sprintf(buf,"%f",cdfr->max());
    fl_set_input(bp,buf);
    r = cdfr;
    break;
  case Exponential:	
    r = new ExponentialRNG();
    break;
  case Gamma:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new GammaRNG(a,b);
    break;
  case LogNormal:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new LogNormalRNG(a,b);
    break;
  case LogNormalLog:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new LogNormalLogRNG(a,b);
    break;
  case Normal:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new NormalRNG(a,b);
    break;
  case Poisson:
    a = atof(fl_get_input(ap));
    r = new PoissonRNG(a);
    break;
  }
  return r;
}