Trouble with GEQRF

General CULA Dense (LAPACK & BLAS) support and troubleshooting. Use this forum if you are having a general problem or have encountered a bug.

Trouble with GEQRF

Postby ssau » Thu Apr 24, 2014 4:27 am

Here is my example which compares QR decomposition performed by numpy with CULA implementation. I did this according to advise in viewtopic.php?f=14&t=932
Code:
Code: Select all
from PyCULA.cula import culaInitialize,culaShutdown
from PyCULA.cula import gpu_geqrf, gpu_orgqr

import numpy as np

import time
import sys

def test_numpy(A):
    Q, R = np.linalg.qr(A)
    print "Q"
    print Q
    print "R"
    print R
    print "transpose(Q)*Q"
    print np.dot(np.transpose(Q), Q)
    print "Q*R"
    print np.dot(Q,R)

def test_cula(A):
    culaInitialize()
    QR, TAU = gpu_geqrf(A)
    R = np.triu(QR)
    Q = gpu_orgqr(QR, A.shape[0], TAU)
    culaShutdown()
    print "Q"
    print Q
    print "R"
    print R
    print "transpose(Q)*Q"
    print np.dot(np.transpose(Q), Q)
    print "Q*R"
    print np.dot(Q,R)

def main():
    rows = int(sys.argv[1])
    cols = int(sys.argv[2])
    A = np.array(np.ones((rows,cols)).astype(np.float64))
    print "A"
    print A
    print "NUMPY"
    test_numpy(A.copy())
    print "CULA"
    test_cula(A.copy())

if __name__ == '__main__':
    main()


Output:
Code: Select all
A
[[ 1.  1.  1.]
[ 1.  1.  1.]
[ 1.  1.  1.]]
NUMPY
Q
[[-0.57735027 -0.57735027 -0.57735027]
[-0.57735027  0.78867513 -0.21132487]
[-0.57735027 -0.21132487  0.78867513]]
R
[[-1.73205081 -1.73205081 -1.73205081]
[ 0.          0.          0.        ]
[ 0.          0.          0.        ]]
transpose(Q)*Q
[[  1.00000000e+00   2.77555756e-17   0.00000000e+00]
[  2.77555756e-17   1.00000000e+00   0.00000000e+00]
[  0.00000000e+00   0.00000000e+00   1.00000000e+00]]
Q*R
[[ 1.  1.  1.]
[ 1.  1.  1.]
[ 1.  1.  1.]]
CULA
Q
[[-0.57735027 -0.57735027 -0.57735027]
[-0.57735027  0.78867513 -0.21132487]
[-0.57735027 -0.21132487  0.78867513]]
R
[[-1.73205081  0.3660254   0.3660254 ]
[-0.          0.          0.        ]
[-0.          0.          0.        ]]
transpose(Q)*Q
[[  1.00000000e+00   2.77555756e-17   0.00000000e+00]
[  2.77555756e-17   1.00000000e+00   0.00000000e+00]
[  0.00000000e+00   0.00000000e+00   1.00000000e+00]]
Q*R
[[ 1.         -0.21132487 -0.21132487]
[ 1.         -0.21132487 -0.21132487]
[ 1.         -0.21132487 -0.21132487]]

Why CULA returns incorrect result? Is it my fault?
ssau
 
Posts: 1
Joined: Thu Oct 28, 2010 2:15 am

Return to CULA Dense Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron