Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_OPTIMIZATION_COMPUTE_INDEX_REORDERING_H
00002 #define OPENTISSUE_CORE_MATH_OPTIMIZATION_COMPUTE_INDEX_REORDERING_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 #include <cassert>
00015
00016 namespace OpenTissue
00017 {
00018 namespace math
00019 {
00020 namespace optimization
00021 {
00022
00049 inline void compute_index_reordering(
00050 ublas::vector<size_t> const & bitmask
00051 , ublas::vector<size_t> & old2new
00052 , ublas::vector<size_t> & new2old
00053 )
00054 {
00055 size_t n = bitmask.size();
00056 old2new.resize(n);
00057 new2old.resize(n);
00058
00059 size_t r = 0;
00060
00061 for (size_t i = 0; i < n; ++ i)
00062 {
00063 if(bitmask(i) == IN_ACTIVE)
00064 {
00065 old2new( i ) = r;
00066 new2old( r ) = i;
00067 ++r;
00068 }
00069 }
00070
00071 for (size_t i = 0; i < n; ++ i)
00072 {
00073 if(bitmask(i) == IN_LOWER)
00074 {
00075 old2new( i ) = r;
00076 new2old( r ) = i;
00077 ++r;
00078 }
00079 }
00080
00081 for (size_t i = 0; i < n; ++ i)
00082 {
00083 if(bitmask(i) == IN_UPPER)
00084 {
00085 old2new( i ) = r;
00086 new2old( r ) = i;
00087 ++r;
00088 }
00089 }
00090
00091 assert( r==n || !"compute_index_reordering(): something went wrong");
00092 }
00093
00094
00095 }
00096 }
00097 }
00098
00099
00100 #endif