예제 #1
0
void SumFunc::execute() {
  ComValue vallist(stack_arg(0));
  reset_stack();
  
  if (vallist.is_type(ComValue::ArrayType)) {
    AttributeValueList* avl = vallist.array_val();
    AddFunc addfunc(comterp());
    push_stack(ComValue::zeroval());
    Iterator it;
    int count = 0;
    for (avl->First(it); !avl->Done(it); avl->Next(it)) {
      count++;
      push_stack(*avl->GetAttrVal(it));
      addfunc.exec(2,0);
    }
    if (_meanfunc) {
      DivFunc divfunc(comterp());
      ComValue divisor(count, ComValue::IntType);
      push_stack(divisor);
      divfunc.exec(2,0);
    }
  } else {
    push_stack(vallist);
  }
}
예제 #2
0
파일: funcadd.c 프로젝트: BRAINSia/calatk
 void
funcadd(AmplExports *ae){
	/* Insert calls on addfunc here... */

/* Arg 3, called type, must satisfy 0 <= type <= 6:
 * type&1 == 0:	0,2,4,6	==> force all arguments to be numeric.
 * type&1 == 1:	1,3,5	==> pass both symbolic and numeric arguments.
 * type&6 == 0:	0,1	==> the function is real valued.
 * type&6 == 2:	2,3	==> the function is char * valued; static storage
			    suffices: AMPL copies the return value.
 * type&6 == 4:	4,5	==> the function is random (real valued).
 * type&6 == 6: 6	==> random, real valued, pass nargs real args,
 *				0 <= nargs <= 2.
 *
 * Arg 4, called nargs, is interpretted as follows:
 *	>=  0 ==> the function has exactly nargs arguments
 *	<= -1 ==> the function has >= -(nargs+1) arguments.
 *
 * Arg 5, called funcinfo, is copied without change to the arglist
 *	structure passed to the function; funcinfo is for the
 *	function to use or ignore as it sees fit.
 */

	/* Solvers quietly ignore kth, sginv, and rncall, since */
	/* kth and sginv are symbolic (i.e., char* valued) and  */
	/* rncall is specified as random.  Thus kth, sginv, and */
	/* rncall may not appear nonlinearly in declarations in */
	/* an AMPL model. */

	addfunc("ginv", (rfunc)ginv, 0, 1, 0);
	addfunc("sginv", (rfunc)sginv, 2, 1, 0);
	addfunc("hypot", (rfunc)myhypot, 0, 2, 0);
	addfunc("ncall", (rfunc)ncall, 0, 0, 0);
	addfunc("rncall", (rfunc)ncall, 4, 0, 0);    /* could change 4 to 6 */
	addfunc("mean0", (rfunc)mean, 0, -1, 0);
	addfunc("mean", (rfunc)mean, 1, -1, 0);
	addfunc("kth", (rfunc)kth, 3, -2, 0);
	if (ae->ASLdate >= 20000608)
		addfunc("getenv", (rfunc)get_env, 3, 1, 0);
	addfunc("ginvae", (rfunc)ginvae, 0, 1, 0); /* demo at_exit, at_reset */
	/* at_end() and at_reset() calls could appear here, too. */
	}
