Пример #1
0
KOCRBase::KOCRBase( QWidget *parent, KSpellConfig *spellConfig,
                    KDialogBase::DialogType face )
   :KDialogBase( face, i18n("Optical Character Recognition"),
		 User2|Close|User1, User1, parent,0, false, true,
		 KGuiItem( i18n("Start OCR" ), "launch",
			   i18n("Start the Optical Character Recognition process" )),
                 KGuiItem( i18n("Cancel" ), "stopocr",
			   i18n("Stop the OCR Process" ))),
    m_animation(0L),
    m_metaBox(0L),
    m_imgHBox(0L),
    m_previewPix(0L),
    m_currImg(0L),
    m_spellConfig(spellConfig),
    m_wantSpellCfg(true),
    m_userWantsSpellCheck(true),
    m_cbWantCheck(0L),
    m_gbSpellOpts(0L)
{
    kdDebug(28000) << "OCR Base Dialog!" << endl;
    // Layout-Boxes

    KConfig *konf = KGlobal::config ();
    KConfigGroupSaver gs( konf, CFG_OCR_KSPELL );
    m_userWantsSpellCheck = konf->readBoolEntry(CFG_WANT_KSPELL, true);

    /* Connect signals which disable the fields and store the configuration */
    connect( this, SIGNAL( user1Clicked()), this, SLOT( writeConfig()));
    connect( this, SIGNAL( user1Clicked()), this, SLOT( startOCR() ));
    connect( this, SIGNAL( user2Clicked()), this, SLOT( stopOCR() ));
    m_previewSize.setWidth(200);
    m_previewSize.setHeight(300);

    enableButton( User1, true );   /* start ocr */
    enableButton( User2, false );  /* Cancel    */
    enableButton( Close, true );
}
Пример #2
0
/// Append any applicable suffixes to the name given and attempt to find
/// vertex, fragment and (optionally) geometry shader source.
GLuint makeShaderByName(const char* name)
{
    if (!name)
        return 0;

    std::string vs(name);
    std::string fs(name);
    std::string gs(name);
    vs += ".vert";
    fs += ".frag";
    gs += ".geom";

    std::cout << std::endl
        << "makeShaderByName("
        << vs
        << ", "
        << fs
        << ", "
        << gs
        << "):__"
        << std::endl;

    return makeShaderFromSource(vs.c_str(), fs.c_str(), gs.c_str());
}
Пример #3
0
void Player::update()
{
	fireDelay -= sfw::getDeltaTime();
	// example of switching between animations
	if (sfw::getKey(' ') && fireDelay < 0)
	{
		fireDelay = rateOfFire;
		gs()->makeBullet(x, y, 0, 300, 4.f); // Now we can use this to draw stuff!

		
	}

	if (animTimer > getAnimationDuration(textureName, animationName))
	{
		animTimer = 0;
		animationName = "BOOM";
	}

	float sdt = sfw::getDeltaTime() * speed;
	if (sfw::getKey('W')) y += sdt; // Euler integration
	if (sfw::getKey('S')) y -= sdt;
	if (sfw::getKey('A')) x -= sdt;
	if (sfw::getKey('D')) x += sdt;
}
Пример #4
0
 const GiTransform& xf() const
 {
     return gs()->xf();
 }
Пример #5
0
void VDBFlushMgr::MainLoop()
{
	VDebugContext& context = VTask::GetCurrent()->GetDebugContext();
	context.StartLowLevelMode();

	sLONG nbpass = 1;
	Boolean AuMoinsUnFlushTreeNonVide;

	fIsFlushing = true;

	if (VDBMgr::GetActivityManager() != nil)
		VDBMgr::GetActivityManager()->SetActivityWrite(true, -1);
	/*
	VGoldfingerSysTrayServer* systray = VGoldfingerSysTrayServer::GetSysTray();
	if ( NULL != systray )
	systray->SetActivityWrite_Toggle(true);
	*/

	VCacheLogQuotedEntry	logEntry(eCLEntryKind_Flush, false, true);

#if trackClose
	trackDebugMsg("debut flush MainLoop\n");
#endif						

	while (nbpass<2)
	{
		uLONG WaitOthers = 1;

		//fFlushedBytes = 0;
		AuMoinsUnFlushTreeNonVide = true;

		FlushProgressInfo fpi;
		fpi.curObjectNum = 0;
		fpi.totbytes = 0;
		fpi.starttime = VSystem::GetCurrentTime();
		fpi.lasttime = fpi.starttime;
		fpi.currentBD = nil;

#if debuglr == 101
		if (fFlushProgress != nil && !fFlushProgress->IsManagerValid())
		{
			sLONG xdebug = 1; // put a break here
		}

		if (fFlushProgress != nil)
			fFlushProgress->Release();
#endif

		fFlushProgress = VDBMgr::GetManager()->RetainDefaultProgressIndicator_For_DataCacheFlushing();
		if (fFlushProgress != nil)
		{
			XBOX::VString session_title;
			gs(1005,22,session_title); // Flushing Data
			fpi.message = session_title;
			fFlushProgress->BeginSession(sGlobalNbFlushObjects,session_title,false);
		}

		Boolean RAZTimers = true;

		SetCurTaskFlushing(true);
		while( AuMoinsUnFlushTreeNonVide) 
		{

			Boolean AllisSomethingFlushed = false;
			Boolean toutvide = true, waitForRequestForInvalid = false;

			SetDirty( false);
			//xSetFlushCancelled( false);

			BaseFlushInfo *curinfo;

			{
				VTaskLock Lock(&ListFlushInfoMutext);
				curinfo = ListFlushInfo;
			}

			while (curinfo != nil)
			{
				Boolean isSomethingFlushed = false;
				BtreeFlush *newbtflush;
				Boolean mustincreasetimer = false;
				sLONG NbModifStamp = 0;
				DataAddrSetVector AllSegsFullyDeletedObjects;

				{
					VTaskLock Lock(&(curinfo->TreeMutex));
					if (RAZTimers)
					{
						curinfo->fWaitToInsertNewObject = 0;
						curinfo->fWaitToInsertNewObjectTimer.Unlock();
					}
					newbtflush = curinfo->fCurTree;
					curinfo->fFlushingTree = newbtflush;
					curinfo->fCurTree = nil;
					if (newbtflush != nil)
					{
						fpi.currentBD = curinfo->GetOwner();
						curinfo->GetOwner()->SwapAllSegsFullyDeletedObjects(AllSegsFullyDeletedObjects);
						if (fNeedValidate.find(curinfo) == fNeedValidate.end())
						{
							curinfo->GetOwner()->InvalidateHeader();
							fNeedValidate.insert(curinfo);
						}
					}
					else
					{
						if (curinfo->fRequestForInvalid > 0)
						{
							waitForRequestForInvalid = true;
							if (fNeedValidate.find(curinfo) == fNeedValidate.end())
							{
								curinfo->GetOwner()->InvalidateHeader();
								fNeedValidate.insert(curinfo);
							}
						}
					}
					NbModifStamp = curinfo->fNbModifStamp;
				}

				if (newbtflush != nil)
				{
					VSize curtot = 0;
					if (newbtflush->ViderFlush( &curtot, &isSomethingFlushed, &events, &FlushEventMutex, fFlushProgress, fpi, AllSegsFullyDeletedObjects))
					{
						// comme tout l'arbre a ete flushe, on peut le supprimer
						xDisposeFlushingTree( curinfo, false);
						newbtflush=nil;
					}
					else toutvide = false;

					for (DataAddrSetVector::iterator cur = AllSegsFullyDeletedObjects.begin(), end = AllSegsFullyDeletedObjects.end(); cur != end; cur++)
					{
						DataAddrSetForFlush* px = &(*cur);
						if (!px->fAddrs.empty())
						{
							sLONG nullzero = 0;
							while (px->fCurrent != px->fLast )
							{
								fpi.currentBD->writelong(&nullzero, 4, *(px->fCurrent), 0);
								px->fCurrent++;
							}
						}
					}

					if (NbModifStamp != curinfo->fNbModifStamp)
						mustincreasetimer = true;

					if (newbtflush!=nil)
					{
						// comme certains objets n'ont pu etre flushe, on recopie le residu d'arbre pour un prochain essai
						xDisposeFlushingTree( curinfo, true);
						newbtflush=nil;
						toutvide = false;
					}

					AllisSomethingFlushed = AllisSomethingFlushed || isSomethingFlushed;

					{
						VTaskLock Lock(&(curinfo->TreeMutex));
						if (curinfo->fCurTree == nil)
						{
							if (curinfo->fRequestForInvalid > 0)
							{
								waitForRequestForInvalid = true;
							}
							else
							{
								fNeedValidate.erase(curinfo);
								curinfo->GetOwner()->ValidateHeader();
							}
							curinfo->fWaitToInsertNewObject = 0;
							curinfo->fWaitToInsertNewObjectTimer.Unlock();
						}
						else
						{
							if (mustincreasetimer)
							{
								if (curinfo->fWaitToInsertNewObject == 0)
								{
									curinfo->fWaitToInsertNewObject = 1;
									curinfo->fLastTimeIncrease = VSystem::GetCurrentTime();
									curinfo->fWaitToInsertNewObjectTimer.ResetAndLock();
								}
								else
								{
									uLONG curtime = VSystem::GetCurrentTime();
									if ((uLONG)abs((sLONG)(curtime - curinfo->fLastTimeIncrease)) > curinfo->fWaitToInsertNewObject)
									{
										if (curinfo->fWaitToInsertNewObject < 8192)
											curinfo->fWaitToInsertNewObject = curinfo->fWaitToInsertNewObject * 2;
										curinfo->fLastTimeIncrease = curtime;
									}
								}
							}
							else // decrease
							{
								if (curinfo->fWaitToInsertNewObject != 0)
								{
									if (curinfo->fWaitToInsertNewObject == 1)
									{
										curinfo->fWaitToInsertNewObject = 0;
										curinfo->fWaitToInsertNewObjectTimer.Unlock();
									}
									else
									{
										uLONG curtime = VSystem::GetCurrentTime();
										if ((uLONG)abs((sLONG)(curtime - curinfo->fLastTimeIncrease)) > curinfo->fWaitToInsertNewObject)
										{
											curinfo->fWaitToInsertNewObject = curinfo->fWaitToInsertNewObject / 2;
											curinfo->fLastTimeIncrease = curtime;
										}
									}
								}
							}

							toutvide = false;
						}
					}

				}

				{
					VTaskLock Lock(&(curinfo->TreeMutex));
					curinfo = curinfo->right;
				}
			}

			// on libere toute les demandes de flush pour memoire qui ont, au moins, fait un cycle complet
			{
				VTaskLock lock2(&FlushEventMutex);
				for (FlushEventList::iterator cur = events.begin(), end = events.end(); cur != end; )
				{
					Boolean next = true;
					if (cur->needmem)
					{
						if (cur->FlushCycle!= fCurrentFlushCycle)
						{
							cur->flag->Unlock();
							cur->flag->Release();
							FlushEventList::iterator theone = cur;
							cur++;
							next = false;
							events.erase(theone);
						}
					}
					if (next)
						cur++;
				}

				fCurrentFlushCycle++;
			}

			// maintenant on supprime les BaseFlushInfo des bases qu'on a ferme
			{
				VTaskLock Lock(&ListFlushInfoMutext);
				curinfo = ListFlushInfo;

				while (curinfo != nil)
				{
					Boolean doisdelete = false;
					BaseFlushInfo* suivant;
					{
						VTaskLock Lock2(&(curinfo->TreeMutex));
						suivant = curinfo->right;

						doisdelete = (curinfo->doisdelete);
						if (doisdelete) 
							DeleteBaseFlushInfo(curinfo);
					}

					curinfo = suivant;
				}
			}

			{
				VTaskLock lock2(&FlushEventMutex);
				for (FlushEventList::iterator cur = events.begin(), end = events.end(); cur != end; )
				{
					Boolean next = true;
					if (cur->waitForAllWritten)
					{
						cur->flag->Unlock();
						cur->flag->Release();
						FlushEventList::iterator theone = cur;
						cur++;
						next = false;
						events.erase(theone);
					}
					if (next)
						cur++;
				}
			}
			if (toutvide)
			{
				if (waitForRequestForInvalid)
					AuMoinsUnFlushTreeNonVide = true;
				else
					AuMoinsUnFlushTreeNonVide = false; // on peut quitter la boucle car tous les arbres ont ete flushes
			}
			else
			{
				if (WaitOthers < 2)
					WaitOthers = WaitOthers * 2;
				VTask::GetCurrent()->Sleep(WaitOthers);
				//vYieldNow();
				//on donne une chance aux autres process de liberer les objets lockes
			}

			VDBMgr::GetCacheManager()->ClearWaitListForBigObject();
			RAZTimers = false;

			VDBMgr::GetManager()->PurgeExpiredDataSets();

			VDBMgr::GetManager()->DeleteDeadBlobPaths();

		}

		if (fFlushProgress != nil)
		{
			fFlushProgress->EndSession();
#if debuglr == 101
			// when debugging, keep the progress indicator
#else
			fFlushProgress->Release();
			fFlushProgress = nil;
#endif
		}

		SetCurTaskFlushing(false);
		//SetDirty( false);

		++nbpass;
	}

#if trackClose
	trackDebugMsg("fin flush MainLoop\n");
#endif						

	xFlushEnd();

#if trackClose
	trackDebugMsg("apres xFlushEnd\n");
#endif						


	if (VDBMgr::GetActivityManager() != nil)
		VDBMgr::GetActivityManager()->SetActivityWrite(false, 0);
	/*
	if ( NULL != systray )
	systray->SetActivityWrite_Toggle(false);
	*/

	VDBMgr::GetManager()->FlushAllData();

	context.StopLowLevelMode();

}
Пример #6
0
Z H1(ts){A z;Z C *t[]={"int","float","char","null","box","sym","func",
 "unknown"};
 W(gs(Et))*z->p=MS(si(t[QA(a)?(Et<a->t?6:Et>a->t?a->t:!a->n?3:
 Et==a->t?(QA(a=(A)*a->p)&&a->t<Xt?4:QS(a)?5:6):6):
 QP(a)?6:QX(a)?6:7]));R(I)z;}
