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


Python numpy.inv方法代码示例

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


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

示例1: invMassMatrix

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import inv [as 别名]
def invMassMatrix(obj):
    """Returns the inverse of obj's generalized mass matrix
      [H 0 ]-1
      [0 mI]
    about the origin."""
    Hinv = numpy.zeros((6,6))
    if obj == None or isinstance(obj,TerrainModel):
        #infinite inertia
        return Hinv
    if isinstance(obj,RobotModel):
        return obj.getMassMatrixInv()
    m = obj.getMass()
    minv = 1.0/m.mass
    Hinv[3,3]=Hinv[4,4]=Hinv[5,5]=minv
    #offset the inertia matrix about the COM
    H = numpy.array((3,3))
    H[0,:] = numpy.array(m.inertia[0:3])
    H[1,:] = numpy.array(m.inertia[3:6])
    H[2,:] = numpy.array(m.inertia[6:9])
    H -= skew(m.com)*skew(m.com)*m.mass
    Hinv[0:3,0:3] = numpy.inv(H)
    return Hinv 
开发者ID:krishauser,项目名称:pyOptimalMotionPlanning,代码行数:24,代码来源:contact.py

示例2: calcCMat

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import inv [as 别名]
def calcCMat(self, callback=None, progressCallback=None):

        nSlopes = self.wfss[0].activeSubaps*2

        self.controlShape = (nSlopes, self.sim_config.totalActs)
        self.controlMatrix = numpy.zeros((nSlopes, self.sim_config.totalActs))
        acts = 0
        for dm in xrange(self.sim_config.nDM):
            dmIMat = self.dms[dm].iMat

            if dmIMat.shape[0]==dmIMat.shape[1]:
                dmCMat = numpy.inv(dmIMat)
            else:
                dmCMat = numpy.linalg.pinv(dmIMat, self.dmConds[dm])

            self.controlMatrix[:,acts:acts+self.dms[dm].n_acts] = dmCMat
            acts += self.dms[dm].n_acts 
开发者ID:AOtools,项目名称:soapy,代码行数:19,代码来源:reconstruction.py

示例3: estimator_fn

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import inv [as 别名]
def estimator_fn(cls, x_p, y_p):
        # Recall beta = np.inv(X.T @ X) * (X.T @ y)
        yy_p = tf.matmul(y_p, y_p, transpose_a=True)  # per-party y.T @ y
        xy_p = tf.matmul(x_p, y_p, transpose_a=True)  # per-party X.T @ y
        xx_p = tf.matmul(x_p, x_p, transpose_a=True)  # per-party X.T @ X
        return yy_p, xy_p, xx_p 
开发者ID:tf-encrypted,项目名称:tf-encrypted,代码行数:8,代码来源:regressor.py

示例4: fit

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import inv [as 别名]
def fit(self, training_players, summary=0, validation_split=None):
        """Trains the linear regressor.

    Arguments:
      training_players: Data owners used for joint training. Must implement the
          compute_estimators as a tfe.local_computation.
      summary: Controls what kind of summary statistics are generated after the
          linear regression fit.
      validation_split: Mimics the behavior of the Keras validation_split kwarg.
    """
        if validation_split is not None:
            raise NotImplementedError()

        partial_estimators = [
            player.compute_estimators(self.estimator_fn) for player in training_players
        ]

        for attr, partial_estimator in zip(self.components, zip(*partial_estimators)):
            setattr(self, attr, tfe.add_n(partial_estimator))

        with tfe.Session() as sess:
            for k in self.components:
                op = getattr(self, k)
                setattr(self, k, sess.run(op.reveal()))

        tf_graph = tf.Graph()
        with tf_graph.as_default():
            self._inverted_covariate_square = tf.linalg.inv(self.covariate_square)
            self.coefficients = tf.matmul(
                self._inverted_covariate_square, self.covariate_label_product
            )

        with tf.Session(graph=tf_graph) as sess:
            for k in ["_inverted_covariate_square", "coefficients"]:
                setattr(self, k, sess.run(getattr(self, k)))

        if not summary:
            return self

        return self.summarize(summary_level=summary) 
开发者ID:tf-encrypted,项目名称:tf-encrypted,代码行数:42,代码来源:regressor.py

示例5: LS_Filter

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import inv [as 别名]
def LS_Filter(refChannel, srvChannel, filterLen, reg=1.0, peek=10, 
    return_filter=False):
    '''Block least squares adaptive filter. Computes filter taps using the 
    direct matrix inversion method.  
    
    Parameters:
        refChannel:     Array containing the reference channel signal
        srvChannel:     Array containing the surveillance channel signal
        filterLen:      Length of the least squares filter (in samples)
        reg:            L2 regularization parameter for the matrix inversion 
                        (default 1.0)
        peek:           Number of noncausal filter taps. Set to zero for a 
                        causal filter. If nonzero, clutter estimates can depend 
                        on future values of the reference signal (this helps 
                        sometimes)
        return_filter:  Boolean indicating whether to return the filter taps

    Returns:
        srvChannelFiltered: Surveillance channel signal with clutter removed
        filterTaps:     (optional) least squares filter taps

    '''
    if refChannel.shape != srvChannel.shape:
        raise ValueError('Input vectors must have the same length')

    lags = np.arange(-1*peek, filterLen)
    
    # Create a matrix of time-shited copies of the reference channel signal
    A = np.zeros((refChannel.shape[0], filterLen+peek), dtype=np.complex64)
    for k in range(lags.shape[0]):
        A[:, k] = np.roll(refChannel, lags[k])
    
    # compute the autocorrelation matrix of ref
    ATA = A.conj().T @ A

    # create the Tikhonov regularization matrix
    K = np.eye(ATA.shape[0], dtype=np.complex64)

    # solve the least squares problem
    filterTaps = np.linalg.solve(ATA + K*reg, A.conj().T @ srvChannel)

    # direct but slightly slower implementation:
    # filterTaps = np.inv(ATA + K*reg) @ A.conj().T @ srvChannel

    # Apply the least squares filter to the surveillance channel
    srvChannelFiltered = srvChannel - A @ filterTaps

    if return_filter:
        return srvChannelFiltered, filterTaps
    else:
        return srvChannelFiltered 
开发者ID:Max-Manning,项目名称:passiveRadar,代码行数:53,代码来源:clutter_removal.py


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