Commit e47e0feb authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

MPS Builder

parent 6aef1043
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ flavor production = (

flavor debug = (
< group basics
STRIP_COMMAND = true
STRIP_COMMAND = gdb-add-index
< compilerCPPOptions Symbols3
< compilerCPPOptions Werror
)
+17 −0
Original line number Diff line number Diff line
@@ -34,6 +34,11 @@ public:
	Builder1D(SizeType sites, SizeType arity, bool isPeriodic)
	    : sites_(sites), srep_("")
	{
		if (arity == 0) {
			buildAnMPS();
			return;
		}

		if (arity != 2)
			throw PsimagLite::RuntimeError("MeraBuilder1D: arity must be 2 for now\n");

@@ -185,6 +190,18 @@ private:
		}
	}

	void buildAnMPS()
	{
		assert(sites_ > 2);
		const SizeType nMinusOne = sites_ - 1;

		srep_ = "u0(s" + ttos(nMinusOne) + ",f0|s0)";

		for (SizeType i = 0; i < nMinusOne; ++i) {
			srep_ +=  "u" + ttos(i+1) + "(s" + ttos(i) + ",f" + ttos(i+1) + "|s" + ttos(i+1) + ")";
		}
	}

	SizeType sites_;
	PsimagLite::String srep_;
};
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public:
	      model_(paramsForMera_.model, paramsForMera_.hamiltonianConnection),
	      paramsForLanczos_(0)
	{
		TensorType::init();
		TensorType::init(0);
		InputCheck inputCheck;
		InputNgType::Writeable ioWriteable(filename,inputCheck);
		InputNgType::Readable io(ioWriteable);
+5 −5
Original line number Diff line number Diff line
@@ -173,15 +173,15 @@ public:
		return handle;
	}

	void printResult(std::ostream& os) const
	void printResult(std::ostream& os, TensorType& outtensor) const
	{
		SizeType indexOfOutputTensor = nameToIndexLUT_(srepStatement_.nameIdOfOutput());
		SizeType total = outputTensor(indexOfOutputTensor).args();
		//SizeType indexOfOutputTensor = nameToIndexLUT_(srepStatement_.nameIdOfOutput());
		SizeType total = outtensor.args(); // outputTensor(indexOfOutputTensor).args();
		static VectorSizeType dimensions;
		if (total > dimensions.size()) dimensions.resize(total,0);

		for (SizeType i = 0; i < total; ++i)
			dimensions[i] = outputTensor(indexOfOutputTensor).argSize(i);
			dimensions[i] = outtensor.argSize(i);

		static VectorSizeType free;
		if (total > free.size()) free.resize(total,0);
@@ -190,7 +190,7 @@ public:
		do {
			//SizeType index = outputTensor(indexOfOutputTensor).index(free);
			SizeType index = 0;
			std::cout<<index<<" "<<outputTensor(indexOfOutputTensor)(free)<<"\n";
			std::cout<<index<<" "<<outtensor(free)<<"\n";
		} while (ProgramGlobals::nextIndex(free,dimensions,total));
	}

+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:
	typedef std::pair<PsimagLite::String, SizeType> PairStringSizeType;
	typedef VectorComplexOrRealType TensorBlobType;

	static void init() {}
	static void init(int) {}

	static void finalize() {}

Loading