core.py 文件源码

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

项目:pyinduct 作者: pyinduct 项目源码 文件源码
def calculate_expanded_base_transformation_matrix(src_base, dst_base, src_order, dst_order, use_eye=False):
    """
    constructs a transformation matrix from basis given by 'src_base' to basis given by 'dst_base' that also
    transforms all temporal derivatives of the given weights.

    :param src_base: the source basis, given by an array of BaseFractions
    :param dst_base: the destination basis, given by an array of BaseFractions
    :param src_order: temporal derivative order available in src
    :param dst_order: temporal derivative order needed in dst
    :param use_eye: use identity as base transformation matrix
    :return: transformation matrix as 2d np.ndarray
    """
    if src_order < dst_order:
        raise ValueError("higher derivative order needed than provided!")

    # build core transformation
    if use_eye:
        core_transformation = np.eye(src_base.size)
    else:
        core_transformation = calculate_base_transformation_matrix(src_base, dst_base)

    # build block matrix
    part_transformation = block_diag(*[core_transformation for i in range(dst_order + 1)])
    complete_transformation = np.hstack([part_transformation] + [np.zeros((part_transformation.shape[0], src_base.size))
                                                                 for i in range(src_order - dst_order)])
    return complete_transformation
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号