Beispiel #1
0
PsimagLite::String pathPrepend(PsimagLite::String pre,PsimagLite::String pathname)
{
	bool addDotDot = false;
	PsimagLite::String path1("");
	if (pathname.length() > 2 && pathname[0] == '.' && pathname[1] == '.') {
		addDotDot = true;
		path1 = pathname.substr(2,pathname.length());
	}

	if (pathname.length() > 1 && pathname[0] == '/') path1 = pathname;

	if (path1 == "") return pre + pathname;

	size_t index = path1.find_last_of("/");

	index++;
	PsimagLite::String ret = path1.substr(0,index) + pre +
	        path1.substr(index,path1.length());
	return (addDotDot) ? ".." + ret : ret;
}
Beispiel #2
0
bool observeOneFullSweep(IoInputType& io,
                         const ModelType& model,
                         const PsimagLite::String& list,
                         bool hasTimeEvolution,
                         SizeType orbitals)
{
	typedef typename ModelType::GeometryType GeometryType;
	typedef Observer<VectorWithOffsetType,ModelType,IoInputType> ObserverType;
	typedef ObservableLibrary<ObserverType> ObservableLibraryType;

	const GeometryType& geometry = model.geometry();
	bool verbose = false;
	SizeType n  = geometry.numberOfSites();
	SizeType rows = n; // could be n/2 if there's enough symmetry
	SizeType cols = n;
	SizeType nf = n - 2;
	SizeType trail = 0;

	PsimagLite::Vector<PsimagLite::String>::Type vecOptions;
	PsimagLite::tokenizer(list,vecOptions,",");
	bool hasTrail = false;

	for (SizeType i = 0; i < vecOptions.size(); ++i) {
		PsimagLite::String item = vecOptions[i];

		PsimagLite::String label = "%nf=";
		std::size_t labelIndex = item.find(label);
		if (labelIndex == 0) {
			nf = atoi(item.substr(label.length()).c_str());
			rows = nf;
			cols = nf;
			std::cerr<<"observe: Found "<<label<<" = "<<nf;
			std::cerr<<" (rows and cols also set to it)\n";
		}

		label = "%trail=";
		labelIndex = item.find(label);
		if (labelIndex == 0) {
			trail = atoi(item.substr(label.length()).c_str());
			std::cerr<<"observe: Found "<<label<<" = "<<trail<<"\n";
			hasTrail = true;
		}

		label = "%rows=";
		labelIndex = item.find(label);
		if (labelIndex == 0) {
			std::cerr<<"observe: Found %rows= with index "<<labelIndex<<"\n";
			rows = atoi(item.substr(label.length()).c_str());
		}

		label = "%cols=";
		labelIndex = item.find(label);
		if (labelIndex == 0) {
			std::cerr<<"observe: Found %cols= with index "<<labelIndex<<"\n";
			cols = atoi(item.substr(label.length()).c_str());
		}
	}

	if (!hasTrail)
		trail = n - 2 - nf;

	ObservableLibraryType observerLib(io,
	                                  n,
	                                  hasTimeEvolution,
	                                  model,
	                                  nf,
	                                  trail,
	                                  verbose);

	for (SizeType i = 0; i < vecOptions.size(); ++i) {
		PsimagLite::String item = vecOptions[i];

		if (item.find("%") == 0) continue;

		if (item.length() > 0 && item[0] != '<')
			observerLib.measureTriage(item,rows,cols,orbitals,hasTimeEvolution);
		else
			observerLib.interpret(item,rows,cols);
	}

	return observerLib.endOfData();
}