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


Python linalg.slogdet方法代码示例

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


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

示例1: do

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def do(self, a, b, tags):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_linalg.py

示例2: do

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def do(self, a, b):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:18,代码来源:test_linalg.py

示例3: test_0_size

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def test_0_size(self):
        a = np.zeros((0, 0), dtype=np.complex64)
        res = linalg.det(a)
        assert_equal(res, 1.)
        assert_(res.dtype.type is np.complex64)
        res = linalg.slogdet(a)
        assert_equal(res, (1, 0))
        assert_(res[0].dtype.type is np.complex64)
        assert_(res[1].dtype.type is np.float32)

        a = np.zeros((0, 0), dtype=np.float64)
        res = linalg.det(a)
        assert_equal(res, 1.)
        assert_(res.dtype.type is np.float64)
        res = linalg.slogdet(a)
        assert_equal(res, (1, 0))
        assert_(res[0].dtype.type is np.float64)
        assert_(res[1].dtype.type is np.float64) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:20,代码来源:test_linalg.py

示例4: initialize

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def initialize(self):
        """ Initialize members for faster scoring. """
        self.ct = self.cw + self.cb
        self.p = inv(self.ct * 0.5) - inv(0.5 * self.cw + self.cb)
        self.q = inv(2 * self.cw) - inv(2 * self.ct)
        k1 = reduce(operator.mul, slogdet(0.5 * self.ct))
        k2 = reduce(operator.mul, slogdet(0.5 * self.cw + self.cb))
        k3 = reduce(operator.mul, slogdet(2 * self.ct))
        k4 = reduce(operator.mul, slogdet(2 * self.cw))
        self.k = 0.5 * (k1 - k2 + k3 - k4)
        self.r = 0.5 * (0.25 * self.p - self.q)
        self.s = 0.5 * (0.25 * self.p + self.q)
        self.t = 0.25 * np.dot(self.p, self.mean.T)
        u1 = 2 * np.dot(self.mean, 0.25 * self.p)
        self.u = self.k + np.dot(u1, self.mean.T)
        self.initialized = True 
开发者ID:Jamiroquai88,项目名称:VBDiarization,代码行数:18,代码来源:gplda.py

示例5: error

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def error(self, start, end):
        """Return the approximation cost on the segment [start:end].

        Args:
            start (int): start of the segment
            end (int): end of the segment

        Returns:
            float: segment cost

        Raises:
            NotEnoughPoints: when the segment is too short (less than ``'min_size'`` samples).
        """
        if end - start < self.min_size:
            raise NotEnoughPoints
        sub = self.signal[start:end]

        if self.signal.shape[1] > 1:
            cov = np.cov(sub.T)
        else:
            cov = np.array([[sub.var()]])
        _, val = slogdet(cov)
        return val * (end - start) 
开发者ID:deepcharles,项目名称:ruptures,代码行数:25,代码来源:costnormal.py

示例6: orientation

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def orientation(face, origin):
    """Compute the orientation of the face with respect to a point, origin.

    Parameters
    ----------
    face : array-like, of shape (N-dim, N-dim)
        The hyperplane we want to know the orientation of
        Do notice that the order in which you provide the points is critical
    origin : array-like, point of shape (N-dim)
        The point to compute the orientation from

    Returns
    -------
    0 if the origin lies in the same hyperplane as face,
    -1 or 1 to indicate left or right orientation

    If two points lie on the same side of the face, the orientation will
    be equal, if they lie on the other side of the face, it will be negated.
    """
    vectors = array(face)
    sign, logdet = slogdet(vectors - origin)
    if logdet < -50:  # assume it to be zero when it's close to zero
        return 0
    return sign 
开发者ID:python-adaptive,项目名称:adaptive,代码行数:26,代码来源:triangulation.py

示例7: test_zero

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import slogdet [as 别名]
def test_zero(self):
        assert_equal(linalg.det([[0.0]]), 0.0)
        assert_equal(type(linalg.det([[0.0]])), double)
        assert_equal(linalg.det([[0.0j]]), 0.0)
        assert_equal(type(linalg.det([[0.0j]])), cdouble)

        assert_equal(linalg.slogdet([[0.0]]), (0.0, -inf))
        assert_equal(type(linalg.slogdet([[0.0]])[0]), double)
        assert_equal(type(linalg.slogdet([[0.0]])[1]), double)
        assert_equal(linalg.slogdet([[0.0j]]), (0.0j, -inf))
        assert_equal(type(linalg.slogdet([[0.0j]])[0]), cdouble)
        assert_equal(type(linalg.slogdet([[0.0j]])[1]), double) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:test_linalg.py


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