Skip to content
Snippets Groups Projects
Commit 2dca98ef authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

MNT: more namespacing

parent e63ee18d
No related branches found
No related tags found
1 merge request!8Mnt/conda
...@@ -75,14 +75,14 @@ public: ...@@ -75,14 +75,14 @@ public:
/// 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();
// Global function. 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) friend std::ostream& operator<<(std::ostream& op, const Simplex& smplx)
{ {
op << "Simplex = " << endl; op << "Simplex = " << std::endl;
for (unsigned int i=0; i<smplx._smx.size(); i++) { for (unsigned int i=0; i<smplx._smx.size(); i++) {
for (unsigned int j=1; j<smplx._smx.size(); j++) { 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._smx[i](j);
} }
op << " | " << std::setw(10) << std::setprecision(4) << smplx._fv[i] << endl; op << " | " << std::setw(10) << std::setprecision(4) << smplx._fv[i] << std::endl;
} }
return(op); return(op);
} }
......
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
SpMatException(const std::string& msg) throw(): m_msg(msg) {} SpMatException(const std::string& msg) throw(): m_msg(msg) {}
virtual const char * what() const throw() { virtual const char * what() const throw() {
return string("SpMat::" + m_msg).c_str(); return std::string("SpMat::" + m_msg).c_str();
} }
~SpMatException() throw() {} ~SpMatException() throw() {}
...@@ -318,11 +318,11 @@ public: ...@@ -318,11 +318,11 @@ public:
T& operator()(unsigned int i); T& operator()(unsigned int i);
unsigned int NO() const {return(_no);} unsigned int NO() const {return(_no);}
unsigned int ri(unsigned int i) { // Index of i'th non-zero value. unsigned int ri(unsigned int i) { // Index of i'th non-zero value.
if (!_sorted) {sort(_occi,&(_occi[_no])); _sorted=true;} if (!_sorted) {std::sort(_occi,&(_occi[_no])); _sorted=true;}
return(_occi[i]); return(_occi[i]);
} }
const T& val(unsigned int i) { // i'th non-zero value. Call ri(i) to find what index that corresponds to const T& val(unsigned int i) { // i'th non-zero value. Call ri(i) to find what index that corresponds to
if (!_sorted) {sort(_occi,&(_occi[_no])); _sorted=true;} if (!_sorted) {std::sort(_occi,&(_occi[_no])); _sorted=true;}
return(_val[_occi[i]]); return(_val[_occi[i]]);
} }
const T& val_at(unsigned int i) const {return(_val[i]);} // Value for index i (or i+1) const T& val_at(unsigned int i) const {return(_val[i]);} // Value for index i (or i+1)
...@@ -515,28 +515,28 @@ template<class T> ...@@ -515,28 +515,28 @@ template<class T>
void SpMat<T>::Print(const std::string& fname, void SpMat<T>::Print(const std::string& fname,
unsigned int precision) const unsigned int precision) const
{ {
ostream *sptr=0; std::ostream *sptr=0;
if (!fname.length()) { if (!fname.length()) {
sptr = &cout; sptr = &std::cout;
} }
else { else {
try { try {
sptr = new ofstream(fname.c_str()); sptr = new std::ofstream(fname.c_str());
} }
catch(...) { catch(...) {
std::string errmsg("BFMatrix::print: Failed to write to file " + fname); std::string errmsg("BFMatrix::print: Failed to write to file " + fname);
throw SpMatException(errmsg); throw SpMatException(errmsg);
} }
} }
(*sptr) << setprecision(precision); (*sptr) << std::setprecision(precision);
for (unsigned int c=0; c<_n; c++) { for (unsigned int c=0; c<_n; c++) {
for (unsigned int i=0; i<_ri[c].size(); i++) { for (unsigned int i=0; i<_ri[c].size(); i++) {
if (_val[c][i]) (*sptr) << _ri[c][i]+1 << " " << c+1 << " " << _val[c][i] << endl; if (_val[c][i]) (*sptr) << _ri[c][i]+1 << " " << c+1 << " " << _val[c][i] << std::endl;
} }
} }
(*sptr) << _m << " " << _n << " " << 0 << endl; (*sptr) << _m << " " << _n << " " << 0 << std::endl;
if (fname.length()) delete sptr; if (fname.length()) delete sptr;
} }
...@@ -616,9 +616,9 @@ NEWMAT::ReturnMatrix SpMat<T>::SolveForx(const NEWMAT::ColumnVector& ...@@ -616,9 +616,9 @@ NEWMAT::ReturnMatrix SpMat<T>::SolveForx(const NEWMAT::ColumnVector&
} }
if (status && _pw) { if (status && _pw) {
cout << "SpMat::SolveForx: Warning requested tolerence not obtained." << endl; std::cout << "SpMat::SolveForx: Warning requested tolerence not obtained." << std::endl;
cout << "Requested tolerance was " << ltol << ", and achieved tolerance was " << tol << endl; std::cout << "Requested tolerance was " << ltol << ", and achieved tolerance was " << tol << std::endl;
cout << "This may or may not be a problem in your application, but you should look into it" << endl; std::cout << "This may or may not be a problem in your application, but you should look into it" << std::endl;
} }
x.Release(); x.Release();
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "miscmaths.h" #include "miscmaths.h"
#include "bfmatrix.h" #include "bfmatrix.h"
using namespace std;
namespace MISCMATHS { namespace MISCMATHS {
// //
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
BFMatrixException(const std::string& msg) throw(): m_msg(msg) {} BFMatrixException(const std::string& msg) throw(): m_msg(msg) {}
virtual const char * what() const throw() { virtual const char * what() const throw() {
return string("BFMatrix::" + m_msg).c_str(); return std::string("BFMatrix::" + m_msg).c_str();
} }
~BFMatrixException() throw() {} ~BFMatrixException() throw() {}
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "cprob/libprob.h" #include "cprob/libprob.h"
#include <stdexcept> #include <stdexcept>
using namespace std;
using namespace NEWMAT; using namespace NEWMAT;
using namespace Utilities; using namespace Utilities;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "kernel.h" #include "kernel.h"
#include "miscmaths.h" #include "miscmaths.h"
using namespace std;
using namespace NEWMAT; using namespace NEWMAT;
namespace MISCMATHS { namespace MISCMATHS {
......
...@@ -102,7 +102,7 @@ namespace MISCMATHS { ...@@ -102,7 +102,7 @@ namespace MISCMATHS {
class kernel class kernel
{ {
private: private:
static set<kernelstorage*, kernelstorage::comparer> existingkernels; static std::set<kernelstorage*, kernelstorage::comparer> existingkernels;
kernelstorage* storedkernel; kernelstorage* storedkernel;
public: public:
...@@ -135,7 +135,7 @@ namespace MISCMATHS { ...@@ -135,7 +135,7 @@ namespace MISCMATHS {
{ {
// see if already in list: // see if already in list:
storedkernel = new kernelstorage(kx,ky,kz,wx,wy,wz); storedkernel = new kernelstorage(kx,ky,kz,wx,wy,wz);
set<kernelstorage*, kernelstorage::comparer>::iterator std::set<kernelstorage*, kernelstorage::comparer>::iterator
it = existingkernels.find(storedkernel); it = existingkernels.find(storedkernel);
if (it==existingkernels.end()) { if (it==existingkernels.end()) {
existingkernels.insert(storedkernel); existingkernels.insert(storedkernel);
......
...@@ -29,7 +29,7 @@ namespace MISCMATHS { ...@@ -29,7 +29,7 @@ namespace MISCMATHS {
class pair_comparer class pair_comparer
{ {
public: public:
bool operator()(const pair<float,NEWMAT::ColumnVector>& p1,const pair<float,NEWMAT::ColumnVector>& p2) const bool operator()(const std::pair<float,NEWMAT::ColumnVector>& p1,const std::pair<float,NEWMAT::ColumnVector>& p2) const
{ {
return p1.first < p2.first; return p1.first < p2.first;
} }
......
...@@ -300,7 +300,7 @@ namespace MISCMATHS { ...@@ -300,7 +300,7 @@ namespace MISCMATHS {
float digamma(const float x); float digamma(const float x);
void glm_vb(const NEWMAT::Matrix& X, const NEWMAT::ColumnVector& Y, NEWMAT::ColumnVector& B, NEWMAT::SymmetricMatrix& ilambda_B, int niters=20); void glm_vb(const NEWMAT::Matrix& X, const NEWMAT::ColumnVector& Y, NEWMAT::ColumnVector& B, NEWMAT::SymmetricMatrix& ilambda_B, int niters=20);
vector<float> ColumnVector2vector(const NEWMAT::ColumnVector& col); std::vector<float> ColumnVector2vector(const NEWMAT::ColumnVector& col);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Uninteresting byte swapping functions // Uninteresting byte swapping functions
...@@ -329,8 +329,8 @@ namespace MISCMATHS { ...@@ -329,8 +329,8 @@ namespace MISCMATHS {
template<class t> void write_vector(const std::string& fname, const std::vector<t>& vec) template<class t> void write_vector(const std::string& fname, const std::vector<t>& vec)
{ {
std::ofstream out; std::ofstream out;
out.open(fname.c_str(), ios::out); out.open(fname.c_str(), std::ios::out);
copy(vec.begin(), vec.end(), ostream_iterator<t>(out, " ")); copy(vec.begin(), vec.end(), std::ostream_iterator<t>(out, " "));
} }
template<class t> void write_vector(const std::vector<t>& vec, const std::string& fname) template<class t> void write_vector(const std::vector<t>& vec, const std::string& fname)
...@@ -345,7 +345,7 @@ namespace MISCMATHS { ...@@ -345,7 +345,7 @@ namespace MISCMATHS {
if (width>0) { if (width>0) {
os.fill('0'); os.fill('0');
os.width(width); os.width(width);
os.setf(ios::internal, ios::adjustfield); os.setf(std::ios::internal, std::ios::adjustfield);
} }
os << n; os << n;
return os.str(); return os.str();
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
NonlinException(const std::string& msg) throw(): m_msg(msg) {} NonlinException(const std::string& msg) throw(): m_msg(msg) {}
virtual const char * what() const throw() { virtual const char * what() const throw() {
return string("Nonlin: msg=" + m_msg).c_str(); return std::string("Nonlin: msg=" + m_msg).c_str();
} }
~NonlinException() throw() {} ~NonlinException() throw() {}
...@@ -397,11 +397,11 @@ NonlinOut nonlin(const NonlinParam& p, const NonlinCF& cfo); ...@@ -397,11 +397,11 @@ NonlinOut nonlin(const NonlinParam& p, const NonlinCF& cfo);
// Declaration of global utility functions // Declaration of global utility functions
pair<NEWMAT::ColumnVector,NEWMAT::ColumnVector> check_grad(const NEWMAT::ColumnVector& par, std::pair<NEWMAT::ColumnVector,NEWMAT::ColumnVector> check_grad(const NEWMAT::ColumnVector& par,
const NonlinCF& cfo); const NonlinCF& cfo);
pair<boost::shared_ptr<BFMatrix>,boost::shared_ptr<BFMatrix> > check_hess(const NEWMAT::ColumnVector& par, std::pair<boost::shared_ptr<BFMatrix>,boost::shared_ptr<BFMatrix> > check_hess(const NEWMAT::ColumnVector& par,
const NonlinCF& cfo); const NonlinCF& cfo);
} // End namespace MISCMATHS } // End namespace MISCMATHS
......
...@@ -125,7 +125,7 @@ namespace MISCMATHS { ...@@ -125,7 +125,7 @@ namespace MISCMATHS {
int nrows; int nrows;
int ncols; int ncols;
std::vector<map<int,double> > data; std::vector<std::map<int,double> > data;
}; };
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
SplinterpolatorException(const std::string& msg) throw(): m_msg(msg) {} SplinterpolatorException(const std::string& msg) throw(): m_msg(msg) {}
virtual const char *what() const throw() { virtual const char *what() const throw() {
return string("Splinterpolator::" + m_msg).c_str(); return std::string("Splinterpolator::" + m_msg).c_str();
} }
~SplinterpolatorException() throw() {} ~SplinterpolatorException() throw() {}
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "utils/tracer_plus.h" #include "utils/tracer_plus.h"
#include "cprob/libprob.h" #include "cprob/libprob.h"
using namespace std;
using namespace NEWMAT; using namespace NEWMAT;
using namespace Utilities; using namespace Utilities;
......
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