Пример #7
0
int main(int argc, char **argv)
{
  long long begin_time = millitime();
  char **argptr = argv+1;
  
  if (!*argptr) usage();
  std::string storename = *argptr++;
  
  if (!*argptr) usage();
  int uid = atoi(*argptr++);

  set_log_prefix(string_printf("%d %d ", getpid(), uid));
  
  if (!*argptr) usage();
  std::string full_channel_name = *argptr++;
#if FFT_SUPPORT
  bool writing_fft = false;
  size_t fftpos = full_channel_name.rfind(".DFT");
  if (fftpos != std::string::npos) {
    full_channel_name = full_channel_name.substr(0, fftpos);
    writing_fft = true;
  }
#endif /* FFT_SUPPORT */

  if (!*argptr) usage();
  int tile_level = atoi(*argptr++);

  if (!*argptr) usage();
  long long tile_offset = atoll(*argptr++);

  if (*argptr) usage();

  // Desired level and offset
  // Translation between tile request and tilestore:
  // tile: level 0 is 512 samples in 512 seconds
  // store: level 0 is 65536 samples in 1 second
  // for tile level 0, we want to get store level 14, which is 65536 samples in 16384 seconds

  // Levels differ by 9 between client and server
  TileIndex client_tile_index = TileIndex(tile_level+9, tile_offset);

  {
    std::string arglist;
    for (int i = 0; i < argc; i++) {
      if (i) arglist += " ";
      arglist += std::string("'")+argv[i]+"'";
    }
    log_f("gettile START: %s (time %.9f-%.9f)",
	  arglist.c_str(), client_tile_index.start_time(), client_tile_index.end_time());
  }
    
  FilesystemKVS store(storename.c_str());

  // 5th ancestor
  TileIndex requested_index = client_tile_index.parent().parent().parent().parent().parent();

  std::vector<DataSample<double> > double_samples;
  std::vector<DataSample<std::string> > string_samples;
  std::vector<DataSample<std::string> > comments;

  bool doubles_binned, strings_binned, comments_binned;
  // TODO: If writing FFT, ***get more data***
  // TODO: Use min_time_required and max_time_required, get max-res data
  read_tile_samples(store, uid, full_channel_name, requested_index, client_tile_index, double_samples, doubles_binned);
#if FFT_SUPPORT
  if (writing_fft) {
    std::vector<std::vector<double> > fft, shifted;
    int num_values;

    windowed_fft(double_samples, requested_index, fft);
    present_fft(fft, shifted, num_values);

    // JSON tile to send back to the client includes some of the same
    // information as a non-DFT tile
    Json::Value tile(Json::objectValue);
    tile["level"] = Json::Value(tile_level);
    // See discussion below for reason to cast tile_offset
    // from long long to double
    tile["offset"] = Json::Value((double)tile_offset);
    tile["num_values"] = Json::Value(num_values);
    tile["dft"] = Json::Value(Json::arrayValue);
    for (unsigned window_id = 0; window_id < shifted.size(); window_id++) {
      Json::Value window(Json::arrayValue);
      for (unsigned i = 0; i < shifted[window_id].size(); i++)
        window.append(shifted[window_id][i]);

      tile["dft"].append(window);
    }
    std::cout << Json::FastWriter().write(tile) << std::endl;
    return 0;
  }
#endif /* FFT_SUPPORT */
  read_tile_samples(store, uid, full_channel_name, requested_index, client_tile_index, string_samples, strings_binned);
  read_tile_samples(store, uid, full_channel_name+"._comment", requested_index, client_tile_index, comments, comments_binned);
  string_samples.insert(string_samples.end(), comments.begin(), comments.end());
  std::sort(string_samples.begin(), string_samples.end(), DataSample<std::string>::time_lessthan);
  
  std::map<double, DataSample<double> > double_sample_map;
  for (unsigned i = 0; i < double_samples.size(); i++) {
    double_sample_map[double_samples[i].time] = double_samples[i]; // TODO: combine if two samples at same time?
  }
  std::set<double> has_string;
  for (unsigned i = 0; i < string_samples.size(); i++) {
    has_string.insert(string_samples[i].time);
  }

  std::vector<GraphSample> graph_samples;

  bool has_fifth_col = string_samples.size()>0;

  for (unsigned i = 0; i < string_samples.size(); i++) {
    if (double_sample_map.find(string_samples[i].time) != double_sample_map.end()) {
      GraphSample gs(double_sample_map[string_samples[i].time]);
      gs.has_comment = true;
      gs.comment = string_samples[i].value;
      graph_samples.push_back(gs);
    } else {
      graph_samples.push_back(GraphSample(string_samples[i]));
    }
  }

  for (unsigned i = 0; i < double_samples.size(); i++) {
    if (has_string.find(double_samples[i].time) == has_string.end()) {
      graph_samples.push_back(GraphSample(double_samples[i]));
    }
  }

  std::sort(graph_samples.begin(), graph_samples.end());

  double bin_width = client_tile_index.duration() / 512.0;
  
  double line_break_threshold = bin_width * 4.0;
  if (!doubles_binned && double_samples.size() > 1) {
    // Find the median distance between samples
    std::vector<double> spacing(double_samples.size()-1);
    for (size_t i = 0; i < double_samples.size()-1; i++) {
      spacing[i] = double_samples[i+1].time - double_samples[i].time;
    }
    std::sort(spacing.begin(), spacing.end());
    double median_spacing = spacing[spacing.size()/2];
    // Set line_break_threshold to larger of 4*median_spacing and 4*bin_width
    line_break_threshold = std::max(line_break_threshold, median_spacing * 4);
  }

  if (graph_samples.size()) {
    log_f("gettile: outputting %zd samples", graph_samples.size());
    Json::Value tile(Json::objectValue);
    tile["level"] = Json::Value(tile_level);
    // An aside about offset type and precision:
    // JSONCPP doesn't have a long long type;  to preserve full resolution we need to convert to double here.  As Javascript itself
    // will read this as a double-precision value, we're not introducing a problem.
    // For a detailed discussion, see https://sites.google.com/a/bodytrack.org/wiki/website/tile-coordinates-and-numeric-precision
    // Irritatingly, JSONCPP wants to add ".0" to the end of floating-point numbers that don't need it.  This is inconsistent
    // with Javascript itself and simply introduces extra bytes to the representation
    tile["offset"] = Json::Value((double)tile_offset);
    tile["fields"] = Json::Value(Json::arrayValue);
    tile["fields"].append(Json::Value("time"));
    tile["fields"].append(Json::Value("mean"));
    tile["fields"].append(Json::Value("stddev"));
    tile["fields"].append(Json::Value("count"));
    if (has_fifth_col) tile["fields"].append(Json::Value("comment"));
    Json::Value data(Json::arrayValue);

    double previous_sample_time = client_tile_index.start_time();
    bool previous_had_value = true;

    for (unsigned i = 0; i < graph_samples.size(); i++) {
      // TODO: improve linebreak calculations:
      // 1) observe channel specs line break size from database (expressed in time;  some observations have long time periods and others short)
      // 2) insert breaks at beginning or end of tile if needed
      // 3) should client be the one to decide where line breaks are (if we give it the threshold?)
      if (graph_samples[i].time - previous_sample_time > line_break_threshold ||
	  !graph_samples[i].has_value || !previous_had_value) {
	// Insert line break, which has value -1e+308
	Json::Value sample = Json::Value(Json::arrayValue);
	sample.append(Json::Value(0.5*(graph_samples[i].time+previous_sample_time)));
	sample.append(Json::Value(-1e308));
	sample.append(Json::Value(0));
	sample.append(Json::Value(0));
	if (has_fifth_col) sample.append(Json::Value()); // NULL
	data.append(sample);
      }
      previous_sample_time = graph_samples[i].time;
      previous_had_value = graph_samples[i].has_value;
      {	
	Json::Value sample = Json::Value(Json::arrayValue);
	sample.append(Json::Value(graph_samples[i].time));
	sample.append(Json::Value(graph_samples[i].has_value ? graph_samples[i].value : 0.0));
	// TODO: fix datastore so we never see NAN crop up here!
	sample.append(Json::Value(isnan(graph_samples[i].stddev) ? 0 : graph_samples[i].stddev));
	sample.append(Json::Value(graph_samples[i].weight));
	if (has_fifth_col) {
	  sample.append(graph_samples[i].has_comment ? Json::Value(graph_samples[i].comment) : Json::Value());
	}
	data.append(sample);
      }

    }
    if (client_tile_index.end_time() - previous_sample_time > line_break_threshold ||
	!previous_had_value) {
      // Insert line break, which has value -1e+308
      Json::Value sample = Json::Value(Json::arrayValue);
      sample.append(Json::Value(0.5*(previous_sample_time + client_tile_index.end_time())));
      sample.append(Json::Value(-1e308));
      sample.append(Json::Value(0));
      sample.append(Json::Value(0));
      if (has_fifth_col) sample.append(Json::Value()); // NULL
      data.append(sample);
    }
    tile["data"] = data;
    // only include the sample_width field if we actually binned
    if (doubles_binned) {
      tile["sample_width"] = bin_width;
    }
    printf("%s\n", rtrim(Json::FastWriter().write(tile)).c_str());
  } else {
    log_f("gettile: no samples");
    printf("{}");
  }
  log_f("gettile: finished in %lld msec", millitime() - begin_time);

  return 0;
}
Пример #8
0
int     gi(void) { return ti(gs()); }
Пример #9
0
SVector ngs(int n) { SVector r=newSV(n); int i; for(i=0;i<n;i++)r->value[i]=gs(); return r; }
Пример #10
0
int main(int argc,char *argv[])
{
	int opt;
	size_t n =0,electronsUp=0,total=0;
	RealType offset = 0;
	std::vector<size_t> sites;
	std::vector<std::string> str;
	bool ladder = false;
	RealType step = 0;
	while ((opt = getopt(argc, argv, "n:e:s:t:o:i:l")) != -1) {
		switch (opt) {
		case 'n':
			n = atoi(optarg);
			break;
		case 'e':
			electronsUp = atoi(optarg);
			break;
		case 's':
			PsimagLite::tokenizer(optarg,str,",");
			for (size_t i=0;i<str.size();i++)
				sites.push_back(atoi(str[i].c_str()));
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'l':
			ladder = true;
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}
	if (n==0 || total==0) throw std::runtime_error("Wrong usage\n");

	size_t dof = 1; // spinless

	GeometryParamsType geometryParams;
	geometryParams.sites = n;
	GeometryLibraryType* geometry;

	if (!ladder) {
		geometryParams.type = GeometryLibraryType::CHAIN;
		geometry = new GeometryLibraryType(geometryParams);
	} else {
		geometryParams.type = GeometryLibraryType::LADDER;
		geometryParams.leg = 2;
		geometryParams.hopping.resize(2);
		geometryParams.hopping[0] = 1.0;
		geometryParams.hopping[1] = 0.5;
		geometry = new GeometryLibraryType(geometryParams);
	}

	std::cerr<<geometry;
	
	ConcurrencyType concurrency(argc,argv);
	EngineType engine(*geometry,concurrency,dof,true);

	std::vector<size_t> ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	size_t sigma =0;
	OpNormalFactoryType opNormalFactory(engine);
	OperatorType& myOp = opNormalFactory(OperatorType::DESTRUCTION,sites[0],sigma);
	HilbertStateType phi2 = gs;
	myOp.applyTo(phi2);
	
//	FieldType density = scalarProduct(phi2,phi2);
//	std::cerr<<"density="<<density<<"\n";
	
	std::cout<<"#site="<<sites[0]<<"\n";
	std::cout<<"#site2="<<sites[1]<<"\n";
	for (size_t it = 0; it<total; it++) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		RealType time = it * step + offset;
		EtoTheIhTimeType eih(time,engine,0);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		HilbertStateType phi = gs;
		myOp.applyTo(phi);
		eihOp.applyTo(phi);
		OperatorType& myOp2 = opNormalFactory(OperatorType::DESTRUCTION,sites[1],sigma);
		myOp2.applyTo(phi);
		std::cout<<time<<" "<<scalarProduct(phi,phi)<<"\n";
	}
	
	delete geometry;
}
Пример #11
0
EvolDF1nlep::EvolDF1nlep(unsigned int dim_i, schemes scheme, orders order, orders_ew 
    order_ew, const StandardModel& model)
