skcuda.linalg.tril

skcuda.linalg.tril(a_gpu, overwrite=False, 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 (bool (default: False)) – If true, 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 skcuda.misc._global_cublas_handle is used.
Returns:

l_gpu – The lower triangle of the original matrix.

Return type:

pycuda.gpuarray

Examples

>>> import pycuda.autoinit
>>> import pycuda.driver as drv
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> import skcuda.linalg as 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