def project_onto_nullspace(mom, cache):
""" Projects a momentum on to the nullspace of the constraint Jacobian.
Parameters
----------
mom : vector
Momentum state to project.
cache : dictionary
Dictionary of cached constraint Jacobian results.
Returns
-------
mom : vector
Momentum state projected into nullspace of constraint Jacobian.
"""
dc_dpos = cache['dc_dpos']
if 'gram_chol' not in cache:
cache['gram_chol'] = la.cho_factor(dc_dpos.dot(dc_dpos.T))
gram_chol = cache['gram_chol']
dc_dpos_mom = dc_dpos.dot(mom)
gram_inv_dc_dpos_mom = la.cho_solve(gram_chol, dc_dpos_mom)
dc_dpos_pinv_dc_dpos_mom = dc_dpos.T.dot(gram_inv_dc_dpos_mom)
mom -= dc_dpos_pinv_dc_dpos_mom
return mom
constrained.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录