Skip to content

Commit

Permalink
moved implementation in util.hpp > util.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomiyama committed Aug 2, 2014
1 parent 047f0c9 commit 2c07391
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
27 changes: 27 additions & 0 deletions bandit/util.cpp
@@ -0,0 +1,27 @@
#include "util.hpp"

namespace bandit{

const double pi = 3.14159265;
const double e = 2.718281828;

//RNG engine
std::mt19937 randomEngine(std::time(0));

//int -> string
std::string itos(int number)
{
std::stringstream ss;
ss << number;
return ss.str();
}

//double -> string
std::string dtos(double number)
{
std::stringstream ss;
ss << number;
return ss.str();
}

} //namespace
23 changes: 5 additions & 18 deletions bandit/util.hpp
Expand Up @@ -16,11 +16,11 @@ namespace bandit{

typedef unsigned int uint;

const double pi = 3.14159265;
const double e = 2.718281828;
extern const double pi;
extern const double e;

//RNG engine
std::mt19937 randomEngine(std::time(0));
extern std::mt19937 randomEngine;

template<class T>
int vectorMaxIndex(const std::vector<T> &elems){
Expand Down Expand Up @@ -55,20 +55,7 @@ T vectorSum(const std::vector<T> &elems){
return s;
}

//int -> string
std::string itos(int number)
{
std::stringstream ss;
ss << number;
return ss.str();
}

//double -> string
std::string dtos(double number)
{
std::stringstream ss;
ss << number;
return ss.str();
}
std::string itos(int number);
std::string dtos(double number);

} //namespace
2 changes: 1 addition & 1 deletion wscript
Expand Up @@ -13,7 +13,7 @@ def configure(conf):
conf.load('compiler_cxx')

def build(bld):
bld(features = 'cxx cxxprogram', source = 'main.cpp', target = 'main', cxxflags = CXXFLAGS)
bld(features = 'cxx cxxprogram', source = 'bandit/util.cpp main.cpp',includes = [".", "./bandit"], target = 'main', cxxflags = CXXFLAGS)



0 comments on commit 2c07391

Please sign in to comment.