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


Python DataVector.mult方法代码示例

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


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

示例1: __computeRanking

# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import mult [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: gradient_fun

# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import mult [as 别名]
    def gradient_fun(self, params):
        '''
        Compute the gradient vector in the current state
        '''
        #import ipdb; ipdb.set_trace() #
        gradient_array = np.empty((self.batch_size, self.grid.getSize()))
        for sample_idx in xrange(self.batch_size):
            x = self._lastseen[sample_idx, :self.dim]
            y = self._lastseen[sample_idx, self.dim]
            params_DV = DataVector(params)
            
            gradient = DataVector(len(params_DV))
            
            single_alpha = DataVector(1)
            single_alpha[0] = 1
            
            data_matrix = DataMatrix(x.reshape(1,-1))
        
            mult_eval = createOperationMultipleEval(self.grid, data_matrix);
            mult_eval.multTranspose(single_alpha, gradient);
         
            residual = gradient.dotProduct(params_DV) - y;
            gradient.mult(residual);
            #import ipdb; ipdb.set_trace() #

            gradient_array[sample_idx, :] =  gradient.array()
        return gradient_array
开发者ID:mlocs,项目名称:ipython-nb,代码行数:29,代码来源:wrappers.py

示例3: computePiecewiseConstantBilinearForm

# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import mult [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.mult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。