Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_OPTIMIZATION_COMPUTE_GENERALIZED_MINIMAL_MAP_H
00002 #define OPENTISSUE_CORE_MATH_OPTIMIZATION_COMPUTE_GENERALIZED_MINIMAL_MAP_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/big/big_types.h>
00013 #include <cmath>
00014
00015 namespace OpenTissue
00016 {
00017 namespace math
00018 {
00019 namespace optimization
00020 {
00021
00034 template < typename T, typename bound_function_type>
00035 inline void compute_generalized_minimal_map(
00036 ublas::vector<T> const & y
00037 , bound_function_type const & l
00038 , bound_function_type const & u
00039 , ublas::vector<T> const & x
00040 , ublas::vector<T> & H
00041 )
00042 {
00043 using std::min;
00044 using std::max;
00045
00046 size_t m = y.size();
00047
00048 if(m==0)
00049 return;
00050
00051 H.resize(m);
00052 for (size_t i = 0; i < m; ++ i)
00053 {
00054 T const l_i = l(x,i);
00055 T const u_i = u(x,i);
00056 T const y_i = y(i);
00057 T const x_i = x(i);
00058 H(i) = max( x_i - u_i, min( x_i - l_i, y_i ) );
00059 }
00060 }
00061
00062 }
00063 }
00064 }
00065
00066
00067 #endif