Example #1
0
int main(int argc, char *argv[]) {
	struct adjlog tg;
	struct opts opts;
	int optind;
	
	TemporalGraphLog tgl;
	
	optind = readopts(argc, argv, &opts);
	
	INFO("Loading graph...");
	//read_stdin(&tg);
	read_contacts(opts,&tg);
	
	INFO("Creating index...");
	create_index(tgl, &tg, &opts);
	LOG("Size of index: %lu\n", tgl.getSize());
	
	//LOG("Depth: %u", tgl.get_log()->getDepth());
	
	ofstream file;
	LOG("Saving graph file in '%s'\n", opts.outfile);
	file.open(opts.outfile, ios::binary);
	tgl.save(file);
	file.close();
	
	return 0;
}
Example #2
0
int main(int argc,char *argv[])
{
  Centroid *SYS,*ENV;
  Sprngmtx *Gamma;
  char *sysfile,*envfile,*massfile,*ctfile,*spgfile;
  double **GG;
  double *CUT,**HS,**HE,**HX,**PH,*P;
  double dd,x,y;
  int **CT,**PIX,nss,nen,nn,ntp,nse,r1,c1,r2,c2,i,j,k;
  int ptmd,rprm,pprm;


  /* Formalities */
  read_command_line(argc,argv,&pprm,&rprm,&ptmd,&MSCL);


  /* Read coordinate and mass data */
  sysfile=get_param(argv[pprm],"syscoords");
  envfile=get_param(argv[pprm],"envcoords");
  massfile=get_param(argv[pprm],"massfile");
  SYS=read_centroids1(sysfile,massfile,&nss);
  ENV=read_centroids1(envfile,massfile,&nen);
  nn=nss+nen;
  fprintf(stderr,"System read from %s: %d centroids\n",sysfile,nss);
  fprintf(stderr,"Environment read from %s: %d centroids\n",envfile,nen);
  fprintf(stderr,"Masses read from %s\n",massfile);
  CT=imatrix(1,nn,1,nn);


  /* Find extent of membrane */
  membounds(ENV,nen,&MHI,&MLO);


  /* Print masses, if called for */
  if(ptmd==2){
    for(i=1;i<=nss;i++)
      for(j=-2;j<=0;j++){
	k=3*i+j;
	printf("%8d%8d% 25.15e\n",k,k,SYS[i].mass);
      }
    for(i=1;i<=nen;i++)
      for(j=-2;j<=0;j++){
	k=3*nss+3*i+j;
	printf("%8d%8d% 25.15e\n",k,k,ENV[i].mass);
      }
    return 0;
  }


  /* ---------------- Assign contacts... ----------------- */
  /* From a contact file... */
  if((ctfile=get_param(argv[pprm],"contactfile"))!=NULL){
    read_contacts(ctfile,CT,nn);
    fprintf(stderr,"Contacts read from %s\n",ctfile);
  }
  /* ...or from a cutoff file... */
  else if((ctfile=get_param(argv[pprm],"cutfile"))!=NULL){
    fprintf(stderr,"Cutoff values read from %s\n",ctfile);
    CUT=read_cutfile2(ctfile,SYS,ENV,nss,nen);
    radius_contact_sysenv(CT,SYS,ENV,nss,nen,CUT);
  }
  /* ...or from default values */
  else{
    CUT=dvector(1,nn);
    for(i=1;i<=nn;i++) CUT[i]=DEFCUT;
    fprintf(stderr,"All cutoff values set to %.3f\n",DEFCUT);
    radius_contact_sysenv(CT,SYS,ENV,nss,nen,CUT);
  }
  fprintf(stderr,"%d clusters\n",num_clusters(CT,nn));

  if(ptmd==1){
    fprintf(stderr,"Printing contacts\n");
    for(i=1;i<=nn;i++)
      for(j=i+1;j<=nn;j++)
	if(CT[i][j]!=0)
	  printf("%d\t%d\n",i,j);
    return 0;
  }

    



  /* ------- Construct the matrix of force constants -------*/
  GG=dmatrix(1,nn,1,nn);
  
  /* Read force constants from file... */
  if((spgfile=get_param(argv[pprm],"springfile"))!=NULL){
    fprintf(stderr,"Reading spring constants from %s\n",spgfile);
    Gamma=read_springfile_sysenv(spgfile,SYS,ENV,nss,nen,&ntp);
    spring_constants_sysenv(SYS,ENV,GG,CT,Gamma,nss,nen,ntp);
  }
  /* ...or else assign the default value to all springs */
  else
    for(i=1;i<=nn;i++)
      for(j=i;j<=nn;j++)
	if(CT[i][j]!=0)
	  GG[i][j]=GG[j][i]=DEFGAM;



  /* Construct the mass-weighted Hessian from 
     coordinates, masses, and potential matrix */
  fprintf(stderr,"Calculating Hessian...\n");
  HS=dmatrix(1,3*nss,1,3*nss);
  HE=dmatrix(1,3*nen,1,3*nen);
  HX=dmatrix(1,3*nss,1,3*nen);
  mwhess_sysenv(HS,HE,HX,SYS,ENV,GG,nss,nen);
      


  /* PRINT THE ENVIRONMENT-ENVIRONMENT SUB-HESSIAN IN SPARSE FORMAT */
  if(ptmd==0 && rprm==-1){
    fprintf(stderr,"\nPrinting env-env sub-hessian...\n\n");
    for(i=1;i<=3*nen;i++)
      for(j=i;j<=3*nen;j++)
	if(fabs(HE[i][j])>1.0e-10)
	  printf("%8d%8d% 25.15e\n",i,j,HE[i][j]);
    return 0;
  }


  /* PRINT THE FULL HESSIAN IN SPARSE FORMAT */
  if(ptmd==3){
    for(i=1;i<=3*nss;i++){
      for(j=i;j<=3*nss;j++)
	if(fabs(HS[i][j])>1.0e-10)
	  printf("%8d%8d% 20.10e\n",i,j,HS[i][j]);
      for(j=1;j<=3*nen;j++)
	if(fabs(HX[i][j])>1.0e-10)
	  printf("%8d%8d% 20.10e\n",i,j+3*nss,HX[i][j]);
    }
    for(i=1;i<=3*nen;i++)
      for(j=i;j<=3*nen;j++)
	if(fabs(HE[i][j])>1.0e-10)
	  printf("%8d%8d% 20.10e\n",i+3*nss,j+3*nss,HE[i][j]);
    return 0;
  }


  /* READ INVERSE OF ENVIRONMENTAL HESSIAN, OR INVERT HE */
  free_imatrix(CT,1,nn,1,nn);
  free_dmatrix(GG,1,nn,1,nn);
  if(rprm!=-1){
    fprintf(stderr,"Reading matrix from %s...\n",argv[rprm]);
    read_sparsemtx(argv[rprm],HE,3*nen,3*nen);
  }
  else{
    fprintf(stderr,"\nWell...How did I get here?\n\n");
    exit(1);}


  /* ---------------- CALCULATE AND PRINT THE PSEUDOHESSIAN ---------------- */

  /* COUNT THE NUMBER OF NON-ZERO TERMS IN THE PROJECTION MATRIX */
  nse=0;
  for(i=1;i<=3*nss;i++)
    for(j=1;j<=3*nen;j++)
      if(fabs(HX[i][j])>1.0e-9) nse++;
  fprintf(stderr,"%d non-zero projection elements\n",nse);
  P=dvector(1,nse);
  PIX=imatrix(1,nse,1,2);
  k=1;
  for(i=1;i<=3*nss;i++)
    for(j=1;j<=3*nen;j++)
      if(fabs(HX[i][j])>1.0e-9){
	PIX[k][1]=i;
	PIX[k][2]=j;
	P[k]=HX[i][j];
	k++;
      }
  free_dmatrix(HX,1,3*nss,1,3*nen);
  PH=dmatrix(1,3*nss,1,3*nss);
  for(i=1;i<=3*nss;i++)
    for(j=i;j<=3*nss;j++)
      PH[i][j]=PH[j][i]=0.0;
  for(i=1;i<=nse;i++){
    r1=PIX[i][1];
    c1=PIX[i][2];
    x=P[i];
    for(j=i;j<=nse;j++){
      r2=PIX[j][1];
      c2=PIX[j][2];
      y=HE[c1][c2]*P[j]*x;
      PH[r1][r2]+=y;
      if(r1==r2 && c1!=c2)
	PH[r1][r2]+=y;
    }
  }

  for(i=1;i<=3*nss;i++)
    for(j=i;j<=3*nss;j++){
      dd=HS[i][j]-PH[i][j];
      if(fabs(dd)>1.0e-10)
	printf("%8d%8d% 25.15e\n",i,j,dd);
    }
  return 0;
}
Example #3
0
void ay_edit_local_accounts(void)
{
	char *text[] = { _("C"),
		_("Screen Name"),
		_("Password"),
		_("Service")
	};
	GtkWidget *box;
	GtkWidget *window_box;
	GtkWidget *hbox;
	GtkWidget *button_box;
	GtkWidget *label;
	guint label_key;
	GtkWidget *toolbar;
	GtkToolItem *toolitem;
	GtkToolItem *tool_sep;
	GtkWidget *separator;
	LList *list;
	LList *l;

	GtkAccelGroup *accel_group;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeSelection *selection;

	if (is_open)
		return;

	is_open = 1;

	accel_group = gtk_accel_group_new();

	account_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(account_window), GTK_WIN_POS_MOUSE);
	gtk_widget_realize(account_window);

	account_list_store = gtk_list_store_new(COL_COUNT,
		G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);

	account_list =
		gtk_tree_view_new_with_model(GTK_TREE_MODEL
		(account_list_store));

	renderer = gtk_cell_renderer_toggle_new();
	column = gtk_tree_view_column_new_with_attributes(text[CONNECT],
		renderer, "active", CONNECT, NULL);

	gtk_tree_view_append_column(GTK_TREE_VIEW(account_list), column);

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(text[USER_NAME],
		renderer, "text", USER_NAME, NULL);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
	gtk_tree_view_append_column(GTK_TREE_VIEW(account_list), column);

	renderer = gtk_cell_renderer_text_new();
	column = gtk_tree_view_column_new_with_attributes(text[SERVICE_TYPE],
		renderer, "text", SERVICE_TYPE, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(account_list), column);

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(account_list));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

	gtk_container_set_border_width(GTK_CONTAINER(account_window), 5);
	g_signal_connect(selection, "changed",
		G_CALLBACK(selection_made_callback), NULL);

	box = gtk_vbox_new(FALSE, 0);
	window_box = gtk_vbox_new(FALSE, 5);
	hbox = gtk_hbox_new(FALSE, 5);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);

	/*Screen Name Section */

	label = gtk_label_new_with_mnemonic(_("Screen _Name:"));
	label_key = gtk_label_get_mnemonic_keyval(GTK_LABEL(label));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 5);
	gtk_widget_show(label);
	username = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(box), username, FALSE, FALSE, 2);
	gtk_widget_show(username);
	gtk_widget_add_accelerator(username, "grab_focus", accel_group,
		label_key, GDK_MOD1_MASK, (GtkAccelFlags) 0);

	/*Password Section */

	label = gtk_label_new_with_mnemonic(_("_Password:"******"grab_focus", accel_group,
		label_key, GDK_MOD1_MASK, (GtkAccelFlags) 0);

	/*Service Type Section */

	label = gtk_label_new_with_mnemonic(_("Service _Type:"));
	label_key = gtk_label_get_mnemonic_keyval(GTK_LABEL(label));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 5);
	gtk_widget_show(label);

	service_type = gtk_combo_box_new_text();

	list = get_service_list();
	for (l = list; l; l = l_list_next(l)) {
		char *label = l->data;
		gtk_combo_box_append_text(GTK_COMBO_BOX(service_type), label);
	}
	l_list_free(list);

	gtk_widget_show(service_type);

	gtk_box_pack_start(GTK_BOX(box), service_type, FALSE, FALSE, 2);
	gtk_widget_add_accelerator(service_type, "grab_focus", accel_group,
		label_key, GDK_MOD1_MASK, (GtkAccelFlags) 0);

	/*Connect at startup Section */

	connect_at_startup =
		gtk_check_button_new_with_mnemonic(_("_Connect at startup"));
	label_key =
		gtk_label_get_mnemonic_keyval(GTK_LABEL(GTK_BIN
			(connect_at_startup)->child));
	gtk_widget_show(connect_at_startup);
	gtk_widget_add_accelerator(connect_at_startup, "clicked", accel_group,
		label_key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
	gtk_box_pack_start(GTK_BOX(box), connect_at_startup, FALSE, FALSE, 5);

	gtk_box_pack_start(GTK_BOX(hbox), box, FALSE, FALSE, 2);
	gtk_widget_show(box);

	box = gtk_vbox_new(FALSE, 0);

	read_contacts();

	gtk_box_pack_start(GTK_BOX(box), account_list, TRUE, TRUE, 0);
	gtk_widget_show(account_list);

	gtk_box_pack_start(GTK_BOX(hbox), box, TRUE, TRUE, 2);
	gtk_widget_show(box);

	gtk_box_pack_start(GTK_BOX(window_box), hbox, TRUE, TRUE, 0);
	gtk_widget_show(hbox);

	separator = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(window_box), separator, TRUE, TRUE, 0);
	gtk_widget_show(separator);

	/*Initialize Toolbar */

	toolbar = gtk_toolbar_new();
	gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
	gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), FALSE);
	gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar),
		GTK_ORIENTATION_HORIZONTAL);
	gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);

	/*Add Button */

