This example illustrates the use of the rocSOLVER getf2
functionality. The rocSOLVER getf2
computes the LU decomposition of an
-
getf2()
: This is the unblocked Level-2-BLAS version of the LU factorization algorithm. An optimized internal implementation without rocBLAS calls could be executed with small and mid-size matrices. -
$A$ is the$m \times n$ input matrix. -
$P$ is an$m \times m$ permutation matrix, in this example stored as an array of row indicesvector<int> Ipiv
of sizemin(m, n)
. -
$L$ is:- an
$m \times m$ lower triangular matrix, when$m \leq n$ . - an
$m \times n$ lower trapezoidal matrix, when$m > n$ .
- an
-
$U$ is:- an
$m \times n$ upper trapezoidal matrix, when$m < n$ . - an
$n \times n$ upper tridiagonal matrix, when$m \geq n$
- an
- Parse command line arguments for the dimension of the input matrix.
- Declare and initialize a number of constants for the input and output matrices and vectors.
- Allocate and initialize the host matrices and vectors.
- Allocate device memory.
- Copy input data from host to device.
- Create a rocBLAS handle.
- Invoke the rocSOLVER
getf2
function with double precision. - Copy the results from device to host.
- Print trace messages.
- Free device memory and the rocBLAS handle.
-
rocsolver_[sdcz]getf2
computes the LU factorization of the$m \times n$ input matrix$A$ . The correct function signature should be chosen, based on the datatype of the input matrix:-
s
(single-precision:float
) -
d
(double-precision:double
) -
c
(single-precision complex:rocblas_float_complex
) -
z
(double-precision complex:rocblas_double_complex
).
-
Input parameters for the precision used in this example (double-precision):
rocblas_handle handle
-
const rocblas_int m
: number of rows of$A$ -
const rocblas_int n
: number of columns of$A$ -
rocblas_double *A
: pointer to matrix$A$ -
const rocblas_int lda
: leading dimension of matrix$A$ -
rocblas_double *Ipiv
: pointer to vector$Ipiv$ -
rocblas_int *info
: result of the getf2 function. If 0, the factorization succeeded, if greater than 0 then$U$ is singular and$U[info,info]$ is the first zero pivot.
Return type: rocblas_status
rocsolver_dgetf2
rocblas_create_handle
rocblas_destroy_handle
rocblas_double
rocblas_handle
rocblas_int
hipFree
hipMalloc
hipMemcpy
hipMemcpyHostToDevice
hipMemcpyDeviceToHost