Loading src/Engine/MeraSolver.h +1 −1 Original line number Diff line number Diff line Loading @@ -314,7 +314,7 @@ private: TensorEvalType tensorEval(*ptr, tensors_, nameToIndexLut_, symmLocal_); typename TensorEvalType::HandleType handle = tensorEval(); while (!handle.done()); while (!handle); VectorSizeType args(1,0); const SizeType index = tensorEval.nameToIndexLut("e" + ttos(ind)); Loading src/Engine/ParallelEnvironHelper.h +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public: typename TensorEvalType::HandleType handle = tensorEval(); while (!handle.done()); while (!handle); // copy result into m SizeType count = 0; Loading src/Engine/TensorEvalNew.h +77 −5 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ along with MERA++. If not, see <http://www.gnu.org/licenses/>. #include "Tensor.h" #include "SrepStatement.h" #include "TensorEvalHandle.h" #include "SymmetryLocal.h" #include "NameToIndexLut.h" Loading @@ -31,7 +30,7 @@ class TensorEval { public: typedef TensorEvalHandle HandleType; typedef bool HandleType; typedef Tensor<ComplexOrRealType> TensorType; typedef typename PsimagLite::Vector<TensorType*>::Type VectorTensorType; typedef typename PsimagLite::Vector<SizeType>::Type VectorSizeType; Loading @@ -42,10 +41,10 @@ public: typedef SymmetryLocal SymmetryLocalType; TensorEval(const SrepStatementType& tSrep, const VectorTensorType& vt, const VectorTensorType&, const NameToIndexLut<TensorType>&, SymmetryLocalType*, bool = false) bool = false) : srepStatement_(tSrep) {} SizeType nameToIndexLut(PsimagLite::String name) Loading @@ -55,13 +54,86 @@ public: HandleType operator()() { throw PsimagLite::RuntimeError("TensorEvalNew::operator: Not implemented yet\n"); PsimagLite::String copy = srepStatement_.sRep(); filterForExatn(copy); std::cout<<copy<<"\n"; //Evaluate a tensor network: auto evaluated = exatn::evaluateTensorNetwork("srepStatement_.sRep()" , copy); TensorType::checkTalshErrorCode(evaluated, "evaluateTensorNetwork"); PsimagLite::String lhs = srepStatement_.lhs().sRep(); filterForExatn(lhs); auto synced = exatn::sync(lhs); return synced; } void printResult(std::ostream& os) const { throw PsimagLite::RuntimeError("TensorEvalNew::printResult: Not implemented yet\n"); } private: static void filterForExatn(PsimagLite::String& str) { removeAll(str, '*'); replaceAll(str, '|', ','); addMultiplication(str); } static void removeAll(PsimagLite::String& str, char what) { PsimagLite::String buffer; const SizeType n = str.length(); for (SizeType i = 0; i < n; ++i) if (str[i] != what) buffer += str[i]; str = buffer; } static void replaceAll(PsimagLite::String& str, char this1, char that1) { PsimagLite::String buffer; const SizeType n = str.length(); for (SizeType i = 0; i < n; ++i) { if (str[i] == this1) buffer += that1; else buffer += str[i]; } str = buffer; } static void addMultiplication(PsimagLite::String& str) { PsimagLite::String buffer; const SizeType n = str.length(); for (SizeType i = 0; i < n; ++i) { if (str[i] == ')' && followsSomething(str, i + 1)) buffer += ")*"; else buffer += str[i]; } str = buffer; } static bool followsSomething(const PsimagLite::String& str, SizeType ind) { const SizeType n = str.length(); SizeType i = ind; for (; i < n; ++i) if (str[i] != ' ' && str[i] != '\t') break; if (i >= n) return false; if (str[i] == '=') return false; return true; } const SrepStatementType& srepStatement_; }; } // namespace Mera #endif // TENSOREVALNEW_H src/Engine/TensorExatn.h +6 −6 Original line number Diff line number Diff line Loading @@ -285,6 +285,12 @@ public: exatn::finalize(); } static void checkTalshErrorCode(bool code, PsimagLite::String what) { if (code) return; throw PsimagLite::RuntimeError("MERA++: TALSH returned false from " + what + "\n"); } // Tensor with only one dimension Tensor(PsimagLite::String name, SizeType dim0, SizeType ins) : name_(name), Loading Loading @@ -435,12 +441,6 @@ private: return index; } static void checkTalshErrorCode(bool code, PsimagLite::String what) { if (code) return; throw PsimagLite::RuntimeError("MERA++: TALSH returned false from " + what + "\n"); } static PsimagLite::RandomForTests<ComplexOrRealType> rng_; PsimagLite::String name_; VectorSizeType dimensions_; Loading src/tensorEval.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ int main(int argc, char **argv) TensorEvalType tensorEval(srepEq, vt, nameToIndexLut, 0, false); TensorEvalType::HandleType handle = tensorEval(); while (!handle.done()); while (!handle); tensorEval.printResult(std::cout); Loading Loading
src/Engine/MeraSolver.h +1 −1 Original line number Diff line number Diff line Loading @@ -314,7 +314,7 @@ private: TensorEvalType tensorEval(*ptr, tensors_, nameToIndexLut_, symmLocal_); typename TensorEvalType::HandleType handle = tensorEval(); while (!handle.done()); while (!handle); VectorSizeType args(1,0); const SizeType index = tensorEval.nameToIndexLut("e" + ttos(ind)); Loading
src/Engine/ParallelEnvironHelper.h +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public: typename TensorEvalType::HandleType handle = tensorEval(); while (!handle.done()); while (!handle); // copy result into m SizeType count = 0; Loading
src/Engine/TensorEvalNew.h +77 −5 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ along with MERA++. If not, see <http://www.gnu.org/licenses/>. #include "Tensor.h" #include "SrepStatement.h" #include "TensorEvalHandle.h" #include "SymmetryLocal.h" #include "NameToIndexLut.h" Loading @@ -31,7 +30,7 @@ class TensorEval { public: typedef TensorEvalHandle HandleType; typedef bool HandleType; typedef Tensor<ComplexOrRealType> TensorType; typedef typename PsimagLite::Vector<TensorType*>::Type VectorTensorType; typedef typename PsimagLite::Vector<SizeType>::Type VectorSizeType; Loading @@ -42,10 +41,10 @@ public: typedef SymmetryLocal SymmetryLocalType; TensorEval(const SrepStatementType& tSrep, const VectorTensorType& vt, const VectorTensorType&, const NameToIndexLut<TensorType>&, SymmetryLocalType*, bool = false) bool = false) : srepStatement_(tSrep) {} SizeType nameToIndexLut(PsimagLite::String name) Loading @@ -55,13 +54,86 @@ public: HandleType operator()() { throw PsimagLite::RuntimeError("TensorEvalNew::operator: Not implemented yet\n"); PsimagLite::String copy = srepStatement_.sRep(); filterForExatn(copy); std::cout<<copy<<"\n"; //Evaluate a tensor network: auto evaluated = exatn::evaluateTensorNetwork("srepStatement_.sRep()" , copy); TensorType::checkTalshErrorCode(evaluated, "evaluateTensorNetwork"); PsimagLite::String lhs = srepStatement_.lhs().sRep(); filterForExatn(lhs); auto synced = exatn::sync(lhs); return synced; } void printResult(std::ostream& os) const { throw PsimagLite::RuntimeError("TensorEvalNew::printResult: Not implemented yet\n"); } private: static void filterForExatn(PsimagLite::String& str) { removeAll(str, '*'); replaceAll(str, '|', ','); addMultiplication(str); } static void removeAll(PsimagLite::String& str, char what) { PsimagLite::String buffer; const SizeType n = str.length(); for (SizeType i = 0; i < n; ++i) if (str[i] != what) buffer += str[i]; str = buffer; } static void replaceAll(PsimagLite::String& str, char this1, char that1) { PsimagLite::String buffer; const SizeType n = str.length(); for (SizeType i = 0; i < n; ++i) { if (str[i] == this1) buffer += that1; else buffer += str[i]; } str = buffer; } static void addMultiplication(PsimagLite::String& str) { PsimagLite::String buffer; const SizeType n = str.length(); for (SizeType i = 0; i < n; ++i) { if (str[i] == ')' && followsSomething(str, i + 1)) buffer += ")*"; else buffer += str[i]; } str = buffer; } static bool followsSomething(const PsimagLite::String& str, SizeType ind) { const SizeType n = str.length(); SizeType i = ind; for (; i < n; ++i) if (str[i] != ' ' && str[i] != '\t') break; if (i >= n) return false; if (str[i] == '=') return false; return true; } const SrepStatementType& srepStatement_; }; } // namespace Mera #endif // TENSOREVALNEW_H
src/Engine/TensorExatn.h +6 −6 Original line number Diff line number Diff line Loading @@ -285,6 +285,12 @@ public: exatn::finalize(); } static void checkTalshErrorCode(bool code, PsimagLite::String what) { if (code) return; throw PsimagLite::RuntimeError("MERA++: TALSH returned false from " + what + "\n"); } // Tensor with only one dimension Tensor(PsimagLite::String name, SizeType dim0, SizeType ins) : name_(name), Loading Loading @@ -435,12 +441,6 @@ private: return index; } static void checkTalshErrorCode(bool code, PsimagLite::String what) { if (code) return; throw PsimagLite::RuntimeError("MERA++: TALSH returned false from " + what + "\n"); } static PsimagLite::RandomForTests<ComplexOrRealType> rng_; PsimagLite::String name_; VectorSizeType dimensions_; Loading
src/tensorEval.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ int main(int argc, char **argv) TensorEvalType tensorEval(srepEq, vt, nameToIndexLut, 0, false); TensorEvalType::HandleType handle = tensorEval(); while (!handle.done()); while (!handle); tensorEval.printResult(std::cout); Loading