#define TOOLBAR_APPEND(titem,stock,tip,callback,cb_data) { \
	titem = gtk_tool_button_new_from_stock(stock); \
	gtk_tool_item_set_tooltip_text(titem, tip); \
	g_signal_connect(titem, "clicked", G_CALLBACK(callback), cb_data); \
	gtk_widget_show(GTK_WIDGET(titem)); \
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), titem, -1); \
}

/* line will tell whether to draw the separator line or not */
#define TOOLBAR_APPEND_SEPARATOR(line) { \
	tool_sep = gtk_separator_tool_item_new(); \
	gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(tool_sep), line); \
	gtk_widget_show(GTK_WIDGET(tool_sep)); \
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_sep, -1); \
}

	TOOLBAR_APPEND(toolitem, GTK_STOCK_HELP, _("Help"), help_callback,
		NULL);

	TOOLBAR_APPEND_SEPARATOR(TRUE);

	TOOLBAR_APPEND(toolitem, GTK_STOCK_ADD, _("Add Account"), add_callback,
		NULL);

	TOOLBAR_APPEND_SEPARATOR(FALSE);

	/*Delete Button */

	TOOLBAR_APPEND(del_button, GTK_STOCK_DELETE, _("Delete Account"),
		remove_callback, NULL);

	gtk_widget_set_sensitive(GTK_WIDGET(del_button), FALSE);
	TOOLBAR_APPEND_SEPARATOR(FALSE);

	/* Modify Button */

	TOOLBAR_APPEND(mod_button, GTK_STOCK_EDIT, _("Modify Account"),
		modify_callback, NULL);

	gtk_widget_set_sensitive(GTK_WIDGET(mod_button), FALSE);

	TOOLBAR_APPEND_SEPARATOR(TRUE);

	/*Okay Button */

	TOOLBAR_APPEND(toolitem, GTK_STOCK_OK, _("Ok"), ok_callback, NULL);

	TOOLBAR_APPEND_SEPARATOR(FALSE);

	/*Cancel Button */

	TOOLBAR_APPEND(toolitem, GTK_STOCK_CANCEL, _("Cancel"), cancel_callback,
		NULL);

#undef TOOLBAR_APPEND_SEPARATOR
#undef TOOLBAR_APPEND
	/*Buttons End */

	button_box = gtk_hbox_new(FALSE, 0);

	gtk_box_pack_end(GTK_BOX(button_box), toolbar, FALSE, FALSE, 0);
	gtk_widget_show(toolbar);

	gtk_box_pack_start(GTK_BOX(window_box), button_box, FALSE, FALSE, 0);
	gtk_widget_show(button_box);

	gtk_widget_show(window_box);

	gtk_container_add(GTK_CONTAINER(account_window), window_box);

	gtk_window_set_title(GTK_WINDOW(account_window),
		_("Ayttm Account Editor"));

	g_signal_connect(account_window, "destroy", G_CALLBACK(destroy), NULL);

	gtk_window_add_accel_group(GTK_WINDOW(account_window), accel_group);

	gtk_widget_show(account_window);
	gtk_widget_grab_focus(username);
}