matrixfunctions.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:crnpy 作者: etonello 项目源码 文件源码
def _pos_dependent(matrix, vector):
    """Check if vector can be written as a positive linear combination of
    the columns of matrix.
    Return the coeffients if possible, None otherwise."""
    if len(matrix) > 0:
        coeffs = Matrix(list(map(lambda i: Symbol("x" + str(i)), range(len(matrix)))))
        sols = solve(Matrix(matrix).T * coeffs - Matrix(vector), coeffs, dict = True, particular = True)
        for sol in sols:
            if all([sol[s] >= 0 for s in sol]):
                return [sol[s] if s in sol else 0 for s in coeffs]
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号