From c0a889890f3a191f5000b9a58a2c1a0332b8d552 Mon Sep 17 00:00:00 2001 From: Jens Wehner Date: Mon, 15 Mar 2021 21:51:55 +0000 Subject: Fixed output of complex matrices --- unsupported/Eigen/src/SparseExtra/MarketIO.h | 2 +- unsupported/test/sparse_extra.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'unsupported') diff --git a/unsupported/Eigen/src/SparseExtra/MarketIO.h b/unsupported/Eigen/src/SparseExtra/MarketIO.h index 833edd4df..dd786d561 100644 --- a/unsupported/Eigen/src/SparseExtra/MarketIO.h +++ b/unsupported/Eigen/src/SparseExtra/MarketIO.h @@ -101,7 +101,7 @@ namespace internal template inline void putVectorElt(std::complex value, std::ofstream& out) { - out << value.real << " " << value.imag()<< "\n"; + out << value.real() << " " << value.imag()<< "\n"; } } // end namespace internal diff --git a/unsupported/test/sparse_extra.cpp b/unsupported/test/sparse_extra.cpp index cbb799acc..bc681e3b1 100644 --- a/unsupported/test/sparse_extra.cpp +++ b/unsupported/test/sparse_extra.cpp @@ -161,6 +161,17 @@ void check_marketio() VERIFY_IS_EQUAL(DenseMatrix(m1),DenseMatrix(m2)); } +template +void check_marketio_vector() +{ + Index size = internal::random(1,100); + VectorType v1, v2; + v1 = VectorType::Random(size); + saveMarketVector(v1, "vector_extra.mtx"); + loadMarketVector(v2, "vector_extra.mtx"); + VERIFY_IS_EQUAL(v1,v2); +} + EIGEN_DECLARE_TEST(sparse_extra) { for(int i = 0; i < g_repeat; i++) { @@ -184,6 +195,17 @@ EIGEN_DECLARE_TEST(sparse_extra) CALL_SUBTEST_4( (check_marketio >()) ); CALL_SUBTEST_4( (check_marketio,ColMajor,long int> >()) ); CALL_SUBTEST_4( (check_marketio,ColMajor,long int> >()) ); + + + CALL_SUBTEST_5( (check_marketio_vector >()) ); + CALL_SUBTEST_5( (check_marketio_vector >()) ); + CALL_SUBTEST_5( (check_marketio_vector,1,Dynamic> >()) ); + CALL_SUBTEST_5( (check_marketio_vector,1,Dynamic> >()) ); + CALL_SUBTEST_5( (check_marketio_vector >()) ); + CALL_SUBTEST_5( (check_marketio_vector >()) ); + CALL_SUBTEST_5( (check_marketio_vector,Dynamic,1> >()) ); + CALL_SUBTEST_5( (check_marketio_vector,Dynamic,1> >()) ); + TEST_SET_BUT_UNUSED_VARIABLE(s); } } -- cgit v1.2.3