Skip to content
Snippets Groups Projects
Commit a7da3e51 authored by Jesper Andersson's avatar Jesper Andersson
Browse files

Simplex.cpp

parent 7b4493f1
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
// //
#include <iostream> #include <iostream>
#include <iomanip>
#include <cfloat> #include <cfloat>
#include <cmath> #include <cmath>
#include <limits> #include <limits>
......
...@@ -74,6 +74,8 @@ public: ...@@ -74,6 +74,8 @@ public:
void MultiContract(); void MultiContract();
/// Update the indicies for best, worst and 2nd to worst points. /// Update the indicies for best, worst and 2nd to worst points.
void UpdateRankIndicies(); void UpdateRankIndicies();
// Prints out the points of the simplex and the associated function values
friend ostream& operator<<(ostream& op, const Simplex& smplx);
private: private:
const MISCMATHS::NonlinCF& _cf; const MISCMATHS::NonlinCF& _cf;
const NEWMAT::ColumnVector _sp; const NEWMAT::ColumnVector _sp;
...@@ -88,6 +90,18 @@ private: ...@@ -88,6 +90,18 @@ private:
void calculate_reflexion_point(unsigned int ii); 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;
}
}
} // End namespace MISCMATHS } // End namespace MISCMATHS
#endif // End #ifndef Simplex_h #endif // End #ifndef Simplex_h
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment