00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_PRINT_INCLUDE
00013 #define MTL_PRINT_INCLUDE
00014
00015 #include <iostream>
00016 #include <boost/numeric/mtl/mtl_fwd.hpp>
00017 #include <boost/numeric/mtl/operation/print_matrix.hpp>
00018 #include <boost/numeric/mtl/operation/print_vector.hpp>
00019 #include <boost/numeric/mtl/utility/tag.hpp>
00020
00021
00022 namespace mtl {
00023
00024 namespace detail {
00025
00026 template <typename Collection>
00027 struct with_format_t
00028 {
00029 explicit with_format_t(const Collection& collection, int width, int precision)
00030 : collection(collection), width(width), precision(precision)
00031 {}
00032
00033 const Collection& collection;
00034 int width, precision;
00035 };
00036
00037 template <typename Collection>
00038 inline std::ostream& operator<< (std::ostream& out, with_format_t<Collection> const& value)
00039 {
00040 return print(value.collection, out, value.width, value.precision);
00041 }
00042
00043
00044 }
00045
00046 namespace matrix {
00047
00048 template <typename Matrix>
00049 inline std::ostream& operator<< (std::ostream& out, const mat_expr<Matrix>& expr)
00050 {
00051 return print_matrix(static_cast<const Matrix&>(expr), out, 3, 2);
00052 }
00053
00054 template <typename Value>
00055 inline std::ostream&
00056 print(Value const& value, std::ostream& out= std::cout, int width= 3, int precision= 2)
00057 {
00058 return print_matrix(value, out, width, precision);
00059 }
00060
00061 template <typename Collection>
00062 inline mtl::detail::with_format_t<Collection> with_format(const Collection& collection, int width= 3, int precision= 2)
00063 {
00064 return mtl::detail::with_format_t<Collection>(collection, width, precision);
00065 }
00066 }
00067
00068 namespace vector {
00069
00070
00071 template <typename Vector>
00072 inline std::ostream& operator<< (std::ostream& out, const vector::vec_expr<Vector>& expr)
00073 {
00074 return print_vector(static_cast<const Vector&>(expr), out, 0, 0);
00075 }
00076
00077
00078 template <typename Value>
00079 inline std::ostream&
00080 print(Value const& value, std::ostream& out= std::cout, int width= 3, int precision= 2)
00081 {
00082 return print_vector(value, out, width, precision);
00083 }
00084
00085 template <typename Collection>
00086 inline mtl::detail::with_format_t<Collection> with_format(const Collection& collection, int width= 3, int precision= 2)
00087 {
00088 return mtl::detail::with_format_t<Collection>(collection, width, precision);
00089 }
00090
00091 }
00092
00093
00094 }
00095
00096
00097 #endif // MTL_PRINT_INCLUDE