X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2Fcml%2Fmatrix%2Fmatrix_print.h;fp=src%2FMoof%2Fcml%2Fmatrix%2Fmatrix_print.h;h=0937afd41cb8d6e7bfdcf9917e11e29fed6d54c2;hp=0000000000000000000000000000000000000000;hb=c2321281bf12a7efaedde930422c7ddbc92080d4;hpb=87bc17e55b0c1dc73ecc66df856d3f08fd7a7724 diff --git a/src/Moof/cml/matrix/matrix_print.h b/src/Moof/cml/matrix/matrix_print.h new file mode 100644 index 0000000..0937afd --- /dev/null +++ b/src/Moof/cml/matrix/matrix_print.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- ------------------------------------------------------------ + +Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/ + +The Configurable Math Library (CML) is distributed under the terms of the +Boost Software License, v1.0 (see cml/LICENSE for details). + + *-----------------------------------------------------------------------*/ +/** @file + * @brief + */ + +#ifndef matrix_print_h +#define matrix_print_h + +#include + +namespace cml { + +/** Output a matrix to a std::ostream. */ +template inline std::ostream& +operator<<(std::ostream& os, const matrix& m) +{ + for(size_t i = 0; i < m.rows(); ++i) { + os << "["; + for(size_t j = 0; j < m.cols(); ++j) { + os << " " << m(i,j); + } + os << " ]"; + if (i != m.rows()-1) { + os << std::endl; + } + } + return os; +} + +/** Output a matrix expression to a std::ostream. */ +template< class XprT > inline std::ostream& +operator<<(std::ostream& os, const et::MatrixXpr& m) +{ + for(size_t i = 0; i < m.rows(); ++i) { + os << "["; + for(size_t j = 0; j < m.cols(); ++j) { + os << " " << m(i,j); + } + os << " ]"; + if (i != m.rows()-1) { + os << std::endl; + } + } + return os; +} + +} // namespace cml + +#endif + +// ------------------------------------------------------------------------- +// vim:ft=cpp