* add Gael a (c) line in IO.h

* let user change default format by defining EIGEN_DEFAULT_IO_FORMAT
* improve docs a little
This commit is contained in:
Benoit Jacob 2008-11-17 12:45:57 +00:00
parent 139529e97b
commit 3614321401
2 changed files with 13 additions and 5 deletions

View File

@ -2,6 +2,7 @@
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. Eigen itself is part of the KDE project.
// //
// Copyright (C) 2006-2008 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2008 Benoit Jacob <jacob@math.jussieu.fr>
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -121,8 +122,7 @@ MatrixBase<Derived>::format(const IOFormat& fmt) const
/** \internal /** \internal
* print the matrix \a _m to the output stream \a s using the output format \a fmt */ * print the matrix \a _m to the output stream \a s using the output format \a fmt */
template<typename Derived> template<typename Derived>
std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase<Derived> & _m, std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase<Derived> & _m, const IOFormat& fmt)
const IOFormat& fmt = IOFormat())
{ {
const typename Derived::Nested m = _m; const typename Derived::Nested m = _m;
int width = 0; int width = 0;
@ -163,8 +163,12 @@ std::ostream & ei_print_matrix(std::ostream & s, const MatrixBase<Derived> & _m,
/** \relates MatrixBase /** \relates MatrixBase
* *
* Outputs the matrix, laid out as an array as usual, to the given stream. * Outputs the matrix, to the given stream.
* You can control the way the matrix is printed using MatrixBase::format(). *
* 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() * \sa MatrixBase::format()
*/ */
@ -173,7 +177,7 @@ std::ostream & operator <<
(std::ostream & s, (std::ostream & s,
const MatrixBase<Derived> & m) const MatrixBase<Derived> & m)
{ {
return ei_print_matrix(s, m.eval()); return ei_print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
} }
#endif // EIGEN_IO_H #endif // EIGEN_IO_H

View File

@ -111,6 +111,10 @@ using Eigen::ei_cos;
#define EIGEN_RESTRICT __restrict #define EIGEN_RESTRICT __restrict
#ifndef EIGEN_DEFAULT_IO_FORMAT
#define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
#endif
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ #define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename OtherDerived> \ template<typename OtherDerived> \
Derived& operator Op(const Eigen::MatrixBase<OtherDerived>& other) \ Derived& operator Op(const Eigen::MatrixBase<OtherDerived>& other) \