当前位置: 首页>>代码示例>>Python>>正文


Python DataVector.add方法代码示例

本文整理汇总了Python中pysgpp.DataVector.add方法的典型用法代码示例。如果您正苦于以下问题:Python DataVector.add方法的具体用法?Python DataVector.add怎么用?Python DataVector.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysgpp.DataVector的用法示例。


在下文中一共展示了DataVector.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __computeRanking

# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import add [as 别名]
    def __computeRanking(self, v, w, A, b):
        """
        Compute ranking for variance estimation

        \argmax_{i \in \A} | w (2 Av + wb) |

        @param v: DataVector, coefficients of known grid points
        @param w: DataVector, estimated coefficients of unknown grid points
        @param A: DataMatrix, stiffness matrix
        @param b: DataVector, squared expectation value contribution
        @return: numpy array, contains the ranking for the given samples
        """
        # update the ranking
        av = DataVector(A.getNrows())
        av.setAll(0.0)
        # = Av
        for i in xrange(A.getNrows()):
            for j in xrange(A.getNcols()):
                av[i] += A.get(i, j) * v[j]
        av.mult(2.)  # 2 * Av
        b.componentwise_mult(w)  # w * b
        av.add(b)  # 2 * Av + w * b
        w.componentwise_mult(av)  # = w * (2 * Av + w * b)
        w.abs()  # = | w * (2 * Av + w * b) |

        return w.array()
开发者ID:ABAtanasov,项目名称:Sparse-Grids,代码行数:28,代码来源:RefinementStrategy.py

示例2: computePiecewiseConstantBilinearForm

# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import add [as 别名]
def computePiecewiseConstantBilinearForm(grid, U):
    # create bilinear form of the grid
    gs = grid.getStorage()
    A = DataMatrix(gs.size(), gs.size())
    createOperationLTwoDotExplicit(A, grid)
    # multiply the entries with the pdf at the center of the support
    p = DataVector(gs.dim())
    q = DataVector(gs.dim())

    for i in xrange(gs.size()):
        gs.get(i).getCoords(p)
        for j in xrange(gs.size()):
            gs.get(j).getCoords(q)
            # compute center of the support
            p.add(q)
            p.mult(0.5)
            # multiply the entries in A with the pdf at p
            y = float(A.get(i, j) * U.pdf(p))
            A.set(i, j, y)
            A.set(j, i, y)

    return A
开发者ID:ABAtanasov,项目名称:Sparse-Grids,代码行数:24,代码来源:bilinear_form.py


注:本文中的pysgpp.DataVector.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。