This example illustrates how to compute the eigenvalues
Matrix
The results are verified by filling in the equation we wanted to solve:
The application has an optional argument:
-
-n <n>
with size of the$n \times n$ matrix$A$ . The default value is3
.
- Parse command line arguments for dimensions of the input matrix.
- Declare the host side inputs and outputs.
- Initialize a random symmetric
$n \times n$ input matrix. - Set the solver parameters.
- Allocate device memory and copy input matrix from host to device.
- Initialize rocBLAS.
- Allocate the required working space on device.
- Compute the eigenvector and eigenvalues.
- Retrieve the results by copying from device to host.
- Print the results
- Validate the results
- Free the memory allocations on device.
-
rocblas_create_handle(...)
initializes rocblas. -
rocsolver_[sd]syev(...)
computes the eigenvalue and optional eigenvector.-
There are 2 different function signatures depending on the type of the input matrix:
-
s
single-precision real (float
) -
d
double-precision real (double
)
For single- and double-precision complex values, the function
rocsolver_[cz]heev(...)
is available in rocSOLVER. -
-
-
rocblas_evect
: specifies how the eigenvectors are computed.-
rocblas_evect_original
: compute the eigenvalues and eigenvectors -
rocblas_evect_tridiagonal
: compute eigenvectors for the symmetric tri-diagonal matrix. However, this is currently not supported. -
rocblas_evect_none
: no eigenvectors are computed.
-
-
rocblas_fill
: specifies which part of$A$ to use.-
rocblas_fill_lower
: data is stored in the lower triangle of$A$ . -
rocblas_fill_upper
: data is stored in the upper triangle of$A$ .
-
rocblas_evect
rocblas_evect_original
rocsolver_dsyev
rocblas_create_handle
rocblas_destroy_handle
rocblas_double
rocblas_fill
rocblas_fill_lower
rocblas_handle
rocblas_int
hipFree
hipMalloc
hipMemcpy
hipMemcpyHostToDevice
hipMemcpyDeviceToHost