(a_gpu, uplo='L', lib='cusolver')
Cholesky factorization.

    Performs an in-place Cholesky factorization on the matrix `a`
    such that `a = x*x.T` or `x.T*x`, if the lower='L' or upper='U'
    triangle of `a` is used, respectively. All other entries in `a` are set to 0.

    Parameters
    ----------
    a_gpu : pycuda.gpuarray.GPUArray
        Input matrix of shape `(m, m)` to decompose.
    uplo : {'U', 'L'}
        Use upper or lower (default) triangle of 'a_gpu'
    lib : str
        Library to use. May be either 'cula' or 'cusolver' (default).

    Notes
    -----
    If using CULA, double precision is only supported if the standard version of the
    CULA Dense toolkit is installed.

    Examples
    --------
    >>> import pycuda.gpuarray as gpuarray
    >>> import pycuda.autoinit
    >>> import numpy as np
    >>> import scipy.linalg
    >>> import skcuda.linalg as linalg
    >>> linalg.init()
    >>> a = np.array([[3.0,0.0],[0.0,7.0]])
    >>> a = np.asarray(a, np.float64)
    >>> a_gpu = gpuarray.to_gpu(a)
    >>> cholesky(a_gpu)
    >>> np.allclose(a_gpu.get(), scipy.linalg.cholesky(a)[0])
    True
Cholesky factorization.
Cholesky factorization .
def cholesky(a_gpu, uplo='L', lib='cusolver'):
    """
    Cholesky factorization.

    Performs an in-place Cholesky factorization on the matrix `a`
    such that `a = x*x.T` or `x.T*x`, if the lower='L' or upper='U'
    triangle of `a` is used, respectively. All other entries in `a` are set to 0.

    Parameters
    ----------
    a_gpu : pycuda.gpuarray.GPUArray
        Input matrix of shape `(m, m)` to decompose.
    uplo : {'U', 'L'}
        Use upper or lower (default) triangle of 'a_gpu'
    lib : str
        Library to use. May be either 'cula' or 'cusolver' (default).

    Notes
    -----
    If using CULA, double precision is only supported if the standard version of the
    CULA Dense toolkit is installed.

    Examples
    --------
    >>> import pycuda.gpuarray as gpuarray
    >>> import pycuda.autoinit
    >>> import numpy as np
    >>> import scipy.linalg
    >>> import skcuda.linalg as linalg
    >>> linalg.init()
    >>> a = np.array([[3.0,0.0],[0.0,7.0]])
    >>> a = np.asarray(a, np.float64)
    >>> a_gpu = gpuarray.to_gpu(a)
    >>> cholesky(a_gpu)
    >>> np.allclose(a_gpu.get(), scipy.linalg.cholesky(a)[0])
    True
    """

    if a_gpu.dtype == np.float32:
        use_double = 0
        use_complex = 0
    elif a_gpu.dtype == np.float64:
        use_double = 1
        use_complex = 0
    elif a_gpu.dtype == np.complex64:
        use_double = 0
        use_complex = 1
    elif a_gpu.dtype == np.complex128:
        use_double = 1
        use_complex = 1
    else:
        raise ValueError('unrecognized type')

    cho_factor(a_gpu, uplo, lib)

    N = a_gpu.shape[0]
    dev = misc.get_current_device()
    block_dim, grid_dim = misc.select_block_grid_sizes(dev, a_gpu.shape)

    # Zero out the opposite triangle of the matrix
    if cublas._CUBLAS_FILL_MODE[uplo] == 0: # 0 == L
        func = _get_triu_kernel(use_double, use_complex, cols=N)
    else:
        func = _get_tril_kernel(use_double, use_complex, cols=N)

    func(a_gpu, np.uint32(a_gpu.size),
         block=block_dim,
         grid=grid_dim)
def cholesky ( a_gpu , uplo = 'L' , lib = 'cusolver' ) : if a_gpu . dtype == np . float32 : use_double = 0 use_complex = 0 elif a_gpu . dtype == np . float64 : use_double = 1 use_complex = 0 elif a_gpu . dtype == np . complex64 : use_double = 0 use_complex = 1 elif a_gpu . dtype == np . complex128 : use_double = 1 use_complex = 1 else : raise ValueError ( 'unrecognized type' ) cho_factor ( a_gpu , uplo , lib ) N = a_gpu . shape [ 0 ] dev = misc . get_current_device ( ) block_dim , grid_dim = misc . select_block_grid_sizes ( dev , a_gpu . shape ) # Zero out the opposite triangle of the matrix if cublas . _CUBLAS_FILL_MODE [ uplo ] == 0 : # 0 == L func = _get_triu_kernel ( use_double , use_complex , cols = N ) else : func = _get_tril_kernel ( use_double , use_complex , cols = N ) func ( a_gpu , np . uint32 ( a_gpu . size ) , block = block_dim , grid = grid_dim )