diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index e997ed205..fe5af260f 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -2,6 +2,7 @@ // for linear algebra. Eigen itself is part of the KDE project. // // Copyright (C) 2006-2008 Benoit Jacob +// Copyright (C) 2008 Gael Guennebaud // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -121,8 +122,7 @@ MatrixBase::format(const IOFormat& fmt) const /** \internal * print the matrix \a _m to the output stream \a s using the output format \a fmt */ template -std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase & _m, - const IOFormat& fmt = IOFormat()) +std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase & _m, const IOFormat& fmt) { const typename Derived::Nested m = _m; int width = 0; @@ -163,8 +163,12 @@ std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase & _m, /** \relates MatrixBase * - * Outputs the matrix, laid out as an array as usual, to the given stream. - * You can control the way the matrix is printed using MatrixBase::format(). + * Outputs the matrix, to the given stream. + * + * If you wish to print the matrix with a format different than the default, use MatrixBase::format(). + * + * It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. + * If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters. * * \sa MatrixBase::format() */ @@ -173,7 +177,7 @@ std::ostream & operator << (std::ostream & s, const MatrixBase & m) { - return ei_print_matrix(s, m.eval()); + return ei_print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT); } #endif // EIGEN_IO_H diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index b95f72e7b..bc0c57b27 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -111,6 +111,10 @@ using Eigen::ei_cos; #define EIGEN_RESTRICT __restrict +#ifndef EIGEN_DEFAULT_IO_FORMAT +#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat() +#endif + #define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ template \ Derived& operator Op(const Eigen::MatrixBase& other) \