Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_OPTIMIZATION_PARTITION_VECTOR_H
00002 #define OPENTISSUE_CORE_MATH_OPTIMIZATION_PARTITION_VECTOR_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 <OpenTissue/core/math/optimization/optimization_constants.h>
00014
00015 namespace OpenTissue
00016 {
00017 namespace math
00018 {
00019 namespace optimization
00020 {
00036 template<typename T >
00037 inline void partition_vector(
00038 ublas::vector<T> const & x
00039 , ublas::vector<size_t> const & bitmask
00040 , ublas::vector<size_t> const & old2new
00041 , size_t const & cnt_active
00042 , size_t const & cnt_inactive
00043 , ublas::vector<T> & x_a
00044 , ublas::vector<T> & x_b
00045 )
00046 {
00047 x_a.resize( cnt_active );
00048 x_b.resize( cnt_inactive );
00049
00050 size_t n = x.size();
00051
00052 for(size_t i_old = 0; i_old < n; ++i_old)
00053 {
00054 size_t i_new = old2new( i_old );
00055 if( bitmask(i_old) == IN_ACTIVE )
00056 x_a( i_new ) = x( i_old);
00057 else
00058 x_b( i_new-cnt_active ) = x( i_old);
00059 }
00060 }
00061
00062 }
00063 }
00064 }
00065
00066
00067 #endif