Ejemplo n.º 1
0
int main (int argc, char *argv[])
{
  if(argc > 1)
    for (int i = 1; i < argc; ++i)
    {
        std::string ar(argv[i]);
        if( ar == "-d")
          ad_debug = true;
        else if( ar == "-s")
          simulate = true;
    }

  readfiles();
  
  GMainLoop *loop;
  WnckScreen *screen;

  gdk_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);
  screen = wnck_screen_get_default ();

  g_signal_connect (screen, "window-opened", G_CALLBACK (on_window_opened), NULL);
  g_main_loop_run (loop);
  g_main_loop_unref (loop);

  return 0;
}
Ejemplo n.º 2
0
loadmix(char *fnames[], int nscores, double *weights) {
	if(nscores<2 || nscores>NSCORES) error("Bad number of files\n");
	
	double xty[NSCORES+1];
	if(weights) {
		int j;
		for(j=0;j<=nscores;j++)
			xty[j]=weights[j];
	} else
		computemix(fnames, nscores, xty);
	lg("Mixing coeeficients\n");
	int f;
	for(f=0;f<=nscores;f++)
		lg("-lew %f ",xty[f]);
	lg("\n");
		
	FILE *fp[NSCORES];
	openfiles(fp,fnames,nscores);
	int i;
	for(i=0; i<NENTRIES; i++) {
		PROGRESS(i,NENTRIES);
		int r=(userent[i]>>USER_LMOVIEMASK)&7;
		float s[NSCORES];
		readfiles(fp,s,nscores);
		float stotal=0.;
		int j;
		for(j=0;j<nscores;j++)
			stotal+=xty[j]*(r-s[j]);
		stotal+=xty[nscores];
		err[i]=r-stotal;
	}
	closefiles(fp,nscores);
}
Ejemplo n.º 3
0
int	main(int ac, char **av)
{
	t_ls	*ls;

	ls = newls();
	setupls(ls, av, ac);
	if (ls->sort_alpha)
		sortargs(ls->args, ls->sort_alpha);
	readfiles(ls);
	readargs(ls->args, ls);
	return (0);
}
Ejemplo n.º 4
0
Archivo: mbar.c Proyecto: q10/SPCE2
int main(int argc, char *argv[]){
	sscanf(argv[1], "%d", &nwindows);
	sscanf(argv[2], "%f", &windowspacing);
	sscanf(argv[3], "%f", &windowwidth);
	sscanf(argv[4], "%f", &minimumh);
	sscanf(argv[5], "%s", &histogramfile);
	sscanf(argv[6], "%d", &niterations);
	sscanf(argv[7], "%s", &datafile);
	readfiles();
	for(k=0; k<=niterations-1; k++){
		iteratedeltaf();
	}
	for(k=0; k<=nwindows-1; k++){
		printf("%f\n", deltaf[k]);

	}
	calculateweights();
	createhistogram();
	return 0;
	
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: mariuz/haiku
/*-------------------------------------------------------------------------*/
int main (int argc, char *argv[])

{
  int i;

  reader_init();

  /* Get arguments, set up defaults */
  parseargs(argc, argv);
  if (!aFiles.size)
  {
    if (add_expfile(&aFiles, "*.c"))
      exit_nomem(" (main: add_expfile)");
  }
  if (!sObjExt)
    sObjExt = ".o";

  if (!aSrcExt.size)
  {
    if (array_addfile(&aSrcExt, ".c") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".cc") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".cp") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".cpp") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".cxx") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".C") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".CC") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".CP") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".CPP") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
    if (array_addfile(&aSrcExt, ".CXX") || array_addfile(&aObjExt, NULL))
      exit_nomem(" (main: add suffix)");
  }

  if (bVerbose)
  {
    printf("MkDepend %s -- Make Dependency Generator\n", VERSION);
    putchar('\n');
  }

  /* Look for the Makefile to modify */
  if (sMake)
  {
    bMakeExists = !stat(sMake, &aMakeStat);
  }
  else if (!sDepfile)
  {
    sMake = "Makefile";
    bMakeExists = !stat(sMake, &aMakeStat);
    if (!bMakeExists)
    {
      sMake = "makefile";
      bMakeExists = !stat(sMake, &aMakeStat);
    }
    if (!bMakeExists)
    {
      sMake = "Makefile.mk";
      bMakeExists = !stat(sMake, &aMakeStat);
    }
    if (!bMakeExists)
    {
      sMake = "makefile.mk";
      bMakeExists = !stat(sMake, &aMakeStat);
    }
    if (!bMakeExists)
    {
      sMake = "GNUMakefile";
      bMakeExists = !stat(sMake, &aMakeStat);
    }
    if (!bMakeExists)
      sMake = "Makefile";
  }

  /* Add the source files to the tree */
  if (!aFiles.size)
  {
    printf("%s: No files given.\n", aPgmName);
    set_rc(RETURN_WARN, TRUE);
  }
  else
  {
      struct stat aStat; /* buffer for stat() */

      for (i = 0; i < aFiles.size; i++)
      {
          if (stat(aFiles.strs[i], &aStat))
          {
              printf("%s: Warning: Can't find source '%s'.\n", aPgmName
                    , aFiles.strs[i]);
              set_rc(RETURN_WARN, FALSE);
          }
          else if (nodes_addsource(aFiles.strs[i], FALSE))
              exit_nomem(" (main: add source)");
      }

      /* If this leaves us with no source files at all, readfiles()
       * will complain.
       */
  }

  /* Mark the exceptional files */
  for (i = 0; i < aAvoid.size; i++)
  {
    if (nodes_addsource(aAvoid.strs[i], TRUE))
      exit_nomem(" (main: add avoided source)");
  }

  /* Read and analyse all those files */
  set_rc(readfiles(), 0);

  /* Handle the selection of files */
  if (IS_SELECT_MODE)
  {
    Node * pNode;

    /* First, mark all nodes with selected files */
    for (i = 0; i < aSelect.size; i++)
    {
      pNode = nodes_find(aSelect.strs[i]);
      if (pNode)
        pNode->flags |= NODE_SELECT;
    }

    /* Now walk the tree and propagate the select information */
    nodes_initwalk();
    while (NULL != (pNode = nodes_inorder()) )
    {
      if (!(pNode->flags & (NODE_IGNORE)) 
       && (pNode->flags & (NODE_SOURCE|NODE_AVOID)) == NODE_SOURCE)
      {
        NODES_UNMARK(pNode);
        nodes_mark_select(pNode);
      }
    }
  }

  if (returncode < RETURN_ERROR && sMake)
    set_rc(output(TRUE), 0);

  if (returncode < RETURN_ERROR && sMake && bVerbose)
    printf("%s '%s'.\n", bMakeExists ? "Updated" : "Created", sMake);

  if (returncode < RETURN_ERROR && sDepfile)
    set_rc(bFlat ? output(FALSE) : output_tree(), 0);

  if (returncode < RETURN_ERROR && sDepfile && bVerbose)
    printf("Created '%s'.\n", sDepfile);

  return (returncode == RETURN_WARN && bNoWarnExit) ? RETURN_OK : returncode;
}
	parser_source::parser_source(const std::vector<std::string>& files)
		: input_pair_(readfiles(files))
		, input_(input_pair_.first)
       		, index_(0)
		, line_(1) 
		, file_indexes_(input_pair_.second) {}
