Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_OPTIMIZATION_AGGLOMERATE_VECTOR_H
00002 #define OPENTISSUE_CORE_MATH_OPTIMIZATION_AGGLOMERATE_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 <stdexcept>
00014
00015 namespace OpenTissue
00016 {
00017 namespace math
00018 {
00019 namespace optimization
00020 {
00032 template<typename T>
00033 inline void agglomerate_vector(
00034 ublas::vector<T> const & x_a
00035 , ublas::vector<T> const & x_b
00036 , ublas::vector<size_t> const & new2old
00037 , ublas::vector<T> & x
00038 )
00039 {
00040 size_t n = x.size();
00041 size_t n_a = x_a.size();
00042 size_t n_b = x_b.size();
00043
00044 if ( (n_a + n_b) != n )
00045 throw std::invalid_argument( "Incompatible dimensions" );
00046
00047 for(size_t i = 0; i< n_a;++i)
00048 x( new2old( i ) ) = x_a( i );
00049 for(size_t i = 0; i< n_b;++i)
00050 x( new2old( i + n_a ) ) = x_b( i );
00051 }
00052
00053 }
00054 }
00055 }
00056
00057
00058 #endif