From 2291a504bff5b2ae7c3892ba0d3c5b1519446485 Mon Sep 17 00:00:00 2001 From: Jesper Andersson <jesper@fmrib.ox.ac.uk> Date: Wed, 9 Jan 2019 17:11:12 +0000 Subject: [PATCH] Added << operator --- Simplex.h | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Simplex.h b/Simplex.h index 93c0bcf..13314ad 100644 --- a/Simplex.h +++ b/Simplex.h @@ -74,8 +74,18 @@ public: void MultiContract(); /// Update the indicies for best, worst and 2nd to worst points. void UpdateRankIndicies(); - // Prints out the points of the simplex and the associated function values + // Global function. Prints out the points of the simplex and the associated function values friend ostream& operator<<(ostream& op, const Simplex& smplx); + { + op << "Simplex = " << endl; + for (unsigned int i=0; i<smplx._smx.size(); i++) { + for (unsigned int j=1; j<smplx._smx.size(); j++) { + op << std::setw(10) << std::setprecision(4) << smplx._smx[i](j); + } + op << " | " << std::setw(10) << std::setprecision(4) << smplx._fv[i] << endl; + } + return(op); + } private: const MISCMATHS::NonlinCF& _cf; const NEWMAT::ColumnVector _sp; @@ -90,19 +100,6 @@ private: void calculate_reflexion_point(unsigned int ii); }; -// Global function, friend of Simplex -ostream& operator<<(ostream& op, const Simplex& smplx) -{ - op << "Simplex = " << endl; - for (unsigned int i=0; i<smplx._smx.size(); i++) { - for (unsigned int j=1; j<smplx._smx.size(); j++) { - op << std::setw(10) << std::setprecision(4) << smplx._smx[i](j); - } - op << " | " << std::setw(10) << std::setprecision(4) << smplx._fv[i] << endl; - } - return(op); -} - } // End namespace MISCMATHS #endif // End #ifndef Simplex_h -- GitLab