aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported
diff options
context:
space:
mode:
authorGravatar Jens Wehner <jenswehner@gmail.com>2021-03-15 21:51:55 +0000
committerGravatar Antonio Sánchez <cantonios@google.com>2021-03-15 21:51:55 +0000
commitc0a889890f3a191f5000b9a58a2c1a0332b8d552 (patch)
tree8c924370483828d7c4682bb8e1a3ad0cded5861e /unsupported
parentf612df273689a19d25b45ca4f8269463207c4fee (diff)
Fixed output of complex matrices
Diffstat (limited to 'unsupported')
-rw-r--r--unsupported/Eigen/src/SparseExtra/MarketIO.h2
-rw-r--r--unsupported/test/sparse_extra.cpp22
2 files changed, 23 insertions, 1 deletions
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<typename Scalar>
inline void putVectorElt(std::complex<Scalar> 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<typename VectorType>
+void check_marketio_vector()
+{
+ Index size = internal::random<Index>(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<SparseMatrix<double,ColMajor,long int> >()) );
CALL_SUBTEST_4( (check_marketio<SparseMatrix<std::complex<float>,ColMajor,long int> >()) );
CALL_SUBTEST_4( (check_marketio<SparseMatrix<std::complex<double>,ColMajor,long int> >()) );
+
+
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<float,1,Dynamic> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<double,1,Dynamic> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<std::complex<float>,1,Dynamic> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<std::complex<double>,1,Dynamic> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<float,Dynamic,1> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<double,Dynamic,1> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<std::complex<float>,Dynamic,1> >()) );
+ CALL_SUBTEST_5( (check_marketio_vector<Matrix<std::complex<double>,Dynamic,1> >()) );
+
TEST_SET_BUT_UNUSED_VARIABLE(s);
}
}