VCCC  2024.05
VisualCamp Common C++ library
matrix_ostream.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/02/05.
3 # */
4 #
5 # ifndef VCCC_MATH_MATRIX_MATRIX_OSTREAM_HPP
6 # define VCCC_MATH_MATRIX_MATRIX_OSTREAM_HPP
7 #
9 # include <ostream>
10 
11 namespace vccc {
12 
15 
16 template<typename E>
17 std::ostream& operator << (std::ostream& os, const MatrixBase<E>& mat_expr) {
18  os << '[';
19 
20  os << mat_expr(0, 0);
21  for(int j=1; j<mat_expr.cols; ++j) {
22  os << ", " << mat_expr(0, j);
23  }
24  os << ";";
25 
26  for(int i=1; i<mat_expr.rows; ++i){
27  os << "\n " << mat_expr(i, 0);
28  for(int j=1; j<mat_expr.cols; ++j) {
29  os << ", " << mat_expr(i, j);
30  }
31  os << ";";
32  }
33 
34  os << ']';
35  return os;
36 }
37 
39 
40 } // namespace vccc
41 
42 # endif // VCCC_MATH_MATRIX_MATRIX_OSTREAM_HPP
Definition: matrix_base.hpp:20
@ cols
Definition: matrix_base.hpp:28
@ rows
Definition: matrix_base.hpp:27
std::ostream & operator<<(std::ostream &os, const MatrixBase< E > &mat_expr)
Definition: matrix_ostream.hpp:17
Definition: directory.h:12