matrix_print.h

Go to the documentation of this file.
00001 /* -*- C++ -*- ------------------------------------------------------------
00002  
00003 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
00004 
00005 The Configurable Math Library (CML) is distributed under the terms of the
00006 Boost Software License, v1.0 (see cml/LICENSE for details).
00007 
00008  *-----------------------------------------------------------------------*/
00013 #ifndef matrix_print_h
00014 #define matrix_print_h
00015 
00016 #include <iostream>
00017 
00018 namespace cml {
00019 
00021 template<typename E, class AT, typename BO, class L> inline std::ostream&
00022 operator<<(std::ostream& os, const matrix<E,AT,BO,L>& m)
00023 {
00024     for(size_t i = 0; i < m.rows(); ++i) {
00025         os << "[";
00026         for(size_t j = 0; j < m.cols(); ++j) {
00027             os << " " << m(i,j);
00028         }
00029         os << " ]";
00030         if (i != m.rows()-1) {
00031             os << std::endl;
00032         }
00033     }
00034     return os;
00035 }
00036 
00038 template< class XprT > inline std::ostream&
00039 operator<<(std::ostream& os, const et::MatrixXpr<XprT>& m)
00040 {
00041     for(size_t i = 0; i < m.rows(); ++i) {
00042         os << "[";
00043         for(size_t j = 0; j < m.cols(); ++j) {
00044             os << " " << m(i,j);
00045         }
00046         os << " ]";
00047         if (i != m.rows()-1) {
00048             os << std::endl;
00049         }
00050     }
00051     return os;
00052 }
00053 
00054 } // namespace cml
00055 
00056 #endif
00057 
00058 // -------------------------------------------------------------------------
00059 // vim:ft=cpp

Generated on Sat Jul 18 19:35:24 2009 for CML 1.0 by  doxygen 1.5.9