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


Python linalg.rq函数代码示例

本文整理汇总了Python中scipy.linalg.rq函数的典型用法代码示例。如果您正苦于以下问题:Python rq函数的具体用法?Python rq怎么用?Python rq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_random

 def test_random(self):
     n = 20
     for k in range(2):
         a = random([n,n])
         r,q = rq(a)
         assert_array_almost_equal(dot(transpose(q),q),identity(n))
         assert_array_almost_equal(dot(r,q),a)
开发者ID:dagss,项目名称:private-scipy-refactor,代码行数:7,代码来源:test_decomp.py

示例2: test_random_complex

 def test_random_complex(self):
     n = 20
     for k in range(2):
         a = random([n,n])+1j*random([n,n])
         r,q = rq(a)
         assert_array_almost_equal(dot(q, conj(transpose(q))),identity(n))
         assert_array_almost_equal(dot(r,q),a)
开发者ID:BeeRad-Johnson,项目名称:scipy-refactor,代码行数:7,代码来源:test_decomp.py

示例3: test_random_tall

 def test_random_tall(self):
     m = 200
     n = 100
     for k in range(2):
         a = random([m,n])
         r,q = rq(a)
         assert_array_almost_equal(dot(q, transpose(q)),identity(n))
         assert_array_almost_equal(dot(r,q),a)
开发者ID:BeeRad-Johnson,项目名称:scipy-refactor,代码行数:8,代码来源:test_decomp.py

示例4: factor

def factor(P):
    K, R = linalg.rq(P[:, :3])
    T = np.diag(np.sign(np.diag(K)))
    if linalg.det(T) < 0:
        T[1, 1] *= -1

    K = np.dot(K, T)
    R = np.dot(T, R)
    t = np.dot(linalg.inv(K), P[:, 3])
    return K, R, t
开发者ID:Nate711,项目名称:TurbidityVideoProcessing,代码行数:10,代码来源:GPSCoorTest.py

示例5: test_random_complex_economic

 def test_random_complex_economic(self):
     m = 100
     n = 200
     for k in range(2):
         a = random([m,n])+1j*random([m,n])
         r,q = rq(a, mode='economic')
         assert_array_almost_equal(dot(q,conj(transpose(q))),identity(m))
         assert_array_almost_equal(dot(r,q),a)
         assert_equal(q.shape, (m, n))
         assert_equal(r.shape, (m, m))
开发者ID:BeeRad-Johnson,项目名称:scipy-refactor,代码行数:10,代码来源:test_decomp.py

示例6: factor

	def factor(self):
		""" Factorize the camera matrix into K,R,t as P = K[R|t]. """
		# factor first 3*3 part
		K,R = linalg.rq(self.P[:,:3])
		# make diagonal of K positive
		T = diag(sign(diag(K)))
		if linalg.det(T) < 0:
			T[1,1] *= -1
		self.K = dot(K,T)
		self.R = dot(T,R) # T is its own inverse
		self.t = dot(linalg.inv(self.K),self.P[:,3])
		return self.K, self.R, self.t
开发者ID:maxschommer,项目名称:Multirotors,代码行数:12,代码来源:camera.py

示例7: factor

def factor(self):

    K,R = linalg.rq(self.P[:,:3])
    T = diag(sign(diag(K)))
    if linalg.det(T) < 0:
        T[1,1] *= -1

    self.K = dot(K,T)
    self.R = dot(T,R)
    self.t = dot(linalg.inv(self.K), self.P[:,:3])

    return self.K, self.R, self.t
开发者ID:GumpCode,项目名称:CodemySummer,代码行数:12,代码来源:camera.py

示例8: factor

 def factor(self):
     """Factorize the camera matrix into K, R, t as P=K[P|t]"""
     K,R = linalg.rq(self.P[:,:3])
     #make diagonal of K positive
     T = np.diag(np.sign(np.diag(K)))
     if linalg.det(T)<0:
         T[1,1]*=-1
         
     self.K = np.dot(K,T)
     self.R = np.dot(T,R)
     self.t = np.dot(linalg.inv(self.K),self.P[:,3])
     
     return self.K, self.R, self.t
开发者ID:rayjim,项目名称:python_proj,代码行数:13,代码来源:camera.py

示例9: factor

 def factor(self):
     """ P = K[R|t]に従い、カメラ行列を K,R,tに分解する """
     # 最初の3*3の部分を分解する
     K,R = linalg.rq(self.P[:,:3])
     
     # Kの対角成分が正になるようにする。
     T = np.diag(np.sign(np.diag(K)))
     if linalg.det(T) < 0:
         T[1,1] *= -1
         
     self.K = np.dot(K,T)
     self.R = np.dot(T,R) # Tはそれ自身が逆行列
     self.t = np.dot(linalg.inv(self.K),self.P[:,3])
         
     return self.K, self.R, self.t
开发者ID:ta-oyama,项目名称:PCV,代码行数:15,代码来源:camera.py

示例10: extract_KRt

def extract_KRt(P):
	"""Based on http://www.janeriksolem.net/2011/03/rq-factorization-of-camera-matrices.html"""
	H = P[0:3, 0:3]
	K, R = rq(H)
	T = np.diag(np.sign(np.diag(K)))
	K = np.dot(K,T)
	R = np.dot(T,R)
	t = np.dot(np.linalg.inv(K), P[:,-1])

	if np.linalg.det(R) < 0 :
		R = np.dot(R, -1 * np.eye(3))
		t = np.dot(-1 * np.eye(3), t)

	K = K/K[-1,-1]

	return K,R,t
