Add custom formatting of complex numbers for Numpy/Native.

This commit is contained in:
Antonio Sánchez
2024-03-25 17:41:44 +00:00
parent 5570a27869
commit 9f77ce4f19
3 changed files with 162 additions and 109 deletions

View File

@@ -82,6 +82,16 @@ struct test_tensor_ostream_impl<std::complex<Scalar>, 2, Layout> {
std::ostringstream os;
os << t.format(Eigen::TensorIOFormat::Plain());
VERIFY(os.str() == " (1,2) (12,3)\n(-4,2) (0,5)\n(-1,4) (5,27)");
os.str("");
os.clear();
os << t.format(Eigen::TensorIOFormat::Numpy());
VERIFY(os.str() == "[[ 1+2j 12+3j]\n [-4+2j 0+5j]\n [-1+4j 5+27j]]");
os.str("");
os.clear();
os << t.format(Eigen::TensorIOFormat::Native());
VERIFY(os.str() == "{{ {1, 2}, {12, 3}},\n {{-4, 2}, {0, 5}},\n {{-1, 4}, {5, 27}}}");
}
};