This example illustrates how to compute the eigenvalues hipsolver[CZ]heevj
.
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 hipSOLVER.
- Query the required working space and allocate this 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.
- hipSOLVER (
hipsolverHandle_t
) gets initialized byhipsolverCreate
and destroyed byhipsolverDestroy
. -
hipsolverEigMode_t
: specifies whether only the eigenvalues or also the eigenvectors should be computed. Passed tohipsolverDsyevj
asjobz
.-
HIPSOLVER_EIG_MODE_VECTOR
: compute the eigenvalues and eigenvectors. -
HIPSOLVER_EIG_MODE_NOVECTOR
: only compute the eigenvalues.
-
-
hipsolverFillMode_t
: specifies which part of$A$ to use.-
HIPSOLVER_FILL_MODE_LOWER
: data is stored in the lower triangle of$A$ . -
HIPSOLVER_FILL_MODE_UPPER
: data is stored in the upper triangle of$A$ .
-
-
hipsolverCreateSyevjInfo
: initializes a structure for the parameters and results for callingsyevj
. -
hipsolverDestroySyevjInfo
: destroys the structure for the parameters and results for callingsyevj
. -
hipsolverXsyevjSetMaxSweeps
: configures the max amounts of sweeps -
hipsolverXsyevjSetTolerance
: configures the tolerance ofsyevj
. -
hipsolverXsyevjSetSortEig
: configures whether to sort the results or not -
hipsolver[SD]sygvj_bufferSize
computes the required buffersizelwork
from a given configuration. -
hipsolver[SD]syevj
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
hipsolver[CZ]heevj(...)
is available in hipSOLVER.For example,
hipsolverDsyevj(...)
works ondouble
s. For the complex datatypes seehipsolver[CZ]heevj
. -
-
hipsolverHandle_t handle
: hipSOLVER handle, seehipsolverCreate
-
hipsolverEigMode_t jobz
: eigenvector output mode, seehipsolverEigMode_t
. -
hipsolverFillMode_t uplo
: fill mode of$A$ , seehipsolverFillMode_t
. -
int n
: number of columns of$A$ . -
double* A
: pointer to the input matrix$A$ on device memory. -
int lda
: leading dimension of$A$ . -
double* W
: pointer to the output$W$ for the eigenvalues. -
double* work
: pointer to the working space. -
int lwork
: size of the working space. -
int* info
: pointer to write the convergence result to. -
syevjInfo_t params
: the structure for the parameters and results forsyevj
.
-
-
hipsolverXsyevjGetSweeps
: gets the amount of executed sweeps ofsyevj
. -
hipsolverXsyevjGetResidual
: gets the residual ofsyevj
.
hipsolverCreate
hipsolverDestroy
hipsolverCreateSyevjInfo
hipsolverDestroySyevjInfo
hipsolverDsyevj
hipsolverDsyevj_bufferSize
hipsolverXsyevjGetResidual
hipsolverXsyevjGetSweeps
hipsolverXsyevjSetMaxSweeps
hipsolverXsyevjSetSortEig
hipsolverXsyevjSetTolerance
hipsolverEigMode_t
hipsolverFillMode_t
hipsolverHandle_t
hipsolverSyevjInfo_t
HIPSOLVER_EIG_MODE_VECTOR
HIPSOLVER_FILL_MODE_LOWER
hipFree
hipMalloc
hipMemcpy
hipMemcpyDeviceToHost
hipMemcpyHostToDevice