Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MATH_UPDATE_F_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MATH_UPDATE_F_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_is_number.h>
00013
00014 #include <cassert>
00015
00016 namespace OpenTissue
00017 {
00018 namespace mbd
00019 {
00020 namespace math
00021 {
00022
00047 template<typename matrix_type, typename size_type, typename real_type, typename vector_type>
00048 void update_f(
00049 matrix_type const & WJT
00050 , size_type const & i
00051 , real_type const & dx
00052 , vector_type & f
00053 )
00054 {
00055 assert( WJT.size1() >0 || !"update_f(): WJT was empty?" );
00056 assert( WJT.size2() >0 || !"update_f(): WJT was empty?" );
00057 assert(i < WJT.size1() || !"update_f(): incorrect i-value" );
00058 assert(f.size() == WJT.size2() || !"update_f(): incorrect dimensions");
00059 assert(is_number(dx) || !"update_f(): not a number encountered");
00060
00061 size_type begin = WJT.index1_data () [i];
00062 size_type end = WJT.index1_data () [i + 1];
00063 assert( (end-begin)==12 || !"update_f(): incorrect format of WJT");
00064 for (size_type j = begin; j < end; ++j)
00065 {
00066 assert(is_number(WJT.value_data()[j]) || !"update_f(): not a number encountered");
00067 f(WJT.index2_data()[j]) += WJT.value_data()[j] * dx;
00068 assert( is_number( f(WJT.index2_data()[j]) ) || !"update_f(): not a number encountered");
00069 }
00070 }
00071
00072
00073
00074 }
00075 }
00076 }
00077
00078 #endif