51 #define NOMINMAX // avoid including the min and max macro
57 #include <boost/random.hpp>
59 #include "CommonTypes.h"
60 #include "Exceptions.h"
70 #define is_deprecated __declspec(deprecated)
71 #elif defined(__GNUC__)
72 #define is_deprecated __attribute__((deprecated))
74 #define is_deprecated //uncommon compiler, don't bother
87 static std::string toString(T t) {
88 std::ostringstream os;
95 static VectorType generateNormalVector(
unsigned n) {
101 static boost::minstd_rand randgen(static_cast<unsigned>(time(0)));
102 static boost::normal_distribution<> dist(0, 1);
103 static boost::variate_generator<boost::minstd_rand, boost::normal_distribution<> > r(randgen, dist);
105 VectorType v = VectorType::Zero(n);
106 for (
unsigned i=0; i < n; i++) {
113 static VectorType ReadVectorFromTxtFile(
const char *name) {
114 typedef std::list<statismo::ScalarType> ListType;
115 std::list<statismo::ScalarType> values;
116 std::ifstream inFile(name, std::ios::in);
118 std::copy(std::istream_iterator<statismo::ScalarType>(inFile), std::istream_iterator<statismo::ScalarType>(), std::back_insert_iterator<ListType >(values));
121 throw StatisticalModelException((std::string(
"Could not read text file ") + name).c_str());
124 VectorType v = VectorType::Zero(values.size());
126 for (ListType::const_iterator it = values.begin(); it != values.end(); ++it) {
134 static std::string CreateTmpName(
const std::string& extension) {
136 std::string tmpDirectoryName;
137 TCHAR szTempFileName[MAX_PATH];
140 dwRetVal = GetTempPath(MAX_PATH,
142 tmpDirectoryName.assign(szTempFileName);
143 std::string tmpfilename = tmpDirectoryName +
"/" + tmpnam(0) +extension;
146 std::string tmpfilename = tmpnam(0);
147 tmpfilename += extension;