: RGEvolutor(dim_i, scheme, order, order_ew), model(model), V(dim_i,0.), Vi(dim_i,0.),
    gs(dim_i,0.), Js(dim_i,0.), ge0(dim_i,0.), K0(dim_i,0.), ge11(dim_i,0.), K11(dim_i,0.),
    JsK0V(dim_i,0.), ViK0Js(dim_i,0.), Gamma_s0T(dim_i,0.), Gamma_s1T(dim_i,0.), 
    Gamma_eT(dim_i,0.), Gamma_seT(dim_i,0.), JsV(dim_i,0.), ViJs(dim_i,0.), K0V(dim_i,0.), 
    ViK0(dim_i,0.), K11V(dim_i,0.), ViK11(dim_i,0.), ge11sing(dim_i,0.), K11sing(dim_i,0.), 
    K11singV(dim_i,0.), e(dim_i,0.), dim(dim_i) {
    
    int nu = 0, nd = 0;
    double  b0 = 0., b1 = 0.;
    
    /* L=3 --> u,d,s,c (nf=3) L=2 --> u,d,s,c (nf=4)  L=1 --> u,d,s,c,b (nf=5) L=0 --> u,d,s,c,b,t (nf=6)*/
    for(int L=3; L>-1; L--){
        
        b0 = model.Beta0(6-L);
        b1 = model.Beta1(6-L);
        
	if(L == 3){nd = 2; nu = 1;} 
        if(L == 2){nd = 2; nu = 2;}
        if(L == 1){nd = 3; nu = 2;} 
        if(L == 0){nd = 3; nu = 3;}
        
        Gamma_s0T = AnomalousDimension_nlep_S(LO,nu,nd).transpose();
        Gamma_s1T = AnomalousDimension_nlep_S(NLO,nu,nd).transpose();
        Gamma_eT = AnomalousDimension_nlep_EM(LO,nu,nd).transpose();
        Gamma_seT = AnomalousDimension_nlep_EM(NLO,nu,nd).transpose();
        
        AnomalousDimension_nlep_S(LO,nu,nd).transpose().eigensystem(V,e);
        Vi = V.inverse();
        
        /* magic numbers of U0 */
        for(unsigned int i = 0; i < dim; i++){
            a[L][i] = e(i).real()/2./b0;
            for (unsigned int j = 0; j < dim; j++){
                for (unsigned int k = 0; k < dim; k++){
                    b[L][i][j][k] = V(i, k).real() * Vi(k, j).real();
                }
            }
        }
    
        gs = (b1/2./b0/b0) * Vi * Gamma_s0T * V - (1./2./b0) * Vi * Gamma_s1T * V;
        for(unsigned int i = 0; i<dim ; i++){
            for(unsigned int j = 0; j<dim ; j++){  
                gs.assign( i , j, gs(i,j)/(1. + a[L][i] - a[L][j]));
            }
        }
        Js = V * gs * Vi;
        
        /*magic numbers related to Js*/
        JsV = Js*V;
        ViJs = Vi * Js;
        for(unsigned int i = 0; i<dim; i++){
            for(unsigned int j = 0; j<dim; j++){
                for(unsigned int k = 0; k<dim; k++){
                    c[L][i][j][k] = JsV(i, k).real() * Vi(k, j).real();
                    d[L][i][j][k] = -V(i, k).real() * ViJs(k, j).real();
                }
            }
        }
        
        ge0 = (1./2./b0) *  Vi * Gamma_eT * V;
        for(unsigned int i = 0; i<dim ; i++){
            for(unsigned int j = 0; j<dim ; j++){
                ge0.assign( i , j, ge0(i,j)/(1. - a[L][i] + a[L][j]));
            }
        }
        K0 = V * ge0 * Vi;
        
        /*magic numbers related to K0*/
        K0V = K0*V;
        ViK0 = Vi * K0;
        for(unsigned int i = 0; i<dim; i++){
            for(unsigned int j = 0; j<dim; j++){
                for(unsigned int k = 0; k<dim; k++){
                    m[L][i][j][k] = K0V(i, k).real() * Vi(k, j).real();
                    n[L][i][j][k] = -V(i, k).real() * ViK0(k, j).real();
                }
            }
        }
        
        ge11 = Gamma_seT - (b1/b0) * Gamma_eT + Gamma_eT * Js - Js * Gamma_eT;
        ge11 = Vi * ge11;
        ge11 = ge11 * V;
        for(unsigned int i = 0; i<dim ; i++){
            for(unsigned int j = 0; j<dim ; j++){
                if(fabs(a[L][j]-a[L][i])> 0.00000000001){
                    ge11.assign( i , j, ge11(i,j)/( 2. * b0 * (a[L][j] - a[L][i])));
                }
                else{
                    ge11sing.assign( i, j, ge11(i,j)/2./b0);
                    ge11.assign( i , j, 0.);
                }
            }
        }
        K11 = V * ge11 * Vi;
        K11sing = V * ge11sing * Vi;
        /*magic numbers related to K11*/
        K11V = K11 * V;
        ViK11 = Vi * K11;
        K11singV = K11sing * V;
        if(L==1){
        }
        for(unsigned int i = 0; i<dim ; i++){
            for(unsigned int j = 0; j<dim ; j++){
                    for(unsigned int k = 0; k<dim ; k++){
                        o[L][i][j][k] = K11V(i, k).real() * Vi(k, j).real();
                        p[L][i][j][k] = -V(i, k).real() * ViK11(k, j).real();
                        u[L][i][j][k] = K11singV(i, k).real() * Vi(k, j).real();
                    }
                }    
            }
        
        /*magic numbers related to K12 and K13*/
        JsK0V = Js * K0 * V; 
        ViK0Js = Vi * K0 * Js;
        for(unsigned int i = 0; i<dim ; i++){
            for(unsigned int j = 0; j<dim ; j++){
                for(unsigned int k=0; k<dim; k++){
                    q[L][i][j][k] =  JsK0V(i, k).real() * Vi(k, j).real();
                    r[L][i][j][k] =  V(i, k).real() * ViK0Js(k, j).real();
                    s[L][i][j][k] = -JsV(i, k).real() * ViK0(k, j).real();
                    t[L][i][j][k] = -K0V(i, k).real() * ViJs(k, j).real();
                }
            }
        }
    }        
}
Пример #12
0
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    //从lpDrawItemStruct获取控件的相关信息
    CRect rect =  lpDrawItemStruct->rcItem;
    CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
    int nSaveDC=pDC->SaveDC();
    UINT state = lpDrawItemStruct->itemState;

    TCHAR strText[MAX_PATH + 1];
    ::GetWindowText(m_hWnd, strText, MAX_PATH);
    BOOL bFocus=m_bOver;   //按钮是否被选中(点击或tab或默认)
    CString strImgPath = "" ;

    //获取按钮的状态
    if (state & ODS_FOCUS || state & ODS_SELECTED || state & ODS_DEFAULT)
    {
        bFocus = TRUE;
    }

    if (m_bIsDrawImgBtn)
    {
        if (bFocus)  //有焦点或鼠标经过
        {
            strImgPath = m_strPathHover;
        }
        else
        {
            strImgPath = m_strPathNormal;
        }
        Graphics gs(pDC->m_hDC);
        Image img(strImgPath.AllocSysString());
        gs.DrawImage(&img,0,0,rect.Width(),rect.Height());
    }
    else
    {
        Color clrStart,clrEnd;
        COLORREF clrBorder;
        if (bFocus)
        {
            clrStart=m_clrTodStartHover;
            clrEnd=m_clrBottomEndHover;
            clrBorder=m_clrBorderHover;

        }
        else
        {
            clrStart=m_clrTodStartNormal;
            clrEnd=m_clrBottomEndNormal;
            clrBorder=m_clrBorderNormal;
        }
        int cxBorder=GetSystemMetrics(SM_CXEDGE);
        int cyBorder=GetSystemMetrics(SM_CYEDGE);
        Graphics myGraphics(pDC->m_hDC);
        LinearGradientBrush linGrBrush(
            Rect(0,0,rect.Width()/*-cxBorder*/,rect.Height()/*-cyBorder*/),
            clrStart,//Color(255, 238, 238, 238),
            clrEnd,//Color(200, 208,208,208),
            LinearGradientModeVertical);
        myGraphics.FillRectangle(&linGrBrush, 1,1,rect.Width()-cxBorder,rect.Height()-cyBorder);

        // 	CRgn rgn;
        // 	rgn.CreateRoundRectRgn(rect.left,rect.top,rect.right,rect.bottom,2,2);
        // 	myGraphics.FillRegion(&linGrBrush,&Region((HRGN)rgn.m_hObject));

        CPen pen;
        pen.CreatePen(PS_SOLID,1,clrBorder);//RGB(162,203,236)
        pDC->SelectObject(&pen);
        pDC->SelectStockObject(NULL_BRUSH);
        pDC->RoundRect(&rect,CPoint(3,3));

        //	pDC->SetPixel(rect.right-2,rect.bottom-2,clrEnd.ToCOLORREF());
    }
    //显示按钮的文本
    if (strText!=NULL)
    {
        CFont* pFont = GetFont();
        CFont* pOldFont = pDC->SelectObject(pFont);
        CSize szExtent = pDC->GetTextExtent(strText, lstrlen(strText));
        CPoint pt( rect.CenterPoint().x - szExtent.cx / 2+1, rect.CenterPoint().y - szExtent.cy / 2+1);
        if (state & ODS_SELECTED)
            pt.Offset(1, 1);
        int nMode = pDC->SetBkMode(TRANSPARENT);
        //输出首字母带下划线效果文本
        if (state & ODS_DISABLED)
            pDC->DrawState(pt, szExtent, strText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
        else
            pDC->DrawState(pt, szExtent, strText, DSS_NORMAL, TRUE, 0, (HBRUSH)NULL);

        pDC->SelectObject(pOldFont);
        pDC->SetBkMode(nMode);
    }

    pDC->RestoreDC(nSaveDC);
}
Пример #13
0
int main(int argc,char *argv[])
{
	int opt;
	size_t n =0,electronsUp=0,total=0;
	RealType offset = 0;
	std::vector<size_t> sites;
	std::vector<std::string> str;
	RealType step = 0;
	GeometryParamsType geometryParams;
	std::vector<RealType> v;

	while ((opt = getopt(argc, argv, "n:e:b:s:t:o:i:g:p:")) != -1) {
		switch (opt) {
		case 'n':
			n = atoi(optarg);
			break;
		case 'e':
			electronsUp = atoi(optarg);
			break;
		case 's':
			str.clear();
			PsimagLite::tokenizer(optarg,str,",");
			for (size_t i=0;i<str.size();i++) {
				sites.push_back(atoi(str[i].c_str()));
			}
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'g':
			str.clear();
			PsimagLite::tokenizer(optarg,str,",");
			setMyGeometry(geometryParams,str);
			break;
		case 'p':
			readPotential(v,optarg);
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}
	if (n==0 || total==0) throw std::runtime_error("Wrong usage\n");
	
	size_t dof = 2; // spin up and down
	geometryParams.sites = n;
	GeometryLibraryType geometry(geometryParams);

	if (geometryParams.type!=GeometryLibraryType::KTWONIFFOUR) {
		geometry.addPotential(v);
	}

	std::cerr<<geometry;
	
	ConcurrencyType concurrency(argc,argv);
	EngineType engine(geometry,concurrency,dof,false);
	
	std::vector<size_t> ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	bool verbose = false;
	HilbertStateType gs(engine,ne,debug);
	
// 	size_t sigma3 = 0;
	
	FieldType superdensity = calcSuperDensity(sites[0],sites[1],gs,engine);
	std::cout<<"#superdensity="<<superdensity<<"\n";
	std::cout<<"#site="<<sites[0]<<" site2="<<sites[1]<<"\n";
	
	PsimagLite::Range<ConcurrencyType> range(0,total,concurrency);
	enum {SPIN_UP,SPIN_DOWN};
	
	while(!range.end()) {
		size_t it = range.index();

		OpNormalFactoryType opNormalFactory(engine);
		OpLibFactoryType opLibFactory(engine);
		OpDiagonalFactoryType opDiagonalFactory(engine);
		
		RealType time = it * step + offset;
		EtoTheIhTimeType eih(time,engine,0);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		
// 		HilbertStateType savedVector = gs;
//		FieldType savedValue = 0;
// 		FieldType sum = 0;
		std::vector<HilbertStateType*> savedVector(4);
		
		for (size_t sigma = 0;sigma<2;sigma++) {
			HilbertStateType phi = gs;
			LibraryOperatorType& myOp = opLibFactory(
				LibraryOperatorType::N,sites[0],1-sigma);
			myOp.applyTo(phi);
			
			OperatorType& myOp2 = opNormalFactory(OperatorType::CREATION,
												  sites[0],sigma);
			myOp2.applyTo(phi);
			
			for (size_t sigma2 = 0;sigma2 < 2;sigma2++) {
				savedVector[sigma+sigma2*2] = new HilbertStateType(phi);
				
				
				LibraryOperatorType& myOp3 = opLibFactory(
					LibraryOperatorType::NBAR,sites[1],1-sigma2);
				myOp3.applyTo(*savedVector[sigma+sigma2*2]);
				
				OperatorType& myOp4 = opNormalFactory(
					OperatorType::DESTRUCTION,sites[1],sigma2);
				myOp4.applyTo(*savedVector[sigma+sigma2*2]);
				
				if (verbose) std::cerr<<"Applying exp(iHt)\n";
				eihOp.applyTo(*savedVector[sigma+sigma2*2]);
				
				if (verbose) std::cerr<<"Applying c_{p down}\n";
				OperatorType& myOp6 = opNormalFactory(
					OperatorType::DESTRUCTION,sites[2],SPIN_DOWN);
				myOp6.applyTo(*savedVector[sigma+sigma2*2]);
				
				if (verbose) std::cerr<<"Applying c_{p up}\n";
				OperatorType& myOp7 = opNormalFactory(
					OperatorType::DESTRUCTION,sites[2],SPIN_UP);
				myOp7.applyTo(*savedVector[sigma+sigma2*2]);
				
// 				if (verbose) std::cerr<<"Adding "<<sigma<<" "<<sigma2<<" "<<it<<"\n";
// 				
// 				if (sigma ==0 && sigma2 ==0) savedVector = phi3;
// 				if (sigma ==1 && sigma2 ==1) {
// 					savedValue = scalarProduct(phi3,savedVector);
// 				}
// 				sum += scalarProduct(phi3,phi3);
// 				if (verbose) std::cerr<<"Done with scalar product\n";
			}
		}
		FieldType sum = 0;
		size_t total = savedVector.size()*savedVector.size()/2;
		for (size_t x=0;x<total;x++) {
			size_t sigma = (x & 3);
			size_t sigma2 = (x & 12);
			sigma2 >>= 2;
			sum += scalarProduct(*savedVector[sigma],*savedVector[sigma2]);
		}
		for (size_t x=0;x<savedVector.size();x++) delete savedVector[x];
		
		std::cout<<time<<" "<<(2.0*sum)<<"\n";
		range.next();
	}
}
Пример #14
0
int main(int argc,char *argv[])
{
	int opt;
	size_t n =0;
	size_t electronsUp=0;
	RealType step = 0;
	RealType offset=0;
	size_t total=0;
	size_t site = 0;
	bool ladder = false;
	std::vector<RealType> v;
	std::vector<std::string> str;

	while ((opt = getopt(argc, argv, "n:e:s:p:t:o:i:l")) != -1) {
		switch (opt) {
			case 'n':
				n = atoi(optarg);
				v.resize(n,0);
				break;
			case 'e':
				electronsUp = atoi(optarg);
				break;
			case 's':
				site = atoi(optarg);
				break;
			case 'p':
				if (v.size()==0) {
					std::string s(argv[0]);
					s += "-p must come after -n\n";
					throw std::runtime_error(s.c_str());
				}
				PsimagLite::tokenizer(optarg,str,",");
				if (str.size() & 1) {
					std::string s(argv[0]);
					s += " Expecting pairs for -p\n";
					throw std::runtime_error(s.c_str());
				}
				for (size_t i=0;i<str.size();i+=2) {
					v[atoi(str[i].c_str())] = atof(str[i+1].c_str());
				}
				break;
			case 't':
				total = atoi(optarg);
				break;
			case 'i':
				step = atof(optarg);
				break;
			case 'o':
				offset = atof(optarg);
				break;
			case 'l':
				ladder = true;
				break;
			default: /* '?' */
				throw std::runtime_error("Wrong usage\n");
		}
	}
	if (n==0 || total==0) throw std::runtime_error("Wrong usage\n");

	size_t dof = 1; // spinless
	GeometryParamsType geometryParams;
	geometryParams.sites = n;
	GeometryLibraryType* geometry;
	if (!ladder) {
		geometryParams.type = GeometryLibraryType::CHAIN;
		geometry = new GeometryLibraryType(geometryParams);
	} else {
		geometryParams.hopping.resize(2);
		geometryParams.hopping[0] = 1.0;
		geometryParams.hopping[1] = 0.5;
		geometryParams.type = GeometryLibraryType::LADDER;
		geometry = new GeometryLibraryType(geometryParams);
	}
	geometry->addPotential(v);
	
	std::cerr<<v;

	ConcurrencyType concurrency(argc,argv);
	EngineType engine(*geometry,concurrency,dof,false);

	std::vector<size_t> ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	size_t sigma =0;

	std::cout<<"#site="<<site<<"\n";

	OpLibFactoryType opLibFactory(engine);
	for (size_t i=0;i<total;++i) {
		RealType beta = i*step + offset;
		doOneBeta(engine,ne,opLibFactory,site,sigma,beta);
	}
	delete geometry;
}
Пример #15
0
int main(int argc, char* argv[])
{
    // Relaxation parameters
    double omega_start = 0.95;
    double omega_delta = 0.25;
    int    omega_count = 2;
    // Tolerance factor
    double tol=1e-6;
    // Output precision
    int p=9;
    // Matrix dimension
    int N=8;
    // Band width
    int band=3;
    // Matrix specification
    Eigen::ArrayXXd A = Eigen::ArrayXXd::Zero(N,2*band+1);

    //diagonal
    for (int i=0; i<N; i++) {A(i,band) = 8.0;}
    //lower diagonal
    for (int i=1; i<N; i++) { 
        //if (i>=2) A(i,band-2) = 3;
        //if (i>=3) A(i,band-3) = 1;
        A(i,band-2) = 2.0;
        A(i,band-3) = 1.0;
    }
    //upper diagonal
    for (int i=0; i<N-1; i++) 
    {
        //if (i<=5) A(i,band+2) = -2;
        //if (i<=4) A(i,band+3) = -1;
        A(i,band+2) = -1.0;
        A(i,band+3) = -2.0;
    }

    Eigen::MatrixXd b = Eigen::VectorXd::Zero(N);
    for (int i=0; i<N; i++) {
        b(i) = (2.0*i-3.0)/(2.0*i*i+1.0);
    }
    
    // Jacobi iterative solve
    std::tuple<Eigen::VectorXd, int> res = jacobi(A, band, b, tol);
    Eigen::VectorXd x = std::get<0>(res);
    int ic = std::get<1>(res);
    Eigen::VectorXd r = b - band_mult(A,band,band,x);

    std::cout << std::fixed
              << std::setprecision(p)
              << "Jacobi: ,"
              << ", Iterations =, " << ic 
              << ", residual =, " << r.norm() 
              << std::endl;

    std::cout << "x = " << std::endl;
    for (int i=0; i<N; i++) {
        std::cout << std::fixed << std::setprecision(p) << x(i) << std::endl;
    }
    
    // Gauss-Seidel iterative solve
    res = gs(A, band, b, tol);
    x = std::get<0>(res);
    ic = std::get<1>(res);
    r = b - band_mult(A,band,band,x);

    std::cout << std::fixed
              << std::setprecision(p)
              << "Gauss-Seidel: ,"
              << ", Iterations =, " << ic 
              << ", residual =, " << r.norm() 
              << std::endl;

    std::cout << "x = " << std::endl;
    for (int i=0; i<N; i++) {
        std::cout << std::fixed << std::setprecision(p) << x(i) << std::endl;
    }

    // SOR iterative solve for all omega values
    double omega = omega_start;
    for (int k=0; k<omega_count; k++) {
        std::tuple<Eigen::VectorXd, int> res = sor(omega, A, band, b, tol);
        Eigen::VectorXd x = std::get<0>(res);
        int ic = std::get<1>(res);
        Eigen::VectorXd r = b - band_mult(A,band,band,x);

        std::cout << std::fixed
                  << std::setprecision(p)
                  << "Omega = ," << omega
                  << ", Iterations =, " << ic 
                  << ", residual =, " << r.norm() 
                  << std::endl;

        std::cout << "x = " << std::endl;
        for (int i=0; i<N; i++) {
            std::cout << std::fixed << std::setprecision(p) << x(i) << std::endl;
        }
        
        omega += omega_delta;
    }

    return 0;
}
Пример #16
0
ShaderPointSpriteGen::ShaderPointSpriteGen(bool color_per_vertex, bool size_per_vertex)
{
	std::string vs("#version 150\n");
	std::string fs("#version 150\n");
	std::string gs("#version 150\n");

	if (color_per_vertex)
	{
		vs += std::string("#define WITH_COLOR 1\n");
		gs += std::string("#define WITH_COLOR 1\n");
		fs += std::string("#define WITH_COLOR 1\n");
	}
	else
	{
		vs += std::string("#define WITH_COLOR 0\n");
		gs += std::string("#define WITH_COLOR 0\n");
		fs += std::string("#define WITH_COLOR 0\n");
	}

	if (size_per_vertex)
	{
		vs += std::string("#define WITH_SIZE 1\n");
		gs += std::string("#define WITH_SIZE 1\n");
		fs += std::string("#define WITH_SIZE 1\n");
	}
	else
	{
		vs += std::string("#define WITH_SIZE 0\n");
		gs += std::string("#define WITH_SIZE 0\n");
		fs += std::string("#define WITH_SIZE 0\n");
	}

	vs += std::string(vertex_shader_source_);
	gs += std::string(geometry_shader_source_);
	fs += std::string(fragment_shader_source_);

	prg_.addShaderFromSourceCode(QOpenGLShader::Vertex, vs.c_str());
	prg_.addShaderFromSourceCode(QOpenGLShader::Geometry, gs.c_str());
	prg_.addShaderFromSourceCode(QOpenGLShader::Fragment, fs.c_str());
	prg_.bindAttributeLocation("vertex_pos", ATTRIB_POS);

	if (color_per_vertex)
		prg_.bindAttributeLocation("vertex_color", ATTRIB_COLOR);

	if (size_per_vertex)
		prg_.bindAttributeLocation("vertex_size", ATTRIB_SIZE);

	prg_.link();
	get_matrices_uniforms();

	unif_color_ = prg_.uniformLocation("color");
	unif_ambiant_ = prg_.uniformLocation("ambiant");
	unif_light_pos_ = prg_.uniformLocation("lightPos");
	unif_size_ = prg_.uniformLocation("point_size");
	unif_plane_clip_ = prg_.uniformLocation("plane_clip");

	if (!color_per_vertex)
		set_color(QColor(250, 0, 0));

	set_ambiant(QColor(5, 5, 5));

	if (!size_per_vertex)
		set_size(1.0f);

	set_light_position(QVector3D(10, 10, 1000));
}
Пример #17
0
int main(int argc,char* argv[])
{
	int opt;
	PsimagLite::String file("");

	while ((opt = getopt(argc, argv, "f:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		default: /* '?' */
			err("Wrong usage\n");
		}
	}

	if (file == "") err("Wrong usage\n");

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,
	                                                         geometryParams.sites);

	SizeType dof = 2; // spin

	GeometryLibraryType geometry(geometryParams);
	std::cerr<<geometry;
	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),
	                  geometryParams.outputFile,
	                  dof,
	                  EngineType::VERBOSE_YES);
	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp);
	HilbertStateType gs(engine,ne);
	RealType sum = 0;
	for (SizeType i=0;i<ne[0];i++) sum += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*sum<<"\n";

	SizeType n = geometryParams.sites;
	SizeType norb = (geometryParams.type == GeometryLibraryType::FEAS ||
	                 geometryParams.type == GeometryLibraryType::FEAS1D) ?
	            geometryParams.orbitals : 1;

	for (SizeType orbital1=0; orbital1<norb; orbital1++) {
		for (SizeType orbital2=0; orbital2<norb; orbital2++) {
			for (SizeType site = 0; site<n ; site++) {
				OpNormalFactoryType opNormalFactory(engine);
				OperatorType& myOp1 = opNormalFactory(OperatorType::DESTRUCTION,
				                                      site+orbital1*n,
				                                      SPIN_DOWN);
				OperatorType& myOp2 = opNormalFactory(OperatorType::CREATION,
				                                      site+orbital1*n,
				                                      SPIN_UP);
				OperatorType& myOp3 = opNormalFactory(OperatorType::DESTRUCTION,
				                                      site+orbital1*n,
				                                      SPIN_UP);
				OperatorType& myOp4 = opNormalFactory(OperatorType::CREATION,
				                                      site+orbital1*n,
				                                      SPIN_DOWN);
				HilbertStateType phi1 = gs;
				myOp1.applyTo(phi1);
				myOp2.applyTo(phi1);
				HilbertStateType phi2 = gs;
				myOp3.applyTo(phi2);
				myOp4.applyTo(phi2);
				for (SizeType site2=0; site2<n; site2++) {
					OperatorType& myOp5 = opNormalFactory(OperatorType::DESTRUCTION,
					                                      site2+orbital2*n,
					                                      SPIN_DOWN);
					OperatorType& myOp6 = opNormalFactory(OperatorType::CREATION,
					                                      site2+orbital2*n,
					                                      SPIN_UP);
					OperatorType& myOp7 = opNormalFactory(OperatorType::DESTRUCTION,
					                                      site2+orbital2*n,
					                                      SPIN_UP);
					OperatorType& myOp8 = opNormalFactory(OperatorType::CREATION,
					                                      site2+orbital2*n,
					                                      SPIN_DOWN);
					HilbertStateType phi3 = gs;
					myOp5.applyTo(phi3);
					myOp6.applyTo(phi3);
					HilbertStateType phi4 = gs;
					myOp7.applyTo(phi4);
					myOp8.applyTo(phi4);
					RealType  x13 = scalarProduct(phi3,phi1);
					RealType  x24 = scalarProduct(phi4,phi2);
					std::cout<<(x13+x24)<<" ";
					//cicj(site,site2) += scalarProduct(gs,phi);
				}

				std::cout<<"\n";
			}

			std::cout<<"-------------------------------------------\n";
		}
	}
}
Пример #18
0
TEST(GhostscriptTest, available1) {
	const char *args[] = {"test", "-dNODISPLAY"};
	Ghostscript gs(2, args);
	ASSERT_TRUE(gs.available());
}
Пример #19
0
bool 
SearchPointVector::PruneInterior()
{
  GrahamScan gs(*this);
  return gs.PruneInterior();
}
Пример #20
0
unsigned long long h (unsigned long long a, unsigned long long b)
{
  return gs (a | 0x100000000ull, b | 0x600000000ull);
}
Пример #21
0
void CMyDialog::DrawCloseButton(CDC *pDC,int enumStatus)
{
	Color clrStart,clrEnd,clrBorder,clrCloseMark;
	CRect rc;
	GetClientRect(rc);
	if (enumStatus==DTS_NORMAL)
	{
		clrStart=Color(231,231,231);
		clrEnd=Color(227,227,227);
		clrBorder=Color(158,158,158);
		clrCloseMark=Color(128,128,128);
		
		clrStart=Color(219,219,220);
	    clrEnd=Color(190,192,193);
	}
	else if (enumStatus==DTS_HOVER)
	{
		clrStart=Color(245,28,6);
		clrEnd=Color(207,9,7);
		clrBorder=Color(187,5,0);
		clrCloseMark=Color(255,255,255);
	}
	else// if (enumStatus==DTS_CLICKED)
	{
		clrStart=Color(207,9,7);	
		clrEnd=Color(245,28,6);
		clrBorder=Color(187,5,0);
		clrCloseMark=Color(255,255,255);
	}
	m_rcClose.SetRect(rc.right-36,1,rc.right-6,21);
	GraphicsPath path;
	int nRadius=4;
	Point point[5];
	point[0]=Point(m_rcClose.right,m_rcClose.bottom-nRadius);
	point[1]=Point(m_rcClose.right,m_rcClose.top);
	point[2]=Point(m_rcClose.left,m_rcClose.top);
	point[3]=Point(m_rcClose.left,m_rcClose.bottom);
	point[4]=Point(m_rcClose.right-nRadius,m_rcClose.bottom);
	path.AddLines(point,5);
	path.AddArc(m_rcClose.right-2*nRadius,m_rcClose.bottom-2*nRadius,2*nRadius,2*nRadius,0,90);
	LinearGradientBrush linGrBrush(
		Rect(m_rcClose.left,m_rcClose.top,m_rcClose.Width(),m_rcClose.Height()),
		clrStart,
		clrEnd, 
		LinearGradientModeVertical);
	Graphics gs(pDC->m_hDC);
	gs.FillPath(&linGrBrush,&path);	
	CPoint ptCenter=m_rcClose.CenterPoint();
	if (enumStatus==DTS_CLICKED)
	{
		ptCenter.Offset(1,1);
	}
	CPen penMark(PS_SOLID,2,clrCloseMark.ToCOLORREF());
	CPen *pOldPen=pDC->SelectObject(&penMark);
	pDC->MoveTo(ptCenter.x-5,ptCenter.y-5);
	pDC->LineTo(ptCenter.x+5,ptCenter.y+5);
	pDC->MoveTo(ptCenter.x-5,ptCenter.y+5);
	pDC->LineTo(ptCenter.x+5,ptCenter.y-5);

// 	CPen penBorder(PS_SOLID,1,clrBorder.ToCOLORREF());
// 	pDC->SelectObject(&penBorder);
// 	pDC->MoveTo(m_rcClose.left-1,m_rcClose.top);
// 	pDC->LineTo(m_rcClose.left-1,m_rcClose.bottom);
	pDC->SelectObject(pOldPen);
}
Пример #22
0
int main(int argc, char *argv[])
{
    GlobalState gs(argc, argv);

    return gs.caveArtMain(argc, argv);
}
Пример #23
0
int main(int argc,char *argv[])
{
	int opt;
	PsimagLite::String file("");
	SizeType total=0;
	RealType offset = 0;
	RealType step = 0;
	SizeType centralSite =0;
	ObservableEnum what = OBS_SZ;

	while ((opt = getopt(argc, argv, "f:t:o:i:c:w:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'c':
			centralSite = atoi(optarg);
			break;
		case 'w':
			if (PsimagLite::String(optarg) == "c")
				what = OBS_C;
			else if (PsimagLite::String(optarg) == "sz")
				what = OBS_SZ;
			else
				throw std::runtime_error("observable" +
			                             PsimagLite::String(optarg) +
			                             " not supported\n");
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}

	if (file=="") {
		throw std::runtime_error("Wrong usage\n");
	}

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);

	SizeType dof = 1;

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;

	SizeType npthreads = 1;
	io.readline(npthreads,"Threads=");
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),
	                  geometryParams.outputFile,
	                  dof,
	                  EngineType::VERBOSE_YES);
	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp);
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	RealType Eg = 0;
	for (SizeType i=0;i<ne[0];i++) Eg += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*Eg<<"\n";

	std::cout<<"#TotalNumberOfSites="<<geometryParams.sites<<"\n";
	std::cout<<"#OmegaTotal="<<total<<"\n";
	std::cout<<"#OmegaBegin="<<offset<<"\n";
	std::cout<<"#OmegaStep="<<step<<"\n";
	std::cout<<"#GeometryKind="<<geometryParams.geometry<<"\n";
	std::cout<<"#TSPSites 1 "<<centralSite<<"\n";
	std::cout<<"#Threads="<<PsimagLite::Concurrency::codeSectionParams.npthreads<<"\n";
	std::cout<<"#What="<<what<<"\n";
	std::cout<<"#############\n";

	typedef PsimagLite::Parallelizer<SqOmegaParallel> ParallelizerType;
	ParallelizerType threadObject(PsimagLite::Concurrency::codeSectionParams);

	SqOmegaParams params(engine,gs,Eg,geometryParams.sites,centralSite,what);
	SqOmegaParallel helperSqOmega(params,total,step,offset);

	threadObject.loopCreate(helperSqOmega);

	helperSqOmega.print(std::cout);
}
Пример #24
0
int main(int argc,char *argv[])
{
	int opt;
	PsimagLite::String file("");
	SizeType total=0;
	RealType offset = 0;
	RealType step = 0;
	SizeType site3 = 0;

	while ((opt = getopt(argc, argv, "f:t:o:i:p:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'p':
			site3 = atoi(optarg);
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}

	if (file=="") {
		throw std::runtime_error("Wrong usage\n");
	}

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);
	PsimagLite::Vector<SizeType>::Type sites;
	GeometryParamsType::readVector(sites,file,"TSPSites");
	sites.resize(3);
	sites[2] = site3;

	SizeType dof = 1; // spinless

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;
	
	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),dof,true);

	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	SizeType sigma =0;
	OpNormalFactoryType opNormalFactory(engine);
	OperatorType& myOp = opNormalFactory(OperatorType::DESTRUCTION,sites[0],sigma);
	HilbertStateType phi2 = gs;
	myOp.applyTo(phi2);
	
