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

Ainur: ellipsis for complex vectors now works

parent 49fc8037
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -32,6 +32,18 @@ struct MyProxyFor<ComplexOrRealType, true> {
	static void copy(std::vector<ComplexOrRealType>& dest,
	                 const std::vector<Type>& src)
	{
		const SizeType ndest = dest.size();
		// ellipsis for complex vectors goes here:
		if (src.size() == 2 && src[1] == "...") {
			if (ndest == 0)
				err("Vector of unknown size cannot use ellipsis\n");
			const std::string copystr = src[0];
			ComplexOrRealType val = toComplex(copystr);
			for (SizeType i = 0; i < ndest; ++i)
				dest[i] = val;
			return;
		}

		dest.clear();
		const SizeType n = src.size();
		if (n == 0) return;
@@ -136,7 +148,7 @@ ruleElipsis<DoubleOrFloatType>()
{
	return  "[" >> boost::spirit::DoubleOrFloatUnderscore  >> "," >> "..." >> "]";
}

// Needed but apparently does not match
template<>
boost::spirit::qi::rule<std::string::iterator,
std::string(),
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@ void partiallyReadSomething(const PsimagLite::Ainur& ainur)
	PsimagLite::String m;
	ainur.readValue(m, "Model");
	std::cout<<m<<"\n";

	std::vector<std::complex<double> > v2(10);
	ainur.readValue(v2, "myv2");
	std::cout<<v2;
}

int main(int argc, char** argv)