2 * @file numeric_archive.cpp Check for a bug in numeric::archive
4 * numeric::archive used to fail if the real part of a complex number
5 * is a rational number and the imaginary part is a floating point one.
16 using namespace GiNaC;
18 struct archive_unarchive_check
20 cl_N operator()(const cl_N& n) const
24 ar.archive_ex(e, "test");
26 ex check = ar.unarchive_ex(l, "test");
27 if (!check.is_equal(e)) {
29 s << __FILE__ << ':' << __LINE__ << ": expected: " << e << ", got " << check;
30 throw std::logic_error(s.str());
36 int main(int argc, char** argv)
39 std::cout << "checking if numeric::archive handles complex numbers properly" << std::endl;
40 const cl_R three_fp = cl_float(3.0, default_float_format);
41 std::vector<cl_N> numbers;
42 numbers.push_back(complex(one, three_fp));
43 numbers.push_back(complex(three_fp, one));
44 numbers.push_back(complex(three_fp, three_fp));
45 numbers.push_back(complex(one, one));
46 std::for_each(numbers.begin(), numbers.end(), archive_unarchive_check());