Commit 5e57cec5 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

some corrections in the extensions

parent acf27767
...@@ -326,7 +326,7 @@ namespace Helpers { ...@@ -326,7 +326,7 @@ namespace Helpers {
ptime now = microsec_clock::local_time(); ptime now = microsec_clock::local_time();
time_duration td = now-t0; time_duration td = now-t0;
return td.total_microseconds(); return td.total_microseconds();
}; }
inline long getRandomSeed(int param = 0) { inline long getRandomSeed(int param = 0) {
using namespace boost::posix_time; using namespace boost::posix_time;
...@@ -338,7 +338,7 @@ namespace Helpers { ...@@ -338,7 +338,7 @@ namespace Helpers {
long value2 = random_seed_initial_value++; long value2 = random_seed_initial_value++;
return value0 + value1 + value2 + param; return value0 + value1 + value2 + param;
}; }
} // end namespace Helpers } // end namespace Helpers
......
...@@ -527,24 +527,24 @@ namespace tools { ...@@ -527,24 +527,24 @@ namespace tools {
void for_each<I>::eval(Container1& vec1, Container2& vec2, Binary_Functor& f) { void for_each<I>::eval(Container1& vec1, Container2& vec2, Binary_Functor& f) {
f(boost::fusion::at_c<I>(vec1), boost::fusion::at_c<I>(vec2)); f(boost::fusion::at_c<I>(vec1), boost::fusion::at_c<I>(vec2));
for_each<I-1>::eval(vec1,vec2,f); for_each<I-1>::eval(vec1,vec2,f);
}; }
template<int I> template<int I>
template<typename Container1, typename Container2, typename T, typename Tertiary_Functor> template<typename Container1, typename Container2, typename T, typename Tertiary_Functor>
void for_each<I>::accumulate(Container1& vec1, Container2& vec2, T& value, Tertiary_Functor& f) { void for_each<I>::accumulate(Container1& vec1, Container2& vec2, T& value, Tertiary_Functor& f) {
f(boost::fusion::at_c<I>(vec1), boost::fusion::at_c<I>(vec2), value); f(boost::fusion::at_c<I>(vec1), boost::fusion::at_c<I>(vec2), value);
for_each<I-1>::accumulate(vec1,vec2,value,f); for_each<I-1>::accumulate(vec1,vec2,value,f);
}; }
template<typename Container1, typename Container2, typename Binary_Functor> template<typename Container1, typename Container2, typename Binary_Functor>
void for_each<0>::eval(Container1& vec1, Container2& vec2, Binary_Functor& f) { void for_each<0>::eval(Container1& vec1, Container2& vec2, Binary_Functor& f) {
f(boost::fusion::at_c<0>(vec1), boost::fusion::at_c<0>(vec2)); f(boost::fusion::at_c<0>(vec1), boost::fusion::at_c<0>(vec2));
}; }
template<typename Container1, typename Container2, typename T, typename Tertiary_Functor> template<typename Container1, typename Container2, typename T, typename Tertiary_Functor>
void for_each<0>::accumulate(Container1& vec1, Container2& vec2, T& value, Tertiary_Functor& f) { void for_each<0>::accumulate(Container1& vec1, Container2& vec2, T& value, Tertiary_Functor& f) {
f(boost::fusion::at_c<0>(vec1), boost::fusion::at_c<0>(vec2),value); f(boost::fusion::at_c<0>(vec1), boost::fusion::at_c<0>(vec2),value);
}; }
} // namespace tools } // namespace tools
......
...@@ -54,7 +54,7 @@ static double signedDist2D(const WorldVector<double> x, const WorldVector<double ...@@ -54,7 +54,7 @@ static double signedDist2D(const WorldVector<double> x, const WorldVector<double
} }
return (norm_xy - (*radius)(alpha)); return (norm_xy - (*radius)(alpha));
}; }
static double signedDist3D(const WorldVector<double> x, const WorldVector<double> midPoint, static double signedDist3D(const WorldVector<double> x, const WorldVector<double> midPoint,
BinaryAbstractFunction<double, double, double> *radius, double eps) BinaryAbstractFunction<double, double, double> *radius, double eps)
...@@ -84,7 +84,7 @@ static double signedDist3D(const WorldVector<double> x, const WorldVector<double ...@@ -84,7 +84,7 @@ static double signedDist3D(const WorldVector<double> x, const WorldVector<double
beta = 0.5*m_pi - atan(x_trans[2]/norm_xy); beta = 0.5*m_pi - atan(x_trans[2]/norm_xy);
return (norm_xyz - (*radius)(alpha, beta)); return (norm_xyz - (*radius)(alpha, beta));
}; }
// radius-functions // radius-functions
// ================ // ================
...@@ -92,8 +92,8 @@ static double signedDist3D(const WorldVector<double> x, const WorldVector<double ...@@ -92,8 +92,8 @@ static double signedDist3D(const WorldVector<double> x, const WorldVector<double
class CircleRadius : public AbstractFunction<double, double> class CircleRadius : public AbstractFunction<double, double>
{ {
public: public:
CircleRadius(double radius_) : radius(radius_) {}; CircleRadius(double radius_) : radius(radius_) {}
double operator()(const double& alpha) const { return radius; }; double operator()(const double& alpha) const { return radius; }
protected: protected:
double radius; double radius;
}; };
...@@ -101,8 +101,8 @@ protected: ...@@ -101,8 +101,8 @@ protected:
class BallRadius : public BinaryAbstractFunction<double, double, double> class BallRadius : public BinaryAbstractFunction<double, double, double>
{ {
public: public:
BallRadius(double radius_) : radius(radius_) {}; BallRadius(double radius_) : radius(radius_) {}
double operator()(const double &alpha, const double &beta) const { return radius; }; double operator()(const double &alpha, const double &beta) const { return radius; }
protected: protected:
double radius; double radius;
}; };
...@@ -112,15 +112,15 @@ class PerturbedCircleRadius : public AbstractFunction<double, double> ...@@ -112,15 +112,15 @@ class PerturbedCircleRadius : public AbstractFunction<double, double>
public: public:
PerturbedCircleRadius(const double radius_, const double strength_, const int period_) : PerturbedCircleRadius(const double radius_, const double strength_, const int period_) :
radius(radius_), strength(strength_), rotation(0.0), period(period_) {}; radius(radius_), strength(strength_), rotation(0.0), period(period_) {}
PerturbedCircleRadius(const double radius_, const double strength_, const int period_, const double rotation_) : PerturbedCircleRadius(const double radius_, const double strength_, const int period_, const double rotation_) :
radius(radius_), strength(strength_), rotation(rotation_), period(period_) {}; radius(radius_), strength(strength_), rotation(rotation_), period(period_) {}
double operator()(const double &alpha) const double operator()(const double &alpha) const
{ {
double result = 1.0 + strength * cos(period * alpha + rotation); double result = 1.0 + strength * cos(period * alpha + rotation);
result *= radius; result *= radius;
return result; return result;
}; }
protected: protected:
...@@ -135,13 +135,13 @@ class PerturbedBallRadius : public BinaryAbstractFunction<double, double, double ...@@ -135,13 +135,13 @@ class PerturbedBallRadius : public BinaryAbstractFunction<double, double, double
public: public:
PerturbedBallRadius(const double radius_, const double strength_, const int period_) : PerturbedBallRadius(const double radius_, const double strength_, const int period_) :
radius(radius_), strength(strength_), period(period_) {}; radius(radius_), strength(strength_), period(period_) {}
double operator()(const double &alpha, const double &beta) const double operator()(const double &alpha, const double &beta) const
{ {
double result = 1.0 + strength * (cos(period*alpha) + cos(period*beta) * cos(period*alpha)); double result = 1.0 + strength * (cos(period*alpha) + cos(period*beta) * cos(period*alpha));
result *= radius; result *= radius;
return result; return result;
}; }
protected: protected:
...@@ -155,13 +155,13 @@ class LemniskateRadius : public AbstractFunction<double, double> ...@@ -155,13 +155,13 @@ class LemniskateRadius : public AbstractFunction<double, double>
{ {
public: public:
LemniskateRadius(const double breite_) : breite(breite_) {}; LemniskateRadius(const double breite_) : breite(breite_) {}
double operator()(const double &alpha) const double operator()(const double &alpha) const
{ {
double result = 2*cos(2*alpha); double result = 2*cos(2*alpha);
result = breite*result; result = breite*result;
return result; return result;
}; }
protected: protected:
...@@ -173,12 +173,12 @@ class Lemniskate3D : public BinaryAbstractFunction<double, double, double> ...@@ -173,12 +173,12 @@ class Lemniskate3D : public BinaryAbstractFunction<double, double, double>
{ {
public: public:
Lemniskate3D(const double breite_) : breite(breite_) {}; Lemniskate3D(const double breite_) : breite(breite_) {}
double operator()(const double &alpha, const double &beta) const double operator()(const double &alpha, const double &beta) const
{ {
double result = 2*breite*cos(2*alpha)*sin(beta); double result = 2*breite*cos(2*alpha)*sin(beta);
return result; return result;
}; }
protected: protected:
...@@ -190,12 +190,12 @@ class EllipseRadius : public AbstractFunction<double, double> ...@@ -190,12 +190,12 @@ class EllipseRadius : public AbstractFunction<double, double>
public: public:
EllipseRadius(const double a_, const double b_) : EllipseRadius(const double a_, const double b_) :
a(a_), b(b_) {}; a(a_), b(b_) {}
double operator()(const double &alpha) const double operator()(const double &alpha) const
{ {
double x=b*cos(alpha), y=a*sin(alpha); double x=b*cos(alpha), y=a*sin(alpha);
return a*b / sqrt(x*x+y*y); return a*b / sqrt(x*x+y*y);
}; }
protected: protected:
...@@ -207,7 +207,7 @@ class EllipsoidRadius : public BinaryAbstractFunction<double, double, double> ...@@ -207,7 +207,7 @@ class EllipsoidRadius : public BinaryAbstractFunction<double, double, double>
public: public:
EllipsoidRadius(const double a_, const double b_, const double c_) : EllipsoidRadius(const double a_, const double b_, const double c_) :
a(a_), b(b_), c(c_) {}; a(a_), b(b_), c(c_) {}
double operator()(const double &alpha, const double &beta) const double operator()(const double &alpha, const double &beta) const
{ {
double sa = sin(alpha), sb = sin(beta); double sa = sin(alpha), sb = sin(beta);
...@@ -215,7 +215,7 @@ public: ...@@ -215,7 +215,7 @@ public:
double x = a*sa*cb, y = b*sa*sb, z = c*ca; double x = a*sa*cb, y = b*sa*sb, z = c*ca;
return sqrt(x*x+y*y+z*z); return sqrt(x*x+y*y+z*z);
}; }
protected: protected:
...@@ -236,7 +236,7 @@ public: ...@@ -236,7 +236,7 @@ public:
x_temp= cos(theta)*x[0] - sin(theta)*x[1]; x_temp= cos(theta)*x[0] - sin(theta)*x[1];
// x_temp[1]= sin(theta)*x[0] + cos(theta)*x[1]; // x_temp[1]= sin(theta)*x[0] + cos(theta)*x[1];
return factor*(shift-x_temp); return factor*(shift-x_temp);
}; }
private: private:
...@@ -255,7 +255,7 @@ public: ...@@ -255,7 +255,7 @@ public:
double operator()(const WorldVector<double>& x) const double operator()(const WorldVector<double>& x) const
{ {
return factor*(shift-x[component]); return factor*(shift-x[component]);
}; }
private: private:
...@@ -270,7 +270,7 @@ public: ...@@ -270,7 +270,7 @@ public:
double operator()(const WorldVector<double>& x) const double operator()(const WorldVector<double>& x) const
{ {
return 1.0; return 1.0;
}; }
}; };
class Rectangle : public AbstractFunction<double, WorldVector<double> > class Rectangle : public AbstractFunction<double, WorldVector<double> >
...@@ -296,7 +296,7 @@ public: ...@@ -296,7 +296,7 @@ public:
result = norm(corner); result = norm(corner);
} }
return result; return result;
}; }
void only2D() { TEST_EXIT(shift.getSize()==2)("Rectangle is defined only for 2 dimension!\n"); } void only2D() { TEST_EXIT(shift.getSize()==2)("Rectangle is defined only for 2 dimension!\n"); }
private: private:
...@@ -323,7 +323,7 @@ public: ...@@ -323,7 +323,7 @@ public:
} }
result = sqrt(result)-radius; result = sqrt(result)-radius;
return factor * result; return factor * result;
}; }
private: private:
...@@ -349,7 +349,7 @@ public: ...@@ -349,7 +349,7 @@ public:
} }
result = sqrt(result)-radius; result = sqrt(result)-radius;
return -result; return -result;
}; }
private: private:
...@@ -408,7 +408,7 @@ public: ...@@ -408,7 +408,7 @@ public:
result1 = sqrt(result1)-radius; result1 = sqrt(result1)-radius;
result2 = sqrt(result2)-radius; result2 = sqrt(result2)-radius;
return -std::min(result1,result2); return -std::min(result1,result2);
}; }
private: private:
...@@ -436,7 +436,7 @@ public: ...@@ -436,7 +436,7 @@ public:
result = signedDist3D(x, midPoint, &perturbedBall, 1.e-6); result = signedDist3D(x, midPoint, &perturbedBall, 1.e-6);
} }
return result; return result;
}; }
private: private:
...@@ -491,7 +491,7 @@ public: ...@@ -491,7 +491,7 @@ public:
result = signedDist3D(x, midPoint, &lemniskate, 1.e-6); result = signedDist3D(x, midPoint, &lemniskate, 1.e-6);
} }
return result; return result;
}; }
private: private:
...@@ -520,7 +520,7 @@ public: ...@@ -520,7 +520,7 @@ public:
} }
result = 1.0-sqrt(result); result = 1.0-sqrt(result);
return result; return result;
}; }
private: private:
...@@ -545,7 +545,7 @@ public: ...@@ -545,7 +545,7 @@ public:
result = sqrt(result)-r2; result = sqrt(result)-r2;
return result; return result;
}; }
private: private:
......
...@@ -31,7 +31,7 @@ const WorldVector<T>& operator*=(WorldVector<T>& v1, const WorldVector<T>& v2) ...@@ -31,7 +31,7 @@ const WorldVector<T>& operator*=(WorldVector<T>& v1, const WorldVector<T>& v2)
*v1It *= *v2It; *v1It *= *v2It;
return v1; return v1;
}; }
// x ~= y // x ~= y
template<typename T> template<typename T>
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
bool operator()(const T &x, const T &y) const { return sqrt((x-y)*(x-y))<tol; } bool operator()(const T &x, const T &y) const { return sqrt((x-y)*(x-y))<tol; }
double tol; double tol;
}; };
template<typename T1, typename T2, int component> template<typename T1, typename T2, int component>
struct comparePair : public binary_function<std::pair<T1, T2>, std::pair<T1, T2>, bool> struct comparePair : public binary_function<std::pair<T1, T2>, std::pair<T1, T2>, bool>
{ {
...@@ -58,6 +59,7 @@ struct compare0 : public binary_function<std::pair<T1, T2>, std::pair<T1, T2>, b ...@@ -58,6 +59,7 @@ struct compare0 : public binary_function<std::pair<T1, T2>, std::pair<T1, T2>, b
return x.first<y.first; return x.first<y.first;
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct compare1 : public binary_function<std::pair<T1, T2>, std::pair<T1, T2>, bool> struct compare1 : public binary_function<std::pair<T1, T2>, std::pair<T1, T2>, bool>
{ {
...@@ -341,11 +343,11 @@ namespace vector_operations { ...@@ -341,11 +343,11 @@ namespace vector_operations {
for (size_t i = 0; i < num_rows(b); ++i) for (size_t i = 0; i < num_rows(b); ++i)
value += sqr(b[i]); value += sqr(b[i]);
return sqrt(value); return sqrt(value);
}; }
/// 2-norm for MTL4 vectors /// 2-norm for MTL4 vectors
template<typename T> template<typename T>
T norm(const mtl::dense_vector<T> &b) { return two_norm(b); }; T norm(const mtl::dense_vector<T> &b) { return two_norm(b); }
/// 1-norm for matrices /// 1-norm for matrices
template<typename Matrix> template<typename Matrix>
...@@ -359,7 +361,7 @@ namespace vector_operations { ...@@ -359,7 +361,7 @@ namespace vector_operations {
asum += abs(M[i][j]); asum += abs(M[i][j]);
} }
return static_cast<double>(asum); return static_cast<double>(asum);
}; }
/// 2-norm for vectors with eps-pertubation /// 2-norm for vectors with eps-pertubation
...@@ -368,7 +370,7 @@ namespace vector_operations { ...@@ -368,7 +370,7 @@ namespace vector_operations {
norm(const Vector &b, const double eps) norm(const Vector &b, const double eps)
{ {
return std::max(static_cast<double>(norm(b)), eps); return std::max(static_cast<double>(norm(b)), eps);
}; }
/// trace of a matrix /// trace of a matrix
template<typename Matrix> template<typename Matrix>
...@@ -395,7 +397,7 @@ namespace vector_operations { ...@@ -395,7 +397,7 @@ namespace vector_operations {
for (size_t i = 0; i < num_rows(v1); ++i) for (size_t i = 0; i < num_rows(v1); ++i)
result[i] = v1[i] * v2[i]; result[i] = v1[i] * v2[i];
return result; return result;
}; }
template<typename Matrix, typename Vector, typename ResultVector> template<typename Matrix, typename Vector, typename ResultVector>
typename boost::enable_if< boost::mpl::and_< is_matrix<Matrix>, is_vector<Vector> >, ResultVector >::type typename boost::enable_if< boost::mpl::and_< is_matrix<Matrix>, is_vector<Vector> >, ResultVector >::type
...@@ -410,7 +412,7 @@ namespace vector_operations { ...@@ -410,7 +412,7 @@ namespace vector_operations {
result[i] += at(A,i,j) * x[j]; result[i] += at(A,i,j) * x[j];
} }
return result; return result;
}; }
template<typename Matrix, typename Vector1, typename Vector2, typename ResultVector> template<typename Matrix, typename Vector1, typename Vector2, typename ResultVector>
typename boost::enable_if< boost::mpl::and_< is_matrix<Matrix>, is_vector<Vector1>, is_vector<Vector2> >, typename boost::enable_if< boost::mpl::and_< is_matrix<Matrix>, is_vector<Vector1>, is_vector<Vector2> >,
...@@ -427,7 +429,7 @@ namespace vector_operations { ...@@ -427,7 +429,7 @@ namespace vector_operations {
result[i] += at(A,i,j) * x[j]; result[i] += at(A,i,j) * x[j];
} }
return result; return result;
}; }
// copy v -> w // copy v -> w
template<typename VectorIn, typename VectorOut> template<typename VectorIn, typename VectorOut>
...@@ -436,7 +438,7 @@ namespace vector_operations { ...@@ -436,7 +438,7 @@ namespace vector_operations {
{ {
for (size_t i = 0; i < std::min(num_rows(v), num_rows(w)); i++) for (size_t i = 0; i < std::min(num_rows(v), num_rows(w)); i++)
w[i] = v[i]; w[i] = v[i];
}; }
template<class MatrixIn, class MatrixOut> template<class MatrixIn, class MatrixOut>
typename boost::enable_if< boost::mpl::and_< is_matrix<MatrixIn>, is_matrix<MatrixOut> >, void >::type typename boost::enable_if< boost::mpl::and_< is_matrix<MatrixIn>, is_matrix<MatrixOut> >, void >::type
...@@ -448,7 +450,7 @@ namespace vector_operations { ...@@ -448,7 +450,7 @@ namespace vector_operations {
at(m,i,j) = at(m_in,i,j); at(m,i,j) = at(m_in,i,j);
} }
} }
}; }
template<class MatrixIn, class MatrixOut> template<class MatrixIn, class MatrixOut>
typename boost::enable_if< boost::mpl::and_< is_matrix<MatrixIn>, is_matrix<MatrixOut> >, void >::type typename boost::enable_if< boost::mpl::and_< is_matrix<MatrixIn>, is_matrix<MatrixOut> >, void >::type
...@@ -468,7 +470,7 @@ namespace vector_operations { ...@@ -468,7 +470,7 @@ namespace vector_operations {
v3[i] = v1[i]; v3[i] = v1[i];
for (size_t j = 0; j < num_rows(v2); j++) for (size_t j = 0; j < num_rows(v2); j++)
v3[j + num_rows(v1)] = v2[j]; v3[j + num_rows(v1)] = v2[j];
}; }
template<typename Vector> template<typename Vector>
void getMin(const Vector &v, typename ValueType<Vector>::type &minVal, size_t &minIdx) void getMin(const Vector &v, typename ValueType<Vector>::type &minVal, size_t &minIdx)
...@@ -484,7 +486,7 @@ namespace vector_operations { ...@@ -484,7 +486,7 @@ namespace vector_operations {
minIdx = i; minIdx = i;
} }
} }
}; }
template<typename Vector> template<typename Vector>
void getMax(const Vector &v, typename ValueType<Vector>::type &maxVal, size_t &maxIdx) void getMax(const Vector &v, typename ValueType<Vector>::type &maxVal, size_t &maxIdx)
...@@ -500,7 +502,7 @@ namespace vector_operations { ...@@ -500,7 +502,7 @@ namespace vector_operations {
maxIdx = i; maxIdx = i;
} }
} }
}; }