开发者ID:srajotte,项目名称:visiontk,代码行数:16,代码来源:algo.py

示例11: retr

    def retr(self, X, Z):
        XU, XS, XV = X
        ZUp, ZM, ZVp = Z
        Qu, Ru = la.qr(ZUp)
        Rv, Qv = rq(ZVp, mode='economic')

        zero_block = np.zeros((Ru.shape[0], Rv.shape[1]))
        block_mat = np.array(np.bmat([[XS + ZM, Rv],
                                     [Ru, zero_block]]))

        Ut, St, Vt = la.svd(block_mat, full_matrices=False)

        U = np.hstack((XU, Qu)).dot(Ut[:, :self._k])
        V = Vt[:self._k, :].dot(np.vstack((XV, Qv)))
        # add some machinery eps to get a slightly perturbed element of a manifold
        # even if we have some zeros in S
        S = np.diag(St[:self._k]) + np.diag(np.spacing(1) * np.ones(self._k))
        return (U, S, V)
开发者ID:Nehoroshiy,项目名称:logmat_riemannian,代码行数:18,代码来源:fixed_rank.py

示例12: factor

    def factor(self, K=None):
        """    Factorize the camera matrix into K,R,t as P = K[R|t]. """
        if K is not None:
            # factor first 3*3 part
            K,R = linalg.rq(self.P[:,:3])

            # make diagonal of K positive
            T = diag(sign(diag(K)))
            if linalg.det(T) < 0:
                T[1,1] *= -1

            self.K = dot(K,T)
            self.R = dot(T,R) # T is its own inverse
            self.t = dot(linalg.inv(self.K),self.P[:,3])

            return self.K, self.R, self.t
        else:
            print("K")
            print(self.K)
            print("Kinv")
            Kinv = linalg.inv(self.K)
            print(Kinv)
            Pose = dot(Kinv, self.P)
开发者ID:mirwox,项目名称:robotica16,代码行数:23,代码来源:camera.py

示例13: RDU

def RDU(A): # Calculate the RDU decomposition of a matrix {{{
    r,U = rq(A)
    d = numpy.diagonal(r)
    R = r / d[newaxis,:]
    D = diagflat(d)
    return R,D,U #}}}
开发者ID:SuperFluffy,项目名称:DeerQMC,代码行数:6,代码来源:math_functions.py

示例14: decomposeQR

    def decomposeQR(self, gl=None, order='qr'):
        """
        Decomposes gl using QR decomposition into:

          gl = q p s m (order 'qr' or 'qpsm') 
          gl = p s m q (order 'rq' or 'psmq')

        where:
          - q: rotation (orthogonal, with det +1) matrix
          - p: parity (diagonal, all elements +1, except that the element 
          corresponding to self.parity_axismatrix can be -1)
          possibly -1
          - s: scale martix, diagonal and positive
          - m: shear matrix, upper triangular, all diagonal elements 1

        Arguments:
          - gl: (ndarray) general linear transformation
          - order: decomposition order 'qr' or 'rq'

        Returns: (q, p, s, m)
        """

        # set decomposition type
        self.order = order

        # parse arg
        if gl is None:
            gl = self.gl
        ndim = gl.shape[0]

        # QR decompose 
        if (order == 'rq') or (order == 'psmq'):
            r, q = linalg.rq(gl)
        elif (order == 'qr') or (order == 'qpsm'):
            q, r = linalg.qr(gl)
        else:
            ValueError("Argumnet order: ", order, " not understood. It should ",
                       "be 'psmq' (same as 'rq') or 'qpsm' (same as 'qr').")

        # extract s, p and m
        r_diag = r.diagonal()
        s_diag = numpy.abs(r_diag)
        s = numpy.diag(s_diag)
        p_diag = numpy.sign(r_diag)
        p = numpy.diag(p_diag)
        s_inv_diag = 1. * p_diag / s_diag
        m = numpy.dot(numpy.diag(s_inv_diag), r)

        # make q = q p and p = 1
        if (order == 'rq') or (order == 'psmq'):
            m = numpy.dot(numpy.dot(p, m), p)
            q = numpy.dot(p, q)
        elif (order == 'qr') or (order == 'qpsm'):
            q = numpy.dot(q, p)
        p = numpy.abs(p)

        # make sure det(q) > 0 and adjust p accordingly
        if linalg.det(q) < 0:
            p = numpy.identity(ndim, dtype=int)
            p[self.parity_axis, self.parity_axis] = -1
            if (order == 'rq') or (order == 'psmq'):
                q = numpy.dot(p, q)
                m = numpy.dot(numpy.dot(p, m), p)
            elif (order == 'qr') or (order == 'qpsm'):
                q = numpy.dot(q, p)

        return q, p, s, m
开发者ID:Splo0sh,项目名称:3DCT,代码行数:67,代码来源:affine.py

示例15: test_simple

 def test_simple(self):
     a = [[8,2,3],[2,9,3],[5,3,6]]
     r,q = rq(a)
     assert_array_almost_equal(dot(transpose(q),q),identity(3))
     assert_array_almost_equal(dot(r,q),a)
开发者ID:dagss,项目名称:private-scipy-refactor,代码行数:5,代码来源:test_decomp.py


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