From 43ee238b931dfaf5124d24e5cd8c09234a75212f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 23 Feb 2019 11:53:09 +0100 Subject: Add operator<< for basic_matrix --- include/mmmatrix.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/mmmatrix.hpp b/include/mmmatrix.hpp index 51233cb..7cb9359 100644 --- a/include/mmmatrix.hpp +++ b/include/mmmatrix.hpp @@ -11,8 +11,7 @@ */ #pragma once -#include -#include +#include namespace mm { template @@ -191,3 +190,16 @@ mm::basic_matrix operator-( ) { return a + static_cast(-1) * b; } + +template +std::ostream& operator<<(std::ostream& os, const mm::basic_matrix& m) { + for (int row = 0; row < Rows; row++) { + os << "[ "; + for (int col = 0; col < (Cols -1); col++) { + os << m.at(row, col); + } + os << m.at(Rows -1, Cols -1) << " ]\n"; + } + + return os; +} -- cgit v1.2.1