# OpenTissue::mbd::math Namespace Reference

## Functions

template<typename matrix_type , typename vector_type >
void compute_diagonal (matrix_type const &J, matrix_type const &WJT, vector_type &d)
template<typename matrix_type , typename vector_type >
void compute_f (matrix_type const &WJT, vector_type const &x, vector_type &f)
template<typename matrix_type >
void compute_WJT (matrix_type const &W, matrix_type const &J, matrix_type &WJT)
template<typename matrix_type , typename size_type , typename real_type , typename vector_type >
void update_f (matrix_type const &WJT, size_type const &i, real_type const &dx, vector_type &f)

## Function Documentation

template<typename matrix_type , typename vector_type >
 void OpenTissue::mbd::math::compute_diagonal ( matrix_type const & J, matrix_type const & WJT, vector_type & d )

Compute the diagonal of A. That is we compute the diagonal of

noalias(A) = prod( J, matrix_type( prod( W, trans(J) ) ) )

Exploiting that we already have pre-computed the term prod( W, trans(J) ).

Parameters:
 J The jacobian matrix. WJT The value of prod(W,trans(J)), where W is the inverted mass matrix. This argument is assumed to be stored as prod(J,W) = trans( prod( W, trans(J) ) ). d Upon return this vector contain the values of the diagonal of A. That is d(i) = A(i,i).
template<typename matrix_type , typename vector_type >
 void OpenTissue::mbd::math::compute_f ( matrix_type const & WJT, vector_type const & x, vector_type & f )

Compute f-vector. The f-vector is defined as

f = prod( prod(W, trans(J) ), x)

We can write x as

e_1 x_1 + ... +e_i x_i + ... + e_n x_n

So f becomes

f = W J^T ( sum_i^n e_i x_i)

From this we see that we can compute f by invoking update_f n-times.

Parameters:
 WJT The value of prod(W, trans(J)) stored as prod(J,W). x f
template<typename matrix_type >
 void OpenTissue::mbd::math::compute_WJT ( matrix_type const & W, matrix_type const & J, matrix_type & WJT )

Multiply inverse mass matrix by transposed jacobian.

Parameters:
 W The inverse mass matrix. J The jacobian matrix. WJT Upon return this argument holds the value of prod(W,trans(J)), where W is the inverted mass matrix. This argument is assumed to be stored as prod(J,W) = trans( prod( W, trans(J) ) ).
template<typename matrix_type , typename size_type , typename real_type , typename vector_type >
 void OpenTissue::mbd::math::update_f ( matrix_type const & WJT, size_type const & i, real_type const & dx, vector_type & f )

Update f-vector. Let

f = W J^T x

Compute new f-value, f', when x_i = x_i + dx, that is

f' = W J^T (x + e_i dx)

where e_i is the i'th euclidean basis vector. Now

f' = f + W J^T ( e_i dx) f' = f + column_i(W J^T) dx f' = f + row_i(J W) dx

The last equation is used to update the f-vector to its new value.

Parameters:
 WJT The value of prod(W, trans(J)) stored as prod(J,W). i dx f