當前位置: 首頁>>代碼示例>>Python>>正文


Python dual.inv方法代碼示例

本文整理匯總了Python中numpy.dual.inv方法的典型用法代碼示例。如果您正苦於以下問題:Python dual.inv方法的具體用法?Python dual.inv怎麽用?Python dual.inv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.dual的用法示例。


在下文中一共展示了dual.inv方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _cov2wt

# 需要導入模塊: from numpy import dual [as 別名]
# 或者: from numpy.dual import inv [as 別名]
def _cov2wt(self, cov):
        """ Convert covariance matrix(-ices) to weights.
        """

        from numpy.dual import inv

        if len(cov.shape) == 2:
            return inv(cov)
        else:
            weights = numpy.zeros(cov.shape, float)

            for i in range(cov.shape[-1]):  # n
                weights[:,:,i] = inv(cov[:,:,i])

            return weights 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:17,代碼來源:odrpack.py

示例2: getI

# 需要導入模塊: from numpy import dual [as 別名]
# 或者: from numpy.dual import inv [as 別名]
def getI(self):
        """
        Returns the (multiplicative) inverse of invertible `self`.

        Parameters
        ----------
        None

        Returns
        -------
        ret : matrix object
            If `self` is non-singular, `ret` is such that ``ret * self`` ==
            ``self * ret`` == ``np.matrix(np.eye(self[0,:].size)`` all return
            ``True``.

        Raises
        ------
        numpy.linalg.LinAlgError: Singular matrix
            If `self` is singular.

        See Also
        --------
        linalg.inv

        Examples
        --------
        >>> m = np.matrix('[1, 2; 3, 4]'); m
        matrix([[1, 2],
                [3, 4]])
        >>> m.getI()
        matrix([[-2. ,  1. ],
                [ 1.5, -0.5]])
        >>> m.getI() * m
        matrix([[ 1.,  0.],
                [ 0.,  1.]])

        """
        M, N = self.shape
        if M == N:
            from numpy.dual import inv as func
        else:
            from numpy.dual import pinv as func
        return asmatrix(func(self)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:45,代碼來源:defmatrix.py


注:本文中的numpy.dual.inv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。