scikits.cuda.linalg.tril

scikits.cuda.linalg.tril(a_gpu, overwrite=True, handle=None)[source]

Lower triangle of a matrix.

Return the lower triangle of a square matrix.

Parameters:

a_gpu : pycuda.gpuarray.GPUArray

Input matrix of shape (m, m)

overwrite : boolean

If true (default), zero out the upper triangle of the matrix. If false, return the result in a newly allocated matrix.

handle : int

CUBLAS context. If no context is specified, the default handle from scikits.cuda.misc._global_cublas_handle is used.

Returns:

l_gpu : pycuda.gpuarray

The lower triangle of the original matrix.

Examples

>>> import pycuda.driver as drv
>>> import pycuda.gpuarray as gpuarray
>>> import pycuda.autoinit
>>> import numpy as np
>>> import linalg
>>> linalg.init()
>>> a = np.asarray(np.random.rand(4, 4), np.float32)
>>> a_gpu = gpuarray.to_gpu(a)
>>> l_gpu = linalg.tril(a_gpu, False)
>>> np.allclose(np.tril(a), l_gpu.get())
True