diff options
-rw-r--r-- | unsupported/Eigen/src/SparseExtra/MarketIO.h | 2 | ||||
-rw-r--r-- | unsupported/test/sparse_extra.cpp | 22 |
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); } } |