本文整理汇总了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()
示例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