numpy.transpose - python examples

Here are the examples of the python api numpy.transpose taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

3 View Complete Implementation : test_decomp_cholesky.py
Copyright MIT License
Author : ktraunmueller
    def test_random_complex(self):
        n = 20
        for k in range(2):
            m = random([n,n])+1j*random([n,n])
            for i in range(n):
                m[i,i] = 20*(.1+abs(m[i,i]))
            a = dot(transpose(conjugate(m)),m)
            c = cholesky(a)
            a1 = dot(transpose(conjugate(c)),c)
            astert_array_almost_equal(a,a1)
            c = transpose(c)
            a = dot(c,transpose(conjugate(c)))
            astert_array_almost_equal(cholesky(a,lower=1),c)

3 View Complete Implementation : colorbar.py
Copyright MIT License
Author : ktraunmueller
    def _outline(self, X, Y):
        '''
        Return *x*, *y* arrays of colorbar bounding polygon,
        taking orientation into account.
        '''
        N = X.shape[0]
        ii = [0, 1, N - 2, N - 1, 2 * N - 1, 2 * N - 2, N + 1, N, 0]
        x = np.take(np.ravel(np.transpose(X)), ii)
        y = np.take(np.ravel(np.transpose(Y)), ii)
        x = x.reshape((len(x), 1))
        y = y.reshape((len(y), 1))
        if self.orientation == 'horizontal':
            return np.hstack((y, x))
        return np.hstack((x, y))

3 View Complete Implementation : test_decomp_cholesky.py
Copyright MIT License
Author : ktraunmueller
    def test_random(self):
        n = 20
        for k in range(2):
            m = random([n,n])
            for i in range(n):
                m[i,i] = 20*(.1+m[i,i])
            a = dot(transpose(m),m)
            c = cholesky(a)
            a1 = dot(transpose(c),c)
            astert_array_almost_equal(a,a1)
            c = transpose(c)
            a = dot(c,transpose(c))
            astert_array_almost_equal(cholesky(a,lower=1),c)

3 View Complete Implementation : test_decomp_cholesky.py
Copyright MIT License
Author : ktraunmueller
    def test_random(self):
        n = 20
        for k in range(2):
            m = random([n,n])
            for i in range(n):
                m[i,i] = 20*(.1+m[i,i])
            a = dot(transpose(m),m)
            c = cholesky(a)
            a1 = dot(transpose(c),c)
            astert_array_almost_equal(a,a1)
            c = transpose(c)
            a = dot(c,transpose(c))
            astert_array_almost_equal(cholesky(a,lower=1),c)

3 View Complete Implementation : test_decomp_cholesky.py
Copyright MIT License
Author : ktraunmueller
    def test_random_complex(self):
        n = 20
        for k in range(2):
            m = random([n,n])+1j*random([n,n])
            for i in range(n):
                m[i,i] = 20*(.1+abs(m[i,i]))
            a = dot(transpose(conjugate(m)),m)
            c = cholesky(a)
            a1 = dot(transpose(conjugate(c)),c)
            astert_array_almost_equal(a,a1)
            c = transpose(c)
            a = dot(c,transpose(conjugate(c)))
            astert_array_almost_equal(cholesky(a,lower=1),c)

3 View Complete Implementation : test_lsmr.py
Copyright MIT License
Author : ktraunmueller
    def setUp(self):
        self.n = 10
        self.A = lowerBidiagonalMatrix(20,self.n)
        self.xtrue = transpose(arange(self.n,0,-1))
        self.Afun = aslinearoperator(self.A)
        self.b = self.Afun.matvec(self.xtrue)
        self.returnValues = lsmr(self.A,self.b)

3 View Complete Implementation : test_fblas.py
Copyright MIT License
Author : ktraunmueller
    def test_y_stride_transpose(self):
        alpha,beta,a,x,y = self.get_data(y_stride=2)
        desired_y = y.copy()
        desired_y[::2] = alpha*matrixmultiply(transpose(a),x)+beta*y[::2]
        y = self.blas_func(alpha,a,x,beta,y,trans=1,incy=2)
        astert_array_almost_equal(desired_y,y)

3 View Complete Implementation : test_decomp_cholesky.py
Copyright MIT License
Author : ktraunmueller
    def test_simple_complex(self):
        m = array([[3+1j,3+4j,5],[0,2+2j,2+7j],[0,0,7+4j]])
        a = dot(transpose(conjugate(m)),m)
        c = cholesky(a)
        a1 = dot(transpose(conjugate(c)),c)
        astert_array_almost_equal(a,a1)
        c = transpose(c)
        a = dot(c,transpose(conjugate(c)))
        astert_array_almost_equal(cholesky(a,lower=1),c)

3 View Complete Implementation : test_regression.py
Copyright MIT License
Author : ktraunmueller
    def test_svd_build(self, level = rlevel):
        """Ticket 627."""
        a = array([[ 0., 1.], [ 1., 1.], [ 2., 1.], [ 3., 1.]])
        m, n = a.shape
        u, s, vh = linalg.svd(a)

        b = dot(transpose(u[:, n:]), a)

        astert_array_almost_equal(b, np.zeros((2, 2)))

3 View Complete Implementation : test_decomp_cholesky.py
Copyright MIT License
Author : ktraunmueller
    def test_simple(self):
        a = [[8,2,3],[2,9,3],[3,3,6]]
        c = cholesky(a)
        astert_array_almost_equal(dot(transpose(c),c),a)
        c = transpose(c)
        a = dot(c,transpose(c))
        astert_array_almost_equal(cholesky(a,lower=1),c)