int main(int argc, char *argv[])
{
	const char         *desc[] = {
		"Read duplex melting curve and duplex data to fit equilibrium [BR]"
			"Solving the equations takes time."
	};

	FILE	*f_melt;
	FILE	*f_fit;
	static real	tmaxabs=-1;
	static bool	bVerbose=FALSE;
	static fit_params f_parm;
	f_parm.max_MC_iter = 200;
	f_parm.wt = 2.0;

	/* Command-line arguments */
	t_pargs          pa[] = {
		{"-mi", FALSE, etINT, {&(f_parm.max_MC_iter)},
			"Number of iterations with random boundaries to find best r^2"},
		{"-wt", FALSE, etREAL, {&(f_parm.wt)},
			"Width of T window to randomize T_min/T_max boundaries"},
		{"-v", TRUE, etBOOL, {&bVerbose},
			"Be verbose."},
	};

	/* Output files */
	t_filenm            fnm[] = {
		{ efDAT, "-d", "duplex_input.dat", ffREAD },
		{ efXVG, "-o", "fitted_melt", ffWRITE  },
	};

#define NFILE asize(fnm)
	output_env_t    oenv;
	int				i,j,k;
	int				npargs;
	char			buf[256];
	const char		*inputfile=NULL;
	const char		*outfile=NULL;
	char			line[255];
	bool			bsettmax;
	f_info			*f_inp; 
	f_all_sol		all_sol;
	int				nfiles=0;
	int				nfiles_read=0;
	real 			*t_min;
	real 			*t_max;

	npargs=asize(pa);
	//	CopyRight(stderr, argv[0]);
	parse_common_args(&argc, argv, 0,
			NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv);

	// read the input file
	inputfile = opt2fn("-d",NFILE,fnm);

	// reading all the inputs, f_inp contains the input file names, the 
	// number of lines per file, as well as the parameters for each fitting
	// We are going to read all the points here, then apply the
	// limits later on 
	readfiles(inputfile, &f_inp, &nfiles_read);

	//initialize PRNG
	srand(time(NULL));

	outfile = opt2fn("-o",NFILE,fnm);
	all_sol=opt_melt_diff_conc(f_inp, nfiles_read, f_parm,  bVerbose, outfile);

	return 0;

}
Ejemplo n.º 8
0
computemix(char *fnames[], int nscores, double *xty)
{
#ifdef HOLDOUT
	lg("With holdout\n");
#endif
	int ns2=nscores+2;
	int ns1=nscores+1;
	FILE *fp[NSCORES];
	openfiles(fp,fnames,nscores);

	double xtx[NSCORES+2][NSCORES+2];
	ZERO(xtx);
	
	int u;
	for(u=0; u<NUSERS; u++) {
		PROGRESS(u,NUSERS);
		int base=useridx[u][0];
#ifdef HOLDOUT
		if(aopt) error("cant do holdout with -a");
		int d0=UNTRAIN(u);
		int d1=UNALL(u)-d0;
#else
		int d0=0;
		int d1=UNTRAIN(u);
#endif
		seekfiles(fp,nscores, d0);
		base+=d0;
		int j;			
		for(j=0;j<d1;j++) {
			unsigned int dd=userent[base+j];
			int r = (dd>>USER_LMOVIEMASK)&7;
			float s[NSCORES+2];
			readfiles(fp,s,nscores);
			int f;
			for(f=0;f<nscores;f++)		
				s[f]=r-s[f];
			s[nscores]=1.;
			s[nscores+1]=r;

			int ff;
			for(f=0;f<ns2;f++) {
				for(ff=0;ff<ns2;ff++)
					xtx[f][ff] +=s[f]*s[ff];
			}
		}
		int d2=UNTOTAL(u)-(d1+d0);
		seekfiles(fp,nscores, d2);
	}
	closefiles(fp,nscores);
	int count=xtx[nscores][nscores];
	int j1,j2;
	for(j1=0;j1<nscores;j1++)
		lg("File %d RMSE %f\n",j1,sqrt((xtx[j1][j1]+xtx[ns1][ns1]-2*xtx[ns1][j1])/count));
	double avgs[NSCORES+2],std[NSCORES+2];
	for(j1=0;j1<ns2;j1++) {
		avgs[j1]=xtx[nscores][j1]/count;
		std[j1]=sqrt(xtx[j1][j1]/count-avgs[j1]*avgs[j1]);
	}
	for(j1=0;j1<ns2;j1++)
		lg("%f\t",avgs[j1]);
	lg("\n");
	for(j1=0;j1<ns2;j1++)
		lg("%f\t",std[j1]);
	lg("\n");
	lg("-------------------------------------------------\n");
	for(j1=0;j1<ns2;j1++) {
		for(j2=0;j2<ns2;j2++) {
			lg("%f\t",(xtx[j1][j2]/count-avgs[j1]*avgs[j2])/(std[j1]*std[j2]+1.e-6));
		}
		lg("\n");
	}
	lg("-------------------------------------------------\n");
	double eavgs[NSCORES],estd[NSCORES];
	for(j1=0;j1<nscores;j1++) {
		eavgs[j1]=avgs[ns1]-avgs[j1];
		estd[j1]=sqrt((xtx[ns1][ns1]+ xtx[j1][j1]-2*xtx[j1][ns1])/count);
	}
	for(j1=0;j1<nscores;j1++)
		lg("%f\t",eavgs[j1]);
	lg("\n");
	for(j1=0;j1<nscores;j1++)
		lg("%f\t",estd[j1]);
	lg("\n");
	lg("-------------------------------------------------\n");
	for(j1=0;j1<nscores;j1++) {
		for(j2=0;j2<nscores;j2++) {
			lg("%f\t",((xtx[j1][j2]+xtx[ns1][ns1]-xtx[ns1][j1]-xtx[ns1][j2])/count-eavgs[j1]*eavgs[j2])/(estd[j1]*estd[j2]+1.e-6));
		}
		lg("\n");
	}


	char TRANS='N';
	char UFLO='U';
	int M=ns1;
	int N=ns1;
	int NRHS=1;
	double A[NSCORES+1][NSCORES+1];
	int LDA=NSCORES+1;
	double B[NSCORES+1];
	int LDB=NSCORES+1;
	double S[NSCORES+1];
	double RCOND=0.00001; // singular values below this are treated as zero.
	int RANK;
	double WORK[1000];
	int LWORK=1000;
	int INFO;

	for(j1=0;j1<ns1;j1++) {
		B[j1]=xtx[ns1][j1];
		for(j2=0;j2<ns1;j2++)
			A[j1][j2]=xtx[j1][j2];
	}	
	for(j1=0;j1<ns1;j1++) A[j1][j1]+=LAMBDA;
	/*dgesv_(&N,&NRHS,A,&LDA,IPIV,B,&LDB,&INFO);*/
	/*dgels_(&TRANS,&M,&N,&NRHS,A,&LDA,B,&LDB,WORK,&LWORK,&INFO);*/
	/*dgelss_( &M, &N, &NRHS, A, &LDA, B, &LDB, S, &RCOND, &RANK, WORK, &LWORK, &INFO );*/
	dposv_(&UFLO,&N,&NRHS,A,&LDA,B,&LDB,&INFO);
	if(INFO) error("failed %d\n",INFO);
		
	for(j1=0;j1<=nscores;j1++)
		xty[j1]=B[j1];

	lg("Check that the matrix inversion worked:\n");
	for(j1=0;j1<=nscores;j1++) {
		double sum=LAMBDA*B[j1];
		for(j2=0;j2<=nscores;j2++)
			sum+=xtx[j1][j2]*B[j2];
		lg("%f\t%f\n",sum,xtx[nscores+1][j1]);
	}
}