//	FieldType density = scalarProduct(phi2,phi2);
//	std::cerr<<"density="<<density<<"\n";
	
	std::cout<<"#site="<<sites[0]<<"\n";
	std::cout<<"#site2="<<sites[1]<<"\n";
	for (SizeType it = 0; it<total; it++) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		RealType time = it * step + offset;
		EtoTheIhTimeType eih(time,engine,0);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		HilbertStateType phi = gs;
		myOp.applyTo(phi);
		eihOp.applyTo(phi);
		OperatorType& myOp2 = opNormalFactory(OperatorType::DESTRUCTION,sites[1],sigma);
		myOp2.applyTo(phi);
		std::cout<<time<<" "<<scalarProduct(phi,phi)<<"\n";
	}
}
Пример #25
0
SVector gss(void) { return strsplit(gs(), ' '); }
Пример #26
0
/** Imprime directamente sobre formato PDF */
bool MReportViewer::printReportToPDF(const QString &outPdfFile)
{
  if (report == 0)
    return false;

  QString gs(aqApp->gsExecutable());
  bool gsOk = false;
  QProcess *procTemp = new QProcess();
  procTemp->addArgument(gs);
  procTemp->addArgument("--version");
  gsOk = procTemp->start();
  delete procTemp;
  if (!gsOk) {
    QMessageBox *m =
      new QMessageBox(tr("Falta Ghostscript"),
                      tr("Para poder exportar a PDF debe instalar Ghostscript (http://www.ghostscript.com) y añadir\n"
                         "el directorio de instalación a la ruta de búsqueda de programas\ndel sistema (PATH).\n\n"),
                      QMessageBox::Critical, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this, 0,
                      false);
    m->show();
    return false;
  }

  QString outPsFile(AQ_DISKCACHE_DIRPATH + "/outprintpdf.ps");
  //QString outPsPdfFile(AQ_DISKCACHE_DIRPATH + "/outprintps.pdf");
  QFile::remove(outPsFile);
  //QFile::remove(outPsPdfFile);
  if (!printReportToPS(outPsFile))
    return false;

  QProcess *proc = new QProcess();
  proc->addArgument(gs);
  proc->addArgument("-q");
  proc->addArgument("-dBATCH");
  proc->addArgument("-dNOPAUSE");
  proc->addArgument("-dSAFER");
  proc->addArgument("-dCompatibilityLevel=1.4");
  proc->addArgument("-dPDFSETTINGS=/printer");
  proc->addArgument("-dAutoFilterColorImages=false");
  proc->addArgument("-sColorImageFilter=FlateEncode");
  proc->addArgument("-dAutoFilterGrayImages=false");
  proc->addArgument("-sGrayImageFilter=FlateEncode");
  proc->addArgument(QString("-r%1").arg(dpi_));

  switch ((QPrinter::PageSize) report->pageSize()) {
    case QPrinter::A0:
      proc->addArgument("-sPAPERSIZE=a0");
      break;
    case QPrinter::A1:
      proc->addArgument("-sPAPERSIZE=a1");
      break;
    case QPrinter::A2:
      proc->addArgument("-sPAPERSIZE=a2");
      break;
    case QPrinter::A3:
      proc->addArgument("-sPAPERSIZE=a3");
      break;
    case QPrinter::A4:
      proc->addArgument("-sPAPERSIZE=a4");
      break;
    case QPrinter::A5:
      proc->addArgument("-sPAPERSIZE=a5");
      break;
    case QPrinter::B0:
      proc->addArgument("-sPAPERSIZE=b0");
      break;
    case QPrinter::B1:
      proc->addArgument("-sPAPERSIZE=b1");
      break;
    case QPrinter::B2:
      proc->addArgument("-sPAPERSIZE=b2");
      break;
    case QPrinter::B3:
      proc->addArgument("-sPAPERSIZE=b3");
      break;
    case QPrinter::B4:
      proc->addArgument("-sPAPERSIZE=b4");
      break;
    case QPrinter::B5:
      proc->addArgument("-sPAPERSIZE=b5");
      break;
    case QPrinter::Legal:
      proc->addArgument("-sPAPERSIZE=legal");
      break;
    case QPrinter::Letter:
      proc->addArgument("-sPAPERSIZE=letter");
      break;
    case QPrinter::Executive:
      proc->addArgument("-sPAPERSIZE=executive");
      break;
    default: {
      QSize sz(report->pageDimensions());
      proc->addArgument(QString("-dDEVICEWIDTHPOINTS=%1").arg(sz.width()));
      proc->addArgument(QString("-dDEVICEHEIGHTPOINTS=%1").arg(sz.height()));
    }
  }

  proc->addArgument("-dAutoRotatePages=/PageByPage");
  proc->addArgument("-dUseCIEColor");
  proc->addArgument("-sOutputFile=" + outPdfFile);
  proc->addArgument("-sDEVICE=pdfwrite");
  proc->addArgument(outPsFile);

  if (!proc->start()) {
    delete proc;
    return false;
  }

  while (proc->isRunning())
    qApp->processEvents();

  delete proc;

  qApp->processEvents();
/**
  proc = new QProcess();
  proc->addArgument(gs);
  proc->addArgument("-q");
  proc->addArgument("-dBATCH");
  proc->addArgument("-dNOPAUSE");
  proc->addArgument("-dSAFER");
  proc->addArgument("-dNODISPLAY");
  proc->addArgument("-dDELAYSAFER");
  proc->addArgument("--");
  proc->addArgument("pdfopt.ps"); //Obsoleto desde gs 9.07
  proc->addArgument(outPsPdfFile);
  proc->addArgument(outPdfFile);

  if (!proc->start()) {
    delete proc;
    return false;
  }

  while (proc->isRunning())
    qApp->processEvents();

  delete proc;

  qApp->processEvents();
**/
  return true;
}
Пример #27
0
int main(int argc,char* argv[])
{
	int opt = 0;
	PsimagLite::String file("");

	while ((opt = getopt(argc, argv, "f:")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}

	if (file=="") {
		throw std::runtime_error("Wrong usage\n");
	}

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);

	SizeType dof = 2; // spin up and down

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;
	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);

	EngineType engine(geometry.matrix(),dof,true);
	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); // n. of up (= n. of  down electrons)
	HilbertStateType gs(engine,ne);
	RealType sum = 0;
	for (SizeType i=0;i<ne[0];i++) sum += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*sum<<"\n";

	SizeType n = geometryParams.sites;
	MatrixType m(n,n);
	FieldType sum2 = 0;
	SizeType effectiveN  = n;
	SizeType norb = (geometryParams.type == GeometryLibraryType::FEAS || geometryParams.type == GeometryLibraryType::FEAS1D) ? geometryParams.orbitals : 1;

	OpLibFactoryType opLibFactory(engine);
	for (SizeType site = 0; site<effectiveN ; site++) {
		FieldType y = 0;
		for (SizeType orb1 = 0;orb1<norb; orb1++) {
			HilbertStateType phi = gs;
			LibraryOperatorType& myOp = opLibFactory(LibraryOperatorType::DELTA,site+orb1*n,0);
			myOp.applyTo(phi);
			y += scalarProduct(phi,gs);
			for (SizeType site2=0; site2<effectiveN; site2++) {
				for (SizeType orb2=0;orb2<norb;orb2++) {
					HilbertStateType phi2 = gs;
					LibraryOperatorType& myOp2 = opLibFactory(LibraryOperatorType::DELTA,site2+orb2*n,0);
					myOp2.applyTo(phi2);
					FieldType x = scalarProduct(phi2,phi);
					std::cout<<x<<" ";
					std::cout.flush();
					m(site,site2) += x;
					sum2 += y*y;
				}
			}
			std::cout<<"\n";
		}
	}
}
Пример #28
0
int	main(void)
{
	int	ch;
	char	comm[256];
	struct	stat st;


	printf("RECV -- 99/4A ROM dump receiver by Edward Swartz.\n\n"
	       "Companion to TRANS on the 99/4A.\n\n");

	if (stat("MODULES",&st) || stat("ROMS",&st) || stat("MODULES.INF",&st))
	{
		printf("This program needs to be run from the directory where V9t9.EXE,\n"
		       "MODULES.INF, etc., are located.  (Use RECV.BAT from that directory.)\n");
		exit(1);
	}

	printf("In order to use this program, TRANS must be running on a\n"
	       "99/4A system connected to this PC by a serial cable.\n"
	       "It's best to start the 99/4A TRANS before running this program.\n\n"
	       "Press <Enter> to continue, or <Esc> to exit RECV:");
	do
		ch=getch();
	while	(ch!=13 && ch!=27);

	if (ch==27)
		exit(1);


	do
	{
		printf("\n\n\nEnter the DOS serial port you are using to connect\n"
		       "to the 99/4A.  Valid values are 1-4.\n\n: ");
		comm[0]=2;
		port=atoi(cgets(comm));
	}	while (port<1 || port>4);

	do
	{
		printf("\n\n\nEnter the IRQ of COM%d.  Typical value is %d.\n\n: ",
			port, ((port==1 || port==3) ? 4 : 3));
		comm[0]=2;
		irq=atoi(cgets(comm));
	}	while (irq<0 || irq>7);

	port--;			// fix port to 0-3

	do
	{
		printf("\n\n\nEnter the baud rate you used to initialize the RS232\n"
		       "in TRANS.  Valid baud rates are\n"
		       "\t110 300 600 1200 2400 4800 9600.\n\n: ");
		comm[0]=5;
		baudrate=atoi(cgets(comm));
	}	while (baudrate<110 || baudrate>9600);

	com_init(port,baudrate,irq);

	printf("\n\nRECV is ready to go.\n\n"
	       "Press a key at any time to abort.\n\n");
	while (!kbhit())
	{
//		ch=bioscom(_COM_RECEIVE,0,port);
		buf_init();
		if (!gs(comm))
		switch(comm[0])
		{
			case	'S':	ps("G");
					if (dump())
						Err();
					break;
			case	'M':    getbasename();
					ps("N");
					break;
			case	'N':	closemodule();
					ps("M");
					break;
			default:	Err();
					break;
		}
		else
			Err();
	}

	com_off();
	return	0;
}
Пример #29
0
Z H1(enc){A z;W(gs(Et))*z->p=ic(a);R(I)z;}
Пример #30
0
int main(int argc,char *argv[])
{
	int opt;
	PsimagLite::String file("");
	SizeType total=0;
	RealType offset = 0;
	RealType step = 0;
	SizeType dynType = DYN_TYPE_0;

	while ((opt = getopt(argc, argv, "f:t:o:i:d")) != -1) {
		switch (opt) {
		case 'f':
			file=optarg;
			break;
		case 't':
			total = atoi(optarg);
			break;
		case 'i':
			step = atof(optarg);
			break;
		case 'o':
			offset = atof(optarg);
			break;
		case 'd':
			dynType = DYN_TYPE_1;
			break;
		default: /* '?' */
			throw std::runtime_error("Wrong usage\n");
		}
	}

	if (file=="") {
		throw std::runtime_error("Wrong usage\n");
	}

	FreeFermions::InputCheck inputCheck;
	InputNgType::Writeable ioWriteable(file,inputCheck);
	InputNgType::Readable io(ioWriteable);

	GeometryParamsType geometryParams(io);
	SizeType electronsUp = GeometryParamsType::readElectrons(io,geometryParams.sites);
	PsimagLite::Vector<SizeType>::Type sites;
	GeometryParamsType::readVector(sites,file,"TSPSites");

	SizeType dof = 1; // spinless

	GeometryLibraryType geometry(geometryParams);

	std::cerr<<geometry;

	SizeType npthreads = 1;
	ConcurrencyType concurrency(&argc,&argv,npthreads);
	EngineType engine(geometry.matrix(),dof,true);

	PsimagLite::Vector<SizeType>::Type ne(dof,electronsUp); // 8 up and 8 down
	bool debug = false;
	HilbertStateType gs(engine,ne,debug);

	RealType Eg = 0;
	for (SizeType i=0;i<ne[0];i++) Eg += engine.eigenvalue(i);
	std::cerr<<"Energy="<<dof*Eg<<"\n";

	SizeType sigma =0;
	OpNormalFactoryType opNormalFactory(engine);
	SizeType creatOrDest = (dynType == DYN_TYPE_1) ? OperatorType::CREATION : OperatorType::DESTRUCTION;

	OperatorType& opKet = opNormalFactory(creatOrDest,sites[0],sigma);
	HilbertStateType phiKet = gs;
	opKet.applyTo(phiKet);

	if (sites.size() == 1) {
		sites.resize(2);
		sites[1] = sites[0];
	}

	OperatorType& opBra = opNormalFactory(creatOrDest,sites[1],sigma);
	HilbertStateType phiBra = gs;
	opBra.applyTo(phiBra);

	FieldType density = scalarProduct(phiBra,phiKet);
	std::cerr<<"density="<<density<<"\n";

	std::cout<<"#site="<<sites[0]<<"\n";
	std::cout<<"#site2="<<sites[1]<<"\n";

	RealType epsilon = 1e-2;
	for (SizeType it = 0; it<total; it++) {
		OpDiagonalFactoryType opDiagonalFactory(engine);
		RealType omega = it * step + offset;
		ComplexType z = ComplexType(omega,epsilon);
		int sign = (dynType== DYN_TYPE_1) ? -1 : 1;
		OneOverZminusHType eih(z,sign,Eg,engine);
		DiagonalOperatorType& eihOp = opDiagonalFactory(eih);
		HilbertStateType phi3 = phiKet;
		eihOp.applyTo(phi3);
		FieldType tmpC = scalarProduct(phiBra,phi3);

		std::cout<<omega<<" "<<std::imag(tmpC)<<" "<<std::real(tmpC)<<"\n";
	}
}