예제 #3
0
int
main (int argc, char *argv[])
{
  GtkWidget *MainFrame;

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  gtk_set_locale ();
  gtk_init (&argc, &argv);

  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */
  MainFrame = create_MainFrame ();
  gtk_widget_show (MainFrame);
  GtkWidget* mylist = lookup_widget(MainFrame,"ls_box");
  char* box[5][1];
  int i;
  box[0][0] = "收件箱";
  box[1][0] = "已发邮件";
  box[2][0] = "垃圾箱";
  box[3][0] = "发件箱";
  box[4][0] = "草稿箱";


  for(i = 0; i < 5; i++)
  {
  	gtk_clist_append((GtkCList*)mylist,box[i]);
  }
  addfunc();
 // strcpy(storename,"10717365");
 // strcpy(storeaddress,"*****@*****.**");
 // strcpy(storepassword,"6188699");
  gtk_main ();
  return 0;
}
예제 #4
0
static int process_def(NODE * temp, enum nonterminal_enum tp ){
	if(tp == ExtDef && temp->name == terminal_name[SEMI - WHILE] ){
///		warning("useless type name in empty declaration", temp->parent->line);
	}else if(tp == ExtDef && temp->name == nonterminal_name[ExtDecList] ){
		temp->parent->attr = temp->attr = temp->previous_sister->attr ;//ExtDef and ExtDecList get attribution form specifier
	}else if(tp == ExtDef && temp->name == nonterminal_name[FunDec]){
		IDTEM* tid;
		temp->child_head->attr = temp->attr = temp->previous_sister->attr ; //FunDec and ID get attr from specifier
		addfunc(temp->child_head);//the function ID node
	}else if(tp == Def && temp->name == nonterminal_name[DecList]){
		pass_attr_for_declist(temp);
	}else if(tp == ParamDec && temp->name == nonterminal_name[VarDec]){
		temp->parent->attr = temp->attr = temp->previous_sister->attr ;//ParamDec and VarDec get attr from Specifier
		temp->value.type_p = temp->parent->parent->value.type_p ;//VarDec get value from varlist 
	}else{
		perror("unknown error: analyze.c:74");
		exit(EXIT_FAILURE);
	}
}
예제 #5
0
void main()
{
	int i, j, k;

	k=addfunc(i,j);
}
예제 #6
0
파일: outargex.c 프로젝트: BRAINSia/calatk
 void
funcadd(AmplExports *ae){
	addfunc("outargex", (rfunc)outargex,
		FUNCADD_STRING_ARGS|FUNCADD_OUTPUT_ARGS, -4, 0);
	}
예제 #7
0
void VarFunc::execute() {
  ComValue vallist(stack_arg(0));
  reset_stack();
  
  if (vallist.is_type(ComValue::ArrayType)) {
    AttributeValueList* avl = vallist.array_val();
    AddFunc addfunc(comterp());
    MpyFunc mpyfunc(comterp());
    ComValue sqrsumval(ComValue::zeroval());
    ComValue sumval(ComValue::zeroval());
    ComValue mnsquaresval;
    Iterator it;
    int count = 0;
    for (avl->First(it); !avl->Done(it); avl->Next(it)) {
      count++;

      /* square value and add to sum of squares */
      push_stack(*avl->GetAttrVal(it));
      push_stack(*avl->GetAttrVal(it));
      mpyfunc.exec(2,0);
      push_stack(sqrsumval);
      addfunc.exec(2,0);
      sqrsumval = comterp()->pop_stack();

      /* add value to running sum */
      push_stack(sumval);
      push_stack(*avl->GetAttrVal(it));
      addfunc.exec(2,0);
      sumval = comterp()->pop_stack();
    }

    /* compute mean of squares */
    DivFunc divfunc(comterp());
    push_stack(sqrsumval);
    ComValue countval((float)count);
    push_stack(countval);
    divfunc.exec(2,0);
    mnsquaresval = comterp()->pop_stack();

    /* compute mean squared */
    push_stack(sumval);
    push_stack(countval);
    divfunc.exec(2,0);
    ComValue meanval(comterp()->pop_stack());
    push_stack(meanval);
    push_stack(meanval);
    mpyfunc.exec(2,0);
    ComValue mnsquaredval(comterp()->pop_stack());

    /* subract mean squared from sum of squares to get variance */
    SubFunc subfunc(comterp());
    push_stack(mnsquaresval);
    push_stack(mnsquaredval);
    subfunc.exec(2,0);

    /* compute standard deviation if StdDevFunc */
    if (_stddevfunc) {
      SqrtFunc sqrtfunc(comterp());
      sqrtfunc.exec(1,0);
    }

  } else {
    push_stack(ComValue::zeroval());
  }
}
예제 #8
0
		std::int64_t operator +=(F f){
			Add addfunc{p_};
			return addfunc(make_delegate<Delegate>(f));
		}