本文整理汇总了Python中pysgpp.DataVector.resize方法的典型用法代码示例。如果您正苦于以下问题:Python DataVector.resize方法的具体用法?Python DataVector.resize怎么用?Python DataVector.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysgpp.DataVector
的用法示例。
在下文中一共展示了DataVector.resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: nonsymmetric
# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import resize [as 别名]
# create regular grid, level 3
level = 3
gridGen = grid.createGridGenerator()
gridGen.regular(level)
print "number of initial grid points: {}".format(gridStorage.size())
# definition of function to interpolate - nonsymmetric(!)
f = lambda x0, x1: 16.0 * (x0-1)*x0 * (x1-1)*x1*x1
# create coefficient vector
alpha = DataVector(gridStorage.size())
print "length of alpha vector: {}".format(alpha.getSize())
# now refine adaptively 5 times
for refnum in range(5):
# set function values in alpha
for i in xrange(gridStorage.size()):
gp = gridStorage.get(i)
alpha[i] = f(gp.getCoord(0), gp.getCoord(1))
# hierarchize
createOperationHierarchisation(grid).doHierarchisation(alpha)
# refine a single grid point each time
gridGen.refine(SurplusRefinementFunctor(alpha, 1))
print "refinement step {}, new grid size: {}".format(refnum+1, gridStorage.size())
# extend alpha vector (new entries uninitialized)
alpha.resize(gridStorage.size())